Re: [Outreachy kernel] [PATCH] Fixed IIO_DEVICE_ATTR_NAMED API to take name as a string and added "" around names

2017-09-12 Thread himanshi
Thanks for the review Daniel! I will change the imperative mood for the commit 
message once the other changes are finalised too and as suggested by Julia,
would try to make the description specific than general.

I tried to think of adding subsystem to the commit subject but could not 
conclude any because of the files involved.
I like the idea of splitting the patch into 2 as you suggested but I
have a doubt that adding the new MACROS to different sysfs files can be put 
into 1
patch with the subsystem you mentioned but changing the existing
IIO_DEVICE_ATTR_NAMED to use IIO_ATTR_NAMED (sysfs file again) would be included
in the second patch if I am not wrong. So would it be fine to keep the
subsystem as iio for the second patch?

On Tue, Sep 12, 2017 at 10:53:26AM +0300, Daniel Baluta wrote:
> Hi Himanshi,
> 
> On Tue, Sep 12, 2017 at 1:43 AM, Himanshi Jain  
> wrote:
> > Fixed IIO_DEVICE_ATTR_NAMED API to take name as a
> > string instead of implicit conversion to string using
> > preprocessors. Added double quotes around names in
> > existing usage of IIO_DEVICE_ATTR_NAMED.
> 
> Always use imperative mood in commit subject (Fix instead of Fixed).
> 
> The subject should contain a tag, which describes the subsytem/files affected.
> 
> I would split this patch into:
> 
> 1) sysfs: iio: Introduce *_ATTR_NAMED
> 
> and explain here why do we need  __ATTR_NAMED and IIO_ATTR_NAMED
> 
> 2) iio: Use new IIO_DEVICE_ATTR_NAMED API
> 
> But of course, lets wait to see Lars and Jonathan's opinions.
> thanks,
> Daniel.
> 
> >
> > Signed-off-by: Himanshi Jain 
> > ---
> >  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(-)
> >
> > diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
> > index e6706a0..d74e324 100644
> > --- a/drivers/iio/adc/ad7793.c
> > +++ b/drivers/iio/adc/ad7793.c
> > @@ -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[] = {
> > diff --git a/drivers/staging/iio/adc/ad7192.c 
> > b/drivers/staging/iio/adc/ad7192.c
> > index d11c6de..daff38c 100644
> > --- a/drivers/staging/iio/adc/ad7192.c
> > +++ b/drivers/staging/iio/adc/ad7192.c
> > @@ -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,
> > diff --git a/drivers/staging/iio/adc/ad7280a.c 
> > b/drivers/staging/iio/adc/ad7280a.c
> > index f85dde9..fd32e9a 100644
> > --- a/drivers/staging/iio/adc/ad7280a.c
> > +++ b/drivers/staging/iio/adc/ad7280a.c
> > @@ -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,
> > diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
> > index ce9426c..49c81a4 100644
> > --- a/include/linux/iio/sysfs.h
> > +++ b/include/linux/iio/sysfs.h
> > @@ -55,6 +55,10 @@ struct iio_const_attr {
> > { .dev_attr = __ATTR(_name, _mode, _show, _store),  \
> >   .address = _addr }
> >
> > +#define IIO_ATTR_NAMED(_name, 

Re: [Outreachy kernel] [PATCH] Fixed IIO_DEVICE_ATTR_NAMED API to take name as a string and added "" around names

2017-09-12 Thread himanshi
Okay. This way with each commit the version can compile and I will
be able to define the subsystem appropriately. Thank you for the
clarification Lars. 

On Tue, Sep 12, 2017 at 08:14:18PM +0200, Lars-Peter Clausen wrote:
> On 09/12/2017 08:06 PM, Julia Lawall wrote:
> > 
> > 
> > On Tue, 12 Sep 2017, himanshi wrote:
> > 
> >> Thanks for the review Daniel! I will change the imperative mood for the 
> >> commit
> >> message once the other changes are finalised too and as suggested by Julia,
> >> would try to make the description specific than general.
> >>
> >> I tried to think of adding subsystem to the commit subject but could not
> >> conclude any because of the files involved.
> >> I like the idea of splitting the patch into 2 as you suggested but I
> >> have a doubt that adding the new MACROS to different sysfs files can be 
> >> put into 1
> >> patch with the subsystem you mentioned but changing the existing
> >> IIO_DEVICE_ATTR_NAMED to use IIO_ATTR_NAMED (sysfs file again) would be 
> >> included
> >> in the second patch if I am not wrong. So would it be fine to keep the
> >> subsystem as iio for the second patch?
> > 
> > Indeed, the kernel has to compile after every commit.  Unless you change
> > the name of the macro, to allow the old and new versions to co-exist, it
> > seems hard to break up such a patch.
> 
> We can still split things into two parts. One patch introducing __ATTR_NAMED
> in the device driver core and then another patch making use of that macro in
> the IIO subsystem.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2017-09-13 Thread himanshi
On Wed, Sep 13, 2017 at 11:12:21AM +0300, Dan Carpenter wrote:
> On Wed, Sep 13, 2017 at 01:26:27PM +0530, Himanshi Jain wrote:
> > 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.
> > 
> > Signed-off-by: Himanshi Jain 
> 
> 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?
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Fixed IIO_DEVICE_ATTR_NAMED API to take name as a string and added "" around names

2017-09-11 Thread Himanshi Jain
Fixed IIO_DEVICE_ATTR_NAMED API to take name as a
string instead of implicit conversion to string using
preprocessors. Added double quotes around names in
existing usage of IIO_DEVICE_ATTR_NAMED.

Signed-off-by: Himanshi Jain 
---
 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(-)

diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index e6706a0..d74e324 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -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[] = {
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..daff38c 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -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,
diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index f85dde9..fd32e9a 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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,
diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
index ce9426c..49c81a4 100644
--- a/include/linux/iio/sysfs.h
+++ b/include/linux/iio/sysfs.h
@@ -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\
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index aa02c32..20321cf 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -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) },\
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 0/2] Rewrite the IIO_DEVICE_ATTR_NAMED API to pass name as string.

2017-09-13 Thread Himanshi Jain
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(-)

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] include: linux: sysfs: Add __ATTR_NAMED macro

2017-09-13 Thread Himanshi Jain
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).

Signed-off-by: Himanshi Jain 
---
 include/linux/sysfs.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index aa02c32..20321cf 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -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) },\
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/2] iio: Use __ATTR_NAMED to allow passing name as string to IIO_DEVICE_ATTR_NAMED and change usage to pass string

2017-09-13 Thread Himanshi Jain
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.

Signed-off-by: Himanshi Jain 
---
 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(-)

diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index e6706a0..d74e324 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -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[] = {
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..daff38c 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -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,
diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index f85dde9..fd32e9a 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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,
diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
index ce9426c..49c81a4 100644
--- a/include/linux/iio/sysfs.h
+++ b/include/linux/iio/sysfs.h
@@ -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\
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 0/2] Rewrite the IIO_DEVICE_ATTR_NAMED API to pass name as string.

2017-09-13 Thread Himanshi Jain
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: Change to __ATTR_NAMED()

 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(-)

-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/2] include: linux: sysfs: Add __ATTR_NAMED macro

2017-09-13 Thread Himanshi Jain
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).

Signed-off-by: Himanshi Jain 
---
 include/linux/sysfs.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index aa02c32..20321cf 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -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) },\
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 2/2] iio: Change to __ATTR_NAMED()

2017-09-13 Thread Himanshi Jain
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.

Signed-off-by: Himanshi Jain 
---
 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(-)

diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
index e6706a0..d74e324 100644
--- a/drivers/iio/adc/ad7793.c
+++ b/drivers/iio/adc/ad7793.c
@@ -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[] = {
diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..daff38c 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -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,
diff --git a/drivers/staging/iio/adc/ad7280a.c 
b/drivers/staging/iio/adc/ad7280a.c
index f85dde9..fd32e9a 100644
--- a/drivers/staging/iio/adc/ad7280a.c
+++ b/drivers/staging/iio/adc/ad7280a.c
@@ -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,
diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h
index ce9426c..49c81a4 100644
--- a/include/linux/iio/sysfs.h
+++ b/include/linux/iio/sysfs.h
@@ -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\
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/2] include: linux: sysfs: Add __ATTR_NAMED macro

2017-09-18 Thread Himanshi Jain
On Thu, Sep 14, 2017 at 2:20 AM, Jonathan Cameron
 wrote:
>
>
> On 13 September 2017 12:23:31 GMT-07:00, Lars-Peter Clausen  
> wrote:
>>On 09/13/2017 08:58 PM, Greg KH wrote:
>>> On Wed, Sep 13, 2017 at 06:03:10PM +0100, Jonathan Cameron wrote:
>>>> On Wed, 13 Sep 2017 14:14:07 +0530
>>>> Himanshi Jain  wrote:
>>>>
>>>>> 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).
>>>>>
>>>>> Signed-off-by: Himanshi Jain 
>>>>> ---
>>>>>  include/linux/sysfs.h | 7 +++
>>>>>  1 file changed, 7 insertions(+)
>>>>>
>>>>> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
>>>>> index aa02c32..20321cf 100644
>>>>> --- a/include/linux/sysfs.h
>>>>> +++ b/include/linux/sysfs.h
>>>>> @@ -104,6 +104,13 @@ struct attribute_group {
>>>>>.store  = _store,   \
>>>>>  }
>>>>>
>>>>> +#define __ATTR_NAMED(_name, _mode, _show, _store) {  
>>>>>  \
>>>>
>>>> I'm not sure about the naming here.  The normal __ATTR macro is also
>>>> 'named'.  Maybe something as awful as
>>>>
>>>> __ATTR_STRING_NAME ?
>>>>
>>>> Greg what do you think?
>>>
>>> ick ick ick.
>>>
>>>> This is all to allow us to have names with operators in them without
>>>> checkpatch complaining about them... A worthwhile aim just to stop
>>>> more people wasting time trying to 'fix' those cases by adding
>>spaces.
>>>
>>> Yeah, but this really seems "heavy" for just a crazy sysfs name in a
>>> macro.  Adding a whole new "core" define for that is a hard sell...
>>>
>>> I also want to get rid of the "generic" __ATTR type macros, and force
>>> people to use the proper _RW and friends instead.  I don't want to
>>add
>>> another new one that people will start to use that I later have to
>>> change...
>>>
>>> So no, I don't like this, how about just changing your macros
>>instead?
>>> No one else has this problem :)
>>
>>Nobody else realized they have this problem yet. E.g. there are a few
>>users
>>of __ATTR in block/genhd.c that have the same issue and are likely to
>>generate the same false positives from static checkers.
>
> For IIO there is the option of moving these over to the core generated 
> available callbacks, but
> that won't work in every case and is a more major change.  I need to shift a 
> few more drivers
> over to the available callbacks and see how well it works out.  Might find 
> time to do one in a
>  gap between interesting talks this afternoon...

Can I help you in this? It is about exploring options as far as I can
make out, although can't really understand what options are those for
now.

Or do you want me to put comments to not to fix this checkpatch
warning as you suggested earlier?

>
> If I am feeling really keen I might write this missing docs I promised a 
> while back on that stuff. Jet lag dependant...
>
> Jonathan
>>
>>--
>>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>>the body of a message to majord...@vger.kernel.org
>>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: iio: adc: Added Space around binary op.

2017-09-07 Thread Himanshi Jain
Added space around(one on each side of) binary
operator(-) as preferred according to kernel
coding style.

Signed-off-by: Himanshi Jain 
---
 drivers/staging/iio/adc/ad7192.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index d11c6de..1aee662 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -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,
-- 
1.9.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel