lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 May 2019 15:30:01 -0400
From:   Vivien Didelot <vivien.didelot@...il.com>
To:     netdev@...r.kernel.org
Cc:     cphealy@...il.com, Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        "David S. Miller" <davem@...emloft.net>
Subject: [RFC net-next 6/9] net: dsa: mv88e6xxx: add default bus operations

In order to prepare the introduction of alternative busses, add a
default mv88e6xxx_bus_ops pointer to the mv88e6xxx_chip structure.

A bus may set the default operations if they aren't already set.

Signed-off-by: Vivien Didelot <vivien.didelot@...il.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 10 ++++++++--
 drivers/net/dsa/mv88e6xxx/chip.h |  3 +++
 drivers/net/dsa/mv88e6xxx/smi.c  |  3 +++
 drivers/net/dsa/mv88e6xxx/smi.h  | 18 ------------------
 4 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 28414db979b0..96e1886e05f0 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -59,7 +59,10 @@ int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
 
 	assert_reg_lock(chip);
 
-	err = mv88e6xxx_smi_read(chip, addr, reg, val);
+	if (unlikely(!(chip->ops && chip->ops->read)))
+		return -EOPNOTSUPP;
+
+	err = chip->ops->read(chip, addr, reg, val);
 	if (err)
 		return err;
 
@@ -75,7 +78,10 @@ int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
 
 	assert_reg_lock(chip);
 
-	err = mv88e6xxx_smi_write(chip, addr, reg, val);
+	if (unlikely(!(chip->ops && chip->ops->write)))
+		return -EOPNOTSUPP;
+
+	err = chip->ops->write(chip, addr, reg, val);
 	if (err)
 		return err;
 
diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index faa3fa889f19..860816ebb7ee 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -204,6 +204,9 @@ struct mv88e6xxx_chip {
 	/* This mutex protects the access to the switch registers */
 	struct mutex reg_lock;
 
+	/* The default registered bus operations */
+	const struct mv88e6xxx_bus_ops *ops;
+
 	/* The MII bus and the address on the bus that is used to
 	 * communication with the switch
 	 */
diff --git a/drivers/net/dsa/mv88e6xxx/smi.c b/drivers/net/dsa/mv88e6xxx/smi.c
index 96f7d2685bdc..77c40596b678 100644
--- a/drivers/net/dsa/mv88e6xxx/smi.c
+++ b/drivers/net/dsa/mv88e6xxx/smi.c
@@ -154,5 +154,8 @@ int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
 	chip->bus = bus;
 	chip->sw_addr = sw_addr;
 
+	if (!chip->ops)
+		chip->ops = chip->smi_ops;
+
 	return 0;
 }
diff --git a/drivers/net/dsa/mv88e6xxx/smi.h b/drivers/net/dsa/mv88e6xxx/smi.h
index 35e6403b65dc..566bfa174354 100644
--- a/drivers/net/dsa/mv88e6xxx/smi.h
+++ b/drivers/net/dsa/mv88e6xxx/smi.h
@@ -38,22 +38,4 @@
 int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
 		       struct mii_bus *bus, int sw_addr);
 
-static inline int mv88e6xxx_smi_read(struct mv88e6xxx_chip *chip,
-				     int dev, int reg, u16 *data)
-{
-	if (chip->smi_ops && chip->smi_ops->read)
-		return chip->smi_ops->read(chip, dev, reg, data);
-
-	return -EOPNOTSUPP;
-}
-
-static inline int mv88e6xxx_smi_write(struct mv88e6xxx_chip *chip,
-				      int dev, int reg, u16 data)
-{
-	if (chip->smi_ops && chip->smi_ops->write)
-		return chip->smi_ops->write(chip, dev, reg, data);
-
-	return -EOPNOTSUPP;
-}
-
 #endif /* _MV88E6XXX_SMI_H */
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ