linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jie Luo <luoj@codeaurora.org>
To: Andrew Lunn <andrew@lunn.ch>
Cc: hkallweit1@gmail.com, davem@davemloft.net, kuba@kernel.org,
	linux@armlinux.org.uk, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, sricharan@codeaurora.org
Subject: Re: [PATCH v1 1/2] net: mdio: Add the reset function for IPQ MDIO driver
Date: Mon, 9 Aug 2021 21:01:36 +0800	[thread overview]
Message-ID: <a698552a-0bc2-c0d4-d6f8-0d70c50373bb@codeaurora.org> (raw)
In-Reply-To: <YQ/3ycEU9zkn8idJ@lunn.ch>


On 8/8/2021 11:27 PM, Andrew Lunn wrote:
>> +static int ipq_mdio_reset(struct mii_bus *bus)
>> +{
>> +	struct ipq4019_mdio_data *priv = bus->priv;
>> +	u32 val;
>> +	int ret;
>> +
>> +	/* To indicate CMN_PLL that ethernet_ldo has been ready if platform resource 1
>> +	 * is specified in the device tree.
>> +	 * */
>> +	if (!IS_ERR(priv->eth_ldo_rdy)) {
>> +		val = readl(priv->eth_ldo_rdy);
>> +		val |= BIT(0);
>> +		writel(val, priv->eth_ldo_rdy);
>> +		fsleep(IPQ_PHY_SET_DELAY_US);
>> +	}
>> +
>> +	/* Configure MDIO clock source frequency if clock is specified in the device tree */
>> +	if (!IS_ERR_OR_NULL(priv->mdio_clk)) {
>> +		ret = clk_set_rate(priv->mdio_clk, IPQ_MDIO_CLK_RATE);
>> +		if (ret)
>> +			return ret;
>> +
>> +		ret = clk_prepare_enable(priv->mdio_clk);
>> +		if (ret)
>> +			return ret;
>> +	}
> These !IS_ERR() are pretty ugly. So
>
>> @@ -182,14 +221,22 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
>>   		return -ENOMEM;
>>   
>>   	priv = bus->priv;
>> +	priv->eth_ldo_rdy = IOMEM_ERR_PTR(-EINVAL);
>>   
>>   	priv->membase = devm_platform_ioremap_resource(pdev, 0);
>>   	if (IS_ERR(priv->membase))
>>   		return PTR_ERR(priv->membase);
>>   
>> +	priv->mdio_clk = devm_clk_get_optional(&pdev->dev, "gcc_mdio_ahb_clk");
> If this returns an error, it is a real error. You should not ignore
> it. Fail the probe returning the error. That then means when the reset
> function is called priv->mdio_clk contains either a clock, or NULL,
> which the clk API is happy to take. No need for an if.
>
>
>> +
>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>> +	if (res)
>> +		priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
> platform_get_resource() returns a pointer or NULL. There is no error
> code. So
>
>> +	if (!IS_ERR(priv->eth_ldo_rdy)) {
> is actually wrong, should simply become
>
>> +	if (priv->eth_ldo_rdy) {
>    Andrew

Hi Andrew,

Thanks for the kindly review and the comments, will follow it in the 
next patch set.


  reply	other threads:[~2021-08-09 13:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-08  7:21 [PATCH v1 0/2] net: mdio: Add IPQ MDIO reset related function Luo Jie
2021-08-08  7:21 ` [PATCH v1 1/2] net: mdio: Add the reset function for IPQ MDIO driver Luo Jie
2021-08-08 15:27   ` Andrew Lunn
2021-08-09 13:01     ` Jie Luo [this message]
2021-08-08 15:29   ` Andrew Lunn
2021-08-09 13:02     ` Jie Luo
2021-08-08  7:21 ` [PATCH v1 2/2] MDIO: Kconfig: Specify more IPQ chipset supported Luo Jie

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=a698552a-0bc2-c0d4-d6f8-0d70c50373bb@codeaurora.org \
    --to=luoj@codeaurora.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=sricharan@codeaurora.org \
    /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).