diff mbox series

[v3,09/10] iio: at91-sama5d2_adc: Use IIO_STATIC_CONST_DEVICE_ATTR()

Message ID 4476a4ce852febb3eb863878e66751c787195b18.1664782676.git.mazziesaccount@gmail.com (mailing list archive)
State Accepted
Headers show
Series iio: Fix unsafe buffer attributes | expand

Commit Message

Matti Vaittinen Oct. 3, 2022, 8:13 a.m. UTC
Slightly simplify by dropping open-coded constant data iio_dev_attr
functions and using the IIO_STATIC_CONST_DEVICE_ATTR() instead.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

Comments

Claudiu Beznea Oct. 6, 2022, 8:35 a.m. UTC | #1
On 03.10.2022 11:13, Matti Vaittinen wrote:
> Slightly simplify by dropping open-coded constant data iio_dev_attr
> functions and using the IIO_STATIC_CONST_DEVICE_ATTR() instead.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>

on SAMA5D2
diff mbox series

Patch

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index 6e3f9fa93cee..dca014d1108f 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -1841,26 +1841,13 @@  static ssize_t at91_adc_get_watermark(struct device *dev,
 	return scnprintf(buf, PAGE_SIZE, "%d\n", st->dma_st.watermark);
 }
 
-static ssize_t hwfifo_watermark_min_show(struct device *dev,
-					 struct device_attribute *attr,
-					 char *buf)
-{
-	return sysfs_emit(buf, "%s\n", "2");
-}
-
-static ssize_t hwfifo_watermark_max_show(struct device *dev,
-					 struct device_attribute *attr,
-					 char *buf)
-{
-	return sysfs_emit(buf, "%s\n", AT91_HWFIFO_MAX_SIZE_STR);
-}
-
 static IIO_DEVICE_ATTR(hwfifo_enabled, 0444,
 		       at91_adc_get_fifo_state, NULL, 0);
 static IIO_DEVICE_ATTR(hwfifo_watermark, 0444,
 		       at91_adc_get_watermark, NULL, 0);
-static IIO_DEVICE_ATTR_RO(hwfifo_watermark_min, 0);
-static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
+
+IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_watermark_min, "2");
+IIO_STATIC_CONST_DEVICE_ATTR(hwfifo_watermark_max, AT91_HWFIFO_MAX_SIZE_STR);
 
 static IIO_CONST_ATTR(oversampling_ratio_available,
 		      __stringify(AT91_OSR_1SAMPLES) " "