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

Guenter Roeck
2025-06-04T12:40:48Z

On 6/4/25 03:11, Oliver Neukum wrote:
> On 04.06.25 06:14, a0282524688@gmail.com wrote:
>> From: Ming Yu <tmyu0@nuvoton.com>
>>
>> The Nuvoton NCT6694 provides an USB interface to the host to
>> access its features.
>>
>> Sub-devices 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>
>> ---
...
>> +static void usb_int_callback(struct urb *urb)
>> +{
>> +    struct nct6694 *nct6694 = urb->context;
>> +    unsigned int *int_status = urb->transfer_buffer;
>> +    int ret;
>> +
>> +    switch (urb->status) {
>> +    case 0:
>> +        break;
>> +    case -ECONNRESET:
>> +    case -ENOENT:
>> +    case -ESHUTDOWN:
>> +        return;
>> +    default:
>> +        goto resubmit;
>> +    }
>> +
>> +    while (*int_status) {
>> +        int irq = __ffs(*int_status);
>> +
>> +        generic_handle_irq_safe(irq_find_mapping(nct6694->domain, irq));
>> +        *int_status &= ~BIT(irq);
>> +    }
>
> Does modifying the byte have any benefit?
>

Not sure if I understand the question, and assuming your question is regarding
*int_status: *int_status!=0 is the loop invariant, so, yes, modifying it does
have a benefit.

I'd be more concerned that transfer_buffer is the raw buffer, and that data
read from it is not endianness converted. That makes me wonder if and how the
code would work on a big endian system.

Guenter