[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFukWp2w2KwE+Obt1DWTcT81DbN7FdMNVo2Q7MSvjNi=_0uBRA@mail.gmail.com>
Date: Fri, 11 Aug 2023 12:01:23 +0200
From: Mehdi Djait <mehdi.djait.k@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: jic23@...nel.org, mazziesaccount@...il.com,
krzysztof.kozlowski+dt@...aro.org, robh+dt@...nel.org,
lars@...afoo.de, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v7 5/7] iio: accel: kionix-kx022a: Refactor driver and add
chip_info structure
Hello Andy,
Thank you for the review.
On Fri, Aug 11, 2023 at 11:46 AM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> 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
Powered by blists - more mailing lists