From: Daniel Mack <zonque@gmail.com>
To: davem@davemloft.net
Cc: f.fainelli@gmail.com, ezequiel.garcia@free-electrons.com,
netdev@vger.kernel.org, Daniel Mack <zonque@gmail.com>,
<stable@vger.kernel.org>
Subject: [PATCH] net: smsc911x: handle suspend/resume for mii bus
Date: Wed, 13 Aug 2014 22:03:17 +0200 [thread overview]
Message-ID: <1407960197-5342-1-git-send-email-zonque@gmail.com> (raw)
Since commit a71e3c37960c ("net: phy: Set the driver when registering
an MDIO bus device"), the ->driver pointers of all mii buses are set to
the parent device's driver. This means that smsc911x_{suspend,resume}
will be called for the MII bus at suspend time now, in addition to the
actual netdev suspend callbacks.
These functions currently assume they are only called for the netdev,
and don't check whether they get back a valid pointer from
dev_get_drvdata().
Fix this by bailing out early if dev_get_drvdata() returns NULL.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Cc: <stable@vger.kernel.org> [3.16+]
---
drivers/net/ethernet/smsc/smsc911x.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 5e13fa5..2ba6590 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2555,7 +2555,15 @@ out_0:
static int smsc911x_suspend(struct device *dev)
{
struct net_device *ndev = dev_get_drvdata(dev);
- struct smsc911x_data *pdata = netdev_priv(ndev);
+ struct smsc911x_data *pdata;
+
+ /* We are called for the mii bus as well, in which case
+ * drvdata is unset.
+ */
+ if (!ndev)
+ return 0;
+
+ pdata = netdev_priv(ndev);
/* enable wake on LAN, energy detection and the external PME
* signal. */
@@ -2569,9 +2577,17 @@ static int smsc911x_suspend(struct device *dev)
static int smsc911x_resume(struct device *dev)
{
struct net_device *ndev = dev_get_drvdata(dev);
- struct smsc911x_data *pdata = netdev_priv(ndev);
+ struct smsc911x_data *pdata;
unsigned int to = 100;
+ if (!ndev)
+ return 0;
+
+ /* We are called for the mii bus as well, in which case
+ * drvdata is unset.
+ */
+ pdata = netdev_priv(ndev);
+
/* Note 3.11 from the datasheet:
* "When the LAN9220 is in a power saving state, a write of any
* data to the BYTE_TEST register will wake-up the device."
--
2.0.4
next reply other threads:[~2014-08-13 20:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 20:03 Daniel Mack [this message]
2014-08-13 20:09 ` [PATCH] net: smsc911x: handle suspend/resume for mii bus Fabio Estevam
2014-08-13 20:14 ` Daniel Mack
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=1407960197-5342-1-git-send-email-zonque@gmail.com \
--to=zonque@gmail.com \
--cc=davem@davemloft.net \
--cc=ezequiel.garcia@free-electrons.com \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).