linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] drivers/usb: Constify static attribute_group structs
@ 2020-11-25 16:24 Rikard Falkeborn
  2020-11-25 16:24 ` [PATCH 1/3] USB: core: " Rikard Falkeborn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-11-25 16:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Rikard Falkeborn, Heikki Krogerus,
	Alan Stern, Eugeniu Rosca, chenqiwu, Zeng Tao

Constify a number of static attribute_group structs. Typically, the
structs either have their address stored in an array of pointers to
const attribute_group or have their address passed to functions that
have pointers to const attribute_group structs as input arguments.

With these patches applied, all static struct attribute_group in
drivers/usb are const.

Done with the help of coccinelle.

Rikard Falkeborn (3):
  USB: core: Constify static attribute_group structs
  usb: typec: Constify static attribute_group structs
  usb: common: ulpi: Constify static attribute_group struct

 drivers/usb/common/ulpi.c   |  2 +-
 drivers/usb/core/endpoint.c |  2 +-
 drivers/usb/core/port.c     |  4 ++--
 drivers/usb/core/sysfs.c    | 14 +++++++-------
 drivers/usb/typec/class.c   |  8 ++++----
 5 files changed, 15 insertions(+), 15 deletions(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] USB: core: Constify static attribute_group structs
  2020-11-25 16:24 [PATCH 0/3] drivers/usb: Constify static attribute_group structs Rikard Falkeborn
@ 2020-11-25 16:24 ` Rikard Falkeborn
  2020-11-25 16:24 ` [PATCH 2/3] usb: typec: " Rikard Falkeborn
  2020-11-25 16:25 ` [PATCH 3/3] usb: common: ulpi: Constify static attribute_group struct Rikard Falkeborn
  2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-11-25 16:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Rikard Falkeborn, Alan Stern,
	Eugeniu Rosca, chenqiwu, Zeng Tao

These are never modified, so make them const to allow the compiler to
put them in read-only memory. Done with the help of coccinelle.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/usb/core/endpoint.c |  2 +-
 drivers/usb/core/port.c     |  4 ++--
 drivers/usb/core/sysfs.c    | 14 +++++++-------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 1c2c04079676..903426b6d305 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -153,7 +153,7 @@ static struct attribute *ep_dev_attrs[] = {
 	&dev_attr_direction.attr,
 	NULL,
 };
-static struct attribute_group ep_dev_attr_grp = {
+static const struct attribute_group ep_dev_attr_grp = {
 	.attrs = ep_dev_attrs,
 };
 static const struct attribute_group *ep_dev_groups[] = {
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 235a7c645503..dfcca9c876c7 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -155,7 +155,7 @@ static struct attribute *port_dev_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group port_dev_attr_grp = {
+static const struct attribute_group port_dev_attr_grp = {
 	.attrs = port_dev_attrs,
 };
 
@@ -169,7 +169,7 @@ static struct attribute *port_dev_usb3_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group port_dev_usb3_attr_grp = {
+static const struct attribute_group port_dev_usb3_attr_grp = {
 	.attrs = port_dev_usb3_attrs,
 };
 
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 8d134193fa0c..d85699bee671 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -641,7 +641,7 @@ static struct attribute *usb2_hardware_lpm_attr[] = {
 	&dev_attr_usb2_lpm_besl.attr,
 	NULL,
 };
-static struct attribute_group usb2_hardware_lpm_attr_group = {
+static const struct attribute_group usb2_hardware_lpm_attr_group = {
 	.name	= power_group_name,
 	.attrs	= usb2_hardware_lpm_attr,
 };
@@ -651,7 +651,7 @@ static struct attribute *usb3_hardware_lpm_attr[] = {
 	&dev_attr_usb3_hardware_lpm_u2.attr,
 	NULL,
 };
-static struct attribute_group usb3_hardware_lpm_attr_group = {
+static const struct attribute_group usb3_hardware_lpm_attr_group = {
 	.name	= power_group_name,
 	.attrs	= usb3_hardware_lpm_attr,
 };
@@ -663,7 +663,7 @@ static struct attribute *power_attrs[] = {
 	&dev_attr_active_duration.attr,
 	NULL,
 };
-static struct attribute_group power_attr_group = {
+static const struct attribute_group power_attr_group = {
 	.name	= power_group_name,
 	.attrs	= power_attrs,
 };
@@ -832,7 +832,7 @@ static struct attribute *dev_attrs[] = {
 #endif
 	NULL,
 };
-static struct attribute_group dev_attr_grp = {
+static const struct attribute_group dev_attr_grp = {
 	.attrs = dev_attrs,
 };
 
@@ -865,7 +865,7 @@ static umode_t dev_string_attrs_are_visible(struct kobject *kobj,
 	return a->mode;
 }
 
-static struct attribute_group dev_string_attr_grp = {
+static const struct attribute_group dev_string_attr_grp = {
 	.attrs =	dev_string_attrs,
 	.is_visible =	dev_string_attrs_are_visible,
 };
@@ -1222,7 +1222,7 @@ static struct attribute *intf_attrs[] = {
 	&dev_attr_interface_authorized.attr,
 	NULL,
 };
-static struct attribute_group intf_attr_grp = {
+static const struct attribute_group intf_attr_grp = {
 	.attrs = intf_attrs,
 };
 
@@ -1246,7 +1246,7 @@ static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
 	return a->mode;
 }
 
-static struct attribute_group intf_assoc_attr_grp = {
+static const struct attribute_group intf_assoc_attr_grp = {
 	.attrs =	intf_assoc_attrs,
 	.is_visible =	intf_assoc_attrs_are_visible,
 };
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] usb: typec: Constify static attribute_group structs
  2020-11-25 16:24 [PATCH 0/3] drivers/usb: Constify static attribute_group structs Rikard Falkeborn
  2020-11-25 16:24 ` [PATCH 1/3] USB: core: " Rikard Falkeborn
@ 2020-11-25 16:24 ` Rikard Falkeborn
  2020-11-25 16:25 ` [PATCH 3/3] usb: common: ulpi: Constify static attribute_group struct Rikard Falkeborn
  2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-11-25 16:24 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Rikard Falkeborn, Heikki Krogerus

These are never modified, so make them const to allow the compiler to
put them in read-only memory. Done with the help of coccinelle.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/usb/typec/class.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index cb1362187a7c..9eaa5ba8d78b 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -384,7 +384,7 @@ static umode_t typec_altmode_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static struct attribute_group typec_altmode_group = {
+static const struct attribute_group typec_altmode_group = {
 	.is_visible = typec_altmode_attr_is_visible,
 	.attrs = typec_altmode_attrs,
 };
@@ -574,7 +574,7 @@ static umode_t typec_partner_attr_is_visible(struct kobject *kobj, struct attrib
 	return attr->mode;
 }
 
-static struct attribute_group typec_partner_group = {
+static const struct attribute_group typec_partner_group = {
 	.is_visible = typec_partner_attr_is_visible,
 	.attrs = typec_partner_attrs
 };
@@ -756,7 +756,7 @@ static umode_t typec_plug_attr_is_visible(struct kobject *kobj, struct attribute
 	return attr->mode;
 }
 
-static struct attribute_group typec_plug_group = {
+static const struct attribute_group typec_plug_group = {
 	.is_visible = typec_plug_attr_is_visible,
 	.attrs = typec_plug_attrs
 };
@@ -1446,7 +1446,7 @@ static umode_t typec_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
-static struct attribute_group typec_group = {
+static const struct attribute_group typec_group = {
 	.is_visible = typec_attr_is_visible,
 	.attrs = typec_attrs,
 };
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] usb: common: ulpi: Constify static attribute_group struct
  2020-11-25 16:24 [PATCH 0/3] drivers/usb: Constify static attribute_group structs Rikard Falkeborn
  2020-11-25 16:24 ` [PATCH 1/3] USB: core: " Rikard Falkeborn
  2020-11-25 16:24 ` [PATCH 2/3] usb: typec: " Rikard Falkeborn
@ 2020-11-25 16:25 ` Rikard Falkeborn
  2 siblings, 0 replies; 4+ messages in thread
From: Rikard Falkeborn @ 2020-11-25 16:25 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Rikard Falkeborn, Heikki Krogerus

It is never modified, so make them const to allow the compiler to
put it in read-only memory. Done with the help of coccinelle.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
 drivers/usb/common/ulpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c
index a18d7c4222dd..ce5e6f6711f7 100644
--- a/drivers/usb/common/ulpi.c
+++ b/drivers/usb/common/ulpi.c
@@ -118,7 +118,7 @@ static struct attribute *ulpi_dev_attrs[] = {
 	NULL
 };
 
-static struct attribute_group ulpi_dev_attr_group = {
+static const struct attribute_group ulpi_dev_attr_group = {
 	.attrs = ulpi_dev_attrs,
 };
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-25 16:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 16:24 [PATCH 0/3] drivers/usb: Constify static attribute_group structs Rikard Falkeborn
2020-11-25 16:24 ` [PATCH 1/3] USB: core: " Rikard Falkeborn
2020-11-25 16:24 ` [PATCH 2/3] usb: typec: " Rikard Falkeborn
2020-11-25 16:25 ` [PATCH 3/3] usb: common: ulpi: Constify static attribute_group struct Rikard Falkeborn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).