Skip to contentSkip to conversation

iio: Declare event_attrs field of iio_info structure as const

PATCH In review Bhumika Goyal 2 participants 3 messages Oct 1, 2016 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: Declare event_attrs field of iio_info structure as const

The event_attrs field of iio_info structure is only initialized once whenever an object of iio_info is created. After that this field is never modified again anywhere in the kernel. So, declare event_attrs field of iio_info as a const struct attribute_group.
Checked for occurences throughout the kernel using grep and coccinelle.

---
 include/linux/iio/iio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/iio/iio.h +1 -1
index b4a0679..4591d8e 100644
@@ -381,7 +381,7 @@ struct iio_dev;
  **/
 struct iio_info {
 	struct module			*driver_module;
-	struct attribute_group		*event_attrs;
+	const struct attribute_group	*event_attrs;
 	const struct attribute_group	*attrs;
 
 	int (*read_raw)(struct iio_dev *indio_dev,
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 8 lines · Bhumika Goyal

The event_attrs field of iio_info structure is only initialized once whenever an object of iio_info is created. After that this field is never modified again anywhere in the kernel. So, declare event_attrs field of iio_info as a const struct attribute_group.
Checked for occurences throughout the kernel using grep and coccinelle.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Clearly this becomes more interesting when the follow up patches making ever event_attr group we can constant.
Looking forward to those ;)

Jonathan

Quoted 18 lines
---
 include/linux/iio/iio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/iio/iio.h +1 -1
index b4a0679..4591d8e 100644
@@ -381,7 +381,7 @@ struct iio_dev;
  **/
 struct iio_info {
 	struct module			*driver_module;
-	struct attribute_group		*event_attrs;
+	const struct attribute_group	*event_attrs;
 	const struct attribute_group	*attrs;
 
 	int (*read_raw)(struct iio_dev *indio_dev,
#2 lore raw
Quoted 8 lines · Jonathan Cameron
Quoted 7 lines · Bhumika Goyal

The event_attrs field of iio_info structure is only initialized once whenever an object of iio_info is created. After that this field is never modified again anywhere in the kernel. So, declare event_attrs field of iio_info as a const struct attribute_group.
Checked for occurences throughout the kernel using grep and coccinelle.

Quoted 8 lines
Quoted 1 line

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Clearly this becomes more interesting when the follow up patches making ever event_attr group we can constant.
Looking forward to those ;)

Yeah sure, I will definitely submit the follow up patches. :D

Thanks,
Bhumika

Quoted 21 lines

Jonathan

Quoted 18 lines
---
 include/linux/iio/iio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/iio/iio.h +1 -1
index b4a0679..4591d8e 100644
@@ -381,7 +381,7 @@ struct iio_dev;
  **/
 struct iio_info {
      struct module                   *driver_module;
-     struct attribute_group          *event_attrs;
+     const struct attribute_group    *event_attrs;
      const struct attribute_group    *attrs;
 
      int (*read_raw)(struct iio_dev *indio_dev,