* [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data
@ 2022-08-31 14:15 Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 2/3] iio: magnetometer: yamaha-yas530: Make strings const in chip info Andy Shevchenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-08-31 14:15 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, Linus Walleij, Jakob Hauser,
linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
Unify ID tables to use pointers for driver data. It will allow
to simplify the driver later on.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: left ID fallback in place (Jonathan)
drivers/iio/magnetometer/yamaha-yas530.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index 026f71e524f3..58f527cfde07 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -32,6 +32,7 @@
#include <linux/mod_devicetable.h>
#include <linux/mutex.h>
#include <linux/pm_runtime.h>
+#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/random.h>
@@ -1437,8 +1438,10 @@ static int yas5xx_probe(struct i2c_client *i2c,
goto assert_reset;
}
- yas5xx->chip_info = &yas5xx_chip_info_tbl[id->driver_data];
- ci = yas5xx->chip_info;
+ ci = device_get_match_data(dev);
+ if (!ci)
+ ci = (const struct yas5xx_chip_info *)id->driver_data;
+ yas5xx->chip_info = ci;
ret = regmap_read(yas5xx->map, YAS5XX_DEVICE_ID, &id_check);
if (ret)
@@ -1583,19 +1586,19 @@ static DEFINE_RUNTIME_DEV_PM_OPS(yas5xx_dev_pm_ops, yas5xx_runtime_suspend,
yas5xx_runtime_resume, NULL);
static const struct i2c_device_id yas5xx_id[] = {
- {"yas530", yas530 },
- {"yas532", yas532 },
- {"yas533", yas533 },
- {"yas537", yas537 },
+ {"yas530", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas530] },
+ {"yas532", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas532] },
+ {"yas533", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas533] },
+ {"yas537", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas537] },
{}
};
MODULE_DEVICE_TABLE(i2c, yas5xx_id);
static const struct of_device_id yas5xx_of_match[] = {
- { .compatible = "yamaha,yas530", },
- { .compatible = "yamaha,yas532", },
- { .compatible = "yamaha,yas533", },
- { .compatible = "yamaha,yas537", },
+ { .compatible = "yamaha,yas530", &yas5xx_chip_info_tbl[yas530] },
+ { .compatible = "yamaha,yas532", &yas5xx_chip_info_tbl[yas532] },
+ { .compatible = "yamaha,yas533", &yas5xx_chip_info_tbl[yas533] },
+ { .compatible = "yamaha,yas537", &yas5xx_chip_info_tbl[yas537] },
{}
};
MODULE_DEVICE_TABLE(of, yas5xx_of_match);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] iio: magnetometer: yamaha-yas530: Make strings const in chip info
2022-08-31 14:15 [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Andy Shevchenko
@ 2022-08-31 14:15 ` Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 3/3] iio: magnetometer: yamaha-yas530: Use dev_err_probe() Andy Shevchenko
2022-09-04 15:30 ` [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-08-31 14:15 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, Linus Walleij, Jakob Hauser,
linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
For better compiler coverage mark strings consts in the chip info.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: no changes
drivers/iio/magnetometer/yamaha-yas530.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index 58f527cfde07..a6e34d5f3e85 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -189,8 +189,8 @@ struct yas5xx;
*/
struct yas5xx_chip_info {
unsigned int devid;
- char *product_name;
- char *version_names[2];
+ const char *product_name;
+ const char *version_names[2];
const int *volatile_reg;
int volatile_reg_qty;
u32 scaling_val2;
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] iio: magnetometer: yamaha-yas530: Use dev_err_probe()
2022-08-31 14:15 [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 2/3] iio: magnetometer: yamaha-yas530: Make strings const in chip info Andy Shevchenko
@ 2022-08-31 14:15 ` Andy Shevchenko
2022-09-04 15:30 ` [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-08-31 14:15 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko, Linus Walleij, Jakob Hauser,
linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
Unify error message format by using dev_err_probe().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: no changes
drivers/iio/magnetometer/yamaha-yas530.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index a6e34d5f3e85..801c760feb4d 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -1415,10 +1415,8 @@ static int yas5xx_probe(struct i2c_client *i2c,
return dev_err_probe(dev, ret, "cannot get regulators\n");
ret = regulator_bulk_enable(ARRAY_SIZE(yas5xx->regs), yas5xx->regs);
- if (ret) {
- dev_err(dev, "cannot enable regulators\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "cannot enable regulators\n");
/* See comment in runtime resume callback */
usleep_range(31000, 40000);
@@ -1426,15 +1424,13 @@ static int yas5xx_probe(struct i2c_client *i2c,
/* This will take the device out of reset if need be */
yas5xx->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(yas5xx->reset)) {
- ret = dev_err_probe(dev, PTR_ERR(yas5xx->reset),
- "failed to get reset line\n");
+ ret = dev_err_probe(dev, PTR_ERR(yas5xx->reset), "failed to get reset line\n");
goto reg_off;
}
yas5xx->map = devm_regmap_init_i2c(i2c, &yas5xx_regmap_config);
if (IS_ERR(yas5xx->map)) {
- dev_err(dev, "failed to allocate register map\n");
- ret = PTR_ERR(yas5xx->map);
+ ret = dev_err_probe(dev, PTR_ERR(yas5xx->map), "failed to allocate register map\n");
goto assert_reset;
}
@@ -1484,13 +1480,13 @@ static int yas5xx_probe(struct i2c_client *i2c,
yas5xx_handle_trigger,
NULL);
if (ret) {
- dev_err(dev, "triggered buffer setup failed\n");
+ dev_err_probe(dev, ret, "triggered buffer setup failed\n");
goto assert_reset;
}
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(dev, "device register failed\n");
+ dev_err_probe(dev, ret, "device register failed\n");
goto cleanup_buffer;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data
2022-08-31 14:15 [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 2/3] iio: magnetometer: yamaha-yas530: Make strings const in chip info Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 3/3] iio: magnetometer: yamaha-yas530: Use dev_err_probe() Andy Shevchenko
@ 2022-09-04 15:30 ` Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2022-09-04 15:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Jonathan Cameron, Linus Walleij, Jakob Hauser, linux-iio,
linux-kernel, Lars-Peter Clausen
On Wed, 31 Aug 2022 17:15:28 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> Unify ID tables to use pointers for driver data. It will allow
> to simplify the driver later on.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Series applied to the togreg branch of iio.git and pushed out as testing
for 0-day to see if it can find things we missed.
Still time for feedback from others before I push this out as the
more or less non-rebasing, togreg branch.
Thanks,
Jonathan
> ---
> v2: left ID fallback in place (Jonathan)
> drivers/iio/magnetometer/yamaha-yas530.c | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
> index 026f71e524f3..58f527cfde07 100644
> --- a/drivers/iio/magnetometer/yamaha-yas530.c
> +++ b/drivers/iio/magnetometer/yamaha-yas530.c
> @@ -32,6 +32,7 @@
> #include <linux/mod_devicetable.h>
> #include <linux/mutex.h>
> #include <linux/pm_runtime.h>
> +#include <linux/property.h>
> #include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
> #include <linux/random.h>
> @@ -1437,8 +1438,10 @@ static int yas5xx_probe(struct i2c_client *i2c,
> goto assert_reset;
> }
>
> - yas5xx->chip_info = &yas5xx_chip_info_tbl[id->driver_data];
> - ci = yas5xx->chip_info;
> + ci = device_get_match_data(dev);
> + if (!ci)
> + ci = (const struct yas5xx_chip_info *)id->driver_data;
> + yas5xx->chip_info = ci;
>
> ret = regmap_read(yas5xx->map, YAS5XX_DEVICE_ID, &id_check);
> if (ret)
> @@ -1583,19 +1586,19 @@ static DEFINE_RUNTIME_DEV_PM_OPS(yas5xx_dev_pm_ops, yas5xx_runtime_suspend,
> yas5xx_runtime_resume, NULL);
>
> static const struct i2c_device_id yas5xx_id[] = {
> - {"yas530", yas530 },
> - {"yas532", yas532 },
> - {"yas533", yas533 },
> - {"yas537", yas537 },
> + {"yas530", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas530] },
> + {"yas532", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas532] },
> + {"yas533", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas533] },
> + {"yas537", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas537] },
> {}
> };
> MODULE_DEVICE_TABLE(i2c, yas5xx_id);
>
> static const struct of_device_id yas5xx_of_match[] = {
> - { .compatible = "yamaha,yas530", },
> - { .compatible = "yamaha,yas532", },
> - { .compatible = "yamaha,yas533", },
> - { .compatible = "yamaha,yas537", },
> + { .compatible = "yamaha,yas530", &yas5xx_chip_info_tbl[yas530] },
> + { .compatible = "yamaha,yas532", &yas5xx_chip_info_tbl[yas532] },
> + { .compatible = "yamaha,yas533", &yas5xx_chip_info_tbl[yas533] },
> + { .compatible = "yamaha,yas537", &yas5xx_chip_info_tbl[yas537] },
> {}
> };
> MODULE_DEVICE_TABLE(of, yas5xx_of_match);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-04 16:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-31 14:15 [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 2/3] iio: magnetometer: yamaha-yas530: Make strings const in chip info Andy Shevchenko
2022-08-31 14:15 ` [PATCH v2 3/3] iio: magnetometer: yamaha-yas530: Use dev_err_probe() Andy Shevchenko
2022-09-04 15:30 ` [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).