Commit 1a4e564b7db999fbe5d88318c96ac8747699d417

Authored by Magnus Damm
Committed by Linus Torvalds
1 parent e958d3ace7

resource: add resource_size()

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>

Showing 2 changed files with 5 additions and 1 deletions Side-by-side Diff

include/linux/ioport.h
... ... @@ -118,6 +118,10 @@
118 118 int adjust_resource(struct resource *res, resource_size_t start,
119 119 resource_size_t size);
120 120 resource_size_t resource_alignment(struct resource *res);
  121 +static inline resource_size_t resource_size(struct resource *res)
  122 +{
  123 + return res->end - res->start + 1;
  124 +}
121 125  
122 126 /* Convenience shorthand with allocation */
123 127 #define request_region(start,n,name) __request_region(&ioport_resource, (start), (n), (name))
... ... @@ -490,7 +490,7 @@
490 490 {
491 491 switch (res->flags & (IORESOURCE_SIZEALIGN | IORESOURCE_STARTALIGN)) {
492 492 case IORESOURCE_SIZEALIGN:
493   - return res->end - res->start + 1;
  493 + return resource_size(res);
494 494 case IORESOURCE_STARTALIGN:
495 495 return res->start;
496 496 default: