Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: dsa: hellcreek: Constify struct devlink_region_ops and struct hellcreek_fdb_entry

'struct devlink_region_ops' and 'struct hellcreek_fdb_entry' are not
modified in this driver.

Constifying these structures moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
55320 19216 320 74856 12468 drivers/net/dsa/hirschmann/hellcreek.o

After:
=====
text data bss dec hex filename
55960 18576 320 74856 12468 drivers/net/dsa/hirschmann/hellcreek.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
Link: https://patch.msgid.link/2f7e8dc30db18bade94999ac7ce79f333342e979.1751231174.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christophe JAILLET and committed by
Jakub Kicinski
10c38949 215891ac

+10 -10
+10 -10
drivers/net/dsa/hirschmann/hellcreek.c
··· 1061 1061 1062 1062 static int hellcreek_setup_fdb(struct hellcreek *hellcreek) 1063 1063 { 1064 - static struct hellcreek_fdb_entry l2_ptp = { 1064 + static const struct hellcreek_fdb_entry l2_ptp = { 1065 1065 /* MAC: 01-1B-19-00-00-00 */ 1066 1066 .mac = { 0x01, 0x1b, 0x19, 0x00, 0x00, 0x00 }, 1067 1067 .portmask = 0x03, /* Management ports */ ··· 1072 1072 .reprio_tc = 6, /* TC: 6 as per IEEE 802.1AS */ 1073 1073 .reprio_en = 1, 1074 1074 }; 1075 - static struct hellcreek_fdb_entry udp4_ptp = { 1075 + static const struct hellcreek_fdb_entry udp4_ptp = { 1076 1076 /* MAC: 01-00-5E-00-01-81 */ 1077 1077 .mac = { 0x01, 0x00, 0x5e, 0x00, 0x01, 0x81 }, 1078 1078 .portmask = 0x03, /* Management ports */ ··· 1083 1083 .reprio_tc = 6, 1084 1084 .reprio_en = 1, 1085 1085 }; 1086 - static struct hellcreek_fdb_entry udp6_ptp = { 1086 + static const struct hellcreek_fdb_entry udp6_ptp = { 1087 1087 /* MAC: 33-33-00-00-01-81 */ 1088 1088 .mac = { 0x33, 0x33, 0x00, 0x00, 0x01, 0x81 }, 1089 1089 .portmask = 0x03, /* Management ports */ ··· 1094 1094 .reprio_tc = 6, 1095 1095 .reprio_en = 1, 1096 1096 }; 1097 - static struct hellcreek_fdb_entry l2_p2p = { 1097 + static const struct hellcreek_fdb_entry l2_p2p = { 1098 1098 /* MAC: 01-80-C2-00-00-0E */ 1099 1099 .mac = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e }, 1100 1100 .portmask = 0x03, /* Management ports */ ··· 1105 1105 .reprio_tc = 6, /* TC: 6 as per IEEE 802.1AS */ 1106 1106 .reprio_en = 1, 1107 1107 }; 1108 - static struct hellcreek_fdb_entry udp4_p2p = { 1108 + static const struct hellcreek_fdb_entry udp4_p2p = { 1109 1109 /* MAC: 01-00-5E-00-00-6B */ 1110 1110 .mac = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x6b }, 1111 1111 .portmask = 0x03, /* Management ports */ ··· 1116 1116 .reprio_tc = 6, 1117 1117 .reprio_en = 1, 1118 1118 }; 1119 - static struct hellcreek_fdb_entry udp6_p2p = { 1119 + static const struct hellcreek_fdb_entry udp6_p2p = { 1120 1120 /* MAC: 33-33-00-00-00-6B */ 1121 1121 .mac = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x6b }, 1122 1122 .portmask = 0x03, /* Management ports */ ··· 1127 1127 .reprio_tc = 6, 1128 1128 .reprio_en = 1, 1129 1129 }; 1130 - static struct hellcreek_fdb_entry stp = { 1130 + static const struct hellcreek_fdb_entry stp = { 1131 1131 /* MAC: 01-80-C2-00-00-00 */ 1132 1132 .mac = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 }, 1133 1133 .portmask = 0x03, /* Management ports */ ··· 1320 1320 return 0; 1321 1321 } 1322 1322 1323 - static struct devlink_region_ops hellcreek_region_vlan_ops = { 1323 + static const struct devlink_region_ops hellcreek_region_vlan_ops = { 1324 1324 .name = "vlan", 1325 1325 .snapshot = hellcreek_devlink_region_vlan_snapshot, 1326 1326 .destructor = kfree, 1327 1327 }; 1328 1328 1329 - static struct devlink_region_ops hellcreek_region_fdb_ops = { 1329 + static const struct devlink_region_ops hellcreek_region_fdb_ops = { 1330 1330 .name = "fdb", 1331 1331 .snapshot = hellcreek_devlink_region_fdb_snapshot, 1332 1332 .destructor = kfree, ··· 1335 1335 static int hellcreek_setup_devlink_regions(struct dsa_switch *ds) 1336 1336 { 1337 1337 struct hellcreek *hellcreek = ds->priv; 1338 - struct devlink_region_ops *ops; 1338 + const struct devlink_region_ops *ops; 1339 1339 struct devlink_region *region; 1340 1340 u64 size; 1341 1341 int ret;