Re: [RFC 3/4] lib: devres: add convenience function to remap aresource

From: Tejun Heo
Date: Mon Oct 24 2011 - 16:19:18 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/