Commit 4078513f authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Paolo Abeni

net: mdio: mux-mmioreg: Simplified with dev_err_probe()

Use the dev_err_probe() helper to simplify code.
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent b00f7f4f
......@@ -109,30 +109,25 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
return -ENOMEM;
ret = of_address_to_resource(np, 0, &res);
if (ret) {
dev_err(&pdev->dev, "could not obtain memory map for node %pOF\n",
np);
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret,
"could not obtain memory map for node %pOF\n", np);
s->phys = res.start;
s->iosize = resource_size(&res);
if (s->iosize != sizeof(uint8_t) &&
s->iosize != sizeof(uint16_t) &&
s->iosize != sizeof(uint32_t)) {
dev_err(&pdev->dev, "only 8/16/32-bit registers are supported\n");
return -EINVAL;
}
s->iosize != sizeof(uint32_t))
return dev_err_probe(&pdev->dev, -EINVAL,
"only 8/16/32-bit registers are supported\n");
iprop = of_get_property(np, "mux-mask", &len);
if (!iprop || len != sizeof(uint32_t)) {
dev_err(&pdev->dev, "missing or invalid mux-mask property\n");
return -ENODEV;
}
if (be32_to_cpup(iprop) >= BIT(s->iosize * 8)) {
dev_err(&pdev->dev, "only 8/16/32-bit registers are supported\n");
return -EINVAL;
}
if (!iprop || len != sizeof(uint32_t))
return dev_err_probe(&pdev->dev, -ENODEV,
"missing or invalid mux-mask property\n");
if (be32_to_cpup(iprop) >= BIT(s->iosize * 8))
return dev_err_probe(&pdev->dev, -EINVAL,
"only 8/16/32-bit registers are supported\n");
s->mask = be32_to_cpup(iprop);
/*
......@@ -142,17 +137,14 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
for_each_available_child_of_node_scoped(np, np2) {
u64 reg;
if (of_property_read_reg(np2, 0, &reg, NULL)) {
dev_err(&pdev->dev, "mdio-mux child node %pOF is "
"missing a 'reg' property\n", np2);
return -ENODEV;
}
if ((u32)reg & ~s->mask) {
dev_err(&pdev->dev, "mdio-mux child node %pOF has "
"a 'reg' value with unmasked bits\n",
np2);
return -ENODEV;
}
if (of_property_read_reg(np2, 0, &reg, NULL))
return dev_err_probe(&pdev->dev, -ENODEV,
"mdio-mux child node %pOF is missing a 'reg' property\n",
np2);
if ((u32)reg & ~s->mask)
return dev_err_probe(&pdev->dev, -ENODEV,
"mdio-mux child node %pOF has a 'reg' value with unmasked bits\n",
np2);
}
ret = mdio_mux_init(&pdev->dev, pdev->dev.of_node,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment