Re: [PATCH v5] USB: serial: ftdi_sio: Add MTP NVM support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 26, 2018 at 2:51 PM, Loic Poulain <loic.poulain@xxxxxxxxxx> wrote:
> On 26 June 2018 at 13:02, Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
>> On Mon, Jun 25, 2018 at 3:35 PM, Loic Poulain <loic.poulain@xxxxxxxxxx> wrote:



>>> +       unsigned char *buf = val;
>>
>> Btw, not sure why you need this now...
>
> Not needed indeed, just wanted to avoid arithmetic on void pointer,
> but I can cast instead.

No need to cast either.
We rely (?) on GCC to allow pointer arithmetic on void pointers to
behave as char pointers.

(?) I don't know if it's deliberate choice, though a lot of code uses
pointer arithmetic against void pointers such if it would be a char
pointers.

In case you would like to keep it, the temporary variable looks the
best way (no ugly castings, please).

>>> +
>>> +       if (bytes % 2) /* 16-bit eeprom */
>>> +               return -EINVAL;
>>> +
>>> +       while (bytes) {
>>> +               int rv;
>>> +
>>> +               rv = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
>>> +                                    FTDI_SIO_WRITE_EEPROM_REQUEST,
>>> +                                    FTDI_SIO_WRITE_EEPROM_REQUEST_TYPE,
>>> +                                    get_unaligned_le16(buf), off / 2, NULL,
>>> +                                    0, WDR_TIMEOUT);
>>> +               if (rv < 0)
>>> +                       return rv;
>>> +
>>> +               off += 2;
>>> +               buf += 2;
>>> +               bytes -= 2;
>>> +       }


-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux