diff options
author | Nicolas Ferre <nicolas.ferre@atmel.com> | 2012-01-18 10:56:36 -0500 |
---|---|---|
committer | Nicolas Ferre <nicolas.ferre@atmel.com> | 2012-03-01 07:38:48 -0500 |
commit | 298312971b2fe8b922a1a15e0a6f5b4da89677d8 (patch) | |
tree | 25a6c8588077badac4d0092e3b81c5df0c8508d1 /drivers/misc/atmel_tclib.c | |
parent | 986c265729cb798bb8414bd5d6c6006240a1011c (diff) |
ARM: at91/tclib: take iomem size from resource
Requesting iomem region and ioremaping is now done using
the resource size specified instead of a constant value.
Each <SoC>_device.c file is modified accordingly to reflect
actual user interface size.
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'drivers/misc/atmel_tclib.c')
-rw-r--r-- | drivers/misc/atmel_tclib.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/misc/atmel_tclib.c b/drivers/misc/atmel_tclib.c index 4bcfc3759734..7a6512a148d4 100644 --- a/drivers/misc/atmel_tclib.c +++ b/drivers/misc/atmel_tclib.c | |||
@@ -9,10 +9,6 @@ | |||
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | 11 | ||
12 | /* Number of bytes to reserve for the iomem resource */ | ||
13 | #define ATMEL_TC_IOMEM_SIZE 256 | ||
14 | |||
15 | |||
16 | /* | 12 | /* |
17 | * This is a thin library to solve the problem of how to portably allocate | 13 | * This is a thin library to solve the problem of how to portably allocate |
18 | * one of the TC blocks. For simplicity, it doesn't currently expect to | 14 | * one of the TC blocks. For simplicity, it doesn't currently expect to |
@@ -48,6 +44,7 @@ struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name) | |||
48 | struct atmel_tc *tc; | 44 | struct atmel_tc *tc; |
49 | struct platform_device *pdev = NULL; | 45 | struct platform_device *pdev = NULL; |
50 | struct resource *r; | 46 | struct resource *r; |
47 | size_t size; | ||
51 | 48 | ||
52 | spin_lock(&tc_list_lock); | 49 | spin_lock(&tc_list_lock); |
53 | list_for_each_entry(tc, &tc_list, node) { | 50 | list_for_each_entry(tc, &tc_list, node) { |
@@ -61,11 +58,15 @@ struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name) | |||
61 | goto fail; | 58 | goto fail; |
62 | 59 | ||
63 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 60 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
64 | r = request_mem_region(r->start, ATMEL_TC_IOMEM_SIZE, name); | ||
65 | if (!r) | 61 | if (!r) |
66 | goto fail; | 62 | goto fail; |
67 | 63 | ||
68 | tc->regs = ioremap(r->start, ATMEL_TC_IOMEM_SIZE); | 64 | size = resource_size(r); |
65 | r = request_mem_region(r->start, size, name); | ||
66 | if (!r) | ||
67 | goto fail; | ||
68 | |||
69 | tc->regs = ioremap(r->start, size); | ||
69 | if (!tc->regs) | 70 | if (!tc->regs) |
70 | goto fail_ioremap; | 71 | goto fail_ioremap; |
71 | 72 | ||
@@ -76,7 +77,7 @@ out: | |||
76 | return tc; | 77 | return tc; |
77 | 78 | ||
78 | fail_ioremap: | 79 | fail_ioremap: |
79 | release_mem_region(r->start, ATMEL_TC_IOMEM_SIZE); | 80 | release_mem_region(r->start, size); |
80 | fail: | 81 | fail: |
81 | tc = NULL; | 82 | tc = NULL; |
82 | goto out; | 83 | goto out; |
@@ -96,7 +97,7 @@ void atmel_tc_free(struct atmel_tc *tc) | |||
96 | spin_lock(&tc_list_lock); | 97 | spin_lock(&tc_list_lock); |
97 | if (tc->regs) { | 98 | if (tc->regs) { |
98 | iounmap(tc->regs); | 99 | iounmap(tc->regs); |
99 | release_mem_region(tc->iomem->start, ATMEL_TC_IOMEM_SIZE); | 100 | release_mem_region(tc->iomem->start, resource_size(tc->iomem)); |
100 | tc->regs = NULL; | 101 | tc->regs = NULL; |
101 | tc->iomem = NULL; | 102 | tc->iomem = NULL; |
102 | } | 103 | } |