From: Stas Sergeev <stsp@list•ru>
To: netdev@vger•kernel.org
Cc: Linux kernel <linux-kernel@vger•kernel.org>,
Stas Sergeev <stsp@users•sourceforge.net>,
Florian Fainelli <f.fainelli@gmail•com>
Subject: [PATCH 2/6] fixed_phy: add fixed_phy_unregister()
Date: Fri, 27 Mar 2015 16:33:31 +0300 [thread overview]
Message-ID: <55155C2B.9020507@list.ru> (raw)
In-Reply-To: <55155AFC.4050800@list.ru>
A counterpart of fixed_phy_register().
Can be used on failure path, like below:
phy = fixed_phy_register(...);
phy->priv = kmalloc(...);
if (!phy->priv) {
fixed_phy_unregister(phy);
return -ENOMEM;
}
CC: Florian Fainelli <f.fainelli@gmail•com>
CC: netdev@vger•kernel.org
CC: linux-kernel@vger•kernel.org
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-27 13:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-27 13:28 [PATCH 0/6] mvneta: SGMII-based in-band link state signaling Stas Sergeev
2015-03-27 13:31 ` PATCH 1/6] fixed_phy: pass phy_device instead of net_device to link_update() function Stas Sergeev
2015-03-27 13:33 ` Stas Sergeev [this message]
2015-03-27 13:34 ` [PATCH " Stas Sergeev
2015-03-27 13:35 ` [PATCH 3/6] of_mdio: restructure of_phy_register_fixed_link() for further modifications Stas Sergeev
2015-03-27 13:37 ` [PATCH 4/6] of: add API for changing parameters of fixed link Stas Sergeev
[not found] ` <55155D35.1070703-cmBhpYW9OiY@public.gmane.org>
2015-03-27 15:41 ` Florian Fainelli
2015-03-27 16:07 ` Stas Sergeev
2015-03-27 16:21 ` Florian Fainelli
[not found] ` <CAGVrzcaLfQcTAx8OR=sE=7FLrp0gGvfX8_YfxK_CU+x26JHymw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-27 16:39 ` Stas Sergeev
2015-03-27 17:15 ` Florian Fainelli
2015-03-27 17:31 ` Stas Sergeev
2015-03-30 14:39 ` Stas Sergeev
2015-03-30 16:06 ` Florian Fainelli
2015-03-30 17:04 ` Stas Sergeev
2015-03-31 17:11 ` Stas Sergeev
2015-03-27 13:39 ` [PATCH 0/6] mvneta: SGMII-based in-band link state signaling Andrew Lunn
2015-03-27 13:52 ` Stas Sergeev
2015-03-27 13:59 ` Andrew Lunn
2015-03-27 14:20 ` Stas Sergeev
2015-03-27 15:44 ` Florian Fainelli
2015-03-27 13:39 ` [PATCH 5/6] mvneta: implement " Stas Sergeev
2015-07-08 16:30 ` [5/6] " Sebastien Rannou
2015-07-08 16:51 ` Stas Sergeev
2015-07-09 9:03 ` Sebastien Rannou
2015-07-09 9:19 ` Thomas Petazzoni
2015-07-09 10:11 ` Stas Sergeev
2015-03-27 13:40 ` [PATCH 6/6] mvneta: port marvell's official in-band status enabling procedure 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=55155C2B.9020507@list.ru \
--to=stsp@list$(echo .)ru \
--cc=f.fainelli@gmail$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=stsp@users$(echo .)sourceforge.net \
/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