kernel: refresh patches
[openwrt/svn-archive/archive.git] / target / linux / mvebu / patches-3.14 / 018-decouple_phy_id_and_address.patch
1 From 9b744942290c168287013f0a19ff7392f65c8107 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Fri, 16 May 2014 16:14:03 +0200
4 Subject: net: phy: decouple PHY id and PHY address in fixed PHY driver
5
6 Until now, the fixed_phy_add() function was taking as argument
7 'phy_id', which was used both as the PHY address on the fake fixed
8 MDIO bus, and as the PHY id, as available in the MII_PHYSID1 and
9 MII_PHYSID2 registers. However, those two informations are completely
10 unrelated.
11
12 This patch decouples them. The PHY id of fixed PHYs is hardcoded to be
13 0x0. Ideally, a really reserved value would be nicer, but there
14 doesn't seem to be an easy of making sure a dummy value can be
15 assigned to the Linux kernel for such usage.
16
17 The PHY address remains passed by the caller of phy_fixed_add().
18
19 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
20 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
21 Tested-by: Florian Fainelli <f.fainelli@gmail.com>
22 Signed-off-by: David S. Miller <davem@davemloft.net>
23
24 --- a/drivers/net/phy/fixed.c
25 +++ b/drivers/net/phy/fixed.c
26 @@ -31,7 +31,7 @@ struct fixed_mdio_bus {
27 };
28
29 struct fixed_phy {
30 - int id;
31 + int addr;
32 u16 regs[MII_REGS_NUM];
33 struct phy_device *phydev;
34 struct fixed_phy_status status;
35 @@ -104,8 +104,8 @@ static int fixed_phy_update_regs(struct
36 if (fp->status.asym_pause)
37 lpa |= LPA_PAUSE_ASYM;
38
39 - fp->regs[MII_PHYSID1] = fp->id >> 16;
40 - fp->regs[MII_PHYSID2] = fp->id;
41 + fp->regs[MII_PHYSID1] = 0;
42 + fp->regs[MII_PHYSID2] = 0;
43
44 fp->regs[MII_BMSR] = bmsr;
45 fp->regs[MII_BMCR] = bmcr;
46 @@ -115,7 +115,7 @@ static int fixed_phy_update_regs(struct
47 return 0;
48 }
49
50 -static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num)
51 +static int fixed_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num)
52 {
53 struct fixed_mdio_bus *fmb = bus->priv;
54 struct fixed_phy *fp;
55 @@ -124,7 +124,7 @@ static int fixed_mdio_read(struct mii_bu
56 return -1;
57
58 list_for_each_entry(fp, &fmb->phys, node) {
59 - if (fp->id == phy_id) {
60 + if (fp->addr == phy_addr) {
61 /* Issue callback if user registered it. */
62 if (fp->link_update) {
63 fp->link_update(fp->phydev->attached_dev,
64 @@ -138,7 +138,7 @@ static int fixed_mdio_read(struct mii_bu
65 return 0xFFFF;
66 }
67
68 -static int fixed_mdio_write(struct mii_bus *bus, int phy_id, int reg_num,
69 +static int fixed_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num,
70 u16 val)
71 {
72 return 0;
73 @@ -160,7 +160,7 @@ int fixed_phy_set_link_update(struct phy
74 return -EINVAL;
75
76 list_for_each_entry(fp, &fmb->phys, node) {
77 - if (fp->id == phydev->phy_id) {
78 + if (fp->addr == phydev->addr) {
79 fp->link_update = link_update;
80 fp->phydev = phydev;
81 return 0;
82 @@ -171,7 +171,7 @@ int fixed_phy_set_link_update(struct phy
83 }
84 EXPORT_SYMBOL_GPL(fixed_phy_set_link_update);
85
86 -int fixed_phy_add(unsigned int irq, int phy_id,
87 +int fixed_phy_add(unsigned int irq, int phy_addr,
88 struct fixed_phy_status *status)
89 {
90 int ret;
91 @@ -184,9 +184,9 @@ int fixed_phy_add(unsigned int irq, int
92
93 memset(fp->regs, 0xFF, sizeof(fp->regs[0]) * MII_REGS_NUM);
94
95 - fmb->irqs[phy_id] = irq;
96 + fmb->irqs[phy_addr] = irq;
97
98 - fp->id = phy_id;
99 + fp->addr = phy_addr;
100 fp->status = *status;
101
102 ret = fixed_phy_update_regs(fp);