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

From: Andi Shyti
Date: Tue Apr 25 2023 - 11:57:42 EST


Hi Mehdi,

On Tue, Apr 25, 2023 at 12:22:25AM +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.

Could you please split this in different patches? Add id in one
patch and refactor in a different patch. Please, also the
refactorings need to be split.

I see here that this is a general code cleanup, plus some other
stuff.

[...]

> @@ -22,22 +23,28 @@ static int kx022a_spi_probe(struct spi_device *spi)
> return -EINVAL;
> }
>
> - regmap = devm_regmap_init_spi(spi, &kx022a_regmap);
> + chip_info = device_get_match_data(&spi->dev);
> + if (!chip_info) {
> + const struct spi_device_id *id = spi_get_device_id(spi);
> + chip_info = (const struct kx022a_chip_info *)id->driver_data;

you don't need the cast here... if you don't find it messy, I
wouldn't mind this form... some hate it, I find it easier to
read:

chip_info = spi_get_device_id(spi)->driver_data;

your choice.

Andi