Patchwork [37/42] synclink: convert devices to new API (rev2)

login
register
mail settings
Submitter stephen hemminger
Date Jan. 7, 2009, 11:48 p.m.
Message ID <20090107154835.37f4de4c@extreme>
Download mbox | patch
Permalink /patch/17262/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Jan. 7, 2009, 11:48 p.m.
Convert to net_device_ops and internal net_device_stats.
Remove unneeded last_rx update.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
 drivers/char/pcmcia/synclink_cs.c |   15 +++++++++------
 drivers/char/synclink.c           |   15 +++++++++------
 drivers/char/synclink_gt.c        |   15 +++++++++------
 drivers/char/synclinkmp.c         |   15 +++++++++------
 drivers/net/wan/hdlc.c            |   21 +++++----------------
 include/linux/hdlc.h              |    2 ++
 6 files changed, 43 insertions(+), 40 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 8, 2009, 2:08 a.m.
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Wed, 7 Jan 2009 15:48:35 -0800

> Convert to net_device_ops and internal net_device_stats.
> Remove unneeded last_rx update.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

I'm deferring this while you and Krzysztof work out how
to implement this properly.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Krzysztof Halasa - Jan. 8, 2009, 10:49 p.m.
David Miller <davem@davemloft.net> writes:

> I'm deferring this while you and Krzysztof work out how
> to implement this properly.

It seems it's ready. Tested with IXP4xx HSS against i686 + PCI200SYN.
X.25 not tested, as usual, but the remaining protocols seem to work.

I'll append the concatenated patch as well.

The following changes since commit 56cf391a9462a4897ea660a6af3662dda5ae8c84:
  Inaky Perez-Gonzalez (1):
        wimax: fix kernel-doc for debufs_dentry member of struct wimax_dev

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6.git for-david

me:
      WAN: Generic HDLC now uses IFF_WAN_HDLC private flag.
      WAN: Allow hw HDLC drivers to override dev->get_stats.
      Fix a comment in include/linux/netdevice.h.
      WAN: Convert generic HDLC drivers to netdev_ops.
      WAN: Fix NAPI interface in IXP4xx HSS driver.

 drivers/char/pcmcia/synclink_cs.c |   18 +++++++++++-------
 drivers/char/synclink.c           |   18 +++++++++++-------
 drivers/char/synclink_gt.c        |   18 +++++++++++-------
 drivers/char/synclinkmp.c         |   18 +++++++++++-------
 drivers/net/wan/c101.c            |   12 ++++++++----
 drivers/net/wan/cosa.c            |   14 ++++++++++----
 drivers/net/wan/dscc4.c           |   18 +++++++++++-------
 drivers/net/wan/farsync.c         |   18 ++++++++++++------
 drivers/net/wan/hdlc.c            |   29 ++++++++++++++---------------
 drivers/net/wan/hdlc_cisco.c      |    1 -
 drivers/net/wan/hdlc_fr.c         |   28 +++++++++-------------------
 drivers/net/wan/hdlc_ppp.c        |    2 --
 drivers/net/wan/hdlc_raw.c        |    3 ---
 drivers/net/wan/hdlc_raw_eth.c    |    8 ++------
 drivers/net/wan/hdlc_x25.c        |    2 +-
 drivers/net/wan/hostess_sv11.c    |   12 +++++++++---
 drivers/net/wan/ixp4xx_hss.c      |   18 ++++++++++++------
 drivers/net/wan/lmc/lmc_main.c    |   19 +++++++++++--------
 drivers/net/wan/lmc/lmc_proto.c   |   17 +----------------
 drivers/net/wan/n2.c              |   12 ++++++++----
 drivers/net/wan/pc300too.c        |   12 ++++++++----
 drivers/net/wan/pci200syn.c       |   12 ++++++++----
 drivers/net/wan/sealevel.c        |   12 +++++++++---
 drivers/net/wan/wanxl.c           |   14 ++++++++++----
 include/linux/hdlc.h              |    5 +++++
 include/linux/if.h                |    1 +
 include/linux/netdevice.h         |    2 +-
 27 files changed, 194 insertions(+), 149 deletions(-)
David Miller - Jan. 13, 2009, 12:18 a.m.
From: Krzysztof Halasa <khc@pm.waw.pl>
Date: Thu, 08 Jan 2009 23:49:37 +0100

>   git://git.kernel.org/pub/scm/linux/kernel/git/chris/linux-2.6.git for-david
> 
> me:
>       WAN: Generic HDLC now uses IFF_WAN_HDLC private flag.
>       WAN: Allow hw HDLC drivers to override dev->get_stats.
>       Fix a comment in include/linux/netdevice.h.
>       WAN: Convert generic HDLC drivers to netdev_ops.
>       WAN: Fix NAPI interface in IXP4xx HSS driver.

Krzysztof, I integrated these changes into my local tree.
Thanks a lot.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/drivers/char/pcmcia/synclink_cs.c	2009-01-07 15:26:51.830497659 -0800
+++ b/drivers/char/pcmcia/synclink_cs.c	2009-01-07 15:30:43.050748848 -0800
@@ -4311,10 +4311,16 @@  static void hdlcdev_rx(MGSLPC_INFO *info
 	dev->stats.rx_bytes += size;
 
 	netif_rx(skb);
-
-	dev->last_rx = jiffies;
 }
 
+static const struct net_device_ops hdlcdev_ops = {
+	.ndo_open       = hdlcdev_open,
+	.ndo_stop       = hdlcdev_close,
+	.ndo_change_mtu = hdlc_change_mtu,
+	.ndo_do_ioctl	= hdlcdev_ioctl,
+	.ndo_tx_timeout = hdlcdev_tx_timeout,
+};
+
 /**
  * called by device driver when adding device instance
  * do generic HDLC initialization
@@ -4341,10 +4347,7 @@  static int hdlcdev_init(MGSLPC_INFO *inf
 	dev->irq       = info->irq_level;
 
 	/* network layer callbacks and settings */
-	dev->do_ioctl       = hdlcdev_ioctl;
-	dev->open           = hdlcdev_open;
-	dev->stop           = hdlcdev_close;
-	dev->tx_timeout     = hdlcdev_tx_timeout;
+	dev->netdev_ops	    = &hdlcdev_ops;
 	dev->watchdog_timeo = 10*HZ;
 	dev->tx_queue_len   = 50;
 
--- a/drivers/char/synclink.c	2009-01-07 15:26:51.810496861 -0800
+++ b/drivers/char/synclink.c	2009-01-07 15:30:43.054747103 -0800
@@ -8007,10 +8007,16 @@  static void hdlcdev_rx(struct mgsl_struc
 	dev->stats.rx_bytes += size;
 
 	netif_rx(skb);
-
-	dev->last_rx = jiffies;
 }
 
+static const struct net_device_ops hdlcdev_ops = {
+	.ndo_open       = hdlcdev_open,
+	.ndo_stop       = hdlcdev_close,
+	.ndo_change_mtu = hdlc_change_mtu,
+	.ndo_do_ioctl	= hdlcdev_ioctl,
+	.ndo_tx_timeout = hdlcdev_tx_timeout,
+};
+
 /**
  * called by device driver when adding device instance
  * do generic HDLC initialization
@@ -8033,15 +8039,12 @@  static int hdlcdev_init(struct mgsl_stru
 	}
 
 	/* for network layer reporting purposes only */
+	dev->netdev_ops = &hdlcdev_ops;
 	dev->base_addr = info->io_base;
 	dev->irq       = info->irq_level;
 	dev->dma       = info->dma_level;
 
 	/* network layer callbacks and settings */
-	dev->do_ioctl       = hdlcdev_ioctl;
-	dev->open           = hdlcdev_open;
-	dev->stop           = hdlcdev_close;
-	dev->tx_timeout     = hdlcdev_tx_timeout;
 	dev->watchdog_timeo = 10*HZ;
 	dev->tx_queue_len   = 50;
 
--- a/drivers/char/synclink_gt.c	2009-01-07 15:26:51.798496911 -0800
+++ b/drivers/char/synclink_gt.c	2009-01-07 15:30:43.058746355 -0800
@@ -1766,10 +1766,16 @@  static void hdlcdev_rx(struct slgt_info 
 	dev->stats.rx_bytes += size;
 
 	netif_rx(skb);
-
-	dev->last_rx = jiffies;
 }
 
+static const struct net_device_ops hdlcdev_ops = {
+	.ndo_open       = hdlcdev_open,
+	.ndo_stop       = hdlcdev_close,
+	.ndo_change_mtu = hdlc_change_mtu,
+	.ndo_do_ioctl	= hdlcdev_ioctl,
+	.ndo_tx_timeout = hdlcdev_tx_timeout,
+};
+
 /**
  * called by device driver when adding device instance
  * do generic HDLC initialization
@@ -1797,10 +1803,7 @@  static int hdlcdev_init(struct slgt_info
 	dev->irq       = info->irq_level;
 
 	/* network layer callbacks and settings */
-	dev->do_ioctl       = hdlcdev_ioctl;
-	dev->open           = hdlcdev_open;
-	dev->stop           = hdlcdev_close;
-	dev->tx_timeout     = hdlcdev_tx_timeout;
+	dev->netdev_ops	    = &hdlcdev_ops;
 	dev->watchdog_timeo = 10*HZ;
 	dev->tx_queue_len   = 50;
 
--- a/drivers/char/synclinkmp.c	2009-01-07 15:26:51.818498600 -0800
+++ b/drivers/char/synclinkmp.c	2009-01-07 15:30:43.058746355 -0800
@@ -1907,10 +1907,16 @@  static void hdlcdev_rx(SLMP_INFO *info, 
 	dev->stats.rx_bytes += size;
 
 	netif_rx(skb);
-
-	dev->last_rx = jiffies;
 }
 
+static const struct net_device_ops hdlcdev_ops = {
+	.ndo_open       = hdlcdev_open,
+	.ndo_stop       = hdlcdev_close,
+	.ndo_change_mtu = hdlc_change_mtu,
+	.ndo_do_ioctl	= hdlcdev_ioctl,
+	.ndo_tx_timeout = hdlcdev_tx_timeout,
+};
+
 /**
  * called by device driver when adding device instance
  * do generic HDLC initialization
@@ -1938,10 +1944,7 @@  static int hdlcdev_init(SLMP_INFO *info)
 	dev->irq       = info->irq_level;
 
 	/* network layer callbacks and settings */
-	dev->do_ioctl       = hdlcdev_ioctl;
-	dev->open           = hdlcdev_open;
-	dev->stop           = hdlcdev_close;
-	dev->tx_timeout     = hdlcdev_tx_timeout;
+	dev->netdev_ops	    = &hdlcdev_ops;
 	dev->watchdog_timeo = 10*HZ;
 	dev->tx_queue_len   = 50;
 
--- a/drivers/net/wan/hdlc.c	2009-01-07 15:26:51.782497083 -0800
+++ b/drivers/net/wan/hdlc.c	2009-01-07 15:46:08.174365761 -0800
@@ -40,26 +40,20 @@ 
 
 static const char* version = "HDLC support module revision 1.22";
 
+static const struct header_ops hdlc_null_ops;
+
 #undef DEBUG_LINK
 
 static struct hdlc_proto *first_proto;
 
-static int hdlc_change_mtu(struct net_device *dev, int new_mtu)
+int hdlc_change_mtu(struct net_device *dev, int new_mtu)
 {
 	if ((new_mtu < 68) || (new_mtu > HDLC_MAX_MTU))
 		return -EINVAL;
 	dev->mtu = new_mtu;
 	return 0;
 }
-
-
-
-static struct net_device_stats *hdlc_get_stats(struct net_device *dev)
-{
-	return &dev->stats;
-}
-
-
+EXPORT_SYMBOL(hdlc_change_mtu);
 
 static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
 		    struct packet_type *p, struct net_device *orig_dev)
@@ -106,7 +100,7 @@  static int hdlc_device_event(struct noti
 	if (dev_net(dev) != &init_net)
 		return NOTIFY_DONE;
 
-	if (dev->get_stats != hdlc_get_stats)
+	if (dev->header_ops != &hdlc_null_ops)
 		return NOTIFY_DONE; /* not an HDLC device */
 
 	if (event != NETDEV_CHANGE)
@@ -226,22 +220,17 @@  int hdlc_ioctl(struct net_device *dev, s
 	return -EINVAL;
 }
 
-static const struct header_ops hdlc_null_ops;
-
 static void hdlc_setup_dev(struct net_device *dev)
 {
 	/* Re-init all variables changed by HDLC protocol drivers,
 	 * including ether_setup() called from hdlc_raw_eth.c.
 	 */
-	dev->get_stats		 = hdlc_get_stats;
 	dev->flags		 = IFF_POINTOPOINT | IFF_NOARP;
 	dev->mtu		 = HDLC_MAX_MTU;
 	dev->type		 = ARPHRD_RAWHDLC;
 	dev->hard_header_len	 = 16;
 	dev->addr_len		 = 0;
 	dev->header_ops		 = &hdlc_null_ops;
-
-	dev->change_mtu		 = hdlc_change_mtu;
 }
 
 static void hdlc_setup(struct net_device *dev)
--- a/include/linux/hdlc.h	2009-01-07 15:26:51.842497178 -0800
+++ b/include/linux/hdlc.h	2009-01-07 15:30:43.062746598 -0800
@@ -103,6 +103,8 @@  int hdlc_open(struct net_device *dev);
 /* Must be called by hardware driver when HDLC device is being closed */
 void hdlc_close(struct net_device *dev);
 
+int hdlc_change_mtu(struct net_device *dev, int new_mtu);
+
 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
 			 size_t size);
 /* May be used by hardware driver to gain control over HDLC device */