Re: [PATCH V1 1/2] gpio: inverter: Add virtual controller for gpio configuration

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

 



On 13/06/19 12:18 PM, Linus Walleij wrote:
> Oops I missed one thing:
>
> On Wed, Jun 12, 2019 at 6:50 AM Harish Jenny K N
> <harish_kandiga@xxxxxxxxxx> wrote:
>
>> +struct gpio_inverter {
>> +       struct gpio_chip gpiochip;
>> +       int count;
>> +       struct gpio_desc *gpios[0];
> No [0] as Geert points out and:
>
>> +       size = sizeof(*virt) + count * sizeof(struct gpio_desc *);
>> +       virt = devm_kzalloc(dev, size, GFP_KERNEL);
>> +       if (!virt)
>> +               return -ENOMEM;
> Use this:
>
> inv = devm_kzalloc(dev, struct_size(inv, gpios, count), GFP_KERNEL);
>
> We use struct_size() for dynamic structs with headroom in the tail.
>
> Yours,
> Linus Walleij


Thanks for the review comments. Will send an updated patch.


Regards,

Harish





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux