From: Andrew Lunn <andrew@lunn.ch>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
davem@davemloft.net, kuba@kernel.org
Subject: Re: [PATCH net-next] net: mdio: mscc-miim: Use devm_platform_get_and_ioremap_resource()
Date: Fri, 11 Jun 2021 05:35:22 +0200 [thread overview]
Message-ID: <YMLZ+k0rjlZY9+7b@lunn.ch> (raw)
In-Reply-To: <fd9cbc9c-478e-85c8-62ec-58a8baf4333c@huawei.com>
On Fri, Jun 11, 2021 at 09:35:04AM +0800, Yang Yingliang wrote:
> Hi,
>
> On 2021/6/11 0:01, Andrew Lunn wrote:
> > > - dev->regs = devm_ioremap_resource(&pdev->dev, res);
> > > + dev->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> > > if (IS_ERR(dev->regs)) {
> > Here, only dev->regs is considered.
> >
> > > dev_err(&pdev->dev, "Unable to map MIIM registers\n");
> > > return PTR_ERR(dev->regs);
> > > }
> >
> >
> > > + dev->phy_regs = devm_platform_get_and_ioremap_resource(pdev, 1, &res);
> > > + if (res && IS_ERR(dev->phy_regs)) {
> > Here you look at both res and dev->phy_regs.
> >
> > This seems inconsistent. Can devm_platform_get_and_ioremap_resource()
> > return success despite res being NULL?
> No, if res is NULL, devm_platform_get_and_ioremap_resource() returns failed.
> But, before this patch, if the internal phy res is NULL, it doesn't return
> error
> code, so I checked the res to make sure it doesn't change the origin code
> logic.
O.K, so IORESOURCE_MEM, 1 is optional. By making this change, i think
you have made this less clear. So i would say it is O.K. to change the
first platform_get_resource(pdev, IORESOURCE_MEM, 0) and
devm_ioremap_resource(&pdev->dev, res) to one call, but i would leave
the second pair alone.
Andrew
prev parent reply other threads:[~2021-06-11 3:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 9:11 Yang Yingliang
2021-06-10 16:01 ` Andrew Lunn
2021-06-11 1:35 ` Yang Yingliang
2021-06-11 3:35 ` Andrew Lunn [this message]
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=YMLZ+k0rjlZY9+7b@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=yangyingliang@huawei.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
all inboxes | Powered by JetHome®