Rewrite the IIO_DEVICE_ATTR_NAMED API to pass name as string.
Subsystems (5)
cover Rewrite the IIO_DEVICE_ATTR_NAMED API to pass name as string.
This patchset is to rewrite the IIO_DEVICE_ATTR_NAMED API to pass name as string.
Himanshi Jain (2):
include: linux: sysfs: Add __ATTR_NAMED macro
iio: Use __ATTR_NAMED to allow passing name as string to
IIO_DEVICE_ATTR_NAMED and change usage to pass string
drivers/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7192.c | 2 +- drivers/staging/iio/adc/ad7280a.c | 4 ++-- include/linux/iio/sysfs.h | 6 +++++- include/linux/sysfs.h | 7 +++++++ 5 files changed, 16 insertions(+), 5 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 include: linux: sysfs: Add __ATTR_NAMED macro
Add __ATTR_NAMED macro similar to __ATTR but taking name as a string instead of implicit conversion of argument to string using the macro _stringify(_name).
--- include/linux/sysfs.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/linux/sysfs.h +7 -0
@@ -104,6 +104,13 @@ struct attribute_group { .store = _store, \ } +#define __ATTR_NAMED (_name, _mode, _show, _store) { \ + .attr = {.name = _name, \ + .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ + .show = _show, \ + .store = _store, \ +} +#define __ATTR_PREALLOC (_name, _mode, _show, _store) { \ .attr = {.name = __stringify(_name), \ .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\
Signature · 1 line
1.9.1
PATCH 2/2 iio: Use __ATTR_NAMED to allow passing name as string to IIO_DEVICE_ATTR_NAMED and change usage to pass string
Add IIO_ATTR_NAMED macro to use __ATTR_NAMED to allow passing name as string to IIO_DEVICE_ATTR_NAMED. Change current usage of IIO_DEVICE_ATTR_NAMED to pass name as string.
--- drivers/iio/adc/ad7793.c | 2 +- drivers/staging/iio/adc/ad7192.c | 2 +- drivers/staging/iio/adc/ad7280a.c | 4 ++-- include/linux/iio/sysfs.h | 6 +++++- 4 files changed, 9 insertions(+), 5 deletions(-)
drivers/iio/adc/ad7793.c +1 -1
@@ -420,7 +420,7 @@ static ssize_t ad7793_show_scale_available(struct device *dev, } static IIO_DEVICE_ATTR_NAMED(in_m_in_scale_available, - in_voltage-voltage_scale_available, S_IRUGO, +"in_voltage-voltage_scale_available" ,S_IRUGO , ad7793_show_scale_available, NULL, 0);static struct attribute *ad7793_attributes[] = {
drivers/staging/iio/adc/ad7192.c +1 -1
@@ -341,7 +341,7 @@ static int ad7192_setup(struct ad7192_state *st, } static IIO_DEVICE_ATTR_NAMED(in_v_m_v_scale_available, - in_voltage-voltage_scale_available, +"in_voltage-voltage_scale_available" , 0444, ad7192_show_scale_available, NULL, 0); static IIO_DEVICE_ATTR(in_voltage_scale_available, 0444,
drivers/staging/iio/adc/ad7280a.c +2 -2
@@ -750,14 +750,14 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) } static IIO_DEVICE_ATTR_NAMED(in_thresh_low_value, - in_voltage-voltage_thresh_low_value, +"in_voltage-voltage_thresh_low_value" ,0644 , ad7280_read_channel_config, ad7280_write_channel_config, AD7280A_CELL_UNDERVOLTAGE); static IIO_DEVICE_ATTR_NAMED(in_thresh_high_value, - in_voltage-voltage_thresh_high_value, +"in_voltage-voltage_thresh_high_value" ,0644 , ad7280_read_channel_config, ad7280_write_channel_config,
include/linux/iio/sysfs.h +5 -1
@@ -55,6 +55,10 @@ struct iio_const_attr { { .dev_attr = __ATTR(_name, _mode, _show, _store), \ .address = _addr } +#define IIO_ATTR_NAMED (_name, _mode, _show, _store, _addr) \ + { .dev_attr = __ATTR_NAMED(_name, _mode, _show, _store), \ + .address = _addr } +#define IIO_ATTR_RO (_name, _addr) \ { .dev_attr = __ATTR_RO(_name), \ .address = _addr }
@@ -85,7 +89,7 @@ struct iio_const_attr {#define IIO_DEVICE_ATTR_NAMED (_vname, _name, _mode, _show, _store, _addr) \ struct iio_dev_attr iio_dev_attr_##_vname \ - = IIO_ATTR(_name, _mode, _show, _store, _addr) + = IIO_ATTR_NAMED(_name, _mode, _show, _store, _addr)#define IIO_CONST_ATTR (_name, _string) \ struct iio_const_attr iio_const_attr_##_name \
Signature · 1 line
1.9.1
Re: [PATCH 2/2] iio: Use __ATTR_NAMED to allow passing name as string to IIO_DEVICE_ATTR_NAMED and change usage to pass string
Quoted 5 lines · Himanshi Jain
Add
IIO_ATTR_NAMEDmacro to use__ATTR_NAMEDto allow passing name as string toIIO_DEVICE_ATTR_NAMED. Change current usage ofIIO_DEVICE_ATTR_NAMEDto pass name as string.Signed-off-by Himanshi Jain <[email protected]>
This version looks nice. The subject is just *way* too long, though. Also you have put a v2 in the subject and a little changelog after the --- cut off. Just call it something like:
[PATCH 2/2 v2] iio: Change to __ATTR_NAMED()
regards,
dan carpenter
Re: [PATCH 2/2] iio: Use __ATTR_NAMED to allow passing name as string to IIO_DEVICE_ATTR_NAMED and change usage to pass string
Quoted 7 lines · Dan Carpenter
Quoted 5 lines · Himanshi Jain
Add
IIO_ATTR_NAMEDmacro to use__ATTR_NAMEDto allow passing name as string toIIO_DEVICE_ATTR_NAMED. Change current usage ofIIO_DEVICE_ATTR_NAMEDto pass name as string.Signed-off-by Himanshi Jain <[email protected]>
Quoted 7 lines
This version looks nice. The subject is just *way* too long, though. Also you have put a v2 in the subject and a little changelog after the --- cut off. Just call it something like:
[PATCH 2/2 v2] iio: Change to__ATTR_NAMED()regards,
dan carpenter
Thank you for the review Dan! Does it look fine now in v2?