RE: drivers/dma/mv_xor.c: use resource_size()

From: H Hartley Sweeten
Date: Mon Nov 23 2009 - 17:04:10 EST


On Monday, November 23, 2009 2:35 PM, Ingo Oeser wrote:
> On Monday 23 November 2009, H Hartley Sweeten wrote:
>> Use resource_size() for devm_ioremap.
>
> This pattern foo = do_with_res(res->start, resource_size(res)) seem to happen quite often.
> What about creating inline functions like
>
> foo = do_with_full_res(res)
>
> ?
>
> That would save some code and make it obviously correct.
>

I thought about that also. Just not sure what header(s) they would go in.

The most obvious ones I can see are:


static inline struct resource * request_mem_resource(struct resource *res, const char *name)
{
return request_mem_region(res->start, resource_size(res), name);
}

static void release_mem_resource(struct resource *res)
{
release_mem_region(res->start, resource_size(res));
}

static void __iomem * ioremap_resource(struct resource *res)
{
return ioremap(res->start, resource_size(res));
}


There are probably others (devm_request_region, etc.).

They could also be #define macros. Not sure which is better.

Regards,
Hartley
--
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/