public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff•org>
To: Jeff Garzik <jeff@garzik•org>
Cc: Ben Dooks <ben-linux@fluff•org>,
	Linux Networking <netdev@vger•kernel.org>,
	akpm@linux-foundation•org
Subject: DM9000: Use delayed work to update MII PHY state
Date: Thu, 8 May 2008 11:36:42 +0100	[thread overview]
Message-ID: <20080508103642.GE30439@fluff.org.uk> (raw)
In-Reply-To: <4820865F.70703@garzik.org>

Periodically check the MII PHY status to ensure that the
network layer's link status is updated and the user informed
of any changes.

Signed-off-by: Ben Dooks <ben-linux@fluff•org>

Index: linux-2.6.25-rc9-quilt2/drivers/net/dm9000.c
===================================================================
--- linux-2.6.25-rc9-quilt2.orig/drivers/net/dm9000.c	2008-04-14 16:41:12.000000000 +0100
+++ linux-2.6.25-rc9-quilt2/drivers/net/dm9000.c	2008-04-15 00:33:08.000000000 +0100
@@ -117,6 +117,9 @@ typedef struct board_info {
 
 	struct mutex	 addr_lock;	/* phy and eeprom access lock */
 
+	struct delayed_work phy_poll;
+	struct net_device  *ndev;
+
 	spinlock_t lock;
 
 	struct mii_if_info mii;
@@ -297,6 +300,10 @@ static void dm9000_set_io(struct board_i
 	}
 }
 
+static void dm9000_schedule_poll(board_info_t *db)
+{
+	schedule_delayed_work(&db->phy_poll, HZ * 2);
+}
 
 /* Our watchdog timed out. Called by the networking layer */
 static void dm9000_timeout(struct net_device *dev)
@@ -465,6 +472,17 @@ static const struct ethtool_ops dm9000_e
  	.set_eeprom		= dm9000_set_eeprom,
 };
 
+static void
+dm9000_poll_work(struct work_struct *w)
+{
+	struct delayed_work *dw = container_of(w, struct delayed_work, work);
+	board_info_t *db = container_of(dw, board_info_t, phy_poll);
+
+	mii_check_media(&db->mii, netif_msg_link(db), 0);
+	
+	if (netif_running(db->ndev))
+		dm9000_schedule_poll(db);
+}
 
 /* dm9000_release_board
  *
@@ -532,10 +550,14 @@ dm9000_probe(struct platform_device *pde
 	memset(db, 0, sizeof (*db));
 
 	db->dev = &pdev->dev;
+	db->ndev = ndev;
 
 	spin_lock_init(&db->lock);
 	mutex_init(&db->addr_lock);
 
+	INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
+
+
 	if (pdev->num_resources < 2) {
 		ret = -ENODEV;
 		goto out;
@@ -761,6 +783,8 @@ dm9000_open(struct net_device *dev)
 
 	mii_check_media(&db->mii, netif_msg_link(db), 1);
 	netif_start_queue(dev);
+	
+	dm9000_schedule_poll(db);
 
 	return 0;
 }
@@ -879,6 +903,8 @@ dm9000_stop(struct net_device *ndev)
 	if (netif_msg_ifdown(db))
 		dev_dbg(db->dev, "shutting down %s\n", ndev->name);
 
+	cancel_delayed_work(&db->phy_poll);
+
 	netif_stop_queue(ndev);
 	netif_carrier_off(ndev);
 

  parent reply	other threads:[~2008-05-08 10:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-28 15:13 DM9000 patches Ben Dooks
2008-04-28 15:21 ` Jeff Garzik
2008-05-06 16:25 ` Jeff Garzik
2008-05-08 10:28   ` Ben Dooks
2008-05-08 10:33   ` DM9000: Add __devinit and __devexit attributes to probe and remove Ben Dooks
2008-05-13  5:18     ` Jeff Garzik
2008-05-08 10:35   ` DM9000: Update and fix driver debugging messages Ben Dooks
2008-05-08 10:36   ` Ben Dooks [this message]
2008-05-08 20:11     ` DM9000: Use delayed work to update MII PHY state Andrew Morton
2008-05-08 20:18     ` Andrew Morton
2008-05-12 20:27       ` Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080508103642.GE30439@fluff.org.uk \
    --to=ben-linux@fluff$(echo .)org \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=jeff@garzik$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox