* [PATCH v2 0/4] staging: iio: adc: ad7816: code cleanups and modernization
@ 2026-03-30 17:40 Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0 Md. Mahmudul Hasan Mabud
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Md. Mahmudul Hasan Mabud @ 2026-03-30 17:40 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Greg Kroah-Hartman
Cc: Andy Shevchenko, David Lechner, Nuno Sá, linux-iio,
linux-staging, linux-kernel, Md. Mahmudul Hasan Mabud
This series addresses feedback from Andy Shevchenko to modernize and clean
up the ad7816 driver.
Changes in v2:
- Renamed sysfs callback functions (e.g., ad7816_show_mode to mode_show)
to satisfy the requirements of modern IIO attribute macros and fix
compilation errors.
- Fixed usage of sysfs_match_string() by removing the unnecessary
ARRAY_SIZE parameter.
- Fixed vertical alignment of function parameters to match open parenthesis.
- Replaced sprintf() with sysfs_emit() across all show attributes.
Md. Mahmudul Hasan Mabud (4):
staging: iio: adc: ad7816: redefine mode constants to start from 0
staging: iio: adc: ad7816: use sysfs_match_string() for mode selection
staging: iio: adc: ad7816: replace sprintf() with sysfs_emit()
staging: iio: adc: ad7816: use modern IIO attribute macros
drivers/staging/iio/adc/ad7816.c | 111 +++++++++++++++----------------
1 file changed, 53 insertions(+), 58 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0
2026-03-30 17:40 [PATCH v2 0/4] staging: iio: adc: ad7816: code cleanups and modernization Md. Mahmudul Hasan Mabud
@ 2026-03-30 17:40 ` Md. Mahmudul Hasan Mabud
2026-03-30 17:48 ` Greg Kroah-Hartman
2026-03-30 17:40 ` [PATCH v2 2/4] staging: iio: adc: ad7816: use sysfs_match_string() for mode selection Md. Mahmudul Hasan Mabud
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Md. Mahmudul Hasan Mabud @ 2026-03-30 17:40 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Greg Kroah-Hartman
Cc: Andy Shevchenko, David Lechner, Nuno Sá, linux-iio,
linux-staging, linux-kernel, Md. Mahmudul Hasan Mabud
---
drivers/staging/iio/adc/ad7816.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 172acf135..5acfceb90 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -22,8 +22,8 @@
/*
* AD7816 config masks
*/
-#define AD7816_FULL 0x1
-#define AD7816_PD 0x2
+#define AD7816_FULL 0
+#define AD7816_PD 1
#define AD7816_CS_MASK 0x7
#define AD7816_CS_MAX 0x4
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/4] staging: iio: adc: ad7816: use sysfs_match_string() for mode selection
2026-03-30 17:40 [PATCH v2 0/4] staging: iio: adc: ad7816: code cleanups and modernization Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0 Md. Mahmudul Hasan Mabud
@ 2026-03-30 17:40 ` Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 3/4] staging: iio: adc: ad7816: replace sprintf() with sysfs_emit() Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 4/4] staging: iio: adc: ad7816: use modern IIO attribute macros Md. Mahmudul Hasan Mabud
3 siblings, 0 replies; 6+ messages in thread
From: Md. Mahmudul Hasan Mabud @ 2026-03-30 17:40 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Greg Kroah-Hartman
Cc: Andy Shevchenko, David Lechner, Nuno Sá, linux-iio,
linux-staging, linux-kernel, Md. Mahmudul Hasan Mabud
---
drivers/staging/iio/adc/ad7816.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index 5acfceb90..f9a0a5a69 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -58,6 +58,11 @@ enum ad7816_type {
ID_AD7818,
};
+static const char * const ad7816_modes[] = {
+ [AD7816_FULL] = "full",
+ [AD7816_PD] = "power-save",
+};
+
/*
* ad7816 data access by SPI
*/
@@ -135,14 +140,14 @@ static ssize_t ad7816_store_mode(struct device *dev,
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
+ int ret;
- if (strcmp(buf, "full") == 0) {
- gpiod_set_value(chip->rdwr_pin, 1);
- chip->mode = AD7816_FULL;
- } else {
- gpiod_set_value(chip->rdwr_pin, 0);
- chip->mode = AD7816_PD;
- }
+ ret = sysfs_match_string(ad7816_modes, buf);
+ if (ret < 0)
+ return ret;
+
+ chip->mode = ret;
+ gpiod_set_value(chip->rdwr_pin, ret == AD7816_FULL);
return len;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/4] staging: iio: adc: ad7816: replace sprintf() with sysfs_emit()
2026-03-30 17:40 [PATCH v2 0/4] staging: iio: adc: ad7816: code cleanups and modernization Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0 Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 2/4] staging: iio: adc: ad7816: use sysfs_match_string() for mode selection Md. Mahmudul Hasan Mabud
@ 2026-03-30 17:40 ` Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 4/4] staging: iio: adc: ad7816: use modern IIO attribute macros Md. Mahmudul Hasan Mabud
3 siblings, 0 replies; 6+ messages in thread
From: Md. Mahmudul Hasan Mabud @ 2026-03-30 17:40 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Greg Kroah-Hartman
Cc: Andy Shevchenko, David Lechner, Nuno Sá, linux-iio,
linux-staging, linux-kernel, Md. Mahmudul Hasan Mabud
---
drivers/staging/iio/adc/ad7816.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index f9a0a5a69..f2486cb29 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -128,9 +128,7 @@ static ssize_t ad7816_show_mode(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
- if (chip->mode)
- return sprintf(buf, "power-save\n");
- return sprintf(buf, "full\n");
+ return sysfs_emit(buf, "%s\n", ad7816_modes[chip->mode]);
}
static ssize_t ad7816_store_mode(struct device *dev,
@@ -161,7 +159,7 @@ static ssize_t ad7816_show_available_modes(struct device *dev,
struct device_attribute *attr,
char *buf)
{
- return sprintf(buf, "full\npower-save\n");
+ return sysfs_emit(buf, "full\npower-save\n");
}
static IIO_DEVICE_ATTR(available_modes, 0444, ad7816_show_available_modes,
@@ -174,7 +172,7 @@ static ssize_t ad7816_show_channel(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
- return sprintf(buf, "%d\n", chip->channel_id);
+ return sysfs_emit(buf, "%d\n", chip->channel_id);
}
static ssize_t ad7816_store_channel(struct device *dev,
@@ -236,9 +234,9 @@ static ssize_t ad7816_show_value(struct device *dev,
data &= AD7816_TEMP_FLOAT_MASK;
if (value < 0)
data = BIT(AD7816_TEMP_FLOAT_OFFSET) - data;
- return sprintf(buf, "%d.%.2d\n", value, data * 25);
+ return sysfs_emit(buf, "%d.%.2d\n", value, data * 25);
}
- return sprintf(buf, "%u\n", data);
+ return sysfs_emit(buf, "%u\n", data);
}
static IIO_DEVICE_ATTR(value, 0444, ad7816_show_value, NULL, 0);
@@ -286,9 +284,9 @@ static ssize_t ad7816_show_oti(struct device *dev,
value = AD7816_BOUND_VALUE_MIN +
(chip->oti_data[chip->channel_id] -
AD7816_BOUND_VALUE_BASE);
- return sprintf(buf, "%d\n", value);
+ return sysfs_emit(buf, "%d\n", value);
}
- return sprintf(buf, "%u\n", chip->oti_data[chip->channel_id]);
+ return sysfs_emit(buf, "%u\n", chip->oti_data[chip->channel_id]);
}
static inline ssize_t ad7816_set_oti(struct device *dev,
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/4] staging: iio: adc: ad7816: use modern IIO attribute macros
2026-03-30 17:40 [PATCH v2 0/4] staging: iio: adc: ad7816: code cleanups and modernization Md. Mahmudul Hasan Mabud
` (2 preceding siblings ...)
2026-03-30 17:40 ` [PATCH v2 3/4] staging: iio: adc: ad7816: replace sprintf() with sysfs_emit() Md. Mahmudul Hasan Mabud
@ 2026-03-30 17:40 ` Md. Mahmudul Hasan Mabud
3 siblings, 0 replies; 6+ messages in thread
From: Md. Mahmudul Hasan Mabud @ 2026-03-30 17:40 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Greg Kroah-Hartman
Cc: Andy Shevchenko, David Lechner, Nuno Sá, linux-iio,
linux-staging, linux-kernel, Md. Mahmudul Hasan Mabud
---
drivers/staging/iio/adc/ad7816.c | 72 ++++++++++++++------------------
1 file changed, 32 insertions(+), 40 deletions(-)
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index f2486cb29..80f84e2bb 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -121,9 +121,9 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data)
return ret;
}
-static ssize_t ad7816_show_mode(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t mode_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -131,10 +131,10 @@ static ssize_t ad7816_show_mode(struct device *dev,
return sysfs_emit(buf, "%s\n", ad7816_modes[chip->mode]);
}
-static ssize_t ad7816_store_mode(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+static ssize_t mode_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -150,24 +150,20 @@ static ssize_t ad7816_store_mode(struct device *dev,
return len;
}
-static IIO_DEVICE_ATTR(mode, 0644,
- ad7816_show_mode,
- ad7816_store_mode,
- 0);
+static IIO_DEVICE_ATTR_RW(mode, 0);
-static ssize_t ad7816_show_available_modes(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t available_modes_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
return sysfs_emit(buf, "full\npower-save\n");
}
-static IIO_DEVICE_ATTR(available_modes, 0444, ad7816_show_available_modes,
- NULL, 0);
+static IIO_DEVICE_ATTR_RO(available_modes, 0);
-static ssize_t ad7816_show_channel(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t channel_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -175,10 +171,10 @@ static ssize_t ad7816_show_channel(struct device *dev,
return sysfs_emit(buf, "%d\n", chip->channel_id);
}
-static ssize_t ad7816_store_channel(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+static ssize_t channel_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -208,14 +204,11 @@ static ssize_t ad7816_store_channel(struct device *dev,
return len;
}
-static IIO_DEVICE_ATTR(channel, 0644,
- ad7816_show_channel,
- ad7816_store_channel,
- 0);
+static IIO_DEVICE_ATTR_RW(channel, 0);
-static ssize_t ad7816_show_value(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t value_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -239,7 +232,7 @@ static ssize_t ad7816_show_value(struct device *dev,
return sysfs_emit(buf, "%u\n", data);
}
-static IIO_DEVICE_ATTR(value, 0444, ad7816_show_value, NULL, 0);
+static IIO_DEVICE_ATTR_RO(value, 0);
static struct attribute *ad7816_attributes[] = {
&iio_dev_attr_available_modes.dev_attr.attr,
@@ -269,9 +262,9 @@ static irqreturn_t ad7816_event_handler(int irq, void *private)
return IRQ_HANDLED;
}
-static ssize_t ad7816_show_oti(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t oti_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -289,10 +282,10 @@ static ssize_t ad7816_show_oti(struct device *dev,
return sysfs_emit(buf, "%u\n", chip->oti_data[chip->channel_id]);
}
-static inline ssize_t ad7816_set_oti(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+static inline ssize_t oti_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad7816_chip_info *chip = iio_priv(indio_dev);
@@ -330,8 +323,7 @@ static inline ssize_t ad7816_set_oti(struct device *dev,
return len;
}
-static IIO_DEVICE_ATTR(oti, 0644,
- ad7816_show_oti, ad7816_set_oti, 0);
+static IIO_DEVICE_ATTR_RW(oti, 0);
static struct attribute *ad7816_event_attributes[] = {
&iio_dev_attr_oti.dev_attr.attr,
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0
2026-03-30 17:40 ` [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0 Md. Mahmudul Hasan Mabud
@ 2026-03-30 17:48 ` Greg Kroah-Hartman
0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2026-03-30 17:48 UTC (permalink / raw)
To: Md. Mahmudul Hasan Mabud
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Andy Shevchenko, David Lechner, Nuno Sá, linux-iio,
linux-staging, linux-kernel
On Mon, Mar 30, 2026 at 11:40:21PM +0600, Md. Mahmudul Hasan Mabud wrote:
> ---
> drivers/staging/iio/adc/ad7816.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
> index 172acf135..5acfceb90 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -22,8 +22,8 @@
> /*
> * AD7816 config masks
> */
> -#define AD7816_FULL 0x1
> -#define AD7816_PD 0x2
> +#define AD7816_FULL 0
> +#define AD7816_PD 1
> #define AD7816_CS_MASK 0x7
> #define AD7816_CS_MAX 0x4
>
> --
> 2.34.1
>
>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- Your patch does not have a Signed-off-by: line. Please read the
kernel file, Documentation/process/submitting-patches.rst and resend
it after adding that line. Note, the line needs to be in the body of
the email, before the patch, not at the bottom of the patch or in the
email signature.
- You did not specify a description of why the patch is needed, or
possibly, any description at all, in the email body. Please read the
section entitled "The canonical patch format" in the kernel file,
Documentation/process/submitting-patches.rst for what is needed in
order to properly describe the change.
- You did not write a descriptive Subject: for the patch, allowing Greg,
and everyone else, to know what this patch is all about. Please read
the section entitled "The canonical patch format" in the kernel file,
Documentation/process/submitting-patches.rst for what a proper
Subject: line should look like.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-30 17:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 17:40 [PATCH v2 0/4] staging: iio: adc: ad7816: code cleanups and modernization Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 1/4] staging: iio: adc: ad7816: redefine mode constants to start from 0 Md. Mahmudul Hasan Mabud
2026-03-30 17:48 ` Greg Kroah-Hartman
2026-03-30 17:40 ` [PATCH v2 2/4] staging: iio: adc: ad7816: use sysfs_match_string() for mode selection Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 3/4] staging: iio: adc: ad7816: replace sprintf() with sysfs_emit() Md. Mahmudul Hasan Mabud
2026-03-30 17:40 ` [PATCH v2 4/4] staging: iio: adc: ad7816: use modern IIO attribute macros Md. Mahmudul Hasan Mabud
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox