Re: [PATCH 01/77] atm: convert mpc device to using netdev_ops

Previous thread: [PATCH 37/77] pcmcia: convert fmvj18x driver to net_device_ops by Stephen Hemminger on Friday, March 20, 2009 - 10:36 pm. (2 messages)

Next thread: [PATCH 52/77] sbni: use internal net_device_stats by Stephen Hemminger on Friday, March 20, 2009 - 10:36 pm. (2 messages)
From: Stephen Hemminger
Date: Friday, March 20, 2009 - 10:35 pm

This converts the mpc device to using new netdevice_ops.
Compile tested only, needs more than usual review since
device was swaping pointers around etc.

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

---
 net/atm/mpc.c |   32 ++++++++++++++------------------
 net/atm/mpc.h |    5 ++++-
 2 files changed, 18 insertions(+), 19 deletions(-)

--- a/net/atm/mpc.c	2009-03-19 22:40:30.534964257 -0700
+++ b/net/atm/mpc.c	2009-03-19 22:42:40.038902168 -0700
@@ -286,33 +286,32 @@ static void start_mpc(struct mpoa_client
 {
 
 	dprintk("mpoa: (%s) start_mpc:\n", mpc->dev->name);
-	if (dev->hard_start_xmit == NULL) {
-		printk("mpoa: (%s) start_mpc: dev->hard_start_xmit == NULL, not starting\n",
-		       dev->name);
-		return;
+	if (!dev->netdev_ops)
+		printk("mpoa: (%s) start_mpc  not starting\n", dev->name);
+	else {
+		mpc->old_ops = dev->netdev_ops;
+		mpc->new_ops = *mpc->old_ops;
+		mpc->new_ops.ndo_start_xmit = mpc_send_packet;
+		dev->netdev_ops = &mpc->new_ops;
 	}
-	mpc->old_hard_start_xmit = dev->hard_start_xmit;
-	dev->hard_start_xmit = mpc_send_packet;
-
-	return;
 }
 
 static void stop_mpc(struct mpoa_client *mpc)
 {
-
+	struct net_device *dev = mpc->dev;
 	dprintk("mpoa: (%s) stop_mpc:", mpc->dev->name);
 
 	/* Lets not nullify lec device's dev->hard_start_xmit */
-	if (mpc->dev->hard_start_xmit != mpc_send_packet) {
+	if (dev->netdev_ops != &mpc->new_ops) {
 		dprintk(" mpc already stopped, not fatal\n");
 		return;
 	}
 	dprintk("\n");
-	mpc->dev->hard_start_xmit = mpc->old_hard_start_xmit;
-	mpc->old_hard_start_xmit = NULL;
-	/* close_shortcuts(mpc);    ??? FIXME */
 
-	return;
+	dev->netdev_ops = mpc->old_ops;
+	mpc->old_ops = NULL;
+
+	/* close_shortcuts(mpc);    ??? FIXME */
 }
 
 static const char *mpoa_device_type_string(char type) __attribute__ ((unused));
@@ -531,7 +530,6 @@ static int send_via_shortcut(struct sk_b
  */
 static int mpc_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
-	int retval;
 	struct ...
From: Chas Williams (CONTRACTOR)
Date: Saturday, March 21, 2009 - 4:44 am

this looks fine.  it seems like there should be a better way to handle
this, but it should work.  i dont remember many people using the mpoa
shortcut code though.

Acked-by: Chas Williams <chas@cmf.nrl.navy.mil>

--

From: David Miller
Date: Saturday, March 21, 2009 - 7:34 pm

From: Stephen Hemminger <shemminger@vyatta.com>

Applied.
--

Previous thread: [PATCH 37/77] pcmcia: convert fmvj18x driver to net_device_ops by Stephen Hemminger on Friday, March 20, 2009 - 10:36 pm. (2 messages)

Next thread: [PATCH 52/77] sbni: use internal net_device_stats by Stephen Hemminger on Friday, March 20, 2009 - 10:36 pm. (2 messages)