netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: <woojung.huh@microchip.com>, <andrew@lunn.ch>,
	<f.fainelli@gmail.com>, <olteanv@gmail.com>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <linus.walleij@linaro.org>,
	<alsi@bang-olufsen.dk>, <justin.chen@broadcom.com>,
	<sebastian.hesselbarth@gmail.com>, <alexandre.torgue@foss.st.com>,
	<joabreu@synopsys.com>, <mcoquelin.stm32@gmail.com>,
	<wens@csie.org>, <jernej.skrabec@gmail.com>,
	<samuel@sholland.org>, <hkallweit1@gmail.com>,
	<linux@armlinux.org.uk>, <ansuelsmth@gmail.com>,
	<UNGLinuxDriver@microchip.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<bcm-kernel-feedback-list@broadcom.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-sunxi@lists.linux.dev>,
	<linux-stm32@st-md-mailman.stormreply.com>, <krzk@kernel.org>,
	<jic23@kernel.org>
Subject: Re: [PATCH net-next v2 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe()
Date: Wed, 28 Aug 2024 13:48:14 +0100	[thread overview]
Message-ID: <20240828134814.0000569d@Huawei.com> (raw)
In-Reply-To: <20240828032343.1218749-9-ruanjinjie@huawei.com>

On Wed, 28 Aug 2024 11:23:38 +0800
Jinjie Ruan <ruanjinjie@huawei.com> wrote:

> Use the dev_err_probe() helper to simplify code.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Ah. I should have read next patch. Sorry!

Might be worth breaking from rule of aligning parameters
after brackets to keep the longest line lengths down.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
> 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, &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",
I'd align these super long ones as. 
			     "mdio-mux child node %pOF has a 'reg' value with unmasked bits\n",
It is ugly but then so are > 100 char lines.
> +					     np2);
>  	}
>  
>  	ret = mdio_mux_init(&pdev->dev, pdev->dev.of_node,


  reply	other threads:[~2024-08-28 12:48 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28  3:23 [PATCH net-next v2 00/13] net: Simplified with scoped function Jinjie Ruan
2024-08-28  3:23 ` [PATCH net-next v2 01/13] net: stmmac: dwmac-sun8i: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-08-28 12:38   ` Jonathan Cameron
2024-08-28 14:17   ` Andrew Lunn
2024-08-29  2:29     ` Jinjie Ruan
2024-08-28  3:23 ` [PATCH net-next v2 02/13] net: stmmac: dwmac-sun8i: Use __free() to simplify code Jinjie Ruan
2024-08-28 12:38   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 03/13] net: dsa: realtek: Use for_each_child_of_node_scoped() Jinjie Ruan
2024-08-28 12:39   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 04/13] net: dsa: realtek: Use __free() to simplify code Jinjie Ruan
2024-08-28 12:37   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 05/13] net: phy: Fix missing of_node_put() for leds Jinjie Ruan
2024-08-28 12:40   ` Jonathan Cameron
2024-08-28 15:45   ` Willem de Bruijn
2024-08-29  2:46     ` Jinjie Ruan
2024-08-29  2:52     ` Jinjie Ruan
2024-08-28  3:23 ` [PATCH net-next v2 06/13] net: phy: Use for_each_available_child_of_node_scoped() Jinjie Ruan
2024-08-28 12:44   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 07/13] net: mdio: mux-mmioreg: Simplified with scoped function Jinjie Ruan
2024-08-28 12:46   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Jinjie Ruan
2024-08-28 12:48   ` Jonathan Cameron [this message]
2024-08-29  3:11     ` Jinjie Ruan
2024-08-29 12:38       ` Andrew Lunn
2024-08-28  3:23 ` [PATCH net-next v2 09/13] net: mv643xx_eth: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-28 12:49   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 10/13] net: dsa: microchip: Use scoped function to simplfy code Jinjie Ruan
2024-08-28 12:50   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 11/13] net: dsa: microchip: Use __free() " Jinjie Ruan
2024-08-28 12:50   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 12/13] net: bcmasp: Simplify with scoped for each OF child loop Jinjie Ruan
2024-08-28 12:51   ` Jonathan Cameron
2024-08-28  3:23 ` [PATCH net-next v2 13/13] net: bcmasp: Simplify with __free() Jinjie Ruan
2024-08-28 12:53   ` Jonathan Cameron
2024-08-28 14:32 ` [PATCH net-next v2 00/13] net: Simplified with scoped function Andrew Lunn
2024-08-28 14:45   ` Krzysztof Kozlowski
2024-08-28 15:24     ` Andrew Lunn
2024-08-28 18:10     ` Jakub Kicinski
2024-08-29  3:26   ` Jinjie Ruan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240828134814.0000569d@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=alsi@bang-olufsen.dk \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jic23@kernel.org \
    --cc=joabreu@synopsys.com \
    --cc=justin.chen@broadcom.com \
    --cc=krzk@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux@armlinux.org.uk \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=ruanjinjie@huawei.com \
    --cc=samuel@sholland.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=wens@csie.org \
    --cc=woojung.huh@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).