All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 000/104] mtd: cleanup partition parsing interface
@ 2011-06-02 14:51 Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 004/104] mtd: drop physmap_configure Dmitry Eremin-Solenikov
                   ` (20 more replies)
  0 siblings, 21 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

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

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 004/104] mtd: drop physmap_configure
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 005/104] mtd: cafe_nand: drop reference to CONFIG_MTD_CMDLINE_PARTS Dmitry Eremin-Solenikov
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

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.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/maps/Kconfig    |    6 ------
 drivers/mtd/maps/physmap.c  |   15 ---------------
 include/linux/mtd/physmap.h |   17 -----------------
 3 files changed, 0 insertions(+), 38 deletions(-)

diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 11cc230..46eca3b 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -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"
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index f64cee4..2174d10 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -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)
diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h
index d40bfa1..be4ed0d 100644
--- a/include/linux/mtd/physmap.h
+++ b/include/linux/mtd/physmap.h
@@ -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__ */
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 005/104] mtd: cafe_nand: drop reference to CONFIG_MTD_CMDLINE_PARTS
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 004/104] mtd: drop physmap_configure Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing Dmitry Eremin-Solenikov
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

There is no need to guard mtd->name with CONFIG_MTD_CMDLINE_PARTS
as name can be used by other parts.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/cafe_nand.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index 87ebb4e..2cb3141 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -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;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 004/104] mtd: drop physmap_configure Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 005/104] mtd: cafe_nand: drop reference to CONFIG_MTD_CMDLINE_PARTS Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-06  7:14   ` Artem Bityutskiy
  2011-06-02 14:51 ` [PATCH 007/104] mtd: m25p80 don't specify default parsing options Dmitry Eremin-Solenikov
                   ` (17 subsequent siblings)
  20 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Lots of MTD devices default to cmdlinepart, NULL as partition parsing
order. Make it a default.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/mtdpart.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 630be3e..3477e16 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -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))
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 007/104] mtd: m25p80 don't specify default parsing options
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (2 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-06  7:20   ` Artem Bityutskiy
  2011-06-02 14:51 ` [PATCH 040/104] mtd: drop mtd_has_cmdlinepart() Dmitry Eremin-Solenikov
                   ` (16 subsequent siblings)
  20 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Since '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.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/devices/m25p80.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 35180e4..70d5fca 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -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;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 040/104] mtd: drop mtd_has_cmdlinepart()
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (3 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 007/104] mtd: m25p80 don't specify default parsing options Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-06  7:23   ` Artem Bityutskiy
  2011-06-02 14:51 ` [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
                   ` (15 subsequent siblings)
  20 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

This function is unused now. Drop it.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 include/linux/mtd/partitions.h |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 3a6f037..08c9c7b 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -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);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (4 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 040/104] mtd: drop mtd_has_cmdlinepart() Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-06  7:57   ` Artem Bityutskiy
  2011-06-06  8:05   ` Artem Bityutskiy
  2011-06-02 14:51 ` [PATCH 042/104] mtd: m25p80: use ofpart through generic parsing Dmitry Eremin-Solenikov
                   ` (14 subsequent siblings)
  20 siblings, 2 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

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) 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

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 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(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c510aff..bfd5a65 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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;
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 3477e16..0b473ec 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -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)
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index a996718..ff11b85 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -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");
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 2541fb8..14305d0 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -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;
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 08c9c7b..5fde0d8 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -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
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 042/104] mtd: m25p80: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (5 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 043/104] mtd: physmap_of: " Dmitry Eremin-Solenikov
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/devices/m25p80.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 70d5fca..a1cdb52 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -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] = "
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 043/104] mtd: physmap_of: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (6 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 042/104] mtd: m25p80: use ofpart through generic parsing Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 044/104] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/maps/physmap_of.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index d251d1d..312eb17 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -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;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 044/104] mtd: fsl_elbc_nand: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (7 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 043/104] mtd: physmap_of: " Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 045/104] mtd: fsl_upm: " Dmitry Eremin-Solenikov
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsl_elbc_nand.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 0bb254c..b818264 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -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",
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 045/104] mtd: fsl_upm: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (8 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 044/104] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 046/104] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/fsl_upm.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index 7c782eb..253b8ff 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -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);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 046/104] mtd: mpc5121_nfc: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (9 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 045/104] mtd: fsl_upm: " Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 047/104] mtd: ndfc: " Dmitry Eremin-Solenikov
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/mpc5121_nfc.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index de3625b..390d1a0 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -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);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 047/104] mtd: ndfc: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (10 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 046/104] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 048/104] mtd: socrates_nand: " Dmitry Eremin-Solenikov
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/ndfc.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index cb66fd7..a041978 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -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:
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 048/104] mtd: socrates_nand: use ofpart through generic parsing
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (11 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 047/104] mtd: ndfc: " Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 049/104] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Convert the driver to use ofpart partitions parsing through the generic
parse_mtd_partitions().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/socrates_nand.c |   11 +----------
 1 files changed, 1 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index 6ed53e1..43b02b1 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -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;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 049/104] mtd: drop of_mtd_parse_partitions()
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (12 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 048/104] mtd: socrates_nand: " Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser Dmitry Eremin-Solenikov
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

All users have been converted to call of_mtd_parse_partitions through
parse_mtd_partitions() multiplexer. Drop obsolete API.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/ofpart.c           |   16 ++++------------
 include/linux/mtd/partitions.h |   16 ----------------
 2 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index ff11b85..89a91ae 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -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,
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 5fde0d8..746fc97 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -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);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (13 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 049/104] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-06  8:02   ` Artem Bityutskiy
  2011-06-02 14:51 ` [PATCH 051/104] mtd: add a flags for partitions which should just leave smth. after them Dmitry Eremin-Solenikov
                   ` (5 subsequent siblings)
  20 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Separate parse_obsolete_partitions() to external ofoldpart partitions parser.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 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

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 4be8373..2aa8afb 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -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---
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 39664c4..1de83b9 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -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
diff --git a/drivers/mtd/maps/physmap_of.c b/drivers/mtd/maps/physmap_of.c
index 312eb17..c953db3 100644
--- a/drivers/mtd/maps/physmap_of.c
+++ b/drivers/mtd/maps/physmap_of.c
@@ -40,51 +40,6 @@ struct of_flash {
 };
 
 #define OF_FLASH_PARTS(info)	((info)->parts)
-static int parse_obsolete_partitions(struct platform_device *dev,
-				     struct of_flash *info,
-				     struct device_node *dp)
-{
-	int i, plen, nr_parts;
-	const struct {
-		__be32 offset, len;
-	} *part;
-	const char *names;
-
-	part = of_get_property(dp, "partitions", &plen);
-	if (!part)
-		return 0; /* No partitions found */
-
-	dev_warn(&dev->dev, "Device tree uses obsolete partition map binding\n");
-
-	nr_parts = plen / sizeof(part[0]);
-
-	info->parts = kzalloc(nr_parts * sizeof(*info->parts), GFP_KERNEL);
-	if (!info->parts)
-		return -ENOMEM;
-
-	names = of_get_property(dp, "partition-names", &plen);
-
-	for (i = 0; i < nr_parts; i++) {
-		info->parts[i].offset = be32_to_cpu(part->offset);
-		info->parts[i].size   = be32_to_cpu(part->len) & ~1;
-		if (be32_to_cpu(part->len) & 1) /* bit 0 set signifies read only partition */
-			info->parts[i].mask_flags = MTD_WRITEABLE;
-
-		if (names && (plen > 0)) {
-			int len = strlen(names) + 1;
-
-			info->parts[i].name = (char *)names;
-			plen -= len;
-			names += len;
-		} else {
-			info->parts[i].name = "unnamed";
-		}
-
-		part++;
-	}
-
-	return nr_parts;
-}
 
 static int of_flash_remove(struct platform_device *dev)
 {
@@ -166,7 +121,7 @@ static struct mtd_info * __devinit obsolete_probe(struct platform_device *dev,
    default is use. These take precedence over other device tree
    information. */
 static const char *part_probe_types_def[] = { "cmdlinepart", "RedBoot",
-					"ofpart", NULL };
+					"ofpart", "ofoldpart", NULL };
 static const char ** __devinit of_get_probes(struct device_node *dp)
 {
 	const char *cp;
@@ -342,12 +297,6 @@ static int __devinit of_flash_probe(struct platform_device *dev)
 	}
 	of_free_probes(part_probe_types);
 
-	if (err == 0) {
-		err = parse_obsolete_partitions(dev, info, dp);
-		if (err < 0)
-			goto err_out;
-	}
-
 	mtd_device_register(info->cmtd, info->parts, err);
 
 	kfree(mtd_list);
diff --git a/drivers/mtd/ofoldpart.c b/drivers/mtd/ofoldpart.c
new file mode 100644
index 0000000..a2c143b
--- /dev/null
+++ b/drivers/mtd/ofoldpart.c
@@ -0,0 +1,89 @@
+/*
+ * Flash partitions described by the OF (or flattened) device tree
+ *
+ * Copyright © 2006 MontaVista Software Inc.
+ * Author: Vitaly Wool <vwool@ru.mvista.com>
+ *
+ * Revised to handle newer style flash binding by:
+ *   Copyright © 2007 David Gibson, IBM Corporation.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/of.h>
+#include <linux/mtd/mtd.h>
+#include <linux/slab.h>
+#include <linux/mtd/partitions.h>
+
+static int parse_ofoldpart_partitions(struct mtd_info *master,
+                             struct mtd_partition **pparts,
+                             unsigned long origin)
+{
+	struct device_node *dp;
+	int i, plen, nr_parts;
+	const struct {
+		__be32 offset, len;
+	} *part;
+	const char *names;
+
+	dp = master->node;
+	if (!dp)
+		return 0;
+
+	part = of_get_property(dp, "partitions", &plen);
+	if (!part)
+		return 0; /* No partitions found */
+
+	pr_warning("Device tree uses obsolete partition map binding: %s\n",
+			dp->full_name);
+
+	nr_parts = plen / sizeof(part[0]);
+
+	*pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
+	if (!pparts)
+		return -ENOMEM;
+
+	names = of_get_property(dp, "partition-names", &plen);
+
+	for (i = 0; i < nr_parts; i++) {
+		(*pparts)[i].offset = be32_to_cpu(part->offset);
+		(*pparts)[i].size   = be32_to_cpu(part->len) & ~1;
+		if (be32_to_cpu(part->len) & 1) /* bit 0 set signifies read only partition */
+			(*pparts)[i].mask_flags = MTD_WRITEABLE;
+
+		if (names && (plen > 0)) {
+			int len = strlen(names) + 1;
+
+			(*pparts)[i].name = (char *)names;
+			plen -= len;
+			names += len;
+		} else {
+			(*pparts)[i].name = "unnamed";
+		}
+
+		part++;
+	}
+
+	return nr_parts;
+}
+
+static struct mtd_part_parser ofoldpart_parser = {
+	.owner = THIS_MODULE,
+	.parse_fn = parse_ofoldpart_partitions,
+	.name = "ofoldpart",
+};
+
+static int __init ofoldpart_parser_init(void)
+{
+	return register_mtd_parser(&ofoldpart_parser);
+}
+
+module_init(ofoldpart_parser_init);
+
+MODULE_LICENSE("GPL");
+
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 051/104] mtd: add a flags for partitions which should just leave smth. after them
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (14 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 052/104] ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning Dmitry Eremin-Solenikov
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Add 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.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/mtdpart.c          |   11 +++++++++++
 include/linux/mtd/partitions.h |    5 ++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 0b473ec..76244a7 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -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;
 
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 746fc97..8601090 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -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)
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 052/104] ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (15 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 051/104] mtd: add a flags for partitions which should just leave smth. after them Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 053/104] mtd: plat-nand: drop unused fields from platform_nand_data Dmitry Eremin-Solenikov
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd; +Cc: Hartley Sweeten, Ryan Mallon

Instead of specifying a callback for dynamic partitioning, use
MTDPART_OFS_RETAIN for reserving a place near the end of flash for
RedBoot.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ryan Mallon <ryan@bluewatersys.com>
---
 arch/arm/mach-ep93xx/ts72xx.c |   22 ++++------------------
 1 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index c2d2cf4..68e2849 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -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,
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 053/104] mtd: plat-nand: drop unused fields from platform_nand_data
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (16 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 052/104] ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 054/104] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Drop now unused set_parts from struct platform_nand_data. Also, while we are
at it, drop long unused priv field from platform_nand_data.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/nand/plat_nand.c |    2 --
 include/linux/mtd/nand.h     |    2 --
 2 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 633c04b..1339fa8 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -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,
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index c2b9ac4..0b185ff 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -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 */
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 054/104] mtd: add new API for handling MTD registration
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (17 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 053/104] mtd: plat-nand: drop unused fields from platform_nand_data Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-02 14:51 ` [PATCH 055/104] mtd: lart.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
  2011-06-03 15:55 ` [RFC PATCH 000/104] mtd: cleanup partition parsing interface Artem Bityutskiy
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Lots (nearly all) mtd drivers contain nearly the similar code that
calls parse_mtd_partitions, provides some platform-default values, if
parsing fails, and registers  mtd device.

This is an aim to provide single implementation of this scenario:
mtd_device_parse_register() which will handle all this parsing and
defaults.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/mtdcore.c   |   40 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/mtd.h |    5 +++++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index bfd5a65..fdbfb0c 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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.
  *
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 14305d0..d8f5efe 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -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);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 055/104] mtd: lart.c: use mtd_device_parse_register
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (18 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 054/104] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
@ 2011-06-02 14:51 ` Dmitry Eremin-Solenikov
  2011-06-03 15:55 ` [RFC PATCH 000/104] mtd: cleanup partition parsing interface Artem Bityutskiy
  20 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-02 14:51 UTC (permalink / raw)
  To: linux-mtd

Replace custom invocations of parse_mtd_partitions and mtd_device_register
with common mtd_device_parse_register call. This would bring: standard
handling of all errors, fallback to default partitions, etc.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/mtd/devices/lart.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index 772a0ff..48b513f 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -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);
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [RFC PATCH 000/104] mtd: cleanup partition parsing interface
  2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
                   ` (19 preceding siblings ...)
  2011-06-02 14:51 ` [PATCH 055/104] mtd: lart.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
@ 2011-06-03 15:55 ` Artem Bityutskiy
  2011-06-04  8:25   ` Dmitry Eremin-Solenikov
  20 siblings, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-03 15:55 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> 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.

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.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [RFC PATCH 000/104] mtd: cleanup partition parsing interface
  2011-06-03 15:55 ` [RFC PATCH 000/104] mtd: cleanup partition parsing interface Artem Bityutskiy
@ 2011-06-04  8:25   ` Dmitry Eremin-Solenikov
  2011-06-06  7:04     ` Artem Bityutskiy
  0 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-04  8:25 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

On 6/3/11, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
>> 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.
>
> 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?

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [RFC PATCH 000/104] mtd: cleanup partition parsing interface
  2011-06-04  8:25   ` Dmitry Eremin-Solenikov
@ 2011-06-06  7:04     ` Artem Bityutskiy
  0 siblings, 0 replies; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  7:04 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Sat, 2011-06-04 at 12:25 +0400, Dmitry Eremin-Solenikov wrote:
> 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!

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing
  2011-06-02 14:51 ` [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing Dmitry Eremin-Solenikov
@ 2011-06-06  7:14   ` Artem Bityutskiy
  0 siblings, 0 replies; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  7:14 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> Lots of MTD devices default to cmdlinepart, NULL as partition parsing
> order. Make it a default.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  drivers/mtd/mtdpart.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 630be3e..3477e16 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -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))

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.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 007/104] mtd: m25p80 don't specify default parsing options
  2011-06-02 14:51 ` [PATCH 007/104] mtd: m25p80 don't specify default parsing options Dmitry Eremin-Solenikov
@ 2011-06-06  7:20   ` Artem Bityutskiy
  0 siblings, 0 replies; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  7:20 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> Since '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.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

Pushed to l2-mtd-2.6.git, thanks.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 040/104] mtd: drop mtd_has_cmdlinepart()
  2011-06-02 14:51 ` [PATCH 040/104] mtd: drop mtd_has_cmdlinepart() Dmitry Eremin-Solenikov
@ 2011-06-06  7:23   ` Artem Bityutskiy
  0 siblings, 0 replies; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  7:23 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> This function is unused now. Drop it.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

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.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-02 14:51 ` [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
@ 2011-06-06  7:57   ` Artem Bityutskiy
  2011-06-06  8:15     ` Dmitry Eremin-Solenikov
  2011-06-06  8:05   ` Artem Bityutskiy
  1 sibling, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  7:57 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> 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) 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
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

Good idea, but 

>  #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

Could all the OF-specific things be done in the ofpart.c ?

> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -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?

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
  2011-06-02 14:51 ` [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser Dmitry Eremin-Solenikov
@ 2011-06-06  8:02   ` Artem Bityutskiy
  2011-06-06  8:09     ` Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  8:02 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> Separate parse_obsolete_partitions() to external ofoldpart partitions parser.
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
>  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
> 
> diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> index 4be8373..2aa8afb 100644
> --- a/drivers/mtd/Kconfig
> +++ b/drivers/mtd/Kconfig
> @@ -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.

I think this tiny piece of code does not deserve to be a separate
module...

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-02 14:51 ` [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
  2011-06-06  7:57   ` Artem Bityutskiy
@ 2011-06-06  8:05   ` Artem Bityutskiy
  2011-06-06  9:21     ` Dmitry Eremin-Solenikov
  1 sibling, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  8:05 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
> 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) 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
> 
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

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.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
  2011-06-06  8:02   ` Artem Bityutskiy
@ 2011-06-06  8:09     ` Dmitry Eremin-Solenikov
  2011-06-06  8:11       ` Artem Bityutskiy
  0 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-06  8:09 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

On 06.06.2011 12:02, Artem Bityutskiy wrote:
> On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
>> Separate parse_obsolete_partitions() to external ofoldpart partitions parser.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
>> ---
>>   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
>>
>> diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
>> index 4be8373..2aa8afb 100644
>> --- a/drivers/mtd/Kconfig
>> +++ b/drivers/mtd/Kconfig
>> @@ -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.
>
> 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.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
  2011-06-06  8:09     ` Dmitry Eremin-Solenikov
@ 2011-06-06  8:11       ` Artem Bityutskiy
  2011-06-06  8:13         ` Artem Bityutskiy
  0 siblings, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  8:11 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Mon, 2011-06-06 at 12:09 +0400, Dmitry Eremin-Solenikov wrote:
> 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. 

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.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
  2011-06-06  8:11       ` Artem Bityutskiy
@ 2011-06-06  8:13         ` Artem Bityutskiy
  2011-06-06  8:24           ` Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  8:13 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Mon, 2011-06-06 at 11:11 +0300, Artem Bityutskiy wrote:
> 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, 

Or rather s/phusmap_of/ofpart/

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-06  7:57   ` Artem Bityutskiy
@ 2011-06-06  8:15     ` Dmitry Eremin-Solenikov
  2011-06-06  8:19       ` Artem Bityutskiy
  0 siblings, 1 reply; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-06  8:15 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

On 06.06.2011 11:57, Artem Bityutskiy wrote:
> On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
>> 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) 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
>>
>> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
>
> Good idea, but
>
>>   #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
>
> 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.

>> --- a/include/linux/mtd/mtd.h
>> +++ b/include/linux/mtd/mtd.h
>> @@ -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?
>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-06  8:15     ` Dmitry Eremin-Solenikov
@ 2011-06-06  8:19       ` Artem Bityutskiy
  2011-06-06 10:10         ` Dmitry Eremin-Solenikov
  0 siblings, 1 reply; 38+ messages in thread
From: Artem Bityutskiy @ 2011-06-06  8:19 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linux-mtd

On Mon, 2011-06-06 at 12:15 +0400, Dmitry Eremin-Solenikov wrote:
> 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().

> It can be used by ofpart.c, ofoldpart.c (extract from physmap_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.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser
  2011-06-06  8:13         ` Artem Bityutskiy
@ 2011-06-06  8:24           ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-06  8:24 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

On 06.06.2011 12:13, Artem Bityutskiy wrote:
> On Mon, 2011-06-06 at 11:11 +0300, Artem Bityutskiy wrote:
>> 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,
>
> 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.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-06  8:05   ` Artem Bityutskiy
@ 2011-06-06  9:21     ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-06  9:21 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

On 06.06.2011 12:05, Artem Bityutskiy wrote:
> On Thu, 2011-06-02 at 18:51 +0400, Dmitry Eremin-Solenikov wrote:
>> 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) 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
>>
>> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
>
> 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.

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser
  2011-06-06  8:19       ` Artem Bityutskiy
@ 2011-06-06 10:10         ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 38+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-06-06 10:10 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd

On 06.06.2011 12:19, Artem Bityutskiy wrote:
> On Mon, 2011-06-06 at 12:15 +0400, Dmitry Eremin-Solenikov wrote:
>> 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().

That will be agains current linux coding practices. E.g. check the gpio, 
i2c, etc. code. All add device_node field to existing structs.

>> It can be used by ofpart.c, ofoldpart.c (extract from physmap_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.

Agreed.


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2011-06-06 10:10 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-02 14:51 [RFC PATCH 000/104] mtd: cleanup partition parsing interface Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 004/104] mtd: drop physmap_configure Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 005/104] mtd: cafe_nand: drop reference to CONFIG_MTD_CMDLINE_PARTS Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 006/104] mtdpart: default to cmdlinepart, NULL partitions probing Dmitry Eremin-Solenikov
2011-06-06  7:14   ` Artem Bityutskiy
2011-06-02 14:51 ` [PATCH 007/104] mtd: m25p80 don't specify default parsing options Dmitry Eremin-Solenikov
2011-06-06  7:20   ` Artem Bityutskiy
2011-06-02 14:51 ` [PATCH 040/104] mtd: drop mtd_has_cmdlinepart() Dmitry Eremin-Solenikov
2011-06-06  7:23   ` Artem Bityutskiy
2011-06-02 14:51 ` [PATCH 041/104] mtd: prepare to convert of_mtd_parse_partitions to partition parser Dmitry Eremin-Solenikov
2011-06-06  7:57   ` Artem Bityutskiy
2011-06-06  8:15     ` Dmitry Eremin-Solenikov
2011-06-06  8:19       ` Artem Bityutskiy
2011-06-06 10:10         ` Dmitry Eremin-Solenikov
2011-06-06  8:05   ` Artem Bityutskiy
2011-06-06  9:21     ` Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 042/104] mtd: m25p80: use ofpart through generic parsing Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 043/104] mtd: physmap_of: " Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 044/104] mtd: fsl_elbc_nand: " Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 045/104] mtd: fsl_upm: " Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 046/104] mtd: mpc5121_nfc: " Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 047/104] mtd: ndfc: " Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 048/104] mtd: socrates_nand: " Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 049/104] mtd: drop of_mtd_parse_partitions() Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 050/104] physmap_of: separate parse_obsolete_partitions to separate parser Dmitry Eremin-Solenikov
2011-06-06  8:02   ` Artem Bityutskiy
2011-06-06  8:09     ` Dmitry Eremin-Solenikov
2011-06-06  8:11       ` Artem Bityutskiy
2011-06-06  8:13         ` Artem Bityutskiy
2011-06-06  8:24           ` Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 051/104] mtd: add a flags for partitions which should just leave smth. after them Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 052/104] ts72xx: use MTDPART_OFS_RETAIN for mtd partitioning Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 053/104] mtd: plat-nand: drop unused fields from platform_nand_data Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 054/104] mtd: add new API for handling MTD registration Dmitry Eremin-Solenikov
2011-06-02 14:51 ` [PATCH 055/104] mtd: lart.c: use mtd_device_parse_register Dmitry Eremin-Solenikov
2011-06-03 15:55 ` [RFC PATCH 000/104] mtd: cleanup partition parsing interface Artem Bityutskiy
2011-06-04  8:25   ` Dmitry Eremin-Solenikov
2011-06-06  7:04     ` Artem Bityutskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.