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: sungem_phy: Constify struct mii_phy_def

'struct mii_phy_def' are not modified in this driver.

Constifying these structures moves some data to a read-only section, so
increase overall security.

While at it fix the checkpatch warning related to this patch (some missing
newlines and spaces around *)

On a x86_64, with allmodconfig:
Before:
======
27709 928 0 28637 6fdd drivers/net/sungem_phy.o

After:
=====
text data bss dec hex filename
28157 476 0 28633 6fd9 drivers/net/sungem_phy.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/54c3b30930f80f4895e6fa2f4234714fdea4ef4e.1723033266.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christophe JAILLET and committed by
Jakub Kicinski
09612576 ceb62743

+20 -17
+19 -16
drivers/net/sungem_phy.c
··· 893 893 .read_link = genmii_read_link, 894 894 }; 895 895 896 - static struct mii_phy_def bcm5201_phy_def = { 896 + static const struct mii_phy_def bcm5201_phy_def = { 897 897 .phy_id = 0x00406210, 898 898 .phy_id_mask = 0xfffffff0, 899 899 .name = "BCM5201", ··· 912 912 .read_link = genmii_read_link, 913 913 }; 914 914 915 - static struct mii_phy_def bcm5221_phy_def = { 915 + static const struct mii_phy_def bcm5221_phy_def = { 916 916 .phy_id = 0x004061e0, 917 917 .phy_id_mask = 0xfffffff0, 918 918 .name = "BCM5221", ··· 930 930 .poll_link = genmii_poll_link, 931 931 .read_link = genmii_read_link, 932 932 }; 933 - static struct mii_phy_def bcm5241_phy_def = { 933 + 934 + static const struct mii_phy_def bcm5241_phy_def = { 934 935 .phy_id = 0x0143bc30, 935 936 .phy_id_mask = 0xfffffff0, 936 937 .name = "BCM5241", ··· 950 949 .read_link = bcm54xx_read_link, 951 950 }; 952 951 953 - static struct mii_phy_def bcm5400_phy_def = { 952 + static const struct mii_phy_def bcm5400_phy_def = { 954 953 .phy_id = 0x00206040, 955 954 .phy_id_mask = 0xfffffff0, 956 955 .name = "BCM5400", ··· 969 968 .read_link = bcm54xx_read_link, 970 969 }; 971 970 972 - static struct mii_phy_def bcm5401_phy_def = { 971 + static const struct mii_phy_def bcm5401_phy_def = { 973 972 .phy_id = 0x00206050, 974 973 .phy_id_mask = 0xfffffff0, 975 974 .name = "BCM5401", ··· 988 987 .read_link = bcm54xx_read_link, 989 988 }; 990 989 991 - static struct mii_phy_def bcm5411_phy_def = { 990 + static const struct mii_phy_def bcm5411_phy_def = { 992 991 .phy_id = 0x00206070, 993 992 .phy_id_mask = 0xfffffff0, 994 993 .name = "BCM5411", ··· 1008 1007 .enable_fiber = bcm5421_enable_fiber, 1009 1008 }; 1010 1009 1011 - static struct mii_phy_def bcm5421_phy_def = { 1010 + static const struct mii_phy_def bcm5421_phy_def = { 1012 1011 .phy_id = 0x002060e0, 1013 1012 .phy_id_mask = 0xfffffff0, 1014 1013 .name = "BCM5421", ··· 1027 1026 .read_link = bcm54xx_read_link, 1028 1027 }; 1029 1028 1030 - static struct mii_phy_def bcm5421k2_phy_def = { 1029 + static const struct mii_phy_def bcm5421k2_phy_def = { 1031 1030 .phy_id = 0x002062e0, 1032 1031 .phy_id_mask = 0xfffffff0, 1033 1032 .name = "BCM5421-K2", ··· 1046 1045 .enable_fiber = bcm5461_enable_fiber, 1047 1046 }; 1048 1047 1049 - static struct mii_phy_def bcm5461_phy_def = { 1048 + static const struct mii_phy_def bcm5461_phy_def = { 1050 1049 .phy_id = 0x002060c0, 1051 1050 .phy_id_mask = 0xfffffff0, 1052 1051 .name = "BCM5461", ··· 1065 1064 .read_link = bcm54xx_read_link, 1066 1065 }; 1067 1066 1068 - static struct mii_phy_def bcm5462V_phy_def = { 1067 + static const struct mii_phy_def bcm5462V_phy_def = { 1069 1068 .phy_id = 0x002060d0, 1070 1069 .phy_id_mask = 0xfffffff0, 1071 1070 .name = "BCM5462-Vesta", ··· 1095 1094 /* two revs in darwin for the 88e1101 ... I could use a datasheet 1096 1095 * to get the proper names... 1097 1096 */ 1098 - static struct mii_phy_def marvell88e1101v1_phy_def = { 1097 + static const struct mii_phy_def marvell88e1101v1_phy_def = { 1099 1098 .phy_id = 0x01410c20, 1100 1099 .phy_id_mask = 0xfffffff0, 1101 1100 .name = "Marvell 88E1101v1", ··· 1103 1102 .magic_aneg = 1, 1104 1103 .ops = &marvell88e1101_phy_ops 1105 1104 }; 1106 - static struct mii_phy_def marvell88e1101v2_phy_def = { 1105 + 1106 + static const struct mii_phy_def marvell88e1101v2_phy_def = { 1107 1107 .phy_id = 0x01410c60, 1108 1108 .phy_id_mask = 0xfffffff0, 1109 1109 .name = "Marvell 88E1101v2", ··· 1112 1110 .magic_aneg = 1, 1113 1111 .ops = &marvell88e1101_phy_ops 1114 1112 }; 1115 - static struct mii_phy_def marvell88e1111_phy_def = { 1113 + 1114 + static const struct mii_phy_def marvell88e1111_phy_def = { 1116 1115 .phy_id = 0x01410cc0, 1117 1116 .phy_id_mask = 0xfffffff0, 1118 1117 .name = "Marvell 88E1111", ··· 1130 1127 .read_link = genmii_read_link 1131 1128 }; 1132 1129 1133 - static struct mii_phy_def genmii_phy_def = { 1130 + static const struct mii_phy_def genmii_phy_def = { 1134 1131 .phy_id = 0x00000000, 1135 1132 .phy_id_mask = 0x00000000, 1136 1133 .name = "Generic MII", ··· 1139 1136 .ops = &generic_phy_ops 1140 1137 }; 1141 1138 1142 - static struct mii_phy_def* mii_phy_table[] = { 1139 + static const struct mii_phy_def *mii_phy_table[] = { 1143 1140 &bcm5201_phy_def, 1144 1141 &bcm5221_phy_def, 1145 1142 &bcm5241_phy_def, ··· 1159 1156 1160 1157 int sungem_phy_probe(struct mii_phy *phy, int mii_id) 1161 1158 { 1159 + const struct mii_phy_def *def; 1162 1160 int rc; 1163 1161 u32 id; 1164 - struct mii_phy_def* def; 1165 1162 int i; 1166 1163 1167 1164 /* We do not reset the mii_phy structure as the driver
+1 -1
include/linux/sungem_phy.h
··· 40 40 /* An instance of a PHY, partially borrowed from mii_if_info */ 41 41 struct mii_phy 42 42 { 43 - struct mii_phy_def* def; 43 + const struct mii_phy_def *def; 44 44 u32 advertising; 45 45 int mii_id; 46 46