diff mbox

[2/6] pass phy_device instead of net_device to fixed_phy link_update() function

Message ID 55142D01.3090601@list.ru
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Stas Sergeev March 26, 2015, 4 p.m. UTC
-=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-
Looking up phy_device pointer from net_device requires poking 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.

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(-)

Comments

David Miller March 26, 2015, 10:49 p.m. UTC | #1
From: Stas Sergeev <stsp@list.ru>
Date: Thu, 26 Mar 2015 19:00:01 +0300

> -=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-

Don't put this into youro commit messages, ever.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stas Sergeev March 26, 2015, 10:55 p.m. UTC | #2
27.03.2015 01:49, David Miller пишет:
> From: Stas Sergeev <stsp@list.ru>
> Date: Thu, 26 Mar 2015 19:00:01 +0300
>
>> -=-=-=-=-=-=-=-=-=# Don't remove this line #=-=-=-=-=-=-=-=-=-
> Don't put this into youro commit messages, ever.
I'll remove the silly thunderbird-patch-inline plugin (that adds this line)
and will try to convince thunderbird not to break indentation, oh...
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thomas Petazzoni March 26, 2015, 10:59 p.m. UTC | #3
Dear Stas Sergeev,

On Fri, 27 Mar 2015 01:55:33 +0300, Stas Sergeev wrote:

> I'll remove the silly thunderbird-patch-inline plugin (that adds this line)
> and will try to convince thunderbird not to break indentation, oh...

Or you start using 'git send-email', which will do the right thing for
you.

Thomas
diff mbox

Patch

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;