Skip to contentSkip to conversation

dsa: Remove unnecessary exports

PATCH Applied Ben Hutchings 4 participants 10 messages Nov 28, 2011 – Nov 29, 2011

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

PATCH 1/3 dsa: Remove unnecessary exports

I mistakenly exported functions from slave.c that are only called from dsa.c, part of the same module.

---
 net/dsa/slave.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
net/dsa/slave.c +0 -2
index c9d52ca..56cf9b8 100644
@@ -45,7 +45,6 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
 			ds->master_mii_bus->id, ds->pd->sw_addr);
 	ds->slave_mii_bus->parent = &ds->master_mii_bus->dev;
 }
-EXPORT_SYMBOL_GPL(dsa_slave_mii_bus_init);
 
 
 /* slave device handling ****************************************************/
@@ -403,4 +402,3 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 
 	return slave_dev;
 }
-EXPORT_SYMBOL_GPL(dsa_slave_create);
Signature · 1 line
1.7.7.3
#1 lore raw

PATCH 2/3 dsa: Move all definitions needed by drivers into <net/dsa.h>

Any headers included by drivers should be under include/, and any definitions they use are not really private to the core as the name "dsa_priv.h" suggests.

---
 include/net/dsa.h         |   90 ++++++++++++++++++++++++++++++++++++++++++++
 net/dsa/dsa_priv.h        |   91 ---------------------------------------------
 net/dsa/mv88e6060.c       |    2 +-
 net/dsa/mv88e6123_61_65.c |    2 +-
 net/dsa/mv88e6131.c       |    2 +-
 net/dsa/mv88e6xxx.c       |    2 +-
 6 files changed, 94 insertions(+), 95 deletions(-)
include/net/dsa.h +90 -0
index 32a1b49..b78db3c 100644
@@ -11,6 +11,7 @@
 #ifndef __LINUX_NET_DSA_H
 #define __LINUX_NET_DSA_H
 
+#include <linux/list.h>
 #include <linux/timer.h>
 #include <linux/workqueue.h>
 
@@ -90,6 +91,95 @@ struct dsa_switch_tree {
 	struct dsa_switch	*ds[DSA_MAX_SWITCHES];
 };
 
+struct dsa_switch {
+	/*
+	 * Parent switch tree, and switch index.
+	 */
+	struct dsa_switch_tree	*dst;
+	int			index;
+
+	/*
+	 * Configuration data for this switch.
+	 */
+	struct dsa_chip_data	*pd;
+
+	/*
+	 * The used switch driver.
+	 */
+	struct dsa_switch_driver	*drv;
+
+	/*
+	 * Reference to mii bus to use.
+	 */
+	struct mii_bus		*master_mii_bus;
+
+	/*
+	 * Slave mii_bus and devices for the individual ports.
+	 */
+	u32			dsa_port_mask;
+	u32			phys_port_mask;
+	struct mii_bus		*slave_mii_bus;
+	struct net_device	*ports[DSA_MAX_PORTS];
+};
+
+static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
+{
+	return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
+}
+
+static inline u8 dsa_upstream_port(struct dsa_switch *ds)
+{
+	struct dsa_switch_tree *dst = ds->dst;
+
+	/*
+	 * If this is the root switch (i.e. the switch that connects
+	 * to the CPU), return the cpu port number on this switch.
+	 * Else return the (DSA) port number that connects to the
+	 * switch that is one hop closer to the cpu.
+	 */
+	if (dst->cpu_switch == ds->index)
+		return dst->cpu_port;
+	else
+		return ds->pd->rtable[dst->cpu_switch];
+}
+
+struct dsa_switch_driver {
+	struct list_head	list;
+
+	__be16			tag_protocol;
+	int			priv_size;
+
+	/*
+	 * Probing and setup.
+	 */
+	char	*(*probe)(struct mii_bus *bus, int sw_addr);
+	int	(*setup)(struct dsa_switch *ds);
+	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
+
+	/*
+	 * Access to the switch's PHY registers.
+	 */
+	int	(*phy_read)(struct dsa_switch *ds, int port, int regnum);
+	int	(*phy_write)(struct dsa_switch *ds, int port,
+			     int regnum, u16 val);
+
+	/*
+	 * Link state polling and IRQ handling.
+	 */
+	void	(*poll_link)(struct dsa_switch *ds);
+
+	/*
+	 * ethtool hardware statistics.
+	 */
+	void	(*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
+	void	(*get_ethtool_stats)(struct dsa_switch *ds,
+				     int port, uint64_t *data);
+	int	(*get_sset_count)(struct dsa_switch *ds);
+};
+
+void register_switch_driver(struct dsa_switch_driver *type);
+void unregister_switch_driver(struct dsa_switch_driver *type);
+
 /*
  * The original DSA tag format and some other tag formats have no
  * ethertype, which means that we need to add a little hack to the
net/dsa/dsa_priv.h +0 -91

108 lines not on this page · raw message

net/dsa/mv88e6060.c +1 -1
index 0e028df..7fc4e81 100644
@@ -11,7 +11,7 @@
 #include <linux/list.h>
 #include <linux/netdevice.h>
 #include <linux/phy.h>
-#include "dsa_priv.h"
+#include <net/dsa.h>
 
 #define REG_PORT(p)		(8 + (p))
 #define REG_GLOBAL		0x0f
net/dsa/mv88e6123_61_65.c +1 -1
index 6504405..c0a458f 100644
@@ -11,7 +11,7 @@
 #include <linux/list.h>
 #include <linux/netdevice.h>
 #include <linux/phy.h>
-#include "dsa_priv.h"
+#include <net/dsa.h>
 #include "mv88e6xxx.h"
 
 static char *mv88e6123_61_65_probe(struct mii_bus *bus, int sw_addr)
net/dsa/mv88e6131.c +1 -1
index 6786ba4..e0eb6824 100644
@@ -11,7 +11,7 @@
 #include <linux/list.h>
 #include <linux/netdevice.h>
 #include <linux/phy.h>
-#include "dsa_priv.h"
+#include <net/dsa.h>
 #include "mv88e6xxx.h"
 
 /*
net/dsa/mv88e6xxx.c +1 -1
index cacd955..5467c04 100644
@@ -11,7 +11,7 @@
 #include <linux/list.h>
 #include <linux/netdevice.h>
 #include <linux/phy.h>
-#include "dsa_priv.h"
+#include <net/dsa.h>
 #include "mv88e6xxx.h"
 
 /*
Signature · 1 line
1.7.7.3
#4 lore raw

PATCH 3/3 dsa: Move switch drivers to new directory drivers/net/dsa

In reply to Ben Hutchings

Support for specific hardware belongs under drivers/net/ not net/.

---
This seems to work, but again it's compile-tested only.

Ben.

 drivers/net/Kconfig                        |    2 +
 drivers/net/Makefile                       |    1 +
 drivers/net/dsa/Kconfig                    |   36 ++++++++++++++++++++++++++++
 drivers/net/dsa/Makefile                   |    9 +++++++
 {net => drivers/net}/dsa/mv88e6060.c       |    0
 {net => drivers/net}/dsa/mv88e6123_61_65.c |    0
 {net => drivers/net}/dsa/mv88e6131.c       |    0
 {net => drivers/net}/dsa/mv88e6xxx.c       |    0
 {net => drivers/net}/dsa/mv88e6xxx.h       |    0
 net/dsa/Kconfig                            |   36 +---------------------------
 net/dsa/Makefile                           |   11 --------
 11 files changed, 49 insertions(+), 46 deletions(-)
 create mode 100644 drivers/net/dsa/Kconfig
 create mode 100644 drivers/net/dsa/Makefile
 rename {net => drivers/net}/dsa/mv88e6060.c (100%)
 rename {net => drivers/net}/dsa/mv88e6123_61_65.c (100%)
 rename {net => drivers/net}/dsa/mv88e6131.c (100%)
 rename {net => drivers/net}/dsa/mv88e6xxx.c (100%)
 rename {net => drivers/net}/dsa/mv88e6xxx.h (100%)
drivers/net/Kconfig +2 -0
index debdf1c..9845afb 100644
@@ -243,6 +243,8 @@ source "drivers/atm/Kconfig"
 
 source "drivers/net/caif/Kconfig"
 
+source "drivers/net/dsa/Kconfig"
+
 source "drivers/net/ethernet/Kconfig"
 
 source "drivers/net/fddi/Kconfig"
drivers/net/Makefile +1 -0
index 4e4ebfe..1988881 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_DEV_APPLETALK) += appletalk/
 obj-$(CONFIG_CAIF) += caif/
 obj-$(CONFIG_CAN) += can/
 obj-$(CONFIG_ETRAX_ETHERNET) += cris/
+obj-$(CONFIG_NET_DSA) += dsa/
 obj-$(CONFIG_ETHERNET) += ethernet/
 obj-$(CONFIG_FDDI) += fddi/
 obj-$(CONFIG_HIPPI) += hippi/
drivers/net/dsa/Kconfig new file +36 -0
new file mode 100644
index 0000000..dd151d5
@@ -0,0 +1,36 @@
+menu "Distributed Switch Architecture drivers"
+	depends on NET_DSA
+
+config NET_DSA_MV88E6XXX
+	tristate
+	default n
+
+config NET_DSA_MV88E6060
+	tristate "Marvell 88E6060 ethernet switch chip support"
+	select NET_DSA_TAG_TRAILER
+	---help---
+	  This enables support for the Marvell 88E6060 ethernet switch
+	  chip.
+
+config NET_DSA_MV88E6XXX_NEED_PPU
+	bool
+	default n
+
+config NET_DSA_MV88E6131
+	tristate "Marvell 88E6085/6095/6095F/6131 ethernet switch chip support"
+	select NET_DSA_MV88E6XXX
+	select NET_DSA_MV88E6XXX_NEED_PPU
+	select NET_DSA_TAG_DSA
+	---help---
+	  This enables support for the Marvell 88E6085/6095/6095F/6131
+	  ethernet switch chips.
+
+config NET_DSA_MV88E6123_61_65
+	tristate "Marvell 88E6123/6161/6165 ethernet switch chip support"
+	select NET_DSA_MV88E6XXX
+	select NET_DSA_TAG_EDSA
+	---help---
+	  This enables support for the Marvell 88E6123/6161/6165
+	  ethernet switch chips.
+
+endmenu
drivers/net/dsa/Makefile new file +9 -0
new file mode 100644
index 0000000..f3bda05
@@ -0,0 +1,9 @@
+obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
+obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o
+mv88e6xxx_drv-y += mv88e6xxx.o
+ifdef CONFIG_NET_DSA_MV88E6123_61_65
+mv88e6xxx_drv-y += mv88e6123_61_65.o
+endif
+ifdef CONFIG_NET_DSA_MV88E6131
+mv88e6xxx_drv-y += mv88e6131.o
+endif
drivers/net/dsa/mv88e6060.c renamed from net/dsa/mv88e6060.c +0 -0
similarity index 100%
rename from net/dsa/mv88e6060.c
rename to drivers/net/dsa/mv88e6060.c
drivers/net/dsa/mv88e6123_61_65.c renamed from net/dsa/mv88e6123_61_65.c +0 -0
similarity index 100%
rename from net/dsa/mv88e6123_61_65.c
rename to drivers/net/dsa/mv88e6123_61_65.c
drivers/net/dsa/mv88e6131.c renamed from net/dsa/mv88e6131.c +0 -0
similarity index 100%
rename from net/dsa/mv88e6131.c
rename to drivers/net/dsa/mv88e6131.c
drivers/net/dsa/mv88e6xxx.c renamed from net/dsa/mv88e6xxx.c +0 -0
similarity index 100%
rename from net/dsa/mv88e6xxx.c
rename to drivers/net/dsa/mv88e6xxx.c
drivers/net/dsa/mv88e6xxx.h renamed from net/dsa/mv88e6xxx.h +0 -0
similarity index 100%
rename from net/dsa/mv88e6xxx.h
rename to drivers/net/dsa/mv88e6xxx.h
net/dsa/Kconfig +1 -35
index 7e12303..274791c 100644
@@ -1,4 +1,4 @@
-menuconfig NET_DSA
+config NET_DSA
 	tristate "Distributed Switch Architecture support"
 	default n
 	depends on EXPERIMENTAL && NETDEVICES && !S390
@@ -23,38 +23,4 @@ config NET_DSA_TAG_TRAILER
 	bool
 	default n
 
-
-# switch drivers
-config NET_DSA_MV88E6XXX
-	tristate
-	default n
-
-config NET_DSA_MV88E6060
-	tristate "Marvell 88E6060 ethernet switch chip support"
-	select NET_DSA_TAG_TRAILER
-	---help---
-	  This enables support for the Marvell 88E6060 ethernet switch
-	  chip.
-
-config NET_DSA_MV88E6XXX_NEED_PPU
-	bool
-	default n
-
-config NET_DSA_MV88E6131
-	tristate "Marvell 88E6085/6095/6095F/6131 ethernet switch chip support"
-	select NET_DSA_MV88E6XXX
-	select NET_DSA_MV88E6XXX_NEED_PPU
-	select NET_DSA_TAG_DSA
-	---help---
-	  This enables support for the Marvell 88E6085/6095/6095F/6131
-	  ethernet switch chips.
-
-config NET_DSA_MV88E6123_61_65
-	tristate "Marvell 88E6123/6161/6165 ethernet switch chip support"
-	select NET_DSA_MV88E6XXX
-	select NET_DSA_TAG_EDSA
-	---help---
-	  This enables support for the Marvell 88E6123/6161/6165
-	  ethernet switch chips.
-
 endif
net/dsa/Makefile +0 -11
index 191dd48..7b9fcbb 100644
@@ -6,14 +6,3 @@ dsa_core-y += dsa.o slave.o
 dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
 dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
 dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
-
-# switch drivers
-obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
-obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o
-mv88e6xxx_drv-y += mv88e6xxx.o
-ifdef CONFIG_NET_DSA_MV88E6123_61_65
-mv88e6xxx_drv-y += mv88e6123_61_65.o
-endif
-ifdef CONFIG_NET_DSA_MV88E6131
-mv88e6xxx_drv-y += mv88e6131.o
-endif
Signature · 1 line
1.7.7.3
#5 lore raw

Re: [PATCH net-next 3/3] dsa: Move switch drivers to new directory drivers/net/dsa

Quoted 1 line · Ben Hutchings

Support for specific hardware belongs under drivers/net/ not net/.

Not sure I agree but maybe
drivers/net/ethernet/marvell/dsa?