Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups
@ 2026-05-08  6:08 Andy Shevchenko
  2026-05-08  6:08 ` [PATCH v1 1/3] iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id() Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-05-08  6:08 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andy Shevchenko

Some small cleanups against yamaha-yas530 driver. I wanted to produce more
but have had no time so far, hence just this mini-series.

Andy Shevchenko (3):
  iio: magnetometer: yamaha-yas530: Get rid of
    i2c_client_get_device_id()
  iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex
    initialization
  iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep()

 drivers/iio/magnetometer/yamaha-yas530.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/3] iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id()
  2026-05-08  6:08 [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Andy Shevchenko
@ 2026-05-08  6:08 ` Andy Shevchenko
  2026-05-08  6:08 ` [PATCH v1 2/3] iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex initialization Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-05-08  6:08 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andy Shevchenko

Instead of relying on the name from ID table, which might be ambiguous
in some cases, use explicit product label in the driver data. With that
being done, get rid of i2c_client_get_device_id() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/magnetometer/yamaha-yas530.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index c8a04f185dbb..2ed0d1b93985 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -168,6 +168,7 @@ struct yas5xx;
 /**
  * struct yas5xx_chip_info - device-specific data and function pointers
  * @devid: device ID number
+ * @product_label: product label used in Linux
  * @product_name: product name of the YAS variant
  * @version_names: version letters or namings
  * @volatile_reg: device-specific volatile registers
@@ -189,6 +190,7 @@ struct yas5xx;
  */
 struct yas5xx_chip_info {
 	unsigned int devid;
+	const char *product_label;
 	const char *product_name;
 	const char *version_names[2];
 	const int *volatile_reg;
@@ -1323,6 +1325,7 @@ static int yas537_power_on(struct yas5xx *yas5xx)
 static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
 	[yas530] = {
 		.devid = YAS530_DEVICE_ID,
+		.product_label = "yas530",
 		.product_name = "YAS530 MS-3E",
 		.version_names = { "A", "B" },
 		.volatile_reg = yas530_volatile_reg,
@@ -1338,6 +1341,7 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
 	},
 	[yas532] = {
 		.devid = YAS532_DEVICE_ID,
+		.product_label = "yas532",
 		.product_name = "YAS532 MS-3R",
 		.version_names = { "AB", "AC" },
 		.volatile_reg = yas530_volatile_reg,
@@ -1353,6 +1357,7 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
 	},
 	[yas533] = {
 		.devid = YAS532_DEVICE_ID,
+		.product_label = "yas533",
 		.product_name = "YAS533 MS-3F",
 		.version_names = { "AB", "AC" },
 		.volatile_reg = yas530_volatile_reg,
@@ -1368,6 +1373,7 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
 	},
 	[yas537] = {
 		.devid = YAS537_DEVICE_ID,
+		.product_label = "yas537",
 		.product_name = "YAS537 MS-3T",
 		.version_names = { "v0", "v1" }, /* version naming unknown */
 		.volatile_reg = yas537_volatile_reg,
@@ -1385,7 +1391,6 @@ static const struct yas5xx_chip_info yas5xx_chip_info_tbl[] = {
 
 static int yas5xx_probe(struct i2c_client *i2c)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
 	struct iio_dev *indio_dev;
 	struct device *dev = &i2c->dev;
 	struct yas5xx *yas5xx;
@@ -1443,7 +1448,7 @@ static int yas5xx_probe(struct i2c_client *i2c)
 	if (id_check != ci->devid) {
 		ret = dev_err_probe(dev, -ENODEV,
 				    "device ID %02x doesn't match %s\n",
-				    id_check, id->name);
+				    id_check, ci->product_label);
 		goto assert_reset;
 	}
 
@@ -1469,7 +1474,7 @@ static int yas5xx_probe(struct i2c_client *i2c)
 	indio_dev->info = &yas5xx_info;
 	indio_dev->available_scan_masks = yas5xx_scan_masks;
 	indio_dev->modes = INDIO_DIRECT_MODE;
-	indio_dev->name = id->name;
+	indio_dev->name = ci->product_label;
 	indio_dev->channels = yas5xx_channels;
 	indio_dev->num_channels = ARRAY_SIZE(yas5xx_channels);
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/3] iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex initialization
  2026-05-08  6:08 [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Andy Shevchenko
  2026-05-08  6:08 ` [PATCH v1 1/3] iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id() Andy Shevchenko
@ 2026-05-08  6:08 ` Andy Shevchenko
  2026-05-08  6:08 ` [PATCH v1 3/3] iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep() Andy Shevchenko
  2026-05-08 13:32 ` [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-05-08  6:08 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andy Shevchenko

Use devm_mutex_init() since it brings some benefits when
CONFIG_DEBUG_MUTEXES is enabled.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/magnetometer/yamaha-yas530.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index 2ed0d1b93985..d6efa8a595b0 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -1405,7 +1405,10 @@ static int yas5xx_probe(struct i2c_client *i2c)
 	yas5xx = iio_priv(indio_dev);
 	i2c_set_clientdata(i2c, indio_dev);
 	yas5xx->dev = dev;
-	mutex_init(&yas5xx->lock);
+
+	ret = devm_mutex_init(dev, &yas5xx->lock);
+	if (ret)
+		return ret;
 
 	ret = iio_read_mount_matrix(dev, &yas5xx->orientation);
 	if (ret)
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 3/3] iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep()
  2026-05-08  6:08 [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Andy Shevchenko
  2026-05-08  6:08 ` [PATCH v1 1/3] iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id() Andy Shevchenko
  2026-05-08  6:08 ` [PATCH v1 2/3] iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex initialization Andy Shevchenko
@ 2026-05-08  6:08 ` Andy Shevchenko
  2026-05-08 13:32 ` [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2026-05-08  6:08 UTC (permalink / raw)
  To: linux-iio, linux-kernel
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andy Shevchenko

Replace usleep_range() with fsleep() to allow the kernel
to select the most appropriate delay mechanism based on duration.
Using USEC_PER_MSEC makes the unit conversion explicit.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/magnetometer/yamaha-yas530.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c
index d6efa8a595b0..75ff2ba0c23f 100644
--- a/drivers/iio/magnetometer/yamaha-yas530.c
+++ b/drivers/iio/magnetometer/yamaha-yas530.c
@@ -1317,7 +1317,7 @@ static int yas537_power_on(struct yas5xx *yas5xx)
 		return ret;
 
 	/* Wait until the coil has ramped up */
-	usleep_range(YAS537_MAG_RCOIL_TIME_US, YAS537_MAG_RCOIL_TIME_US + 100);
+	fsleep(YAS537_MAG_RCOIL_TIME_US);
 
 	return 0;
 }
@@ -1426,7 +1426,7 @@ static int yas5xx_probe(struct i2c_client *i2c)
 		return dev_err_probe(dev, ret, "cannot enable regulators\n");
 
 	/* See comment in runtime resume callback */
-	usleep_range(31000, 40000);
+	fsleep(31 * USEC_PER_MSEC);
 
 	/* This will take the device out of reset if need be */
 	yas5xx->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
@@ -1565,7 +1565,7 @@ static int yas5xx_runtime_resume(struct device *dev)
 	 * for all voltages to settle. The YAS532 is 10ms then 4ms for the
 	 * I2C to come online. Let's keep it safe and put this at 31ms.
 	 */
-	usleep_range(31000, 40000);
+	fsleep(31 * USEC_PER_MSEC);
 	gpiod_set_value_cansleep(yas5xx->reset, 0);
 
 	ret = ci->power_on(yas5xx);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups
  2026-05-08  6:08 [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Andy Shevchenko
                   ` (2 preceding siblings ...)
  2026-05-08  6:08 ` [PATCH v1 3/3] iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep() Andy Shevchenko
@ 2026-05-08 13:32 ` Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-05-08 13:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-iio, linux-kernel, David Lechner, Nuno Sá,
	Andy Shevchenko

On Fri,  8 May 2026 08:08:32 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Some small cleanups against yamaha-yas530 driver. I wanted to produce more
> but have had no time so far, hence just this mini-series.
Applied.

Thanks,

J
> 
> Andy Shevchenko (3):
>   iio: magnetometer: yamaha-yas530: Get rid of
>     i2c_client_get_device_id()
>   iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex
>     initialization
>   iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep()
> 
>  drivers/iio/magnetometer/yamaha-yas530.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-08 13:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08  6:08 [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Andy Shevchenko
2026-05-08  6:08 ` [PATCH v1 1/3] iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id() Andy Shevchenko
2026-05-08  6:08 ` [PATCH v1 2/3] iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex initialization Andy Shevchenko
2026-05-08  6:08 ` [PATCH v1 3/3] iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep() Andy Shevchenko
2026-05-08 13:32 ` [PATCH v1 0/3] iio: magnetometer: yamaha-yas530: Ad-hoc cleanups Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox