diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-10-16 10:22:28 -0400 |
---|---|---|
committer | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2008-10-29 14:06:38 -0400 |
commit | c176d0ca8b775a784e38d8afc7c7b42e8906282d (patch) | |
tree | d1caf1593a1d601b4593913015b685bb5bf3c66b /drivers/mtd/nand | |
parent | a4e4f29cbeec200c12c6f3ebedc053a581f90b48 (diff) |
[MTD] sharpsl-nand: cleanup partitions support
Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/sharpsl.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 328e02ee3d8e..17625c0a8f61 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * drivers/mtd/nand/sharpsl.c | 2 | * drivers/mtd/nand/sharpsl.c |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Richard Purdie | 4 | * Copyright (C) 2004 Richard Purdie |
5 | * Copyright (C) 2008 Dmitry Baryshkov | ||
5 | * | 6 | * |
6 | * Based on Sharp's NAND driver sharp_sl.c | 7 | * Based on Sharp's NAND driver sharp_sl.c |
7 | * | 8 | * |
@@ -52,12 +53,12 @@ struct sharpsl_nand { | |||
52 | #define FLCLE (1 << 1) | 53 | #define FLCLE (1 << 1) |
53 | #define FLCE0 (1 << 0) | 54 | #define FLCE0 (1 << 0) |
54 | 55 | ||
56 | #ifdef CONFIG_MTD_PARTITIONS | ||
55 | /* | 57 | /* |
56 | * Define partitions for flash device | 58 | * Define partitions for flash device |
57 | */ | 59 | */ |
58 | #define DEFAULT_NUM_PARTITIONS 3 | 60 | #define DEFAULT_NUM_PARTITIONS 3 |
59 | 61 | ||
60 | static int nr_partitions; | ||
61 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { | 62 | static struct mtd_partition sharpsl_nand_default_partition_info[] = { |
62 | { | 63 | { |
63 | .name = "System Area", | 64 | .name = "System Area", |
@@ -75,6 +76,7 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = { | |||
75 | .size = MTDPART_SIZ_FULL, | 76 | .size = MTDPART_SIZ_FULL, |
76 | }, | 77 | }, |
77 | }; | 78 | }; |
79 | #endif | ||
78 | 80 | ||
79 | /* | 81 | /* |
80 | * hardware specific access to control-lines | 82 | * hardware specific access to control-lines |
@@ -151,7 +153,7 @@ static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, | |||
151 | } | 153 | } |
152 | 154 | ||
153 | #ifdef CONFIG_MTD_PARTITIONS | 155 | #ifdef CONFIG_MTD_PARTITIONS |
154 | const char *part_probes[] = { "cmdlinepart", NULL }; | 156 | static const char *part_probes[] = { "cmdlinepart", NULL }; |
155 | #endif | 157 | #endif |
156 | 158 | ||
157 | /* | 159 | /* |
@@ -160,7 +162,10 @@ const char *part_probes[] = { "cmdlinepart", NULL }; | |||
160 | static int __devinit sharpsl_nand_probe(struct platform_device *pdev) | 162 | static int __devinit sharpsl_nand_probe(struct platform_device *pdev) |
161 | { | 163 | { |
162 | struct nand_chip *this; | 164 | struct nand_chip *this; |
165 | #ifdef CONFIG_MTD_PARTITIONS | ||
163 | struct mtd_partition *sharpsl_partition_info; | 166 | struct mtd_partition *sharpsl_partition_info; |
167 | int nr_partitions; | ||
168 | #endif | ||
164 | struct resource *r; | 169 | struct resource *r; |
165 | int err = 0; | 170 | int err = 0; |
166 | struct sharpsl_nand *sharpsl; | 171 | struct sharpsl_nand *sharpsl; |
@@ -229,10 +234,11 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev) | |||
229 | 234 | ||
230 | /* Register the partitions */ | 235 | /* Register the partitions */ |
231 | sharpsl->mtd.name = "sharpsl-nand"; | 236 | sharpsl->mtd.name = "sharpsl-nand"; |
237 | #ifdef CONFIG_MTD_PARTITIONS | ||
232 | nr_partitions = parse_mtd_partitions(&sharpsl->mtd, part_probes, &sharpsl_partition_info, 0); | 238 | nr_partitions = parse_mtd_partitions(&sharpsl->mtd, part_probes, &sharpsl_partition_info, 0); |
233 | 239 | ||
234 | if (nr_partitions <= 0) { | 240 | if (nr_partitions <= 0) { |
235 | nr_partitions = DEFAULT_NUM_PARTITIONS; | 241 | nr_partitions = ARRAY_SIZE(sharpsl_nand_default_partition_info); |
236 | sharpsl_partition_info = sharpsl_nand_default_partition_info; | 242 | sharpsl_partition_info = sharpsl_nand_default_partition_info; |
237 | if (machine_is_poodle()) { | 243 | if (machine_is_poodle()) { |
238 | sharpsl_partition_info[1].size = 22 * 1024 * 1024; | 244 | sharpsl_partition_info[1].size = 22 * 1024 * 1024; |
@@ -249,11 +255,19 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev) | |||
249 | } | 255 | } |
250 | } | 256 | } |
251 | 257 | ||
252 | add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions); | 258 | err = add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions); |
259 | #else | ||
260 | err = add_mtd_device(&sharpsl->mtd); | ||
261 | #endif | ||
262 | if (err) | ||
263 | goto err_add; | ||
253 | 264 | ||
254 | /* Return happy */ | 265 | /* Return happy */ |
255 | return 0; | 266 | return 0; |
256 | 267 | ||
268 | err_add: | ||
269 | nand_release(&sharpsl->mtd); | ||
270 | |||
257 | err_scan: | 271 | err_scan: |
258 | platform_set_drvdata(pdev, NULL); | 272 | platform_set_drvdata(pdev, NULL); |
259 | iounmap(sharpsl->io); | 273 | iounmap(sharpsl->io); |