Message ID | 20230628024517.1440644-1-yunchuan@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8616886vqr; Tue, 27 Jun 2023 19:48:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qhz1MTBwNwJEiVeQS6ml+h3eIVFokCXIONrC3wczkwK/CdukfzwmciWBR6Ru+q+LU5wCx X-Received: by 2002:a17:906:5198:b0:987:6960:36c8 with SMTP id y24-20020a170906519800b00987696036c8mr24058940ejk.7.1687920482974; Tue, 27 Jun 2023 19:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687920482; cv=none; d=google.com; s=arc-20160816; b=pTKyLD4oCJWoD3cYP3VgoD4DOVjmzOnL0Pzpj2M+0JYZQgNZRBWJw8LMzf31d12EIa Npbqqo+QTpSG5FcWdrBs7FykL9G8J/XC+kR7Xv55QXEL2/wipPE2UIQFzHLLZ7pJyQO6 hDZY9DktCCP7afXtmeA/8TcP6uo4NB58ygn6DozNguvye80n9dRLayriibO2B+rE7gbh XRofUHLVhPWB/DWav9o86farRkFHMfOhapeIMf8mLaiFRCuMLPZRZrmBd6zgmFCl/AvG 8eUH9R9Ypr7HNTwpkwzKMI+ilmKNlanqNbrSbeuGY9yaIlQBy/ciPQ8MPu68iLJKfOaH hHGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=IOTPRryKmO3r251ieV7fPFuAYGyLkN68MKSEfLEYnJE=; fh=64t3c7CNo8ZCuCPdL/phW3seljCL9cODZCSjKPzDRuM=; b=Gwo8mSOPyb8hDIv0pzHFXmkReXhY3zsBYGNEHGCrw8wCw3O4GoIYdaN27QI6BOR96h NO41p+E4Bco10ZL7FMgvlvZgAXZwGmGioiAMLEQSqf2jct/mT4vDWWP/zaU9RHQSoS6e PiRzT5SJqyqS9loLxusl8CbVUmM+GybRgjp+WH4rGS+iLoU/UUwIs2g99XyD8tbOm1OT uOgJg8991/OzfT390gj7t9A6rHuLXLTX1dZHj2T3Z2ROGtxbul3Uqpsm0Qvqdps3BL3K eH8aRpwuqvoBALhUdNAAvBVJp6CGdHvAe8dUFhYKtEe1ZsPmrnzVfJ5A1BCV2WCGABlR mdig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p23-20020a170906229700b0098f99532dbasi3326567eja.669.2023.06.27.19.47.39; Tue, 27 Jun 2023 19:48:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbjF1Cpu (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Tue, 27 Jun 2023 22:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbjF1Cpa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 27 Jun 2023 22:45:30 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 6CA942D4E; Tue, 27 Jun 2023 19:45:22 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id E5116604D9369; Wed, 28 Jun 2023 10:45:18 +0800 (CST) X-MD-Sfrom: yunchuan@nfschina.com X-MD-SrcIP: 180.167.10.98 From: wuych <yunchuan@nfschina.com> To: iyappan@os.amperecomputing.com, keyur@os.amperecomputing.com, quan@os.amperecomputing.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, wuych <yunchuan@nfschina.com> Subject: [PATCH net-next 08/10] net: mdio: Remove unnecessary (void*) conversions Date: Wed, 28 Jun 2023 10:45:17 +0800 Message-Id: <20230628024517.1440644-1-yunchuan@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769912908516591195?= X-GMAIL-MSGID: =?utf-8?q?1769912908516591195?= |
Series |
Remove unnecessary (void*) conversions
|
|
Commit Message
Wu Yunchuan
June 28, 2023, 2:45 a.m. UTC
Pointer variables of void * type do not require type cast.
Signed-off-by: wuych <yunchuan@nfschina.com>
---
drivers/net/mdio/mdio-xgene.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Hi, I think you missed one case: if (mdio_id == XGENE_MDIO_RGMII) { mdio_bus->read = xgene_mdio_rgmii_read; mdio_bus->write = xgene_mdio_rgmii_write; mdio_bus->priv = (void __force *)pdata; This cast using __force is also not required. On Wed, Jun 28, 2023 at 10:45:17AM +0800, wuych wrote: > @@ -211,7 +211,7 @@ static void xgene_enet_wr_mdio_csr(void __iomem *base_addr, > static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, > int reg, u16 data) > { > - void __iomem *addr = (void __iomem *)bus->priv; > + void __iomem *addr = bus->priv; > int timeout = 100; > u32 status, val; > > @@ -234,7 +234,7 @@ static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, > > static int xgene_xfi_mdio_read(struct mii_bus *bus, int phy_id, int reg) > { > - void __iomem *addr = (void __iomem *)bus->priv; > + void __iomem *addr = bus->priv; > u32 data, status, val; > int timeout = 100; These probably cause Sparse to warn whether or not the cast is there. Given that in this case, bus->priv is initialised via: mdio_bus->priv = (void __force *)pdata->mdio_csr_addr; I think the simple thing is to _always_ initialise mdio_bus->priv to point at pdata, and have xgene_xfi_mdio_*() always do: struct xgene_mdio_pdata *pdata = bus->priv; void __iomem *addr = pdata->mdio_csr_addr; The extra access will be dwarfed by the time taken to perform the access. This change should be made with a separate patch and not combined with the patch removing the casts in xgene_mdio_rgmii_*(). Thanks.
On 2023/6/28 17:50, Russell King (Oracle) wrote: > Hi, > > I think you missed one case: > > if (mdio_id == XGENE_MDIO_RGMII) { > mdio_bus->read = xgene_mdio_rgmii_read; > mdio_bus->write = xgene_mdio_rgmii_write; > mdio_bus->priv = (void __force *)pdata; > > This cast using __force is also not required. > > On Wed, Jun 28, 2023 at 10:45:17AM +0800, wuych wrote: >> @@ -211,7 +211,7 @@ static void xgene_enet_wr_mdio_csr(void __iomem *base_addr, >> static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, >> int reg, u16 data) >> { >> - void __iomem *addr = (void __iomem *)bus->priv; >> + void __iomem *addr = bus->priv; >> int timeout = 100; >> u32 status, val; >> >> @@ -234,7 +234,7 @@ static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, >> >> static int xgene_xfi_mdio_read(struct mii_bus *bus, int phy_id, int reg) >> { >> - void __iomem *addr = (void __iomem *)bus->priv; >> + void __iomem *addr = bus->priv; >> u32 data, status, val; >> int timeout = 100; > These probably cause Sparse to warn whether or not the cast is there. Hi, Russell King, I didn't notice this Sparse warning. Should I remove this cast although it cause Sparse warning? > > Given that in this case, bus->priv is initialised via: > > mdio_bus->priv = (void __force *)pdata->mdio_csr_addr; > > I think the simple thing is to _always_ initialise mdio_bus->priv > to point at pdata, and have xgene_xfi_mdio_*() always do: > > struct xgene_mdio_pdata *pdata = bus->priv; > void __iomem *addr = pdata->mdio_csr_addr; > > The extra access will be dwarfed by the time taken to perform the > access. > > This change should be made with a separate patch and not combined with > the patch removing the casts in xgene_mdio_rgmii_*(). yeah, this change is great. I will send a separate patch as your suggestion If we can ignore Sparse warning. Thanks for your suggestion! wuych > > Thanks. >
On Thu, Jun 29, 2023 at 09:59:56AM +0800, yunchuan wrote: > On 2023/6/28 17:50, Russell King (Oracle) wrote: > > On Wed, Jun 28, 2023 at 10:45:17AM +0800, wuych wrote: > > > @@ -211,7 +211,7 @@ static void xgene_enet_wr_mdio_csr(void __iomem *base_addr, > > > static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, > > > int reg, u16 data) > > > { > > > - void __iomem *addr = (void __iomem *)bus->priv; > > > + void __iomem *addr = bus->priv; > > > int timeout = 100; > > > u32 status, val; > > > @@ -234,7 +234,7 @@ static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, > > > static int xgene_xfi_mdio_read(struct mii_bus *bus, int phy_id, int reg) > > > { > > > - void __iomem *addr = (void __iomem *)bus->priv; > > > + void __iomem *addr = bus->priv; > > > u32 data, status, val; > > > int timeout = 100; > > These probably cause Sparse to warn whether or not the cast is there. > > Hi, Russell King, > > I didn't notice this Sparse warning. > Should I remove this cast although it cause Sparse warning? No. Don't introduce new Sparse warnings. regards, dan carpenter
On 2023/6/29 13:50, Dan Carpenter wrote: > On Thu, Jun 29, 2023 at 09:59:56AM +0800, yunchuan wrote: >> On 2023/6/28 17:50, Russell King (Oracle) wrote: >>> On Wed, Jun 28, 2023 at 10:45:17AM +0800, wuych wrote: >>>> @@ -211,7 +211,7 @@ static void xgene_enet_wr_mdio_csr(void __iomem *base_addr, >>>> static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, >>>> int reg, u16 data) >>>> { >>>> - void __iomem *addr = (void __iomem *)bus->priv; >>>> + void __iomem *addr = bus->priv; >>>> int timeout = 100; >>>> u32 status, val; >>>> @@ -234,7 +234,7 @@ static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, >>>> static int xgene_xfi_mdio_read(struct mii_bus *bus, int phy_id, int reg) >>>> { >>>> - void __iomem *addr = (void __iomem *)bus->priv; >>>> + void __iomem *addr = bus->priv; >>>> u32 data, status, val; >>>> int timeout = 100; >>> These probably cause Sparse to warn whether or not the cast is there. >> Hi, Russell King, >> >> I didn't notice this Sparse warning. >> Should I remove this cast although it cause Sparse warning? > No. Don't introduce new Sparse warnings. Got it, thanks for your answer! wuych > > regards, > dan carpenter >
diff --git a/drivers/net/mdio/mdio-xgene.c b/drivers/net/mdio/mdio-xgene.c index 7aafc221b5cf..aa79464c9d6d 100644 --- a/drivers/net/mdio/mdio-xgene.c +++ b/drivers/net/mdio/mdio-xgene.c @@ -79,7 +79,7 @@ EXPORT_SYMBOL(xgene_mdio_wr_mac); int xgene_mdio_rgmii_read(struct mii_bus *bus, int phy_id, int reg) { - struct xgene_mdio_pdata *pdata = (struct xgene_mdio_pdata *)bus->priv; + struct xgene_mdio_pdata *pdata = bus->priv; u32 data, done; u8 wait = 10; @@ -105,7 +105,7 @@ EXPORT_SYMBOL(xgene_mdio_rgmii_read); int xgene_mdio_rgmii_write(struct mii_bus *bus, int phy_id, int reg, u16 data) { - struct xgene_mdio_pdata *pdata = (struct xgene_mdio_pdata *)bus->priv; + struct xgene_mdio_pdata *pdata = bus->priv; u32 val, done; u8 wait = 10; @@ -211,7 +211,7 @@ static void xgene_enet_wr_mdio_csr(void __iomem *base_addr, static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 data) { - void __iomem *addr = (void __iomem *)bus->priv; + void __iomem *addr = bus->priv; int timeout = 100; u32 status, val; @@ -234,7 +234,7 @@ static int xgene_xfi_mdio_write(struct mii_bus *bus, int phy_id, static int xgene_xfi_mdio_read(struct mii_bus *bus, int phy_id, int reg) { - void __iomem *addr = (void __iomem *)bus->priv; + void __iomem *addr = bus->priv; u32 data, status, val; int timeout = 100;