* [PATCH v4 0/3] iio: dac: m62332: header cleanup and guard(mutex)
@ 2026-06-27 13:25 Erick Henrique
2026-06-27 13:25 ` [PATCH v4 1/3] iio: dac: m62332: Sort header includes alphabetically Erick Henrique
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Erick Henrique @ 2026-06-27 13:25 UTC (permalink / raw)
To: jic23; +Cc: andriy.shevchenko, andy, dlechner, nuno.sa, linux-iio,
Erick Henrique
This series cleans up the m62332 header includes and converts its locking
to guard(mutex).
Changes in v4:
- Split the include cleanup in two: 1/3 only re-sorts the existing
includes; 2/3 does the IWYU add/remove (per Jonathan's review).
- 2/3: drop the unused slab.h and add the specific headers the file uses
(array_size.h, bits.h, mutex.h, pm.h, types.h, mod_devicetable.h).
- 3/3 (guard(mutex)): unchanged from v3.
v3: https://lore.kernel.org/r/20260418130322.106769-1-erick.henrique.rodrigues@usp.br
Erick Henrique (3):
iio: dac: m62332: Sort header includes alphabetically
iio: dac: m62332: Clean up header includes
iio: dac: m62332: Use guard(mutex) for locking
drivers/iio/dac/m62332.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
base-commit: 4b570552ea4788d49373d3e31c5a802210f4ac45
--
2.51.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v4 1/3] iio: dac: m62332: Sort header includes alphabetically
2026-06-27 13:25 [PATCH v4 0/3] iio: dac: m62332: header cleanup and guard(mutex) Erick Henrique
@ 2026-06-27 13:25 ` Erick Henrique
2026-06-27 17:34 ` Joshua Crofts
2026-06-27 13:25 ` [PATCH v4 2/3] iio: dac: m62332: Clean up header includes Erick Henrique
2026-06-27 13:25 ` [PATCH v4 3/3] iio: dac: m62332: Use guard(mutex) for locking Erick Henrique
2 siblings, 1 reply; 7+ messages in thread
From: Erick Henrique @ 2026-06-27 13:25 UTC (permalink / raw)
To: jic23; +Cc: andriy.shevchenko, andy, dlechner, nuno.sa, linux-iio,
Erick Henrique
Sort the existing header includes alphabetically within their groups.
No headers are added or removed; this only reorders them so the
following include cleanup is easier to review.
Signed-off-by: Erick Henrique <erick.henrique.rodrigues@usp.br>
---
drivers/iio/dac/m62332.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
index 3497513854d7..56cd0081afde 100644
--- a/drivers/iio/dac/m62332.c
+++ b/drivers/iio/dac/m62332.c
@@ -8,13 +8,13 @@
* Copyright (C) 2010, 2011 Roland Stigge <stigge@antcom.de>
*/
+#include <linux/err.h>
+#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/err.h>
-#include <linux/iio/iio.h>
#include <linux/iio/driver.h>
+#include <linux/iio/iio.h>
#include <linux/regulator/consumer.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] iio: dac: m62332: Clean up header includes
2026-06-27 13:25 [PATCH v4 0/3] iio: dac: m62332: header cleanup and guard(mutex) Erick Henrique
2026-06-27 13:25 ` [PATCH v4 1/3] iio: dac: m62332: Sort header includes alphabetically Erick Henrique
@ 2026-06-27 13:25 ` Erick Henrique
2026-06-27 17:40 ` Joshua Crofts
2026-06-27 13:25 ` [PATCH v4 3/3] iio: dac: m62332: Use guard(mutex) for locking Erick Henrique
2 siblings, 1 reply; 7+ messages in thread
From: Erick Henrique @ 2026-06-27 13:25 UTC (permalink / raw)
To: jic23; +Cc: andriy.shevchenko, andy, dlechner, nuno.sa, linux-iio,
Erick Henrique
Follow the IWYU principle: include specific headers for the symbols
used in this file and drop the unused slab.h. Add array_size.h, bits.h,
mutex.h, pm.h and types.h for symbols that were previously pulled in
only indirectly, and add mod_devicetable.h for the device ID table.
This prepares the driver for the guard(mutex) conversion that follows.
Signed-off-by: Erick Henrique <erick.henrique.rodrigues@usp.br>
---
drivers/iio/dac/m62332.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
index 56cd0081afde..ee8fd3a71315 100644
--- a/drivers/iio/dac/m62332.c
+++ b/drivers/iio/dac/m62332.c
@@ -8,10 +8,16 @@
* Copyright (C) 2010, 2011 Roland Stigge <stigge@antcom.de>
*/
+#include <linux/array_size.h>
+#include <linux/bits.h>
+#include <linux/device.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/slab.h>
+#include <linux/mutex.h>
+#include <linux/pm.h>
+#include <linux/types.h>
#include <linux/iio/driver.h>
#include <linux/iio/iio.h>
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 2/3] iio: dac: m62332: Clean up header includes
2026-06-27 13:25 ` [PATCH v4 2/3] iio: dac: m62332: Clean up header includes Erick Henrique
@ 2026-06-27 17:40 ` Joshua Crofts
0 siblings, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-06-27 17:40 UTC (permalink / raw)
To: Erick Henrique
Cc: jic23, andriy.shevchenko, andy, dlechner, nuno.sa, linux-iio
On Sat, 27 Jun 2026 10:25:29 -0300
Erick Henrique <erick.henrique.rodrigues@usp.br> wrote:
> Follow the IWYU principle: include specific headers for the symbols
> used in this file and drop the unused slab.h. Add array_size.h, bits.h,
> mutex.h, pm.h and types.h for symbols that were previously pulled in
> only indirectly, and add mod_devicetable.h for the device ID table.
> This prepares the driver for the guard(mutex) conversion that follows.
>
> Signed-off-by: Erick Henrique <erick.henrique.rodrigues@usp.br>
> ---
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] iio: dac: m62332: Use guard(mutex) for locking
2026-06-27 13:25 [PATCH v4 0/3] iio: dac: m62332: header cleanup and guard(mutex) Erick Henrique
2026-06-27 13:25 ` [PATCH v4 1/3] iio: dac: m62332: Sort header includes alphabetically Erick Henrique
2026-06-27 13:25 ` [PATCH v4 2/3] iio: dac: m62332: Clean up header includes Erick Henrique
@ 2026-06-27 13:25 ` Erick Henrique
2026-06-27 17:44 ` Joshua Crofts
2 siblings, 1 reply; 7+ messages in thread
From: Erick Henrique @ 2026-06-27 13:25 UTC (permalink / raw)
To: jic23; +Cc: andriy.shevchenko, andy, dlechner, nuno.sa, linux-iio,
Erick Henrique
Replace mutex_lock()/mutex_unlock() calls with guard(mutex)() to
simplify locking and make cleanup automatic when the lock goes out
of scope. Also simplify the i2c_master_send() error handling by
using sequential early returns instead of a combined condition.
Signed-off-by: Erick Henrique <erick.henrique.rodrigues@usp.br>
---
drivers/iio/dac/m62332.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
index ee8fd3a71315..10ff6727b76c 100644
--- a/drivers/iio/dac/m62332.c
+++ b/drivers/iio/dac/m62332.c
@@ -47,33 +47,26 @@ static int m62332_set_value(struct iio_dev *indio_dev, u8 val, int channel)
outbuf[0] = channel;
outbuf[1] = val;
- mutex_lock(&data->mutex);
+ guard(mutex)(&data->mutex);
if (val) {
res = regulator_enable(data->vcc);
if (res)
- goto out;
+ return res;
}
res = i2c_master_send(client, outbuf, ARRAY_SIZE(outbuf));
- if (res >= 0 && res != ARRAY_SIZE(outbuf))
- res = -EIO;
if (res < 0)
- goto out;
+ return res;
+ if (res != ARRAY_SIZE(outbuf))
+ return -EIO;
data->raw[channel] = val;
if (!val)
regulator_disable(data->vcc);
- mutex_unlock(&data->mutex);
-
return 0;
-
-out:
- mutex_unlock(&data->mutex);
-
- return res;
}
static int m62332_read_raw(struct iio_dev *indio_dev,
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v4 3/3] iio: dac: m62332: Use guard(mutex) for locking
2026-06-27 13:25 ` [PATCH v4 3/3] iio: dac: m62332: Use guard(mutex) for locking Erick Henrique
@ 2026-06-27 17:44 ` Joshua Crofts
0 siblings, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-06-27 17:44 UTC (permalink / raw)
To: Erick Henrique
Cc: jic23, andriy.shevchenko, andy, dlechner, nuno.sa, linux-iio
On Sat, 27 Jun 2026 10:25:30 -0300
Erick Henrique <erick.henrique.rodrigues@usp.br> wrote:
> Replace mutex_lock()/mutex_unlock() calls with guard(mutex)() to
> simplify locking and make cleanup automatic when the lock goes out
> of scope. Also simplify the i2c_master_send() error handling by
> using sequential early returns instead of a combined condition.
>
> Signed-off-by: Erick Henrique <erick.henrique.rodrigues@usp.br>
> ---
> drivers/iio/dac/m62332.c | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
> index ee8fd3a71315..10ff6727b76c 100644
> --- a/drivers/iio/dac/m62332.c
> +++ b/drivers/iio/dac/m62332.c
> @@ -47,33 +47,26 @@ static int m62332_set_value(struct iio_dev *indio_dev, u8 val, int channel)
> outbuf[0] = channel;
> outbuf[1] = val;
>
> - mutex_lock(&data->mutex);
> + guard(mutex)(&data->mutex);
You're missing #include <linux/cleanup.h>.
--
Kind regards
CJD
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-06-27 17:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-27 13:25 [PATCH v4 0/3] iio: dac: m62332: header cleanup and guard(mutex) Erick Henrique
2026-06-27 13:25 ` [PATCH v4 1/3] iio: dac: m62332: Sort header includes alphabetically Erick Henrique
2026-06-27 17:34 ` Joshua Crofts
2026-06-27 13:25 ` [PATCH v4 2/3] iio: dac: m62332: Clean up header includes Erick Henrique
2026-06-27 17:40 ` Joshua Crofts
2026-06-27 13:25 ` [PATCH v4 3/3] iio: dac: m62332: Use guard(mutex) for locking Erick Henrique
2026-06-27 17:44 ` Joshua Crofts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox