[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <dfc7876d660d700a840e64c35de0a6519e117539.1723031352.git.christophe.jaillet@wanadoo.fr>
Date: Wed, 7 Aug 2024 13:50:31 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
netdev@...r.kernel.org
Subject: [PATCH net-next] net: ibm/emac: 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.
On a x86_64, with allmodconfig:
Before:
======
4901 464 0 5365 14f5 drivers/net/ethernet/ibm/emac/phy.o
After:
=====
text data bss dec hex filename
5127 240 0 5367 14f7 drivers/net/ethernet/ibm/emac/phy.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Compile tested-only.
---
drivers/net/ethernet/ibm/emac/phy.c | 18 +++++++++---------
drivers/net/ethernet/ibm/emac/phy.h | 2 +-
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/ibm/emac/phy.c b/drivers/net/ethernet/ibm/emac/phy.c
index 1e798cc9b6b8..f90abcfaf487 100644
--- a/drivers/net/ethernet/ibm/emac/phy.c
+++ b/drivers/net/ethernet/ibm/emac/phy.c
@@ -284,7 +284,7 @@ static const struct mii_phy_ops generic_phy_ops = {
.read_link = genmii_read_link
};
-static struct mii_phy_def genmii_phy_def = {
+static const struct mii_phy_def genmii_phy_def = {
.phy_id = 0x00000000,
.phy_id_mask = 0x00000000,
.name = "Generic MII",
@@ -349,14 +349,14 @@ static const struct mii_phy_ops cis8201_phy_ops = {
.read_link = genmii_read_link
};
-static struct mii_phy_def cis8201_phy_def = {
+static const struct mii_phy_def cis8201_phy_def = {
.phy_id = 0x000fc410,
.phy_id_mask = 0x000ffff0,
.name = "CIS8201 Gigabit Ethernet",
.ops = &cis8201_phy_ops
};
-static struct mii_phy_def bcm5248_phy_def = {
+static const struct mii_phy_def bcm5248_phy_def = {
.phy_id = 0x0143bc00,
.phy_id_mask = 0x0ffffff0,
@@ -429,7 +429,7 @@ static const struct mii_phy_ops et1011c_phy_ops = {
.read_link = genmii_read_link
};
-static struct mii_phy_def et1011c_phy_def = {
+static const struct mii_phy_def et1011c_phy_def = {
.phy_id = 0x0282f000,
.phy_id_mask = 0x0fffff00,
.name = "ET1011C Gigabit Ethernet",
@@ -448,7 +448,7 @@ static const struct mii_phy_ops m88e1111_phy_ops = {
.read_link = genmii_read_link
};
-static struct mii_phy_def m88e1111_phy_def = {
+static const struct mii_phy_def m88e1111_phy_def = {
.phy_id = 0x01410CC0,
.phy_id_mask = 0x0ffffff0,
@@ -464,7 +464,7 @@ static const struct mii_phy_ops m88e1112_phy_ops = {
.read_link = genmii_read_link
};
-static struct mii_phy_def m88e1112_phy_def = {
+static const struct mii_phy_def m88e1112_phy_def = {
.phy_id = 0x01410C90,
.phy_id_mask = 0x0ffffff0,
.name = "Marvell 88E1112 Ethernet",
@@ -489,14 +489,14 @@ static const struct mii_phy_ops ar8035_phy_ops = {
.read_link = genmii_read_link,
};
-static struct mii_phy_def ar8035_phy_def = {
+static const struct mii_phy_def ar8035_phy_def = {
.phy_id = 0x004dd070,
.phy_id_mask = 0xfffffff0,
.name = "Atheros 8035 Gigabit Ethernet",
.ops = &ar8035_phy_ops,
};
-static struct mii_phy_def *mii_phy_table[] = {
+static const struct mii_phy_def *mii_phy_table[] = {
&et1011c_phy_def,
&cis8201_phy_def,
&bcm5248_phy_def,
@@ -509,7 +509,7 @@ static struct mii_phy_def *mii_phy_table[] = {
int emac_mii_phy_probe(struct mii_phy *phy, int address)
{
- struct mii_phy_def *def;
+ const struct mii_phy_def *def;
int i;
u32 id;
diff --git a/drivers/net/ethernet/ibm/emac/phy.h b/drivers/net/ethernet/ibm/emac/phy.h
index 2184e8373ee5..b1ede47a540f 100644
--- a/drivers/net/ethernet/ibm/emac/phy.h
+++ b/drivers/net/ethernet/ibm/emac/phy.h
@@ -47,7 +47,7 @@ struct mii_phy_def {
/* An instance of a PHY, partially borrowed from mii_if_info */
struct mii_phy {
- struct mii_phy_def *def;
+ const struct mii_phy_def *def;
u32 advertising; /* Ethtool ADVERTISED_* defines */
u32 features; /* Copied from mii_phy_def.features
or determined automaticaly */
--
2.45.2
Powered by blists - more mailing lists