All of lore.kernel.org
 help / color / mirror / Atom feed
From: tj@kernel.org (Tejun Heo)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 3/4] lib: devres: add convenience function to remap a resource
Date: Mon, 24 Oct 2011 13:19:07 -0700	[thread overview]
Message-ID: <20111024201907.GD24914@google.com> (raw)
In-Reply-To: <20111024200933.GB6326@pengutronix.de>

On Mon, Oct 24, 2011 at 10:09:33PM +0200, Wolfram Sang wrote:
> > So, for library functions, it's nice if the function doesn't hold any
> > extra resource on error return.  devres has grouping to support this.
> > You just need to wrap allocations inside a group and remove it on
> > success and release on error.  ie.
> > 
> > 	if (!devres_open_group(dev, NULL, GFP_KERNEL))
> > 		return NULL;
> > 	if (alloc_resource(0) < 0)
> > 		goto fail;
> > 	if (alloc_resource(1) < 0)
> > 		goto fail;
> > 	devres_remove_group(dev, NULL);
> > 	return 0;
> > fail:
> > 	devres_release_group(dev, NULL);
> > 	return 0;
> 
> I am not sure I got what you mean here, but wouldn't it be easier to simply
> call devm_release_mem_region() when devm_ioremap comes back with a NULL
> pointer?

Oh, yeah, that would work too. :)

Thanks.

-- 
tejun

WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Greg KH <gregkh@suse.de>,
	Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [RFC 3/4] lib: devres: add convenience function to remap a resource
Date: Mon, 24 Oct 2011 13:19:07 -0700	[thread overview]
Message-ID: <20111024201907.GD24914@google.com> (raw)
In-Reply-To: <20111024200933.GB6326@pengutronix.de>

On Mon, Oct 24, 2011 at 10:09:33PM +0200, Wolfram Sang wrote:
> > So, for library functions, it's nice if the function doesn't hold any
> > extra resource on error return.  devres has grouping to support this.
> > You just need to wrap allocations inside a group and remove it on
> > success and release on error.  ie.
> > 
> > 	if (!devres_open_group(dev, NULL, GFP_KERNEL))
> > 		return NULL;
> > 	if (alloc_resource(0) < 0)
> > 		goto fail;
> > 	if (alloc_resource(1) < 0)
> > 		goto fail;
> > 	devres_remove_group(dev, NULL);
> > 	return 0;
> > fail:
> > 	devres_release_group(dev, NULL);
> > 	return 0;
> 
> I am not sure I got what you mean here, but wouldn't it be easier to simply
> call devm_release_mem_region() when devm_ioremap comes back with a NULL
> pointer?

Oh, yeah, that would work too. :)

Thanks.

-- 
tejun

  reply	other threads:[~2011-10-24 20:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-24  8:42 [RFC 0/4] simplify remapping a resource for drivers Wolfram Sang
2011-10-24  8:42 ` Wolfram Sang
2011-10-24  8:42 ` [RFC 1/4] Documentation: devres: add allocation functions to list of supported calls Wolfram Sang
2011-10-24 15:25   ` Tejun Heo
2011-10-24 15:25     ` Tejun Heo
2011-10-24  8:42 ` [RFC 2/4] lib: devres: add annotations for #endif Wolfram Sang
2011-10-24  8:42 ` [RFC 3/4] lib: devres: add convenience function to remap a resource Wolfram Sang
2011-10-24 11:56   ` Grant Likely
2011-10-24 11:56     ` Grant Likely
2011-10-24 15:44     ` Tejun Heo
2011-10-24 15:44       ` Tejun Heo
2011-10-24 15:43   ` Tejun Heo
2011-10-24 15:43     ` Tejun Heo
2011-10-24 20:09     ` Wolfram Sang
2011-10-24 20:09       ` Wolfram Sang
2011-10-24 20:19       ` Tejun Heo [this message]
2011-10-24 20:19         ` Tejun Heo
2011-10-24  8:42 ` [RFC 4/4] watchdog: imx2: simplify resource allocation Wolfram Sang
2011-10-24 11:56   ` Grant Likely
2011-10-24 11:56     ` Grant Likely

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=20111024201907.GD24914@google.com \
    --to=tj@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.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.