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 | |
| 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>
| -rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 4 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91sam9g45_devices.c | 4 | ||||
| -rw-r--r-- | drivers/misc/atmel_tclib.c | 17 |
3 files changed, 13 insertions, 12 deletions
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index df487ce83c5e..c450cb3970a0 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c | |||
| @@ -642,7 +642,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
| 642 | static struct resource tcb0_resources[] = { | 642 | static struct resource tcb0_resources[] = { |
| 643 | [0] = { | 643 | [0] = { |
| 644 | .start = AT91SAM9260_BASE_TCB0, | 644 | .start = AT91SAM9260_BASE_TCB0, |
| 645 | .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1, | 645 | .end = AT91SAM9260_BASE_TCB0 + SZ_256 - 1, |
| 646 | .flags = IORESOURCE_MEM, | 646 | .flags = IORESOURCE_MEM, |
| 647 | }, | 647 | }, |
| 648 | [1] = { | 648 | [1] = { |
| @@ -672,7 +672,7 @@ static struct platform_device at91sam9260_tcb0_device = { | |||
| 672 | static struct resource tcb1_resources[] = { | 672 | static struct resource tcb1_resources[] = { |
| 673 | [0] = { | 673 | [0] = { |
| 674 | .start = AT91SAM9260_BASE_TCB1, | 674 | .start = AT91SAM9260_BASE_TCB1, |
| 675 | .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1, | 675 | .end = AT91SAM9260_BASE_TCB1 + SZ_256 - 1, |
| 676 | .flags = IORESOURCE_MEM, | 676 | .flags = IORESOURCE_MEM, |
| 677 | }, | 677 | }, |
| 678 | [1] = { | 678 | [1] = { |
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index 410829532aab..aee595013d33 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c | |||
| @@ -1052,7 +1052,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} | |||
| 1052 | static struct resource tcb0_resources[] = { | 1052 | static struct resource tcb0_resources[] = { |
| 1053 | [0] = { | 1053 | [0] = { |
| 1054 | .start = AT91SAM9G45_BASE_TCB0, | 1054 | .start = AT91SAM9G45_BASE_TCB0, |
| 1055 | .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1, | 1055 | .end = AT91SAM9G45_BASE_TCB0 + SZ_256 - 1, |
| 1056 | .flags = IORESOURCE_MEM, | 1056 | .flags = IORESOURCE_MEM, |
| 1057 | }, | 1057 | }, |
| 1058 | [1] = { | 1058 | [1] = { |
| @@ -1073,7 +1073,7 @@ static struct platform_device at91sam9g45_tcb0_device = { | |||
| 1073 | static struct resource tcb1_resources[] = { | 1073 | static struct resource tcb1_resources[] = { |
| 1074 | [0] = { | 1074 | [0] = { |
| 1075 | .start = AT91SAM9G45_BASE_TCB1, | 1075 | .start = AT91SAM9G45_BASE_TCB1, |
| 1076 | .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1, | 1076 | .end = AT91SAM9G45_BASE_TCB1 + SZ_256 - 1, |
| 1077 | .flags = IORESOURCE_MEM, | 1077 | .flags = IORESOURCE_MEM, |
| 1078 | }, | 1078 | }, |
| 1079 | [1] = { | 1079 | [1] = { |
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 | } |
