netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: wuych <yunchuan@nfschina.com>
Cc: iyappan@os.amperecomputing.com, keyur@os.amperecomputing.com,
	quan@os.amperecomputing.com, andrew@lunn.ch,
	hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net-next 08/10] net: mdio: Remove unnecessary (void*) conversions
Date: Wed, 28 Jun 2023 10:50:41 +0100	[thread overview]
Message-ID: <ZJwCcWgi0d6kEepI@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230628024517.1440644-1-yunchuan@nfschina.com>

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.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-06-28  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  2:45 [PATCH net-next 08/10] net: mdio: Remove unnecessary (void*) conversions wuych
2023-06-28  9:50 ` Russell King (Oracle) [this message]
2023-06-29  1:59   ` yunchuan
2023-06-29  5:50     ` Dan Carpenter
2023-06-29  6:19       ` yunchuan

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=ZJwCcWgi0d6kEepI@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=iyappan@os.amperecomputing.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=keyur@os.amperecomputing.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quan@os.amperecomputing.com \
    --cc=yunchuan@nfschina.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).