Commit 1a4e564b authored by Magnus Damm's avatar Magnus Damm Committed by Linus Torvalds
Browse files

resource: add resource_size()



Avoid one-off errors by introducing a resource_size() function.

Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e958d3ac
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -118,6 +118,10 @@ extern int allocate_resource(struct resource *root, struct resource *new,
int adjust_resource(struct resource *res, resource_size_t start,
		    resource_size_t size);
resource_size_t resource_alignment(struct resource *res);
static inline resource_size_t resource_size(struct resource *res)
{
	return res->end - res->start + 1;
}

/* Convenience shorthand with allocation */
#define request_region(start,n,name)	__request_region(&ioport_resource, (start), (n), (name))
+1 −1
Original line number Diff line number Diff line
@@ -490,7 +490,7 @@ resource_size_t resource_alignment(struct resource *res)
{
	switch (res->flags & (IORESOURCE_SIZEALIGN | IORESOURCE_STARTALIGN)) {
	case IORESOURCE_SIZEALIGN:
		return res->end - res->start + 1;
		return resource_size(res);
	case IORESOURCE_STARTALIGN:
		return res->start;
	default: