All of lore.kernel.org
 help / color / mirror / Atom feed
From: <sean.wang@mediatek.com>
To: <john@phrozen.org>
Cc: <davem@davemloft.net>, <nbd@openwrt.org>,
	<netdev@vger.kernel.org>, <linux-mediatek@lists.infradead.org>,
	<keyhaede@gmail.com>
Subject: Re: [RESEND PATCH net 09/10] net: ethernet: mediatek: use devm_mdiobus_alloc instead of mdiobus_alloc inside mtk_mdio_init
Date: Fri, 26 Aug 2016 14:33:13 +0800	[thread overview]
Message-ID: <1472193193-24046-1-git-send-email-sean.wang@mediatek.com> (raw)
In-Reply-To: <84142b03-2100-1d56-8f5e-1d39b1748a25@phrozen.org>

On Date: Thu, 25 Aug 2016 15:39:08 +0200, John Crispin wrote:
>Hi Sean, >
>small nitpick inline
>
>On 25/08/2016 12:45, Sean Wang wrote:
>> a lot of parts in the driver uses devm_* APIs to gain benefits from the
....
  
>> -	eth->mii_bus = mdiobus_alloc();
>> +	eth->mii_bus = devm_mdiobus_alloc(eth->dev);
>>  	if (!eth->mii_bus) {
>>  		err = -ENOMEM;
>>  		goto err_put_node;
>> @@ -318,18 +318,9 @@ static int mtk_mdio_init(struct mtk_eth *eth)
>>  
>>  	snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%s", mii_np->name);
>>  	err = of_mdiobus_register(eth->mii_bus, mii_np);
>> -	if (err)
>> -		goto err_free_bus;
>> -	of_node_put(mii_np);
>> -
>> -	return 0;
>> -
>> -err_free_bus:
>> -	mdiobus_free(eth->mii_bus);
>>  
>>  err_put_node:
>>  	of_node_put(mii_np);
>> -	eth->mii_bus = NULL;
>>  	return err;
>
>you might want to rename err to ret. that would make it more readable.
>right now it looks like the code always flows through the error path.
>
>	John
>

okay, i will change this from err to ret for readable code
and my thought is using common code provided by the framework helps
to 
1) have simplified the code flow as [1] says 
2) decrease the risk of incorrect error handling by human
3) only a few drivers used it since it ware proposed on linux 3.16,
so just hope to promote for this.

[1] https://patchwork.ozlabs.org/patch/344093/

>>  }
>>  
>> @@ -339,8 +330,6 @@ static void mtk_mdio_cleanup(struct mtk_eth *eth)
>>  		return;
>>  
>>  	mdiobus_unregister(eth->mii_bus);
>> -	of_node_put(eth->mii_bus->dev.of_node);
>> -	mdiobus_free(eth->mii_bus);
>>  }

WARNING: multiple messages have this Message-ID (diff)
From: <sean.wang@mediatek.com>
To: john@phrozen.org
Cc: davem@davemloft.net, nbd@openwrt.org, netdev@vger.kernel.org,
	linux-mediatek@lists.infradead.org, keyhaede@gmail.com
Subject: Re: [RESEND PATCH net 09/10] net: ethernet: mediatek: use devm_mdiobus_alloc instead of mdiobus_alloc inside mtk_mdio_init
Date: Fri, 26 Aug 2016 14:33:13 +0800	[thread overview]
Message-ID: <1472193193-24046-1-git-send-email-sean.wang@mediatek.com> (raw)
In-Reply-To: <84142b03-2100-1d56-8f5e-1d39b1748a25@phrozen.org>

On Date: Thu, 25 Aug 2016 15:39:08 +0200, John Crispin wrote:
>Hi Sean, >
>small nitpick inline
>
>On 25/08/2016 12:45, Sean Wang wrote:
>> a lot of parts in the driver uses devm_* APIs to gain benefits from the
....
  
>> -	eth->mii_bus = mdiobus_alloc();
>> +	eth->mii_bus = devm_mdiobus_alloc(eth->dev);
>>  	if (!eth->mii_bus) {
>>  		err = -ENOMEM;
>>  		goto err_put_node;
>> @@ -318,18 +318,9 @@ static int mtk_mdio_init(struct mtk_eth *eth)
>>  
>>  	snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%s", mii_np->name);
>>  	err = of_mdiobus_register(eth->mii_bus, mii_np);
>> -	if (err)
>> -		goto err_free_bus;
>> -	of_node_put(mii_np);
>> -
>> -	return 0;
>> -
>> -err_free_bus:
>> -	mdiobus_free(eth->mii_bus);
>>  
>>  err_put_node:
>>  	of_node_put(mii_np);
>> -	eth->mii_bus = NULL;
>>  	return err;
>
>you might want to rename err to ret. that would make it more readable.
>right now it looks like the code always flows through the error path.
>
>	John
>

okay, i will change this from err to ret for readable code
and my thought is using common code provided by the framework helps
to 
1) have simplified the code flow as [1] says 
2) decrease the risk of incorrect error handling by human
3) only a few drivers used it since it ware proposed on linux 3.16,
so just hope to promote for this.

[1] https://patchwork.ozlabs.org/patch/344093/

>>  }
>>  
>> @@ -339,8 +330,6 @@ static void mtk_mdio_cleanup(struct mtk_eth *eth)
>>  		return;
>>  
>>  	mdiobus_unregister(eth->mii_bus);
>> -	of_node_put(eth->mii_bus->dev.of_node);
>> -	mdiobus_free(eth->mii_bus);
>>  }

  reply	other threads:[~2016-08-26  6:33 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-25 10:44 [RESEND PATCH net 00/10] net: ethernet: mediatek: a couple of fixes Sean Wang
2016-08-25 10:44 ` Sean Wang
2016-08-25 10:44 ` [RESEND PATCH net 01/10] net: ethernet: mediatek: fix fails from TX housekeeping due to incorrect port setup Sean Wang
2016-08-25 10:44   ` Sean Wang
2016-08-25 12:19   ` John Crispin
     [not found] ` <1472121901-15629-1-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2016-08-25 10:44   ` [RESEND PATCH net 02/10] net: ethernet: mediatek: fix incorrect return value of devm_clk_get with EPROBE_DEFER Sean Wang
2016-08-25 10:44     ` Sean Wang
2016-08-25 13:49     ` John Crispin
     [not found]       ` <e1e9ca7a-c33b-3a9e-fd47-48f80bb10a32-Pj+rj9U5foFAfugRpC6u6w@public.gmane.org>
2016-08-26  5:22         ` [RESEND PATCH net 02/10] net: ethernet: mediatek: fix incorrect Sean Wang
2016-08-26  5:22           ` Sean Wang
2016-08-25 10:44   ` [RESEND PATCH net 03/10] net: ethernet: mediatek: fix API usage with skb_free_frag Sean Wang
2016-08-25 10:44     ` Sean Wang
2016-08-25 12:20     ` John Crispin
2016-08-25 10:44 ` [RESEND PATCH net 04/10] net: ethernet: mediatek: remove redundant free_irq for devm_request_irq allocated irq Sean Wang
2016-08-25 10:44   ` Sean Wang
2016-08-25 12:20   ` John Crispin
2016-08-25 10:44 ` [RESEND PATCH net 05/10] net: ethernet: mediatek: fix logic unbalance between probe and remove Sean Wang
2016-08-25 10:44   ` Sean Wang
2016-08-25 12:22   ` John Crispin
2016-08-25 10:44 ` [RESEND PATCH net 06/10] net: ethernet: mediatek: fix the loss of pin-mux setting for GMAC2 Sean Wang
2016-08-25 10:44   ` Sean Wang
2016-08-25 13:30   ` Andrew Lunn
     [not found]     ` <20160825133034.GA25046-g2DYL2Zd6BY@public.gmane.org>
2016-08-26  3:33       ` [RESEND PATCH net 06/10] net: ethernet: mediatek: fix the loss Sean Wang
2016-08-26  3:33         ` Sean Wang
2016-08-26 14:17         ` Andrew Lunn
2016-08-29  4:27           ` Sean Wang
2016-08-29  4:27             ` Sean Wang
2016-08-25 10:44 ` [RESEND PATCH net 07/10] net: ethernet: mediatek: fix issue of driver removal with interface is up Sean Wang
2016-08-25 10:44   ` Sean Wang
     [not found]   ` <1472121901-15629-8-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2016-08-25 13:35     ` John Crispin
     [not found]       ` <2203871f-d73d-3a39-928d-39862ba5e367-Pj+rj9U5foFAfugRpC6u6w@public.gmane.org>
2016-08-26  5:50         ` Sean Wang
2016-08-26  5:50           ` Sean Wang
2016-08-25 10:44 ` [RESEND PATCH net 08/10] net: ethernet: mediatek: fix the missing of_node_put() after node is used done inside mtk_mdio_init Sean Wang
2016-08-25 10:44   ` Sean Wang
     [not found]   ` <1472121901-15629-9-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2016-08-25 13:36     ` John Crispin
2016-08-25 10:45 ` [RESEND PATCH net 09/10] net: ethernet: mediatek: use devm_mdiobus_alloc instead of mdiobus_alloc " Sean Wang
2016-08-25 10:45   ` Sean Wang
     [not found]   ` <1472121901-15629-10-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2016-08-25 13:39     ` John Crispin
2016-08-26  6:33       ` sean.wang [this message]
2016-08-26  6:33         ` sean.wang
2016-08-25 10:45 ` [RESEND PATCH net 10/10] net: ethernet: mediatek: fix error handling " Sean Wang
2016-08-25 10:45   ` Sean Wang
     [not found]   ` <1472121901-15629-11-git-send-email-sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2016-08-25 13:39     ` John Crispin

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=1472193193-24046-1-git-send-email-sean.wang@mediatek.com \
    --to=sean.wang@mediatek.com \
    --cc=davem@davemloft.net \
    --cc=john@phrozen.org \
    --cc=keyhaede@gmail.com \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=nbd@openwrt.org \
    --cc=netdev@vger.kernel.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 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.