* [PATCH net-next v3 00/13] net: Simplified with scoped function
@ 2024-08-29 6:31 Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
` (13 more replies)
0 siblings, 14 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Simplify with scoped for each OF child loop and __free(), as well as
dev_err_probe().
Changes in v3:
- Sort the variables, longest first, shortest last.
- Add Reviewed-by.
Changes in v2:
- Subject prefix: next -> net-next.
- Split __free() from scoped for each OF child loop clean.
- Fix use of_node_put() instead of __free() for the 5th patch.
Jinjie Ruan (13):
net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
net: stmmac: dwmac-sun8i: Use __free() to simplify code
net: dsa: realtek: Use for_each_child_of_node_scoped()
net: dsa: realtek: Use __free() to simplify code
net: phy: Fix missing of_node_put() for leds
net: phy: Use for_each_available_child_of_node_scoped()
net: mdio: mux-mmioreg: Simplified with scoped function
net: mdio: mux-mmioreg: Simplified with dev_err_probe()
net: mv643xx_eth: Simplify with scoped for each OF child loop
net: dsa: microchip: Use scoped function to simplfy code
net: dsa: microchip: Use __free() to simplfy code
net: bcmasp: Simplify with scoped for each OF child loop
net: bcmasp: Simplify with __free()
drivers/net/dsa/microchip/ksz_common.c | 12 ++---
drivers/net/dsa/realtek/rtl8366rb.c | 21 +++-----
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 18 +++----
drivers/net/ethernet/marvell/mv643xx_eth.c | 5 +-
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 20 +++-----
drivers/net/mdio/mdio-mux-mmioreg.c | 51 ++++++++-----------
drivers/net/phy/phy_device.c | 7 +--
7 files changed, 51 insertions(+), 83 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:46 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 02/13] net: stmmac: dwmac-sun8i: Use __free() to simplify code Jinjie Ruan
` (12 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using
for_each_child_of_node_scoped(), which can simplfy code.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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] 27+ messages in thread
* [PATCH net-next v3 02/13] net: stmmac: dwmac-sun8i: Use __free() to simplify code
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped() Jinjie Ruan
` (11 subsequent siblings)
13 siblings, 0 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using __free(), which
can simplfy code.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
v3:
- Add Reviewed-by.
---
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 4a0ae92b3055..415a0d23b3a5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -774,19 +774,17 @@ 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_internal;
- struct device_node *mdio_mux;
int ret;
- mdio_mux = of_get_child_by_name(priv->device->of_node, "mdio-mux");
+ struct device_node *mdio_mux __free(device_node) =
+ of_get_child_by_name(priv->device->of_node, "mdio-mux");
if (!mdio_mux) {
dev_err(priv->device, "Cannot get mdio-mux node\n");
return -ENODEV;
}
- mdio_internal = of_get_compatible_child(mdio_mux,
- "allwinner,sun8i-h3-mdio-internal");
- of_node_put(mdio_mux);
+ struct device_node *mdio_internal __free(device_node) =
+ of_get_compatible_child(mdio_mux, "allwinner,sun8i-h3-mdio-internal");
if (!mdio_internal) {
dev_err(priv->device, "Cannot get internal_mdio node\n");
return -ENODEV;
@@ -800,18 +798,14 @@ static int get_ephy_nodes(struct stmmac_priv *priv)
gmac->rst_ephy = of_reset_control_get_exclusive(iphynode, NULL);
if (IS_ERR(gmac->rst_ephy)) {
ret = PTR_ERR(gmac->rst_ephy);
- if (ret == -EPROBE_DEFER) {
- of_node_put(mdio_internal);
+ if (ret == -EPROBE_DEFER)
return ret;
- }
continue;
}
dev_info(priv->device, "Found internal PHY node\n");
- of_node_put(mdio_internal);
return 0;
}
- of_node_put(mdio_internal);
return -ENODEV;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH net-next v3 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped()
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 02/13] net: stmmac: dwmac-sun8i: Use __free() to simplify code Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:47 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 04/13] net: dsa: realtek: Use __free() to simplify code Jinjie Ruan
` (10 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using
for_each_child_of_node_scoped(), which can simplfy code.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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] 27+ messages in thread
* [PATCH net-next v3 04/13] net: dsa: realtek: Use __free() to simplify code
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (2 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 05/13] net: phy: Fix missing of_node_put() for leds Jinjie Ruan
` (9 subsequent siblings)
13 siblings, 0 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using __free(), which
can simplfy code.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
---
v3:
- Move "return ret" up to the only place it can come from.
- Use ret only in the loop.
v2
- Split into 2 patches.
---
drivers/net/dsa/realtek/rtl8366rb.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/net/dsa/realtek/rtl8366rb.c b/drivers/net/dsa/realtek/rtl8366rb.c
index 11243f89c98a..31d2d5356c1e 100644
--- a/drivers/net/dsa/realtek/rtl8366rb.c
+++ b/drivers/net/dsa/realtek/rtl8366rb.c
@@ -1010,15 +1010,14 @@ static int rtl8366rb_setup_all_leds_off(struct realtek_priv *priv)
static int rtl8366rb_setup_leds(struct realtek_priv *priv)
{
struct dsa_switch *ds = &priv->ds;
- struct device_node *leds_np;
struct dsa_port *dp;
- int ret = 0;
dsa_switch_for_each_port(dp, ds) {
if (!dp->dn)
continue;
- leds_np = of_get_child_by_name(dp->dn, "leds");
+ struct device_node *leds_np __free(device_node) =
+ of_get_child_by_name(dp->dn, "leds");
if (!leds_np) {
dev_dbg(priv->dev, "No leds defined for port %d",
dp->index);
@@ -1026,15 +1025,11 @@ static int rtl8366rb_setup_leds(struct realtek_priv *priv)
}
for_each_child_of_node_scoped(leds_np, led_np) {
- ret = rtl8366rb_setup_led(priv, dp,
- of_fwnode_handle(led_np));
+ int ret = rtl8366rb_setup_led(priv, dp,
+ of_fwnode_handle(led_np));
if (ret)
- break;
+ return ret;
}
-
- of_node_put(leds_np);
- if (ret)
- return ret;
}
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH net-next v3 05/13] net: phy: Fix missing of_node_put() for leds
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (3 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 04/13] net: dsa: realtek: Use __free() to simplify code Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:50 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 06/13] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
` (8 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
The call of of_get_child_by_name() will cause refcount incremented
for leds, if it succeeds, it should call of_node_put() to decrease
it, fix it.
Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
- Use of_node_put() rather than __free() to fix it.
---
drivers/net/phy/phy_device.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 8f5314c1fecc..243dae686992 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3424,11 +3424,13 @@ static int of_phy_leds(struct phy_device *phydev)
err = of_phy_led(phydev, led);
if (err) {
of_node_put(led);
+ of_node_put(leds);
phy_leds_unregister(phydev);
return err;
}
}
+ of_node_put(leds);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH net-next v3 06/13] net: phy: Use for_each_available_child_of_node_scoped()
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (4 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 05/13] net: phy: Fix missing of_node_put() for leds Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:50 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 07/13] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
` (7 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, 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.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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 243dae686992..560e338b307a 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);
of_node_put(leds);
phy_leds_unregister(phydev);
return err;
--
2.34.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH net-next v3 07/13] net: mdio: mux-mmioreg: Simplified with scoped function
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (5 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 06/13] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:51 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
` (6 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, 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().
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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] 27+ messages in thread
* [PATCH net-next v3 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (6 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 07/13] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:53 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
` (5 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Use the dev_err_probe() helper to simplify code.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/mdio/mdio-mux-mmioreg.c | 45 ++++++++++++-----------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/drivers/net/mdio/mdio-mux-mmioreg.c b/drivers/net/mdio/mdio-mux-mmioreg.c
index 4d87e61fec7b..08c484ccdcbe 100644
--- a/drivers/net/mdio/mdio-mux-mmioreg.c
+++ b/drivers/net/mdio/mdio-mux-mmioreg.c
@@ -109,30 +109,26 @@ 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;
+ 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 +138,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] 27+ messages in thread
* [PATCH net-next v3 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (7 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:53 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 10/13] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
` (4 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Use scoped for_each_available_child_of_node_scoped() when iterating
over device nodes to make code a bit simpler.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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] 27+ messages in thread
* [PATCH net-next v3 10/13] net: dsa: microchip: Use scoped function to simplfy code
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (8 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:54 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 11/13] net: dsa: microchip: Use __free() " Jinjie Ruan
` (3 subsequent siblings)
13 siblings, 1 reply; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, 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().
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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] 27+ messages in thread
* [PATCH net-next v3 11/13] net: dsa: microchip: Use __free() to simplfy code
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (9 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 10/13] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
` (2 subsequent siblings)
13 siblings, 0 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Avoids the need for manual cleanup of_node_put() by using __free().
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/dsa/microchip/ksz_common.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 86ed563938f6..8058a0b7c161 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -4595,7 +4595,6 @@ 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 *ports;
phy_interface_t interface;
unsigned int port_num;
int ret;
@@ -4677,7 +4676,8 @@ int ksz_switch_register(struct ksz_device *dev)
ret = of_get_phy_mode(dev->dev->of_node, &interface);
if (ret == 0)
dev->compat_interface = interface;
- ports = of_get_child_by_name(dev->dev->of_node, "ethernet-ports");
+ struct device_node *ports __free(device_node) =
+ of_get_child_by_name(dev->dev->of_node, "ethernet-ports");
if (!ports)
ports = of_get_child_by_name(dev->dev->of_node, "ports");
if (ports) {
@@ -4685,16 +4685,13 @@ int ksz_switch_register(struct ksz_device *dev)
if (of_property_read_u32(port, "reg",
&port_num))
continue;
- if (!(dev->port_mask & BIT(port_num))) {
- of_node_put(ports);
+ if (!(dev->port_mask & BIT(port_num)))
return -EINVAL;
- }
of_get_phy_mode(port,
&dev->ports[port_num].interface);
ksz_parse_rgmii_delay(dev, port_num, port);
}
- of_node_put(ports);
}
dev->synclko_125 = of_property_read_bool(dev->dev->of_node,
"microchip,synclko-125");
--
2.34.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (10 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 11/13] net: dsa: microchip: Use __free() " Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:54 ` Andrew Lunn
` (2 more replies)
2024-08-29 6:31 ` [PATCH net-next v3 13/13] net: bcmasp: Simplify with __free() Jinjie Ruan
2024-08-29 12:43 ` [PATCH net-next v3 00/13] net: Simplified with scoped function Andrew Lunn
13 siblings, 3 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Use scoped for_each_available_child_of_node_scoped() when
iterating over device nodes to make code a bit simpler.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
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] 27+ messages in thread
* [PATCH net-next v3 13/13] net: bcmasp: Simplify with __free()
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (11 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-08-29 6:31 ` Jinjie Ruan
2024-08-29 12:43 ` [PATCH net-next v3 00/13] net: Simplified with scoped function Andrew Lunn
13 siblings, 0 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-29 6:31 UTC (permalink / raw)
To: woojung.huh, andrew, f.fainelli, olteanv, davem, edumazet, kuba,
pabeni, linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
Cc: ruanjinjie
Avoid need to manually handle of_node_put() by using __free(), which
can simplfy code.
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
v3:
- Add Reviewed-by.
v2:
- Split into 2 patches.
---
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
index 297c2682a9cf..73e767aada2f 100644
--- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c
+++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
@@ -1302,7 +1302,6 @@ static int bcmasp_probe(struct platform_device *pdev)
{
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;
@@ -1367,7 +1366,8 @@ static int bcmasp_probe(struct platform_device *pdev)
bcmasp_core_init(priv);
bcmasp_core_init_filters(priv);
- ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");
+ struct device_node *ports_node __free(device_node) =
+ of_find_node_by_name(dev->of_node, "ethernet-ports");
if (!ports_node) {
dev_warn(dev, "No ports found\n");
return -EINVAL;
@@ -1377,10 +1377,9 @@ static int bcmasp_probe(struct platform_device *pdev)
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);
- ret = -ENOMEM;
- goto of_put_exit;
+ return dev_err_probe(dev, -ENOMEM,
+ "Cannot create eth interface %d\n", i);
}
list_add_tail(&intf->list, &priv->intfs);
i++;
@@ -1406,16 +1405,14 @@ static int bcmasp_probe(struct platform_device *pdev)
"failed to register net_device: %d\n", ret);
priv->destroy_wol(priv);
bcmasp_remove_intfs(priv);
- goto of_put_exit;
+ return ret;
}
count++;
}
dev_info(dev, "Initialized %d port(s)\n", count);
-of_put_exit:
- of_node_put(ports_node);
- return ret;
+ return 0;
}
static void bcmasp_remove(struct platform_device *pdev)
--
2.34.1
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 00/13] net: Simplified with scoped function
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
` (12 preceding siblings ...)
2024-08-29 6:31 ` [PATCH net-next v3 13/13] net: bcmasp: Simplify with __free() Jinjie Ruan
@ 2024-08-29 12:43 ` Andrew Lunn
2024-08-30 2:03 ` Jinjie Ruan
13 siblings, 1 reply; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:43 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:05PM +0800, Jinjie Ruan wrote:
> Simplify with scoped for each OF child loop and __free(), as well as
> dev_err_probe().
I said the for_each_child_of_node_scoped() parts are fine. The
__free() parts are ugly, and i would like to reject them. So please
post just the for_each_child_of_node_scoped() parts for merging, while
we discuss what to do about __free().
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped()
2024-08-29 6:31 ` [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-08-29 12:46 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:46 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:06PM +0800, Jinjie Ruan wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_child_of_node_scoped(), which can simplfy code.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Your Signed-off-by: should always be last. I've posted this comment to
quite a few patches to netdev over the last couple of days. Are you
not reading the list?
With that corrected, please add my:
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped()
2024-08-29 6:31 ` [PATCH net-next v3 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped() Jinjie Ruan
@ 2024-08-29 12:47 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:47 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:08PM +0800, Jinjie Ruan wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_child_of_node_scoped(), which can simplfy code.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 05/13] net: phy: Fix missing of_node_put() for leds
2024-08-29 6:31 ` [PATCH net-next v3 05/13] net: phy: Fix missing of_node_put() for leds Jinjie Ruan
@ 2024-08-29 12:50 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:50 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:10PM +0800, Jinjie Ruan wrote:
> The call of of_get_child_by_name() will cause refcount incremented
> for leds, if it succeeds, it should call of_node_put() to decrease
> it, fix it.
>
> Fixes: 01e5b728e9e4 ("net: phy: Add a binding for PHY LEDs")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This is a fix. You were asked to break it out of the series, and post
it to net, not net-next.
Jonathan, please could you step in and do some mentoring. Huawei is
big enough it should not need Maintainers to teach its developers the
basics.
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 06/13] net: phy: Use for_each_available_child_of_node_scoped()
2024-08-29 6:31 ` [PATCH net-next v3 06/13] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
@ 2024-08-29 12:50 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:50 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:11PM +0800, Jinjie Ruan wrote:
> Avoid need to manually handle of_node_put() by using
> for_each_available_child_of_node_scoped(), which can simplfy code.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 07/13] net: mdio: mux-mmioreg: Simplified with scoped function
2024-08-29 6:31 ` [PATCH net-next v3 07/13] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
@ 2024-08-29 12:51 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:51 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:12PM +0800, 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().
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
2024-08-29 6:31 ` [PATCH net-next v3 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
@ 2024-08-29 12:53 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:53 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
> 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;
> + return dev_err_probe(&pdev->dev, -EINVAL,
> + "only 8/16/32-bit registers are supported\n");
Please think about this change. Why is it wrong?
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop
2024-08-29 6:31 ` [PATCH net-next v3 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-08-29 12:53 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:53 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:14PM +0800, Jinjie Ruan wrote:
> Use scoped for_each_available_child_of_node_scoped() when iterating
> over device nodes to make code a bit simpler.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 10/13] net: dsa: microchip: Use scoped function to simplfy code
2024-08-29 6:31 ` [PATCH net-next v3 10/13] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
@ 2024-08-29 12:54 ` Andrew Lunn
0 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:54 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:15PM +0800, 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().
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop
2024-08-29 6:31 ` [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
@ 2024-08-29 12:54 ` Andrew Lunn
2024-08-29 20:54 ` Justin Chen
2024-08-29 22:16 ` Florian Fainelli
2 siblings, 0 replies; 27+ messages in thread
From: Andrew Lunn @ 2024-08-29 12:54 UTC (permalink / raw)
To: Jinjie Ruan
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On Thu, Aug 29, 2024 at 02:31:17PM +0800, Jinjie Ruan wrote:
> Use scoped for_each_available_child_of_node_scoped() when
> iterating over device nodes to make code a bit simpler.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop
2024-08-29 6:31 ` [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-29 12:54 ` Andrew Lunn
@ 2024-08-29 20:54 ` Justin Chen
2024-08-29 22:16 ` Florian Fainelli
2 siblings, 0 replies; 27+ messages in thread
From: Justin Chen @ 2024-08-29 20:54 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, f.fainelli, olteanv, davem,
edumazet, kuba, pabeni, linus.walleij, alsi,
sebastian.hesselbarth, alexandre.torgue, joabreu, wens,
jernej.skrabec, samuel, mcoquelin.stm32, hkallweit1, linux,
ansuelsmth, UNGLinuxDriver, netdev, bcm-kernel-feedback-list,
linux-stm32, linux-arm-kernel, linux-sunxi, krzk, jic23
On 8/28/24 11:31 PM, 'Jinjie Ruan' via BCM-KERNEL-FEEDBACK-LIST,PDL wrote:
> Use scoped for_each_available_child_of_node_scoped() when
> iterating over device nodes to make code a bit simpler.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Justin Chen <justin.chen@broadcom.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop
2024-08-29 6:31 ` [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-29 12:54 ` Andrew Lunn
2024-08-29 20:54 ` Justin Chen
@ 2024-08-29 22:16 ` Florian Fainelli
2 siblings, 0 replies; 27+ messages in thread
From: Florian Fainelli @ 2024-08-29 22:16 UTC (permalink / raw)
To: Jinjie Ruan, woojung.huh, andrew, f.fainelli, olteanv, davem,
edumazet, kuba, pabeni, linus.walleij, alsi, justin.chen,
sebastian.hesselbarth, alexandre.torgue, joabreu, wens,
jernej.skrabec, samuel, mcoquelin.stm32, hkallweit1, linux,
ansuelsmth, UNGLinuxDriver, netdev, bcm-kernel-feedback-list,
linux-stm32, linux-arm-kernel, linux-sunxi, krzk, jic23
On 8/28/24 23:31, 'Jinjie Ruan' via BCM-KERNEL-FEEDBACK-LIST,PDL wrote:
> Use scoped for_each_available_child_of_node_scoped() when
> iterating over device nodes to make code a bit simpler.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH net-next v3 00/13] net: Simplified with scoped function
2024-08-29 12:43 ` [PATCH net-next v3 00/13] net: Simplified with scoped function Andrew Lunn
@ 2024-08-30 2:03 ` Jinjie Ruan
0 siblings, 0 replies; 27+ messages in thread
From: Jinjie Ruan @ 2024-08-30 2:03 UTC (permalink / raw)
To: Andrew Lunn
Cc: woojung.huh, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
linus.walleij, alsi, justin.chen, sebastian.hesselbarth,
alexandre.torgue, joabreu, wens, jernej.skrabec, samuel,
mcoquelin.stm32, hkallweit1, linux, ansuelsmth, UNGLinuxDriver,
netdev, bcm-kernel-feedback-list, linux-stm32, linux-arm-kernel,
linux-sunxi, krzk, jic23
On 2024/8/29 20:43, Andrew Lunn wrote:
> On Thu, Aug 29, 2024 at 02:31:05PM +0800, Jinjie Ruan wrote:
>> Simplify with scoped for each OF child loop and __free(), as well as
>> dev_err_probe().
>
> I said the for_each_child_of_node_scoped() parts are fine. The
> __free() parts are ugly, and i would like to reject them. So please
> post just the for_each_child_of_node_scoped() parts for merging, while
> we discuss what to do about __free().
Sure.
>
> Andrew
>
> ---
> pw-bot: cr
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2024-08-30 2:03 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29 6:31 [PATCH net-next v3 00/13] net: Simplified with scoped function Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-08-29 12:46 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 02/13] net: stmmac: dwmac-sun8i: Use __free() to simplify code Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-08-29 12:47 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 04/13] net: dsa: realtek: Use __free() to simplify code Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 05/13] net: phy: Fix missing of_node_put() for leds Jinjie Ruan
2024-08-29 12:50 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 06/13] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
2024-08-29 12:50 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 07/13] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
2024-08-29 12:51 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
2024-08-29 12:53 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-29 12:53 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 10/13] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
2024-08-29 12:54 ` Andrew Lunn
2024-08-29 6:31 ` [PATCH net-next v3 11/13] net: dsa: microchip: Use __free() " Jinjie Ruan
2024-08-29 6:31 ` [PATCH net-next v3 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-29 12:54 ` Andrew Lunn
2024-08-29 20:54 ` Justin Chen
2024-08-29 22:16 ` Florian Fainelli
2024-08-29 6:31 ` [PATCH net-next v3 13/13] net: bcmasp: Simplify with __free() Jinjie Ruan
2024-08-29 12:43 ` [PATCH net-next v3 00/13] net: Simplified with scoped function Andrew Lunn
2024-08-30 2:03 ` Jinjie Ruan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).