Re: [PATCH 09/11] hw/avr/arduino: Replace magic number by gpio_port_index() call

2021-03-13 Thread Philippe Mathieu-Daudé
On 3/13/21 9:02 PM, Richard Henderson wrote: > On 3/13/21 10:54 AM, Philippe Mathieu-Daudé wrote: >> +static unsigned gpio_port_index(char c) >> +{ >> +    assert(c >= 'A' && c < 'A' + GPIO_MAX); >> +    return c - 'A'; >> +} > > If you're not going to use this for anything else, isn't > > #defin

Re: [PATCH 09/11] hw/avr/arduino: Replace magic number by gpio_port_index() call

2021-03-13 Thread Richard Henderson
On 3/13/21 10:54 AM, Philippe Mathieu-Daudé wrote: +static unsigned gpio_port_index(char c) +{ +assert(c >= 'A' && c < 'A' + GPIO_MAX); +return c - 'A'; +} If you're not going to use this for anything else, isn't #define PORT_B 1 enough? r~

[PATCH 09/11] hw/avr/arduino: Replace magic number by gpio_port_index() call

2021-03-13 Thread Philippe Mathieu-Daudé
The '1' magic value means 'Port B'. Introduce and use the gpio_port_index() helper to explicit the port name. Signed-off-by: Philippe Mathieu-Daudé --- hw/avr/arduino.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/avr/arduino.c b/hw/avr/arduino.c index 73563a35d0