aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorentin Labbe <clabbe.montjoie@gmail.com>2017-09-04 12:30:14 -0400
committerDavid S. Miller <davem@davemloft.net>2017-09-05 17:42:52 -0400
commit5482a978b962abd23f17a004e46d255d11646c20 (patch)
treed3f5e27abcda7441f5934fd919d2f0dafefd411d
parentfdade4f69e4ca29753963f858dc42c5f8faf1d0b (diff)
net: mdio-mux: add mdio_mux parameter to mdio_mux_init()
mdio_mux_init() use the parameter dev for two distinct thing: 1) Have a device for all devm_ functions 2) Get device_node from it Since it is two distinct purpose, this patch add a parameter mdio_mux that is linked to task 2. This will also permit to register an of_node mdio-mux that lacks a direct owning device. For example a mdio-mux which is a subnode of a real device. Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/mdio-mux-bcm-iproc.c2
-rw-r--r--drivers/net/phy/mdio-mux-gpio.c2
-rw-r--r--drivers/net/phy/mdio-mux-mmioreg.c3
-rw-r--r--drivers/net/phy/mdio-mux.c7
-rw-r--r--include/linux/mdio-mux.h9
5 files changed, 17 insertions, 6 deletions
diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c
index 0a5f62e0efcc..0831b7142df7 100644
--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -199,7 +199,7 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
199 199
200 platform_set_drvdata(pdev, md); 200 platform_set_drvdata(pdev, md);
201 201
202 rc = mdio_mux_init(md->dev, mdio_mux_iproc_switch_fn, 202 rc = mdio_mux_init(md->dev, md->dev->of_node, mdio_mux_iproc_switch_fn,
203 &md->mux_handle, md, md->mii_bus); 203 &md->mux_handle, md, md->mii_bus);
204 if (rc) { 204 if (rc) {
205 dev_info(md->dev, "mdiomux initialization failed\n"); 205 dev_info(md->dev, "mdiomux initialization failed\n");
diff --git a/drivers/net/phy/mdio-mux-gpio.c b/drivers/net/phy/mdio-mux-gpio.c
index 919949960a10..082ffef0dec4 100644
--- a/drivers/net/phy/mdio-mux-gpio.c
+++ b/drivers/net/phy/mdio-mux-gpio.c
@@ -54,7 +54,7 @@ static int mdio_mux_gpio_probe(struct platform_device *pdev)
54 if (IS_ERR(s->gpios)) 54 if (IS_ERR(s->gpios))
55 return PTR_ERR(s->gpios); 55 return PTR_ERR(s->gpios);
56 56
57 r = mdio_mux_init(&pdev->dev, 57 r = mdio_mux_init(&pdev->dev, pdev->dev.of_node,
58 mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL); 58 mdio_mux_gpio_switch_fn, &s->mux_handle, s, NULL);
59 59
60 if (r != 0) { 60 if (r != 0) {
diff --git a/drivers/net/phy/mdio-mux-mmioreg.c b/drivers/net/phy/mdio-mux-mmioreg.c
index c3825c7da038..2573ab012f16 100644
--- a/drivers/net/phy/mdio-mux-mmioreg.c
+++ b/drivers/net/phy/mdio-mux-mmioreg.c
@@ -159,7 +159,8 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
159 } 159 }
160 } 160 }
161 161
162 ret = mdio_mux_init(&pdev->dev, mdio_mux_mmioreg_switch_fn, 162 ret = mdio_mux_init(&pdev->dev, pdev->dev.of_node,
163 mdio_mux_mmioreg_switch_fn,
163 &s->mux_handle, s, NULL); 164 &s->mux_handle, s, NULL);
164 if (ret) { 165 if (ret) {
165 dev_err(&pdev->dev, "failed to register mdio-mux bus %pOF\n", 166 dev_err(&pdev->dev, "failed to register mdio-mux bus %pOF\n",
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 6f75e9f27fed..0a86f1e4c02f 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -86,6 +86,7 @@ out:
86static int parent_count; 86static int parent_count;
87 87
88int mdio_mux_init(struct device *dev, 88int mdio_mux_init(struct device *dev,
89 struct device_node *mux_node,
89 int (*switch_fn)(int cur, int desired, void *data), 90 int (*switch_fn)(int cur, int desired, void *data),
90 void **mux_handle, 91 void **mux_handle,
91 void *data, 92 void *data,
@@ -98,11 +99,11 @@ int mdio_mux_init(struct device *dev,
98 struct mdio_mux_parent_bus *pb; 99 struct mdio_mux_parent_bus *pb;
99 struct mdio_mux_child_bus *cb; 100 struct mdio_mux_child_bus *cb;
100 101
101 if (!dev->of_node) 102 if (!mux_node)
102 return -ENODEV; 103 return -ENODEV;
103 104
104 if (!mux_bus) { 105 if (!mux_bus) {
105 parent_bus_node = of_parse_phandle(dev->of_node, 106 parent_bus_node = of_parse_phandle(mux_node,
106 "mdio-parent-bus", 0); 107 "mdio-parent-bus", 0);
107 108
108 if (!parent_bus_node) 109 if (!parent_bus_node)
@@ -132,7 +133,7 @@ int mdio_mux_init(struct device *dev,
132 pb->mii_bus = parent_bus; 133 pb->mii_bus = parent_bus;
133 134
134 ret_val = -ENODEV; 135 ret_val = -ENODEV;
135 for_each_available_child_of_node(dev->of_node, child_bus_node) { 136 for_each_available_child_of_node(mux_node, child_bus_node) {
136 int v; 137 int v;
137 138
138 r = of_property_read_u32(child_bus_node, "reg", &v); 139 r = of_property_read_u32(child_bus_node, "reg", &v);
diff --git a/include/linux/mdio-mux.h b/include/linux/mdio-mux.h
index 61f5b21b31c7..a5d58f221939 100644
--- a/include/linux/mdio-mux.h
+++ b/include/linux/mdio-mux.h
@@ -12,7 +12,16 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/phy.h> 13#include <linux/phy.h>
14 14
15/* mdio_mux_init() - Initialize a MDIO mux
16 * @dev The device owning the MDIO mux
17 * @mux_node The device node of the MDIO mux
18 * @switch_fn The function called for switching target MDIO child
19 * mux_handle A pointer to a (void *) used internaly by mdio-mux
20 * @data Private data used by switch_fn()
21 * @mux_bus An optional parent bus (Other case are to use parent_bus property)
22 */
15int mdio_mux_init(struct device *dev, 23int mdio_mux_init(struct device *dev,
24 struct device_node *mux_node,
16 int (*switch_fn) (int cur, int desired, void *data), 25 int (*switch_fn) (int cur, int desired, void *data),
17 void **mux_handle, 26 void **mux_handle,
18 void *data, 27 void *data,