linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 0/3] net: generic netdev_ioaddr
@ 2004-10-29 10:04 Pekka Enberg
  2004-10-29 10:04 ` [PATCH 1/3] " Pekka Enberg
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Pekka Enberg @ 2004-10-29 10:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

Hi,

This patch introduces a generic netdev_ioaddr and converts natsemi and
8139too drivers to use it.

With the recent __iomem annotations, the network drivers need to either
invent this wrapper (like natsemi has done) or duplicate the IO base
address in their private data (similar to 8139too).  Therefore, lets
make netdev_ioaddr generic before it is all over the place.

			Pekka


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/3] net: generic netdev_ioaddr
  2004-10-29 10:04 [RFC][PATCH 0/3] net: generic netdev_ioaddr Pekka Enberg
@ 2004-10-29 10:04 ` Pekka Enberg
  2004-10-29 10:05   ` [PATCH 2/3] net: use netdev_ioaddr in natsemi Pekka Enberg
  2004-10-29 11:52 ` [RFC][PATCH 0/3] net: generic netdev_ioaddr Christoph Hellwig
  2004-10-29 13:16 ` Al Viro
  2 siblings, 1 reply; 16+ messages in thread
From: Pekka Enberg @ 2004-10-29 10:04 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

This patch introduces a generic netdev_ioaddr in include/linux/netdevice.h.
It is pulled from driver/net/natsemi.c.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 netdevice.h |    5 +++++
 1 files changed, 5 insertions(+)

Index: 2.6.10-rc1-mm1/include/linux/netdevice.h
===================================================================
--- 2.6.10-rc1-mm1.orig/include/linux/netdevice.h	2004-10-29 11:07:56.000000000 +0300
+++ 2.6.10-rc1-mm1/include/linux/netdevice.h	2004-10-29 11:37:56.000000000 +0300
@@ -500,6 +500,11 @@
 				& ~NETDEV_ALIGN_CONST);
 }
 
+static inline void __iomem *netdev_ioaddr(struct net_device *dev)
+{
+	return (void __iomem *) dev->base_addr;
+}
+
 #define SET_MODULE_OWNER(dev) do { } while (0)
 /* Set the sysfs physical device reference for the network logical device
  * if set prior to registration will cause a symlink during initialization.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/3] net: use netdev_ioaddr in natsemi
  2004-10-29 10:04 ` [PATCH 1/3] " Pekka Enberg
@ 2004-10-29 10:05   ` Pekka Enberg
  2004-10-29 10:05     ` [PATCH 3/3] net: use netdev_ioaddr in 8139too Pekka Enberg
  0 siblings, 1 reply; 16+ messages in thread
From: Pekka Enberg @ 2004-10-29 10:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

This patch converts natsemi driver to use netdev_ioaddr.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 natsemi.c |   75 ++++++++++++++++++++++++++++----------------------------------
 1 files changed, 35 insertions(+), 40 deletions(-)

Index: 2.6.10-rc1-mm1/drivers/net/natsemi.c
===================================================================
--- 2.6.10-rc1-mm1.orig/drivers/net/natsemi.c	2004-10-29 11:07:52.000000000 +0300
+++ 2.6.10-rc1-mm1/drivers/net/natsemi.c	2004-10-29 11:38:30.000000000 +0300
@@ -770,15 +770,10 @@
 static int netdev_get_eeprom(struct net_device *dev, u8 *buf);
 static struct ethtool_ops ethtool_ops;
 
-static inline void __iomem *ns_ioaddr(struct net_device *dev)
-{
-	return (void __iomem *) dev->base_addr;
-}
-
 static void move_int_phy(struct net_device *dev, int addr)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int target = 31;
 
 	/* 
@@ -1073,7 +1068,7 @@
 static int mii_getbit (struct net_device *dev)
 {
 	int data;
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	writel(MII_ShiftClk, ioaddr + EECtrl);
 	data = readl(ioaddr + EECtrl);
@@ -1085,7 +1080,7 @@
 static void mii_send_bits (struct net_device *dev, u32 data, int len)
 {
 	u32 i;
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	for (i = (1 << (len-1)); i; i >>= 1)
 	{
@@ -1141,7 +1136,7 @@
 static int mdio_read(struct net_device *dev, int reg)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	/* The 83815 series has two ports:
 	 * - an internal transceiver
@@ -1156,7 +1151,7 @@
 static void mdio_write(struct net_device *dev, int reg, u16 data)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	/* The 83815 series has an internal transceiver; handle separately */
 	if (dev->if_port == PORT_TP)
@@ -1168,7 +1163,7 @@
 static void init_phy_fixup(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int i;
 	u32 cfg;
 	u16 tmp;
@@ -1280,7 +1275,7 @@
 static int switch_port_external(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	u32 cfg;
 
 	cfg = readl(ioaddr + ChipConfig);
@@ -1313,7 +1308,7 @@
 static int switch_port_internal(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int i;
 	u32 cfg;
 	u16 bmcr;
@@ -1414,7 +1409,7 @@
 	u16 pmatch[3];
 	u16 sopass[3];
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	/*
 	 * Resetting the chip causes some registers to be lost.
@@ -1485,7 +1480,7 @@
 static void natsemi_reload_eeprom(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int i;
 
 	writel(EepromReload, ioaddr + PCIBusCfg);
@@ -1505,7 +1500,7 @@
 
 static void natsemi_stop_rxtx(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
 	int i;
 
@@ -1527,7 +1522,7 @@
 static int netdev_open(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	int i;
 
 	/* Reset the chip, just in case. */
@@ -1576,7 +1571,7 @@
 static void do_cable_magic(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	if (dev->if_port != PORT_TP)
 		return;
@@ -1621,7 +1616,7 @@
 {
 	u16 data;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	if (dev->if_port != PORT_TP)
 		return;
@@ -1640,7 +1635,7 @@
 static void check_link(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	int duplex;
 	u16 bmsr;
        
@@ -1701,7 +1696,7 @@
 static void init_registers(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	init_phy_fixup(dev);
 
@@ -1780,7 +1775,7 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	int next_tick = 5*HZ;
 
 	if (netif_msg_timer(np)) {
@@ -1868,7 +1863,7 @@
 static void tx_timeout(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	disable_irq(dev->irq);
 	spin_lock_irq(&np->lock);
@@ -2068,7 +2063,7 @@
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	unsigned entry;
 
 	/* Note: Ordering is important here, set the field with the
@@ -2162,7 +2157,7 @@
 {
 	struct net_device *dev = dev_instance;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	int boguscnt = max_interrupt_work;
 	unsigned int handled = 0;
 
@@ -2224,7 +2219,7 @@
 	int boguscnt = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 	s32 desc_status = le32_to_cpu(np->rx_head_desc->cmd_status);
 	unsigned int buflen = np->rx_buf_sz;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	/* If the driver owns the next entry it's a new packet. Send it up. */
 	while (desc_status < 0) { /* e.g. & DescOwn */
@@ -2312,7 +2307,7 @@
 static void netdev_error(struct net_device *dev, int intr_status)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	spin_lock(&np->lock);
 	if (intr_status & LinkChange) {
@@ -2371,7 +2366,7 @@
 
 static void __get_stats(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
 
 	/* The chip only need report frame silently dropped. */
@@ -2404,7 +2399,7 @@
 #define HASH_TABLE	0x200
 static void __set_rx_mode(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
 	u8 mc_filter[64]; /* Multicast hash filter */
 	u32 rx_mode;
@@ -2450,7 +2445,7 @@
 	/* synchronized against open : rtnl_lock() held by caller */
 	if (netif_running(dev)) {
 		struct netdev_private *np = netdev_priv(dev);
-		void __iomem * ioaddr = ns_ioaddr(dev);
+		void __iomem * ioaddr = netdev_ioaddr(dev);
 
 		disable_irq(dev->irq);
 		spin_lock(&np->lock);
@@ -2612,7 +2607,7 @@
 static int netdev_set_wol(struct net_device *dev, u32 newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	u32 data = readl(ioaddr + WOLCmd) & ~WakeOptsSummary;
 
 	/* translate to bitmasks this chip understands */
@@ -2642,7 +2637,7 @@
 static int netdev_get_wol(struct net_device *dev, u32 *supported, u32 *cur)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	u32 regval = readl(ioaddr + WOLCmd);
 
 	*supported = (WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST
@@ -2678,7 +2673,7 @@
 static int netdev_set_sopass(struct net_device *dev, u8 *newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	u16 *sval = (u16 *)newval;
 	u32 addr;
 
@@ -2710,7 +2705,7 @@
 static int netdev_get_sopass(struct net_device *dev, u8 *data)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	u16 *sval = (u16 *)data;
 	u32 addr;
 
@@ -2894,7 +2889,7 @@
 	int j;
 	u32 rfcr;
 	u32 *rbuf = (u32 *)buf;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	/* read non-mii page 0 of registers */
 	for (i = 0; i < NATSEMI_PG0_NREGS/2; i++) {
@@ -2944,7 +2939,7 @@
 {
 	int i;
 	u16 *ebuf = (u16 *)buf;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	/* eeprom_read reads 16 bits, and indexes by 16 bits */
 	for (i = 0; i < NATSEMI_EEPROM_SIZE/2; i++) {
@@ -3016,7 +3011,7 @@
 
 static void enable_wol_mode(struct net_device *dev, int enable_intr)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
 
 	if (netif_msg_wol(np))
@@ -3049,7 +3044,7 @@
 
 static int netdev_close(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
 
 	if (netif_msg_ifdown(np))
@@ -3126,7 +3121,7 @@
 static void __devexit natsemi_remove1 (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	unregister_netdev (dev);
 	pci_release_regions (pdev);
@@ -3164,7 +3159,7 @@
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = netdev_ioaddr(dev);
 
 	rtnl_lock();
 	if (netif_running (dev)) {




^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/3] net: use netdev_ioaddr in 8139too
  2004-10-29 10:05   ` [PATCH 2/3] net: use netdev_ioaddr in natsemi Pekka Enberg
@ 2004-10-29 10:05     ` Pekka Enberg
  0 siblings, 0 replies; 16+ messages in thread
From: Pekka Enberg @ 2004-10-29 10:05 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

This patch converts 8139too driver to use netdev_ioaddr.

Not tested as I don't have access to the hardware right now.  Compiles and
passes sparse checks.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 8139too.c |  101 +++++++++++++++++++++++++++++++-------------------------------
 1 files changed, 52 insertions(+), 49 deletions(-)

Index: 2.6.10-rc1-mm1/drivers/net/8139too.c
===================================================================
--- 2.6.10-rc1-mm1.orig/drivers/net/8139too.c	2004-10-29 12:02:27.132401800 +0300
+++ 2.6.10-rc1-mm1/drivers/net/8139too.c	2004-10-29 12:18:14.406394264 +0300
@@ -570,7 +570,6 @@
 };
 
 struct rtl8139_private {
-	void *mmio_addr;
 	int drv_flags;
 	struct pci_dev *pci_dev;
 	u32 msg_enable;
@@ -614,7 +613,7 @@
 MODULE_PARM_DESC (media, "8139too: Bits 4+9: force full duplex, bit 5: 100Mbps");
 MODULE_PARM_DESC (full_duplex, "8139too: Force full duplex for board(s) (1)");
 
-static int read_eeprom (void *ioaddr, int location, int addr_len);
+static int read_eeprom (void __iomem *ioaddr, int location, int addr_len);
 static int rtl8139_open (struct net_device *dev);
 static int mdio_read (struct net_device *dev, int phy_id, int location);
 static void mdio_write (struct net_device *dev, int phy_id, int location,
@@ -731,6 +730,16 @@
 static const unsigned int rtl8139_tx_config =
 	TxIFG96 | (TX_DMA_BURST << TxDMAShift) | (TX_RETRY << TxRetryShift);
 
+static void rtl8139_cleanup_iomem (struct net_device *dev)
+{
+#ifndef USE_IO_OPS
+	void __iomem *ioaddr = netdev_ioaddr(dev);
+
+	if (ioaddr)
+		iounmap(ioaddr);
+#endif /* !USE_IO_OPS */
+}
+
 static void __rtl8139_cleanup_dev (struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
@@ -740,10 +749,7 @@
 	assert (tp->pci_dev != NULL);
 	pdev = tp->pci_dev;
 
-#ifndef USE_IO_OPS
-	if (tp->mmio_addr)
-		iounmap (tp->mmio_addr);
-#endif /* !USE_IO_OPS */
+	rtl8139_cleanup_iomem(dev);
 
 	/* it's ok to call this even if we have no regions to free */
 	pci_release_regions (pdev);
@@ -754,7 +760,7 @@
 }
 
 
-static void rtl8139_chip_reset (void *ioaddr)
+static void rtl8139_chip_reset (void __iomem *ioaddr)
 {
 	int i;
 
@@ -774,7 +780,7 @@
 static int __devinit rtl8139_init_board (struct pci_dev *pdev,
 					 struct net_device **dev_out)
 {
-	void *ioaddr;
+	void __iomem *ioaddr;
 	struct net_device *dev;
 	struct rtl8139_private *tp;
 	u8 tmp8;
@@ -855,9 +861,8 @@
 	pci_set_master (pdev);
 
 #ifdef USE_IO_OPS
-	ioaddr = (void *) pio_start;
+	ioaddr = (void __iomem *) pio_start;
 	dev->base_addr = pio_start;
-	tp->mmio_addr = ioaddr;
 	tp->regs_len = pio_len;
 #else
 	/* ioremap MMIO region */
@@ -867,8 +872,7 @@
 		rc = -EIO;
 		goto err_out;
 	}
-	dev->base_addr = (long) ioaddr;
-	tp->mmio_addr = ioaddr;
+	dev->base_addr = (__force long) ioaddr;
 	tp->regs_len = mmio_len;
 #endif /* USE_IO_OPS */
 
@@ -945,7 +949,7 @@
 	struct net_device *dev = NULL;
 	struct rtl8139_private *tp;
 	int i, addr_len, option;
-	void *ioaddr;
+	void __iomem *ioaddr;
 	static int board_idx = -1;
 	u8 pci_rev;
 
@@ -981,7 +985,7 @@
 	assert (dev != NULL);
 	tp = netdev_priv(dev);
 
-	ioaddr = tp->mmio_addr;
+	ioaddr = netdev_ioaddr(dev);
 	assert (ioaddr != NULL);
 
 	addr_len = read_eeprom (ioaddr, 0, 8) == 0x8129 ? 8 : 6;
@@ -1018,7 +1022,6 @@
 
 	/* note: tp->chipset set in rtl8139_init_board */
 	tp->drv_flags = board_info[ent->driver_data].hw_flags;
-	tp->mmio_addr = ioaddr;
 	tp->msg_enable =
 		(debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1));
 	spin_lock_init (&tp->lock);
@@ -1150,11 +1153,11 @@
 #define EE_READ_CMD		(6)
 #define EE_ERASE_CMD	(7)
 
-static int __devinit read_eeprom (void *ioaddr, int location, int addr_len)
+static int __devinit read_eeprom (void __iomem *ioaddr, int location, int addr_len)
 {
 	int i;
 	unsigned retval = 0;
-	void *ee_addr = ioaddr + Cfg9346;
+	void __iomem * ee_addr = ioaddr + Cfg9346;
 	int read_cmd = location | (EE_READ_CMD << addr_len);
 
 	writeb (EE_ENB & ~EE_CS, ee_addr);
@@ -1219,7 +1222,7 @@
 
 #ifdef CONFIG_8139TOO_8129
 /* Syncronize the MII management interface by shifting 32 one bits out. */
-static void mdio_sync (void *mdio_addr)
+static void mdio_sync (void __iomem *mdio_addr)
 {
 	int i;
 
@@ -1234,17 +1237,17 @@
 
 static int mdio_read (struct net_device *dev, int phy_id, int location)
 {
-	struct rtl8139_private *tp = netdev_priv(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int retval = 0;
 #ifdef CONFIG_8139TOO_8129
-	void *mdio_addr = tp->mmio_addr + Config4;
+	void __iomem * mdio_addr = ioaddr + Config4;
 	int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location;
 	int i;
 #endif
 
 	if (phy_id > 31) {	/* Really a 8139.  Use internal registers. */
 		return location < 8 && mii_2_8139_map[location] ?
-		    readw (tp->mmio_addr + mii_2_8139_map[location]) : 0;
+		    readw (ioaddr + mii_2_8139_map[location]) : 0;
 	}
 
 #ifdef CONFIG_8139TOO_8129
@@ -1276,15 +1279,14 @@
 static void mdio_write (struct net_device *dev, int phy_id, int location,
 			int value)
 {
-	struct rtl8139_private *tp = netdev_priv(dev);
 #ifdef CONFIG_8139TOO_8129
-	void *mdio_addr = tp->mmio_addr + Config4;
+	void __iomem *mdio_addr = netdev_ioaddr(dev) + Config4;
 	int mii_cmd = (0x5002 << 16) | (phy_id << 23) | (location << 18) | value;
 	int i;
 #endif
 
 	if (phy_id > 31) {	/* Really a 8139.  Use internal registers. */
-		void *ioaddr = tp->mmio_addr;
+		void __iomem *ioaddr = netdev_ioaddr(dev);
 		if (location == 0) {
 			RTL_W8 (Cfg9346, Cfg9346_Unlock);
 			RTL_W16 (BasicModeCtrl, value);
@@ -1321,7 +1323,7 @@
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
 	int retval;
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	retval = request_irq (dev->irq, rtl8139_interrupt, SA_SHIRQ, dev->name, dev);
 	if (retval)
@@ -1378,7 +1380,7 @@
 static void rtl8139_hw_start (struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	u32 i;
 	u8 tmp;
 
@@ -1480,7 +1482,7 @@
 				  struct rtl8139_private *tp)
 {
 	int linkcase;
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	/* This is a complicated state machine to configure the "twister" for
 	   impedance/echos based on the cable length.
@@ -1564,7 +1566,7 @@
 
 static inline void rtl8139_thread_iter (struct net_device *dev,
 				 struct rtl8139_private *tp,
-				 void *ioaddr)
+				 void __iomem *ioaddr)
 {
 	int mii_lpa;
 
@@ -1634,7 +1636,7 @@
 			break;
 
 		rtnl_lock ();
-		rtl8139_thread_iter (dev, tp, tp->mmio_addr);
+		rtl8139_thread_iter (dev, tp, netdev_ioaddr(dev));
 		rtnl_unlock ();
 	}
 
@@ -1672,7 +1674,7 @@
 static void rtl8139_tx_timeout (struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int i;
 	u8 tmp8;
 	unsigned long flags;
@@ -1717,7 +1719,7 @@
 static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	unsigned int entry;
 	unsigned int len = skb->len;
 
@@ -1759,7 +1761,7 @@
 
 static void rtl8139_tx_interrupt (struct net_device *dev,
 				  struct rtl8139_private *tp,
-				  void *ioaddr)
+				  void __iomem *ioaddr)
 {
 	unsigned long dirty_tx, tx_left;
 
@@ -1829,7 +1831,7 @@
 
 /* TODO: clean this up!  Rx reset need not be this intensive */
 static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
-			    struct rtl8139_private *tp, void *ioaddr)
+			    struct rtl8139_private *tp, void __iomem *ioaddr)
 {
 	u8 tmp8;
 #ifdef CONFIG_8139_OLD_RX_RESET
@@ -1924,9 +1926,10 @@
 }
 #endif
 
-static void rtl8139_isr_ack(struct rtl8139_private *tp)
+static void rtl8139_isr_ack(struct net_device *dev)
 {
-	void *ioaddr = tp->mmio_addr;
+	struct rtl8139_private *tp = netdev_priv(dev);
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	u16 status;
 
 	status = RTL_R16 (IntrStatus) & RxAckBits;
@@ -1945,7 +1948,7 @@
 static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
 		      int budget)
 {
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int received = 0;
 	unsigned char *rx_ring = tp->rx_ring;
 	unsigned int cur_rx = tp->cur_rx;
@@ -2054,11 +2057,11 @@
 		cur_rx = (cur_rx + rx_size + 4 + 3) & ~3;
 		RTL_W16 (RxBufPtr, (u16) (cur_rx - 16));
 
-		rtl8139_isr_ack(tp);
+		rtl8139_isr_ack(dev);
 	}
 
 	if (unlikely(!received || rx_size == 0xfff0))
-		rtl8139_isr_ack(tp);
+		rtl8139_isr_ack(dev);
 
 #if RTL8139_DEBUG > 1
 	DPRINTK ("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x,"
@@ -2083,7 +2086,7 @@
 
 static void rtl8139_weird_interrupt (struct net_device *dev,
 				     struct rtl8139_private *tp,
-				     void *ioaddr,
+				     void __iomem *ioaddr,
 				     int status, int link_changed)
 {
 	DPRINTK ("%s: Abnormal interrupt, status %8.8x.\n",
@@ -2123,7 +2126,7 @@
 static int rtl8139_poll(struct net_device *dev, int *budget)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int orig_budget = min(*budget, dev->quota);
 	int done = 1;
 
@@ -2159,9 +2162,9 @@
 static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
 			       struct pt_regs *regs)
 {
-	struct net_device *dev = (struct net_device *) dev_instance;
+	struct net_device *dev = dev_instance;
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	u16 status, ackstat;
 	int link_changed = 0; /* avoid bogus "uninit" warning */
 	int handled = 0;
@@ -2237,7 +2240,7 @@
 static int rtl8139_close (struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	int ret = 0;
 	unsigned long flags;
 
@@ -2300,7 +2303,7 @@
 static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct rtl8139_private *np = netdev_priv(dev);
-	void *ioaddr = np->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 
 	spin_lock_irq(&np->lock);
 	if (rtl_chip_info[np->chipset].flags & HasLWake) {
@@ -2334,7 +2337,7 @@
 static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct rtl8139_private *np = netdev_priv(dev);
-	void *ioaddr = np->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	u32 support;
 	u8 cfg3, cfg5;
 
@@ -2441,7 +2444,7 @@
 	regs->version = RTL_REGS_VER;
 
 	spin_lock_irq(&np->lock);
-	memcpy_fromio(regbuf, np->mmio_addr, regs->len);
+	memcpy_fromio(regbuf, netdev_ioaddr(dev), regs->len);
 	spin_unlock_irq(&np->lock);
 }
 #endif /* CONFIG_8139TOO_MMIO */
@@ -2502,7 +2505,7 @@
 static struct net_device_stats *rtl8139_get_stats (struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	unsigned long flags;
 
 	if (netif_running(dev)) {
@@ -2521,7 +2524,7 @@
 static void __set_rx_mode (struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	u32 mc_filter[2];	/* Multicast hash filter */
 	int i, rx_mode;
 	u32 tmp;
@@ -2582,7 +2585,7 @@
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
 	struct rtl8139_private *tp = netdev_priv(dev);
-	void *ioaddr = tp->mmio_addr;
+	void __iomem *ioaddr = netdev_ioaddr(dev);
 	unsigned long flags;
 
 	pci_save_state (pdev);




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC][PATCH 0/3] net: generic netdev_ioaddr
  2004-10-29 10:04 [RFC][PATCH 0/3] net: generic netdev_ioaddr Pekka Enberg
  2004-10-29 10:04 ` [PATCH 1/3] " Pekka Enberg
@ 2004-10-29 11:52 ` Christoph Hellwig
  2004-10-29 13:16 ` Al Viro
  2 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2004-10-29 11:52 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: davem, netdev, linux-kernel

On Fri, Oct 29, 2004 at 01:04:04PM +0300, Pekka Enberg wrote:
> Hi,
> 
> This patch introduces a generic netdev_ioaddr and converts natsemi and
> 8139too drivers to use it.
> 
> With the recent __iomem annotations, the network drivers need to either
> invent this wrapper (like natsemi has done) or duplicate the IO base
> address in their private data (similar to 8139too).  Therefore, lets
> make netdev_ioaddr generic before it is all over the place.

This casting around sounds like a bad idea.  Either add another

	void __iomem *mmioaddr;

member to struct net_device, or better move that completely into the
driver-private structure which seems the better level of abstraction.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [RFC][PATCH 0/3] net: generic netdev_ioaddr
  2004-10-29 10:04 [RFC][PATCH 0/3] net: generic netdev_ioaddr Pekka Enberg
  2004-10-29 10:04 ` [PATCH 1/3] " Pekka Enberg
  2004-10-29 11:52 ` [RFC][PATCH 0/3] net: generic netdev_ioaddr Christoph Hellwig
@ 2004-10-29 13:16 ` Al Viro
  2004-10-29 18:50   ` Pekka J Enberg
  2004-10-29 20:01   ` [PATCH] net: fix natsemi base_addr casting Pekka Enberg
  2 siblings, 2 replies; 16+ messages in thread
From: Al Viro @ 2004-10-29 13:16 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: davem, netdev, linux-kernel

On Fri, Oct 29, 2004 at 01:04:04PM +0300, Pekka Enberg wrote:
> Hi,
> 
> This patch introduces a generic netdev_ioaddr and converts natsemi and
> 8139too drivers to use it.
> 
> With the recent __iomem annotations, the network drivers need to either
> invent this wrapper (like natsemi has done) or duplicate the IO base
> address in their private data (similar to 8139too).  Therefore, lets
> make netdev_ioaddr generic before it is all over the place.

NAK.  ->base_addr casting is a Bad Idea(tm) and natsemi "solution" isn't
(thanks for spotting that crap in natsemi, though; will fix...)

Note that there is no such thing as "generic IO base address" - it _is_
private and in the best case current ->base_addr is a scratch register
probably used for something vaguely connected with some IO, but it's
really up to driver...

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-29 13:16 ` Al Viro
@ 2004-10-29 18:50   ` Pekka J Enberg
  2004-10-29 19:18     ` Krzysztof Halasa
  2004-10-29 20:01   ` [PATCH] net: fix natsemi base_addr casting Pekka Enberg
  1 sibling, 1 reply; 16+ messages in thread
From: Pekka J Enberg @ 2004-10-29 18:50 UTC (permalink / raw)
  To: Al Viro; +Cc: davem, netdev, linux-kernel

Hi, 

Al Viro writes:
> NAK.  ->base_addr casting is a Bad Idea(tm) and natsemi "solution" isn't
> (thanks for spotting that crap in natsemi, though; will fix...) 
> 
> Note that there is no such thing as "generic IO base address" - it _is_
> private and in the best case current ->base_addr is a scratch register
> probably used for something vaguely connected with some IO, but it's
> really up to driver...

Yup, I thought about that after I sent the patch. However, as it stands now, 
many network drivers use netdev->base_addr for just that.  Perhaps it should 
be nuked completely instead? 

            Pekka 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-29 18:50   ` Pekka J Enberg
@ 2004-10-29 19:18     ` Krzysztof Halasa
  2004-10-29 19:38       ` Al Viro
  0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Halasa @ 2004-10-29 19:18 UTC (permalink / raw)
  To: Pekka J Enberg; +Cc: Al Viro, davem, netdev, linux-kernel

"Pekka J Enberg" <penberg@cs.helsinki.fi> writes:

> Yup, I thought about that after I sent the patch. However, as it
> stands now, many network drivers use netdev->base_addr for just that.
> Perhaps it should be nuked completely instead?

I thinks so. With ifmap, SIOCSIFMAP, ifr_map, mem_end etc.,
irq, if_port, dma.
-- 
Krzysztof Halasa

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-29 19:18     ` Krzysztof Halasa
@ 2004-10-29 19:38       ` Al Viro
  2004-10-29 21:13         ` Krzysztof Halasa
  0 siblings, 1 reply; 16+ messages in thread
From: Al Viro @ 2004-10-29 19:38 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: Pekka J Enberg, davem, netdev, linux-kernel

On Fri, Oct 29, 2004 at 09:18:18PM +0200, Krzysztof Halasa wrote:
> "Pekka J Enberg" <penberg@cs.helsinki.fi> writes:
> 
> > Yup, I thought about that after I sent the patch. However, as it
> > stands now, many network drivers use netdev->base_addr for just that.
> > Perhaps it should be nuked completely instead?
> 
> I thinks so. With ifmap, SIOCSIFMAP, ifr_map, mem_end etc.,
> irq, if_port, dma.

SIOCSIFMAP is unfortunate, but legitimate - it passes more or less
opaque structure to driver and lets driver interpret it.

SIOCGIFMAP, OTOH, is really bad - among other things, for many drivers
it leaks ioremapped addresses to userland.  And *that* is a LARTable
offense - it's an information that makes no sense whatsoever for userland
code and should never be exposed, just as with any kernel pointers.

What uses ->base_addr from the data returned by SIOCGIFMAP?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] net: fix natsemi base_addr casting
  2004-10-29 13:16 ` Al Viro
  2004-10-29 18:50   ` Pekka J Enberg
@ 2004-10-29 20:01   ` Pekka Enberg
  1 sibling, 0 replies; 16+ messages in thread
From: Pekka Enberg @ 2004-10-29 20:01 UTC (permalink / raw)
  To: Al Viro; +Cc: davem, netdev, linux-kernel, hch

Hi,

This patch adds a mmioaddr field with proper void __iomem* type to
netdev_private struct and removes the ns_ioaddr function that messes around
with netdev->base_addr.

I tested this with actual hardware.  The code also passes sparse checks.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 natsemi.c |   83 +++++++++++++++++++++++++++++++-------------------------------
 1 files changed, 42 insertions(+), 41 deletions(-)

Index: 2.6.10-rc1-mm1/drivers/net/natsemi.c
===================================================================
--- 2.6.10-rc1-mm1.orig/drivers/net/natsemi.c	2004-10-29 22:03:06.000000000 +0300
+++ 2.6.10-rc1-mm1/drivers/net/natsemi.c	2004-10-29 22:47:09.000000000 +0300
@@ -668,6 +668,7 @@
 };
 
 struct netdev_private {
+	void __iomem *mmioaddr;
 	/* Descriptor rings first for alignment */
 	dma_addr_t ring_dma;
 	struct netdev_desc *rx_ring;
@@ -770,15 +771,10 @@
 static int netdev_get_eeprom(struct net_device *dev, u8 *buf);
 static struct ethtool_ops ethtool_ops;
 
-static inline void __iomem *ns_ioaddr(struct net_device *dev)
-{
-	return (void __iomem *) dev->base_addr;
-}
-
 static void move_int_phy(struct net_device *dev, int addr)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int target = 31;
 
 	/* 
@@ -867,11 +863,11 @@
 		prev_eedata = eedata;
 	}
 
-	dev->base_addr = (unsigned long __force) ioaddr;
 	dev->irq = irq;
 
 	np = netdev_priv(dev);
 
+	np->mmioaddr = ioaddr;
 	np->pci_dev = pdev;
 	pci_set_drvdata(pdev, dev);
 	np->iosize = iosize;
@@ -1073,7 +1069,8 @@
 static int mii_getbit (struct net_device *dev)
 {
 	int data;
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	writel(MII_ShiftClk, ioaddr + EECtrl);
 	data = readl(ioaddr + EECtrl);
@@ -1085,7 +1082,8 @@
 static void mii_send_bits (struct net_device *dev, u32 data, int len)
 {
 	u32 i;
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	for (i = (1 << (len-1)); i; i >>= 1)
 	{
@@ -1141,7 +1139,7 @@
 static int mdio_read(struct net_device *dev, int reg)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	/* The 83815 series has two ports:
 	 * - an internal transceiver
@@ -1156,7 +1154,7 @@
 static void mdio_write(struct net_device *dev, int reg, u16 data)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr; 
 
 	/* The 83815 series has an internal transceiver; handle separately */
 	if (dev->if_port == PORT_TP)
@@ -1168,7 +1166,7 @@
 static void init_phy_fixup(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int i;
 	u32 cfg;
 	u16 tmp;
@@ -1280,7 +1278,7 @@
 static int switch_port_external(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	u32 cfg;
 
 	cfg = readl(ioaddr + ChipConfig);
@@ -1313,7 +1311,7 @@
 static int switch_port_internal(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int i;
 	u32 cfg;
 	u16 bmcr;
@@ -1414,7 +1412,7 @@
 	u16 pmatch[3];
 	u16 sopass[3];
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	/*
 	 * Resetting the chip causes some registers to be lost.
@@ -1485,7 +1483,7 @@
 static void natsemi_reload_eeprom(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int i;
 
 	writel(EepromReload, ioaddr + PCIBusCfg);
@@ -1505,8 +1503,8 @@
 
 static void natsemi_stop_rxtx(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int i;
 
 	writel(RxOff | TxOff, ioaddr + ChipCmd);
@@ -1527,7 +1525,7 @@
 static int netdev_open(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int i;
 
 	/* Reset the chip, just in case. */
@@ -1576,7 +1574,7 @@
 static void do_cable_magic(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	if (dev->if_port != PORT_TP)
 		return;
@@ -1621,7 +1619,7 @@
 {
 	u16 data;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	if (dev->if_port != PORT_TP)
 		return;
@@ -1640,7 +1638,7 @@
 static void check_link(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int duplex;
 	u16 bmsr;
        
@@ -1701,7 +1699,7 @@
 static void init_registers(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	init_phy_fixup(dev);
 
@@ -1780,7 +1778,7 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int next_tick = 5*HZ;
 
 	if (netif_msg_timer(np)) {
@@ -1868,7 +1866,7 @@
 static void tx_timeout(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	disable_irq(dev->irq);
 	spin_lock_irq(&np->lock);
@@ -2068,7 +2066,7 @@
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	unsigned entry;
 
 	/* Note: Ordering is important here, set the field with the
@@ -2162,7 +2160,7 @@
 {
 	struct net_device *dev = dev_instance;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int boguscnt = max_interrupt_work;
 	unsigned int handled = 0;
 
@@ -2224,7 +2222,7 @@
 	int boguscnt = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 	s32 desc_status = le32_to_cpu(np->rx_head_desc->cmd_status);
 	unsigned int buflen = np->rx_buf_sz;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* If the driver owns the next entry it's a new packet. Send it up. */
 	while (desc_status < 0) { /* e.g. & DescOwn */
@@ -2312,7 +2310,7 @@
 static void netdev_error(struct net_device *dev, int intr_status)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	spin_lock(&np->lock);
 	if (intr_status & LinkChange) {
@@ -2371,8 +2369,8 @@
 
 static void __get_stats(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* The chip only need report frame silently dropped. */
 	np->stats.rx_crc_errors	+= readl(ioaddr + RxCRCErrs);
@@ -2404,8 +2402,8 @@
 #define HASH_TABLE	0x200
 static void __set_rx_mode(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u8 mc_filter[64]; /* Multicast hash filter */
 	u32 rx_mode;
 
@@ -2450,7 +2448,7 @@
 	/* synchronized against open : rtnl_lock() held by caller */
 	if (netif_running(dev)) {
 		struct netdev_private *np = netdev_priv(dev);
-		void __iomem * ioaddr = ns_ioaddr(dev);
+		void __iomem * ioaddr = np->mmioaddr;
 
 		disable_irq(dev->irq);
 		spin_lock(&np->lock);
@@ -2612,7 +2610,7 @@
 static int netdev_set_wol(struct net_device *dev, u32 newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u32 data = readl(ioaddr + WOLCmd) & ~WakeOptsSummary;
 
 	/* translate to bitmasks this chip understands */
@@ -2642,7 +2640,7 @@
 static int netdev_get_wol(struct net_device *dev, u32 *supported, u32 *cur)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u32 regval = readl(ioaddr + WOLCmd);
 
 	*supported = (WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST
@@ -2678,7 +2676,7 @@
 static int netdev_set_sopass(struct net_device *dev, u8 *newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u16 *sval = (u16 *)newval;
 	u32 addr;
 
@@ -2710,7 +2708,7 @@
 static int netdev_get_sopass(struct net_device *dev, u8 *data)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u16 *sval = (u16 *)data;
 	u32 addr;
 
@@ -2894,7 +2892,8 @@
 	int j;
 	u32 rfcr;
 	u32 *rbuf = (u32 *)buf;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* read non-mii page 0 of registers */
 	for (i = 0; i < NATSEMI_PG0_NREGS/2; i++) {
@@ -2944,7 +2943,8 @@
 {
 	int i;
 	u16 *ebuf = (u16 *)buf;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* eeprom_read reads 16 bits, and indexes by 16 bits */
 	for (i = 0; i < NATSEMI_EEPROM_SIZE/2; i++) {
@@ -3016,8 +3016,8 @@
 
 static void enable_wol_mode(struct net_device *dev, int enable_intr)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	if (netif_msg_wol(np))
 		printk(KERN_INFO "%s: remaining active for wake-on-lan\n",
@@ -3049,8 +3049,8 @@
 
 static int netdev_close(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	if (netif_msg_ifdown(np))
 		printk(KERN_DEBUG
@@ -3126,7 +3126,8 @@
 static void __devexit natsemi_remove1 (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	unregister_netdev (dev);
 	pci_release_regions (pdev);
@@ -3164,7 +3165,7 @@
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	rtnl_lock();
 	if (netif_running (dev)) {



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-29 19:38       ` Al Viro
@ 2004-10-29 21:13         ` Krzysztof Halasa
  2004-10-30  9:52           ` Pekka Enberg
  0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Halasa @ 2004-10-29 21:13 UTC (permalink / raw)
  To: Al Viro; +Cc: Pekka J Enberg, davem, netdev, linux-kernel

Al Viro <viro@parcelfarce.linux.theplanet.co.uk> writes:

> What uses ->base_addr from the data returned by SIOCGIFMAP?

ifconfig I think:

eth0      Link encap:Ethernet  HWaddr 00:50:BA:70:68:3E  
          inet addr:10.0.0.2  Bcast:10.0.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2796430 errors:1 dropped:0 overruns:0 frame:0
          TX packets:4056563 errors:3 dropped:0 overruns:0 carrier:3
          collisions:0 txqueuelen:1000 
          RX bytes:285233613 (272.0 Mb)  TX bytes:1252627624 (1194.5 Mb)
          Interrupt:10 Base address:0x4000 

With this driver it happens to be MMIO address.

I understand presenting this value to users might have some value:
it can help determine the physical port/card for a given netdev.
But it should be something like a description text set by the driver
(ie. containing PCI bus/device, or even ISA address for ISA non-PnP
card, possibly with other information).

It seems while some devices use SIOCGIFMAP (ie. by setting the fields
in netdev struct), support for SIOCSIFMAP doesn't make sense for most
hardware.

Drivers using SIOCSIFMAP (selecting media only?):
arch/cris/arch-v10/drivers/ethernet.c:    dev->set_config = e100_set_config;
drivers/net/au1000_eth.c:     dev->set_config = &au1000_set_config;
drivers/net/sis900.c: net_dev->set_config = &sis900_set_config;
drivers/net/arm/etherh.c:     dev->set_config         = etherh_set_config;
drivers/net/pcmcia/3c589_cs.c:    dev->set_config = &el3_config;
drivers/net/pcmcia/fmvj18x_cs.c:    dev->set_config = &fjn_config;
drivers/net/pcmcia/nmclan_cs.c:    dev->set_config = &mace_config;
drivers/net/pcmcia/pcnet_cs.c:    dev->set_config = &set_config;
drivers/net/pcmcia/smc91c92_cs.c:    dev->set_config = &s9k_config;
drivers/net/pcmcia/xirc2ps_cs.c:    dev->set_config = &do_config;
drivers/net/wan/sdla.c:       dev->set_config         = sdla_set_config;
drivers/net/wireless/ray_cs.c:    dev->set_config = &ray_dev_config;

I think I would mark this stuff obsolete, and remove when the drivers
are updated (if they need an update at all, they may support
ethtool/mii-tool already).
-- 
Krzysztof Halasa

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-29 21:13         ` Krzysztof Halasa
@ 2004-10-30  9:52           ` Pekka Enberg
  2004-10-31  1:02             ` Krzysztof Halasa
  0 siblings, 1 reply; 16+ messages in thread
From: Pekka Enberg @ 2004-10-30  9:52 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: Al Viro, davem, netdev, linux-kernel

Hi,

Al Viro <viro@parcelfarce.linux.theplanet.co.uk> writes:
> > What uses ->base_addr from the data returned by SIOCGIFMAP?

On Fri, 2004-10-29 at 23:13 +0200, Krzysztof Halasa wrote:
> 
> ifconfig I think:

[snip] 

> With this driver it happens to be MMIO address.
> 
> I understand presenting this value to users might have some value:
> it can help determine the physical port/card for a given netdev.
> But it should be something like a description text set by the driver
> (ie. containing PCI bus/device, or even ISA address for ISA non-PnP
> card, possibly with other information).

It seems that the user can also setup dev->base_addr with "netdev="
kernel parameter before a driver starts probing (for example
drivers/net/appletalk/cops.c). Should we get rid of "netdev=" too and
push preconfiguring down to the drivers that actually use it?

		Pekka


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-30  9:52           ` Pekka Enberg
@ 2004-10-31  1:02             ` Krzysztof Halasa
  2004-10-31  7:11               ` Pekka Enberg
  0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Halasa @ 2004-10-31  1:02 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Al Viro, davem, netdev, linux-kernel

Pekka Enberg <penberg@cs.helsinki.fi> writes:

>> With this driver it happens to be MMIO address.

Of course 0x4000 was an IO (non-MMIO) address.

> It seems that the user can also setup dev->base_addr with "netdev="
> kernel parameter before a driver starts probing (for example
> drivers/net/appletalk/cops.c). Should we get rid of "netdev=" too and
> push preconfiguring down to the drivers that actually use it?

Sure, cops.io= should be fine. Or cops.hw=io,irq,mem etc.

Still, this is an issue with non-PnP ISA cards only.
-- 
Krzysztof Halasa

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-31  1:02             ` Krzysztof Halasa
@ 2004-10-31  7:11               ` Pekka Enberg
  2004-10-31 23:14                 ` Krzysztof Halasa
  0 siblings, 1 reply; 16+ messages in thread
From: Pekka Enberg @ 2004-10-31  7:11 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: Al Viro, davem, netdev, linux-kernel

Hi,

On Sun, 2004-10-31 at 02:02 +0100, Krzysztof Halasa wrote:
> Sure, cops.io= should be fine. Or cops.hw=io,irq,mem etc.
> 
> Still, this is an issue with non-PnP ISA cards only.

Cops already exposes base address and irq as module parameters and yet
it calls netdev_boot_setup_check() to check "netdev=" so I assume
there's a reason for that.  Perhaps something like the (untested) patch
below would make more sense?

		Pekka

Index: 2.6.10-rc1-mm1/drivers/net/appletalk/cops.c
===================================================================
--- 2.6.10-rc1-mm1.orig/drivers/net/appletalk/cops.c	2004-10-31 08:56:31.487324160 +0200
+++ 2.6.10-rc1-mm1/drivers/net/appletalk/cops.c	2004-10-31 09:06:09.273487312 +0200
@@ -171,6 +171,8 @@
 
 struct cops_local
 {
+	unsigned long base_addr;
+	unsigned int irq;
         struct net_device_stats stats;
         int board;			/* Holds what board type is. */
 	int nodeid;			/* Set to 1 once have nodeid. */
@@ -205,20 +207,22 @@
 
 static void cleanup_card(struct net_device *dev)
 {
-	if (dev->irq)
-		free_irq(dev->irq, dev);
-	release_region(dev->base_addr, COPS_IO_EXTENT);
+	struct cops_local *lp = netdev_priv(dev);
+	if (lp->irq)
+		free_irq(lp->irq, dev);
+	release_region(lp->base_addr, COPS_IO_EXTENT);
 }
 
 /*
  *      Check for a network adaptor of this type, and return '0' iff one exists.
- *      If dev->base_addr == 0, probe all likely locations.
- *      If dev->base_addr in [1..0x1ff], always return failure.
+ *      If lp->base_addr == 0, probe all likely locations.
+ *      If lp->base_addr in [1..0x1ff], always return failure.
  *        otherwise go with what we pass in.
  */
 struct net_device * __init cops_probe(int unit)
 {
 	struct net_device *dev;
+	struct cops_local *lp;
 	unsigned *port;
 	int base_addr;
 	int err = 0;
@@ -227,13 +231,23 @@
 	if (!dev)
 		return ERR_PTR(-ENOMEM);
 
+	lp = netdev_priv(dev);
+
 	if (unit >= 0) {
+		struct ifmap *map;
+
+		base_addr = 0;
+		irq = 0;
+
 		sprintf(dev->name, "lt%d", unit);
-		netdev_boot_setup_check(dev);
-		irq = dev->irq;
-		base_addr = dev->base_addr;
+
+		map = netdev_boot_ifmap(dev->name);
+		if (map) {
+			irq = lp->irq = map->irq;
+			base_addr = lp->base_addr = map->base_addr;
+		}
 	} else {
-		base_addr = dev->base_addr = io;
+		base_addr = lp->base_addr = io;
 	}
 
 	SET_MODULE_OWNER(dev);
@@ -273,7 +287,7 @@
  */
 static int __init cops_probe1(struct net_device *dev, int ioaddr)
 {
-        struct cops_local *lp;
+        struct cops_local *lp = netdev_priv(dev);
 	static unsigned version_printed;
 	int board = board_type;
 	int retval;
@@ -292,13 +306,13 @@
          * interrupts are typically not reported by the boards, and we must
          * used AutoIRQ to find them.
 	 */
-	dev->irq = irq;
-	switch (dev->irq)
+	lp->irq = irq;
+	switch (lp->irq)
 	{
 		case 0:
 			/* COPS AutoIRQ routine */
-			dev->irq = cops_irq(ioaddr, board);
-			if (dev->irq)
+			lp->irq = cops_irq(ioaddr, board);
+			if (lp->irq)
 				break;
 			/* No IRQ found on this port, fallthrough */
 		case 1:
@@ -309,7 +323,7 @@
 		 * IRQ 9, or don't know which one to set.
 		 */
 		case 2:
-			dev->irq = 9;
+			lp->irq = 9;
 			break;
 
 		/* Polled operation requested. Although irq of zero passed as
@@ -317,7 +331,7 @@
 		 * overload it to denote polled operation at runtime.
 		 */
 		case 0xff:
-			dev->irq = 0;
+			lp->irq = 0;
 			break;
 
 		default:
@@ -325,16 +339,14 @@
 	}
 
 	/* Reserve any actual interrupt. */
-	if (dev->irq) {
-		retval = request_irq(dev->irq, &cops_interrupt, 0, dev->name, dev);
+	if (lp->irq) {
+		retval = request_irq(lp->irq, &cops_interrupt, 0, dev->name, dev);
 		if (retval)
 			goto err_out;
 	}
 
-	dev->base_addr = ioaddr;
+	lp->base_addr = ioaddr;
 
-        lp = netdev_priv(dev);
-        memset(lp, 0, sizeof(struct cops_local));
         spin_lock_init(&lp->lock);
 
 	/* Copy local board variable to lp struct. */
@@ -354,11 +366,11 @@
 	/* Tell the user where the card is and what mode we're in. */
 	if(board==DAYNA)
 		printk("%s: %s at %#3x, using IRQ %d, in Dayna mode.\n", 
-			dev->name, cardname, ioaddr, dev->irq);
+			dev->name, cardname, ioaddr, lp->irq);
 	if(board==TANGENT) {
-		if(dev->irq)
+		if(lp->irq)
 			printk("%s: %s at %#3x, IRQ %d, in Tangent mode\n", 
-				dev->name, cardname, ioaddr, dev->irq);
+				dev->name, cardname, ioaddr, lp->irq);
 		else
 			printk("%s: %s at %#3x, using polled IO, in Tangent mode.\n", 
 				dev->name, cardname, ioaddr);
@@ -424,7 +436,7 @@
 {
     struct cops_local *lp = netdev_priv(dev);
 
-	if(dev->irq==0)
+	if(lp->irq==0)
 	{
 		/*
 		 * I don't know if the Dayna-style boards support polled 
@@ -491,7 +503,7 @@
 static void cops_reset(struct net_device *dev, int sleep)
 {
         struct cops_local *lp = netdev_priv(dev);
-        int ioaddr=dev->base_addr;
+        int ioaddr=lp->base_addr;
 
         if(lp->board==TANGENT)
         {
@@ -526,7 +538,7 @@
         struct ifreq ifr;
         struct ltfirmware *ltf= (struct ltfirmware *)&ifr.ifr_ifru;
         struct cops_local *lp = netdev_priv(dev);
-        int ioaddr=dev->base_addr;
+        int ioaddr=lp->base_addr;
 	int length, i = 0;
 
         strcpy(ifr.ifr_name,"lt0");
@@ -619,7 +631,7 @@
 static int cops_nodeid (struct net_device *dev, int nodeid)
 {
 	struct cops_local *lp = netdev_priv(dev);
-	int ioaddr = dev->base_addr;
+	int ioaddr = lp->base_addr;
 
 	if(lp->board == DAYNA)
         {
@@ -695,13 +707,14 @@
 	int boguscount = 0;
 
 	struct net_device *dev = (struct net_device *)ltdev;
+	struct cops_local *lp = netdev_priv(dev);
 
 	del_timer(&cops_timer);
 
 	if(dev == NULL)
 		return;	/* We've been downed */
 
-	ioaddr = dev->base_addr;
+	ioaddr = lp->base_addr;
 	do {
 		status=inb(ioaddr+TANG_CARD_STATUS);
 		if(status & TANG_RX_READY)
@@ -725,12 +738,11 @@
 static irqreturn_t cops_interrupt(int irq, void *dev_id, struct pt_regs * regs)
 {
         struct net_device *dev = dev_id;
-        struct cops_local *lp;
+        struct cops_local *lp = netdev_priv(dev);
         int ioaddr, status;
         int boguscount = 0;
 
-        ioaddr = dev->base_addr;
-        lp = netdev_priv(dev);
+        ioaddr = lp->base_addr;
 
 	if(lp->board==DAYNA)
 	{
@@ -766,7 +778,7 @@
         int rsp_type = 0;
         struct sk_buff *skb = NULL;
         struct cops_local *lp = netdev_priv(dev);
-        int ioaddr = dev->base_addr;
+        int ioaddr = lp->base_addr;
         int boguscount = 0;
         unsigned long flags;
 
@@ -870,7 +882,7 @@
 static void cops_timeout(struct net_device *dev)
 {
         struct cops_local *lp = netdev_priv(dev);
-        int ioaddr = dev->base_addr;
+        int ioaddr = lp->base_addr;
 
 	lp->stats.tx_errors++;
         if(lp->board==TANGENT)
@@ -892,7 +904,7 @@
 static int cops_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
         struct cops_local *lp = netdev_priv(dev);
-        int ioaddr = dev->base_addr;
+        int ioaddr = lp->base_addr;
         unsigned long flags;
 
         /*
@@ -1006,7 +1018,7 @@
 
 	/* If we were running polled, yank the timer.
 	 */
-	if(lp->board==TANGENT && dev->irq==0)
+	if(lp->board==TANGENT && lp->irq==0)
 		del_timer(&cops_timer);
 
 	netif_stop_queue(dev);
Index: 2.6.10-rc1-mm1/include/linux/netdevice.h
===================================================================
--- 2.6.10-rc1-mm1.orig/include/linux/netdevice.h	2004-10-31 08:56:31.488324008 +0200
+++ 2.6.10-rc1-mm1/include/linux/netdevice.h	2004-10-31 08:57:41.706649200 +0200
@@ -523,7 +523,9 @@
 extern rwlock_t				dev_base_lock;		/* Device list lock */
 
 extern int			netdev_boot_setup_add(char *name, struct ifmap *map);
-extern int 			netdev_boot_setup_check(struct net_device *dev);
+/* use netdev_boot_ifmap instead */
+extern int __deprecated		netdev_boot_setup_check(struct net_device *dev);
+extern struct ifmap *		netdev_boot_ifmap(const char *name);
 extern unsigned long		netdev_boot_base(const char *prefix, int unit);
 extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
 extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
Index: 2.6.10-rc1-mm1/net/core/dev.c
===================================================================
--- 2.6.10-rc1-mm1.orig/net/core/dev.c	2004-10-31 08:56:31.490323704 +0200
+++ 2.6.10-rc1-mm1/net/core/dev.c	2004-10-31 08:56:49.355607768 +0200
@@ -408,6 +408,32 @@
 
 
 /**
+ *	netdev_boot_ifmap	- return boot time settings
+ *	@name: the netdevice name
+ *
+ * 	Check boot time settings for the device.
+ *	The found settings are set for the device to be used
+ *	later in the device probing.
+ *	Returns NULL if no settings found, pointer to struct ifmap if they are.
+ */
+struct ifmap *netdev_boot_ifmap(const char *name)
+{
+	struct netdev_boot_setup *s = dev_boot_setup;
+	struct ifmap *ret = NULL;
+	int i;
+
+	for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
+		if (s[i].name[0] != '\0' && s[i].name[0] != ' ' &&
+		    !strncmp(name, s[i].name, strlen(s[i].name))) {
+			ret = &s[i].map;
+			break;
+		}
+	}
+	return ret;
+}
+
+
+/**
  *	netdev_boot_base	- get address from boot time settings
  *	@prefix: prefix for network device
  *	@unit: id for network device
@@ -3265,6 +3291,7 @@
 EXPORT_SYMBOL(dev_set_mtu);
 EXPORT_SYMBOL(free_netdev);
 EXPORT_SYMBOL(netdev_boot_setup_check);
+EXPORT_SYMBOL(netdev_boot_ifmap);
 EXPORT_SYMBOL(netdev_set_master);
 EXPORT_SYMBOL(netdev_state_change);
 EXPORT_SYMBOL(netif_receive_skb);



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-31  7:11               ` Pekka Enberg
@ 2004-10-31 23:14                 ` Krzysztof Halasa
  2004-11-01 14:27                   ` Pekka Enberg
  0 siblings, 1 reply; 16+ messages in thread
From: Krzysztof Halasa @ 2004-10-31 23:14 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Al Viro, davem, netdev, linux-kernel

Hi,

Pekka Enberg <penberg@cs.helsinki.fi> writes:

> Cops already exposes base address and irq as module parameters and yet
> it calls netdev_boot_setup_check() to check "netdev=" so I assume
> there's a reason for that.  Perhaps something like the (untested) patch
> below would make more sense?

IMHO partially: base_addr etc should go from the core (to driver's
local structs if needed). I think no general netdev-setup thing is
needed, we have module parameters and library functions.

No ioctl for such things is needed either.
/sbin/ifconfig shouldn't mess with hardware data such as I/O address,
IRQ etc. - it should be a configuration tool for software protocols,
not for hardware (i.e. as /sbin/ip is).

My opinion of course.
-- 
Krzysztof Halasa

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: net: generic netdev_ioaddr
  2004-10-31 23:14                 ` Krzysztof Halasa
@ 2004-11-01 14:27                   ` Pekka Enberg
  0 siblings, 0 replies; 16+ messages in thread
From: Pekka Enberg @ 2004-11-01 14:27 UTC (permalink / raw)
  To: Krzysztof Halasa; +Cc: Al Viro, davem, netdev, linux-kernel

Hi,

On Mon, 2004-11-01 at 00:14 +0100, Krzysztof Halasa wrote:
> IMHO partially: base_addr etc should go from the core (to driver's
> local structs if needed). I think no general netdev-setup thing is
> needed, we have module parameters and library functions.
> 
> No ioctl for such things is needed either.
> /sbin/ifconfig shouldn't mess with hardware data such as I/O address,
> IRQ etc. - it should be a configuration tool for software protocols,
> not for hardware (i.e. as /sbin/ip is).
> 
> My opinion of course.

FWIW I am running this patch on my box.  ifconfig doesn't mind but I am
not sure about the rtnetlink part.  I can start stabbing other drivers
if the maintainers are interested in this cleanup...

		Pekka

---

 drivers/net/Space.c       |   23 ++-----
 drivers/net/natsemi.c     |  134 +++++++++++++++++++++----------------------
 include/linux/netdevice.h |   12 ---
 net/core/dev.c            |  141 ----------------------------------------------
 net/core/rtnetlink.c      |   12 ---
 net/ethernet/eth.c        |    4 -
 6 files changed, 74 insertions(+), 252 deletions(-)

Index: 2.6.10-rc1-mm1/drivers/net/Space.c
===================================================================
--- 2.6.10-rc1-mm1.orig/drivers/net/Space.c	2004-11-01 16:11:34.682350032 +0200
+++ 2.6.10-rc1-mm1/drivers/net/Space.c	2004-11-01 16:12:31.554704120 +0200
@@ -322,17 +322,12 @@
  
 static void __init ethif_probe2(int unit)
 {
-	unsigned long base_addr = netdev_boot_base("eth", unit);
-
-	if (base_addr == 1)
-		return;
-
-	(void)(	probe_list2(unit, m68k_probes, base_addr == 0) &&
-		probe_list2(unit, mips_probes, base_addr == 0) &&
-		probe_list2(unit, eisa_probes, base_addr == 0) &&
-		probe_list2(unit, mca_probes, base_addr == 0) &&
-		probe_list2(unit, isa_probes, base_addr == 0) &&
-		probe_list2(unit, parport_probes, base_addr == 0));
+	(void)(	probe_list2(unit, m68k_probes, 1) &&
+		probe_list2(unit, mips_probes, 1) &&
+		probe_list2(unit, eisa_probes, 1) &&
+		probe_list2(unit, mca_probes, 1) &&
+		probe_list2(unit, isa_probes, 1) &&
+		probe_list2(unit, parport_probes, 1));
 }
 
 #ifdef CONFIG_TR
@@ -374,11 +369,7 @@
 
 static void __init trif_probe2(int unit)
 {
-	unsigned long base_addr = netdev_boot_base("tr", unit);
-
-	if (base_addr == 1)
-		return;
-	probe_list2(unit, tr_probes2, base_addr == 0);
+	probe_list2(unit, tr_probes2, 1);
 }
 #endif
 
Index: 2.6.10-rc1-mm1/drivers/net/natsemi.c
===================================================================
--- 2.6.10-rc1-mm1.orig/drivers/net/natsemi.c	2004-11-01 16:11:33.217572712 +0200
+++ 2.6.10-rc1-mm1/drivers/net/natsemi.c	2004-11-01 16:12:31.700681928 +0200
@@ -327,7 +327,7 @@
 is set, then access is permitted under spin_lock_irq(&np->lock).
 
 Thus configuration functions that want to access everything must call
-	disable_irq(dev->irq);
+	disable_irq(np->irq);
 	spin_lock_bh(dev->xmit_lock);
 	spin_lock_irq(&np->lock);
 
@@ -349,7 +349,7 @@
 
 
 
-enum pcistuff {
+enum {
 	PCI_USES_IO = 0x01,
 	PCI_USES_MEM = 0x02,
 	PCI_USES_MASTER = 0x04,
@@ -668,6 +668,8 @@
 };
 
 struct netdev_private {
+	void __iomem *mmioaddr;
+	unsigned int irq;
 	/* Descriptor rings first for alignment */
 	dma_addr_t ring_dma;
 	struct netdev_desc *rx_ring;
@@ -770,15 +772,10 @@
 static int netdev_get_eeprom(struct net_device *dev, u8 *buf);
 static struct ethtool_ops ethtool_ops;
 
-static inline void __iomem *ns_ioaddr(struct net_device *dev)
-{
-	return (void __iomem *) dev->base_addr;
-}
-
 static void move_int_phy(struct net_device *dev, int addr)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int target = 31;
 
 	/* 
@@ -867,11 +864,11 @@
 		prev_eedata = eedata;
 	}
 
-	dev->base_addr = (unsigned long __force) ioaddr;
-	dev->irq = irq;
 
 	np = netdev_priv(dev);
 
+	np->mmioaddr = ioaddr;
+	np->irq = irq;
 	np->pci_dev = pdev;
 	pci_set_drvdata(pdev, dev);
 	np->iosize = iosize;
@@ -906,8 +903,6 @@
 	}
 
 	option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
-	if (dev->mem_start)
-		option = dev->mem_start;
 
 	/* The lower four bits are the media type. */
 	if (option) {
@@ -1073,7 +1068,8 @@
 static int mii_getbit (struct net_device *dev)
 {
 	int data;
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	writel(MII_ShiftClk, ioaddr + EECtrl);
 	data = readl(ioaddr + EECtrl);
@@ -1085,7 +1081,8 @@
 static void mii_send_bits (struct net_device *dev, u32 data, int len)
 {
 	u32 i;
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	for (i = (1 << (len-1)); i; i >>= 1)
 	{
@@ -1141,7 +1138,7 @@
 static int mdio_read(struct net_device *dev, int reg)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	/* The 83815 series has two ports:
 	 * - an internal transceiver
@@ -1156,7 +1153,7 @@
 static void mdio_write(struct net_device *dev, int reg, u16 data)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr; 
 
 	/* The 83815 series has an internal transceiver; handle separately */
 	if (dev->if_port == PORT_TP)
@@ -1168,7 +1165,7 @@
 static void init_phy_fixup(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int i;
 	u32 cfg;
 	u16 tmp;
@@ -1280,7 +1277,7 @@
 static int switch_port_external(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	u32 cfg;
 
 	cfg = readl(ioaddr + ChipConfig);
@@ -1313,7 +1310,7 @@
 static int switch_port_internal(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int i;
 	u32 cfg;
 	u16 bmcr;
@@ -1414,7 +1411,7 @@
 	u16 pmatch[3];
 	u16 sopass[3];
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	/*
 	 * Resetting the chip causes some registers to be lost.
@@ -1485,7 +1482,7 @@
 static void natsemi_reload_eeprom(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 	int i;
 
 	writel(EepromReload, ioaddr + PCIBusCfg);
@@ -1505,8 +1502,8 @@
 
 static void natsemi_stop_rxtx(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int i;
 
 	writel(RxOff | TxOff, ioaddr + ChipCmd);
@@ -1527,21 +1524,21 @@
 static int netdev_open(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int i;
 
 	/* Reset the chip, just in case. */
 	natsemi_reset(dev);
 
-	i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev);
+	i = request_irq(np->irq, &intr_handler, SA_SHIRQ, dev->name, dev);
 	if (i) return i;
 
 	if (netif_msg_ifup(np))
 		printk(KERN_DEBUG "%s: netdev_open() irq %d.\n",
-			dev->name, dev->irq);
+			dev->name, np->irq);
 	i = alloc_ring(dev);
 	if (i < 0) {
-		free_irq(dev->irq, dev);
+		free_irq(np->irq, dev);
 		return i;
 	}
 	init_ring(dev);
@@ -1576,7 +1573,7 @@
 static void do_cable_magic(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem *ioaddr = ns_ioaddr(dev);
+	void __iomem *ioaddr = np->mmioaddr;
 
 	if (dev->if_port != PORT_TP)
 		return;
@@ -1621,7 +1618,7 @@
 {
 	u16 data;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	if (dev->if_port != PORT_TP)
 		return;
@@ -1640,7 +1637,7 @@
 static void check_link(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int duplex;
 	u16 bmsr;
        
@@ -1701,7 +1698,7 @@
 static void init_registers(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	init_phy_fixup(dev);
 
@@ -1780,7 +1777,7 @@
 {
 	struct net_device *dev = (struct net_device *)data;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int next_tick = 5*HZ;
 
 	if (netif_msg_timer(np)) {
@@ -1805,14 +1802,14 @@
 				if (netif_msg_hw(np))
 					printk(KERN_NOTICE "%s: possible phy reset: "
 						"re-initializing\n", dev->name);
-				disable_irq(dev->irq);
+				disable_irq(np->irq);
 				spin_lock_irq(&np->lock);
 				natsemi_stop_rxtx(dev);
 				dump_ring(dev);
 				reinit_ring(dev);
 				init_registers(dev);
 				spin_unlock_irq(&np->lock);
-				enable_irq(dev->irq);
+				enable_irq(np->irq);
 			} else {
 				/* hurry back */
 				next_tick = HZ;
@@ -1829,10 +1826,10 @@
 		spin_unlock_irq(&np->lock);
 	}
 	if (np->oom) {
-		disable_irq(dev->irq);
+		disable_irq(np->irq);
 		np->oom = 0;
 		refill_rx(dev);
-		enable_irq(dev->irq);
+		enable_irq(np->irq);
 		if (!np->oom) {
 			writel(RxOn, ioaddr + ChipCmd);
 		} else {
@@ -1868,9 +1865,9 @@
 static void tx_timeout(struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
-	disable_irq(dev->irq);
+	disable_irq(np->irq);
 	spin_lock_irq(&np->lock);
 	if (!np->hands_off) {
 		if (netif_msg_tx_err(np))
@@ -1889,7 +1886,7 @@
 			dev->name);
 	}
 	spin_unlock_irq(&np->lock);
-	enable_irq(dev->irq);
+	enable_irq(np->irq);
 
 	dev->trans_start = jiffies;
 	np->stats.tx_errors++;
@@ -2068,7 +2065,7 @@
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	unsigned entry;
 
 	/* Note: Ordering is important here, set the field with the
@@ -2162,7 +2159,7 @@
 {
 	struct net_device *dev = dev_instance;
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	int boguscnt = max_interrupt_work;
 	unsigned int handled = 0;
 
@@ -2224,7 +2221,7 @@
 	int boguscnt = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 	s32 desc_status = le32_to_cpu(np->rx_head_desc->cmd_status);
 	unsigned int buflen = np->rx_buf_sz;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* If the driver owns the next entry it's a new packet. Send it up. */
 	while (desc_status < 0) { /* e.g. & DescOwn */
@@ -2312,7 +2309,7 @@
 static void netdev_error(struct net_device *dev, int intr_status)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	spin_lock(&np->lock);
 	if (intr_status & LinkChange) {
@@ -2371,8 +2368,8 @@
 
 static void __get_stats(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* The chip only need report frame silently dropped. */
 	np->stats.rx_crc_errors	+= readl(ioaddr + RxCRCErrs);
@@ -2395,17 +2392,17 @@
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void natsemi_poll_controller(struct net_device *dev)
 {
-	disable_irq(dev->irq);
-	intr_handler(dev->irq, dev, NULL);
-	enable_irq(dev->irq);
+	disable_irq(np->irq);
+	intr_handler(np->irq, dev, NULL);
+	enable_irq(np->irq);
 }
 #endif
 
 #define HASH_TABLE	0x200
 static void __set_rx_mode(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u8 mc_filter[64]; /* Multicast hash filter */
 	u32 rx_mode;
 
@@ -2450,9 +2447,9 @@
 	/* synchronized against open : rtnl_lock() held by caller */
 	if (netif_running(dev)) {
 		struct netdev_private *np = netdev_priv(dev);
-		void __iomem * ioaddr = ns_ioaddr(dev);
+		void __iomem * ioaddr = np->mmioaddr;
 
-		disable_irq(dev->irq);
+		disable_irq(np->irq);
 		spin_lock(&np->lock);
 		/* stop engines */
 		natsemi_stop_rxtx(dev);
@@ -2465,7 +2462,7 @@
 		/* restart engines */
 		writel(RxOn | TxOn, ioaddr + ChipCmd);
 		spin_unlock(&np->lock);
-		enable_irq(dev->irq);
+		enable_irq(np->irq);
 	}
 	return 0;
 }
@@ -2612,7 +2609,7 @@
 static int netdev_set_wol(struct net_device *dev, u32 newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u32 data = readl(ioaddr + WOLCmd) & ~WakeOptsSummary;
 
 	/* translate to bitmasks this chip understands */
@@ -2642,7 +2639,7 @@
 static int netdev_get_wol(struct net_device *dev, u32 *supported, u32 *cur)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u32 regval = readl(ioaddr + WOLCmd);
 
 	*supported = (WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST
@@ -2678,7 +2675,7 @@
 static int netdev_set_sopass(struct net_device *dev, u8 *newval)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u16 *sval = (u16 *)newval;
 	u32 addr;
 
@@ -2710,7 +2707,7 @@
 static int netdev_get_sopass(struct net_device *dev, u8 *data)
 {
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 	u16 *sval = (u16 *)data;
 	u32 addr;
 
@@ -2894,7 +2891,8 @@
 	int j;
 	u32 rfcr;
 	u32 *rbuf = (u32 *)buf;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* read non-mii page 0 of registers */
 	for (i = 0; i < NATSEMI_PG0_NREGS/2; i++) {
@@ -2944,7 +2942,8 @@
 {
 	int i;
 	u16 *ebuf = (u16 *)buf;
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	/* eeprom_read reads 16 bits, and indexes by 16 bits */
 	for (i = 0; i < NATSEMI_EEPROM_SIZE/2; i++) {
@@ -3016,8 +3015,8 @@
 
 static void enable_wol_mode(struct net_device *dev, int enable_intr)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	if (netif_msg_wol(np))
 		printk(KERN_INFO "%s: remaining active for wake-on-lan\n",
@@ -3049,8 +3048,8 @@
 
 static int netdev_close(struct net_device *dev)
 {
-	void __iomem * ioaddr = ns_ioaddr(dev);
 	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	if (netif_msg_ifdown(np))
 		printk(KERN_DEBUG
@@ -3070,16 +3069,16 @@
 	 */
 
 	del_timer_sync(&np->timer);
-	disable_irq(dev->irq);
+	disable_irq(np->irq);
 	spin_lock_irq(&np->lock);
 	/* Disable interrupts, and flush posted writes */
 	writel(0, ioaddr + IntrEnable);
 	readl(ioaddr + IntrEnable);
 	np->hands_off = 1;
 	spin_unlock_irq(&np->lock);
-	enable_irq(dev->irq);
+	enable_irq(np->irq);
 
-	free_irq(dev->irq, dev);
+	free_irq(np->irq, dev);
 
 	/* Interrupt disabled, interrupt handler released,
 	 * queue stopped, timer deleted, rtnl_lock held
@@ -3126,7 +3125,8 @@
 static void __devexit natsemi_remove1 (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	struct netdev_private *np = netdev_priv(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	unregister_netdev (dev);
 	pci_release_regions (pdev);
@@ -3164,13 +3164,13 @@
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
 	struct netdev_private *np = netdev_priv(dev);
-	void __iomem * ioaddr = ns_ioaddr(dev);
+	void __iomem * ioaddr = np->mmioaddr;
 
 	rtnl_lock();
 	if (netif_running (dev)) {
 		del_timer_sync(&np->timer);
 
-		disable_irq(dev->irq);
+		disable_irq(np->irq);
 		spin_lock_irq(&np->lock);
 
 		writel(0, ioaddr + IntrEnable);
@@ -3179,7 +3179,7 @@
 		netif_stop_queue(dev);
 
 		spin_unlock_irq(&np->lock);
-		enable_irq(dev->irq);
+		enable_irq(np->irq);
 
 		/* Update the error counts. */
 		__get_stats(dev);
@@ -3222,13 +3222,13 @@
 
 		natsemi_reset(dev);
 		init_ring(dev);
-		disable_irq(dev->irq);
+		disable_irq(np->irq);
 		spin_lock_irq(&np->lock);
 		np->hands_off = 0;
 		init_registers(dev);
 		netif_device_attach(dev);
 		spin_unlock_irq(&np->lock);
-		enable_irq(dev->irq);
+		enable_irq(np->irq);
 
 		mod_timer(&np->timer, jiffies + 1*HZ);
 	}
Index: 2.6.10-rc1-mm1/include/linux/netdevice.h
===================================================================
--- 2.6.10-rc1-mm1.orig/include/linux/netdevice.h	2004-11-01 16:11:34.683349880 +0200
+++ 2.6.10-rc1-mm1/include/linux/netdevice.h	2004-11-01 16:12:31.625693328 +0200
@@ -272,15 +272,6 @@
 	char			name[IFNAMSIZ];
 
 	/*
-	 *	I/O specific fields
-	 *	FIXME: Merge these and struct ifmap into one
-	 */
-	unsigned long		mem_end;	/* shared mem end	*/
-	unsigned long		mem_start;	/* shared mem start	*/
-	unsigned long		base_addr;	/* device I/O address	*/
-	unsigned int		irq;		/* device IRQ number	*/
-
-	/*
 	 *	Some hardware also needs these fields, but they are not
 	 *	part of the usual set specified in Space.c.
 	 */
@@ -522,9 +513,6 @@
 extern struct net_device		*dev_base;		/* All devices */
 extern rwlock_t				dev_base_lock;		/* Device list lock */
 
-extern int			netdev_boot_setup_add(char *name, struct ifmap *map);
-extern int 			netdev_boot_setup_check(struct net_device *dev);
-extern unsigned long		netdev_boot_base(const char *prefix, int unit);
 extern struct net_device    *dev_getbyhwaddr(unsigned short type, char *hwaddr);
 extern struct net_device *__dev_getfirstbyhwtype(unsigned short type);
 extern struct net_device *dev_getfirstbyhwtype(unsigned short type);
Index: 2.6.10-rc1-mm1/net/core/dev.c
===================================================================
--- 2.6.10-rc1-mm1.orig/net/core/dev.c	2004-11-01 16:11:35.376244544 +0200
+++ 2.6.10-rc1-mm1/net/core/dev.c	2004-11-01 16:12:31.559703360 +0200
@@ -343,129 +343,6 @@
 	synchronize_net();
 }
 
-/******************************************************************************
-
-		      Device Boot-time Settings Routines
-
-*******************************************************************************/
-
-/* Boot time configuration table */
-static struct netdev_boot_setup dev_boot_setup[NETDEV_BOOT_SETUP_MAX];
-
-/**
- *	netdev_boot_setup_add	- add new setup entry
- *	@name: name of the device
- *	@map: configured settings for the device
- *
- *	Adds new setup entry to the dev_boot_setup list.  The function
- *	returns 0 on error and 1 on success.  This is a generic routine to
- *	all netdevices.
- */
-int netdev_boot_setup_add(char *name, struct ifmap *map)
-{
-	struct netdev_boot_setup *s;
-	int i;
-
-	s = dev_boot_setup;
-	for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
-		if (s[i].name[0] == '\0' || s[i].name[0] == ' ') {
-			memset(s[i].name, 0, sizeof(s[i].name));
-			strcpy(s[i].name, name);
-			memcpy(&s[i].map, map, sizeof(s[i].map));
-			break;
-		}
-	}
-
-	return i >= NETDEV_BOOT_SETUP_MAX ? 0 : 1;
-}
-
-/**
- *	netdev_boot_setup_check	- check boot time settings
- *	@dev: the netdevice
- *
- * 	Check boot time settings for the device.
- *	The found settings are set for the device to be used
- *	later in the device probing.
- *	Returns 0 if no settings found, 1 if they are.
- */
-int netdev_boot_setup_check(struct net_device *dev)
-{
-	struct netdev_boot_setup *s = dev_boot_setup;
-	int i;
-
-	for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++) {
-		if (s[i].name[0] != '\0' && s[i].name[0] != ' ' &&
-		    !strncmp(dev->name, s[i].name, strlen(s[i].name))) {
-			dev->irq 	= s[i].map.irq;
-			dev->base_addr 	= s[i].map.base_addr;
-			dev->mem_start 	= s[i].map.mem_start;
-			dev->mem_end 	= s[i].map.mem_end;
-			return 1;
-		}
-	}
-	return 0;
-}
-
-
-/**
- *	netdev_boot_base	- get address from boot time settings
- *	@prefix: prefix for network device
- *	@unit: id for network device
- *
- * 	Check boot time settings for the base address of device.
- *	The found settings are set for the device to be used
- *	later in the device probing.
- *	Returns 0 if no settings found.
- */
-unsigned long netdev_boot_base(const char *prefix, int unit)
-{
-	const struct netdev_boot_setup *s = dev_boot_setup;
-	char name[IFNAMSIZ];
-	int i;
-
-	sprintf(name, "%s%d", prefix, unit);
-
-	/*
-	 * If device already registered then return base of 1
-	 * to indicate not to probe for this interface
-	 */
-	if (__dev_get_by_name(name))
-		return 1;
-
-	for (i = 0; i < NETDEV_BOOT_SETUP_MAX; i++)
-		if (!strcmp(name, s[i].name))
-			return s[i].map.base_addr;
-	return 0;
-}
-
-/*
- * Saves at boot time configured settings for any netdevice.
- */
-int __init netdev_boot_setup(char *str)
-{
-	int ints[5];
-	struct ifmap map;
-
-	str = get_options(str, ARRAY_SIZE(ints), ints);
-	if (!str || !*str)
-		return 0;
-
-	/* Save settings */
-	memset(&map, 0, sizeof(map));
-	if (ints[0] > 0)
-		map.irq = ints[1];
-	if (ints[0] > 1)
-		map.base_addr = ints[2];
-	if (ints[0] > 2)
-		map.mem_start = ints[3];
-	if (ints[0] > 3)
-		map.mem_end = ints[4];
-
-	/* Add new entry to the list */
-	return netdev_boot_setup_add(str, &map);
-}
-
-__setup("netdev=", netdev_boot_setup);
 
 /*******************************************************************************
 
@@ -2404,23 +2281,6 @@
 					    NETDEV_CHANGEADDR, dev);
 			return 0;
 
-		case SIOCGIFMAP:
-			ifr->ifr_map.mem_start = dev->mem_start;
-			ifr->ifr_map.mem_end   = dev->mem_end;
-			ifr->ifr_map.base_addr = dev->base_addr;
-			ifr->ifr_map.irq       = dev->irq;
-			ifr->ifr_map.dma       = dev->dma;
-			ifr->ifr_map.port      = dev->if_port;
-			return 0;
-
-		case SIOCSIFMAP:
-			if (dev->set_config) {
-				if (!netif_device_present(dev))
-					return -ENODEV;
-				return dev->set_config(dev, &ifr->ifr_map);
-			}
-			return -EOPNOTSUPP;
-
 		case SIOCADDMULTI:
 			if (!dev->set_multicast_list ||
 			    ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
@@ -3264,7 +3124,6 @@
 EXPORT_SYMBOL(dev_change_name);
 EXPORT_SYMBOL(dev_set_mtu);
 EXPORT_SYMBOL(free_netdev);
-EXPORT_SYMBOL(netdev_boot_setup_check);
 EXPORT_SYMBOL(netdev_set_master);
 EXPORT_SYMBOL(netdev_state_change);
 EXPORT_SYMBOL(netif_receive_skb);
Index: 2.6.10-rc1-mm1/net/core/rtnetlink.c
===================================================================
--- 2.6.10-rc1-mm1.orig/net/core/rtnetlink.c	2004-11-01 16:11:32.428692640 +0200
+++ 2.6.10-rc1-mm1/net/core/rtnetlink.c	2004-11-01 16:12:31.755673568 +0200
@@ -181,18 +181,6 @@
 		RTA_PUT(skb, IFLA_WEIGHT, sizeof(weight), &weight);
 	}
 
-	if (1) {
-		struct rtnl_link_ifmap map = {
-			.mem_start   = dev->mem_start,
-			.mem_end     = dev->mem_end,
-			.base_addr   = dev->base_addr,
-			.irq         = dev->irq,
-			.dma         = dev->dma,
-			.port        = dev->if_port,
-		};
-		RTA_PUT(skb, IFLA_MAP, sizeof(map), &map);
-	}
-
 	if (dev->addr_len) {
 		RTA_PUT(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr);
 		RTA_PUT(skb, IFLA_BROADCAST, dev->addr_len, dev->broadcast);
Index: 2.6.10-rc1-mm1/net/ethernet/eth.c
===================================================================
--- 2.6.10-rc1-mm1.orig/net/ethernet/eth.c	2004-11-01 16:11:34.687349272 +0200
+++ 2.6.10-rc1-mm1/net/ethernet/eth.c	2004-11-01 16:12:31.560703208 +0200
@@ -62,10 +62,6 @@
 #include <asm/system.h>
 #include <asm/checksum.h>
 
-extern int __init netdev_boot_setup(char *str);
-
-__setup("ether=", netdev_boot_setup);
-
 /*
  *	 Create the Ethernet MAC header for an arbitrary protocol layer 
  *



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-11-01 14:42 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-29 10:04 [RFC][PATCH 0/3] net: generic netdev_ioaddr Pekka Enberg
2004-10-29 10:04 ` [PATCH 1/3] " Pekka Enberg
2004-10-29 10:05   ` [PATCH 2/3] net: use netdev_ioaddr in natsemi Pekka Enberg
2004-10-29 10:05     ` [PATCH 3/3] net: use netdev_ioaddr in 8139too Pekka Enberg
2004-10-29 11:52 ` [RFC][PATCH 0/3] net: generic netdev_ioaddr Christoph Hellwig
2004-10-29 13:16 ` Al Viro
2004-10-29 18:50   ` Pekka J Enberg
2004-10-29 19:18     ` Krzysztof Halasa
2004-10-29 19:38       ` Al Viro
2004-10-29 21:13         ` Krzysztof Halasa
2004-10-30  9:52           ` Pekka Enberg
2004-10-31  1:02             ` Krzysztof Halasa
2004-10-31  7:11               ` Pekka Enberg
2004-10-31 23:14                 ` Krzysztof Halasa
2004-11-01 14:27                   ` Pekka Enberg
2004-10-29 20:01   ` [PATCH] net: fix natsemi base_addr casting Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).