diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-09-23 05:56:24 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-09-23 05:56:24 -0400 |
commit | 9a05eded5d17a425b9d9ed9dd80f518429dde4e8 (patch) | |
tree | c89aa151f179eb26abf776d0804f85833f144554 /drivers | |
parent | 892e4fba1cb5cdc70f3acc65e024e541c0b2d559 (diff) |
[MTD] SSFDC translation layer minor cleanup
Don't include <linux/config.h>.
Don't say 'MB' where you mean 'MiB'.
Don't allocate 512 bytes on the stack.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mtd/ssfdc.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index ddbf015f4119..cf60a5e87f19 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
@@ -10,7 +10,6 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/config.h> | ||
14 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 14 | #include <linux/module.h> |
16 | #include <linux/init.h> | 15 | #include <linux/init.h> |
@@ -29,7 +28,7 @@ struct ssfdcr_record { | |||
29 | int cis_block; /* block n. containing CIS/IDI */ | 28 | int cis_block; /* block n. containing CIS/IDI */ |
30 | int erase_size; /* phys_block_size */ | 29 | int erase_size; /* phys_block_size */ |
31 | unsigned short *logic_block_map; /* all zones (max 8192 phys blocks on | 30 | unsigned short *logic_block_map; /* all zones (max 8192 phys blocks on |
32 | the 128MB) */ | 31 | the 128MiB) */ |
33 | int map_len; /* n. phys_blocks on the card */ | 32 | int map_len; /* n. phys_blocks on the card */ |
34 | }; | 33 | }; |
35 | 34 | ||
@@ -43,11 +42,11 @@ struct ssfdcr_record { | |||
43 | #define MAX_LOGIC_BLK_PER_ZONE 1000 | 42 | #define MAX_LOGIC_BLK_PER_ZONE 1000 |
44 | #define MAX_PHYS_BLK_PER_ZONE 1024 | 43 | #define MAX_PHYS_BLK_PER_ZONE 1024 |
45 | 44 | ||
46 | #define KB(x) ( (x) * 1024L ) | 45 | #define KiB(x) ( (x) * 1024L ) |
47 | #define MB(x) ( KB(x) * 1024L ) | 46 | #define MiB(x) ( KiB(x) * 1024L ) |
48 | 47 | ||
49 | /** CHS Table | 48 | /** CHS Table |
50 | 1MB 2MB 4MB 8MB 16MB 32MB 64MB 128MB | 49 | 1MiB 2MiB 4MiB 8MiB 16MiB 32MiB 64MiB 128MiB |
51 | NCylinder 125 125 250 250 500 500 500 500 | 50 | NCylinder 125 125 250 250 500 500 500 500 |
52 | NHead 4 4 4 4 4 8 8 16 | 51 | NHead 4 4 4 4 4 8 8 16 |
53 | NSector 4 8 8 16 16 16 32 32 | 52 | NSector 4 8 8 16 16 16 32 32 |
@@ -64,14 +63,14 @@ typedef struct { | |||
64 | 63 | ||
65 | /* Must be ordered by size */ | 64 | /* Must be ordered by size */ |
66 | static const chs_entry_t chs_table[] = { | 65 | static const chs_entry_t chs_table[] = { |
67 | { MB( 1), 125, 4, 4 }, | 66 | { MiB( 1), 125, 4, 4 }, |
68 | { MB( 2), 125, 4, 8 }, | 67 | { MiB( 2), 125, 4, 8 }, |
69 | { MB( 4), 250, 4, 8 }, | 68 | { MiB( 4), 250, 4, 8 }, |
70 | { MB( 8), 250, 4, 16 }, | 69 | { MiB( 8), 250, 4, 16 }, |
71 | { MB( 16), 500, 4, 16 }, | 70 | { MiB( 16), 500, 4, 16 }, |
72 | { MB( 32), 500, 8, 16 }, | 71 | { MiB( 32), 500, 8, 16 }, |
73 | { MB( 64), 500, 8, 32 }, | 72 | { MiB( 64), 500, 8, 32 }, |
74 | { MB(128), 500, 16, 32 }, | 73 | { MiB(128), 500, 16, 32 }, |
75 | { 0 }, | 74 | { 0 }, |
76 | }; | 75 | }; |
77 | 76 | ||
@@ -109,14 +108,19 @@ static int get_valid_cis_sector(struct mtd_info *mtd) | |||
109 | int ret, k, cis_sector; | 108 | int ret, k, cis_sector; |
110 | size_t retlen; | 109 | size_t retlen; |
111 | loff_t offset; | 110 | loff_t offset; |
112 | uint8_t sect_buf[SECTOR_SIZE]; | 111 | uint8_t *sect_buf; |
112 | |||
113 | cis_sector = -1; | ||
114 | |||
115 | sect_buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); | ||
116 | if (!sect_buf) | ||
117 | goto out; | ||
113 | 118 | ||
114 | /* | 119 | /* |
115 | * Look for CIS/IDI sector on the first GOOD block (give up after 4 bad | 120 | * Look for CIS/IDI sector on the first GOOD block (give up after 4 bad |
116 | * blocks). If the first good block doesn't contain CIS number the flash | 121 | * blocks). If the first good block doesn't contain CIS number the flash |
117 | * is not SSFDC formatted | 122 | * is not SSFDC formatted |
118 | */ | 123 | */ |
119 | cis_sector = -1; | ||
120 | for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { | 124 | for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { |
121 | if (!mtd->block_isbad(mtd, offset)) { | 125 | if (!mtd->block_isbad(mtd, offset)) { |
122 | ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, | 126 | ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, |
@@ -140,6 +144,8 @@ static int get_valid_cis_sector(struct mtd_info *mtd) | |||
140 | } | 144 | } |
141 | } | 145 | } |
142 | 146 | ||
147 | kfree(sect_buf); | ||
148 | out: | ||
143 | return cis_sector; | 149 | return cis_sector; |
144 | } | 150 | } |
145 | 151 | ||