Re: [PATCH v3 1/7] mfd: Add core driver for Nuvoton NCT6694

Linus Walleij
2024-12-20T12:45:52Z

Hi Ming,

thanks for your patch!

On Tue, Dec 10, 2024 at 11:45 AM Ming Yu <a0282524688@gmail.com> wrote:

> The Nuvoton NCT6694 is a peripheral expander with 16 GPIO chips,
> 6 I2C controllers, 2 CANfd controllers, 2 Watchdog timers, ADC,
> PWM, and RTC.
>
> This driver implements USB device functionality and shares the
> chip's peripherals as a child device.
>
> Each child device can use the USB functions nct6694_read_msg()
> and nct6694_write_msg() to issue a command. They can also request
> interrupt that will be called when the USB device receives its
> interrupt pipe.
>
> Signed-off-by: Ming Yu <tmyu0@nuvoton.com>
(...)
> + while (*int_status) {
> + int irq = __ffs(*int_status);
> +
> + if (*int_status & (1 << irq))
> + generic_handle_irq_safe(irq_find_mapping(nct6694->domain, irq));
> +
> + *int_status &= ~(1 << irq);

What about doing what you do in the GPIO driver and
#include <linux/bits.h>

And search and replace "(1 << irq)" with BIT(irq)?

PS the main reason we do this is because

int a = (1 << 31);

becomes a negative number on 32bit machines, and
can lead to confusing side effects. BIT() always work
on unsigned.

Yours,
Linus Walleij