public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Lennert Buytenhek <buytenh@wantstofly.org>,
	Andrew Lunn <andrew@lunn.ch>, Jason Cooper <jason@lakedaemon.net>,
	Florian Fainelli <florian@openwrt.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: mv643xx_eth: use managed devm_kzalloc
Date: Thu, 11 Apr 2013 00:26:08 +0400	[thread overview]
Message-ID: <5165CAE0.3070207@cogentembedded.com> (raw)
In-Reply-To: <5165C8E4.7030401@gmail.com>

On 04/11/2013 12:17 AM, Sebastian Hesselbarth wrote:
>
>>
>>> This patch moves shared private data kzalloc to managed devm_kzalloc 
>>> and
>>> cleans now unneccessary kfree and error handling.
>>>
>>> Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
>>> ---
>>> Note that there is also an ioremap call, that could be transferred to
>>> devm_ioremap_resource. But as long as mv643xx_eth and mvmdio iomem
>>> resources overlap, this will throw -EBUSY.
>>>
>>> Cc: Lennert Buytenhek <buytenh@wantstofly.org>
>>> Cc: Andrew Lunn <andrew@lunn.ch>
>>> Cc: Jason Cooper <jason@lakedaemon.net>
>>> Cc: Florian Fainelli <florian@openwrt.org>
>>> Cc: netdev@vger.kernel.org
>>> Cc: linux-kernel@vger.kernel.org
>>> ---
>>> drivers/net/ethernet/marvell/mv643xx_eth.c | 17 ++++-------------
>>> 1 file changed, 4 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> b/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> index bbe6104..955baab 100644
>>> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
>>> @@ -2547,25 +2547,22 @@ static int mv643xx_eth_shared_probe(struct
>>> platform_device *pdev)
>>> struct mv643xx_eth_shared_private *msp;
>>> const struct mbus_dram_target_info *dram;
>>> struct resource *res;
>>> - int ret;
>>> if (!mv643xx_eth_version_printed++)
>>> pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
>>> mv643xx_eth_driver_version);
>>> - ret = -EINVAL;
>>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> if (res == NULL)
>>> - goto out;
>>> + return -EINVAL;
>>> - ret = -ENOMEM;
>>> - msp = kzalloc(sizeof(*msp), GFP_KERNEL);
>>> + msp = devm_kzalloc(&pdev->dev, sizeof(*msp), GFP_KERNEL);
>>> if (msp == NULL)
>>> - goto out;
>>> + return -ENOMEM;
>>> msp->base = ioremap(res->start, resource_size(res));
>>> if (msp->base == NULL)
>>> - goto out_free;
>>> + return -EADDRNOTAVAIL;
>>
>> -ENOMEM usually.
>
> Sergei,
>
> I was looking at the example for devm_request_and_ioremap() in
> lib/devres.c. There it is -EADDRNOTAVAIL which is returned on
> failing ioremap.

    This is a recommended value to return if this function fails, to be 
precise --
regardless of the reason.
    With mere ioremap(), the value has always been -ENOMEM.

WBR, Sergei


  reply	other threads:[~2013-04-10 20:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 17:38 [PATCH] net: mv643xx_eth: use managed devm_kzalloc Sebastian Hesselbarth
2013-04-10 18:41 ` Sergei Shtylyov
2013-04-10 20:17   ` Sebastian Hesselbarth
2013-04-10 20:26     ` Sergei Shtylyov [this message]
2013-04-10 20:42 ` [PATCH v2] " Sebastian Hesselbarth
2013-04-11  3:39   ` David Miller
2013-04-11  6:53     ` Sebastian Hesselbarth
2013-04-11 17:15       ` David Miller

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=5165CAE0.3070207@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=andrew@lunn.ch \
    --cc=buytenh@wantstofly.org \
    --cc=florian@openwrt.org \
    --cc=jason@lakedaemon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sebastian.hesselbarth@gmail.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