* [PATCH 01/43] mtd: add new API for handling MTD registration
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-09 7:20 ` Artem Bityutskiy
2011-06-08 16:05 ` [PATCH 02/43] mtd: mtd_dataflash.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
` (42 subsequent siblings)
43 siblings, 1 reply; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Lots (nearly all) mtd drivers contain nearly the similar code that
calls parse_mtd_partitions, provides some platform-default values, if
parsing fails, and registers mtd device.
This is an aim to provide single implementation of this scenario:
mtd_device_parse_register() which will handle all this parsing and
defaults.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/mtdcore.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mtd/mtd.h | 5 ++++
2 files changed, 65 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c510aff..a0b41e3 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -452,6 +452,66 @@ int mtd_device_register(struct mtd_info *master,
EXPORT_SYMBOL_GPL(mtd_device_register);
/**
+ * mtd_device_parse_register - parse partitions and register an MTD device.
+ *
+ * @mtd: the MTD device to register
+ * @types: the list of MTD partition probes to try, see
+ * 'parse_mtd_partitions()' for more information
+ * @origin: start address of MTD device, %0 unless you are sure you need this.
+ * @parts: fallback partition information to register, if parsing fails;
+ * only valid if %nr_parts > %0
+ * @nr_parts: the number of partitions in parts, if zero then the full
+ * MTD device is registered if no partition info is found
+ *
+ * This function aggregates MTD partitions parsing (done by
+ * 'parse_mtd_partitions()') and MTD device and partitions registering. It
+ * basically follows the most common pattern found in many MTD drivers:
+ *
+ * * It first tries to probe partitions on MTD device @mtd using parsers
+ * specified in @types (if @types is %NULL, then the default list of
+ * parsers is used, see 'parse_mtd_partitions()' for more information).
+ * * If none are found this functions tries to fallback to information
+ * specified in @parts/@nr_parts.
+ * * If any parititioning info was found, this function registers
+ * the found partitions.
+ * * If no partitions were found this function just registers the MTD
+ * device @mtd and exits.
+ *
+ * Returns zero in case of success and a negative error code in case of
+ * failure.
+ */
+int mtd_device_parse_register(struct mtd_info *mtd,
+ const char **types,
+ unsigned long origin,
+ const struct mtd_partition *parts,
+ int nr_parts)
+{
+ int err;
+ struct mtd_partition *real_parts;
+
+ err = parse_mtd_partitions(mtd, types, &real_parts, origin);
+ if (err <= 0 && nr_parts) {
+ real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
+ GFP_KERNEL);
+ err = nr_parts;
+ if (!parts)
+ err = -ENOMEM;
+ }
+
+ if (err > 0) {
+ err = add_mtd_partitions(mtd, real_parts, err);
+ kfree(real_parts);
+ } else if (err == 0) {
+ err = add_mtd_device(mtd);
+ if (err == 1)
+ err = -ENODEV;
+ }
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(mtd_device_parse_register);
+
+/**
* mtd_device_unregister - unregister an existing MTD device.
*
* @master: the MTD device to unregister. This will unregister both the master
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 2541fb8..d28a241 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -327,6 +327,11 @@ struct mtd_partition;
extern int mtd_device_register(struct mtd_info *master,
const struct mtd_partition *parts,
int nr_parts);
+extern int mtd_device_parse_register(struct mtd_info *mtd,
+ const char **part_probe_types,
+ unsigned long origin,
+ const struct mtd_partition *defparts,
+ int defnr_parts);
extern int mtd_device_unregister(struct mtd_info *master);
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
extern int __get_mtd_device(struct mtd_info *mtd);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* Re: [PATCH 01/43] mtd: add new API for handling MTD registration
2011-06-08 16:05 ` [PATCH 01/43] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
@ 2011-06-09 7:20 ` Artem Bityutskiy
0 siblings, 0 replies; 49+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 7:20 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: Russell King, linux-mtd, David Woodhouse
On Wed, 2011-06-08 at 20:05 +0400, Dmitry Eremin-Solenikov wrote:
> Lots (nearly all) mtd drivers contain nearly the similar code that
> calls parse_mtd_partitions, provides some platform-default values, if
> parsing fails, and registers mtd device.
>
> This is an aim to provide single implementation of this scenario:
> mtd_device_parse_register() which will handle all this parsing and
> defaults.
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> drivers/mtd/mtdcore.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/mtd/mtd.h | 5 ++++
> 2 files changed, 65 insertions(+), 0 deletions(-)
I've re-formatted comments - removed no-so-nice-looking tabs, made lines
longer because (my vim can do this). And pushed, thanks!
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH 02/43] mtd: mtd_dataflash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 01/43] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 03/43] mtd: sst25l.c: " Dmitry Eremin-Solenikov
` (41 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/devices/mtd_dataflash.c | 21 +++------------------
1 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 4d4a9cd..8f6b02c 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -637,8 +637,6 @@ add_dataflash_otp(struct spi_device *spi, char *name,
struct flash_platform_data *pdata = spi->dev.platform_data;
char *otp_tag = "";
int err = 0;
- struct mtd_partition *parts;
- int nr_parts = 0;
priv = kzalloc(sizeof *priv, GFP_KERNEL);
if (!priv)
@@ -677,23 +675,10 @@ add_dataflash_otp(struct spi_device *spi, char *name,
pagesize, otp_tag);
dev_set_drvdata(&spi->dev, priv);
- nr_parts = parse_mtd_partitions(device, NULL, &parts, 0);
+ err = mtd_device_parse_register(device, NULL, 0,
+ pdata ? pdata->parts : NULL,
+ pdata ? pdata->nr_parts : 0);
- if (nr_parts <= 0 && pdata && pdata->parts) {
- parts = pdata->parts;
- nr_parts = pdata->nr_parts;
- }
-
- if (nr_parts > 0) {
- priv->partitioned = 1;
- err = mtd_device_register(device, parts, nr_parts);
- goto out;
- }
-
- if (mtd_device_register(device, NULL, 0) == 1)
- err = -ENODEV;
-
-out:
if (!err)
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 03/43] mtd: sst25l.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 01/43] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 02/43] mtd: mtd_dataflash.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 04/43] mtd: bfin-async-flash.c: " Dmitry Eremin-Solenikov
` (40 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/devices/sst25l.c | 33 ++++-----------------------------
1 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c
index cd095af..eaae4e0 100644
--- a/drivers/mtd/devices/sst25l.c
+++ b/drivers/mtd/devices/sst25l.c
@@ -52,8 +52,6 @@ struct sst25l_flash {
struct spi_device *spi;
struct mutex lock;
struct mtd_info mtd;
-
- int partitioned;
};
struct flash_info {
@@ -381,8 +379,6 @@ static int __devinit sst25l_probe(struct spi_device *spi)
struct sst25l_flash *flash;
struct flash_platform_data *data;
int ret, i;
- struct mtd_partition *parts = NULL;
- int nr_parts = 0;
flash_info = sst25l_match_device(spi);
if (!flash_info)
@@ -423,31 +419,10 @@ static int __devinit sst25l_probe(struct spi_device *spi)
flash->mtd.numeraseregions);
- nr_parts = parse_mtd_partitions(&flash->mtd, NULL, &parts, 0);
-
- if (nr_parts <= 0 && data && data->parts) {
- parts = data->parts;
- nr_parts = data->nr_parts;
- }
-
- if (nr_parts > 0) {
- for (i = 0; i < nr_parts; i++) {
- DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
- "{.name = %s, .offset = 0x%llx, "
- ".size = 0x%llx (%lldKiB) }\n",
- i, parts[i].name,
- (long long)parts[i].offset,
- (long long)parts[i].size,
- (long long)(parts[i].size >> 10));
- }
-
- flash->partitioned = 1;
- return mtd_device_register(&flash->mtd, parts,
- nr_parts);
- }
-
- ret = mtd_device_register(&flash->mtd, NULL, 0);
- if (ret == 1) {
+ ret = mtd_device_parse_register(&flash->mtd, NULL, 0,
+ data ? data->parts : NULL,
+ data ? data->nr_parts : 0);
+ if (ret) {
kfree(flash);
dev_set_drvdata(&spi->dev, NULL);
return -ENODEV;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 04/43] mtd: bfin-async-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (2 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 03/43] mtd: sst25l.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 05/43] mtd: dc21285.c: " Dmitry Eremin-Solenikov
` (39 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/bfin-async-flash.c | 16 ++--------------
1 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/mtd/maps/bfin-async-flash.c b/drivers/mtd/maps/bfin-async-flash.c
index d4297a9..246890e 100644
--- a/drivers/mtd/maps/bfin-async-flash.c
+++ b/drivers/mtd/maps/bfin-async-flash.c
@@ -41,7 +41,6 @@ struct async_state {
uint32_t flash_ambctl0, flash_ambctl1;
uint32_t save_ambctl0, save_ambctl1;
unsigned long irq_flags;
- struct mtd_partition *parts;
};
static void switch_to_flash(struct async_state *state)
@@ -165,18 +164,8 @@ static int __devinit bfin_flash_probe(struct platform_device *pdev)
return -ENXIO;
}
- ret = parse_mtd_partitions(state->mtd, part_probe_types, &pdata->parts, 0);
- if (ret > 0) {
- pr_devinit(KERN_NOTICE DRIVER_NAME ": Using commandline partition definition\n");
- mtd_device_register(state->mtd, pdata->parts, ret);
- state->parts = pdata->parts;
- } else if (pdata->nr_parts) {
- pr_devinit(KERN_NOTICE DRIVER_NAME ": Using board partition definition\n");
- mtd_device_register(state->mtd, pdata->parts, pdata->nr_parts);
- } else {
- pr_devinit(KERN_NOTICE DRIVER_NAME ": no partition info available, registering whole flash at once\n");
- mtd_device_register(state->mtd, NULL, 0);
- }
+ mtd_device_parse_register(state->mtd, part_probe_types, 0,
+ pdata->parts, pdata->nr_parts);
platform_set_drvdata(pdev, state);
@@ -188,7 +177,6 @@ static int __devexit bfin_flash_remove(struct platform_device *pdev)
struct async_state *state = platform_get_drvdata(pdev);
gpio_free(state->enet_flash_pin);
mtd_device_unregister(state->mtd);
- kfree(state->parts);
map_destroy(state->mtd);
kfree(state);
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 05/43] mtd: dc21285.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (3 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 04/43] mtd: bfin-async-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 06/43] mtd: gpio-addr-flash.c: " Dmitry Eremin-Solenikov
` (38 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/dc21285.c | 9 +--------
1 files changed, 1 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/maps/dc21285.c b/drivers/mtd/maps/dc21285.c
index 7a9e198..f43b365 100644
--- a/drivers/mtd/maps/dc21285.c
+++ b/drivers/mtd/maps/dc21285.c
@@ -145,14 +145,10 @@ static struct map_info dc21285_map = {
/* Partition stuff */
-static struct mtd_partition *dc21285_parts;
static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
static int __init init_dc21285(void)
{
-
- int nrparts;
-
/* Determine bankwidth */
switch (*CSR_SA110_CNTL & (3<<14)) {
case SA110_CNTL_ROMWIDTH_8:
@@ -200,8 +196,7 @@ static int __init init_dc21285(void)
dc21285_mtd->owner = THIS_MODULE;
- nrparts = parse_mtd_partitions(dc21285_mtd, probes, &dc21285_parts, 0);
- mtd_device_register(dc21285_mtd, dc21285_parts, nrparts);
+ mtd_device_parse_register(dc21285_mtd, probes, 0, NULL, 0);
if(machine_is_ebsa285()) {
/*
@@ -224,8 +219,6 @@ static int __init init_dc21285(void)
static void __exit cleanup_dc21285(void)
{
mtd_device_unregister(dc21285_mtd);
- if (dc21285_parts)
- kfree(dc21285_parts);
map_destroy(dc21285_mtd);
iounmap(dc21285_map.virt);
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 06/43] mtd: gpio-addr-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (4 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 05/43] mtd: dc21285.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 07/43] mtd: h720x-flash.c: " Dmitry Eremin-Solenikov
` (37 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/gpio-addr-flash.c | 16 ++--------------
1 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/mtd/maps/gpio-addr-flash.c b/drivers/mtd/maps/gpio-addr-flash.c
index 7568c5f..1ec66f0 100644
--- a/drivers/mtd/maps/gpio-addr-flash.c
+++ b/drivers/mtd/maps/gpio-addr-flash.c
@@ -187,7 +187,6 @@ static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
*/
static int __devinit gpio_flash_probe(struct platform_device *pdev)
{
- int nr_parts;
size_t i, arr_size;
struct physmap_flash_data *pdata;
struct resource *memory;
@@ -252,20 +251,9 @@ static int __devinit gpio_flash_probe(struct platform_device *pdev)
return -ENXIO;
}
- nr_parts = parse_mtd_partitions(state->mtd, part_probe_types,
- &pdata->parts, 0);
- if (nr_parts > 0) {
- pr_devinit(KERN_NOTICE PFX "Using commandline partition definition\n");
- kfree(pdata->parts);
- } else if (pdata->nr_parts) {
- pr_devinit(KERN_NOTICE PFX "Using board partition definition\n");
- nr_parts = pdata->nr_parts;
- } else {
- pr_devinit(KERN_NOTICE PFX "no partition info available, registering whole flash at once\n");
- nr_parts = 0;
- }
- mtd_device_register(state->mtd, pdata->parts, nr_parts);
+ mtd_device_parse_register(state->mtd, part_probe_types, 0,
+ pdata->parts, pdata->nr_parts);
return 0;
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 07/43] mtd: h720x-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (5 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 06/43] mtd: gpio-addr-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 08/43] mtd: impa7.c: " Dmitry Eremin-Solenikov
` (36 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/h720x-flash.c | 21 ++-------------------
1 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c
index f331a2c..49c1418 100644
--- a/drivers/mtd/maps/h720x-flash.c
+++ b/drivers/mtd/maps/h720x-flash.c
@@ -58,16 +58,11 @@ static struct mtd_partition h720x_partitions[] = {
#define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions)
-static int nr_mtd_parts;
-static struct mtd_partition *mtd_parts;
/*
* Initialize FLASH support
*/
static int __init h720x_mtd_init(void)
{
-
- char *part_type = NULL;
-
h720x_map.virt = ioremap(h720x_map.phys, h720x_map.size);
if (!h720x_map.virt) {
@@ -90,16 +85,8 @@ static int __init h720x_mtd_init(void)
if (mymtd) {
mymtd->owner = THIS_MODULE;
- nr_mtd_parts = parse_mtd_partitions(mymtd, NULL, &mtd_parts, 0);
- if (nr_mtd_parts > 0)
- part_type = "command line";
- if (nr_mtd_parts <= 0) {
- mtd_parts = h720x_partitions;
- nr_mtd_parts = NUM_PARTITIONS;
- part_type = "builtin";
- }
- printk(KERN_INFO "Using %s partition table\n", part_type);
- mtd_device_register(mymtd, mtd_parts, nr_mtd_parts);
+ mtd_device_parse_register(mymtd, NULL, 0,
+ h720x_partitions, NUM_PARTITIONS);
return 0;
}
@@ -118,10 +105,6 @@ static void __exit h720x_mtd_cleanup(void)
map_destroy(mymtd);
}
- /* Free partition info, if commandline partition was used */
- if (mtd_parts && (mtd_parts != h720x_partitions))
- kfree (mtd_parts);
-
if (h720x_map.virt) {
iounmap((void *)h720x_map.virt);
h720x_map.virt = 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 08/43] mtd: impa7.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (6 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 07/43] mtd: h720x-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-09 7:24 ` Artem Bityutskiy
2011-06-08 16:05 ` [PATCH 09/43] mtd: intel_vr_nor.c: " Dmitry Eremin-Solenikov
` (35 subsequent siblings)
43 siblings, 1 reply; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/impa7.c | 25 +++----------------------
1 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/maps/impa7.c b/drivers/mtd/maps/impa7.c
index 2d45a48..7b8b5d8 100644
--- a/drivers/mtd/maps/impa7.c
+++ b/drivers/mtd/maps/impa7.c
@@ -58,15 +58,10 @@ static struct mtd_partition static_partitions[] =
},
};
-static int mtd_parts_nb[NUM_FLASHBANKS];
-static struct mtd_partition *mtd_parts[NUM_FLASHBANKS];
-
-
static int __init init_impa7(void)
{
static const char *rom_probe_types[] = PROBETYPES;
const char **type;
- const char *part_type = 0;
int i;
static struct { u_long addr; u_long size; } pt[NUM_FLASHBANKS] = {
{ WINDOW_ADDR0, WINDOW_SIZE0 },
@@ -96,23 +91,9 @@ static int __init init_impa7(void)
if (impa7_mtd[i]) {
impa7_mtd[i]->owner = THIS_MODULE;
devicesfound++;
- mtd_parts_nb[i] = parse_mtd_partitions(impa7_mtd[i],
- NULL,
- &mtd_parts[i],
- 0);
- if (mtd_parts_nb[i] > 0) {
- part_type = "command line";
- } else {
- mtd_parts[i] = static_partitions;
- mtd_parts_nb[i] = ARRAY_SIZE(static_partitions);
- part_type = "static";
- }
-
- printk(KERN_NOTICE MSG_PREFIX
- "using %s partition definition\n",
- part_type);
- mtd_device_register(impa7_mtd[i],
- mtd_parts[i], mtd_parts_nb[i]);
+ mtd_device_parse_register(impa7_mtd[i], NULL, 0,
+ static_partitions,
+ ARRAY_SIZE(static_partitions));
}
else
iounmap((void *)impa7_map[i].virt);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* Re: [PATCH 08/43] mtd: impa7.c: use mtd_device_parse_register
2011-06-08 16:05 ` [PATCH 08/43] mtd: impa7.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 7:24 ` Artem Bityutskiy
0 siblings, 0 replies; 49+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 7:24 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: Russell King, linux-mtd, David Woodhouse
On Wed, 2011-06-08 at 20:05 +0400, Dmitry Eremin-Solenikov wrote:
> - mtd_device_register(impa7_mtd[i],
> - mtd_parts[i], mtd_parts_nb[i]);
> + mtd_device_parse_register(impa7_mtd[i], NULL, 0,
> + static_partitions,
> + ARRAY_SIZE(static_partitions));
> }
Compare the alignment - original file is aligned with tabs and then few
spaces (the way I prefer), you use only tabs, which is not consistent
with this driver's style. But I'll amend this myself :-)
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH 09/43] mtd: intel_vr_nor.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (7 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 08/43] mtd: impa7.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 10/43] mtd: ixp2000.c: " Dmitry Eremin-Solenikov
` (34 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/intel_vr_nor.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/maps/intel_vr_nor.c b/drivers/mtd/maps/intel_vr_nor.c
index fd612c7..08c2396 100644
--- a/drivers/mtd/maps/intel_vr_nor.c
+++ b/drivers/mtd/maps/intel_vr_nor.c
@@ -44,7 +44,6 @@ struct vr_nor_mtd {
void __iomem *csr_base;
struct map_info map;
struct mtd_info *info;
- int nr_parts;
struct pci_dev *dev;
};
@@ -71,12 +70,9 @@ static void __devexit vr_nor_destroy_partitions(struct vr_nor_mtd *p)
static int __devinit vr_nor_init_partitions(struct vr_nor_mtd *p)
{
- struct mtd_partition *parts;
-
/* register the flash bank */
/* partition the flash bank */
- p->nr_parts = parse_mtd_partitions(p->info, NULL, &parts, 0);
- return mtd_device_register(p->info, parts, p->nr_parts);
+ return mtd_device_parse_register(p->info, NULL, 0, NULL, 0);
}
static void __devexit vr_nor_destroy_mtd_setup(struct vr_nor_mtd *p)
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 10/43] mtd: ixp2000.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (8 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 09/43] mtd: intel_vr_nor.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 11/43] mtd: ixp4xx.c: " Dmitry Eremin-Solenikov
` (33 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/ixp2000.c | 11 +----------
1 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index c00b917..93bf83d 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -38,7 +38,6 @@
struct ixp2000_flash_info {
struct mtd_info *mtd;
struct map_info map;
- struct mtd_partition *partitions;
struct resource *res;
};
@@ -125,8 +124,6 @@ static int ixp2000_flash_remove(struct platform_device *dev)
if (info->map.map_priv_1)
iounmap((void *) info->map.map_priv_1);
- kfree(info->partitions);
-
if (info->res) {
release_resource(info->res);
kfree(info->res);
@@ -228,13 +225,7 @@ static int ixp2000_flash_probe(struct platform_device *dev)
}
info->mtd->owner = THIS_MODULE;
- err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0);
- if (err > 0) {
- err = mtd_device_register(info->mtd, info->partitions, err);
- if(err)
- dev_err(&dev->dev, "Could not parse partitions\n");
- }
-
+ err = mtd_device_parse_register(info->mtd, probes, 0, NULL, 0);
if (err)
goto Error;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 11/43] mtd: ixp4xx.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (9 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 10/43] mtd: ixp2000.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 12/43] mtd: lantiq-flash.c: " Dmitry Eremin-Solenikov
` (32 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/ixp4xx.c | 29 ++++-------------------------
1 files changed, 4 insertions(+), 25 deletions(-)
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 155b219..3040901 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -145,7 +145,6 @@ static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
struct ixp4xx_flash_info {
struct mtd_info *mtd;
struct map_info map;
- struct mtd_partition *partitions;
struct resource *res;
};
@@ -168,8 +167,6 @@ static int ixp4xx_flash_remove(struct platform_device *dev)
if (info->map.virt)
iounmap(info->map.virt);
- kfree(info->partitions);
-
if (info->res) {
release_resource(info->res);
kfree(info->res);
@@ -185,8 +182,6 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
{
struct flash_platform_data *plat = dev->dev.platform_data;
struct ixp4xx_flash_info *info;
- const char *part_type = NULL;
- int nr_parts = 0;
int err = -1;
if (!plat)
@@ -252,28 +247,12 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
/* Use the fast version */
info->map.write = ixp4xx_write16;
- nr_parts = parse_mtd_partitions(info->mtd, probes, &info->partitions,
- dev->resource->start);
- if (nr_parts > 0) {
- part_type = "dynamic";
- } else {
- info->partitions = plat->parts;
- nr_parts = plat->nr_parts;
- part_type = "static";
- }
- if (nr_parts == 0)
- printk(KERN_NOTICE "IXP4xx flash: no partition info "
- "available, registering whole flash\n");
- else
- printk(KERN_NOTICE "IXP4xx flash: using %s partition "
- "definition\n", part_type);
-
- err = mtd_device_register(info->mtd, info->partitions, nr_parts);
- if (err)
+ err = mtd_device_parse_register(info->mtd, probes, dev->resource->start,
+ plat->parts, plat->nr_parts);
+ if (err) {
printk(KERN_ERR "Could not parse partitions\n");
-
- if (err)
goto Error;
+ }
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 12/43] mtd: lantiq-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (10 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 11/43] mtd: ixp4xx.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 13/43] mtd: latch-addr-flash.c: " Dmitry Eremin-Solenikov
` (31 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/lantiq-flash.c | 14 ++------------
1 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/maps/lantiq-flash.c b/drivers/mtd/maps/lantiq-flash.c
index 57ea3fe..f750784 100644
--- a/drivers/mtd/maps/lantiq-flash.c
+++ b/drivers/mtd/maps/lantiq-flash.c
@@ -112,9 +112,7 @@ ltq_mtd_probe(struct platform_device *pdev)
{
struct physmap_flash_data *ltq_mtd_data = dev_get_platdata(&pdev->dev);
struct ltq_mtd *ltq_mtd;
- struct mtd_partition *parts;
struct resource *res;
- int nr_parts = 0;
struct cfi_private *cfi;
int err;
@@ -170,16 +168,8 @@ ltq_mtd_probe(struct platform_device *pdev)
cfi->addr_unlock1 ^= 1;
cfi->addr_unlock2 ^= 1;
- nr_parts = parse_mtd_partitions(ltq_mtd->mtd, NULL, &parts, 0);
- if (nr_parts > 0) {
- dev_info(&pdev->dev,
- "using %d partitions from cmdline", nr_parts);
- } else {
- nr_parts = ltq_mtd_data->nr_parts;
- parts = ltq_mtd_data->parts;
- }
-
- err = add_mtd_partitions(ltq_mtd->mtd, parts, nr_parts);
+ err = mtd_device_parse_register(ltq_mtd->mtd, NULL, 0,
+ ltq_mtd_data->parts, ltq_mtd_data->nr_parts);
if (err) {
dev_err(&pdev->dev, "failed to add partitions\n");
goto err_destroy;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 13/43] mtd: latch-addr-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (11 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 12/43] mtd: lantiq-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 14/43] mtd: physmap.c: " Dmitry Eremin-Solenikov
` (30 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/latch-addr-flash.c | 21 ++-------------------
1 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/maps/latch-addr-flash.c b/drivers/mtd/maps/latch-addr-flash.c
index 09cf704..119baa7 100644
--- a/drivers/mtd/maps/latch-addr-flash.c
+++ b/drivers/mtd/maps/latch-addr-flash.c
@@ -33,9 +33,6 @@ struct latch_addr_flash_info {
/* cache; could be found out of res */
unsigned long win_mask;
- int nr_parts;
- struct mtd_partition *parts;
-
spinlock_t lock;
};
@@ -110,8 +107,6 @@ static int latch_addr_flash_remove(struct platform_device *dev)
latch_addr_data = dev->dev.platform_data;
if (info->mtd != NULL) {
- if (info->nr_parts)
- kfree(info->parts);
mtd_device_unregister(info->mtd);
map_destroy(info->mtd);
}
@@ -204,20 +199,8 @@ static int __devinit latch_addr_flash_probe(struct platform_device *dev)
}
info->mtd->owner = THIS_MODULE;
- err = parse_mtd_partitions(info->mtd, NULL, &info->parts, 0);
- if (err > 0) {
- mtd_device_register(info->mtd, info->parts, err);
- return 0;
- }
- if (latch_addr_data->nr_parts) {
- pr_notice("Using latch-addr-flash partition information\n");
- mtd_device_register(info->mtd,
- latch_addr_data->parts,
- latch_addr_data->nr_parts);
- return 0;
- }
-
- mtd_device_register(info->mtd, NULL, 0);
+ mtd_device_parse_register(info->mtd, NULL, 0,
+ latch_addr_data->parts, latch_addr_data->nr_parts);
return 0;
iounmap:
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 14/43] mtd: physmap.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (12 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 13/43] mtd: latch-addr-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-09 7:32 ` Artem Bityutskiy
2011-06-08 16:05 ` [PATCH 15/43] mtd: plat-ram.c: " Dmitry Eremin-Solenikov
` (29 subsequent siblings)
43 siblings, 1 reply; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/physmap.c | 23 ++---------------------
1 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 2174d10..256f787 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -27,8 +27,6 @@ struct physmap_flash_info {
struct mtd_info *mtd[MAX_RESOURCES];
struct mtd_info *cmtd;
struct map_info map[MAX_RESOURCES];
- int nr_parts;
- struct mtd_partition *parts;
};
static int physmap_flash_remove(struct platform_device *dev)
@@ -46,8 +44,6 @@ static int physmap_flash_remove(struct platform_device *dev)
if (info->cmtd) {
mtd_device_unregister(info->cmtd);
- if (info->nr_parts)
- kfree(info->parts);
if (info->cmtd != info->mtd[0])
mtd_concat_destroy(info->cmtd);
}
@@ -175,23 +171,8 @@ static int physmap_flash_probe(struct platform_device *dev)
if (err)
goto err_out;
- err = parse_mtd_partitions(info->cmtd, part_probe_types,
- &info->parts, 0);
- if (err > 0) {
- mtd_device_register(info->cmtd, info->parts, err);
- info->nr_parts = err;
- return 0;
- }
-
- if (physmap_data->nr_parts) {
- printk(KERN_NOTICE "Using physmap partition information\n");
- mtd_device_register(info->cmtd, physmap_data->parts,
- physmap_data->nr_parts);
- return 0;
- }
-
- mtd_device_register(info->cmtd, NULL, 0);
-
+ mtd_device_parse_register(info->cmtd, part_probe_types, 0,
+ physmap_data->parts, physmap_data->nr_parts);
return 0;
err_out:
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* Re: [PATCH 14/43] mtd: physmap.c: use mtd_device_parse_register
2011-06-08 16:05 ` [PATCH 14/43] mtd: physmap.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 7:32 ` Artem Bityutskiy
0 siblings, 0 replies; 49+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 7:32 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: Russell King, linux-mtd, David Woodhouse
On Wed, 2011-06-08 at 20:05 +0400, Dmitry Eremin-Solenikov wrote:
> - if (physmap_data->nr_parts) {
> - printk(KERN_NOTICE "Using physmap partition information\n");
> - mtd_device_register(info->cmtd, physmap_data->parts,
> - physmap_data->nr_parts);
> - return 0;
> - }
> -
> - mtd_device_register(info->cmtd, NULL, 0);
> -
> + mtd_device_parse_register(info->cmtd, part_probe_types, 0,
> + physmap_data->parts, physmap_data->nr_parts);
Same here.
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 49+ messages in thread
* [PATCH 15/43] mtd: plat-ram.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (13 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 14/43] mtd: physmap.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 16/43] mtd: pxa2xx-flash.c: " Dmitry Eremin-Solenikov
` (28 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/plat-ram.c | 23 ++---------------------
1 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index 9ca1ecc..94f5534 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -44,8 +44,6 @@ struct platram_info {
struct device *dev;
struct mtd_info *mtd;
struct map_info map;
- struct mtd_partition *partitions;
- bool free_partitions;
struct resource *area;
struct platdata_mtd_ram *pdata;
};
@@ -95,10 +93,6 @@ static int platram_remove(struct platform_device *pdev)
if (info->mtd) {
mtd_device_unregister(info->mtd);
- if (info->partitions) {
- if (info->free_partitions)
- kfree(info->partitions);
- }
map_destroy(info->mtd);
}
@@ -228,21 +222,8 @@ static int platram_probe(struct platform_device *pdev)
/* check to see if there are any available partitions, or wether
* to add this device whole */
- if (!pdata->nr_partitions) {
- /* try to probe using the supplied probe type */
- if (pdata->probes) {
- err = parse_mtd_partitions(info->mtd, pdata->probes,
- &info->partitions, 0);
- info->free_partitions = 1;
- if (err > 0)
- err = mtd_device_register(info->mtd,
- info->partitions, err);
- }
- }
- /* use the static mapping */
- else
- err = mtd_device_register(info->mtd, pdata->partitions,
- pdata->nr_partitions);
+ err = mtd_device_parse_register(info->mtd, pdata->probes, 0,
+ pdata->partitions, pdata->nr_partitions);
if (!err)
dev_info(&pdev->dev, "registered mtd device\n");
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 16/43] mtd: pxa2xx-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (14 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 15/43] mtd: plat-ram.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 17/43] mtd: rbtx4939-flash.c: " Dmitry Eremin-Solenikov
` (27 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/pxa2xx-flash.c | 20 +-------------------
1 files changed, 1 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index f59d62f..8fb8198 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -41,8 +41,6 @@ static void pxa2xx_map_inval_cache(struct map_info *map, unsigned long from,
}
struct pxa2xx_flash_info {
- struct mtd_partition *parts;
- int nr_parts;
struct mtd_info *mtd;
struct map_info map;
};
@@ -55,9 +53,7 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev)
{
struct flash_platform_data *flash = pdev->dev.platform_data;
struct pxa2xx_flash_info *info;
- struct mtd_partition *parts;
struct resource *res;
- int ret = 0;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
@@ -71,8 +67,6 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev)
info->map.bankwidth = flash->width;
info->map.phys = res->start;
info->map.size = res->end - res->start + 1;
- info->parts = flash->parts;
- info->nr_parts = flash->nr_parts;
info->map.virt = ioremap(info->map.phys, info->map.size);
if (!info->map.virt) {
@@ -104,18 +98,7 @@ static int __devinit pxa2xx_flash_probe(struct platform_device *pdev)
}
info->mtd->owner = THIS_MODULE;
- ret = parse_mtd_partitions(info->mtd, probes, &parts, 0);
-
- if (ret > 0) {
- info->nr_parts = ret;
- info->parts = parts;
- }
-
- if (!info->nr_parts)
- printk("Registering %s as whole device\n",
- info->map.name);
-
- mtd_device_register(info->mtd, info->parts, info->nr_parts);
+ mtd_device_parse_register(info->mtd, probes, 0, NULL, 0);
platform_set_drvdata(pdev, info);
return 0;
@@ -133,7 +116,6 @@ static int __devexit pxa2xx_flash_remove(struct platform_device *dev)
iounmap(info->map.virt);
if (info->map.cached)
iounmap(info->map.cached);
- kfree(info->parts);
kfree(info);
return 0;
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 17/43] mtd: rbtx4939-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (15 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 16/43] mtd: pxa2xx-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 18/43] mtd: sa1100-flash.c: " Dmitry Eremin-Solenikov
` (26 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/rbtx4939-flash.c | 21 ++++-----------------
1 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/maps/rbtx4939-flash.c b/drivers/mtd/maps/rbtx4939-flash.c
index 5d15b6b..0237f19 100644
--- a/drivers/mtd/maps/rbtx4939-flash.c
+++ b/drivers/mtd/maps/rbtx4939-flash.c
@@ -25,8 +25,6 @@
struct rbtx4939_flash_info {
struct mtd_info *mtd;
struct map_info map;
- int nr_parts;
- struct mtd_partition *parts;
};
static int rbtx4939_flash_remove(struct platform_device *dev)
@@ -41,8 +39,6 @@ static int rbtx4939_flash_remove(struct platform_device *dev)
if (info->mtd) {
struct rbtx4939_flash_data *pdata = dev->dev.platform_data;
- if (info->nr_parts)
- kfree(info->parts);
mtd_device_unregister(info->mtd);
map_destroy(info->mtd);
}
@@ -106,20 +102,11 @@ static int rbtx4939_flash_probe(struct platform_device *dev)
info->mtd->owner = THIS_MODULE;
if (err)
goto err_out;
- err = parse_mtd_partitions(info->mtd, NULL, &info->parts, 0);
- if (err > 0) {
- mtd_device_register(info->mtd, info->parts, err);
- info->nr_parts = err;
- return 0;
- }
+ err = mtd_device_parse_register(info->mtd, NULL, 0,
+ pdata->parts, pdata->nr_parts);
- if (pdata->nr_parts) {
- pr_notice("Using rbtx4939 partition information\n");
- mtd_device_register(info->mtd, pdata->parts, pdata->nr_parts);
- return 0;
- }
-
- mtd_device_register(info->mtd, NULL, 0);
+ if (err)
+ goto err_out;
return 0;
err_out:
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 18/43] mtd: sa1100-flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (16 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 17/43] mtd: rbtx4939-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 19/43] mtd: solutionengine.c: " Dmitry Eremin-Solenikov
` (25 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/sa1100-flash.c | 30 +++---------------------------
1 files changed, 3 insertions(+), 27 deletions(-)
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index a9b5e0e..fa9c0a9 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -131,10 +131,8 @@ struct sa_subdev_info {
};
struct sa_info {
- struct mtd_partition *parts;
struct mtd_info *mtd;
int num_subdev;
- unsigned int nr_parts;
struct sa_subdev_info subdev[0];
};
@@ -231,8 +229,6 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
mtd_concat_destroy(info->mtd);
}
- kfree(info->parts);
-
for (i = info->num_subdev - 1; i >= 0; i--)
sa1100_destroy_subdev(&info->subdev[i]);
kfree(info);
@@ -341,10 +337,8 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
static int __devinit sa1100_mtd_probe(struct platform_device *pdev)
{
struct flash_platform_data *plat = pdev->dev.platform_data;
- struct mtd_partition *parts;
- const char *part_type = NULL;
struct sa_info *info;
- int err, nr_parts = 0;
+ int err;
if (!plat)
return -ENODEV;
@@ -358,26 +352,8 @@ static int __devinit sa1100_mtd_probe(struct platform_device *pdev)
/*
* Partition selection stuff.
*/
- nr_parts = parse_mtd_partitions(info->mtd, part_probes, &parts, 0);
- if (nr_parts > 0) {
- info->parts = parts;
- part_type = "dynamic";
- } else {
- parts = plat->parts;
- nr_parts = plat->nr_parts;
- part_type = "static";
- }
-
- if (nr_parts == 0)
- printk(KERN_NOTICE "SA1100 flash: no partition info "
- "available, registering whole flash\n");
- else
- printk(KERN_NOTICE "SA1100 flash: using %s partition "
- "definition\n", part_type);
-
- mtd_device_register(info->mtd, parts, nr_parts);
-
- info->nr_parts = nr_parts;
+ mtd_device_parse_register(info->mtd, part_probes, 0,
+ plat->parts, plat->nr_parts);
platform_set_drvdata(pdev, info);
err = 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 19/43] mtd: solutionengine.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (17 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 18/43] mtd: sa1100-flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 20/43] mtd: wr_sbc82xx_flash.c: " Dmitry Eremin-Solenikov
` (24 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/solutionengine.c | 30 +++++++-----------------------
1 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/maps/solutionengine.c b/drivers/mtd/maps/solutionengine.c
index cbf6bad..496c407 100644
--- a/drivers/mtd/maps/solutionengine.c
+++ b/drivers/mtd/maps/solutionengine.c
@@ -19,8 +19,6 @@
static struct mtd_info *flash_mtd;
static struct mtd_info *eprom_mtd;
-static struct mtd_partition *parsed_parts;
-
struct map_info soleng_eprom_map = {
.name = "Solution Engine EPROM",
.size = 0x400000,
@@ -51,12 +49,14 @@ static struct mtd_partition superh_se_partitions[] = {
.size = MTDPART_SIZ_FULL,
}
};
+#define NUM_PARTITIONS ARRAY_SIZE(superh_se_partitions)
+#else
+#define superh_se_partitions NULL
+#define NUM_PARTITIONS 0
#endif /* CONFIG_MTD_SUPERH_RESERVE */
static int __init init_soleng_maps(void)
{
- int nr_parts = 0;
-
/* First probe at offset 0 */
soleng_flash_map.phys = 0;
soleng_flash_map.virt = (void __iomem *)P2SEGADDR(0);
@@ -92,21 +92,8 @@ static int __init init_soleng_maps(void)
mtd_device_register(eprom_mtd, NULL, 0);
}
- nr_parts = parse_mtd_partitions(flash_mtd, probes, &parsed_parts, 0);
-
-#ifdef CONFIG_MTD_SUPERH_RESERVE
- if (nr_parts <= 0) {
- printk(KERN_NOTICE "Using configured partition at 0x%08x.\n",
- CONFIG_MTD_SUPERH_RESERVE);
- parsed_parts = superh_se_partitions;
- nr_parts = sizeof(superh_se_partitions)/sizeof(*parsed_parts);
- }
-#endif /* CONFIG_MTD_SUPERH_RESERVE */
-
- if (nr_parts > 0)
- mtd_device_register(flash_mtd, parsed_parts, nr_parts);
- else
- mtd_device_register(flash_mtd, NULL, 0);
+ mtd_device_parse_register(flash_mtd, probes, 0,
+ superh_se_partitions, NUM_PARTITIONS);
return 0;
}
@@ -118,10 +105,7 @@ static void __exit cleanup_soleng_maps(void)
map_destroy(eprom_mtd);
}
- if (parsed_parts)
- mtd_device_unregister(flash_mtd);
- else
- mtd_device_unregister(flash_mtd);
+ mtd_device_unregister(flash_mtd);
map_destroy(flash_mtd);
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 20/43] mtd: wr_sbc82xx_flash.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (18 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 19/43] mtd: solutionengine.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 21/43] mtd: atmel_nand.c: " Dmitry Eremin-Solenikov
` (23 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/maps/wr_sbc82xx_flash.c | 30 +++++++++++-------------------
1 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c
index 901ce96..aaec902 100644
--- a/drivers/mtd/maps/wr_sbc82xx_flash.c
+++ b/drivers/mtd/maps/wr_sbc82xx_flash.c
@@ -20,7 +20,6 @@
#include <asm/immap_cpm2.h>
static struct mtd_info *sbcmtd[3];
-static struct mtd_partition *sbcmtd_parts[3];
struct map_info sbc82xx_flash_map[3] = {
{.name = "Boot flash"},
@@ -101,6 +100,7 @@ static int __init init_sbc82xx_flash(void)
for (i=0; i<3; i++) {
int8_t flashcs[3] = { 0, 6, 1 };
int nr_parts;
+ struct mtd_partition *defparts;
printk(KERN_NOTICE "PowerQUICC II %s (%ld MiB on CS%d",
sbc82xx_flash_map[i].name,
@@ -129,24 +129,20 @@ static int __init init_sbc82xx_flash(void)
sbcmtd[i]->owner = THIS_MODULE;
- nr_parts = parse_mtd_partitions(sbcmtd[i], part_probes,
- &sbcmtd_parts[i], 0);
- if (nr_parts > 0) {
- mtd_device_register(sbcmtd[i], sbcmtd_parts[i],
- nr_parts);
- continue;
- }
-
/* No partitioning detected. Use default */
if (i == 2) {
- mtd_device_register(sbcmtd[i], NULL, 0);
+ defparts = NULL;
+ nr_parts = 0;
} else if (i == bigflash) {
- mtd_device_register(sbcmtd[i], bigflash_parts,
- ARRAY_SIZE(bigflash_parts));
+ defparts = bigflash_parts;
+ nr_parts = ARRAY_SIZE(bigflash_parts);
} else {
- mtd_device_register(sbcmtd[i], smallflash_parts,
- ARRAY_SIZE(smallflash_parts));
+ defparts = smallflash_parts;
+ nr_parts = ARRAY_SIZE(smallflash_parts);
}
+
+ mtd_device_parse_register(sbcmtd[i], part_probes, 0,
+ defparts, nr_parts);
}
return 0;
}
@@ -159,12 +155,8 @@ static void __exit cleanup_sbc82xx_flash(void)
if (!sbcmtd[i])
continue;
- if (i<2 || sbcmtd_parts[i])
- mtd_device_unregister(sbcmtd[i]);
- else
- mtd_device_unregister(sbcmtd[i]);
+ mtd_device_unregister(sbcmtd[i]);
- kfree(sbcmtd_parts[i]);
map_destroy(sbcmtd[i]);
iounmap((void *)sbc82xx_flash_map[i].virt);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 21/43] mtd: atmel_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (19 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 20/43] mtd: wr_sbc82xx_flash.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 22/43] mtd: bcm_umi_nand.c: " Dmitry Eremin-Solenikov
` (22 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/atmel_nand.c | 19 ++-----------------
1 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index a19a112..6702208 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -491,8 +491,6 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
struct resource *regs;
struct resource *mem;
int res;
- struct mtd_partition *partitions = NULL;
- int num_partitions = 0;
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) {
@@ -651,24 +649,11 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
}
mtd->name = "atmel_nand";
- num_partitions = parse_mtd_partitions(mtd, NULL, &partitions, 0);
- if (num_partitions <= 0 && host->board->parts) {
- partitions = host->board->parts;
- num_partitions = host->board->num_parts;
- }
-
- if ((!partitions) || (num_partitions == 0)) {
- printk(KERN_ERR "atmel_nand: No partitions defined, or unsupported device.\n");
- res = -ENXIO;
- goto err_no_partitions;
- }
-
- res = mtd_device_register(mtd, partitions, num_partitions);
+ res = mtd_device_parse_register(mtd, NULL, 0,
+ host->board->parts, host->board->num_parts);
if (!res)
return res;
-err_no_partitions:
- nand_release(mtd);
err_scan_tail:
err_scan_ident:
err_no_card:
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 22/43] mtd: bcm_umi_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (20 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 21/43] mtd: atmel_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 23/43] mtd: cafe_nand.c: " Dmitry Eremin-Solenikov
` (21 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/bcm_umi_nand.c | 19 ++-----------------
1 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/nand/bcm_umi_nand.c b/drivers/mtd/nand/bcm_umi_nand.c
index e0230c5..d98bc48 100644
--- a/drivers/mtd/nand/bcm_umi_nand.c
+++ b/drivers/mtd/nand/bcm_umi_nand.c
@@ -489,23 +489,8 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
}
/* Register the partitions */
- {
- int nr_partitions;
- struct mtd_partition *partition_info;
-
- board_mtd->name = "bcm_umi-nand";
- nr_partitions = parse_mtd_partitions(board_mtd, NULL,
- &partition_info, 0);
-
- if (nr_partitions <= 0) {
- printk(KERN_ERR "BCM UMI NAND: Too few partitions - %d\n",
- nr_partitions);
- iounmap(bcm_umi_io_base);
- kfree(board_mtd);
- return -EIO;
- }
- mtd_device_register(board_mtd, partition_info, nr_partitions);
- }
+ board_mtd->name = "bcm_umi-nand";
+ mtd_device_parse_register(board_mtd, NULL, 0, NULL, 0);
/* Return happy */
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 23/43] mtd: cafe_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (21 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 22/43] mtd: bcm_umi_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 24/43] mtd: cmx270_nand.c: " Dmitry Eremin-Solenikov
` (20 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/cafe_nand.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 88ac4b5..db3bfac 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -57,7 +57,6 @@
struct cafe_priv {
struct nand_chip nand;
- struct mtd_partition *parts;
struct pci_dev *pdev;
void __iomem *mmio;
struct rs_control *rs;
@@ -630,8 +629,6 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
struct cafe_priv *cafe;
uint32_t ctrl;
int err = 0;
- struct mtd_partition *parts;
- int nr_parts;
/* Very old versions shared the same PCI ident for all three
functions on the chip. Verify the class too... */
@@ -804,12 +801,8 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
mtd_device_register(mtd, NULL, 0);
mtd->name = "cafe_nand";
- nr_parts = parse_mtd_partitions(mtd, part_probes, &parts, 0);
- if (nr_parts > 0) {
- cafe->parts = parts;
- dev_info(&cafe->pdev->dev, "%d partitions found\n", nr_parts);
- mtd_device_register(mtd, parts, nr_parts);
- }
+ mtd_device_parse_register(mtd, part_probes, 0, NULL, 0);
+
goto out;
out_irq:
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 24/43] mtd: cmx270_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (22 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 23/43] mtd: cafe_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 25/43] mtd: cs553x_nand.c: " Dmitry Eremin-Solenikov
` (19 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/cmx270_nand.c | 20 ++------------------
1 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c
index f8f5b7c..8305692 100644
--- a/drivers/mtd/nand/cmx270_nand.c
+++ b/drivers/mtd/nand/cmx270_nand.c
@@ -149,9 +149,6 @@ static int cmx270_device_ready(struct mtd_info *mtd)
static int __init cmx270_init(void)
{
struct nand_chip *this;
- const char *part_type;
- struct mtd_partition *mtd_parts;
- int mtd_parts_nb = 0;
int ret;
if (!(machine_is_armcore() && cpu_is_pxa27x()))
@@ -220,22 +217,9 @@ static int __init cmx270_init(void)
goto err_scan;
}
- mtd_parts_nb = parse_mtd_partitions(cmx270_nand_mtd, NULL,
- &mtd_parts, 0);
- if (mtd_parts_nb > 0)
- part_type = "command line";
- else
- mtd_parts_nb = 0;
-
- if (!mtd_parts_nb) {
- mtd_parts = partition_info;
- mtd_parts_nb = NUM_PARTITIONS;
- part_type = "static";
- }
-
/* Register the partitions */
- pr_notice("Using %s partition definition\n", part_type);
- ret = mtd_device_register(cmx270_nand_mtd, mtd_parts, mtd_parts_nb);
+ ret = mtd_device_parse_register(cmx270_nand_mtd, NULL, 0,
+ partition_info, NUM_PARTITIONS);
if (ret)
goto err_scan;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 25/43] mtd: cs553x_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (23 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 24/43] mtd: cmx270_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 26/43] mtd: davinci_nand.c: " Dmitry Eremin-Solenikov
` (18 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/cs553x_nand.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
index b2bdf72..a60ae39 100644
--- a/drivers/mtd/nand/cs553x_nand.c
+++ b/drivers/mtd/nand/cs553x_nand.c
@@ -283,8 +283,6 @@ static int __init cs553x_init(void)
int err = -ENXIO;
int i;
uint64_t val;
- int mtd_parts_nb = 0;
- struct mtd_partition *mtd_parts = NULL;
/* If the CPU isn't a Geode GX or LX, abort */
if (!is_geode())
@@ -314,11 +312,9 @@ static int __init cs553x_init(void)
do mtdconcat etc. if we want to. */
for (i = 0; i < NR_CS553X_CONTROLLERS; i++) {
if (cs553x_mtd[i]) {
-
/* If any devices registered, return success. Else the last error. */
- mtd_parts_nb = parse_mtd_partitions(cs553x_mtd[i], NULL, &mtd_parts, 0);
- mtd_device_register(cs553x_mtd[i], mtd_parts,
- mtd_parts_nb);
+ mtd_device_parse_register(cs553x_mtd[i], NULL, 0,
+ NULL, 0);
err = 0;
}
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 26/43] mtd: davinci_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (24 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 25/43] mtd: cs553x_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 27/43] mtd: edb7312.c: " Dmitry Eremin-Solenikov
` (17 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/davinci_nand.c | 25 ++-----------------------
1 files changed, 2 insertions(+), 23 deletions(-)
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 70c92a5..c153e1f 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -57,7 +57,6 @@ struct davinci_nand_info {
struct device *dev;
struct clk *clk;
- bool partitioned;
bool is_readmode;
@@ -530,8 +529,6 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
int ret;
uint32_t val;
nand_ecc_modes_t ecc_mode;
- struct mtd_partition *mtd_parts = NULL;
- int mtd_parts_nb = 0;
/* insist on board-specific configuration */
if (!pdata)
@@ -753,26 +750,8 @@ syndrome_done:
if (ret < 0)
goto err_scan;
- mtd_parts_nb = parse_mtd_partitions(&info->mtd, NULL, &mtd_parts, 0);
-
- if (mtd_parts_nb <= 0) {
- mtd_parts = pdata->parts;
- mtd_parts_nb = pdata->nr_parts;
- }
-
- /* Register any partitions */
- if (mtd_parts_nb > 0) {
- ret = mtd_device_register(&info->mtd, mtd_parts,
- mtd_parts_nb);
- if (ret == 0)
- info->partitioned = true;
- }
-
- /* If there's no partition info, just package the whole chip
- * as a single MTD device.
- */
- if (!info->partitioned)
- ret = mtd_device_register(&info->mtd, NULL, 0) ? -ENODEV : 0;
+ ret = mtd_device_parse_register(&info->mtd, NULL, 0,
+ pdata->parts, pdata->nr_parts);
if (ret < 0)
goto err_scan;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 27/43] mtd: edb7312.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (25 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 26/43] mtd: davinci_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 28/43] mtd: fsmc_nand.c: " Dmitry Eremin-Solenikov
` (16 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/edb7312.c | 17 ++---------------
1 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
index 2f9374b..0b1bb91 100644
--- a/drivers/mtd/nand/edb7312.c
+++ b/drivers/mtd/nand/edb7312.c
@@ -104,9 +104,6 @@ static int ep7312_device_ready(struct mtd_info *mtd)
static int __init ep7312_init(void)
{
struct nand_chip *this;
- const char *part_type = 0;
- int mtd_parts_nb = 0;
- struct mtd_partition *mtd_parts = 0;
void __iomem *ep7312_fio_base;
/* Allocate memory for MTD device structure and private data */
@@ -156,20 +153,10 @@ static int __init ep7312_init(void)
return -ENXIO;
}
ep7312_mtd->name = "edb7312-nand";
- mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, NULL, &mtd_parts, 0);
- if (mtd_parts_nb > 0)
- part_type = "command line";
- else
- mtd_parts_nb = 0;
- if (mtd_parts_nb == 0) {
- mtd_parts = partition_info;
- mtd_parts_nb = NUM_PARTITIONS;
- part_type = "static";
- }
/* Register the partitions */
- printk(KERN_NOTICE "Using %s partition definition\n", part_type);
- mtd_device_register(ep7312_mtd, mtd_parts, mtd_parts_nb);
+ mtd_device_register(ep7312_mtd, NULL, 0,
+ partition_info, NUM_PARTITIONS);
/* Return happy */
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 28/43] mtd: fsmc_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (26 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 27/43] mtd: edb7312.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 29/43] mtd: h1910.c: " Dmitry Eremin-Solenikov
` (15 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/fsmc_nand.c | 66 ++++++------------------------------------
1 files changed, 9 insertions(+), 57 deletions(-)
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index a39c224..8cc8065 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -146,7 +146,7 @@ static struct mtd_partition partition_info_16KB_blk[] = {
{
.name = "Root File System",
.offset = 0x460000,
- .size = 0,
+ .size = MTDPART_SIZ_FULL,
},
};
@@ -173,7 +173,7 @@ static struct mtd_partition partition_info_128KB_blk[] = {
{
.name = "Root File System",
.offset = 0x800000,
- .size = 0,
+ .size = MTDPART_SIZ_FULL,
},
};
@@ -184,8 +184,6 @@ static struct mtd_partition partition_info_128KB_blk[] = {
* @pid: Part ID on the AMBA PrimeCell format
* @mtd: MTD info for a NAND flash.
* @nand: Chip related info for a NAND flash.
- * @partitions: Partition info for a NAND Flash.
- * @nr_partitions: Total number of partition of a NAND flash.
*
* @ecc_place: ECC placing locations in oobfree type format.
* @bank: Bank number for probed device.
@@ -200,8 +198,6 @@ struct fsmc_nand_data {
u32 pid;
struct mtd_info mtd;
struct nand_chip nand;
- struct mtd_partition *partitions;
- unsigned int nr_partitions;
struct fsmc_eccplace *ecc_place;
unsigned int bank;
@@ -717,57 +713,13 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
* Check for partition info passed
*/
host->mtd.name = "nand";
- host->nr_partitions = parse_mtd_partitions(&host->mtd, NULL,
- &host->partitions, 0);
- if (host->nr_partitions <= 0) {
- /*
- * Check if partition info passed via command line
- */
- if (pdata->partitions) {
- host->partitions = pdata->partitions;
- host->nr_partitions = pdata->nr_partitions;
- } else {
- struct mtd_partition *partition;
- int i;
-
- /* Select the default partitions info */
- switch (host->mtd.size) {
- case 0x01000000:
- case 0x02000000:
- case 0x04000000:
- host->partitions = partition_info_16KB_blk;
- host->nr_partitions =
- sizeof(partition_info_16KB_blk) /
- sizeof(struct mtd_partition);
- break;
- case 0x08000000:
- case 0x10000000:
- case 0x20000000:
- case 0x40000000:
- host->partitions = partition_info_128KB_blk;
- host->nr_partitions =
- sizeof(partition_info_128KB_blk) /
- sizeof(struct mtd_partition);
- break;
- default:
- ret = -ENXIO;
- pr_err("Unsupported NAND size\n");
- goto err_probe;
- }
-
- partition = host->partitions;
- for (i = 0; i < host->nr_partitions; i++, partition++) {
- if (partition->size == 0) {
- partition->size = host->mtd.size -
- partition->offset;
- break;
- }
- }
- }
- }
-
- ret = mtd_device_register(&host->mtd, host->partitions,
- host->nr_partitions);
+ ret = mtd_device_parse_register(&host->mtd, NULL, 0,
+ host->mtd.size <= 0x04000000 ?
+ partition_info_16KB_blk :
+ partition_info_128KB_blk,
+ host->mtd.size <= 0x04000000 ?
+ ARRAY_SIZE(partition_info_16KB_blk) :
+ ARRAY_SIZE(partition_info_128KB_blk),
if (ret)
goto err_probe;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 29/43] mtd: h1910.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (27 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 28/43] mtd: fsmc_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 30/43] mtd: jz4740_nand.c: " Dmitry Eremin-Solenikov
` (14 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/h1910.c | 15 ++-------------
1 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index 42f9177..5dc6f0d 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -81,9 +81,6 @@ static int h1910_device_ready(struct mtd_info *mtd)
static int __init h1910_init(void)
{
struct nand_chip *this;
- const char *part_type = 0;
- int mtd_parts_nb = 0;
- struct mtd_partition *mtd_parts = 0;
void __iomem *nandaddr;
if (!machine_is_h1900())
@@ -136,18 +133,10 @@ static int __init h1910_init(void)
iounmap((void *)nandaddr);
return -ENXIO;
}
- mtd_parts_nb = parse_mtd_partitions(h1910_nand_mtd, NULL, &mtd_parts, 0);
- if (mtd_parts_nb > 0)
- part_type = "command line";
- else {
- mtd_parts = partition_info;
- mtd_parts_nb = NUM_PARTITIONS;
- part_type = "static";
- }
/* Register the partitions */
- printk(KERN_NOTICE "Using %s partition definition\n", part_type);
- mtd_device_register(h1910_nand_mtd, mtd_parts, mtd_parts_nb);
+ mtd_device_parse_register(h1910_nand_mtd, NULL, 0,
+ partition_info, NUM_PARTITIONS);
/* Return happy */
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 30/43] mtd: jz4740_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (28 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 29/43] mtd: h1910.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 31/43] mtd: mxc_nand.c: " Dmitry Eremin-Solenikov
` (13 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/jz4740_nand.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
index 920719c..e266407 100644
--- a/drivers/mtd/nand/jz4740_nand.c
+++ b/drivers/mtd/nand/jz4740_nand.c
@@ -295,8 +295,6 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
struct nand_chip *chip;
struct mtd_info *mtd;
struct jz_nand_platform_data *pdata = pdev->dev.platform_data;
- struct mtd_partition *partition_info;
- int num_partitions = 0;
nand = kzalloc(sizeof(*nand), GFP_KERNEL);
if (!nand) {
@@ -369,12 +367,9 @@ static int __devinit jz_nand_probe(struct platform_device *pdev)
goto err_gpio_free;
}
- num_partitions = parse_mtd_partitions(mtd, NULL, &partition_info, 0);
- if (num_partitions <= 0 && pdata) {
- num_partitions = pdata->num_partitions;
- partition_info = pdata->partitions;
- }
- ret = mtd_device_register(mtd, partition_info, num_partitions);
+ ret = mtd_device_parse_register(mtd, NULL, 0,
+ pdata ? pdata->partitions : NULL,
+ pdata ? pdata->num_partitions : 0);
if (ret) {
dev_err(&pdev->dev, "Failed to add mtd device\n");
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 31/43] mtd: mxc_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (29 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 30/43] mtd: jz4740_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 32/43] mtd: omap2.c: " Dmitry Eremin-Solenikov
` (12 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/mxc_nand.c | 15 +++------------
1 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index ca42c8f..4c2bb4a 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -143,7 +143,6 @@
struct mxc_nand_host {
struct mtd_info mtd;
struct nand_chip nand;
- struct mtd_partition *parts;
struct device *dev;
void *spare0;
@@ -1044,7 +1043,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
struct mxc_nand_platform_data *pdata = pdev->dev.platform_data;
struct mxc_nand_host *host;
struct resource *res;
- int err = 0, __maybe_unused nr_parts = 0;
+ int err = 0;
struct nand_ecclayout *oob_smallpage, *oob_largepage;
/* Allocate memory for MTD device structure and private data */
@@ -1231,16 +1230,8 @@ static int __init mxcnd_probe(struct platform_device *pdev)
}
/* Register the partitions */
- nr_parts =
- parse_mtd_partitions(mtd, part_probes, &host->parts, 0);
- if (nr_parts > 0)
- mtd_device_register(mtd, host->parts, nr_parts);
- else if (pdata->parts)
- mtd_device_register(mtd, pdata->parts, pdata->nr_parts);
- else {
- pr_info("Registering %s as whole device\n", mtd->name);
- mtd_device_register(mtd, NULL, 0);
- }
+ mtd_device_parse_register(mtd, part_probes, 0,
+ pdata->parts, pdata->nr_parts);
platform_set_drvdata(pdev, host);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 32/43] mtd: omap2.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (30 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 31/43] mtd: mxc_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 33/43] mtd: orion_nand.c: " Dmitry Eremin-Solenikov
` (11 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/omap2.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 8783c08..c5e33fd 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -112,7 +112,6 @@ struct omap_nand_info {
struct nand_hw_control controller;
struct omap_nand_platform_data *pdata;
struct mtd_info mtd;
- struct mtd_partition *parts;
struct nand_chip nand;
struct platform_device *pdev;
@@ -1101,13 +1100,8 @@ static int __devinit omap_nand_probe(struct platform_device *pdev)
goto out_release_mem_region;
}
- err = parse_mtd_partitions(&info->mtd, NULL, &info->parts, 0);
- if (err > 0)
- mtd_device_register(&info->mtd, info->parts, err);
- else if (pdata->parts)
- mtd_device_register(&info->mtd, pdata->parts, pdata->nr_parts);
- else
- mtd_device_register(&info->mtd, NULL, 0);
+ mtd_device_parse_register(&info->mtd, NULL, 0,
+ pdata->parts, pdata->nr_parts);
platform_set_drvdata(pdev, &info->mtd);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 33/43] mtd: orion_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (31 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 32/43] mtd: omap2.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 34/43] mtd: plat_nand.c: " Dmitry Eremin-Solenikov
` (10 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/orion_nand.c | 12 ++----------
1 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 5c55981..29f505a 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -79,8 +79,6 @@ static int __init orion_nand_probe(struct platform_device *pdev)
struct resource *res;
void __iomem *io_base;
int ret = 0;
- struct mtd_partition *partitions = NULL;
- int num_part = 0;
nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
if (!nc) {
@@ -131,14 +129,8 @@ static int __init orion_nand_probe(struct platform_device *pdev)
}
mtd->name = "orion_nand";
- num_part = parse_mtd_partitions(mtd, NULL, &partitions, 0);
- /* If cmdline partitions have been passed, let them be used */
- if (num_part <= 0) {
- num_part = board->nr_parts;
- partitions = board->parts;
- }
-
- ret = mtd_device_register(mtd, partitions, num_part);
+ ret = mtd_device_parse_register(mtd, NULL, 0,
+ board->parts, board->nr_parts);
if (ret) {
nand_release(mtd);
goto no_dev;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 34/43] mtd: plat_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (32 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 33/43] mtd: orion_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 35/43] mtd: ppchameleonevb.c: " Dmitry Eremin-Solenikov
` (9 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/plat_nand.c | 22 +++-------------------
1 files changed, 3 insertions(+), 19 deletions(-)
diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 1339fa8..e62468b 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -21,8 +21,6 @@ struct plat_nand_data {
struct nand_chip chip;
struct mtd_info mtd;
void __iomem *io_base;
- int nr_parts;
- struct mtd_partition *parts;
};
/*
@@ -99,21 +97,9 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
goto out;
}
- if (pdata->chip.part_probe_types) {
- err = parse_mtd_partitions(&data->mtd,
- pdata->chip.part_probe_types,
- &data->parts, 0);
- if (err > 0) {
- mtd_device_register(&data->mtd, data->parts, err);
- return 0;
- }
- }
- if (pdata->chip.partitions) {
- data->parts = pdata->chip.partitions;
- err = mtd_device_register(&data->mtd, data->parts,
- pdata->chip.nr_partitions);
- } else
- err = mtd_device_register(&data->mtd, NULL, 0);
+ err = mtd_device_parse_register(&data->mtd,
+ pdata->chip.part_probe_types, 0,
+ pdata->chip.partitions, pdata->chip.nr_partitions);
if (!err)
return err;
@@ -143,8 +129,6 @@ static int __devexit plat_nand_remove(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
nand_release(&data->mtd);
- if (data->parts && data->parts != pdata->chip.partitions)
- kfree(data->parts);
if (pdata->ctrl.remove)
pdata->ctrl.remove(pdev);
iounmap(data->io_base);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 35/43] mtd: ppchameleonevb.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (33 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 34/43] mtd: plat_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 36/43] mtd: pxa3xx_nand.c: " Dmitry Eremin-Solenikov
` (8 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/ppchameleonevb.c | 42 ++++++++----------------------------
1 files changed, 10 insertions(+), 32 deletions(-)
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c
index 9376633..7e52af5 100644
--- a/drivers/mtd/nand/ppchameleonevb.c
+++ b/drivers/mtd/nand/ppchameleonevb.c
@@ -191,9 +191,6 @@ static int ppchameleonevb_device_ready(struct mtd_info *minfo)
static int __init ppchameleonevb_init(void)
{
struct nand_chip *this;
- const char *part_type = 0;
- int mtd_parts_nb = 0;
- struct mtd_partition *mtd_parts = 0;
void __iomem *ppchameleon_fio_base;
void __iomem *ppchameleonevb_fio_base;
@@ -276,24 +273,13 @@ static int __init ppchameleonevb_init(void)
#endif
ppchameleon_mtd->name = "ppchameleon-nand";
- mtd_parts_nb = parse_mtd_partitions(ppchameleon_mtd, NULL, &mtd_parts, 0);
- if (mtd_parts_nb > 0)
- part_type = "command line";
- else
- mtd_parts_nb = 0;
-
- if (mtd_parts_nb == 0) {
- if (ppchameleon_mtd->size == NAND_SMALL_SIZE)
- mtd_parts = partition_info_me;
- else
- mtd_parts = partition_info_hi;
- mtd_parts_nb = NUM_PARTITIONS;
- part_type = "static";
- }
/* Register the partitions */
- printk(KERN_NOTICE "Using %s partition definition\n", part_type);
- mtd_device_register(ppchameleon_mtd, mtd_parts, mtd_parts_nb);
+ mtd_device_parse_register(ppchameleon_mtd, NULL, 0,
+ ppchameleon_mtd->size == NAND_SMALL_SIZE ?
+ partition_info_me :
+ partition_info_hi,
+ NUM_PARTITIONS);
nand_evb_init:
/****************************
@@ -377,21 +363,13 @@ static int __init ppchameleonevb_init(void)
}
ppchameleonevb_mtd->name = NAND_EVB_MTD_NAME;
- mtd_parts_nb = parse_mtd_partitions(ppchameleonevb_mtd, NULL, &mtd_parts, 0);
- if (mtd_parts_nb > 0)
- part_type = "command line";
- else
- mtd_parts_nb = 0;
-
- if (mtd_parts_nb == 0) {
- mtd_parts = partition_info_evb;
- mtd_parts_nb = NUM_PARTITIONS;
- part_type = "static";
- }
/* Register the partitions */
- printk(KERN_NOTICE "Using %s partition definition\n", part_type);
- mtd_device_register(ppchameleonevb_mtd, mtd_parts, mtd_parts_nb);
+ mtd_device_parse_register(ppchameleonevb_mtd, NULL, 0,
+ ppchameleon_mtd->size == NAND_SMALL_SIZE ?
+ partition_info_me :
+ partition_info_hi,
+ NUM_PARTITIONS);
/* Return happy */
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 36/43] mtd: pxa3xx_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (34 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 35/43] mtd: ppchameleonevb.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 37/43] mtd: s3c2410.c: " Dmitry Eremin-Solenikov
` (7 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/pxa3xx_nand.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 5c3af2f..b7db1b2 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1133,8 +1133,6 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
{
struct pxa3xx_nand_platform_data *pdata;
struct pxa3xx_nand_info *info;
- struct mtd_partition *parts;
- int nr_parts;
pdata = pdev->dev.platform_data;
if (!pdata) {
@@ -1152,13 +1150,8 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
return -ENODEV;
}
-
- nr_parts = parse_mtd_partitions(info->mtd, NULL, &parts, 0);
-
- if (nr_parts)
- return mtd_device_register(info->mtd, parts, nr_parts);
-
- return mtd_device_register(info->mtd, pdata->parts, pdata->nr_parts);
+ return mtd_device_parse_register(info->mtd, NULL, 0,
+ pdata->parts, pdata->nr_parts);
}
#ifdef CONFIG_PM
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 37/43] mtd: s3c2410.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (35 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 36/43] mtd: pxa3xx_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 38/43] mtd: sharpsl.c: " Dmitry Eremin-Solenikov
` (6 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/s3c2410.c | 18 ++++--------------
1 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 17954ba..b0f8e77 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -748,21 +748,11 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
struct s3c2410_nand_mtd *mtd,
struct s3c2410_nand_set *set)
{
- struct mtd_partition *part_info;
- int nr_part = 0;
+ if (set)
+ mtd->mtd.name = set->name;
- if (set == NULL)
- return mtd_device_register(&mtd->mtd, NULL, 0);
-
- mtd->mtd.name = set->name;
- nr_part = parse_mtd_partitions(&mtd->mtd, NULL, &part_info, 0);
-
- if (nr_part <= 0 && set->nr_partitions > 0) {
- nr_part = set->nr_partitions;
- part_info = set->partitions;
- }
-
- return mtd_device_register(&mtd->mtd, part_info, nr_part);
+ return mtd_device_parse_register(&mtd->mtd, NULL, 0,
+ set->partitions, set->nr_partitions);
}
/**
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 38/43] mtd: sharpsl.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (36 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 37/43] mtd: s3c2410.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 39/43] mtd: tmio_nand.c: " Dmitry Eremin-Solenikov
` (5 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/sharpsl.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index b3377f8..619d2a5 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -109,8 +109,6 @@ static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat,
static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
{
struct nand_chip *this;
- struct mtd_partition *sharpsl_partition_info;
- int nr_partitions;
struct resource *r;
int err = 0;
struct sharpsl_nand *sharpsl;
@@ -182,14 +180,9 @@ static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
/* Register the partitions */
sharpsl->mtd.name = "sharpsl-nand";
- nr_partitions = parse_mtd_partitions(&sharpsl->mtd, NULL, &sharpsl_partition_info, 0);
- if (nr_partitions <= 0) {
- nr_partitions = data->nr_partitions;
- sharpsl_partition_info = data->partitions;
- }
- err = mtd_device_register(&sharpsl->mtd, sharpsl_partition_info,
- nr_partitions);
+ err = mtd_device_parse_register(&sharpsl->mtd, NULL, 0,
+ data->partitions, data->nr_partitions);
if (err)
goto err_add;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 39/43] mtd: tmio_nand.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (37 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 38/43] mtd: sharpsl.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 40/43] mtd: txx9ndfmc.c: " Dmitry Eremin-Solenikov
` (4 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/tmio_nand.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
index b6ffad6..d476857 100644
--- a/drivers/mtd/nand/tmio_nand.c
+++ b/drivers/mtd/nand/tmio_nand.c
@@ -378,8 +378,6 @@ static int tmio_probe(struct platform_device *dev)
struct tmio_nand *tmio;
struct mtd_info *mtd;
struct nand_chip *nand_chip;
- struct mtd_partition *parts;
- int nbparts = 0;
int retval;
if (data == NULL)
@@ -458,13 +456,9 @@ static int tmio_probe(struct platform_device *dev)
goto err_scan;
}
/* Register the partitions */
- nbparts = parse_mtd_partitions(mtd, NULL, &parts, 0);
- if (nbparts <= 0 && data) {
- parts = data->partition;
- nbparts = data->num_partitions;
- }
-
- retval = mtd_device_register(mtd, parts, nbparts);
+ retval = mtd_device_register(mtd, NULL, 0,
+ data ? data->partition : NULL,
+ data ? data->num_partitions : 0);
if (!retval)
return retval;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 40/43] mtd: txx9ndfmc.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (38 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 39/43] mtd: tmio_nand.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 41/43] mtd: onenand/generic.c: " Dmitry Eremin-Solenikov
` (3 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/nand/txx9ndfmc.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c
index 91b05b9..ace46fd 100644
--- a/drivers/mtd/nand/txx9ndfmc.c
+++ b/drivers/mtd/nand/txx9ndfmc.c
@@ -74,7 +74,6 @@ struct txx9ndfmc_drvdata {
unsigned char hold; /* in gbusclock */
unsigned char spw; /* in gbusclock */
struct nand_hw_control hw_control;
- struct mtd_partition *parts[MAX_TXX9NDFMC_DEV];
};
static struct platform_device *mtd_to_platdev(struct mtd_info *mtd)
@@ -332,7 +331,6 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
struct txx9ndfmc_priv *txx9_priv;
struct nand_chip *chip;
struct mtd_info *mtd;
- int nr_parts;
if (!(plat->ch_mask & (1 << i)))
continue;
@@ -392,9 +390,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
}
mtd->name = txx9_priv->mtdname;
- nr_parts = parse_mtd_partitions(mtd, NULL,
- &drvdata->parts[i], 0);
- mtd_device_register(mtd, drvdata->parts[i], nr_parts);
+ mtd_device_parse_register(mtd, NULL, 0, NULL, 0);
drvdata->mtds[i] = mtd;
}
@@ -420,7 +416,6 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev)
txx9_priv = chip->priv;
nand_release(mtd);
- kfree(drvdata->parts[i]);
kfree(txx9_priv->mtdname);
kfree(txx9_priv);
}
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 41/43] mtd: onenand/generic.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (39 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 40/43] mtd: txx9ndfmc.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 42/43] mtd: onenand/omap2.c: " Dmitry Eremin-Solenikov
` (2 subsequent siblings)
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/onenand/generic.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
index bca1c49..8152a31 100644
--- a/drivers/mtd/onenand/generic.c
+++ b/drivers/mtd/onenand/generic.c
@@ -32,7 +32,6 @@
struct onenand_info {
struct mtd_info mtd;
- struct mtd_partition *parts;
struct onenand_chip onenand;
};
@@ -71,13 +70,9 @@ static int __devinit generic_onenand_probe(struct platform_device *pdev)
goto out_iounmap;
}
- err = parse_mtd_partitions(&info->mtd, NULL, &info->parts, 0);
- if (err > 0)
- mtd_device_register(&info->mtd, info->parts, err);
- else if (err <= 0 && pdata && pdata->parts)
- mtd_device_register(&info->mtd, pdata->parts, pdata->nr_parts);
- else
- err = mtd_device_register(&info->mtd, NULL, 0);
+ err = mtd_device_parse_register(&info->mtd, NULL, 0,
+ pdata ? pdata->parts : NULL,
+ pdata ? pdata->nr_parts : 0);
platform_set_drvdata(pdev, info);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 42/43] mtd: onenand/omap2.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (40 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 41/43] mtd: onenand/generic.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-08 16:05 ` [PATCH 43/43] mtd: onenand/samsung.c: " Dmitry Eremin-Solenikov
2011-06-09 7:56 ` [PATCH 0/43 V2] mtd: simplify mtd partitions handling Artem Bityutskiy
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/onenand/omap2.c | 13 +++----------
1 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index 5ca2053..eb9cbd9 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -57,7 +57,6 @@ struct omap2_onenand {
unsigned long phys_base;
int gpio_irq;
struct mtd_info mtd;
- struct mtd_partition *parts;
struct onenand_chip onenand;
struct completion irq_done;
struct completion dma_done;
@@ -752,13 +751,9 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
if ((r = onenand_scan(&c->mtd, 1)) < 0)
goto err_release_regulator;
- r = parse_mtd_partitions(&c->mtd, NULL, &c->parts, 0);
- if (r > 0)
- r = mtd_device_register(&c->mtd, c->parts, r);
- else if (pdata->parts != NULL)
- r = mtd_device_register(&c->mtd, pdata->parts, pdata->nr_parts);
- else
- r = mtd_device_register(&c->mtd, NULL, 0);
+ r = mtd_device_parse_register(&info->mtd, NULL, 0,
+ pdata ? pdata->parts : NULL,
+ pdata ? pdata->nr_parts : 0);
if (r)
goto err_release_onenand;
@@ -785,7 +780,6 @@ err_release_mem_region:
err_free_cs:
gpmc_cs_free(c->gpmc_cs);
err_kfree:
- kfree(c->parts);
kfree(c);
return r;
@@ -808,7 +802,6 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
iounmap(c->onenand.base);
release_mem_region(c->phys_base, ONENAND_IO_SIZE);
gpmc_cs_free(c->gpmc_cs);
- kfree(c->parts);
kfree(c);
return 0;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* [PATCH 43/43] mtd: onenand/samsung.c: use mtd_device_parse_register
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (41 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 42/43] mtd: onenand/omap2.c: " Dmitry Eremin-Solenikov
@ 2011-06-08 16:05 ` Dmitry Eremin-Solenikov
2011-06-09 7:56 ` [PATCH 0/43 V2] mtd: simplify mtd partitions handling Artem Bityutskiy
43 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-08 16:05 UTC (permalink / raw)
To: linux-mtd; +Cc: David Woodhouse, Russell King, dedekind1
Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
drivers/mtd/onenand/samsung.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index 78a08ea..597dffc 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -147,7 +147,6 @@ struct s3c_onenand {
struct resource *dma_res;
unsigned long phys_base;
struct completion complete;
- struct mtd_partition *parts;
};
#define CMD_MAP_00(dev, addr) (dev->cmd_map(MAP_00, ((addr) << 1)))
@@ -1015,13 +1014,9 @@ static int s3c_onenand_probe(struct platform_device *pdev)
if (s3c_read_reg(MEM_CFG_OFFSET) & ONENAND_SYS_CFG1_SYNC_READ)
dev_info(&onenand->pdev->dev, "OneNAND Sync. Burst Read enabled\n");
- err = parse_mtd_partitions(mtd, NULL, &onenand->parts, 0);
- if (err > 0)
- mtd_device_register(mtd, onenand->parts, err);
- else if (err <= 0 && pdata && pdata->parts)
- mtd_device_register(mtd, pdata->parts, pdata->nr_parts);
- else
- err = mtd_device_register(mtd, NULL, 0);
+ err = mtd_device_parse_register(&info->mtd, NULL, 0,
+ pdata ? pdata->parts : NULL,
+ pdata ? pdata->nr_parts : 0);
platform_set_drvdata(pdev, mtd);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 49+ messages in thread* Re: [PATCH 0/43 V2] mtd: simplify mtd partitions handling
2011-06-08 16:05 [PATCH 0/43 V2] mtd: simplify mtd partitions handling Dmitry Eremin-Solenikov
` (42 preceding siblings ...)
2011-06-08 16:05 ` [PATCH 43/43] mtd: onenand/samsung.c: " Dmitry Eremin-Solenikov
@ 2011-06-09 7:56 ` Artem Bityutskiy
2011-06-09 8:23 ` Dmitry Eremin-Solenikov
43 siblings, 1 reply; 49+ messages in thread
From: Artem Bityutskiy @ 2011-06-09 7:56 UTC (permalink / raw)
To: Dmitry Eremin-Solenikov; +Cc: Russell King, linux-mtd, David Woodhouse
On Wed, 2011-06-08 at 20:05 +0400, Dmitry Eremin-Solenikov wrote:
> Lots of mtd drivers have more or less the same common logic:
> parse partitions, then register them. Currently this ends up
> with lots of code duplication, each copy having it's own features
> and bugs. In this patch serie I create a special function
> (mtd_device_parse_register) which handles all issues with acquiring
> partition information, registering mtd device(s) and returning correct
> error code.
>
> Changes since V1:
> - Added kerneldoc for mtd_device_parse_register
> - removed lart.c patch (wrong commit message)
> - dropped call to mtd_device_register from rbtx4939-flash
> - small fixes within patches
>
> The following changes since commit 1dc1d90aa53e6cec61f5369b6d1e185b3ef40c14:
>
> mtd: davinci_nand: remove redundant mtd_device_unregister (2011-06-08 18:00:41 +0300)
>
> are available in the git repository at:
> git://git.infradead.org/users/dbaryshkov/mtd-cleanup.git mtd-parse-1st-2
Pushed the series with minor tweaks to l2-mtd-2.6.git, thank you!
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 49+ messages in thread* Re: [PATCH 0/43 V2] mtd: simplify mtd partitions handling
2011-06-09 7:56 ` [PATCH 0/43 V2] mtd: simplify mtd partitions handling Artem Bityutskiy
@ 2011-06-09 8:23 ` Dmitry Eremin-Solenikov
0 siblings, 0 replies; 49+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-09 8:23 UTC (permalink / raw)
To: dedekind1; +Cc: Russell King, linux-mtd, David Woodhouse
On 6/9/11, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Wed, 2011-06-08 at 20:05 +0400, Dmitry Eremin-Solenikov wrote:
>> Lots of mtd drivers have more or less the same common logic:
>> parse partitions, then register them. Currently this ends up
>> with lots of code duplication, each copy having it's own features
>> and bugs. In this patch serie I create a special function
>> (mtd_device_parse_register) which handles all issues with acquiring
>> partition information, registering mtd device(s) and returning correct
>> error code.
>>
>> Changes since V1:
>> - Added kerneldoc for mtd_device_parse_register
>> - removed lart.c patch (wrong commit message)
>> - dropped call to mtd_device_register from rbtx4939-flash
>> - small fixes within patches
>>
>> The following changes since commit
>> 1dc1d90aa53e6cec61f5369b6d1e185b3ef40c14:
>>
>> mtd: davinci_nand: remove redundant mtd_device_unregister (2011-06-08
>> 18:00:41 +0300)
>>
>> are available in the git repository at:
>> git://git.infradead.org/users/dbaryshkov/mtd-cleanup.git mtd-parse-1st-2
>
> Pushed the series with minor tweaks to l2-mtd-2.6.git, thank you!
Thank you!
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 49+ messages in thread