From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D22CC54FAA for ; Wed, 28 Aug 2024 14:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:CC:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VQ11qb6TIxMBEfGZP1puPxe5Tf4byZe87Z1ghm78Aws=; b=lWHnrs5c234/R12bhdhBjhomXK l3Q8OIg3Bto5eM6eNuJ6AbNDUNOQZRB1JgVtWzn93HHJZhLLcTMamZfHS2oDLCXlBgDqOAD3AMz1y z4mSz3VqUR27Ooe/Oo19cDXJC0gVueMfuTUWpqU4dJElW5wjVCuYha+XklKbHwmEcwhbrpNZdaadn 8+osm9WTcH9XOZjMdUaFQxC7m2NJwa5ikFvYjsXi0pL9/m66qDCM5mlu0+j/KuXy8peOnHhHFaJvx vmsxH4nuGarr2UYmPntk2WY6d4TduzF279jUYbAeBNZP75mBhPkhKt66U8Je0YyDP5fq7RzfW/HZe VIY42UwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjJE3-0000000Fdhg-09yt; Wed, 28 Aug 2024 14:00:43 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjI63-0000000FNoX-2GfI for linux-arm-kernel@lists.infradead.org; Wed, 28 Aug 2024 12:48:25 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Wv3z01DSdz6H7Wv; Wed, 28 Aug 2024 20:45:00 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 665B814038F; Wed, 28 Aug 2024 20:48:16 +0800 (CST) Received: from localhost (10.203.177.66) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 28 Aug 2024 13:48:15 +0100 Date: Wed, 28 Aug 2024 13:48:14 +0100 From: Jonathan Cameron To: Jinjie Ruan CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH net-next v2 08/13] net: mdio: mux-mmioreg: Simplified with dev_err_probe() Message-ID: <20240828134814.0000569d@Huawei.com> In-Reply-To: <20240828032343.1218749-9-ruanjinjie@huawei.com> References: <20240828032343.1218749-1-ruanjinjie@huawei.com> <20240828032343.1218749-9-ruanjinjie@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240828_054823_902247_4DD84477 X-CRM114-Status: GOOD ( 19.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 28 Aug 2024 11:23:38 +0800 Jinjie Ruan wrote: > Use the dev_err_probe() helper to simplify code. > > Signed-off-by: Jinjie Ruan 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 > --- > 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", 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,