Skip to contentSkip to conversation

net: constify struct device_type usage

PATCH Applied Ricardo B. Marliere 6 participants 28 messages Feb 17, 2024 – Feb 21, 2024

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

cover net: constify struct device_type usage

This is a simple and straight forward cleanup series that makes all device types in the net subsystem constants. This has been possible since 2011 [1] but not all occurrences were cleaned. I have been sweeping the tree to fix them all.

I was not sure if I should send these squashed, but there are quite a few changes so I decided to send them separately. Please let me know if that is not desirable.

---
[1] https://lore.kernel.org/all/[email protected]/

---
Ricardo B. Marliere (12):
net: usbnet: constify the struct device_type usage
net: dsa: constify the struct device_type usage
net: bridge: constify the struct device_type usage
net: vxlan: constify the struct device_type usage
net: ppp: constify the struct device_type usage
net: geneve: constify the struct device_type usage
net: hsr: constify the struct device_type usage
net: l2tp: constify the struct device_type usage
net: vlan: constify the struct device_type usage
net: netdevsim: constify the struct device_type usage
net: wwan: core: constify the struct device_type usage
net: hso: constify the struct device_type usage

 drivers/net/geneve.c           | 2 +-
 drivers/net/netdevsim/bus.c    | 2 +-
 drivers/net/ppp/ppp_generic.c  | 2 +-
 drivers/net/usb/hso.c          | 2 +-
 drivers/net/usb/usbnet.c       | 4 ++--
 drivers/net/vxlan/vxlan_core.c | 2 +-
 drivers/net/wwan/wwan_core.c   | 2 +-
 net/8021q/vlan_dev.c           | 2 +-
 net/bridge/br_device.c         | 2 +-
 net/dsa/user.c                 | 2 +-
 net/hsr/hsr_device.c           | 2 +-
 net/l2tp/l2tp_eth.c            | 2 +-
 12 files changed, 13 insertions(+), 13 deletions(-)

---
base-commit: a6e0cb150c514efba4aaba4069927de43d80bb59
change-id: 20240217-device_cleanup-net-878960951968

Best regards,

Signature · 1 line
Ricardo B. Marliere <[email protected]>
#1 lore raw

PATCH 1/12 net: usbnet: constify the struct device_type usage

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the wlan_type and wwan_type variables to be constant structures as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/usb/usbnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/usb/usbnet.c +2 -2
index 2d14b0d78541..b21ebe24057f 100644
@@ -1654,11 +1654,11 @@ static const struct net_device_ops usbnet_netdev_ops = {
 
 // precondition: never called in_interrupt
 
-static struct device_type wlan_type = {
+static const struct device_type wlan_type = {
 	.name	= "wlan",
 };
 
-static struct device_type wwan_type = {
+static const struct device_type wwan_type = {
 	.name	= "wwan",
 };
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/12
#2 lore raw

Re: [PATCH 01/12] net: usbnet: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the wlan_type and wwan_type variables to be constant structures as well, placing it into read-only memory which can not be modified at runtime.

#3 lore raw

PATCH 2/12 net: dsa: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the dsa_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 net/dsa/user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/dsa/user.c +1 -1
index 5d666dfb317d..4d53c76a9840 100644
@@ -2429,7 +2429,7 @@ static const struct net_device_ops dsa_user_netdev_ops = {
 	.ndo_fill_forward_path	= dsa_user_fill_forward_path,
 };
 
-static struct device_type dsa_type = {
+static const struct device_type dsa_type = {
 	.name	= "dsa",
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v1 2/12
#4 lore raw

Re: [PATCH 02/12] net: dsa: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the dsa_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

Signature · 1 line
Florian
#5 lore raw

PATCH 3/12 net: bridge: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the br_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 net/bridge/br_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_device.c +1 -1
index 717e9750614c..874cec75a818 100644
@@ -474,7 +474,7 @@ static const struct net_device_ops br_netdev_ops = {
 	.ndo_fill_forward_path	 = br_fill_forward_path,
 };
 
-static struct device_type br_type = {
+static const struct device_type br_type = {
 	.name	= "bridge",
 };
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 3/12
#6 lore raw

Re: [PATCH 03/12] net: bridge: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the br_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#7 lore raw

PATCH 4/12 net: vxlan: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the vxlan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/vxlan/vxlan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/vxlan/vxlan_core.c +1 -1
index 705a6fd6ab6c..386cbe4d3327 100644
@@ -3254,7 +3254,7 @@ static const struct net_device_ops vxlan_netdev_raw_ops = {
 };
 
 /* Info for udev, that this is a virtual tunnel endpoint */
-static struct device_type vxlan_type = {
+static const struct device_type vxlan_type = {
 	.name = "vxlan",
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v1 4/12
#8 lore raw

Re: [PATCH 04/12] net: vxlan: constify the struct device_type usage

Quoted 4 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the vxlan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

Note: To help maintainers (and potentially reviewers) work please write in the subject prefix which tree you're targetting. For this series, it should be "[PATCH net-next xx/yy]".

#9 lore raw

Re: [PATCH 04/12] net: vxlan: constify the struct device_type usage

Hi Guillaume,

Quoted 11 lines · Guillaume Nault
Quoted 4 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the vxlan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

Note: To help maintainers (and potentially reviewers) work please write in the subject prefix which tree you're targetting. For this series, it should be "[PATCH net-next xx/yy]".

Makes sense, will keep this in mind next time!

Thanks for reviewing,
- Ricardo.

#10 lore raw

PATCH 5/12 net: ppp: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the ppp_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/ppp/ppp_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ppp/ppp_generic.c +1 -1
index 3dd52bf28f15..db1d11ae817b 100644
@@ -1607,7 +1607,7 @@ static const struct net_device_ops ppp_netdev_ops = {
 	.ndo_fill_forward_path = ppp_fill_forward_path,
 };
 
-static struct device_type ppp_type = {
+static const struct device_type ppp_type = {
 	.name = "ppp",
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v1 5/12
#11 lore raw

Re: [PATCH 05/12] net: ppp: constify the struct device_type usage

Quoted 4 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the ppp_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#12 lore raw

PATCH 6/12 net: geneve: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the geneve_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/geneve.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/geneve.c +1 -1
index 256602a72356..6f3f9b446b1d 100644
@@ -1142,7 +1142,7 @@ static const struct ethtool_ops geneve_ethtool_ops = {
 };
 
 /* Info for udev, that this is a virtual tunnel endpoint */
-static struct device_type geneve_type = {
+static const struct device_type geneve_type = {
 	.name = "geneve",
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v1 6/12
#13 lore raw

Re: [PATCH 06/12] net: geneve: constify the struct device_type usage

Quoted 4 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the geneve_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#14 lore raw

PATCH 7/12 net: hsr: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the hsr_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 net/hsr/hsr_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/hsr/hsr_device.c +1 -1
index 5ef6d437db72..c98b5b71ad7c 100644
@@ -467,7 +467,7 @@ static const struct net_device_ops hsr_device_ops = {
 	.ndo_set_rx_mode = hsr_set_rx_mode,
 };
 
-static struct device_type hsr_type = {
+static const struct device_type hsr_type = {
 	.name = "hsr",
 };
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 7/12
#15 lore raw

Re: [PATCH 07/12] net: hsr: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the hsr_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#16 lore raw

PATCH 8/12 net: l2tp: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the l2tpeth_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 net/l2tp/l2tp_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/l2tp/l2tp_eth.c +1 -1
index 25ca89f80414..39e487ccc468 100644
@@ -100,7 +100,7 @@ static const struct net_device_ops l2tp_eth_netdev_ops = {
 	.ndo_set_mac_address	= eth_mac_addr,
 };
 
-static struct device_type l2tpeth_type = {
+static const struct device_type l2tpeth_type = {
 	.name = "l2tpeth",
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v1 8/12
#17 lore raw

Re: [PATCH 08/12] net: l2tp: constify the struct device_type usage

Quoted 4 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the l2tpeth_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#18 lore raw

PATCH 9/12 net: vlan: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the vlan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 net/8021q/vlan_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/8021q/vlan_dev.c +1 -1
index 790b54a7cbe3..df5552518251 100644
@@ -537,7 +537,7 @@ static const struct header_ops vlan_passthru_header_ops = {
 	.parse_protocol = vlan_parse_protocol,
 };
 
-static struct device_type vlan_type = {
+static const struct device_type vlan_type = {
 	.name	= "vlan",
 };
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 9/12
#19 lore raw

Re: [PATCH 09/12] net: vlan: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the vlan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#20 lore raw

PATCH 10/12 net: netdevsim: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the nsim_bus_dev_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/netdevsim/bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netdevsim/bus.c +1 -1
index aedab1d9623a..0c5aff63d242 100644
@@ -129,7 +129,7 @@ static void nsim_bus_dev_release(struct device *dev)
 		complete(&nsim_bus_devs_released);
 }
 
-static struct device_type nsim_bus_dev_type = {
+static const struct device_type nsim_bus_dev_type = {
 	.groups = nsim_bus_dev_attr_groups,
 	.release = nsim_bus_dev_release,
 };
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 10/12
#21 lore raw

Re: [PATCH 10/12] net: netdevsim: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the nsim_bus_dev_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#22 lore raw

PATCH 11/12 net: wwan: core: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the wwan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/wwan/wwan_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wwan/wwan_core.c +1 -1
index 2ed20b20e7fc..b0030f3ed0f0 100644
@@ -920,7 +920,7 @@ static int wwan_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
 	return 0;
 }
 
-static struct device_type wwan_type = { .name = "wwan" };
+static const struct device_type wwan_type = { .name = "wwan" };
 
 static struct net_device *wwan_rtnl_alloc(struct nlattr *tb[],
 					  const char *ifname,
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 11/12
#23 lore raw

Re: [PATCH 11/12] net: wwan: core: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the wwan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

maintainer Reviewed-by on v1 11/12
#24 lore raw

Re: [PATCH 11/12] net: wwan: core: constify the struct device_type usage

In reply to Ricardo B. Marliere
Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the wwan_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#25 lore raw

PATCH 12/12 net: hso: constify the struct device_type usage

In reply to Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the hso_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

---
 drivers/net/usb/hso.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/hso.c +1 -1
index f088ea2ba6f3..1aeb36119d3f 100644
@@ -2465,7 +2465,7 @@ static void hso_create_rfkill(struct hso_device *hso_dev,
 	}
 }
 
-static struct device_type hso_type = {
+static const struct device_type hso_type = {
 	.name	= "wwan",
 };
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 12/12
#26 lore raw

Re: [PATCH 12/12] net: hso: constify the struct device_type usage

Quoted 7 lines · Ricardo B. Marliere

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the hso_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime.

#27 lore raw
In reply to Ricardo B. Marliere
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 10 lines · On Sat, 17 Feb 2024 17:13:22 -0300 you wrote:

This is a simple and straight forward cleanup series that makes all device types in the net subsystem constants. This has been possible since 2011 [1] but not all occurrences were cleaned. I have been sweeping the tree to fix them all.

I was not sure if I should send these squashed, but there are quite a few changes so I decided to send them separately. Please let me know if that is not desirable.

[...]

Here is the summary with links:
- [01/12] net: usbnet: constify the struct device_type usage

    https://git.kernel.org/netdev/net-next/c/3ce7caee3af0
  - [02/12] net: dsa: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/7e0acba3b49e
  - [03/12] net: bridge: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/bbc7e4cc21a4
  - [04/12] net: vxlan: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/c7170e7672e5
  - [05/12] net: ppp: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/908ada0da6d4
  - [06/12] net: geneve: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/e443f3acbc6d
  - [07/12] net: hsr: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/0072b2c1ffd0
  - [08/12] net: l2tp: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/43820fd1ddb5
  - [09/12] net: vlan: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/7ae9d3423f1d
  - [10/12] net: netdevsim: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/52042e092ba9
  - [11/12] net: wwan: core: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/7eccf41b3bac
  - [12/12] net: hso: constify the struct device_type usage
    https://git.kernel.org/netdev/net-next/c/55fad9c4a3c4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html