Skip to contentSkip to conversation

iio: Prefer octal over symbolic permissions.

PATCH In review Joe Simmons-Talbott 4 participants 6 messages May 27, 2022 – Jun 1, 2022 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: Prefer octal over symbolic permissions.

As reported by checkpatch.pl use ocatl permissions rather than symbolic permissions.

---
 drivers/iio/industrialio-buffer.c  | 12 ++++++------
 drivers/iio/industrialio-core.c    | 10 +++++-----
 drivers/iio/industrialio-trigger.c |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/iio/industrialio-buffer.c +6 -6
index b078eb2f3c9d..c27f74a3c0f3 100644
@@ -1391,17 +1391,17 @@ static ssize_t direction_show(struct device *dev,
 	}
 }
 
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
+static DEVICE_ATTR(length, 0644, iio_buffer_read_length,
 		   iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
-	S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+	0444, iio_buffer_read_length, NULL);
+static DEVICE_ATTR(enable, 0644,
 		   iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(watermark, 0644,
 		   iio_buffer_show_watermark, iio_buffer_store_watermark);
 static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
-	S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
+	0444, iio_buffer_show_watermark, NULL);
+static DEVICE_ATTR(data_available, 0444,
 		iio_dma_show_data_available, NULL);
 static DEVICE_ATTR_RO(direction);
 
drivers/iio/industrialio-core.c +5 -5
index e1ed44dec2ab..35de348d686e 100644
@@ -1114,12 +1114,12 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,
 	dev_attr->attr.name = name;
 
 	if (readfunc) {
-		dev_attr->attr.mode |= S_IRUGO;
+		dev_attr->attr.mode |= 0444;
 		dev_attr->show = readfunc;
 	}
 
 	if (writefunc) {
-		dev_attr->attr.mode |= S_IWUSR;
+		dev_attr->attr.mode |= 0200;
 		dev_attr->store = writefunc;
 	}
 
@@ -1401,7 +1401,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
 	return sysfs_emit(buf, "%s\n", indio_dev->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_show_dev_name, NULL);
 
 static ssize_t iio_show_dev_label(struct device *dev,
 				 struct device_attribute *attr,
@@ -1411,7 +1411,7 @@ static ssize_t iio_show_dev_label(struct device *dev,
 	return sysfs_emit(buf, "%s\n", indio_dev->label);
 }
 
-static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+static DEVICE_ATTR(label, 0444, iio_show_dev_label, NULL);
 
 static ssize_t iio_show_timestamp_clock(struct device *dev,
 					struct device_attribute *attr,
@@ -1509,7 +1509,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
 	return 0;
 }
 
-static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_timestamp_clock, 0644,
 		   iio_show_timestamp_clock, iio_store_timestamp_clock);
 
 static int iio_device_register_sysfs(struct iio_dev *indio_dev)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..e22a35634f2c 100644
@@ -54,7 +54,7 @@ static ssize_t iio_trigger_read_name(struct device *dev,
 	return sysfs_emit(buf, "%s\n", trig->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_trigger_read_name, NULL);
 
 static struct attribute *iio_trig_dev_attrs[] = {
 	&dev_attr_name.attr,
@@ -494,7 +494,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
 	return ret;
 }
 
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_trigger, 0644,
 		   iio_trigger_read_current,
 		   iio_trigger_write_current);
 
Signature · 1 line
2.35.3
maintainer
#1 lore raw
Quoted 4 lines · On Fri, 27 May 2022 14:56:52 -0400 Joe Simmons-Talbott <[email protected]>…

As reported by checkpatch.pl use ocatl permissions rather than symbolic permissions.

Hi Joe,

Why the resend? Given change of description, I'm guessing this is v2 because of feedback on a similar patch elsewhere. If so, please put the version number in the patch log and provide a changelog below the ---

Hmm. I guess I don't really mind cleaning this up though it is some churn in core code which is usually something we try to avoid for fairly trivial style reasons.

One request inline (though I suspect it applies in several places, I just haven't checked ;)

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/iio/industrialio-buffer.c  | 12 ++++++------
 drivers/iio/industrialio-core.c    | 10 +++++-----
 drivers/iio/industrialio-trigger.c |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/iio/industrialio-buffer.c +3 -3
index b078eb2f3c9d..c27f74a3c0f3 100644
@@ -1391,17 +1391,17 @@ static ssize_t direction_show(struct device *dev,
 	}
 }
 
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
+static DEVICE_ATTR(length, 0644, iio_buffer_read_length,
 		   iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
-	S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+	0444, iio_buffer_read_length, NULL);
+static DEVICE_ATTR(enable, 0644,

drivers/iio/industrialio-buffer.c static ssize_t direction_show(struct device *dev, · line 1405

Quoted 10 lines
drivers/iio/industrialio-buffer.c +3 -3
 		   iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(watermark, 0644,
 		   iio_buffer_show_watermark, iio_buffer_store_watermark);
 static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
-	S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
+	0444, iio_buffer_show_watermark, NULL);
+static DEVICE_ATTR(data_available, 0444,
 		iio_dma_show_data_available, NULL);

a side effect of this change a slight shortening of how long the above two lines will be if combined into one. It's now sub 80 chars I think, so please make them a single line. Also check for similar cases elsewhere.

Quoted 70 lines
drivers/iio/industrialio-buffer.c +0 -0
 static DEVICE_ATTR_RO(direction);
 
drivers/iio/industrialio-core.c +5 -5
index e1ed44dec2ab..35de348d686e 100644
@@ -1114,12 +1114,12 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,
 	dev_attr->attr.name = name;
 
 	if (readfunc) {
-		dev_attr->attr.mode |= S_IRUGO;
+		dev_attr->attr.mode |= 0444;
 		dev_attr->show = readfunc;
 	}
 
 	if (writefunc) {
-		dev_attr->attr.mode |= S_IWUSR;
+		dev_attr->attr.mode |= 0200;
 		dev_attr->store = writefunc;
 	}
 
@@ -1401,7 +1401,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
 	return sysfs_emit(buf, "%s\n", indio_dev->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_show_dev_name, NULL);
 
 static ssize_t iio_show_dev_label(struct device *dev,
 				 struct device_attribute *attr,
@@ -1411,7 +1411,7 @@ static ssize_t iio_show_dev_label(struct device *dev,
 	return sysfs_emit(buf, "%s\n", indio_dev->label);
 }
 
-static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+static DEVICE_ATTR(label, 0444, iio_show_dev_label, NULL);
 
 static ssize_t iio_show_timestamp_clock(struct device *dev,
 					struct device_attribute *attr,
@@ -1509,7 +1509,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
 	return 0;
 }
 
-static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_timestamp_clock, 0644,
 		   iio_show_timestamp_clock, iio_store_timestamp_clock);
 
 static int iio_device_register_sysfs(struct iio_dev *indio_dev)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..e22a35634f2c 100644
@@ -54,7 +54,7 @@ static ssize_t iio_trigger_read_name(struct device *dev,
 	return sysfs_emit(buf, "%s\n", trig->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_trigger_read_name, NULL);
 
 static struct attribute *iio_trig_dev_attrs[] = {
 	&dev_attr_name.attr,
@@ -494,7 +494,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
 	return ret;
 }
 
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_trigger, 0644,
 		   iio_trigger_read_current,
 		   iio_trigger_write_current);
 
#2 lore raw
Quoted 4 lines · Jonathan Cameron
Quoted 2 lines · On Fri, 27 May 2022 14:56:52 -0400 Joe Simmons-Talbott <[email protected]>…

As reported by checkpatch.pl use ocatl permissions rather than symbolic permissions.

[]

Quoted 11 lines

Why the resend? Given change of description, I'm guessing this is v2 because of feedback on a similar patch elsewhere. If so, please put the version number in the patch log and provide a changelog below the ---

Hmm. I guess I don't really mind cleaning this up though it is some churn in core code which is usually something we try to avoid for fairly trivial style reasons.

One request inline (though I suspect it applies in several places, I just haven't checked ;)

[]

Quoted 1 line

drivers/iio/industrialio-buffer.c

Quoted 1 line
drivers/iio/industrialio-buffer.c +0 -0

[]

Quoted 19 lines
Quoted 19 lines
drivers/iio/industrialio-buffer.c +4 -6
@@ -1391,17 +1391,17 @@ static ssize_t direction_show(struct device *dev,
 	}
 }
 
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
+static DEVICE_ATTR(length, 0644, iio_buffer_read_length,
 		   iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
-	S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+	0444, iio_buffer_read_length, NULL);
+static DEVICE_ATTR(enable, 0644,
 		   iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(watermark, 0644,
 		   iio_buffer_show_watermark, iio_buffer_store_watermark);
 static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
-	S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
Quoted 8 lines

drivers/iio/industrialio-buffer.c static ssize_t direction_show(struct device *dev, · line 1405

Quoted 3 lines
drivers/iio/industrialio-buffer.c +2 -0
+	0444, iio_buffer_show_watermark, NULL);
+static DEVICE_ATTR(data_available, 0444,
 		iio_dma_show_data_available, NULL);

a side effect of this change a slight shortening of how long the above two lines will be if combined into one. It's now sub 80 chars I think, so please make them a single line. Also check for similar cases elsewhere.

another possibility it to rename the function to <var>_show and change

	static DEVICE_ATTR(foo, 0444, <var>, NULL)

to
static DEVICE_ATTR_RO(<var>)

and also use

DEVICE_ATTR_RW

with appropriate function renaming where feasible.

#3 lore raw
In reply to Jonathan Cameron
Quoted 7 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 27 May 2022 14:56:52 -0400 Joe Simmons-Talbott <[email protected]>…

As reported by checkpatch.pl use ocatl permissions rather than symbolic permissions.

Quoted 8 lines
Quoted 1 line

Hi Joe,

Why the resend? Given change of description, I'm guessing this is v2 because of feedback on a similar patch elsewhere. If so, please put the version number in the patch log and provide a changelog below the ---

I sent the patch again because I neglected to include linux-kernel and you in the
original patch's recipients. I wasn't sure if I should include the v2 but will in the future.
Should I use v3 for my updated patch?

Thanks,
Joe

Quoted 123 lines

Hmm. I guess I don't really mind cleaning this up though it is some churn in core code which is usually something we try to avoid for fairly trivial style reasons.

One request inline (though I suspect it applies in several places, I just haven't checked ;)

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/iio/industrialio-buffer.c  | 12 ++++++------
 drivers/iio/industrialio-core.c    | 10 +++++-----
 drivers/iio/industrialio-trigger.c |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/iio/industrialio-buffer.c +3 -3
index b078eb2f3c9d..c27f74a3c0f3 100644
@@ -1391,17 +1391,17 @@ static ssize_t direction_show(struct device *dev,
      }
 }
 
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
+static DEVICE_ATTR(length, 0644, iio_buffer_read_length,
                 iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
-     S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+     0444, iio_buffer_read_length, NULL);
+static DEVICE_ATTR(enable, 0644,

drivers/iio/industrialio-buffer.c static ssize_t direction_show(struct device *dev, · line 1405

Quoted 10 lines
drivers/iio/industrialio-buffer.c +3 -3
                 iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(watermark, 0644,
                 iio_buffer_show_watermark, iio_buffer_store_watermark);
 static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
-     S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
+     0444, iio_buffer_show_watermark, NULL);
+static DEVICE_ATTR(data_available, 0444,
              iio_dma_show_data_available, NULL);

a side effect of this change a slight shortening of how long the above two lines will be if combined into one. It's now sub 80 chars I think, so please make them a single line. Also check for similar cases elsewhere.

Quoted 70 lines
drivers/iio/industrialio-buffer.c +0 -0
 static DEVICE_ATTR_RO(direction);
 
drivers/iio/industrialio-core.c +5 -5
index e1ed44dec2ab..35de348d686e 100644
@@ -1114,12 +1114,12 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,
      dev_attr->attr.name = name;
 
      if (readfunc) {
-             dev_attr->attr.mode |= S_IRUGO;
+             dev_attr->attr.mode |= 0444;
              dev_attr->show = readfunc;
      }
 
      if (writefunc) {
-             dev_attr->attr.mode |= S_IWUSR;
+             dev_attr->attr.mode |= 0200;
              dev_attr->store = writefunc;
      }
 
@@ -1401,7 +1401,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
      return sysfs_emit(buf, "%s\n", indio_dev->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_show_dev_name, NULL);
 
 static ssize_t iio_show_dev_label(struct device *dev,
                               struct device_attribute *attr,
@@ -1411,7 +1411,7 @@ static ssize_t iio_show_dev_label(struct device *dev,
      return sysfs_emit(buf, "%s\n", indio_dev->label);
 }
 
-static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+static DEVICE_ATTR(label, 0444, iio_show_dev_label, NULL);
 
 static ssize_t iio_show_timestamp_clock(struct device *dev,
                                      struct device_attribute *attr,
@@ -1509,7 +1509,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
      return 0;
 }
 
-static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_timestamp_clock, 0644,
                 iio_show_timestamp_clock, iio_store_timestamp_clock);
 
 static int iio_device_register_sysfs(struct iio_dev *indio_dev)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..e22a35634f2c 100644
@@ -54,7 +54,7 @@ static ssize_t iio_trigger_read_name(struct device *dev,
      return sysfs_emit(buf, "%s\n", trig->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_trigger_read_name, NULL);
 
 static struct attribute *iio_trig_dev_attrs[] = {
      &dev_attr_name.attr,
@@ -494,7 +494,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
      return ret;
 }
 
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_trigger, 0644,
                 iio_trigger_read_current,
                 iio_trigger_write_current);
 
#4 lore raw
Quoted 18 lines · On Sun, 29 May 2022 10:08:21 -0400 Joe Talbott <[email protected]> wrote:
Quoted 7 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 27 May 2022 14:56:52 -0400 Joe Simmons-Talbott <[email protected]>…

As reported by checkpatch.pl use ocatl permissions rather than symbolic permissions.

Quoted 8 lines
Quoted 1 line

Hi Joe,

Why the resend? Given change of description, I'm guessing this is v2 because of feedback on a similar patch elsewhere. If so, please put the version number in the patch log and provide a changelog below the ---

Quoted 4 lines

I sent the patch again because I neglected to include linux-kernel and you in the
original patch's recipients. I wasn't sure if I should include the v2 but will in the future.

For that case, common choice is [RESEND PATCH .... with a brief note in the cover letter that you missed some to/cc

Quoted 1 line

Should I use v3 for my updated patch?

v2 is fine given v2 doesn't yet exist - v3 also fine though...

Jonathan

Quoted 127 lines

Thanks,
Joe

Quoted 123 lines

Hmm. I guess I don't really mind cleaning this up though it is some churn in core code which is usually something we try to avoid for fairly trivial style reasons.

One request inline (though I suspect it applies in several places, I just haven't checked ;)

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/iio/industrialio-buffer.c  | 12 ++++++------
 drivers/iio/industrialio-core.c    | 10 +++++-----
 drivers/iio/industrialio-trigger.c |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/iio/industrialio-buffer.c +3 -3
index b078eb2f3c9d..c27f74a3c0f3 100644
@@ -1391,17 +1391,17 @@ static ssize_t direction_show(struct device *dev,
      }
 }
 
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
+static DEVICE_ATTR(length, 0644, iio_buffer_read_length,
                 iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
-     S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+     0444, iio_buffer_read_length, NULL);
+static DEVICE_ATTR(enable, 0644,

drivers/iio/industrialio-buffer.c static ssize_t direction_show(struct device *dev, · line 1405

Quoted 10 lines
drivers/iio/industrialio-buffer.c +3 -3
                 iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(watermark, 0644,
                 iio_buffer_show_watermark, iio_buffer_store_watermark);
 static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
-     S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
+     0444, iio_buffer_show_watermark, NULL);
+static DEVICE_ATTR(data_available, 0444,
              iio_dma_show_data_available, NULL);  

a side effect of this change a slight shortening of how long the above two lines will be if combined into one. It's now sub 80 chars I think, so please make them a single line. Also check for similar cases elsewhere.

Quoted 70 lines
drivers/iio/industrialio-buffer.c +0 -0
 static DEVICE_ATTR_RO(direction);
 
drivers/iio/industrialio-core.c +5 -5
index e1ed44dec2ab..35de348d686e 100644
@@ -1114,12 +1114,12 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,
      dev_attr->attr.name = name;
 
      if (readfunc) {
-             dev_attr->attr.mode |= S_IRUGO;
+             dev_attr->attr.mode |= 0444;
              dev_attr->show = readfunc;
      }
 
      if (writefunc) {
-             dev_attr->attr.mode |= S_IWUSR;
+             dev_attr->attr.mode |= 0200;
              dev_attr->store = writefunc;
      }
 
@@ -1401,7 +1401,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
      return sysfs_emit(buf, "%s\n", indio_dev->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_show_dev_name, NULL);
 
 static ssize_t iio_show_dev_label(struct device *dev,
                               struct device_attribute *attr,
@@ -1411,7 +1411,7 @@ static ssize_t iio_show_dev_label(struct device *dev,
      return sysfs_emit(buf, "%s\n", indio_dev->label);
 }
 
-static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+static DEVICE_ATTR(label, 0444, iio_show_dev_label, NULL);
 
 static ssize_t iio_show_timestamp_clock(struct device *dev,
                                      struct device_attribute *attr,
@@ -1509,7 +1509,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
      return 0;
 }
 
-static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_timestamp_clock, 0644,
                 iio_show_timestamp_clock, iio_store_timestamp_clock);
 
 static int iio_device_register_sysfs(struct iio_dev *indio_dev)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..e22a35634f2c 100644
@@ -54,7 +54,7 @@ static ssize_t iio_trigger_read_name(struct device *dev,
      return sysfs_emit(buf, "%s\n", trig->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_trigger_read_name, NULL);
 
 static struct attribute *iio_trig_dev_attrs[] = {
      &dev_attr_name.attr,
@@ -494,7 +494,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
      return ret;
 }
 
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_trigger, 0644,
                 iio_trigger_read_current,
                 iio_trigger_write_current);
 
#5 lore raw
Quoted 26 lines · Jonathan Cameron
Quoted 18 lines · On Sun, 29 May 2022 10:08:21 -0400 Joe Talbott <[email protected]> wrote:
Quoted 7 lines · Jonathan Cameron
Quoted 3 lines · On Fri, 27 May 2022 14:56:52 -0400 Joe Simmons-Talbott <[email protected]>…

As reported by checkpatch.pl use ocatl permissions rather than symbolic permissions.

Quoted 8 lines
Quoted 1 line

Hi Joe,

Why the resend? Given change of description, I'm guessing this is v2 because of feedback on a similar patch elsewhere. If so, please put the version number in the patch log and provide a changelog below the ---

Quoted 4 lines

I sent the patch again because I neglected to include linux-kernel and you in the
original patch's recipients. I wasn't sure if I should include the v2 but will in the future.

Quoted 5 lines

For that case, common choice is [RESEND PATCH .... with a brief note in the cover letter that you missed some to/cc

Quoted 1 line

Should I use v3 for my updated patch?

v2 is fine given v2 doesn't yet exist - v3 also fine though...

Thanks for the info. I've resubmitted the patch as:
[PATCH v2] iio: Use octal permissions and DEVICE_ATTR_{RO,RW}.

Thanks,
Joe

Quoted 131 lines

Jonathan

Quoted 127 lines

Thanks,
Joe

Quoted 123 lines

Hmm. I guess I don't really mind cleaning this up though it is some churn in core code which is usually something we try to avoid for fairly trivial style reasons.

One request inline (though I suspect it applies in several places, I just haven't checked ;)

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/iio/industrialio-buffer.c  | 12 ++++++------
 drivers/iio/industrialio-core.c    | 10 +++++-----
 drivers/iio/industrialio-trigger.c |  4 ++--
 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/iio/industrialio-buffer.c +3 -3
index b078eb2f3c9d..c27f74a3c0f3 100644
@@ -1391,17 +1391,17 @@ static ssize_t direction_show(struct device *dev,
      }
 }
 
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
+static DEVICE_ATTR(length, 0644, iio_buffer_read_length,
                 iio_buffer_write_length);
 static struct device_attribute dev_attr_length_ro = __ATTR(length,
-     S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
+     0444, iio_buffer_read_length, NULL);
+static DEVICE_ATTR(enable, 0644,

drivers/iio/industrialio-buffer.c static ssize_t direction_show(struct device *dev, · line 1405

Quoted 10 lines
drivers/iio/industrialio-buffer.c +3 -3
                 iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(watermark, 0644,
                 iio_buffer_show_watermark, iio_buffer_store_watermark);
 static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
-     S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
+     0444, iio_buffer_show_watermark, NULL);
+static DEVICE_ATTR(data_available, 0444,
              iio_dma_show_data_available, NULL);  

a side effect of this change a slight shortening of how long the above two lines will be if combined into one. It's now sub 80 chars I think, so please make them a single line. Also check for similar cases elsewhere.

Quoted 70 lines
drivers/iio/industrialio-buffer.c +0 -0
 static DEVICE_ATTR_RO(direction);
 
drivers/iio/industrialio-core.c +5 -5
index e1ed44dec2ab..35de348d686e 100644
@@ -1114,12 +1114,12 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,
      dev_attr->attr.name = name;
 
      if (readfunc) {
-             dev_attr->attr.mode |= S_IRUGO;
+             dev_attr->attr.mode |= 0444;
              dev_attr->show = readfunc;
      }
 
      if (writefunc) {
-             dev_attr->attr.mode |= S_IWUSR;
+             dev_attr->attr.mode |= 0200;
              dev_attr->store = writefunc;
      }
 
@@ -1401,7 +1401,7 @@ static ssize_t iio_show_dev_name(struct device *dev,
      return sysfs_emit(buf, "%s\n", indio_dev->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_show_dev_name, NULL);
 
 static ssize_t iio_show_dev_label(struct device *dev,
                               struct device_attribute *attr,
@@ -1411,7 +1411,7 @@ static ssize_t iio_show_dev_label(struct device *dev,
      return sysfs_emit(buf, "%s\n", indio_dev->label);
 }
 
-static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+static DEVICE_ATTR(label, 0444, iio_show_dev_label, NULL);
 
 static ssize_t iio_show_timestamp_clock(struct device *dev,
                                      struct device_attribute *attr,
@@ -1509,7 +1509,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev,
      return 0;
 }
 
-static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_timestamp_clock, 0644,
                 iio_show_timestamp_clock, iio_store_timestamp_clock);
 
 static int iio_device_register_sysfs(struct iio_dev *indio_dev)
drivers/iio/industrialio-trigger.c +2 -2
index f504ed351b3e..e22a35634f2c 100644
@@ -54,7 +54,7 @@ static ssize_t iio_trigger_read_name(struct device *dev,
      return sysfs_emit(buf, "%s\n", trig->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+static DEVICE_ATTR(name, 0444, iio_trigger_read_name, NULL);
 
 static struct attribute *iio_trig_dev_attrs[] = {
      &dev_attr_name.attr,
@@ -494,7 +494,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
      return ret;
 }
 
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
+static DEVICE_ATTR(current_trigger, 0644,
                 iio_trigger_read_current,
                 iio_trigger_write_current);