resource: add resource_size()
authorMagnus Damm <damm@igel.co.jp>
Wed, 30 Jul 2008 05:32:57 +0000 (22:32 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Jul 2008 16:41:43 +0000 (09:41 -0700)
Avoid one-off errors by introducing a resource_size() function.

Signed-off-by: Magnus 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/ioport.h
kernel/resource.c

index 2cd07cc29687c49bd1cf8a0883cf5c72bbb4e762..22d2115458c67fe1e6e499996a9218af36fb772a 100644 (file)
@@ -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))
index 74af2d7cb5a135ffa1da4c52ce9af026c527044d..f5b518eabefec5cfe880c230fe07ce7b8615f732 100644 (file)
@@ -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: