[PATCH 01/04] resource: add resource_size()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Magnus Damm
Date: Wednesday, July 9, 2008 - 4:54 am

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

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 include/linux/ioport.h |    4 ++++
 kernel/resource.c      |    2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

--- 0001/include/linux/ioport.h
+++ work/include/linux/ioport.h	2008-07-09 12:59:04.000000000 +0900
@@ -113,6 +113,10 @@ extern int allocate_resource(struct reso
 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))
--- 0001/kernel/resource.c
+++ work/kernel/resource.c	2008-07-09 12:59:41.000000000 +0900
@@ -490,7 +490,7 @@ resource_size_t resource_alignment(struc
 {
 	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:
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/04] resource: type and size patches, Magnus Damm, (Wed Jul 9, 4:54 am)
[PATCH 01/04] resource: add resource_size(), Magnus Damm, (Wed Jul 9, 4:54 am)
[PATCH 04/04] resource: add new IORESOURCE_CLK type, Magnus Damm, (Wed Jul 9, 4:55 am)
Re: [PATCH 03/04] resource: use new resource type changes, Andrew Morton, (Fri Jul 11, 12:18 pm)
Re: [PATCH 04/04] resource: add new IORESOURCE_CLK type, Andrew Morton, (Fri Jul 11, 12:18 pm)
Re: [PATCH 04/04] resource: add new IORESOURCE_CLK type, Andrew Morton, (Thu Jul 17, 4:20 pm)