From: Boris BREZILLON <b.brezillon@overkiz.com>
To: "David S. Miller" <davem@davemloft.net>,
Mark Brown <broonie@kernel.org>,
Nick Bowler <nbowler@elliptictech.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Grant Likely <grant.likely@secretlab.ca>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Boris BREZILLON <b.brezillon@overkiz.com>
Subject: [RFC PATCH] phylib: mdio: handle register/unregister/register sequence
Date: Thu, 22 Aug 2013 14:34:43 +0200 [thread overview]
Message-ID: <1377174883-10643-1-git-send-email-b.brezillon@overkiz.com> (raw)
In-Reply-To: <1377174836-10569-1-git-send-email-b.brezillon@overkiz.com>
The current implementation does not accept this sequence on a given mdio
bus: register/unregister/register.
The device core framework complain about already initialized kobject
struct:
"kobject (df9e9848): tried to init an initialized object, something is
seriously wrong."
This patch replaces the device_register call with device_add in
mdiobus_register and move the device struct initialization in the
mdiobus_alloc_size function.
Thus the device struct is only initialized once.
Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
---
drivers/net/phy/mdio_bus.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index dc92097..a256de3 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -68,6 +68,8 @@ struct mii_bus *mdiobus_alloc_size(size_t size)
bus->priv = (void *)bus + aligned_size;
}
+ device_initialize(&bus->dev);
+
return bus;
}
EXPORT_SYMBOL(mdiobus_alloc_size);
@@ -151,7 +153,7 @@ int mdiobus_register(struct mii_bus *bus)
bus->dev.groups = NULL;
dev_set_name(&bus->dev, "%s", bus->id);
- err = device_register(&bus->dev);
+ err = device_add(&bus->dev);
if (err) {
pr_err("mii_bus %s failed to register\n", bus->id);
return -EINVAL;
@@ -195,12 +197,12 @@ void mdiobus_unregister(struct mii_bus *bus)
BUG_ON(bus->state != MDIOBUS_REGISTERED);
bus->state = MDIOBUS_UNREGISTERED;
- device_del(&bus->dev);
for (i = 0; i < PHY_MAX_ADDR; i++) {
if (bus->phy_map[i])
device_unregister(&bus->phy_map[i]->dev);
bus->phy_map[i] = NULL;
}
+ device_del(&bus->dev);
}
EXPORT_SYMBOL(mdiobus_unregister);
--
1.7.9.5
next prev parent reply other threads:[~2013-08-22 12:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-22 12:33 Boris BREZILLON
2013-08-22 12:34 ` Boris BREZILLON [this message]
2013-08-22 12:43 ` Florian Fainelli
2013-08-22 13:05 ` boris brezillon
2013-08-22 13:15 ` Florian Fainelli
2013-08-22 13:24 ` boris brezillon
2013-08-22 13:14 ` boris brezillon
2013-08-22 15:27 ` Greg Kroah-Hartman
2013-08-22 15:38 ` boris brezillon
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=1377174883-10643-1-git-send-email-b.brezillon@overkiz.com \
--to=b.brezillon@overkiz.com \
--cc=broonie@kernel.org \
--cc=davem@davemloft.net \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbowler@elliptictech.com \
--cc=netdev@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
all inboxes | Powered by JetHome®