Re: [PATCH v2 4/7] gpio: mockup: improve readability

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

 



2017-05-31 16:57 GMT+02:00 Andy Shevchenko <andy.shevchenko@xxxxxxxxx>:
> On Wed, May 31, 2017 at 1:53 PM, Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>> 2017-05-30 20:55 GMT+02:00 Andy Shevchenko <andy.shevchenko@xxxxxxxxx>:
>>> On Tue, May 30, 2017 at 11:58 AM, Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>>>> We currently shift bits here and there without actually explaining
>>>> what we're doing. Add some helper variables with names indicating
>>>> their purpose to improve the code readability.
>>>
>>>> +       /* Each chip is described by two values. */
>>>> +       num_chips = gpio_mockup_params_nr / 2;
>>>> +
>>>> +       chips = devm_kzalloc(dev, sizeof(*chips) * num_chips, GFP_KERNEL);
>>>
>>> It's effectively
>>> devm_kcalloc()
>>> or
>>> devm_kmalloc_array()
>>> depending on the requirement of zeroing a memory chunks.
>
>> Is there any advantage to using one of these here?
>
> Yes, though subtle one in this case. The caller will not care about
> (possible) overflow in multiplication.
> Other (micro)optimizations might be in place in the future as well,
> but I dunno about this.
>
> I would suggest to change.
>

Ok, I'll change it both for the lines and for the chips arrays and add
a separate patch.

Thanks,
Bartosz
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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