* [PATCH net-next v4 1/8] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 15:26 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 2/8] net: dsa: realtek: " Jinjie Ruan
` (7 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using
for_each_child_of_node_scoped(), which can simplfy code.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Add Reviewed-by.
- Signed-off-by: should always be last.
v3:
- Sort the variables, longest first, shortest last
- Add Reviewed-by.
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index cc93f73a380e..4a0ae92b3055 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -774,8 +774,8 @@ static int sun8i_dwmac_reset(struct stmmac_priv *priv)
static int get_ephy_nodes(struct stmmac_priv *priv)
{
struct sunxi_priv_data *gmac = priv->plat->bsp_priv;
- struct device_node *mdio_mux, *iphynode;
struct device_node *mdio_internal;
+ struct device_node *mdio_mux;
int ret;
mdio_mux = of_get_child_by_name(priv->device->of_node, "mdio-mux");
@@ -793,7 +793,7 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
}
/* Seek for internal PHY */
- for_each_child_of_node(mdio_internal, iphynode) {
+ for_each_child_of_node_scoped(mdio_internal, iphynode) {
gmac->ephy_clk = of_clk_get(iphynode, 0);
if (IS_ERR(gmac->ephy_clk))
continue;
@@ -801,14 +801,12 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
if (IS_ERR(gmac->rst_ephy)) {
ret = PTR_ERR(gmac->rst_ephy);
if (ret == -EPROBE_DEFER) {
- of_node_put(iphynode);
of_node_put(mdio_internal);
return ret;
}
continue;
}
dev_info(priv->device, "Found internal PHY node\n");
- of_node_put(iphynode);
of_node_put(mdio_internal);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 1/8] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
2024-08-30 3:13 ` [PATCH net-next v4 1/8] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-09-02 15:26 ` Florian Fainelli
0 siblings, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:26 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_child_of_node_scoped(), which can simplfy code.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 2/8] net: dsa: realtek: Use for_each_child_of_node_scoped()
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
2024-08-30 3:13 ` [PATCH net-next v4 1/8] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 8:22 ` Linus Walleij
2024-09-02 15:26 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 3/8] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
` (6 subsequent siblings)
8 siblings, 2 replies; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using
for_each_child_of_node_scoped(), which can simplfy code.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Add Reviewed-by.
- Signed-off-by: should always be last.
v3:
- Sort the variables, longest first, shortest last
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/dsa/realtek/rtl8366rb.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c
index 9e821b42e5f3..11243f89c98a 100644
--- a/drivers/net/dsa/realtek/rtl8366rb.c
+++ b/drivers/net/dsa/realtek/rtl8366rb.c
@@ -1009,8 +1009,8 @@ static int rtl8366rb_setup_all_leds_off(struct realtek_priv *priv)
static int rtl8366rb_setup_leds(struct realtek_priv *priv)
{
- struct device_node *leds_np, *led_np;
struct dsa_switch *ds = &priv->ds;
+ struct device_node *leds_np;
struct dsa_port *dp;
int ret = 0;
@@ -1025,13 +1025,11 @@ static int rtl8366rb_setup_leds(struct realtek_priv *priv)
continue;
}
- for_each_child_of_node(leds_np, led_np) {
+ for_each_child_of_node_scoped(leds_np, led_np) {
ret = rtl8366rb_setup_led(priv, dp,
of_fwnode_handle(led_np));
- if (ret) {
- of_node_put(led_np);
+ if (ret)
break;
- }
}
of_node_put(leds_np);
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 2/8] net: dsa: realtek: Use for_each_child_of_node_scoped()
2024-08-30 3:13 ` [PATCH net-next v4 2/8] net: dsa: realtek: " Jinjie Ruan
@ 2024-09-02 8:22 ` Linus Walleij
2024-09-02 15:26 ` Florian Fainelli
1 sibling, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2024-09-02 8:22 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On Fri, Aug 30, 2024 at 5:06 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_child_of_node_scoped(), which can simplfy code.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net-next v4 2/8] net: dsa: realtek: Use for_each_child_of_node_scoped()
2024-08-30 3:13 ` [PATCH net-next v4 2/8] net: dsa: realtek: " Jinjie Ruan
2024-09-02 8:22 ` Linus Walleij
@ 2024-09-02 15:26 ` Florian Fainelli
1 sibling, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:26 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_child_of_node_scoped(), which can simplfy code.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 3/8] net: phy: Use for_each_available_child_of_node_scoped()
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
2024-08-30 3:13 ` [PATCH net-next v4 1/8] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-08-30 3:13 ` [PATCH net-next v4 2/8] net: dsa: realtek: " Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 15:26 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 4/8] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
` (5 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using
for_each_available_child_of_node_scoped(), which can simplfy code.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Rebased on the previous fix patch has been stripped out.
- Add Reviewed-by.
v3:
- Add Reviewed-by
v2
- Split into 2 patches.
---
drivers/net/phy/phy_device.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8f5314c1fecc..7c4a09455493 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3407,7 +3407,7 @@ static int of_phy_led(struct phy_device *phydev,
static int of_phy_leds(struct phy_device *phydev)
{
struct device_node *node = phydev->mdio.dev.of_node;
- struct device_node *leds, *led;
+ struct device_node *leds;
int err;
if (!IS_ENABLED(CONFIG_OF_MDIO))
@@ -3420,10 +3420,9 @@ static int of_phy_leds(struct phy_device *phydev)
if (!leds)
return 0;
- for_each_available_child_of_node(leds, led) {
+ for_each_available_child_of_node_scoped(leds, led) {
err = of_phy_led(phydev, led);
if (err) {
- of_node_put(led);
phy_leds_unregister(phydev);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 3/8] net: phy: Use for_each_available_child_of_node_scoped()
2024-08-30 3:13 ` [PATCH net-next v4 3/8] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
@ 2024-09-02 15:26 ` Florian Fainelli
0 siblings, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:26 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_available_child_of_node_scoped(), which can simplfy code.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 4/8] net: mdio: mux-mmioreg: Simplified with scoped function
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
` (2 preceding siblings ...)
2024-08-30 3:13 ` [PATCH net-next v4 3/8] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 15:27 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
` (4 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Avoids the need for manual cleanup of_node_put() in early exits
from the loop by using for_each_available_child_of_node_scoped().
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Add Reviewed-by.
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/mdio/mdio-mux-mmioreg.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mdio/mdio-mux-mmioreg.c b/drivers/net/mdio/mdio-mux-mmioreg.c
index de08419d0c98..4d87e61fec7b 100644
--- a/drivers/net/mdio/mdio-mux-mmioreg.c
+++ b/drivers/net/mdio/mdio-mux-mmioreg.c
@@ -96,7 +96,7 @@ static int mdio_mux_mmioreg_switch_fn(int current_child, int desired_child,
static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
{
- struct device_node *np2, *np = pdev->dev.of_node;
+ struct device_node *np = pdev->dev.of_node;
struct mdio_mux_mmioreg_state *s;
struct resource res;
const __be32 *iprop;
@@ -139,20 +139,18 @@ static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
* Verify that the 'reg' property of each child MDIO bus does not
* set any bits outside of the 'mask'.
*/
- for_each_available_child_of_node(np, np2) {
+ for_each_available_child_of_node_scoped(np, np2) {
u64 reg;
if (of_property_read_reg(np2, 0, ®, NULL)) {
dev_err(&pdev->dev, "mdio-mux child node %pOF is "
"missing a 'reg' property\n", np2);
- of_node_put(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);
- of_node_put(np2);
return -ENODEV;
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 4/8] net: mdio: mux-mmioreg: Simplified with scoped function
2024-08-30 3:13 ` [PATCH net-next v4 4/8] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
@ 2024-09-02 15:27 ` Florian Fainelli
0 siblings, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:27 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Avoids the need for manual cleanup of_node_put() in early exits
> from the loop by using for_each_available_child_of_node_scoped().
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
` (3 preceding siblings ...)
2024-08-30 3:13 ` [PATCH net-next v4 4/8] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 15:29 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 6/8] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
` (3 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Use the dev_err_probe() helper to simplify code.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Remove the extra parentheses.
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/mdio/mdio-mux-mmioreg.c | 48 ++++++++++++-----------------
1 file changed, 20 insertions(+), 28 deletions(-)
diff --git a/drivers/net/mdio/mdio-mux-mmioreg.c b/drivers/net/mdio/mdio-mux-mmioreg.c
index 4d87e61fec7b..b70e6d1ad429 100644
--- a/drivers/net/mdio/mdio-mux-mmioreg.c
+++ b/drivers/net/mdio/mdio-mux-mmioreg.c
@@ -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, ®, 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, ®, 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,
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
2024-08-30 3:13 ` [PATCH net-next v4 5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
@ 2024-09-02 15:29 ` Florian Fainelli
2024-09-03 12:53 ` Andrew Lunn
0 siblings, 1 reply; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:29 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Use the dev_err_probe() helper to simplify code.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v4:
> - Remove the extra parentheses.
> v3:
> - Add Reviewed-by.
> v2:
> - Split into 2 patches.
> ---
> drivers/net/mdio/mdio-mux-mmioreg.c | 48 ++++++++++++-----------------
> 1 file changed, 20 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/mdio/mdio-mux-mmioreg.c b/drivers/net/mdio/mdio-mux-mmioreg.c
> index 4d87e61fec7b..b70e6d1ad429 100644
> --- a/drivers/net/mdio/mdio-mux-mmioreg.c
> +++ b/drivers/net/mdio/mdio-mux-mmioreg.c
> @@ -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);
Besides that one, which I don't think is even a candidate for resource
deferral in the first place given the OF platform implementation, it
does not seem to help that much to switch to dev_err_probe() other than
just combining the error message and return code in a single statement.
So it's fewer lines of codes, but it is not exactly what dev_err_probe()
was originally intended for IMHO.
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
2024-09-02 15:29 ` Florian Fainelli
@ 2024-09-03 12:53 ` Andrew Lunn
0 siblings, 0 replies; 19+ messages in thread
From: Andrew Lunn @ 2024-09-03 12:53 UTC (permalink / raw)
To: Florian Fainelli
Cc: Jinjie Ruan, woojung.huh, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
> > @@ -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);
>
> Besides that one, which I don't think is even a candidate for resource
> deferral in the first place given the OF platform implementation, it does
> not seem to help that much to switch to dev_err_probe() other than just
> combining the error message and return code in a single statement. So it's
> fewer lines of codes, but it is not exactly what dev_err_probe() was
> originally intended for IMHO.
Agreed. Rather than abuse dev_err_probe(), maybe a dev_err_error()
would be added with the same prototype, does the same formatting, and
skips all the PROBE_DEFFER logic. The problem would be, it would
encourage more of this churn.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 6/8] net: mv643xx_eth: Simplify with scoped for each OF child loop
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
` (4 preceding siblings ...)
2024-08-30 3:13 ` [PATCH net-next v4 5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 15:29 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 7/8] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
` (2 subsequent siblings)
8 siblings, 1 reply; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Use scoped for_each_available_child_of_node_scoped() when iterating
over device nodes to make code a bit simpler.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Add Reviewed-by.
v3:
- Add Reviewed-by.
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index f35ae2c88091..9e80899546d9 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2802,7 +2802,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
{
struct mv643xx_eth_shared_platform_data *pd;
- struct device_node *pnp, *np = pdev->dev.of_node;
+ struct device_node *np = pdev->dev.of_node;
int ret;
/* bail out if not registered from DT */
@@ -2816,10 +2816,9 @@ static int mv643xx_eth_shared_of_probe(struct platform_device *pdev)
mv643xx_eth_property(np, "tx-checksum-limit", pd->tx_csum_limit);
- for_each_available_child_of_node(np, pnp) {
+ for_each_available_child_of_node_scoped(np, pnp) {
ret = mv643xx_eth_shared_of_add_port(pdev, pnp);
if (ret) {
- of_node_put(pnp);
mv643xx_eth_shared_of_remove();
return ret;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 6/8] net: mv643xx_eth: Simplify with scoped for each OF child loop
2024-08-30 3:13 ` [PATCH net-next v4 6/8] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-09-02 15:29 ` Florian Fainelli
0 siblings, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:29 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Use scoped for_each_available_child_of_node_scoped() when iterating
> over device nodes to make code a bit simpler.
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 7/8] net: dsa: microchip: Use scoped function to simplfy code
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
` (5 preceding siblings ...)
2024-08-30 3:13 ` [PATCH net-next v4 6/8] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-02 15:29 ` Florian Fainelli
2024-08-30 3:13 ` [PATCH net-next v4 8/8] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
2024-09-03 11:00 ` [PATCH net-next v4 0/8] net: Simplified with scoped function patchwork-bot+netdevbpf
8 siblings, 1 reply; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Avoids the need for manual cleanup of_node_put() in early exits
from the loop by using for_each_available_child_of_node_scoped().
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Add Reviewed-by.
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/dsa/microchip/ksz_common.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index cd3991792b69..86ed563938f6 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -4595,7 +4595,7 @@ static int ksz_parse_drive_strength(struct ksz_device *dev)
int ksz_switch_register(struct ksz_device *dev)
{
const struct ksz_chip_data *info;
- struct device_node *port, *ports;
+ struct device_node *ports;
phy_interface_t interface;
unsigned int port_num;
int ret;
@@ -4681,12 +4681,11 @@ int ksz_switch_register(struct ksz_device *dev)
if (!ports)
ports = of_get_child_by_name(dev->dev->of_node, "ports");
if (ports) {
- for_each_available_child_of_node(ports, port) {
+ for_each_available_child_of_node_scoped(ports, port) {
if (of_property_read_u32(port, "reg",
&port_num))
continue;
if (!(dev->port_mask & BIT(port_num))) {
- of_node_put(port);
of_node_put(ports);
return -EINVAL;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 7/8] net: dsa: microchip: Use scoped function to simplfy code
2024-08-30 3:13 ` [PATCH net-next v4 7/8] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
@ 2024-09-02 15:29 ` Florian Fainelli
0 siblings, 0 replies; 19+ messages in thread
From: Florian Fainelli @ 2024-09-02 15:29 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
On 8/29/2024 8:13 PM, Jinjie Ruan wrote:
> Avoids the need for manual cleanup of_node_put() in early exits
> from the loop by using for_each_available_child_of_node_scoped().
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net-next v4 8/8] net: bcmasp: Simplify with scoped for each OF child loop
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
` (6 preceding siblings ...)
2024-08-30 3:13 ` [PATCH net-next v4 7/8] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
@ 2024-08-30 3:13 ` Jinjie Ruan
2024-09-03 11:00 ` [PATCH net-next v4 0/8] net: Simplified with scoped function patchwork-bot+netdevbpf
8 siblings, 0 replies; 19+ messages in thread
From: Jinjie Ruan @ 2024-08-30 3:13 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Cc: ruanjinjie
Use scoped for_each_available_child_of_node_scoped() when
iterating over device nodes to make code a bit simpler.
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Justin Chen <justin.chen@broadcom.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v4:
- Add Reviewed-by.
v3:
- Sort the variables, longest first, shortest last.
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index 20c6529ec135..297c2682a9cf 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -1300,9 +1300,9 @@ static void bcmasp_remove_intfs(struct bcmasp_priv *priv)
static int bcmasp_probe(struct platform_device *pdev)
{
- struct device_node *ports_node, *intf_node;
const struct bcmasp_plat_data *pdata;
struct device *dev = &pdev->dev;
+ struct device_node *ports_node;
struct bcmasp_priv *priv;
struct bcmasp_intf *intf;
int ret = 0, count = 0;
@@ -1374,12 +1374,11 @@ static int bcmasp_probe(struct platform_device *pdev)
}
i = 0;
- for_each_available_child_of_node(ports_node, intf_node) {
+ for_each_available_child_of_node_scoped(ports_node, intf_node) {
intf = bcmasp_interface_create(priv, intf_node, i);
if (!intf) {
dev_err(dev, "Cannot create eth interface %d\n", i);
bcmasp_remove_intfs(priv);
- of_node_put(intf_node);
ret = -ENOMEM;
goto of_put_exit;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH net-next v4 0/8] net: Simplified with scoped function
2024-08-30 3:13 [PATCH net-next v4 0/8] net: Simplified with scoped function Jinjie Ruan
` (7 preceding siblings ...)
2024-08-30 3:13 ` [PATCH net-next v4 8/8] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-09-03 11:00 ` patchwork-bot+netdevbpf
8 siblings, 0 replies; 19+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-03 11:00 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, mcoquelin.stm32, wens, jernej.skrabec,
samuel, hkallweit1, linux, UNGLinuxDriver, netdev,
bcm-kernel-feedback-list, linux-arm-kernel, linux-sunxi,
linux-stm32, krzk, jic23
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Fri, 30 Aug 2024 11:13:17 +0800 you wrote:
> Simplify with scoped for each OF child loop, as well as dev_err_probe().
>
> Changes in v4:
> - Drop the fix patch and __free() patch.
> - Rebased on the fix patch has been stripped out.
> - Remove the extra parentheses.
> - Ensure Signed-off-by: should always be last.
> - Add Reviewed-by.
> - Update the cover letter commit message.
>
> [...]
Here is the summary with links:
- [net-next,v4,1/8] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
https://git.kernel.org/netdev/net-next/c/81b4eb62878a
- [net-next,v4,2/8] net: dsa: realtek: Use for_each_child_of_node_scoped()
https://git.kernel.org/netdev/net-next/c/51c884291a94
- [net-next,v4,3/8] net: phy: Use for_each_available_child_of_node_scoped()
https://git.kernel.org/netdev/net-next/c/1dce520abd46
- [net-next,v4,4/8] net: mdio: mux-mmioreg: Simplified with scoped function
https://git.kernel.org/netdev/net-next/c/b00f7f4f8e93
- [net-next,v4,5/8] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
https://git.kernel.org/netdev/net-next/c/4078513fc86c
- [net-next,v4,6/8] net: mv643xx_eth: Simplify with scoped for each OF child loop
https://git.kernel.org/netdev/net-next/c/3a3eea209e6d
- [net-next,v4,7/8] net: dsa: microchip: Use scoped function to simplfy code
https://git.kernel.org/netdev/net-next/c/f834d572b7e9
- [net-next,v4,8/8] net: bcmasp: Simplify with scoped for each OF child loop
https://git.kernel.org/netdev/net-next/c/e8ac8974451e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 19+ messages in thread