* [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table
@ 2023-08-12 14:31 Biju Das
2023-08-12 14:47 ` Hans de Goede
2023-08-15 6:46 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Biju Das @ 2023-08-12 14:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Biju Das, Lars-Peter Clausen, Uwe Kleine-König,
Andy Shevchenko, Hans de Goede, Vladimir Oltean, Mehdi Djait,
Rob Herring, linux-iio, Geert Uytterhoeven, linux-renesas-soc
Convert enum->pointer for data in the ID table, so that
device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
bus type match support added to it.
Replace enum->struct *mma_chip_info for data in the ID table and simplify
mma8452_probe() by replacing device_get_match_data() with
i2c_get_match_data().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/iio/accel/mma8452.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index f42a88711486..5864ad726e97 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -1547,7 +1547,6 @@ MODULE_DEVICE_TABLE(of, mma8452_dt_ids);
static int mma8452_probe(struct i2c_client *client)
{
- const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct mma8452_data *data;
struct iio_dev *indio_dev;
int ret;
@@ -1560,15 +1559,10 @@ static int mma8452_probe(struct i2c_client *client)
data->client = client;
mutex_init(&data->lock);
- data->chip_info = device_get_match_data(&client->dev);
- if (!data->chip_info) {
- if (id) {
- data->chip_info = &mma_chip_info_table[id->driver_data];
- } else {
- dev_err(&client->dev, "unknown device model\n");
- return -ENODEV;
- }
- }
+ data->chip_info = i2c_get_match_data(client);
+ if (!data->chip_info)
+ return dev_err_probe(&client->dev, -ENODEV,
+ "unknown device model\n");
ret = iio_read_mount_matrix(&client->dev, &data->orientation);
if (ret)
@@ -1830,12 +1824,12 @@ static const struct dev_pm_ops mma8452_pm_ops = {
};
static const struct i2c_device_id mma8452_id[] = {
- { "mma8451", mma8451 },
- { "mma8452", mma8452 },
- { "mma8453", mma8453 },
- { "mma8652", mma8652 },
- { "mma8653", mma8653 },
- { "fxls8471", fxls8471 },
+ { "mma8451", (kernel_ulong_t)&mma_chip_info_table[mma8451] },
+ { "mma8452", (kernel_ulong_t)&mma_chip_info_table[mma8452] },
+ { "mma8453", (kernel_ulong_t)&mma_chip_info_table[mma8453] },
+ { "mma8652", (kernel_ulong_t)&mma_chip_info_table[mma8652] },
+ { "mma8653", (kernel_ulong_t)&mma_chip_info_table[mma8653] },
+ { "fxls8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
{ }
};
MODULE_DEVICE_TABLE(i2c, mma8452_id);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table
2023-08-12 14:31 [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table Biju Das
@ 2023-08-12 14:47 ` Hans de Goede
2023-08-15 6:46 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2023-08-12 14:47 UTC (permalink / raw)
To: Biju Das, Jonathan Cameron
Cc: Lars-Peter Clausen, Uwe Kleine-König, Andy Shevchenko,
Vladimir Oltean, Mehdi Djait, Rob Herring, linux-iio,
Geert Uytterhoeven, linux-renesas-soc
Hi,
On 8/12/23 16:31, Biju Das wrote:
> Convert enum->pointer for data in the ID table, so that
> device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
> bus type match support added to it.
>
> Replace enum->struct *mma_chip_info for data in the ID table and simplify
> mma8452_probe() by replacing device_get_match_data() with
> i2c_get_match_data().
>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/iio/accel/mma8452.c | 26 ++++++++++----------------
> 1 file changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index f42a88711486..5864ad726e97 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -1547,7 +1547,6 @@ MODULE_DEVICE_TABLE(of, mma8452_dt_ids);
>
> static int mma8452_probe(struct i2c_client *client)
> {
> - const struct i2c_device_id *id = i2c_client_get_device_id(client);
> struct mma8452_data *data;
> struct iio_dev *indio_dev;
> int ret;
> @@ -1560,15 +1559,10 @@ static int mma8452_probe(struct i2c_client *client)
> data->client = client;
> mutex_init(&data->lock);
>
> - data->chip_info = device_get_match_data(&client->dev);
> - if (!data->chip_info) {
> - if (id) {
> - data->chip_info = &mma_chip_info_table[id->driver_data];
> - } else {
> - dev_err(&client->dev, "unknown device model\n");
> - return -ENODEV;
> - }
> - }
> + data->chip_info = i2c_get_match_data(client);
> + if (!data->chip_info)
> + return dev_err_probe(&client->dev, -ENODEV,
> + "unknown device model\n");
>
> ret = iio_read_mount_matrix(&client->dev, &data->orientation);
> if (ret)
> @@ -1830,12 +1824,12 @@ static const struct dev_pm_ops mma8452_pm_ops = {
> };
>
> static const struct i2c_device_id mma8452_id[] = {
> - { "mma8451", mma8451 },
> - { "mma8452", mma8452 },
> - { "mma8453", mma8453 },
> - { "mma8652", mma8652 },
> - { "mma8653", mma8653 },
> - { "fxls8471", fxls8471 },
> + { "mma8451", (kernel_ulong_t)&mma_chip_info_table[mma8451] },
> + { "mma8452", (kernel_ulong_t)&mma_chip_info_table[mma8452] },
> + { "mma8453", (kernel_ulong_t)&mma_chip_info_table[mma8453] },
> + { "mma8652", (kernel_ulong_t)&mma_chip_info_table[mma8652] },
> + { "mma8653", (kernel_ulong_t)&mma_chip_info_table[mma8653] },
> + { "fxls8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, mma8452_id);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table
2023-08-12 14:31 [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table Biju Das
2023-08-12 14:47 ` Hans de Goede
@ 2023-08-15 6:46 ` Andy Shevchenko
2023-08-15 6:54 ` Biju Das
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-15 6:46 UTC (permalink / raw)
To: Biju Das
Cc: Jonathan Cameron, Lars-Peter Clausen, Uwe Kleine-König,
Hans de Goede, Vladimir Oltean, Mehdi Djait, Rob Herring,
linux-iio, Geert Uytterhoeven, linux-renesas-soc
On Sat, Aug 12, 2023 at 03:31:00PM +0100, Biju Das wrote:
> Convert enum->pointer for data in the ID table, so that
> device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
> bus type match support added to it.
>
> Replace enum->struct *mma_chip_info for data in the ID table and simplify
> mma8452_probe() by replacing device_get_match_data() with
> i2c_get_match_data().
...
> static const struct i2c_device_id mma8452_id[] = {
> - { "mma8451", mma8451 },
> - { "mma8452", mma8452 },
> - { "mma8453", mma8453 },
> - { "mma8652", mma8652 },
> - { "mma8653", mma8653 },
> - { "fxls8471", fxls8471 },
> + { "mma8451", (kernel_ulong_t)&mma_chip_info_table[mma8451] },
> + { "mma8452", (kernel_ulong_t)&mma_chip_info_table[mma8452] },
> + { "mma8453", (kernel_ulong_t)&mma_chip_info_table[mma8453] },
> + { "mma8652", (kernel_ulong_t)&mma_chip_info_table[mma8652] },
> + { "mma8653", (kernel_ulong_t)&mma_chip_info_table[mma8653] },
> + { "fxls8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
You can also keep it sorted by name.
> { }
> };
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table
2023-08-15 6:46 ` Andy Shevchenko
@ 2023-08-15 6:54 ` Biju Das
0 siblings, 0 replies; 4+ messages in thread
From: Biju Das @ 2023-08-15 6:54 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, Lars-Peter Clausen, Uwe Kleine-König,
Hans de Goede, Vladimir Oltean, Mehdi Djait, Rob Herring,
linux-iio@vger.kernel.org, Geert Uytterhoeven,
linux-renesas-soc@vger.kernel.org
Hi Andy Shevchenko,
Thanks for the feedback.
> Subject: Re: [PATCH] iio: accel: mma8452: Convert enum->pointer for data
> in the ID table
>
> On Sat, Aug 12, 2023 at 03:31:00PM +0100, Biju Das wrote:
> > Convert enum->pointer for data in the ID table, so that
> > device_get_match_data() can do match against OF/ACPI/I2C tables, once
> > i2c bus type match support added to it.
> >
> > Replace enum->struct *mma_chip_info for data in the ID table and
> > simplify
> > mma8452_probe() by replacing device_get_match_data() with
> > i2c_get_match_data().
>
> ...
>
> > static const struct i2c_device_id mma8452_id[] = {
> > - { "mma8451", mma8451 },
> > - { "mma8452", mma8452 },
> > - { "mma8453", mma8453 },
> > - { "mma8652", mma8652 },
> > - { "mma8653", mma8653 },
> > - { "fxls8471", fxls8471 },
> > + { "mma8451", (kernel_ulong_t)&mma_chip_info_table[mma8451] },
> > + { "mma8452", (kernel_ulong_t)&mma_chip_info_table[mma8452] },
> > + { "mma8453", (kernel_ulong_t)&mma_chip_info_table[mma8453] },
> > + { "mma8652", (kernel_ulong_t)&mma_chip_info_table[mma8652] },
> > + { "mma8653", (kernel_ulong_t)&mma_chip_info_table[mma8653] },
> > + { "fxls8471", (kernel_ulong_t)&mma_chip_info_table[fxls8471] },
>
> You can also keep it sorted by name.
OK will sort by name.
Cheers,
Biju
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-15 6:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-12 14:31 [PATCH] iio: accel: mma8452: Convert enum->pointer for data in the ID table Biju Das
2023-08-12 14:47 ` Hans de Goede
2023-08-15 6:46 ` Andy Shevchenko
2023-08-15 6:54 ` Biju Das
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox