mtd: simplify mtd partitions handling
Subsystems (5)
v2 cover mtd: simplify mtd partitions handling
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
Dmitry Eremin-Solenikov (43):
mtd: add new API for handling MTD registration
mtd: mtd_dataflash.c: use mtd_device_parse_register
mtd: sst25l.c: use mtd_device_parse_register
mtd: bfin-async-flash.c: use mtd_device_parse_register
mtd: dc21285.c: use mtd_device_parse_register
mtd: gpio-addr-flash.c: use mtd_device_parse_register
mtd: h720x-flash.c: use mtd_device_parse_register
mtd: impa7.c: use mtd_device_parse_register
mtd: intel_vr_nor.c: use mtd_device_parse_register
mtd: ixp2000.c: use mtd_device_parse_register
mtd: ixp4xx.c: use mtd_device_parse_register
mtd: lantiq-flash.c: use mtd_device_parse_register
mtd: latch-addr-flash.c: use mtd_device_parse_register
mtd: physmap.c: use mtd_device_parse_register
mtd: plat-ram.c: use mtd_device_parse_register
mtd: pxa2xx-flash.c: use mtd_device_parse_register
mtd: rbtx4939-flash.c: use mtd_device_parse_register
mtd: sa1100-flash.c: use mtd_device_parse_register
mtd: solutionengine.c: use mtd_device_parse_register
mtd: wr_sbc82xx_flash.c: use mtd_device_parse_register
mtd: atmel_nand.c: use mtd_device_parse_register
mtd: bcm_umi_nand.c: use mtd_device_parse_register
mtd: cafe_nand.c: use mtd_device_parse_register
mtd: cmx270_nand.c: use mtd_device_parse_register
mtd: cs553x_nand.c: use mtd_device_parse_register
mtd: davinci_nand.c: use mtd_device_parse_register
mtd: edb7312.c: use mtd_device_parse_register
mtd: fsmc_nand.c: use mtd_device_parse_register
mtd: h1910.c: use mtd_device_parse_register
mtd: jz4740_nand.c: use mtd_device_parse_register
mtd: mxc_nand.c: use mtd_device_parse_register
mtd: omap2.c: use mtd_device_parse_register
mtd: orion_nand.c: use mtd_device_parse_register
mtd: plat_nand.c: use mtd_device_parse_register
mtd: ppchameleonevb.c: use mtd_device_parse_register
mtd: pxa3xx_nand.c: use mtd_device_parse_register
mtd: s3c2410.c: use mtd_device_parse_register
mtd: sharpsl.c: use mtd_device_parse_register
mtd: tmio_nand.c: use mtd_device_parse_register
mtd: txx9ndfmc.c: use mtd_device_parse_register
mtd: onenand/generic.c: use mtd_device_parse_register
mtd: onenand/omap2.c: use mtd_device_parse_register
mtd: onenand/samsung.c: use mtd_device_parse_register
drivers/mtd/devices/mtd_dataflash.c | 21 ++--------- drivers/mtd/devices/sst25l.c | 33 ++--------------- drivers/mtd/maps/bfin-async-flash.c | 16 +------- drivers/mtd/maps/dc21285.c | 9 +---- drivers/mtd/maps/gpio-addr-flash.c | 16 +------- drivers/mtd/maps/h720x-flash.c | 21 +---------- drivers/mtd/maps/impa7.c | 25 ++----------- drivers/mtd/maps/intel_vr_nor.c | 6 +--- drivers/mtd/maps/ixp2000.c | 11 +----- drivers/mtd/maps/ixp4xx.c | 29 ++------------- drivers/mtd/maps/lantiq-flash.c | 14 +------ drivers/mtd/maps/latch-addr-flash.c | 21 +---------- drivers/mtd/maps/physmap.c | 23 +----------- drivers/mtd/maps/plat-ram.c | 23 +----------- drivers/mtd/maps/pxa2xx-flash.c | 20 +---------- drivers/mtd/maps/rbtx4939-flash.c | 21 ++--------- drivers/mtd/maps/sa1100-flash.c | 30 ++-------------- drivers/mtd/maps/solutionengine.c | 30 ++++------------ drivers/mtd/maps/wr_sbc82xx_flash.c | 30 ++++++---------- drivers/mtd/mtdcore.c | 60 +++++++++++++++++++++++++++++++ drivers/mtd/nand/atmel_nand.c | 19 +--------- drivers/mtd/nand/bcm_umi_nand.c | 19 +--------- drivers/mtd/nand/cafe_nand.c | 11 +----- drivers/mtd/nand/cmx270_nand.c | 20 +--------- drivers/mtd/nand/cs553x_nand.c | 8 +--- drivers/mtd/nand/davinci_nand.c | 25 +------------ drivers/mtd/nand/edb7312.c | 17 +-------- drivers/mtd/nand/fsmc_nand.c | 66 +++++------------------------------ drivers/mtd/nand/h1910.c | 15 +------- drivers/mtd/nand/jz4740_nand.c | 11 ++---- drivers/mtd/nand/mxc_nand.c | 15 ++------ drivers/mtd/nand/omap2.c | 10 +---- drivers/mtd/nand/orion_nand.c | 12 +----- drivers/mtd/nand/plat_nand.c | 22 ++---------- drivers/mtd/nand/ppchameleonevb.c | 42 +++++----------------- drivers/mtd/nand/pxa3xx_nand.c | 11 +----- drivers/mtd/nand/s3c2410.c | 18 ++------- drivers/mtd/nand/sharpsl.c | 11 +----- drivers/mtd/nand/tmio_nand.c | 12 ++----- drivers/mtd/nand/txx9ndfmc.c | 7 +--- drivers/mtd/onenand/generic.c | 11 ++---- drivers/mtd/onenand/omap2.c | 13 ++----- drivers/mtd/onenand/samsung.c | 11 ++---- include/linux/mtd/mtd.h | 5 +++ 44 files changed, 191 insertions(+), 679 deletions(-)
PATCH v2 1/43 mtd: add new API for handling MTD registration
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.
--- drivers/mtd/mtdcore.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mtd/mtd.h | 5 ++++ 2 files changed, 65 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +60 -0
@@ -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
include/linux/mtd/mtd.h +5 -0
@@ -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);
Signature · 1 line
1.7.4.4
Re: [PATCH 01/43] mtd: add new API for handling MTD registration
Quoted 8 lines · Dmitry Eremin-Solenikov
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.
Quoted 5 lines
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- 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!
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
PATCH v2 2/43 mtd: mtd_dataflash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/devices/mtd_dataflash.c | 21 +++------------------ 1 files changed, 3 insertions(+), 18 deletions(-)
drivers/mtd/devices/mtd_dataflash.c +3 -18
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 3/43 mtd: sst25l.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/devices/sst25l.c | 33 ++++----------------------------- 1 files changed, 4 insertions(+), 29 deletions(-)
drivers/mtd/devices/sst25l.c +4 -29
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 4/43 mtd: bfin-async-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/bfin-async-flash.c | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-)
drivers/mtd/maps/bfin-async-flash.c +2 -14
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 5/43 mtd: dc21285.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/dc21285.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
drivers/mtd/maps/dc21285.c +1 -8
@@ -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); }
Signature · 1 line
1.7.4.4
PATCH v2 6/43 mtd: gpio-addr-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/gpio-addr-flash.c | 16 ++-------------- 1 files changed, 2 insertions(+), 14 deletions(-)
drivers/mtd/maps/gpio-addr-flash.c +2 -14
@@ -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 ; }
Signature · 1 line
1.7.4.4
PATCH v2 7/43 mtd: h720x-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/h720x-flash.c | 21 ++------------------- 1 files changed, 2 insertions(+), 19 deletions(-)
drivers/mtd/maps/h720x-flash.c +2 -19
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 8/43 mtd: impa7.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/impa7.c | 25 +++---------------------- 1 files changed, 3 insertions(+), 22 deletions(-)
drivers/mtd/maps/impa7.c +3 -22
@@ -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);
Signature · 1 line
1.7.4.4
Re: [PATCH 08/43] mtd: impa7.c: use mtd_device_parse_register
drivers/mtd/maps/impa7.c static int __init init_impa7(void) · line 97
Quoted 6 lines · Dmitry Eremin-Solenikov
drivers/mtd/maps/impa7.c +3
-2-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 :-)
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
PATCH v2 9/43 mtd: intel_vr_nor.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/intel_vr_nor.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
drivers/mtd/maps/intel_vr_nor.c +1 -5
@@ -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)
Signature · 1 line
1.7.4.4
PATCH v2 10/43 mtd: ixp2000.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/ixp2000.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/mtd/maps/ixp2000.c +1 -10
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 11/43 mtd: ixp4xx.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/ixp4xx.c | 29 ++++------------------------- 1 files changed, 4 insertions(+), 25 deletions(-)
drivers/mtd/maps/ixp4xx.c +4 -25
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 12/43 mtd: lantiq-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/lantiq-flash.c | 14 ++------------ 1 files changed, 2 insertions(+), 12 deletions(-)
drivers/mtd/maps/lantiq-flash.c +2 -12
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 13/43 mtd: latch-addr-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/latch-addr-flash.c | 21 ++------------------- 1 files changed, 2 insertions(+), 19 deletions(-)
drivers/mtd/maps/latch-addr-flash.c +2 -19
@@ -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:
Signature · 1 line
1.7.4.4
PATCH v2 14/43 mtd: physmap.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/physmap.c | 23 ++--------------------- 1 files changed, 2 insertions(+), 21 deletions(-)
drivers/mtd/maps/physmap.c +2 -21
@@ -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:
Signature · 1 line
1.7.4.4
Re: [PATCH 14/43] mtd: physmap.c: use mtd_device_parse_register
drivers/mtd/maps/physmap.c static int physmap_flash_probe(struct platform_device *dev) · line 175
Quoted 11 lines · Dmitry Eremin-Solenikov
drivers/mtd/maps/physmap.c +2
-9-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.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
PATCH v2 15/43 mtd: plat-ram.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/plat-ram.c | 23 ++--------------------- 1 files changed, 2 insertions(+), 21 deletions(-)
drivers/mtd/maps/plat-ram.c +2 -21
@@ -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" );
Signature · 1 line
1.7.4.4
PATCH v2 16/43 mtd: pxa2xx-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/pxa2xx-flash.c | 20 +------------------- 1 files changed, 1 insertions(+), 19 deletions(-)
drivers/mtd/maps/pxa2xx-flash.c +1 -19
@@ -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 ; }
Signature · 1 line
1.7.4.4
PATCH v2 17/43 mtd: rbtx4939-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/rbtx4939-flash.c | 21 ++++----------------- 1 files changed, 4 insertions(+), 17 deletions(-)
drivers/mtd/maps/rbtx4939-flash.c +4 -17
@@ -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:
Signature · 1 line
1.7.4.4
PATCH v2 18/43 mtd: sa1100-flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/sa1100-flash.c | 30 +++--------------------------- 1 files changed, 3 insertions(+), 27 deletions(-)
drivers/mtd/maps/sa1100-flash.c +3 -27
@@ -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 *plamtd_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 ;
Signature · 1 line
1.7.4.4
PATCH v2 19/43 mtd: solutionengine.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/solutionengine.c | 30 +++++++----------------------- 1 files changed, 7 insertions(+), 23 deletions(-)
drivers/mtd/maps/solutionengine.c +7 -23
@@ -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); }
Signature · 1 line
1.7.4.4
PATCH v2 20/43 mtd: wr_sbc82xx_flash.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/maps/wr_sbc82xx_flash.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-)
drivers/mtd/maps/wr_sbc82xx_flash.c +11 -19
@@ -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);
Signature · 1 line
1.7.4.4
PATCH v2 21/43 mtd: atmel_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/atmel_nand.c | 19 ++----------------- 1 files changed, 2 insertions(+), 17 deletions(-)
drivers/mtd/nand/atmel_nand.c +2 -17
@@ -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:
Signature · 1 line
1.7.4.4
PATCH v2 22/43 mtd: bcm_umi_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/bcm_umi_nand.c | 19 ++----------------- 1 files changed, 2 insertions(+), 17 deletions(-)
drivers/mtd/nand/bcm_umi_nand.c +2 -17
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 23/43 mtd: cafe_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/cafe_nand.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)
drivers/mtd/nand/cafe_nand.c +2 -9
@@ -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:
Signature · 1 line
1.7.4.4
PATCH v2 24/43 mtd: cmx270_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/cmx270_nand.c | 20 ++------------------ 1 files changed, 2 insertions(+), 18 deletions(-)
drivers/mtd/nand/cmx270_nand.c +2 -18
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 25/43 mtd: cs553x_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/cs553x_nand.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/mtd/nand/cs553x_nand.c +2 -6
@@ -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 ; } }
Signature · 1 line
1.7.4.4
PATCH v2 26/43 mtd: davinci_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/davinci_nand.c | 25 ++----------------------- 1 files changed, 2 insertions(+), 23 deletions(-)
drivers/mtd/nand/davinci_nand.c +2 -23
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 27/43 mtd: edb7312.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/edb7312.c | 17 ++--------------- 1 files changed, 2 insertions(+), 15 deletions(-)
drivers/mtd/nand/edb7312.c +2 -15
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 28/43 mtd: fsmc_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/fsmc_nand.c | 66 ++++++------------------------------------ 1 files changed, 9 insertions(+), 57 deletions(-)
drivers/mtd/nand/fsmc_nand.c +9 -57
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 29/43 mtd: h1910.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/h1910.c | 15 ++------------- 1 files changed, 2 insertions(+), 13 deletions(-)
drivers/mtd/nand/h1910.c +2 -13
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 30/43 mtd: jz4740_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/jz4740_nand.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/mtd/nand/jz4740_nand.c +3 -8
@@ -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" );
Signature · 1 line
1.7.4.4
PATCH v2 31/43 mtd: mxc_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/mxc_nand.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-)
drivers/mtd/nand/mxc_nand.c +3 -12
@@ -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);
Signature · 1 line
1.7.4.4
PATCH v2 32/43 mtd: omap2.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/omap2.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
drivers/mtd/nand/omap2.c +2 -8
@@ -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);
Signature · 1 line
1.7.4.4
PATCH v2 33/43 mtd: orion_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/orion_nand.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-)
drivers/mtd/nand/orion_nand.c +2 -10
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 34/43 mtd: plat_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/plat_nand.c | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-)
drivers/mtd/nand/plat_nand.c +3 -19
@@ -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);
Signature · 1 line
1.7.4.4
PATCH v2 35/43 mtd: ppchameleonevb.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/ppchameleonevb.c | 42 ++++++++---------------------------- 1 files changed, 10 insertions(+), 32 deletions(-)
drivers/mtd/nand/ppchameleonevb.c +10 -32
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 36/43 mtd: pxa3xx_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/pxa3xx_nand.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)
drivers/mtd/nand/pxa3xx_nand.c +2 -9
@@ -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
Signature · 1 line
1.7.4.4
PATCH v2 37/43 mtd: s3c2410.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/s3c2410.c | 18 ++++-------------- 1 files changed, 4 insertions(+), 14 deletions(-)
drivers/mtd/nand/s3c2410.c +4 -14
@@ -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); }/**
Signature · 1 line
1.7.4.4
PATCH v2 38/43 mtd: sharpsl.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/sharpsl.c | 11 ++--------- 1 files changed, 2 insertions(+), 9 deletions(-)
drivers/mtd/nand/sharpsl.c +2 -9
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 39/43 mtd: tmio_nand.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/tmio_nand.c | 12 +++--------- 1 files changed, 3 insertions(+), 9 deletions(-)
drivers/mtd/nand/tmio_nand.c +3 -9
@@ -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;
Signature · 1 line
1.7.4.4
PATCH v2 40/43 mtd: txx9ndfmc.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/nand/txx9ndfmc.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/mtd/nand/txx9ndfmc.c +1 -6
@@ -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); }
Signature · 1 line
1.7.4.4
PATCH v2 41/43 mtd: onenand/generic.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/onenand/generic.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/mtd/onenand/generic.c +3 -8
@@ -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);
Signature · 1 line
1.7.4.4
PATCH v2 42/43 mtd: onenand/omap2.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/onenand/omap2.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-)
drivers/mtd/onenand/omap2.c +3 -10
@@ -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 ;
Signature · 1 line
1.7.4.4
PATCH v2 43/43 mtd: onenand/samsung.c: use mtd_device_parse_register
In reply to Dmitry Eremin-SolenikovReplace 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.
--- drivers/mtd/onenand/samsung.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
drivers/mtd/onenand/samsung.c +3 -8
@@ -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);
Signature · 1 line
1.7.4.4
Quoted 14 lines · Dmitry Eremin-Solenikov
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 formtd_device_parse_register
- removedlart.cpatch (wrong commit message)
- dropped call tomtd_device_registerfrom rbtx4939-flash
- small fixes within patches
Quoted 6 lines
The following changes since commit
1dc1d90aa53e6cec61f5369b6d1e185b3ef40c14:mtd:
davinci_nand: remove redundantmtd_device_unregister(2011-06-08 18:00:41 +0300)are available in the git repository at:
git://git.infradead.org/users/dbaryshkov/mtd-cleanup.gitmtd-parse-1st-2
Pushed the series with minor tweaks to l2-mtd-2.6.git, thank you!
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Quoted 18 lines · Artem Bityutskiy
Quoted 17 lines · Dmitry Eremin-Solenikov
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 formtd_device_parse_register
- removedlart.cpatch (wrong commit message)
- dropped call tomtd_device_registerfrom rbtx4939-flash
- small fixes within patchesThe following changes since commit
1dc1d90aa53e6cec61f5369b6d1e185b3ef40c14:
Quoted 7 lines
Quoted 5 lines
mtd:
davinci_nand: remove redundantmtd_device_unregister(2011-06-08
18:00:41 +0300)are available in the git repository at:
git://git.infradead.org/users/dbaryshkov/mtd-cleanup.gitmtd-parse-1st-2Pushed the series with minor tweaks to l2-mtd-2.6.git, thank you!
Thank you!
Signature · 2 lines
With best wishes Dmitry