mtd: cleanup partition parsing interface
Subsystems (6)
cover mtd: cleanup partition parsing interface
Hello,
This is an RFC for a huge serie of patches converting most mtd drivers to use single instance of code for managing mtd partitions parsing and handling.
Currently each driver responsible for partitions implements this part of code on it's own, resulting in memory leaks, possible frees of non-allocated memory, etc. As the patch serie is huge, I'm posting only patches I consider "interesting", i. e. from the subserie doing the same cleanup for different drivers I post only first patch. Rest are available through the gitweb.
Only one driver still uses parse_mtd_partitions after this serie (edb7312), as it registers both parsed partitions and the whole mtd device and I ain't sure how to behave at this case.
If the idea seems find to be commited, I'll post the whole serie for full review.
The following changes since commit 55922c9d1b84b89cb946c777fddccb3247e7df2c:
Linux 3.0-rc1 (2011-05-29 17:43:36 -0700)
are available in the git repository at:
ssh://master.kernel.org/pub/scm/linux/kernel/git/lumag/mtd-cleanup.git mtd-cleanup
Dmitry Eremin-Solenikov (104):
ATMEL, AVR32: inline nand partition table access clps711x/ceiva: port to use physmap flash
mtd: drop ceiva map driver
mtd: drop physmap_configure
mtd: cafe_nand: drop reference to CONFIG_MTD_CMDLINE_PARTS
mtdpart: default to cmdlinepart, NULL partitions probing
mtd: m25p80 don't specify default parsing options
mtd: mtd_dataflash don't specify default parsing options
mtd: sst25l don't specify default parsing options
mtd: h720x-flash don't specify default parsing options
mtd: impa7 don't specify default parsing options
mtd: intel_vr_nor don't specify default parsing options
mtd: rbtx4939-flash don't specify default parsing options
mtd: atmel_nand don't specify default parsing options
mtd: bcm_umi_nand don't specify default parsing options
mtd: cmx270_nand don't specify default parsing options
mtd: cs553x_nand don't specify default parsing options
mtd: davinci_nand don't specify default parsing options
mtd: edb7312 don't specify default parsing options
mtd: fsl_upm don't specify default parsing options
mtd: fsmc_nand don't specify default parsing options
mtd: h1910 don't specify default parsing options
mtd: jz4740_nand don't specify default parsing options
mtd: lantiq-flash don't specify default parsing options
mtd: latch-addr-flash don't specify default parsing options
mtd: mpc5121_nfc don't specify default parsing options
mtd: ndfc don't specify default parsing options
mtd: omap2 don't specify default parsing options
mtd: orion_nand don't specify default parsing options
mtd: ppchameleonevb don't specify default parsing options
mtd: pxa3xx_nand don't specify default parsing options
mtd: s3c2410 don't specify default parsing options
mtd: sharpsl don't specify default parsing options
mtd: socrates_nand don't specify default parsing options
mtd: tmio_nand don't specify default parsing options
mtd: txx9ndfmc don't specify default parsing options
mtd: onenand/generic don't specify default parsing options
mtd: onenand/omap2 don't specify default parsing options
mtd: samsung/onenand don't specify default parsing options
mtd: drop mtd_has_cmdlinepart()
mtd: prepare to convert of_mtd_parse_partitions to partition parser
mtd: m25p80: use ofpart through generic parsing
mtd: physmap_of: use ofpart through generic parsing
mtd: fsl_elbc_nand: use ofpart through generic parsing
mtd: fsl_upm: use ofpart through generic parsing
mtd: mpc5121_nfc: use ofpart through generic parsing
mtd: ndfc: use ofpart through generic parsing
mtd: socrates_nand: use ofpart through generic parsing
mtd: drop of_mtd_parse_partitions()
physmap_of: separate parse_obsolete_partitions to separate parser
mtd: add a flags for partitions which should just leave smth. after them
ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning
mtd: plat-nand: drop unused fields from platform_nand_data
mtd: add new API for handling MTD registration
mtd: lart.c: use mtd_device_parse_register
mtd: m25p80.c: use mtd_device_parse_register
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: physmap_of.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: fsl_elbc_nand.c: use mtd_device_parse_register
mtd: fsl_upm.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: mpc5121_nfc.c: use mtd_device_parse_register
mtd: mxc_nand.c: use mtd_device_parse_register
mtd: ndfc.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: socrates_nand.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
arch/arm/mach-at91/board-afeb-9260v1.c | 9 +- arch/arm/mach-at91/board-cam60.c | 9 +- arch/arm/mach-at91/board-cap9adk.c | 9 +- arch/arm/mach-at91/board-kb9202.c | 9 +- arch/arm/mach-at91/board-neocore926.c | 9 +- arch/arm/mach-at91/board-qil-a9260.c | 9 +- arch/arm/mach-at91/board-rm9200dk.c | 9 +- arch/arm/mach-at91/board-sam9-l9260.c | 9 +- arch/arm/mach-at91/board-sam9260ek.c | 9 +- arch/arm/mach-at91/board-sam9261ek.c | 9 +- arch/arm/mach-at91/board-sam9263ek.c | 9 +- arch/arm/mach-at91/board-sam9g20ek.c | 9 +- arch/arm/mach-at91/board-sam9m10g45ek.c | 9 +- arch/arm/mach-at91/board-sam9rlek.c | 9 +- arch/arm/mach-at91/board-snapper9260.c | 10 +- arch/arm/mach-at91/board-usb-a9260.c | 9 +- arch/arm/mach-at91/board-usb-a9263.c | 9 +- arch/arm/mach-at91/board-yl-9200.c | 9 +- arch/arm/mach-at91/include/mach/board.h | 3 +- arch/arm/mach-clps711x/ceiva.c | 60 +++++ arch/arm/mach-ep93xx/ts72xx.c | 22 +-- arch/avr32/boards/atngw100/setup.c | 8 +- arch/avr32/boards/atstk1000/atstk1002.c | 9 +- arch/avr32/mach-at32ap/include/mach/board.h | 3 +- drivers/mtd/Kconfig | 10 + drivers/mtd/Makefile | 1 + drivers/mtd/devices/lart.c | 12 +- drivers/mtd/devices/m25p80.c | 42 +--- drivers/mtd/devices/mtd_dataflash.c | 26 +-- drivers/mtd/devices/sst25l.c | 38 +--- drivers/mtd/maps/Kconfig | 14 - drivers/mtd/maps/Makefile | 1 - drivers/mtd/maps/bfin-async-flash.c | 16 +- drivers/mtd/maps/ceiva.c | 341 --------------------------- drivers/mtd/maps/dc21285.c | 9 +- drivers/mtd/maps/gpio-addr-flash.c | 16 +- drivers/mtd/maps/h720x-flash.c | 23 +-- drivers/mtd/maps/impa7.c | 26 +-- drivers/mtd/maps/intel_vr_nor.c | 7 +- drivers/mtd/maps/ixp2000.c | 11 +- drivers/mtd/maps/ixp4xx.c | 29 +-- drivers/mtd/maps/lantiq-flash.c | 17 +-- drivers/mtd/maps/latch-addr-flash.c | 24 +-- drivers/mtd/maps/physmap.c | 38 +--- drivers/mtd/maps/physmap_of.c | 79 +------ 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 | 49 ++++ drivers/mtd/mtdpart.c | 16 ++ drivers/mtd/nand/atmel_nand.c | 25 +-- drivers/mtd/nand/bcm_umi_nand.c | 22 +-- drivers/mtd/nand/cafe_nand.c | 13 +- drivers/mtd/nand/cmx270_nand.c | 23 +-- drivers/mtd/nand/cs553x_nand.c | 10 +- drivers/mtd/nand/davinci_nand.c | 32 +--- drivers/mtd/nand/edb7312.c | 19 +-- drivers/mtd/nand/fsl_elbc_nand.c | 16 +- drivers/mtd/nand/fsl_upm.c | 13 +- drivers/mtd/nand/fsmc_nand.c | 75 +----- drivers/mtd/nand/h1910.c | 19 +-- drivers/mtd/nand/jz4740_nand.c | 18 +-- drivers/mtd/nand/mpc5121_nfc.c | 18 +-- drivers/mtd/nand/mxc_nand.c | 15 +- drivers/mtd/nand/ndfc.c | 20 +-- drivers/mtd/nand/omap2.c | 12 +- drivers/mtd/nand/orion_nand.c | 16 +- drivers/mtd/nand/plat_nand.c | 24 +-- drivers/mtd/nand/ppchameleonevb.c | 47 +--- drivers/mtd/nand/pxa3xx_nand.c | 14 +- drivers/mtd/nand/s3c2410.c | 19 +-- drivers/mtd/nand/sharpsl.c | 13 +- drivers/mtd/nand/socrates_nand.c | 27 +-- drivers/mtd/nand/tmio_nand.c | 17 +- drivers/mtd/nand/txx9ndfmc.c | 8 +- drivers/mtd/ofoldpart.c | 89 +++++++ drivers/mtd/ofpart.c | 28 ++- drivers/mtd/onenand/generic.c | 13 +- drivers/mtd/onenand/omap2.c | 15 +- drivers/mtd/onenand/samsung.c | 13 +- include/linux/mtd/mtd.h | 8 + include/linux/mtd/nand.h | 2 - include/linux/mtd/partitions.h | 27 +-- include/linux/mtd/physmap.h | 17 -- 87 files changed, 457 insertions(+), 1557 deletions(-) delete mode 100644 drivers/mtd/maps/ceiva.c create mode 100644 drivers/mtd/ofoldpart.c
PATCH 4/104 mtd: drop physmap_configure
physmap_configure() and physmap_set_partitions() have no users in kernel. Out of kernel users should have been converted to regular platform device long ago. Drop support for this obsolete API.
--- drivers/mtd/maps/Kconfig | 6 ------ drivers/mtd/maps/physmap.c | 15 --------------- include/linux/mtd/physmap.h | 17 ----------------- 3 files changed, 0 insertions(+), 38 deletions(-)
drivers/mtd/maps/Kconfig +0 -6
@@ -41,8 +41,6 @@ config MTD_PHYSMAP_START are mapped on your particular target board. Refer to the memory map which should hopefully be in the documentation for your board. - Ignore this option if you use run-time physmap configuration - (i.e., run-time calling physmap_configure()). config MTD_PHYSMAP_LEN hex "Physical length of flash mapping"
@@ -55,8 +53,6 @@ config MTD_PHYSMAP_LEN than the total amount of flash present. Refer to the memory map which should hopefully be in the documentation for your board. - Ignore this option if you use run-time physmap configuration - (i.e., run-time calling physmap_configure()). config MTD_PHYSMAP_BANKWIDTH int "Bank width in octets"
@@ -67,8 +63,6 @@ config MTD_PHYSMAP_BANKWIDTH in octets. For example, if you have a data bus width of 32 bits, you would set the bus width octet value to 4. This is used internally by the CFI drivers. - Ignore this option if you use run-time physmap configuration - (i.e., run-time calling physmap_configure()). config MTD_PHYSMAP_OF tristate "Flash device in physical memory map based on OF description"
drivers/mtd/maps/physmap.c +0 -15
@@ -245,21 +245,6 @@ static struct platform_device physmap_flash = { .num_resources = 1, .resource = &physmap_flash_resource, }; - -void physmap_configure (unsigned long addr,unsigned long size, -int bankwidth,void (*set_vpp)(struct map_info *,int )) -{ - physmap_flash_resource.start = addr; - physmap_flash_resource.end = addr + size -1 ; - physmap_flash_data.width = bankwidth; - physmap_flash_data.set_vpp = set_vpp; -} - -void physmap_set_partitions (struct mtd_partition *parts,int num_parts) -{ - physmap_flash_data.nr_parts = num_parts; - physmap_flash_data.parts = parts; -}#endif static int __init physmap_init (void )
include/linux/mtd/physmap.h +0 -17
@@ -31,21 +31,4 @@ struct physmap_flash_data { struct mtd_partition *parts; }; -/* -* Board needs to specify the exact mapping during their setup time. -*/ -void physmap_configure (unsigned long addr,unsigned long size, -int bankwidth,void (*set_vpp)(struct map_info *,int ) ); - -/* -* Machines that wish to do flash partition may want to call this function in -* their setup routine. -* -* physmap_set_partitions(mypartitions, num_parts); -* -* Note that one can always override this hard-coded partition with -* command line partition (you need to enable CONFIG_MTD_CMDLINE_PARTS). -*/ -void physmap_set_partitions (struct mtd_partition *parts,int num_parts); -#endif /* __LINUX_MTD_PHYSMAP__ */
Signature · 1 line
1.7.4.4
PATCH 5/104 mtd: cafe_nand: drop reference to CONFIG_MTD_CMDLINE_PARTS
In reply to Dmitry Eremin-SolenikovThere is no need to guard mtd->name with CONFIG_MTD_CMDLINE_PARTS as name can be used by other parts.
--- drivers/mtd/nand/cafe_nand.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/mtd/nand/cafe_nand.c +0 -2
@@ -802,9 +802,7 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,/* We register the whole device first, separate from the partitions */ mtd_device_register (mtd,NULL ,0 ); -#ifdef CONFIG_MTD_CMDLINE_PARTS mtd->name ="cafe_nand" ; -#endif nr_parts =parse_mtd_partitions (mtd, part_probes, &parts,0 );if (nr_parts >0 ) { cafe->parts = parts;
Signature · 1 line
1.7.4.4
PATCH 6/104 mtdpart: default to cmdlinepart, NULL partitions probing
In reply to Dmitry Eremin-SolenikovLots of MTD devices default to cmdlinepart, NULL as partition parsing order. Make it a default.
--- drivers/mtd/mtdpart.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/mtd/mtdpart.c +5 -0
@@ -712,12 +712,17 @@ int deregister_mtd_parser(struct mtd_part_parser *p) }EXPORT_SYMBOL_GPL (deregister_mtd_parser); +static const char *default_mtd_part_types[] = {"cmdlinepart" ,NULL }; +int parse_mtd_partitions (struct mtd_info *master,const char **types,struct mtd_partition **pparts,unsigned long origin) {struct mtd_part_parser *parser;int ret =0 ; +if (!types) + types = default_mtd_part_types; +for ( ; ret <=0 && *types; types++) { parser =get_partition_parser (*types);if (!parser && !request_module ("%s" , *types))
Signature · 1 line
1.7.4.4
Re: [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing
Quoted 20 lines · Dmitry Eremin-Solenikov
Lots of MTD devices default to cmdlinepart, NULL as partition parsing order. Make it a default.
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- drivers/mtd/mtdpart.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)drivers/mtd/mtdpart.c +2
-0@@ -712,12 +712,17 @@ int deregister_mtd_parser(struct mtd_part_parser *p) }EXPORT_SYMBOL_GPL (deregister_mtd_parser); +static const char *default_mtd_part_types[] = {"cmdlinepart" ,NULL }; +int parse_mtd_partitions (struct mtd_info *master,const char **types,struct mtd_partition **pparts,unsigned long origin)
drivers/mtd/mtdpart.c int deregister_mtd_parser(struct mtd_part_parser *p) · line 728
Quoted 10 lines
drivers/mtd/mtdpart.c +3
-0{struct mtd_part_parser *parser;int ret =0 ; +if (!types) + types = default_mtd_part_types; +for ( ; ret <=0 && *types; types++) { parser =get_partition_parser (*types);if (!parser && !request_module ("%s" , *types))
Pushed patches 4 and 5 to l2-mtd-2.6.git. Going to push this one as well, but I would be nice go put a piece of descriptive comment above 'parse_mtd_partitions()', preferably a nice kerneldoc comment. As a separate patch.
Anyway, pushing this one to the l2 tree as well.
P.S. Also added an "mtd:" prefix.
PATCH 7/104 mtd: m25p80 don't specify default parsing options
In reply to Dmitry Eremin-SolenikovSince 'cmdline, NULL' is now a default for parse_mtd_partitions, don't specify this in every driver, instead pass NULL to force parse_mtd_partitions to use default.
--- drivers/mtd/devices/m25p80.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/devices/m25p80.c +1 -7
@@ -968,13 +968,7 @@ static int __devinit m25p_probe(struct spi_device *spi)/* partitions should match sector boundaries; and it may be good to * use readonly partitions for writeprotected sectors (BP2..BP0). */ -if (mtd_has_cmdlinepart ()) { -static const char *part_probes[] - = {"cmdlinepart" ,NULL , }; - - nr_parts =parse_mtd_partitions (&flash->mtd, - part_probes, &parts,0 ); - } + nr_parts =parse_mtd_partitions (&flash->mtd,NULL , &parts,0 );if (nr_parts <=0 && data && data->parts) { parts = data->parts;
Signature · 1 line
1.7.4.4
Artem Bityutskiy
AppliedRe: [PATCH 007/104] mtd: m25p80 don't specify default parsing options
Quoted 5 lines · Dmitry Eremin-Solenikov
Since 'cmdline, NULL' is now a default for
parse_mtd_partitions, don't specify this in every driver, instead pass NULL to forceparse_mtd_partitionsto use default.Signed-off-by Dmitry Eremin-Solenikov <[email protected]>
Pushed to l2-mtd-2.6.git, thanks.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
PATCH 40/104 mtd: drop mtd_has_cmdlinepart()
In reply to Dmitry Eremin-SolenikovThis function is unused now. Drop it.
--- include/linux/mtd/partitions.h | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
include/linux/mtd/partitions.h +0 -6
@@ -83,12 +83,6 @@ static inline int of_mtd_parse_partitions(struct device *dev, }#endif -#ifdef CONFIG_MTD_CMDLINE_PARTS -static inline int mtd_has_cmdlinepart (void ) {return 1 ; } -#else -static inline int mtd_has_cmdlinepart (void ) {return 0 ; } -#endif -int mtd_is_partition (struct mtd_info *mtd);int mtd_add_partition (struct mtd_info *master,char *name,long long offset,long long length);
Signature · 1 line
1.7.4.4
Re: [PATCH 040/104] mtd: drop mtd_has_cmdlinepart()
Quoted 3 lines · Dmitry Eremin-Solenikov
This function is unused now. Drop it.
Signed-off-by Dmitry Eremin-Solenikov <[email protected]>
I guess patches 8-39 are like patch 7 and remove explicit cmdline setup. I guess it does not hurt if I take this patch now - you can omit it from the next submission.
So, taken to l2-mtd-2.6.git, thanks.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
PATCH 41/104 mtd: prepare to convert of_mtd_parse_partitions to partition parser
In reply to Dmitry Eremin-SolenikovPrepare to convert of_mtd_parse_partitions() to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Add device_node to mtd_info struct
4) Move of_mtd_parse_partitions from __devinit to common text section
5) add ofpart to the default list of partition parsers
--- drivers/mtd/mtdcore.c | 9 +++++++++ drivers/mtd/mtdpart.c | 2 +- drivers/mtd/ofpart.c | 30 ++++++++++++++++++++++++++++-- include/linux/mtd/mtd.h | 3 +++ include/linux/mtd/partitions.h | 2 +- 5 files changed, 42 insertions(+), 4 deletions(-)
drivers/mtd/mtdcore.c +9 -0
@@ -36,6 +36,7 @@#include <linux/idr.h> #include <linux/backing-dev.h> #include <linux/gfp.h> +#include <linux/of.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h>
@@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif return parts ?add_mtd_partitions (master, parts, nr_parts) :add_mtd_device (master); }
@@ -461,6 +466,10 @@ int mtd_device_unregister(struct mtd_info *master) {int err; +#ifdef CONFIG_OF +if (master->node) +of_node_put (master->node); +#endif err =del_mtd_partitions (master);if (err)return err;
drivers/mtd/mtdpart.c +1 -1
@@ -712,7 +712,7 @@ int deregister_mtd_parser(struct mtd_part_parser *p) }EXPORT_SYMBOL_GPL (deregister_mtd_parser); -static const char *default_mtd_part_types[] = {"cmdlinepart" ,NULL }; +static const char *default_mtd_part_types[] = {"cmdlinepart" ,"ofpart" ,NULL };int parse_mtd_partitions (struct mtd_info *master,const char **types,struct mtd_partition **pparts,unsigned long origin)
drivers/mtd/ofpart.c +28 -2
@@ -20,7 +20,20 @@#include <linux/slab.h> #include <linux/mtd/partitions.h> -int __devinit of_mtd_parse_partitions (struct device *dev, +static int parse_ofpart_partitions (struct mtd_info *master, +struct mtd_partition **pparts, +unsigned long origin) +{ +struct device_node *node; + + node = master->node; +if (!node) +return 0 ; + +return of_mtd_parse_partitions (NULL , node, pparts); +} + +int of_mtd_parse_partitions (struct device *dev,struct device_node *node,struct mtd_partition **pparts) {
@@ -69,7 +82,7 @@ int __devinit of_mtd_parse_partitions(struct device *dev,if (!i) {of_node_put (pp); -dev_err (dev,"No valid partition found on %s\n" , node->full_name); +pr_err ("No valid partition found on %s\n" , node->full_name);kfree (*pparts); *pparts =NULL ;return -EINVAL ;
@@ -79,4 +92,17 @@ int __devinit of_mtd_parse_partitions(struct device *dev, }EXPORT_SYMBOL (of_mtd_parse_partitions); +static struct mtd_part_parser ofpart_parser = { + .owner =THIS_MODULE , + .parse_fn = parse_ofpart_partitions, + .name ="ofpart" , +}; + +static int __init ofpart_parser_init (void ) +{ +return register_mtd_parser (&ofpart_parser); +} + +module_init (ofpart_parser_init); +MODULE_LICENSE ("GPL" );
include/linux/mtd/mtd.h +3 -0
@@ -171,6 +171,9 @@ struct mtd_info {// Kernel-only stuff starts here. const char *name;int index; +#ifdef CONFIG_OF +struct device_node *node; +#endif /* ecc layout structure pointer - read only ! */ struct nand_ecclayout *ecclayout;
include/linux/mtd/partitions.h +1 -1
@@ -71,7 +71,7 @@ struct device;struct device_node ;#ifdef CONFIG_MTD_OF_PARTS -int __devinit of_mtd_parse_partitions (struct device *dev, +int of_mtd_parse_partitions (struct device *dev,struct device_node *node,struct mtd_partition **pparts);#else
Signature · 1 line
1.7.4.4
Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 8 lines · Dmitry Eremin-Solenikov
Prepare to convert
of_mtd_parse_partitions()to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov <[email protected]>
Good idea, but
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 10 lines
#include <
linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>drivers/mtd/mtdcore.c +4
-0@@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif
Could all the OF-specific things be done in the ofpart.c ?
include/linux/mtd/mtd.h struct mtd_info { · line 176
Quoted 9 lines
include/linux/mtd/mtd.h +3
-0@@ -171,6 +171,9 @@ struct mtd_info {// Kernel-only stuff starts here. const char *name;int index; +#ifdef CONFIG_OF +struct device_node *node; +#endif
And designe-wise this does not look like a good idea to have such fields in mtd_info ... Who initializes this "node" field?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 12 lines · Artem Bityutskiy
Quoted 8 lines · Dmitry Eremin-Solenikov
Prepare to convert
of_mtd_parse_partitions()to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov<[email protected]>Good idea, but
Quoted 12 lines
drivers/mtd/mtdcore.c int mtd_device_register(struct mtd_info *master, · line 453
Quoted 10 lines
#include<linux/mtd/mtd.h> #include<linux/mtd/partitions.h>drivers/mtd/mtdcore.c +4
-0@@ -446,6 +447,10 @@ int mtd_device_register(struct mtd_info *master, const struct mtd_partition *parts, int nr_parts) { +#ifdef CONFIG_OF +if (master->node) +of_node_get (master->node); +#endif Could all the OF-specific things be done in the
ofpart.c?
Answering both of your questions here:
My idea is to have an of node connected to mtd device, if there is any. It can be used by ofpart.c, ofoldpart.c (extract from physmap_of), maybe some other parsers/drivers/etc.
The field is populated by the creator of mtd_info. Then the function
dedicated to registration of the mtd should get the node and other functions can just use it. Maybe this should be moved to add_mtd_device, but this shouldn't be handled in ofpart.c
Another way can be to populate ->node pointer before parsing, then drop it at the end of parsing/registration. Thus we won't have to handle getting/putting the of node, but it won't be available during mtd lifecycle.
Quoted 13 lines
include/linux/mtd/mtd.h struct mtd_info { · line 176
Quoted 9 lines
include/linux/mtd/mtd.h +3
-0@@ -171,6 +171,9 @@ struct mtd_info {// Kernel-only stuff starts here. const char *name;int index; +#ifdef CONFIG_OF +struct device_node *node; +#endif And designe-wise this does not look like a good idea to have such fields in
mtd_info... Who initializes this "node" field?
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 3 lines · Dmitry Eremin-Solenikov
Answering both of your questions here:
My idea is to have an of node connected to mtd device, if there is any.
I just think the connection should be different. Probably the best would be to have an OF-specific object (some struct of_info) containing struct mtd_info inside, and then OF code can use container_of().
Quoted 2 lines
It can be used by
ofpart.c,ofoldpart.c(extract fromphysmap_of), maybe some other parsers/drivers/etc.
I'm still not convinced we need ofoldpart.c - that is a small piece of cade which can be put to ofpart.c.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 8 lines · Artem Bityutskiy
Quoted 3 lines · Dmitry Eremin-Solenikov
Answering both of your questions here:
My idea is to have an of node connected to mtd device, if there is any.I just think the connection should be different. Probably the best would be to have an OF-specific object (some struct
of_info) containing structmtd_infoinside, and then OF code can usecontainer_of().
That will be agains current linux coding practices. E.g. check the gpio, i2c, etc. code. All add device_node field to existing structs.
Quoted 5 lines
Quoted 2 lines
It can be used by
ofpart.c,ofoldpart.c(extract fromphysmap_of), maybe some other parsers/drivers/etc.I'm still not convinced we need
ofoldpart.c- that is a small piece of cade which can be put toofpart.c.
Agreed.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
In reply to Dmitry Eremin-SolenikovQuoted 8 lines · Dmitry Eremin-Solenikov
Prepare to convert
of_mtd_parse_partitions()to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsersSigned-off-by Dmitry Eremin-Solenikov <[email protected]>
Do not apply this and further changes so far - I had some questions.
Anyway, your series consists of as set of logical steps, which is really nice, so let's finish with the first cmdline consolidation step, and then move on.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
Quoted 8 lines · Artem Bityutskiy
Quoted 7 lines · Dmitry Eremin-Solenikov
Prepare to convert
of_mtd_parse_partitions()to usual partitions parser:
1) Register ofpart parser
2) Internally don't use passed device for error printing
3) Adddevice_nodetomtd_infostruct
4) Moveof_mtd_parse_partitionsfrom__devinitto common text section
5) add ofpart to the default list of partition parsers
Quoted 7 lines
Quoted 1 line
Signed-off-by Dmitry Eremin-Solenikov<[email protected]>Do not apply this and further changes so far - I had some questions.
Anyway, your series consists of as set of logical steps, which is really nice, so let's finish with the first cmdline consolidation step, and then move on.
BTW: what about fixing order of parsing to:
cmdlinepart,
RedBoot,
afs,
ofpart/ofoldpart,
platform-default-hook.
This will allow me to drop "parse order" options from all relevant functions.
Signature · 2 lines
With best wishes Dmitry
PATCH 42/104 mtd: m25p80: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/devices/m25p80.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/devices/m25p80.c +1 -7
@@ -928,6 +928,7 @@ static int __devinit m25p_probe(struct spi_device *spi)if (info->flags &M25P_NO_ERASE ) flash->mtd.flags |=MTD_NO_ERASE ; + flash->mtd.node = spi->dev.of_node; flash->mtd.dev.parent = &spi->dev; flash->page_size = info->page_size;
@@ -975,13 +976,6 @@ static int __devinit m25p_probe(struct spi_device *spi) nr_parts = data->nr_parts; } -#ifdef CONFIG_MTD_OF_PARTS -if (nr_parts <=0 && spi->dev.of_node) { - nr_parts =of_mtd_parse_partitions (&spi->dev, - spi->dev.of_node, &parts); - } -#endif -if (nr_parts >0 ) {for (i =0 ; i < nr_parts; i++) { DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
Signature · 1 line
1.7.4.4
PATCH 43/104 mtd: physmap_of: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/maps/physmap_of.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
drivers/mtd/maps/physmap_of.c +3 -7
@@ -165,7 +165,8 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,specifies the list of partition probers to use. If none is given then the default is use. These take precedence over other device tree information. */ -static const char *part_probe_types_def[] = {"cmdlinepart" ,"RedBoot" ,NULL }; +static const char *part_probe_types_def[] = {"cmdlinepart" ,"RedBoot" , +"ofpart" ,NULL };static const char **__devinit of_get_probes (struct device_node *dp) {const char *cp;
@@ -331,6 +332,7 @@ static int __devinit of_flash_probe(struct platform_device *dev)if (err) goto err_out; + info->cmtd->node = dp; part_probe_types =of_get_probes (dp); err =parse_mtd_partitions (info->cmtd, part_probe_types, &info->parts,0 );
@@ -341,12 +343,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)of_free_probes (part_probe_types);if (err ==0 ) { - err =of_mtd_parse_partitions (&dev->dev, dp, &info->parts); -if (err <0 ) - goto err_out; - } - -if (err ==0 ) { err =parse_obsolete_partitions (dev, info, dp);if (err <0 ) goto err_out;
Signature · 1 line
1.7.4.4
PATCH 44/104 mtd: fsl_elbc_nand: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/fsl_elbc_nand.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
drivers/mtd/nand/fsl_elbc_nand.c +2 -7
@@ -842,7 +842,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)struct resource res;struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl;static const char *part_probe_types[] - = {"cmdlinepart" ,"RedBoot" ,NULL }; + = {"cmdlinepart" ,"RedBoot" ,"ofpart" ,NULL };struct mtd_partition *parts;int ret;int bank;
@@ -910,6 +910,7 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev) goto err; } + priv->mtd.node = pdev->dev.of_node; priv->mtd.name =kasprintf (GFP_KERNEL ,"%x.flash" , (unsigned )res.start);if (!priv->mtd.name) { ret = -ENOMEM ;
@@ -938,12 +939,6 @@ static int __devinit fsl_elbc_nand_probe(struct platform_device *pdev)if (ret <0 ) goto err; -if (ret ==0 ) { - ret =of_mtd_parse_partitions (priv->dev, node, &parts); -if (ret <0 ) - goto err; - } -mtd_device_register (&priv->mtd, parts, ret); printk(KERN_INFO "eLBC NAND device at 0x%llx, bank %d\n",
Signature · 1 line
1.7.4.4
PATCH 45/104 mtd: fsl_upm: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/fsl_upm.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/nand/fsl_upm.c +1 -7
@@ -175,6 +175,7 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun, fun->mtd.priv = &fun->chip; fun->mtd.owner =THIS_MODULE ; + fun->mtd.node = flash_np; flash_np =of_get_next_child (upm_np,NULL );if (!flash_np)
@@ -193,13 +194,6 @@ static int __devinit fun_chip_init(struct fsl_upm_nand *fun, ret =parse_mtd_partitions (&fun->mtd,NULL , &fun->parts,0 ); -#ifdef CONFIG_MTD_OF_PARTS -if (ret ==0 ) { - ret =of_mtd_parse_partitions (fun->dev, flash_np, &fun->parts); -if (ret <0 ) - goto err; - } -#endif ret =mtd_device_register (&fun->mtd, fun->parts, ret); err:of_node_put (flash_np);
Signature · 1 line
1.7.4.4
PATCH 46/104 mtd: mpc5121_nfc: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/mpc5121_nfc.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
drivers/mtd/nand/mpc5121_nfc.c +1 -4
@@ -725,6 +725,7 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op) } mtd->name ="MPC5121 NAND" ; + mtd->node = dn; chip->dev_ready = mpc5121_nfc_dev_ready; chip->cmdfunc = mpc5121_nfc_command; chip->read_byte = mpc5121_nfc_read_byte;
@@ -836,10 +837,6 @@ static int __devinit mpc5121_nfc_probe(struct platform_device *op)/* Register device in MTD */ retval =parse_mtd_partitions (mtd,NULL , &parts,0 ); -#ifdef CONFIG_MTD_OF_PARTS -if (retval ==0 ) - retval =of_mtd_parse_partitions (dev, dn, &parts); -#endif if (retval <0 ) {dev_err (dev,"Error parsing MTD partitions!\n" );devm_free_irq (dev, prv->irq, mtd);
Signature · 1 line
1.7.4.4
PATCH 47/104 mtd: ndfc: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/ndfc.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/mtd/nand/ndfc.c +1 -7
@@ -188,6 +188,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,if (!flash_np)return -ENODEV ; + ndfc->mtd.node = flash_np; ndfc->mtd.name =kasprintf (GFP_KERNEL ,"%s.%s" ,dev_name (&ndfc->ofdev->dev), flash_np->name);if (!ndfc->mtd.name) {
@@ -203,13 +204,6 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,if (ret <0 ) goto err; -if (ret ==0 ) { - ret =of_mtd_parse_partitions (&ndfc->ofdev->dev, flash_np, - &ndfc->parts); -if (ret <0 ) - goto err; - } - ret =mtd_device_register (&ndfc->mtd, ndfc->parts, ret); err:
Signature · 1 line
1.7.4.4
PATCH 48/104 mtd: socrates_nand: use ofpart through generic parsing
In reply to Dmitry Eremin-SolenikovConvert the driver to use ofpart partitions parsing through the generic parse_mtd_partitions().
--- drivers/mtd/nand/socrates_nand.c | 11 +---------- 1 files changed, 1 insertions(+), 10 deletions(-)
drivers/mtd/nand/socrates_nand.c +1 -10
@@ -191,6 +191,7 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev) mtd->name ="socrates_nand" ; mtd->owner =THIS_MODULE ; mtd->dev.parent = &ofdev->dev; + mtd->node = ofdev->dev.of_node;/*should never be accessed directly */ nand_chip->IO_ADDR_R = (void *)0xdeadbeef ;
@@ -230,16 +231,6 @@ static int __devinit socrates_nand_probe(struct platform_device *ofdev) goto release; } -if (num_partitions ==0 ) { - num_partitions =of_mtd_parse_partitions (&ofdev->dev, - ofdev->dev.of_node, - &partitions); -if (num_partitions <0 ) { - res = num_partitions; - goto release; - } - } - res =mtd_device_register (mtd, partitions, num_partitions);if (!res)return res;
Signature · 1 line
1.7.4.4
PATCH 49/104 mtd: drop of_mtd_parse_partitions()
In reply to Dmitry Eremin-SolenikovAll users have been converted to call of_mtd_parse_partitions through parse_mtd_partitions() multiplexer. Drop obsolete API.
--- drivers/mtd/ofpart.c | 16 ++++------------ include/linux/mtd/partitions.h | 16 ---------------- 2 files changed, 4 insertions(+), 28 deletions(-)
drivers/mtd/ofpart.c +4 -12
@@ -25,22 +25,15 @@ static int parse_ofpart_partitions(struct mtd_info *master, unsigned long origin) {struct device_node *node; +const char *partname; +struct device_node *pp; +int nr_parts, i; + node = master->node;if (!node)return 0 ; -return of_mtd_parse_partitions (NULL , node, pparts); -} - -int of_mtd_parse_partitions (struct device *dev, -struct device_node *node, -struct mtd_partition **pparts) -{ -const char *partname; -struct device_node *pp; -int nr_parts, i; -/* First count the subnodes */ pp =NULL ; nr_parts =0 ;
@@ -90,7 +83,6 @@ int of_mtd_parse_partitions(struct device *dev,return nr_parts; } -EXPORT_SYMBOL (of_mtd_parse_partitions);static struct mtd_part_parser ofpart_parser = { .owner =THIS_MODULE ,
include/linux/mtd/partitions.h +0 -16
@@ -67,22 +67,6 @@ extern int parse_mtd_partitions(struct mtd_info *master, const char **types,#define put_partition_parser (p) do { module_put((p)->owner); } while(0) -struct device ; -struct device_node ; - -#ifdef CONFIG_MTD_OF_PARTS -int of_mtd_parse_partitions (struct device *dev, -struct device_node *node, -struct mtd_partition **pparts); -#else -static inline int of_mtd_parse_partitions (struct device *dev, -struct device_node *node, -struct mtd_partition **pparts) -{ -return 0 ; -} -#endif -int mtd_is_partition (struct mtd_info *mtd);int mtd_add_partition (struct mtd_info *master,char *name,long long offset,long long length);
Signature · 1 line
1.7.4.4
PATCH 50/104 physmap_of: separate parse_obsolete_partitions to separate parser
In reply to Dmitry Eremin-SolenikovSeparate parse_obsolete_partitions() to external ofoldpart partitions parser.
--- drivers/mtd/Kconfig | 10 +++++ drivers/mtd/Makefile | 1 + drivers/mtd/maps/physmap_of.c | 53 +------------------------ drivers/mtd/ofoldpart.c | 89 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 52 deletions(-) create mode 100644 drivers/mtd/ofoldpart.c
drivers/mtd/Kconfig +10 -0
@@ -144,6 +144,16 @@ config MTD_OF_PARTS the partition map from the children of the flash node, as described in Documentation/powerpc/booting-without-of.txt. +config MTD_OF_OLD_PARTS + bool "Obsolete OF tree partition info" + depends on OF + help + This provides a partition parsing function which derives + the partition map from the the flash node, being an obsolete + way to describe physmap_of partitioning info. + + If you aren't sure you need this, you can say N. + config MTD_AR7_PARTS tristate "TI AR7 partitioning support" ---help---
drivers/mtd/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_MTD) += mtd.o mtd-y := mtdcore.o mtdsuper.o mtdconcat.o mtdpart.o mtd-$(CONFIG_MTD_OF_PARTS) += ofpart.o +mtd-$(CONFIG_MTD_OF_OLD_PARTS) += ofoldpart.o obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o
drivers/mtd/maps/physmap_of.c +1 -52
71 lines not on this page · raw message
drivers/mtd/ofoldpart.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.7.4.4
Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
Quoted 18 lines · Dmitry Eremin-Solenikov
Separate
parse_obsolete_partitions()to external ofoldpart partitions parser.Signed-off-by Dmitry Eremin-Solenikov <[email protected]>--- drivers/mtd/Kconfig | 10 +++++ drivers/mtd/Makefile | 1 + drivers/mtd/maps/physmap_of.c | 53 +------------------------ drivers/mtd/ofoldpart.c | 89 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 52 deletions(-) create mode 100644 drivers/mtd/ofoldpart.cdrivers/mtd/Kconfig +0
-0@@ -144,6 +144,16 @@ config MTD_OF_PARTS the partition map from the children of the flash node, as described in Documentation/powerpc/booting-without-of.txt.
drivers/mtd/Kconfig config MTD_OF_PARTS · line 155
Quoted 10 lines
drivers/mtd/Kconfig +9
-0+config MTD_OF_OLD_PARTS + bool "Obsolete OF tree partition info" + depends on OF + help + This provides a partition parsing function which derives + the partition map from the the flash node, being an obsolete + way to describe physmap_of partitioning info. + + If you aren't sure you need this, you can say N.
I think this tiny piece of code does not deserve to be a separate module...
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
Quoted 20 lines · Artem Bityutskiy
Quoted 19 lines · Dmitry Eremin-Solenikov
Separate
parse_obsolete_partitions()to external ofoldpart partitions parser.Signed-off-by Dmitry Eremin-Solenikov<[email protected]>--- drivers/mtd/Kconfig | 10 +++++ drivers/mtd/Makefile | 1 + drivers/mtd/maps/physmap_of.c | 53 +------------------------ drivers/mtd/ofoldpart.c | 89 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 52 deletions(-)create mode 100644
drivers/mtd/ofoldpart.cdrivers/mtd/Kconfig +0
-0@@ -144,6 +144,16 @@ config MTD_OF_PARTS the partition map from the children of the flash node, as described in Documentation/powerpc/booting-without-of.txt.
Quoted 12 lines
drivers/mtd/Kconfig config MTD_OF_PARTS · line 155
Quoted 9 lines
drivers/mtd/Kconfig +9
-0+config MTD_OF_OLD_PARTS + bool "Obsolete OF tree partition info" + depends on OF + help + This provides a partition parsing function which derives + the partition map from the the flash node, being an obsolete + way to describe physmap_of partitioning info. + + If you aren't sure you need this, you can say N.I think this tiny piece of code does not deserve to be a separate module...
I'd really like to strip it out of physmap_of to simplify things.
It parses the mtd partitions, it's a separate functional part. I can argue if it should be a module or just in-kernel part, if it should be visible to users (or just autoselected by physmap_of), but I'd definitely prefer to have this as a separate source file hooking into generic mtd_parse subsystem.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
Quoted 8 lines · Dmitry Eremin-Solenikov
I'd really like to strip it out of
physmap_ofto simplify things.It parses the mtd partitions, it's a separate functional part. I can argue if it should be a module or just in-kernel part, if it should be
visible to users (or just autoselected byphysmap_of), but I'd definitely prefer to have this as a separate source file hooking into genericmtd_parsesubsystem.
I understand your desire to keep physmap_of nice and shiny and have all the crap separate, but that is really too small amount of code to even a separate file. And after all, that's physmap_of's crap, you can keep it in separate functions and register as a separate parser, but put it say, to the end of phusmap_of file with a big fat comment telling that no one should use it, you can add a deprication date, a warning, etc as well.
P.S. I'm not very aware of OF so if adding a warning is a stupid suggestion, please just ignore it.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
Quoted 3 lines · Artem Bityutskiy
I understand your desire to keep
physmap_ofnice and shiny and have all the crap separate, but that is really too small amount of code to even a separate file. And after all, that's physmap_of's crap,
Or rather s/phusmap_of/ofpart/
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
Quoted 6 lines · Artem Bityutskiy
Quoted 3 lines · Artem Bityutskiy
I understand your desire to keep
physmap_ofnice and shiny and have all the crap separate, but that is really too small amount of code to even a separate file. And after all, that's physmap_of's crap,Or rather s/phusmap_of/ofpart/
I've initially thought about this, but didn't want to put too much crap to ofpart. Will follow this way, as you suggest.
Signature · 2 lines
With best wishes Dmitry
PATCH 51/104 mtd: add a flags for partitions which should just leave smth. after them
In reply to Dmitry Eremin-SolenikovAdd support for MTDPART_OFS_RETAIN: such partitions start at the current offset, take as much space as possible, but rain part->size bytes after the end of the partitions for other parts. Primarily this is intended for ts72xx arm platforms cleanup.
--- drivers/mtd/mtdpart.c | 11 +++++++++++ include/linux/mtd/partitions.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletions(-)
drivers/mtd/mtdpart.c +11 -0
@@ -479,6 +479,17 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, (unsigned long long)cur_offset, (unsigned long long)slave->offset); } } +if (slave->offset ==MTDPART_OFS_RETAIN ) { + slave->offset = cur_offset; +if (master->size - slave->offset >= slave->mtd.size) { + slave->mtd.size = master->size - slave->offset - slave->mtd.size; + }else { +printk (KERN_ERR "mtd partition \"%s\" doesn't have enough space: %#llx < %#llx, disabled\n" , + part->name, master->size - slave->offset, slave->mtd.size); +/* register to preserve ordering */ + goto out_register; + } + }if (slave->mtd.size ==MTDPART_SIZ_FULL ) slave->mtd.size = master->size - slave->offset;
include/linux/mtd/partitions.h +4 -1
@@ -24,7 +24,9 @@* will extend to the end of the master MTD device. * offset: absolute starting position within the master MTD device; if * defined as MTDPART_OFS_APPEND, the partition will start where the -* previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block. +* previous one ended; if MTDPART_OFS_NXTBLK, at the next erase block; +* if MTDPART_OFS_RETAIN, consume as much as possible, leaving size +* after the end of partition. * mask_flags: contains flags that have to be masked (removed) from the * master MTD flag set for the corresponding MTD partition. * For example, to force a read-only partition, simply adding
@@ -42,6 +44,7 @@ struct mtd_partition {struct nand_ecclayout *ecclayout;/* out of band layout for this partition (NAND only) */ }; +#define MTDPART_OFS_RETAIN (-3)#define MTDPART_OFS_NXTBLK (-2)#define MTDPART_OFS_APPEND (-1)#define MTDPART_SIZ_FULL (0)
Signature · 1 line
1.7.4.4
PATCH 52/104 ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning
In reply to Dmitry Eremin-SolenikovInstead of specifying a callback for dynamic partitioning, use MTDPART_OFS_RETAIN for reserving a place near the end of flash for RedBoot.
--- arch/arm/mach-ep93xx/ts72xx.c | 22 ++++------------------ 1 files changed, 4 insertions(+), 18 deletions(-)
arch/arm/mach-ep93xx/ts72xx.c +4 -18
@@ -116,8 +116,8 @@ static struct mtd_partition ts72xx_nand_parts[] = { .mask_flags = MTD_WRITEABLE, /* force read-only */ }, { .name = "Linux", - .offset = MTDPART_OFS_APPEND, - .size = 0, /* filled in later */ + .offset = MTDPART_OFS_RETAIN, + .size = TS72XX_REDBOOT_PART_SIZE, /* leave so much for last partition */ }, { .name = "RedBoot", .offset = MTDPART_OFS_APPEND,
@@ -126,28 +126,14 @@ static struct mtd_partition ts72xx_nand_parts[] = { }, }; -static void ts72xx_nand_set_parts (uint64_t size, -struct platform_nand_chip *chip) -{ -/* Factory TS-72xx boards only come with 32MiB or 128MiB NAND options */ -if (size ==SZ_32M || size ==SZ_128M ) { -/* Set the "Linux" partition size */ - ts72xx_nand_parts[1 ].size = size -TS72XX_REDBOOT_PART_SIZE ; - - chip->partitions = ts72xx_nand_parts; - chip->nr_partitions =ARRAY_SIZE (ts72xx_nand_parts); - }else { -pr_warning ("Unknown nand disk size:%lluMiB\n" , size >>20 ); - } -} -static struct platform_nand_data ts72xx_nand_data = { .chip = { .nr_chips =1 , .chip_offset =0 , .chip_delay =15 , .part_probe_types = ts72xx_nand_part_probes, - .set_parts = ts72xx_nand_set_parts, + .partitions = ts72xx_nand_parts, + .nr_partitions =ARRAY_SIZE (ts72xx_nand_parts), }, .ctrl = { .cmd_ctrl = ts72xx_nand_hwcontrol,
Signature · 1 line
1.7.4.4
PATCH 53/104 mtd: plat-nand: drop unused fields from platform_nand_data
In reply to Dmitry Eremin-SolenikovDrop now unused set_parts from struct platform_nand_data. Also, while we are at it, drop long unused priv field from platform_nand_data.
--- drivers/mtd/nand/plat_nand.c | 2 -- include/linux/mtd/nand.h | 2 -- 2 files changed, 0 insertions(+), 4 deletions(-)
drivers/mtd/nand/plat_nand.c +0 -2
@@ -108,8 +108,6 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)return 0 ; } } -if (pdata->chip.set_parts) - pdata->chip.set_parts (data->mtd.size, &pdata->chip);if (pdata->chip.partitions) { data->parts = pdata->chip.partitions; err = mtd_device_register(&data->mtd, data->parts,
include/linux/mtd/nand.h +0 -2
@@ -625,8 +625,6 @@ struct platform_nand_chip {int chip_delay;unsigned int options;const char **part_probe_types; -void (*set_parts)(uint64_t size,struct platform_nand_chip *chip); -void *priv; };/* Keep gcc happy */
Signature · 1 line
1.7.4.4
PATCH 54/104 mtd: add new API for handling MTD registration
In reply to Dmitry Eremin-SolenikovLots (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 | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/mtd/mtd.h | 5 +++++ 2 files changed, 45 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +40 -0
@@ -456,6 +456,46 @@ int mtd_device_register(struct mtd_info *master, }EXPORT_SYMBOL_GPL (mtd_device_register); +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) +{ +int err; +struct mtd_partition *parts; + + err =parse_mtd_partitions (mtd, part_probe_types, &parts, origin); +if (err <=0 && defnr_parts) { +unsigned long size =sizeof (*parts) * defnr_parts; + err = defnr_parts; + parts =kzalloc (size,GFP_KERNEL ); +memcpy (parts, defparts, size); + } + +#ifdef CONFIG_OF +if (mtd->node) +of_node_get (mtd->node); +#endif + +if (err >0 ) { + err =add_mtd_partitions (mtd, parts, err); +kfree (parts); + }else { + err =add_mtd_device (mtd); +if (err ==1 ) + err = -ENODEV ; + } + +#ifdef CONFIG_OF +if (err <0 && mtd->node) +of_node_put (mtd->node); +#endif + +return err; +} +EXPORT_SYMBOL_GPL (mtd_device_parse_register); +/** * mtd_device_unregister - unregister an existing MTD device. *
include/linux/mtd/mtd.h +5 -0
@@ -330,6 +330,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
PATCH 55/104 mtd: lart.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/lart.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/mtd/devices/lart.c +4 -8
@@ -619,6 +619,10 @@ static struct mtd_partition lart_partitions[] = { .size = INITRD_LEN, /* MTDPART_SIZ_FULL */ } }; +#define NUM_PARTITIONS ARRAY_SIZE(lart_partitions) +#else +#define lart_partitions NULL +#define NUM_PARTITIONS 0#endif static int __init lart_flash_init (void )
@@ -683,23 +687,15 @@ static int __init lart_flash_init (void)#endif #endif -#ifndef HAVE_PARTITIONS - result =mtd_device_register (&mtd,NULL ,0 ); -#else result =mtd_device_register (&mtd, lart_partitions,ARRAY_SIZE (lart_partitions)); -#endif return (result); } static void __exit lart_flash_exit (void) { -#ifndef HAVE_PARTITIONS mtd_device_unregister (&mtd); -#else -mtd_device_unregister (&mtd); -#endif }module_init (lart_flash_init);
Signature · 1 line
1.7.4.4
Quoted 11 lines · Dmitry Eremin-Solenikov
Hello,
This is an RFC for a huge serie of patches converting most mtd drivers to use single instance of code for managing mtd partitions parsing and handling.
Currently each driver responsible for partitions implements this part of code on it's own, resulting in memory leaks, possible frees of non-allocated memory, etc. As the patch serie is huge, I'm posting only patches I consider "interesting", i. e. from the subserie doing the same cleanup for different drivers I post only first patch. Rest are available through the gitweb.
Quoted 6 lines
Only one driver still uses
parse_mtd_partitionsafter this serie (edb7312), as it registers both parsed partitions and the whole mtd device and I ain't sure how to behave at this case.If the idea seems find to be commited, I'll post the whole serie for full review.
Hi, sure this is interesting. I'll try to find time and go through this and push to l2 tree. But then please, ping dwmw2 to look at this, because otherwise it will not get to linux-next till the end of the next merge window.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Quoted 22 lines · Artem Bityutskiy
Quoted 21 lines · Dmitry Eremin-Solenikov
Hello,
This is an RFC for a huge serie of patches converting most mtd drivers to use
single instance of code for managing mtd partitions parsing and handling.Currently each driver responsible for partitions implements this part of code
on it's own, resulting in memory leaks, possible frees of non-allocated memory,
etc. As the patch serie is huge, I'm posting only patches I consider "interesting", i. e. from the subserie doing the same cleanup for different
drivers I post only first patch. Rest are available through the gitweb.Only one driver still uses
parse_mtd_partitionsafter this serie (edb7312),
as it registers both parsed partitions and the whole mtd device and I ain't
sure how to behave at this case.
Quoted 7 lines
Quoted 2 lines
If the idea seems find to be commited, I'll post the whole serie for full review.
Hi, sure this is interesting. I'll try to find time and go through this and push to l2 tree. But then please, ping dwmw2 to look at this, because otherwise it will not get to linux-next till the end of the next merge window.
I'll then rebase this on top of l2 tree and post a formal pull request with both you and dwmw2 in cc. Is this fine from your point of view?
Signature · 2 lines
With best wishes Dmitry
Quoted 2 lines · Dmitry Eremin-Solenikov
I'll then rebase this on top of l2 tree and post a formal pull request with both you and dwmw2 in cc. Is this fine from your point of view?
Sure, but also send all the patches to the mailing list.
P.S. Please, do provide a git URL, but note that we usually do not pull. Instead, we pick patches and add Signed-off-by tags.
Thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)