All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 net-next 01/10] net: korina: Fix MDIO functions
Date: Fri, 16 Apr 2021 01:17:54 +0200	[thread overview]
Message-ID: <YHjJotQ9vQ03KZSH@lunn.ch> (raw)
In-Reply-To: <20210414230648.76129-2-tsbogend@alpha.franken.de>

> +static int korina_mdio_wait(struct korina_private *lp)
> +{
> +	u32 value;
> +
> +	return readl_poll_timeout_atomic(&lp->eth_regs->miimind,
> +					 value, value & ETH_MII_IND_BSY,
> +					 1, 1000);
> +}
> +
> +static int korina_mdio_read(struct net_device *dev, int phy, int reg)
>  {
>  	struct korina_private *lp = netdev_priv(dev);
>  	int ret;
>  
> -	mii_id = ((lp->rx_irq == 0x2c ? 1 : 0) << 8);
> +	if (korina_mdio_wait(lp))
> +		return -ETIMEDOUT;
>  
> -	writel(0, &lp->eth_regs->miimcfg);
> -	writel(0, &lp->eth_regs->miimcmd);
> -	writel(mii_id | reg, &lp->eth_regs->miimaddr);
> -	writel(ETH_MII_CMD_SCN, &lp->eth_regs->miimcmd);
> +	writel(phy << 8 | reg, &lp->eth_regs->miimaddr);
> +	writel(1, &lp->eth_regs->miimcmd);
> +
> +	if (korina_mdio_wait(lp))
> +		return -ETIMEDOUT;

Just return what readl_poll_timeout_atomic() returns. In general, you
should not change error codes.

>  
> -	ret = (int)(readl(&lp->eth_regs->miimrdd));
> +	if (readl(&lp->eth_regs->miimind) & ETH_MII_IND_NV)
> +		return -1;

Please use -ESOMETHING, not -1.

       Andrew

  reply	other threads:[~2021-04-15 23:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-14 23:06 [PATCH v3 net-next 00/10] net: Korina improvements Thomas Bogendoerfer
2021-04-14 23:06 ` [PATCH v3 net-next 01/10] net: korina: Fix MDIO functions Thomas Bogendoerfer
2021-04-15 23:17   ` Andrew Lunn [this message]
2021-04-14 23:06 ` [PATCH v3 net-next 02/10] net: korina: Use devres functions Thomas Bogendoerfer
2021-04-15 23:19   ` Andrew Lunn
2021-04-14 23:06 ` [PATCH v3 net-next 03/10] net: korina: Remove not needed cache flushes Thomas Bogendoerfer
2021-04-15 23:20   ` Andrew Lunn
2021-04-14 23:06 ` [PATCH v3 net-next 04/10] net: korina: Remove nested helpers Thomas Bogendoerfer
2021-04-15 23:21   ` Andrew Lunn
2021-04-14 23:06 ` [PATCH v3 net-next 05/10] net: korina: Use DMA API Thomas Bogendoerfer
2021-04-15 23:23   ` Andrew Lunn
2021-04-14 23:06 ` [PATCH v3 net-next 06/10] net: korina: Only pass mac address via platform data Thomas Bogendoerfer
2021-04-15 23:30   ` Andrew Lunn
2021-04-16  6:54     ` Thomas Bogendoerfer
2021-04-14 23:06 ` [PATCH v3 net-next 07/10] net: korina: Add support for device tree Thomas Bogendoerfer
2021-04-15 23:49   ` Andrew Lunn
2021-04-16  7:12     ` Thomas Bogendoerfer
2021-04-14 23:06 ` [PATCH v3 net-next 08/10] net: korina: Get mdio input clock via common clock framework Thomas Bogendoerfer
2021-04-15 23:52   ` Andrew Lunn
2021-04-14 23:06 ` [PATCH v3 net-next 09/10] net: korina: Make driver COMPILE_TESTable Thomas Bogendoerfer

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=YHjJotQ9vQ03KZSH@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.