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>,
"David S. Miller" <davem@davemloft.net>,
Andrew Lunn <andrew@lunn.ch>, Guenter Roeck <linux@roeck-us.net>,
Alexander Duyck <alexander.h.duyck@intel.com>,
Joe Perches <joe@perches.com>
Subject: [PATCH 1/6] fixed_phy: pass phy_device instead of net_device to link_update() function
Date: Fri, 27 Mar 2015 16:34:10 +0300 [thread overview]
Message-ID: <55155C52.1070006@list.ru> (raw)
In-Reply-To: <55155AFC.4050800@list.ru>
Looking up phy_device pointer from net_device requires looking into
private data. This may be problematic if phy is handled separately
from net_device.
Pass phy_device pointer to link_update() function because looking
up net_device pointer from phy_device is trivial, if needed.
CC: Florian Fainelli <f.fainelli@gmail.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: Andrew Lunn <andrew@lunn.ch>
CC: Guenter Roeck <linux@roeck-us.net>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
CC: Joe Perches <joe@perches.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 | 7 +++----
include/linux/phy_fixed.h | 4 ++--
net/dsa/slave.c | 3 ++-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index a08a3c7..8078998 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -36,7 +36,7 @@ struct fixed_phy {
u16 regs[MII_REGS_NUM];
struct phy_device *phydev;
struct fixed_phy_status status;
- int (*link_update)(struct net_device *, struct fixed_phy_status *);
+ int (*link_update)(struct phy_device *, struct fixed_phy_status *);
struct list_head node;
};
@@ -139,8 +139,7 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num)
if (fp->addr == phy_addr) {
/* Issue callback if user registered it. */
if (fp->link_update) {
- fp->link_update(fp->phydev->attached_dev,
- &fp->status);
+ fp->link_update(fp->phydev, &fp->status);
fixed_phy_update_regs(fp);
}
return fp->regs[reg_num];
@@ -162,7 +161,7 @@ static int fixed_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num,
* May be useful for PHY's that need to be software-driven.
*/
int fixed_phy_set_link_update(struct phy_device *phydev,
- int (*link_update)(struct net_device *,
+ int (*link_update)(struct phy_device *,
struct fixed_phy_status *))
{
struct fixed_mdio_bus *fmb = &platform_fmb;
diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h
index 7e75bfe..ac82e6d 100644
--- a/include/linux/phy_fixed.h
+++ b/include/linux/phy_fixed.h
@@ -19,7 +19,7 @@ extern struct phy_device *fixed_phy_register(unsigned int irq,
struct device_node *np);
extern void fixed_phy_del(int phy_addr);
extern int fixed_phy_set_link_update(struct phy_device *phydev,
- int (*link_update)(struct net_device *,
+ int (*link_update)(struct phy_device *,
struct fixed_phy_status *));
#else
static inline int fixed_phy_add(unsigned int irq, int phy_id,
@@ -38,7 +38,7 @@ static inline int fixed_phy_del(int phy_addr)
return -ENODEV;
}
static inline int fixed_phy_set_link_update(struct phy_device *phydev,
- int (*link_update)(struct net_device *,
+ int (*link_update)(struct phy_device *,
struct fixed_phy_status *))
{
return -ENODEV;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index f23dead..86ac744 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -500,9 +500,10 @@ static void dsa_slave_adjust_link(struct net_device *dev)
phy_print_status(p->phy);
}
-static int dsa_slave_fixed_link_update(struct net_device *dev,
+static int dsa_slave_fixed_link_update(struct phy_device *phy,
struct fixed_phy_status *status)
{
+ struct net_device *dev = phy->attached_dev;
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_switch *ds = p->parent;
--
1.7.9.5
next prev parent reply other threads:[~2015-03-27 13:34 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 ` [PATCH 2/6] fixed_phy: add fixed_phy_unregister() Stas Sergeev
2015-03-27 13:34 ` Stas Sergeev [this message]
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=55155C52.1070006@list.ru \
--to=stsp@list.ru \
--cc=alexander.h.duyck@intel.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=netdev@vger.kernel.org \
--cc=stsp@users.sourceforge.net \
/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).