Skip to content

Commit 82d9859

Browse files
plappermaulrobimarko
authored andcommitted
realtek: mdio: provide individual bus probing function
rtmdio_probe() is a do-it-all setup function. It creates one control structure and one bus. In the future multiple busses will be created. As a preparation carve out the bus specific part into an individual probing function. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: openwrt#22604 Signed-off-by: Robert Marko <robimarko@gmail.com>
1 parent 6069fe9 commit 82d9859

1 file changed

Lines changed: 34 additions & 22 deletions

File tree

target/linux/realtek/files-6.12/drivers/net/mdio/mdio-realtek-otto.c

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -908,32 +908,12 @@ static int rtmdio_map_ports(struct device *dev)
908908
return 0;
909909
}
910910

911-
static int rtmdio_probe(struct platform_device *pdev)
911+
static int rtmdio_probe_one(struct device *dev, struct rtmdio_ctrl *ctrl)
912912
{
913-
struct device *dev = &pdev->dev;
914-
struct rtmdio_ctrl *ctrl;
915913
struct rtmdio_chan *chan;
916914
struct mii_bus *bus;
917915
int ret, addr;
918916

919-
ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
920-
if (!ctrl)
921-
return -ENOMEM;
922-
923-
platform_set_drvdata(pdev, ctrl);
924-
ctrl->cfg = (const struct rtmdio_config *)device_get_match_data(dev);
925-
ctrl->map = syscon_node_to_regmap(pdev->dev.of_node->parent);
926-
if (IS_ERR(ctrl->map))
927-
return PTR_ERR(ctrl->map);
928-
929-
ret = rtmdio_map_ports(dev);
930-
if (ret) {
931-
for_each_phy(ctrl, addr)
932-
of_node_put(ctrl->port[addr].dn);
933-
return ret;
934-
}
935-
rtmdio_setup_smi_topology(ctrl);
936-
937917
bus = devm_mdiobus_alloc_size(dev, sizeof(*chan));
938918
if (!bus)
939919
return -ENOMEM;
@@ -954,7 +934,7 @@ static int rtmdio_probe(struct platform_device *pdev)
954934

955935
ret = devm_mdiobus_register(dev, bus);
956936
if (ret)
957-
return ret;
937+
return dev_err_probe(dev, ret, "cannot register MDIO bus\n");
958938

959939
for_each_phy(ctrl, addr) {
960940
if (!ret)
@@ -965,12 +945,44 @@ static int rtmdio_probe(struct platform_device *pdev)
965945
if (ret)
966946
return ret;
967947

948+
/*
949+
* TODO: This polling setup needs to be relocated into rtmdio_probe(). It is a generic
950+
* function and not bus specific. But this will require more rework of the data
951+
* structures. For now it is easier to hand over the single bus that was just created.
952+
*/
968953
if (ctrl->cfg->setup_polling)
969954
ctrl->cfg->setup_polling(bus);
970955

971956
return 0;
972957
}
973958

959+
static int rtmdio_probe(struct platform_device *pdev)
960+
{
961+
struct device *dev = &pdev->dev;
962+
struct rtmdio_ctrl *ctrl;
963+
int ret, addr;
964+
965+
ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL);
966+
if (!ctrl)
967+
return -ENOMEM;
968+
969+
platform_set_drvdata(pdev, ctrl);
970+
ctrl->cfg = (const struct rtmdio_config *)device_get_match_data(dev);
971+
ctrl->map = syscon_node_to_regmap(pdev->dev.of_node->parent);
972+
if (IS_ERR(ctrl->map))
973+
return PTR_ERR(ctrl->map);
974+
975+
ret = rtmdio_map_ports(dev);
976+
if (ret) {
977+
for_each_phy(ctrl, addr)
978+
of_node_put(ctrl->port[addr].dn);
979+
return ret;
980+
}
981+
rtmdio_setup_smi_topology(ctrl);
982+
983+
return rtmdio_probe_one(dev, ctrl);
984+
}
985+
974986
static const struct rtmdio_config rtmdio_838x_cfg = {
975987
.num_phys = 28,
976988
.raw_page = 4095,

0 commit comments

Comments
 (0)