netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.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: Wed, 10 Apr 2013 22:17:40 +0200	[thread overview]
Message-ID: <5165C8E4.7030401@gmail.com> (raw)
In-Reply-To: <5165B264.6000605@cogentembedded.com>

On 04/10/2013 08:41 PM, Sergei Shtylyov wrote:
> Hello.
>
> On 04/10/2013 09:38 PM, 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.

Actually, I was hoping to also use devm_ioremap_resource() for
the above, but that is too early as mv643xx_eth and mvmdio have
overlapping mem resources. Changing this will require some more
step-by-step patches that get also tested on arch/ppc and others
using platform mv643xx_eth.

But, I can send an updated patch with -ENOMEM above if required.

Sebastian

  reply	other threads:[~2013-04-10 20:17 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 [this message]
2013-04-10 20:26     ` Sergei Shtylyov
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=5165C8E4.7030401@gmail.com \
    --to=sebastian.hesselbarth@gmail.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=sergei.shtylyov@cogentembedded.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;
as well as URLs for NNTP newsgroup(s).