From: Stas Sergeev <stsp@list•ru>
To: netdev@vger•kernel.org
Cc: Rami Rosen <rosenr@marvell•com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons•com>
Subject: [PATCH 3/6] fixed_phy: add fixed_phy_unregister()
Date: Thu, 26 Mar 2015 19:01:00 +0300 [thread overview]
Message-ID: <55142D3C.4040902@list.ru> (raw)
In-Reply-To: <55142D01.3090601@list.ru>
-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-
A counterpart of fixed_phy_register().
Can be used on failure path.
Signed-off-by: Stas Sergeev <stsp@users•sourceforge.net>
---
drivers/net/phy/fixed_phy.c | 11 +++++++++++
drivers/net/phy/phy_device.c | 7 +++++++
include/linux/phy.h | 1 +
include/linux/phy_fixed.h | 4 ++++
4 files changed, 23 insertions(+)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index 8078998..c2e82a0 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -275,6 +275,17 @@ struct phy_device *fixed_phy_register(unsigned int irq,
}
EXPORT_SYMBOL_GPL(fixed_phy_register);
+void fixed_phy_unregister(struct phy_device *phy)
+{
+ struct device_node *np = phy->dev.of_node;
+
+ fixed_phy_del(phy->addr);
+ phy_device_unregister(phy);
+ phy_device_free(phy);
+ of_node_put(np);
+}
+EXPORT_SYMBOL_GPL(fixed_phy_unregister);
+
static int __init fixed_mdio_bus_init(void)
{
struct fixed_mdio_bus *fmb = &platform_fmb;
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index bdfe51f..8923c0d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -375,6 +375,13 @@ int phy_device_register(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_device_register);
+void phy_device_unregister(struct phy_device *phydev)
+{
+ phydev->bus->phy_map[phydev->addr] = NULL;
+ device_del(&phydev->dev);
+}
+EXPORT_SYMBOL(phy_device_unregister);
+
/**
* phy_find_first - finds the first PHY device on the bus
* @bus: the target MII bus
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 6858098..448dda3 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -714,6 +714,7 @@ struct phy_device *phy_device_create(struct mii_bus
*bus, int addr, int phy_id,
struct phy_c45_device_ids *c45_ids);
struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool
is_c45);
int phy_device_register(struct phy_device *phy);
+void phy_device_unregister(struct phy_device *phydev);
int phy_init_hw(struct phy_device *phydev);
int phy_suspend(struct phy_device *phydev);
int phy_resume(struct phy_device *phydev);
diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h
index ac82e6d..bb7d17c 100644
--- a/include/linux/phy_fixed.h
+++ b/include/linux/phy_fixed.h
@@ -17,6 +17,7 @@ extern int fixed_phy_add(unsigned int irq, int phy_id,
extern struct phy_device *fixed_phy_register(unsigned int irq,
struct fixed_phy_status *status,
struct device_node *np);
+extern void fixed_phy_unregister(struct phy_device *phy);
extern void fixed_phy_del(int phy_addr);
extern int fixed_phy_set_link_update(struct phy_device *phydev,
int (*link_update)(struct phy_device *,
@@ -33,6 +34,9 @@ static inline struct phy_device
*fixed_phy_register(unsigned int irq,
{
return ERR_PTR(-ENODEV);
}
+static inline void fixed_phy_unregister(struct phy_device *phy)
+{
+}
static inline int fixed_phy_del(int phy_addr)
{
return -ENODEV;
--
1.7.9.5
next prev parent reply other threads:[~2015-03-26 16:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 15:56 [PATCH 0/6] mvneta: SGMII-based in-band link status signaling Stas Sergeev
2015-03-26 15:58 ` [PATCH 1/6] restructure of_phy_register_fixed_link() for further modifications Stas Sergeev
2015-03-26 16:00 ` [PATCH 2/6] pass phy_device instead of net_device to fixed_phy link_update() function Stas Sergeev
2015-03-26 16:01 ` Stas Sergeev [this message]
2015-03-26 16:02 ` [PATCH 4/6] of: add API for changing parameters of fixed link Stas Sergeev
2015-03-26 16:03 ` [PATCH 5/6] mvneta: implement SGMII-based in-band link status signaling Stas Sergeev
2015-03-26 16:04 ` [PATCH 6/6] mvneta: port marvell's official in-band status enabling procedure Stas Sergeev
2015-03-26 22:49 ` [PATCH 2/6] pass phy_device instead of net_device to fixed_phy link_update() function David Miller
2015-03-26 22:55 ` Stas Sergeev
2015-03-26 22:59 ` Thomas Petazzoni
2015-03-26 19:01 ` [PATCH 1/6] restructure of_phy_register_fixed_link() for further modifications Sergei Shtylyov
2015-03-26 20:26 ` Stas Sergeev
2015-03-26 17:13 ` [PATCH 0/6] mvneta: SGMII-based in-band link status signaling Florian Fainelli
2015-03-26 17:23 ` Stas Sergeev
2015-03-26 17:29 ` Florian Fainelli
2015-03-26 17:34 ` Stas Sergeev
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=55142D3C.4040902@list.ru \
--to=stsp@list$(echo .)ru \
--cc=netdev@vger$(echo .)kernel.org \
--cc=rosenr@marvell$(echo .)com \
--cc=thomas.petazzoni@free-electrons$(echo .)com \
/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