Skip to content

Commit

Permalink
resource: add resource_size()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Magnus Damm authored and Linus Torvalds committed Jul 30, 2008
1 parent e958d3a commit 1a4e564
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/linux/ioport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1a4e564

Please sign in to comment.