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

From: Andy Shevchenko
Date: Thu Aug 24 2023 - 07:56:26 EST


On Wed, Aug 23, 2023 at 11:16:39PM +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);
> +
> + chip_info = (const struct kx022a_chip_info *)id->driver_data;
> + if (!chip_info)
> + return -EINVAL;
> + }

There is a new API for that, please use it.

...

> +/* kx022a Regmap configs */

regmap

...

> irq = fwnode_irq_get_byname(fwnode, "INT2");
> if (irq <= 0)

= 0 case is fixed now, means should never appear here,
but it's a material for another, separate change.

> return dev_err_probe(dev, irq, "No suitable IRQ\n");

--
With Best Regards,
Andy Shevchenko