Re: [PATCH v7 5/7] iio: accel: kionix-kx022a: Refactor driver and add chip_info structure

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

 



Hello Andy,

Thank you for the review.

On Fri, Aug 11, 2023 at 11:46 AM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Wed, Aug 09, 2023 at 09:11:36PM +0200, Mehdi Djait wrote:
> > Add the chip_info structure to the driver's private data to hold all
> > the device specific infos.
> > Refactor the kx022a driver implementation to make it more generic and
> > extensible.
>
> ...
>
> > +     chip_info = device_get_match_data(&i2c->dev);
> > +     if (!chip_info) {
> > +             const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
>
> Missing blank line.
>
> > +             chip_info = (const struct kx022a_chip_info *)id->driver_data;
> > +             if (!chip_info)
> > +                     return -EINVAL;
> > +     }
>
> ...
>
> > -     if (val > KX022A_FIFO_LENGTH)
> > -             val = KX022A_FIFO_LENGTH;
> > +     val = min_t(unsigned int, data->chip_info->fifo_length, val);
>
> min_t() is a beast. Please, use min() if no special requirement for
> min_t() here, otherwise explain why.

No actual reason, you suggested min_t or min for a previous version

>
> ...
>
> > +     data->fifo_buffer = kmalloc(data->chip_info->fifo_length *
> > +                                 KX022A_FIFO_SAMPLES_SIZE_BYTES, GFP_KERNEL);
>
> kmalloc_array()

Should I send another version for this ?
The usage of kmalloc is quite straightforward and easy to understand here.

--
Kind Regard
Mehdi Djait




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux