OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From 6709752e7233afd929a130ac4f3645348be94c1f Mon Sep 17 00:00:00 2001 |
2 | From: Russell King <rmk+kernel@armlinux.org.uk> |
||
3 | Date: Tue, 2 Jan 2018 10:58:37 +0000 |
||
4 | Subject: [PATCH 294/454] net: phy: add unlocked accessors |
||
5 | |||
6 | commit 788f9933db6172801336d0ae2dec5bdc7525389f upstream. |
||
7 | |||
8 | Add unlocked versions of the bus accessors, which allows access to the |
||
9 | bus with all the tracing. These accessors validate that the bus mutex |
||
10 | is held, which is a basic requirement for all mii bus accesses. |
||
11 | |||
12 | Also added is a read-modify-write unlocked accessor with the same |
||
13 | locking requirements. |
||
14 | |||
15 | Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> |
||
16 | Reviewed-by: Andrew Lunn <andrew@lunn.ch> |
||
17 | Signed-off-by: David S. Miller <davem@davemloft.net> |
||
18 | --- |
||
19 | drivers/net/phy/phy-core.c | 25 +++++++++++++++++++++++++ |
||
20 | include/linux/phy.h | 28 ++++++++++++++++++++++++++++ |
||
21 | 2 files changed, 53 insertions(+) |
||
22 | |||
23 | --- a/drivers/net/phy/phy-core.c |
||
24 | +++ b/drivers/net/phy/phy-core.c |
||
25 | @@ -280,3 +280,28 @@ int phy_write_mmd(struct phy_device *phy |
||
26 | return ret; |
||
27 | } |
||
28 | EXPORT_SYMBOL(phy_write_mmd); |
||
29 | + |
||
30 | +/** |
||
31 | + * __phy_modify() - Convenience function for modifying a PHY register |
||
32 | + * @phydev: a pointer to a &struct phy_device |
||
33 | + * @regnum: register number |
||
34 | + * @mask: bit mask of bits to clear |
||
35 | + * @set: bit mask of bits to set |
||
36 | + * |
||
37 | + * Unlocked helper function which allows a PHY register to be modified as |
||
38 | + * new register value = (old register value & mask) | set |
||
39 | + */ |
||
40 | +int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) |
||
41 | +{ |
||
42 | + int ret, res; |
||
43 | + |
||
44 | + ret = __phy_read(phydev, regnum); |
||
45 | + if (ret >= 0) { |
||
46 | + res = __phy_write(phydev, regnum, (ret & ~mask) | set); |
||
47 | + if (res < 0) |
||
48 | + ret = res; |
||
49 | + } |
||
50 | + |
||
51 | + return ret; |
||
52 | +} |
||
53 | +EXPORT_SYMBOL_GPL(__phy_modify); |
||
54 | --- a/include/linux/phy.h |
||
55 | +++ b/include/linux/phy.h |
||
56 | @@ -726,6 +726,18 @@ static inline int phy_read(struct phy_de |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | + * __phy_read - convenience function for reading a given PHY register |
||
61 | + * @phydev: the phy_device struct |
||
62 | + * @regnum: register number to read |
||
63 | + * |
||
64 | + * The caller must have taken the MDIO bus lock. |
||
65 | + */ |
||
66 | +static inline int __phy_read(struct phy_device *phydev, u32 regnum) |
||
67 | +{ |
||
68 | + return __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum); |
||
69 | +} |
||
70 | + |
||
71 | +/** |
||
72 | * phy_write - Convenience function for writing a given PHY register |
||
73 | * @phydev: the phy_device struct |
||
74 | * @regnum: register number to write |
||
75 | @@ -741,6 +753,22 @@ static inline int phy_write(struct phy_d |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | + * __phy_write - Convenience function for writing a given PHY register |
||
80 | + * @phydev: the phy_device struct |
||
81 | + * @regnum: register number to write |
||
82 | + * @val: value to write to @regnum |
||
83 | + * |
||
84 | + * The caller must have taken the MDIO bus lock. |
||
85 | + */ |
||
86 | +static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val) |
||
87 | +{ |
||
88 | + return __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, |
||
89 | + val); |
||
90 | +} |
||
91 | + |
||
92 | +int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set); |
||
93 | + |
||
94 | +/** |
||
95 | * phy_interrupt_is_valid - Convenience function for testing a given PHY irq |
||
96 | * @phydev: the phy_device struct |
||
97 | * |