* [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup
@ 2026-08-08 16:58 Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 1/4] iio: accel: mma8452: convert to bulk regulator usage Sanjay Chitroda via B4 Relay
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-08-08 16:58 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Sanjay Chitroda, Andy Shevchenko,
Jonathan Cameron
Hi all,
This series contains a nuber of small fixes, cleanup and improvements
for the mma8452 accelerometer driver.
The changes modernize macro like mutex with guard(), bulk regulator,
IIO_DEV_ACQUIRE_DIRECT_MODE() and etc.
Changes in v5:
- Drop the PM runtime handling patch, as suitable hardware is not
available to properly validate the PM state transitions.
- Apply reviewed tags.
- Rebase series onto the latest iio/testing branch.
- Link to v4: https://patch.msgid.link/20260602-15-apr-pm-iio-mma8452-v4-temp-v4-0-26d6dff8fc55@gmail.com
Changes in v4:
- Part of the series already merged into the IIO tree; rebase the
remaining patches onto the latest iio/testing branch.
- Link to v3: https://lore.kernel.org/all/20260602-15-apr-pm-iio-mma8452-v4-temp-v4-0-26d6dff8fc55@gmail.com
Changes in v3:
- Following input from Andy and Jonathan added new changes as following
0001: handle return value to have proper error propagation
0002: use non-devm API to maintain resource management LIFO order
0006: convert individual regulator using bulk regulator API
0009: use IIO cleanup helper for DIRECT_MODE
- Address kernel coding stype specific review comment
- Reorder local struct device and dev_err_probe change
v2 series -> https://lore.kernel.org/all/20260422165643.2148195-1-sanjayembedded@gmail.com/
Changes in v2:
- 0005: address review comment from Andy and Geert
and use DEFINE_RUNTIME_DEV_PM_OPS macro
- Added new cleanup channges in mma8452 driver
No functional behavior changes are intended.
Testing:
- Compiled with W=1
- Build-tested on QEMU x86_64
Feedback and reviews are very welcome.
---
Sanjay Chitroda (4):
iio: accel: mma8452: convert to bulk regulator usage
iio: accel: mma8452: use local struct device
iio: accel: mma8452: Use IIO cleanup helpers
iio: accel: mma8452: use guard() to release mutexes
drivers/iio/accel/mma8452.c | 145 +++++++++++++++++---------------------------
1 file changed, 54 insertions(+), 91 deletions(-)
---
base-commit: 350d1fb9204b13c5f95e511e98b8bcb47574d425
change-id: 20260601-15-apr-pm-iio-mma8452-v4-temp-e040489abec3
Best regards,
--
Sanjay Chitroda <sanjayembeddedse@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 1/4] iio: accel: mma8452: convert to bulk regulator usage
2026-08-08 16:58 [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Sanjay Chitroda via B4 Relay
@ 2026-08-08 16:58 ` Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 2/4] iio: accel: mma8452: use local struct device Sanjay Chitroda via B4 Relay
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-08-08 16:58 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Sanjay Chitroda, Andy Shevchenko,
Jonathan Cameron
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
The "vdd" and "vddio" regulators are always controlled together. Switch
to the regulator bulk API to handle setup, enable, and disable paths in
a single call.
No functional change intended.
Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
---
changes in v4:
- added explicit header with input from Joshua Crofts
- validate new member of structure with `pahole` and `bloat-o-meter`
comment from Andy
./scripts/bloat-o-meter mma8452-before.o mma8452-after.o
add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-1013 (-1013)
Function old new delta
_entry_ptr 72 56 -16
_entry 396 308 -88
mma8452_remove 646 548 -98
mma8452_runtime_suspend 633 467 -166
mma8452_runtime_resume 939 639 -300
mma8452_probe 4247 3902 -345
Total: Before=36561, After=35548, chg -2.77%
pahole before:
/* size: 288, cachelines: 5, members: 10 */
/* sum members: 278, holes: 2, sum holes: 10 */
pahole after:
/* size: 320, cachelines: 5, members: 9 */
/* sum members: 310, holes: 2, sum holes: 10 */
summary: overall size of driver is optimized and all new member are in same cacheline
- v3 link -> https://lore.kernel.org/all/20260505174640.3998281-7-sanjayembedded@gmail.com/
---
drivers/iio/accel/mma8452.c | 60 ++++++++++++---------------------------------
1 file changed, 16 insertions(+), 44 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 7d683686dd9d..772463d5ff47 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -18,6 +18,7 @@
* TODO: orientation events
*/
+#include <linux/array_size.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
@@ -110,8 +111,7 @@ struct mma8452_data {
u8 data_cfg;
const struct mma_chip_info *chip_info;
int sleep_val;
- struct regulator *vdd_reg;
- struct regulator *vddio_reg;
+ struct regulator_bulk_data regs[2];
/* Ensure correct alignment of time stamp when present */
struct {
@@ -1569,25 +1569,15 @@ static int mma8452_probe(struct i2c_client *client)
if (ret)
return ret;
- data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
- if (IS_ERR(data->vdd_reg))
- return dev_err_probe(&client->dev, PTR_ERR(data->vdd_reg),
- "failed to get VDD regulator!\n");
-
- data->vddio_reg = devm_regulator_get(&client->dev, "vddio");
- if (IS_ERR(data->vddio_reg))
- return dev_err_probe(&client->dev, PTR_ERR(data->vddio_reg),
- "failed to get VDDIO regulator!\n");
-
- ret = regulator_enable(data->vdd_reg);
+ data->regs[0].supply = "vdd";
+ data->regs[1].supply = "vddio";
+ ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regs), data->regs);
if (ret)
- return dev_err_probe(dev, ret, "failed to enable VDD regulator!\n");
+ return dev_err_probe(dev, ret, "failed to get regulators\n");
- ret = regulator_enable(data->vddio_reg);
- if (ret) {
- dev_err_probe(dev, ret, "failed to enable VDDIO regulator!\n");
- goto disable_regulator_vdd;
- }
+ ret = regulator_bulk_enable(ARRAY_SIZE(data->regs), data->regs);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to enable regulators\n");
ret = i2c_smbus_read_byte_data(client, MMA8452_WHO_AM_I);
if (ret < 0)
@@ -1722,10 +1712,7 @@ static int mma8452_probe(struct i2c_client *client)
mma8452_trigger_cleanup(indio_dev);
disable_regulators:
- regulator_disable(data->vddio_reg);
-
-disable_regulator_vdd:
- regulator_disable(data->vdd_reg);
+ regulator_bulk_disable(ARRAY_SIZE(data->regs), data->regs);
return ret;
}
@@ -1747,8 +1734,7 @@ static void mma8452_remove(struct i2c_client *client)
mma8452_trigger_cleanup(indio_dev);
mma8452_standby(iio_priv(indio_dev));
- regulator_disable(data->vddio_reg);
- regulator_disable(data->vdd_reg);
+ regulator_bulk_disable(ARRAY_SIZE(data->regs), data->regs);
}
#ifdef CONFIG_PM
@@ -1766,15 +1752,9 @@ static int mma8452_runtime_suspend(struct device *dev)
return -EAGAIN;
}
- ret = regulator_disable(data->vddio_reg);
- if (ret) {
- dev_err(dev, "failed to disable VDDIO regulator\n");
- return ret;
- }
-
- ret = regulator_disable(data->vdd_reg);
+ ret = regulator_bulk_disable(ARRAY_SIZE(data->regs), data->regs);
if (ret) {
- dev_err(dev, "failed to disable VDD regulator\n");
+ dev_err(dev, "failed to disable regulators\n");
return ret;
}
@@ -1787,16 +1767,9 @@ static int mma8452_runtime_resume(struct device *dev)
struct mma8452_data *data = iio_priv(indio_dev);
int ret, sleep_val;
- ret = regulator_enable(data->vdd_reg);
- if (ret) {
- dev_err(dev, "failed to enable VDD regulator\n");
- return ret;
- }
-
- ret = regulator_enable(data->vddio_reg);
+ ret = regulator_bulk_enable(ARRAY_SIZE(data->regs), data->regs);
if (ret) {
- dev_err(dev, "failed to enable VDDIO regulator\n");
- regulator_disable(data->vdd_reg);
+ dev_err(dev, "failed to enable regulators\n");
return ret;
}
@@ -1814,8 +1787,7 @@ static int mma8452_runtime_resume(struct device *dev)
return 0;
runtime_resume_failed:
- regulator_disable(data->vddio_reg);
- regulator_disable(data->vdd_reg);
+ regulator_bulk_disable(ARRAY_SIZE(data->regs), data->regs);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 2/4] iio: accel: mma8452: use local struct device
2026-08-08 16:58 [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 1/4] iio: accel: mma8452: convert to bulk regulator usage Sanjay Chitroda via B4 Relay
@ 2026-08-08 16:58 ` Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 3/4] iio: accel: mma8452: Use IIO cleanup helpers Sanjay Chitroda via B4 Relay
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-08-08 16:58 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Sanjay Chitroda, Andy Shevchenko
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Introduce a local struct device pointer derived from &client->dev.
This avoids repeated &client->dev usage and improves readability.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
---
changes in v4:
- address coding style comment given by Andy
- v3 link -> https://lore.kernel.org/all/20260505174640.3998281-8-sanjayembedded@gmail.com/
---
drivers/iio/accel/mma8452.c | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 772463d5ff47..af0cc5970f3b 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -222,15 +222,15 @@ static int mma8452_drdy(struct mma8452_data *data)
static int mma8452_set_runtime_pm_state(struct i2c_client *client, bool on)
{
#ifdef CONFIG_PM
+ struct device *dev = &client->dev;
int ret;
if (on)
- ret = pm_runtime_resume_and_get(&client->dev);
+ ret = pm_runtime_resume_and_get(dev);
else
- ret = pm_runtime_put_autosuspend(&client->dev);
+ ret = pm_runtime_put_autosuspend(dev);
if (ret < 0) {
- dev_err(&client->dev,
- "failed to change power state to %d\n", on);
+ dev_err(dev, "failed to change power state to %d\n", on);
return ret;
}
@@ -1552,7 +1552,7 @@ static int mma8452_probe(struct i2c_client *client)
struct iio_dev *indio_dev;
int ret;
- indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
@@ -1562,10 +1562,9 @@ static int mma8452_probe(struct i2c_client *client)
data->chip_info = i2c_get_match_data(client);
if (!data->chip_info)
- return dev_err_probe(&client->dev, -ENODEV,
- "unknown device model\n");
+ return dev_err_probe(dev, -ENODEV, "unknown device model\n");
- ret = iio_read_mount_matrix(&client->dev, &data->orientation);
+ ret = iio_read_mount_matrix(dev, &data->orientation);
if (ret)
return ret;
@@ -1598,7 +1597,7 @@ static int mma8452_probe(struct i2c_client *client)
goto disable_regulators;
}
- dev_info(&client->dev, "registering %s accelerometer; ID 0x%x\n",
+ dev_info(dev, "registering %s accelerometer; ID 0x%x\n",
data->chip_info->name, data->chip_info->chip_id);
i2c_set_clientdata(client, indio_dev);
@@ -1631,10 +1630,10 @@ static int mma8452_probe(struct i2c_client *client)
if (client->irq) {
int irq2;
- irq2 = fwnode_irq_get_byname(dev_fwnode(&client->dev), "INT2");
+ irq2 = fwnode_irq_get_byname(dev_fwnode(dev), "INT2");
if (irq2 == client->irq) {
- dev_dbg(&client->dev, "using interrupt line INT2\n");
+ dev_dbg(dev, "using interrupt line INT2\n");
} else {
ret = i2c_smbus_write_byte_data(client,
MMA8452_CTRL_REG5,
@@ -1642,7 +1641,7 @@ static int mma8452_probe(struct i2c_client *client)
if (ret < 0)
goto disable_regulators;
- dev_dbg(&client->dev, "using interrupt line INT1\n");
+ dev_dbg(dev, "using interrupt line INT1\n");
}
ret = i2c_smbus_write_byte_data(client,
@@ -1679,14 +1678,13 @@ static int mma8452_probe(struct i2c_client *client)
goto buffer_cleanup;
}
- ret = pm_runtime_set_active(&client->dev);
+ ret = pm_runtime_set_active(dev);
if (ret < 0)
goto free_irq;
- pm_runtime_enable(&client->dev);
- pm_runtime_set_autosuspend_delay(&client->dev,
- MMA8452_AUTO_SUSPEND_DELAY_MS);
- pm_runtime_use_autosuspend(&client->dev);
+ pm_runtime_enable(dev);
+ pm_runtime_set_autosuspend_delay(dev, MMA8452_AUTO_SUSPEND_DELAY_MS);
+ pm_runtime_use_autosuspend(dev);
ret = iio_device_register(indio_dev);
if (ret < 0)
@@ -1721,11 +1719,12 @@ static void mma8452_remove(struct i2c_client *client)
{
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct mma8452_data *data = iio_priv(indio_dev);
+ struct device *dev = &client->dev;
iio_device_unregister(indio_dev);
- pm_runtime_disable(&client->dev);
- pm_runtime_set_suspended(&client->dev);
+ pm_runtime_disable(dev);
+ pm_runtime_set_suspended(dev);
if (client->irq)
free_irq(client->irq, indio_dev);
@@ -1748,7 +1747,7 @@ static int mma8452_runtime_suspend(struct device *dev)
ret = mma8452_standby(data);
mutex_unlock(&data->lock);
if (ret < 0) {
- dev_err(&data->client->dev, "powering off device failed\n");
+ dev_err(dev, "powering off device failed\n");
return -EAGAIN;
}
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 3/4] iio: accel: mma8452: Use IIO cleanup helpers
2026-08-08 16:58 [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 1/4] iio: accel: mma8452: convert to bulk regulator usage Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 2/4] iio: accel: mma8452: use local struct device Sanjay Chitroda via B4 Relay
@ 2026-08-08 16:58 ` Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 4/4] iio: accel: mma8452: use guard() to release mutexes Sanjay Chitroda via B4 Relay
2026-08-10 0:03 ` [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Jonathan Cameron
4 siblings, 0 replies; 6+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-08-08 16:58 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Sanjay Chitroda, Andy Shevchenko,
Jonathan Cameron
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Use IIO_DEV_ACQUIRE_DIRECT_MODE() helper to automatically release
direct mode.
Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
---
drivers/iio/accel/mma8452.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index af0cc5970f3b..c78b1b742b08 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -495,14 +495,14 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
int i, ret;
switch (mask) {
- case IIO_CHAN_INFO_RAW:
- if (!iio_device_claim_direct(indio_dev))
+ case IIO_CHAN_INFO_RAW: {
+ IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
+ if (IIO_DEV_ACQUIRE_FAILED(claim))
return -EBUSY;
mutex_lock(&data->lock);
ret = mma8452_read(data, buffer);
mutex_unlock(&data->lock);
- iio_device_release_direct(indio_dev);
if (ret < 0)
return ret;
@@ -511,6 +511,7 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
chan->scan_type.realbits - 1);
return IIO_VAL_INT;
+ }
case IIO_CHAN_INFO_SCALE:
i = data->data_cfg & MMA8452_DATA_CFG_FS_MASK;
*val = data->chip_info->mma_scales[i][0];
@@ -777,14 +778,11 @@ static int mma8452_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val, int val2, long mask)
{
- int ret;
-
- if (!iio_device_claim_direct(indio_dev))
+ IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
+ if (IIO_DEV_ACQUIRE_FAILED(claim))
return -EBUSY;
- ret = __mma8452_write_raw(indio_dev, chan, val, val2, mask);
- iio_device_release_direct(indio_dev);
- return ret;
+ return __mma8452_write_raw(indio_dev, chan, val, val2, mask);
}
static int mma8452_get_event_regs(struct mma8452_data *data,
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 4/4] iio: accel: mma8452: use guard() to release mutexes
2026-08-08 16:58 [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Sanjay Chitroda via B4 Relay
` (2 preceding siblings ...)
2026-08-08 16:58 ` [PATCH v5 3/4] iio: accel: mma8452: Use IIO cleanup helpers Sanjay Chitroda via B4 Relay
@ 2026-08-08 16:58 ` Sanjay Chitroda via B4 Relay
2026-08-10 0:03 ` [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Jonathan Cameron
4 siblings, 0 replies; 6+ messages in thread
From: Sanjay Chitroda via B4 Relay @ 2026-08-08 16:58 UTC (permalink / raw)
To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko
Cc: linux-iio, linux-kernel, Sanjay Chitroda, Andy Shevchenko
From: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Replace explicit mutex_lock() and mutex_unlock() with the guard() and
scoped_guard() macro for cleaner and safer mutex handling.
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
---
changes in v4:
- add blank line with input from Andy
- v3 link -> https://lore.kernel.org/all/20260505174640.3998281-11-sanjayembedded@gmail.com/
changes in v3:
- Following input from Jonathan extended mutex scope for
IIO_CHAN_INFO_RAW case to include math operation under lock
- v2 link -> https://lore.kernel.org/all/20260422165643.2148195-7-sanjayembedded@gmail.com/
---
drivers/iio/accel/mma8452.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index c78b1b742b08..fe62a903f0e2 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -19,6 +19,7 @@
*/
#include <linux/array_size.h>
+#include <linux/cleanup.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
@@ -500,9 +501,9 @@ static int mma8452_read_raw(struct iio_dev *indio_dev,
if (IIO_DEV_ACQUIRE_FAILED(claim))
return -EBUSY;
- mutex_lock(&data->lock);
+ guard(mutex)(&data->lock);
+
ret = mma8452_read(data, buffer);
- mutex_unlock(&data->lock);
if (ret < 0)
return ret;
@@ -600,36 +601,30 @@ static int mma8452_change_config(struct mma8452_data *data, u8 reg, u8 val)
int ret;
int is_active;
- mutex_lock(&data->lock);
+ guard(mutex)(&data->lock);
is_active = mma8452_is_active(data);
- if (is_active < 0) {
- ret = is_active;
- goto fail;
- }
+ if (is_active < 0)
+ return is_active;
/* config can only be changed when in standby */
if (is_active > 0) {
ret = mma8452_standby(data);
if (ret < 0)
- goto fail;
+ return ret;
}
ret = i2c_smbus_write_byte_data(data->client, reg, val);
if (ret < 0)
- goto fail;
+ return ret;
if (is_active > 0) {
ret = mma8452_active(data);
if (ret < 0)
- goto fail;
+ return ret;
}
- ret = 0;
-fail:
- mutex_unlock(&data->lock);
-
- return ret;
+ return 0;
}
static int mma8452_set_power_mode(struct mma8452_data *data, u8 mode)
@@ -1741,9 +1736,8 @@ static int mma8452_runtime_suspend(struct device *dev)
struct mma8452_data *data = iio_priv(indio_dev);
int ret;
- mutex_lock(&data->lock);
- ret = mma8452_standby(data);
- mutex_unlock(&data->lock);
+ scoped_guard(mutex, &data->lock)
+ ret = mma8452_standby(data);
if (ret < 0) {
dev_err(dev, "powering off device failed\n");
return -EAGAIN;
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup
2026-08-08 16:58 [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Sanjay Chitroda via B4 Relay
` (3 preceding siblings ...)
2026-08-08 16:58 ` [PATCH v5 4/4] iio: accel: mma8452: use guard() to release mutexes Sanjay Chitroda via B4 Relay
@ 2026-08-10 0:03 ` Jonathan Cameron
4 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2026-08-10 0:03 UTC (permalink / raw)
To: Sanjay Chitroda via B4 Relay
Cc: sanjayembeddedse, David Lechner, Nuno Sá,
Andy Shevchenko, linux-iio, linux-kernel, Andy Shevchenko
On Sat, 08 Aug 2026 22:28:12 +0530
Sanjay Chitroda via B4 Relay <devnull+sanjayembeddedse.gmail.com@kernel.org> wrote:
> Hi all,
>
> This series contains a nuber of small fixes, cleanup and improvements
> for the mma8452 accelerometer driver.
>
> The changes modernize macro like mutex with guard(), bulk regulator,
> IIO_DEV_ACQUIRE_DIRECT_MODE() and etc.
>
Applied to the testing branch of iio.git. Note that branch will be
rebased on rc1 once available in about 3 weeks time (and maybe
I'll rebase on intermediate baselines in between).
Thanks,
Jonathan
> Changes in v5:
> - Drop the PM runtime handling patch, as suitable hardware is not
> available to properly validate the PM state transitions.
> - Apply reviewed tags.
> - Rebase series onto the latest iio/testing branch.
> - Link to v4: https://patch.msgid.link/20260602-15-apr-pm-iio-mma8452-v4-temp-v4-0-26d6dff8fc55@gmail.com
> Changes in v4:
> - Part of the series already merged into the IIO tree; rebase the
> remaining patches onto the latest iio/testing branch.
> - Link to v3: https://lore.kernel.org/all/20260602-15-apr-pm-iio-mma8452-v4-temp-v4-0-26d6dff8fc55@gmail.com
> Changes in v3:
> - Following input from Andy and Jonathan added new changes as following
> 0001: handle return value to have proper error propagation
> 0002: use non-devm API to maintain resource management LIFO order
> 0006: convert individual regulator using bulk regulator API
> 0009: use IIO cleanup helper for DIRECT_MODE
> - Address kernel coding stype specific review comment
> - Reorder local struct device and dev_err_probe change
> v2 series -> https://lore.kernel.org/all/20260422165643.2148195-1-sanjayembedded@gmail.com/
> Changes in v2:
> - 0005: address review comment from Andy and Geert
> and use DEFINE_RUNTIME_DEV_PM_OPS macro
> - Added new cleanup channges in mma8452 driver
>
> No functional behavior changes are intended.
>
> Testing:
> - Compiled with W=1
> - Build-tested on QEMU x86_64
>
> Feedback and reviews are very welcome.
>
> ---
> Sanjay Chitroda (4):
> iio: accel: mma8452: convert to bulk regulator usage
> iio: accel: mma8452: use local struct device
> iio: accel: mma8452: Use IIO cleanup helpers
> iio: accel: mma8452: use guard() to release mutexes
>
> drivers/iio/accel/mma8452.c | 145 +++++++++++++++++---------------------------
> 1 file changed, 54 insertions(+), 91 deletions(-)
> ---
> base-commit: 350d1fb9204b13c5f95e511e98b8bcb47574d425
> change-id: 20260601-15-apr-pm-iio-mma8452-v4-temp-e040489abec3
>
> Best regards,
> --
> Sanjay Chitroda <sanjayembeddedse@gmail.com>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-08-10 0:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-08 16:58 [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 1/4] iio: accel: mma8452: convert to bulk regulator usage Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 2/4] iio: accel: mma8452: use local struct device Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 3/4] iio: accel: mma8452: Use IIO cleanup helpers Sanjay Chitroda via B4 Relay
2026-08-08 16:58 ` [PATCH v5 4/4] iio: accel: mma8452: use guard() to release mutexes Sanjay Chitroda via B4 Relay
2026-08-10 0:03 ` [PATCH v5 0/4] iio: accel: mma8452: use modern coding style and resource cleanup Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®