From: "Måns Rullgård" <mans@mansr.com>
To: Sebastian Frias <sf84@laposte.net>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
mason <slash.tmp@free.fr>
Subject: Re: [PATCH v2] net: ethernet: support "fixed-link" DT key/node on nb8800 driver
Date: Fri, 05 Feb 2016 14:13:59 +0000 [thread overview]
Message-ID: <yw1xoabvgs7s.fsf@unicorn.mansr.com> (raw)
In-Reply-To: <56B4ACC4.1000607@laposte.net> (Sebastian Frias's message of "Fri, 05 Feb 2016 15:08:04 +0100")
Sebastian Frias <sf84@laposte.net> writes:
> On 02/05/2016 02:58 PM, Måns Rullgård wrote:
>> Sebastian Frias <sf84@laposte.net> writes:
>>
>>> Signed-off-by: Sebastian Frias <sf84@laposte.net>
>>> ---
>>> drivers/net/ethernet/aurora/nb8800.c | 15 ++++++++++++---
>>> 1 file changed, 12 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/aurora/nb8800.c
>>> b/drivers/net/ethernet/aurora/nb8800.c
>>> index ecc4a33..dd7bedc 100644
>>> --- a/drivers/net/ethernet/aurora/nb8800.c
>>> +++ b/drivers/net/ethernet/aurora/nb8800.c
>>> @@ -1462,9 +1462,18 @@ static int nb8800_probe(struct platform_device *pdev)
>>>
>>> priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
>>> if (!priv->phy_node) {
>>> - dev_err(&pdev->dev, "no PHY specified\n");
>>> - ret = -ENODEV;
>>> - goto err_free_bus;
>>> + if (of_phy_is_fixed_link(pdev->dev.of_node)) {
>>> + ret = of_phy_register_fixed_link(pdev->dev.of_node);
>>> + if (ret < 0) {
>>> + dev_err(&pdev->dev, "bad fixed-link spec\n");
>>> + goto err_free_bus;
>>> + }
>>> + priv->phy_node = of_node_get(pdev->dev.of_node);
>>> + } else {
>>> + dev_err(&pdev->dev, "no PHY specified\n");
>>> + ret = -ENODEV;
>>> + goto err_free_bus;
>>> + }
>>> }
>>
>> Maybe it would be clearer to reduce the if() nesting a bit, like this
>> for instance:
>>
>> if (of_phy_is_fixed_link(pdev->dev.of_node)) {
>> ret = of_phy_register_fixed_link(pdev->dev.of_node);
>> if (ret < 0) {
>> dev_err(&pdev->dev, "bad fixed-link spec\n");
>> goto err_free_bus;
>> }
>> priv->phy_node = of_node_get(pdev->dev.of_node);
>> }
>>
>> if (!priv->phy_node)
>> priv->phy_node = of_parse_phandle(pdev->dev.of_node,
>> "phy-handle", 0);
>>
>> if (!priv->phy_node) {
>> dev_err(&pdev->dev, "no PHY specified\n");
>> ret = -ENODEV;
>> goto err_free_bus;
>> }
>>
>>
>
> Thanks Måns for your comments.
> With old code + my patch, we only hit 1 comparison in the general
> case, and a 2nd one in "fixed-link" case.
> With your suggestion above, it would mean that we hit 3 comparisons
> all the time.
> If you are ok with the 3 comparisons, I can post a v3.
This is code that runs once so IMO clarity is more important than a
minuscule speed difference.
--
Måns Rullgård
next prev parent reply other threads:[~2016-02-05 14:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 13:31 [PATCH] net: ethernet: support "fixed-link" DT node " Sebastian Frias
2016-02-05 13:39 ` Måns Rullgård
2016-02-05 13:49 ` [PATCH v2] net: ethernet: support "fixed-link" DT key/node " Sebastian Frias
2016-02-05 13:58 ` Måns Rullgård
2016-02-05 14:08 ` Sebastian Frias
2016-02-05 14:13 ` Måns Rullgård [this message]
2016-02-05 14:22 ` [PATCH v3] net: ethernet: support "fixed-link" DT node " Sebastian Frias
2016-02-05 14:34 ` Måns Rullgård
2016-02-05 14:56 ` Sebastian Frias
2016-02-05 15:08 ` Måns Rullgård
2016-02-05 15:20 ` Sebastian Frias
2016-02-05 15:26 ` Måns Rullgård
2016-02-08 10:23 ` [PATCH v5] net: ethernet: nb8800: support fixed-link DT node Sebastian Frias
2016-02-08 13:19 ` Måns Rullgård
2016-02-16 20:04 ` David Miller
2016-02-08 10:34 ` [PATCH v3] net: ethernet: support "fixed-link" DT node on nb8800 driver Sebastian Frias
2016-02-08 13:37 ` Måns Rullgård
2016-02-08 14:11 ` Mason
2016-02-08 14:38 ` Sebastian Frias
2016-02-08 14:44 ` Måns Rullgård
2016-02-08 14:32 ` Sebastian Frias
2016-02-08 14:50 ` Måns Rullgård
2016-02-05 14:56 ` [PATCH v4] net: ethernet: nb8800: support fixed-link DT node Sebastian Frias
2016-02-05 15:57 ` [PATCH] net: ethernet: support "fixed-link" DT node on nb8800 driver Andy Shevchenko
2016-02-05 15:58 ` Måns Rullgård
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=yw1xoabvgs7s.fsf@unicorn.mansr.com \
--to=mans@mansr.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sf84@laposte.net \
--cc=slash.tmp@free.fr \
/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®