* [PATCH] iio: accel: bma180: Convert enum->pointer for data in the match table
@ 2023-08-12 14:10 Biju Das
2023-08-15 7:19 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Biju Das @ 2023-08-12 14:10 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Biju Das, Lars-Peter Clausen, Uwe Kleine-König,
Andy Shevchenko, Javier Martinez Canillas, Crt Mori, Rob Herring,
linux-iio, Geert Uytterhoeven, linux-renesas-soc
Convert enum->pointer for data in the match 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 *bma180_part_info for data in the match table and
simplify bma180_probe().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
drivers/iio/accel/bma180.c | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 13439f52d26d..ab4fccb24b6c 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -926,7 +926,6 @@ static int bma180_probe(struct i2c_client *client)
struct device *dev = &client->dev;
struct bma180_data *data;
struct iio_dev *indio_dev;
- enum chip_ids chip;
int ret;
indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
@@ -936,11 +935,7 @@ static int bma180_probe(struct i2c_client *client)
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
- if (client->dev.of_node)
- chip = (uintptr_t)of_device_get_match_data(dev);
- else
- chip = id->driver_data;
- data->part_info = &bma180_part_info[chip];
+ data->part_info = i2c_get_match_data(client);
ret = iio_read_mount_matrix(dev, &data->orientation);
if (ret)
@@ -1092,11 +1087,11 @@ static int bma180_resume(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume);
static const struct i2c_device_id bma180_ids[] = {
- { "bma023", BMA023 },
- { "bma150", BMA150 },
- { "bma180", BMA180 },
- { "bma250", BMA250 },
- { "smb380", BMA150 },
+ { "bma023", (kernel_ulong_t)&bma180_part_info[BMA023] },
+ { "bma150", (kernel_ulong_t)&bma180_part_info[BMA150] },
+ { "bma180", (kernel_ulong_t)&bma180_part_info[BMA180] },
+ { "bma250", (kernel_ulong_t)&bma180_part_info[BMA250] },
+ { "smb380", (kernel_ulong_t)&bma180_part_info[BMA150] },
{ }
};
@@ -1105,23 +1100,23 @@ MODULE_DEVICE_TABLE(i2c, bma180_ids);
static const struct of_device_id bma180_of_match[] = {
{
.compatible = "bosch,bma023",
- .data = (void *)BMA023
+ .data = &bma180_part_info[BMA023]
},
{
.compatible = "bosch,bma150",
- .data = (void *)BMA150
+ .data = &bma180_part_info[BMA150]
},
{
.compatible = "bosch,bma180",
- .data = (void *)BMA180
+ .data = &bma180_part_info[BMA180]
},
{
.compatible = "bosch,bma250",
- .data = (void *)BMA250
+ .data = &bma180_part_info[BMA250]
},
{
.compatible = "bosch,smb380",
- .data = (void *)BMA150
+ .data = &bma180_part_info[BMA150]
},
{ }
};
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: accel: bma180: Convert enum->pointer for data in the match table
2023-08-12 14:10 [PATCH] iio: accel: bma180: Convert enum->pointer for data in the match table Biju Das
@ 2023-08-15 7:19 ` Andy Shevchenko
2023-08-28 13:31 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-08-15 7:19 UTC (permalink / raw)
To: Biju Das
Cc: Jonathan Cameron, Lars-Peter Clausen, Uwe Kleine-König,
Javier Martinez Canillas, Crt Mori, Rob Herring, linux-iio,
Geert Uytterhoeven, linux-renesas-soc
On Sat, Aug 12, 2023 at 03:10:44PM +0100, Biju Das wrote:
> Convert enum->pointer for data in the match 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 *bma180_part_info for data in the match table and
> simplify bma180_probe().
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: accel: bma180: Convert enum->pointer for data in the match table
2023-08-15 7:19 ` Andy Shevchenko
@ 2023-08-28 13:31 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2023-08-28 13:31 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Biju Das, Lars-Peter Clausen, Uwe Kleine-König,
Javier Martinez Canillas, Crt Mori, Rob Herring, linux-iio,
Geert Uytterhoeven, linux-renesas-soc
On Tue, 15 Aug 2023 10:19:43 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> On Sat, Aug 12, 2023 at 03:10:44PM +0100, Biju Das wrote:
> > Convert enum->pointer for data in the match 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 *bma180_part_info for data in the match table and
> > simplify bma180_probe().
>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
Applied. Thanks,
J
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-28 13:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-12 14:10 [PATCH] iio: accel: bma180: Convert enum->pointer for data in the match table Biju Das
2023-08-15 7:19 ` Andy Shevchenko
2023-08-28 13:31 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox