Skip to contentSkip to conversation

Fix mtd parent device not showing up in sysfs

PATCH In review Frans Klaver 2 participants 65 messages Jun 10, 2015 – Oct 13, 2015

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix mtd parent device not showing up in sysfs

Here's the second iteration of a series stemming from a previous discussion about mtd devices not showing up in sysfs properly[1]. While the original series 27 patches, this one should cover all drivers that suffer from this issue, and shamelessly hits 60. Again, if it's preferred that the patches are grouped differently, like by mtd subdir, I'd be happy to resend. Until then, we'll make do with this.

This series teaches add_mtd_device() to set name and owner based on the set parent device, if dev.parent is filled in, and name resp. owner isn't already filled in. All drivers that I could find that don't set the parent are touched to set the parent device, and remove the name and owner assignment in cases where I'm sure the resulting name will not change. Only the latter is done in cases where I would find the driver explicitly filling in the owner.

Thanks for having a go at your favorite MTD,
Frans

v1..v2
- Overall: make it more clear that it's about a parent device symlink gone missing (thanks, Brian)
- Fix compile error in 30: "fsmc_nand: show parent device in sysfs"
- Fix possible null-pointer dereference in 02: "mtd: core: set some

    defaults..."

[1] https://lkml.org/lkml/2014/5/26/586

Frans Klaver (60):
mtd: core: tone down suggestion that dev.parent should be set
mtd: core: set some defaults when dev.parent is set
mtd: devices: bcm47xxflash: show parent device in sysfs
mtd: devices: docg3: show parent device in sysfs
mtd: devices: m25p80: show parent device in sysfs
mtd: devices: mtd_dataflash: drop owner assignment
mtd: devices: spear_smi: show parent device in sysfs
mtd: devices: sst251: show parent device in sysfs
mtd: lpddr: show parent device in sysfs
mtd: maps: bfin-async-flash: show parent device in sysfs
mtd: maps: gpio-addr-flash: show parent device in sysfs
mtd: maps: intel_vr_nor: show parent device in sysfs
mtd: maps: ixp4xx: show parent device in sysfs
mtd: maps: lantiq-flash: show parent device in sysfs
mtd: maps: latch-addr-flash: show parent device in sysfs
mtd: maps: physmap: drop owner assignment
mtd: maps: physmap_of: drop owner assignment
mtd: maps: plat_ram: drop owner assignment
mtd: maps: pxa2xx-flash: show parent device in sysfs
mtd: maps: rbtx4939-flash: show parent device in sysfs
mtd: maps: sa1100-flash: show parent device in sysfs
mtd: nand: atmel_nand: show parent device in sysfs
mtd: nand: au1550nd: show parent device in sysfs
mtd: nand: bcm47xxnflash: show parent device in sysfs
mtd: nand: bf5xx_nand: show parent device in sysfs
mtd: nand: cafe_nand: drop owner assignment
mtd: nand: davinci_nand: drop owner and name assignment
mtd: nand: denali: drop owner assignment
mtd: nand: docg4: show parent device in sysfs
mtd: nand: fsl_elbc_nand: show parent device in sysfs
mtd: nand: fsl_ifc_nand: show parent device in sysfs
mtd: nand: fsl_upm: show parent device in sysfs
mtd: nand: fsmc_nand: show parent device in sysfs
mtd: nand: gpio: show parent device in sysfs
mtd: nand: gpmi-nand: show parent device in sysfs
mtd: nand: hisi504_nand: drop owner assignment
mtd: nand: jz4740_nand: show parent device in sysfs
mtd: nand: lpc32xx_mlc: drop owner assignment
mtd: nand: mpc5121_nfc: show parent device in sysfs
mtd: nand: mxc_nand: drop owner assignment
mtd: nand: ndfc: show parent device in sysfs
mtd: nand: nuc900_nand: show parent device in sysfs
mtd: nand: omap2: show parent device structure in sysfs
mtd: nand: orion_nand: show parent device in sysfs
mtd: nand: pasemi_nand: show parent device in sysfs
mtd: nand: plat_nand: show parent device in sysfs
mtd: nand: pxa3xx_nand: show parent device in sysfs
mtd: nand: r852: drop owner assignment
mtd: nand: s3c2410: show parent device in sysfs
mtd: nand: sh_flctl: show parent device in sysfs
mtd: nand: sharpsl: show parent device in sysfs
mtd: nand: socrates_nand: drop owner assignment
mtd: nand: sunxi_nand: drop owner assignment
mtd: nand: tmio_nand: show parent device in sysfs
mtd: nand: txx9ndfmc: show parent device in sysfs
mtd: onenand: generic: show parent device in sysfs
mtd: onenand: omap2: drop owner and name assignment
mtd: onenand: samsung: drop owner assignment
mtd: spi-nor: fsl-quadspi: show parent device in sysfs
staging: mt29f_spinand: show parent device in sysfs

 drivers/mtd/devices/bcm47xxsflash.c           |  7 ++++---
 drivers/mtd/devices/docg3.c                   |  2 +-
 drivers/mtd/devices/m25p80.c                  |  1 +
 drivers/mtd/devices/mtd_dataflash.c           |  1 -
 drivers/mtd/devices/spear_smi.c               |  1 +
 drivers/mtd/devices/sst25l.c                  |  3 +--
 drivers/mtd/lpddr/lpddr2_nvm.c                |  1 +
 drivers/mtd/maps/bfin-async-flash.c           |  1 +
 drivers/mtd/maps/gpio-addr-flash.c            |  2 +-
 drivers/mtd/maps/intel_vr_nor.c               |  2 +-
 drivers/mtd/maps/ixp4xx.c                     |  2 +-
 drivers/mtd/maps/lantiq-flash.c               |  2 +-
 drivers/mtd/maps/latch-addr-flash.c           |  2 +-
 drivers/mtd/maps/physmap.c                    |  1 -
 drivers/mtd/maps/physmap_of.c                 |  1 -
 drivers/mtd/maps/plat-ram.c                   |  1 -
 drivers/mtd/maps/pxa2xx-flash.c               |  2 +-
 drivers/mtd/maps/rbtx4939-flash.c             |  2 +-
 drivers/mtd/maps/sa1100-flash.c               |  2 +-
 drivers/mtd/mtdcore.c                         | 11 ++++++++++-
 drivers/mtd/nand/atmel_nand.c                 |  2 +-
 drivers/mtd/nand/au1550nd.c                   |  2 +-
 drivers/mtd/nand/bcm47xxnflash/main.c         |  2 +-
 drivers/mtd/nand/bf5xx_nand.c                 |  2 +-
 drivers/mtd/nand/cafe_nand.c                  |  1 -
 drivers/mtd/nand/davinci_nand.c               |  3 ---
 drivers/mtd/nand/denali.c                     |  1 -
 drivers/mtd/nand/docg4.c                      |  2 +-
 drivers/mtd/nand/fsl_elbc_nand.c              |  2 +-
 drivers/mtd/nand/fsl_ifc_nand.c               |  2 +-
 drivers/mtd/nand/fsl_upm.c                    |  2 +-
 drivers/mtd/nand/fsmc_nand.c                  |  2 +-
 drivers/mtd/nand/gpio.c                       |  2 +-
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c        |  2 +-
 drivers/mtd/nand/hisi504_nand.c               |  1 -
 drivers/mtd/nand/jz4740_nand.c                |  2 +-
 drivers/mtd/nand/lpc32xx_mlc.c                |  1 -
 drivers/mtd/nand/mpc5121_nfc.c                |  1 +
 drivers/mtd/nand/mxc_nand.c                   |  1 -
 drivers/mtd/nand/ndfc.c                       |  2 +-
 drivers/mtd/nand/nuc900_nand.c                |  2 +-
 drivers/mtd/nand/omap2.c                      |  3 +--
 drivers/mtd/nand/orion_nand.c                 |  2 +-
 drivers/mtd/nand/pasemi_nand.c                |  2 +-
 drivers/mtd/nand/plat_nand.c                  |  3 +--
 drivers/mtd/nand/pxa3xx_nand.c                |  2 +-
 drivers/mtd/nand/r852.c                       |  1 -
 drivers/mtd/nand/s3c2410.c                    |  2 +-
 drivers/mtd/nand/sh_flctl.c                   |  1 +
 drivers/mtd/nand/sharpsl.c                    |  2 +-
 drivers/mtd/nand/socrates_nand.c              |  1 -
 drivers/mtd/nand/sunxi_nand.c                 |  1 -
 drivers/mtd/nand/tmio_nand.c                  |  1 +
 drivers/mtd/nand/txx9ndfmc.c                  |  2 +-
 drivers/mtd/onenand/generic.c                 |  3 +--
 drivers/mtd/onenand/omap2.c                   |  2 --
 drivers/mtd/onenand/samsung.c                 |  1 -
 drivers/mtd/spi-nor/fsl-quadspi.c             |  1 +
 drivers/staging/mt29f_spinand/mt29f_spinand.c |  3 +--
 59 files changed, 56 insertions(+), 61 deletions(-)
Signature · 1 line
2.4.0
#1 lore raw

PATCH v2 1/60 mtd: core: tone down suggestion that dev.parent should be set

add_mtd_device() has a comment suggesting that the caller should have set dev.parent. This is required to have the parent device symlink show up in sysfs, but not for proper operation of the mtd device itself. Currently we have five drivers registering mtd devices during module initialization, so they don't actually provide a parent device to link to. That means we cannot WARN_ON() here, as it would trigger false positives.

Make the comment a bit less firm in its assertion that dev.parent should be set.

---
 drivers/mtd/mtdcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdcore.c +1 -1
index d172195..d7967cc 100644
@@ -423,7 +423,7 @@ int add_mtd_device(struct mtd_info *mtd)
 	}
 
 	/* Caller should have set dev.parent to match the
-	 * physical device.
+	 * physical device, if appropriate.
 	 */
 	mtd->dev.type = &mtd_devtype;
 	mtd->dev.class = &mtd_class;
Signature · 1 line
2.4.0
#5 lore raw

PATCH v2 5/60 mtd: devices: m25p80: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/devices/m25p80.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/devices/m25p80.c +1 -0
index 3af137f..dfa6ee0 100644
@@ -206,6 +206,7 @@ static int m25p_probe(struct spi_device *spi)
 
 	spi_set_drvdata(spi, flash);
 	flash->mtd.priv = nor;
+	flash->mtd.dev.parent = &spi->dev;
 	flash->spi = spi;
 
 	if (spi->mode & SPI_RX_QUAD)
Signature · 1 line
2.4.0
#11 lore raw

PATCH v2 9/60 mtd: lpddr: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/lpddr/lpddr2_nvm.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/lpddr/lpddr2_nvm.c +1 -0
index 063cec4..2342277 100644
@@ -460,6 +460,7 @@ static int lpddr2_nvm_probe(struct platform_device *pdev)
 
 	/* Populate mtd_info data structure */
 	*mtd = (struct mtd_info) {
+		.dev		= { .parent = &pdev->dev },
 		.name		= pdev->dev.init_name,
 		.type		= MTD_RAM,
 		.priv		= map,
Signature · 1 line
2.4.0
#2 lore raw

PATCH v2 2/60 mtd: core: set some defaults when dev.parent is set

In reply to Frans Klaver

If a parent device is set, add_mtd_device() has enough knowledge to fill in some sane default values for the module name and owner. Do so if they aren't already set.

---
v1..v2
- Apparently we can get here without a driver set, causing a NULL dereference[0]. Check that a driver is there before copying the owner. It does mean that parent devices that don't seem to be having a driver lying around still can't produce an owner. I suppose the effect is not much different from it was before.
- Change wording of debug message to mention the fact we're talking about parent device symlinks here.

[0] https://lkml.org/lkml/2015/4/16/15

---
 drivers/mtd/mtdcore.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/mtdcore.c +9 -0
index d7967cc..0bd1761 100644
@@ -413,6 +413,15 @@ int add_mtd_device(struct mtd_info *mtd)
 	mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1;
 	mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
 
+	if (mtd->dev.parent) {
+		if (!mtd->owner && mtd->dev.parent->driver)
+			mtd->owner = mtd->dev.parent->driver->owner;
+		if (!mtd->name)
+			mtd->name = dev_name(mtd->dev.parent);
+	} else {
+		pr_debug("mtd device won't show a device symlink in sysfs\n");
+	}
+
 	/* Some chips always power up locked. Unlock them now */
 	if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) {
 		error = mtd_unlock(mtd, 0, mtd->size);
Signature · 1 line
2.4.0
#3 lore raw

PATCH v2 3/60 mtd: devices: bcm47xxflash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/devices/bcm47xxsflash.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mtd/devices/bcm47xxsflash.c +4 -3
index 3d008a9..347bb83 100644
@@ -237,13 +237,14 @@ static int bcm47xxsflash_write(struct mtd_info *mtd, loff_t to, size_t len,
 	return 0;
 }
 
-static void bcm47xxsflash_fill_mtd(struct bcm47xxsflash *b47s)
+static void bcm47xxsflash_fill_mtd(struct bcm47xxsflash *b47s,
+				   struct device *dev)
 {
 	struct mtd_info *mtd = &b47s->mtd;
 
 	mtd->priv = b47s;
+	mtd->dev.parent = dev;
 	mtd->name = "bcm47xxsflash";
-	mtd->owner = THIS_MODULE;
 
 	mtd->type = MTD_NORFLASH;
 	mtd->flags = MTD_CAP_NORFLASH;
@@ -300,7 +301,7 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
 	b47s->blocksize = sflash->blocksize;
 	b47s->numblocks = sflash->numblocks;
 	b47s->size = sflash->size;
-	bcm47xxsflash_fill_mtd(b47s);
+	bcm47xxsflash_fill_mtd(b47s, &pdev->dev);
 
 	err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
 	if (err) {
Signature · 1 line
2.4.0
#15 lore raw

PATCH v2 13/60 mtd: maps: ixp4xx: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/maps/ixp4xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/ixp4xx.c +1 -1
index b443074..e3180d5 100644
@@ -226,7 +226,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
 		err = -ENXIO;
 		goto Error;
 	}
-	info->mtd->owner = THIS_MODULE;
+	info->mtd->dev.parent = &dev->dev;
 
 	/* Use the fast version */
 	info->map.write = ixp4xx_write16;
Signature · 1 line
2.4.0
#9 lore raw

PATCH v2 7/60 mtd: devices: spear_smi: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/devices/spear_smi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/devices/spear_smi.c +1 -0
index 508bab3..015a1cf 100644
@@ -854,6 +854,7 @@ static int spear_smi_setup_banks(struct platform_device *pdev,
 	else
 		flash->mtd.name = flash_devices[flash_index].name;
 
+	flash->mtd.dev.parent = &pdev->dev;
 	flash->mtd.type = MTD_NORFLASH;
 	flash->mtd.writesize = 1;
 	flash->mtd.flags = MTD_CAP_NORFLASH;
Signature · 1 line
2.4.0
#4 lore raw

PATCH v2 4/60 mtd: devices: docg3: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/devices/docg3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/devices/docg3.c +1 -1
index 866d319..7697c58 100644
@@ -1841,7 +1841,6 @@ static void __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
 		mtd->erasesize /= 2;
 	mtd->writebufsize = mtd->writesize = DOC_LAYOUT_PAGE_SIZE;
 	mtd->oobsize = DOC_LAYOUT_OOB_SIZE;
-	mtd->owner = THIS_MODULE;
 	mtd->_erase = doc_erase;
 	mtd->_read = doc_read;
 	mtd->_write = doc_write;
@@ -1881,6 +1880,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev)
 	if (!mtd)
 		goto nomem2;
 	mtd->priv = docg3;
+	mtd->dev.parent = dev;
 	bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1,
 				   8 * DOC_LAYOUT_PAGE_SIZE);
 	docg3->bbt = kzalloc(bbt_nbpages * DOC_LAYOUT_PAGE_SIZE, GFP_KERNEL);
Signature · 1 line
2.4.0
#24 lore raw

PATCH v2 22/60 mtd: nand: atmel_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/atmel_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/atmel_nand.c +1 -1
index 46010bd..8989473 100644
@@ -2126,7 +2126,7 @@ static int atmel_nand_probe(struct platform_device *pdev)
 
 	nand_chip->priv = host;		/* link the private data structures */
 	mtd->priv = nand_chip;
-	mtd->owner = THIS_MODULE;
+	mtd->dev.parent = &pdev->dev;
 
 	/* Set address of NAND IO lines */
 	nand_chip->IO_ADDR_R = host->io_base;
Signature · 1 line
2.4.0
#12 lore raw

PATCH v2 10/60 mtd: maps: bfin-async-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/maps/bfin-async-flash.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/maps/bfin-async-flash.c +1 -0
index 41730fe..d10356c 100644
@@ -163,6 +163,7 @@ static int bfin_flash_probe(struct platform_device *pdev)
 		kfree(state);
 		return -ENXIO;
 	}
+	state->mtd.dev.parent = &pdev->dev;
 
 	mtd_device_parse_register(state->mtd, part_probe_types, NULL,
 				  pdata->parts, pdata->nr_parts);
Signature · 1 line
2.4.0
#8 lore raw

PATCH v2 6/60 mtd: devices: mtd_dataflash: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/devices/mtd_dataflash.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/devices/mtd_dataflash.c +0 -1
index 0099aba..ca5ae8e 100644
@@ -647,7 +647,6 @@ static int add_dataflash_otp(struct spi_device *spi, char *name, int nr_pages,
 	device->size = nr_pages * pagesize;
 	device->erasesize = pagesize;
 	device->writesize = pagesize;
-	device->owner = THIS_MODULE;
 	device->type = MTD_DATAFLASH;
 	device->flags = MTD_WRITEABLE;
 	device->_erase = dataflash_erase;
Signature · 1 line
2.4.0
#10 lore raw

PATCH v2 8/60 mtd: devices: sst251: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/devices/sst25l.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/devices/sst25l.c +1 -2
index c63ecbc..3928014 100644
@@ -374,9 +374,8 @@ static int sst25l_probe(struct spi_device *spi)
 	data = dev_get_platdata(&spi->dev);
 	if (data && data->name)
 		flash->mtd.name = data->name;
-	else
-		flash->mtd.name = dev_name(&spi->dev);
 
+	flash->mtd.dev.parent   = &spi->dev;
 	flash->mtd.type		= MTD_NORFLASH;
 	flash->mtd.flags	= MTD_CAP_NORFLASH;
 	flash->mtd.erasesize	= flash_info->erase_size;
Signature · 1 line
2.4.0
#16 lore raw

PATCH v2 14/60 mtd: maps: lantiq-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/maps/lantiq-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/lantiq-flash.c +1 -1
index 33d26f5..0cef3ba 100644
@@ -161,7 +161,7 @@ ltq_mtd_probe(struct platform_device *pdev)
 		return -ENXIO;
 	}
 
-	ltq_mtd->mtd->owner = THIS_MODULE;
+	ltq_mtd->mtd->dev.parent = &pdev->dev;
 
 	cfi = ltq_mtd->map->fldrv_priv;
 	cfi->addr_unlock1 ^= 1;
Signature · 1 line
2.4.0
#23 lore raw

PATCH v2 21/60 mtd: maps: sa1100-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore. Incidentally, it seems the owner field in the concatenated mtds is not actually used, so this shouldn't make much of a difference anyway.

---
 drivers/mtd/maps/sa1100-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/sa1100-flash.c +1 -1
index 892ad6a..142fc3d 100644
@@ -117,7 +117,6 @@ static int sa1100_probe_subdev(struct sa_subdev_info *subdev, struct resource *r
 		ret = -ENXIO;
 		goto err;
 	}
-	subdev->mtd->owner = THIS_MODULE;
 
 	printk(KERN_INFO "SA1100 flash: CFI device at 0x%08lx, %uMiB, %d-bit\n",
 		phys, (unsigned)(subdev->mtd->size >> 20),
@@ -234,6 +233,7 @@ static struct sa_info *sa1100_setup_mtd(struct platform_device *pdev,
 		if (info->mtd == NULL)
 			ret = -ENXIO;
 	}
+	info->mtd->dev.parent = &pdev->dev;
 
 	if (ret == 0)
 		return info;
Signature · 1 line
2.4.0
#13 lore raw

PATCH v2 11/60 mtd: maps: gpio-addr-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/maps/gpio-addr-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/gpio-addr-flash.c +1 -1
index 2fb3460..385305e 100644
@@ -266,7 +266,7 @@ static int gpio_flash_probe(struct platform_device *pdev)
 		kfree(state);
 		return -ENXIO;
 	}
-
+	state->mtd->dev.parent = &pdev->dev;
 
 	mtd_device_parse_register(state->mtd, part_probe_types, NULL,
 				  pdata->parts, pdata->nr_parts);
Signature · 1 line
2.4.0
#14 lore raw

PATCH v2 12/60 mtd: maps: intel_vr_nor: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/maps/intel_vr_nor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/intel_vr_nor.c +1 -1
index 5ab71f0..8bf7977 100644
@@ -90,7 +90,7 @@ static int vr_nor_mtd_setup(struct vr_nor_mtd *p)
 	if (!p->info)
 		return -ENODEV;
 
-	p->info->owner = THIS_MODULE;
+	p->info->dev.parent = &p->dev->dev;
 
 	return 0;
 }
Signature · 1 line
2.4.0
#17 lore raw

PATCH v2 15/60 mtd: maps: latch-addr-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/maps/latch-addr-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/latch-addr-flash.c +1 -1
index cadfbe0..6dc97aa 100644
@@ -195,7 +195,7 @@ static int latch_addr_flash_probe(struct platform_device *dev)
 		err = -ENODEV;
 		goto iounmap;
 	}
-	info->mtd->owner = THIS_MODULE;
+	info->mtd->dev.parent = &dev->dev;
 
 	mtd_device_parse_register(info->mtd, NULL, NULL,
 				  latch_addr_data->parts,
Signature · 1 line
2.4.0
#22 lore raw

PATCH v2 20/60 mtd: maps: rbtx4939-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/maps/rbtx4939-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/rbtx4939-flash.c +1 -1
index 5a7551a..18ee3614 100644
@@ -96,7 +96,7 @@ static int rbtx4939_flash_probe(struct platform_device *dev)
 		err = -ENXIO;
 		goto err_out;
 	}
-	info->mtd->owner = THIS_MODULE;
+	info->mtd.dev.parent = &dev->dev;
 	err = mtd_device_parse_register(info->mtd, NULL, NULL, pdata->parts,
 					pdata->nr_parts);
 
Signature · 1 line
2.4.0
#18 lore raw

PATCH v2 16/60 mtd: maps: physmap: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/maps/physmap.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/maps/physmap.c +0 -1
index 4305fd6..cc2adbb 100644
@@ -167,7 +167,6 @@ static int physmap_flash_probe(struct platform_device *dev)
 		} else {
 			devices_found++;
 		}
-		info->mtd[i]->owner = THIS_MODULE;
 		info->mtd[i]->dev.parent = &dev->dev;
 	}
 
Signature · 1 line
2.4.0
#19 lore raw

PATCH v2 17/60 mtd: maps: physmap_of: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/maps/physmap_of.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/maps/physmap_of.c +0 -1
index ff26e97..10954f7 100644
@@ -288,7 +288,6 @@ static int of_flash_probe(struct platform_device *dev)
 		} else {
 			info->list_size++;
 		}
-		info->list[i].mtd->owner = THIS_MODULE;
 		info->list[i].mtd->dev.parent = &dev->dev;
 	}
 
Signature · 1 line
2.4.0
#27 lore raw

PATCH v2 25/60 mtd: nand: bf5xx_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/bf5xx_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/bf5xx_nand.c +1 -1
index 4d8d4ba..acec344 100644
@@ -782,7 +782,7 @@ static int bf5xx_nand_probe(struct platform_device *pdev)
 	/* initialise mtd info data struct */
 	mtd 		= &info->mtd;
 	mtd->priv	= chip;
-	mtd->owner	= THIS_MODULE;
+	mtd->dev.parent = &pdev->dev;
 
 	/* initialise the hardware */
 	err = bf5xx_nand_hw_init(info);
Signature · 1 line
2.4.0
#20 lore raw

PATCH v2 18/60 mtd: maps: plat_ram: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/maps/plat-ram.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/maps/plat-ram.c +0 -1
index 4b65c08..5157289 100644
@@ -210,7 +210,6 @@ static int platram_probe(struct platform_device *pdev)
 		goto exit_free;
 	}
 
-	info->mtd->owner = THIS_MODULE;
 	info->mtd->dev.parent = &pdev->dev;
 
 	platram_setrw(info, PLATRAM_RW);
Signature · 1 line
2.4.0
#21 lore raw

PATCH v2 19/60 mtd: maps: pxa2xx-flash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/maps/pxa2xx-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/pxa2xx-flash.c +1 -1
index 12fa75d..9adc4ef 100644
@@ -93,7 +93,7 @@ static int pxa2xx_flash_probe(struct platform_device *pdev)
 			iounmap(info->map.cached);
 		return -EIO;
 	}
-	info->mtd->owner = THIS_MODULE;
+	info->mtd->dev.parent = &pdev->dev;
 
 	mtd_device_parse_register(info->mtd, probes, NULL, flash->parts,
 				  flash->nr_parts);
Signature · 1 line
2.4.0
#25 lore raw

PATCH v2 23/60 mtd: nand: au1550nd: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/au1550nd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/au1550nd.c +1 -1
index c0c3be1..08a130f 100644
@@ -439,7 +439,7 @@ static int au1550nd_probe(struct platform_device *pdev)
 
 	this = &ctx->chip;
 	ctx->info.priv = this;
-	ctx->info.owner = THIS_MODULE;
+	ctx->info.dev.parent = &pdev->dev;
 
 	/* figure out which CS# r->start belongs to */
 	cs = find_nand_cs(r->start);
Signature · 1 line
2.4.0
#31 lore raw

PATCH v2 29/60 mtd: nand: docg4: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/docg4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/docg4.c +1 -1
index e5d7bca..510c12d 100644
@@ -1316,7 +1316,7 @@ static int __init probe_docg4(struct platform_device *pdev)
 	doc = (struct docg4_priv *) (nand + 1);
 	mtd->priv = nand;
 	nand->priv = doc;
-	mtd->owner = THIS_MODULE;
+	mtd->dev.parent = &pdev->dev;
 	doc->virtadr = virtadr;
 	doc->dev = dev;
 
Signature · 1 line
2.4.0
#26 lore raw

PATCH v2 24/60 mtd: nand: bcm47xxnflash: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/bcm47xxnflash/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/bcm47xxnflash/main.c +1 -1
index 461577c..9ba0c0f 100644
@@ -34,7 +34,7 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	b47n->nand_chip.priv = b47n;
-	b47n->mtd.owner = THIS_MODULE;
+	b47n->mtd.dev.parent = &pdev->dev;
 	b47n->mtd.priv = &b47n->nand_chip; /* Required */
 	b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash);
 
Signature · 1 line
2.4.0
#32 lore raw

PATCH v2 30/60 mtd: nand: fsl_elbc_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

--
v1..v2
- fix build error

---
 drivers/mtd/nand/fsl_elbc_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/fsl_elbc_nand.c +1 -1
index 04b22fd..d50c345 100644
@@ -747,7 +747,7 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
 
 	/* Fill in fsl_elbc_mtd structure */
 	priv->mtd.priv = chip;
-	priv->mtd.owner = THIS_MODULE;
+	priv->mtd.dev.parent = priv->dev;
 
 	/* set timeout to maximum */
 	priv->fmr = 15 << FMR_CWTO_SHIFT;
Signature · 1 line
2.4.0
#28 lore raw

PATCH v2 26/60 mtd: nand: cafe_nand: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/cafe_nand.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/cafe_nand.c +0 -1
index 9a0f45f..aa1dc55 100644
@@ -604,7 +604,6 @@ static int cafe_nand_probe(struct pci_dev *pdev,
 
 	mtd->dev.parent = &pdev->dev;
 	mtd->priv = cafe;
-	mtd->owner = THIS_MODULE;
 
 	cafe->pdev = pdev;
 	cafe->mmio = pci_iomap(pdev, 0, 0);
Signature · 1 line
2.4.0
#29 lore raw

PATCH v2 27/60 mtd: nand: davinci_nand: drop owner and name assignment

In reply to Frans Klaver

Owner and name are automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/davinci_nand.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/mtd/nand/davinci_nand.c +0 -3
index feb6d18..78e0c4d 100644
@@ -657,9 +657,6 @@ static int nand_davinci_probe(struct platform_device *pdev)
 	info->vaddr		= vaddr;
 
 	info->mtd.priv		= &info->chip;
-	info->mtd.name		= dev_name(&pdev->dev);
-	info->mtd.owner		= THIS_MODULE;
-
 	info->mtd.dev.parent	= &pdev->dev;
 
 	info->chip.IO_ADDR_R	= vaddr;
Signature · 1 line
2.4.0
#34 lore raw

PATCH v2 32/60 mtd: nand: fsl_upm: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner set by mtdcore.

---
 drivers/mtd/nand/fsl_upm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/fsl_upm.c +1 -1
index 72755d7..d326369 100644
@@ -176,7 +176,7 @@ static int fun_chip_init(struct fsl_upm_nand *fun,
 		fun->chip.dev_ready = fun_chip_ready;
 
 	fun->mtd.priv = &fun->chip;
-	fun->mtd.owner = THIS_MODULE;
+	fun->mtd.dev.parent = fun->dev;
 
 	flash_np = of_get_next_child(upm_np, NULL);
 	if (!flash_np)
Signature · 1 line
2.4.0
#33 lore raw

PATCH v2 31/60 mtd: nand: fsl_ifc_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner set by mtdcore.

---
 drivers/mtd/nand/fsl_ifc_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/fsl_ifc_nand.c +1 -1
index 51394e5..c2a78fa 100644
@@ -880,7 +880,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
 
 	/* Fill in fsl_ifc_mtd structure */
 	priv->mtd.priv = chip;
-	priv->mtd.owner = THIS_MODULE;
+	priv->mtd.dev.parent = priv->dev;
 
 	/* fill in nand_chip structure */
 	/* set up function call table */
Signature · 1 line
2.4.0
#30 lore raw

PATCH v2 28/60 mtd: nand: denali: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/denali.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/denali.c +0 -1
index 870c7fc..84ee0fe 100644
@@ -1454,7 +1454,6 @@ int denali_init(struct denali_nand_info *denali)
 	/* now that our ISR is registered, we can enable interrupts */
 	denali_set_intr_modes(denali, true);
 	denali->mtd.name = "denali-nand";
-	denali->mtd.owner = THIS_MODULE;
 	denali->mtd.priv = &denali->nand;
 
 	/* register the driver with the NAND core subsystem */
Signature · 1 line
2.4.0
#35 lore raw

PATCH v2 33/60 mtd: nand: fsmc_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/fsmc_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/fsmc_nand.c +1 -1
index e58af4b..a6717b9 100644
@@ -1017,7 +1017,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 	mtd->priv = nand;
 	nand->priv = host;
 
-	host->mtd.owner = THIS_MODULE;
+	host->mtd.dev.parent = &pdev->dev;
 	nand->IO_ADDR_R = host->data_va;
 	nand->IO_ADDR_W = host->data_va;
 	nand->cmd_ctrl = fsmc_cmd_ctrl;
Signature · 1 line
2.4.0
#36 lore raw

PATCH v2 34/60 mtd: nand: gpio: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/gpio.c +1 -1
index 73c4048..9ab97f9 100644
@@ -275,7 +275,7 @@ static int gpio_nand_probe(struct platform_device *pdev)
 	chip->cmd_ctrl		= gpio_nand_cmd_ctrl;
 
 	gpiomtd->mtd_info.priv	= chip;
-	gpiomtd->mtd_info.owner	= THIS_MODULE;
+	gpiomtd->mtd_info.dev.parent = &pdev->dev;
 
 	platform_set_drvdata(pdev, gpiomtd);
 
Signature · 1 line
2.4.0
#37 lore raw

PATCH v2 35/60 mtd: nand: gpmi-nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner set by mtdcore.

---
 drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1 -1
index 1b8f350..1dbcc81 100644
@@ -1897,7 +1897,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
 	/* init the MTD data structures */
 	mtd->priv		= chip;
 	mtd->name		= "gpmi-nand";
-	mtd->owner		= THIS_MODULE;
+	mtd->dev.parent		= this->dev;
 
 	/* init the nand_chip{}, we don't support a 16-bit NAND Flash bus. */
 	chip->priv		= this;
Signature · 1 line
2.4.0
#39 lore raw

PATCH v2 37/60 mtd: nand: jz4740_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/jz4740_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/jz4740_nand.c +1 -1
index ebf2cce..dc4e844 100644
@@ -434,7 +434,7 @@ static int jz_nand_probe(struct platform_device *pdev)
 	mtd		= &nand->mtd;
 	chip		= &nand->chip;
 	mtd->priv	= chip;
-	mtd->owner	= THIS_MODULE;
+	mtd->dev.parent = &pdev->dev;
 	mtd->name	= "jz4740-nand";
 
 	chip->ecc.hwctl		= jz_nand_hwctl;
Signature · 1 line
2.4.0
#38 lore raw

PATCH v2 36/60 mtd: nand: hisi504_nand: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/hisi504_nand.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/hisi504_nand.c +0 -1
index 8dcc7b8..6099aaa 100644
@@ -737,7 +737,6 @@ static int hisi_nfc_probe(struct platform_device *pdev)
 	}
 
 	mtd->priv		= chip;
-	mtd->owner		= THIS_MODULE;
 	mtd->name		= "hisi_nand";
 	mtd->dev.parent         = &pdev->dev;
 
Signature · 1 line
2.4.0
#40 lore raw

PATCH v2 38/60 mtd: nand: lpc32xx_mlc: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/lpc32xx_mlc.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/lpc32xx_mlc.c +0 -1
index 79c3b78..65b7e03 100644
@@ -682,7 +682,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
 
 	nand_chip->priv = host;		/* link the private data structures */
 	mtd->priv = nand_chip;
-	mtd->owner = THIS_MODULE;
 	mtd->dev.parent = &pdev->dev;
 
 	/* Get NAND clock */
Signature · 1 line
2.4.0
#41 lore raw

PATCH v2 39/60 mtd: nand: mpc5121_nfc: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/nand/mpc5121_nfc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/nand/mpc5121_nfc.c +1 -0
index 1f12e5b..b97c371 100644
@@ -659,6 +659,7 @@ static int mpc5121_nfc_probe(struct platform_device *op)
 	chip = &prv->chip;
 
 	mtd->priv = chip;
+	mtd->dev.parent = dev;
 	chip->priv = prv;
 	prv->dev = dev;
 
Signature · 1 line
2.4.0
#43 lore raw

PATCH v2 41/60 mtd: nand: ndfc: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner set by mtdcore.

---
 drivers/mtd/nand/ndfc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/ndfc.c +1 -1
index 3187c6b..9c3f6c8 100644
@@ -171,7 +171,7 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,
 	chip->priv = ndfc;
 
 	ndfc->mtd.priv = chip;
-	ndfc->mtd.owner = THIS_MODULE;
+	ndfc->mtd.dev.parent = &ndfc->ofdev->dev;
 
 	flash_np = of_get_next_child(node, NULL);
 	if (!flash_np)
Signature · 1 line
2.4.0
#44 lore raw

PATCH v2 42/60 mtd: nand: nuc900_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/nuc900_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nuc900_nand.c +1 -1
index e58c644..f0687f7 100644
@@ -250,7 +250,7 @@ static int nuc900_nand_probe(struct platform_device *pdev)
 	chip = &(nuc900_nand->chip);
 
 	nuc900_nand->mtd.priv	= chip;
-	nuc900_nand->mtd.owner	= THIS_MODULE;
+	nuc900_nand->mtd.dev.parent = &pdev->dev;
 	spin_lock_init(&nuc900_nand->lock);
 
 	nuc900_nand->clk = devm_clk_get(&pdev->dev, NULL);
Signature · 1 line
2.4.0
#42 lore raw

PATCH v2 40/60 mtd: nand: mxc_nand: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/mxc_nand.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/mxc_nand.c +0 -1
index 372e0e3..dca63a7 100644
@@ -1450,7 +1450,6 @@ static int mxcnd_probe(struct platform_device *pdev)
 	this = &host->nand;
 	mtd = &host->mtd;
 	mtd->priv = this;
-	mtd->owner = THIS_MODULE;
 	mtd->dev.parent = &pdev->dev;
 	mtd->name = DRIVER_NAME;
 
Signature · 1 line
2.4.0
#45 lore raw

PATCH v2 43/60 mtd: nand: omap2: show parent device structure in sysfs

In reply to Frans Klaver

Make sure the device structure is properly shown in sysfs by properly filling in dev.parent.

While at it, make use of the default owner and name values set by mtdcore.

---
 drivers/mtd/nand/omap2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/nand/omap2.c +1 -2
index 60fa899..7fbf009 100644
@@ -1684,8 +1684,7 @@ static int omap_nand_probe(struct platform_device *pdev)
 	info->ecc_opt		= pdata->ecc_opt;
 	mtd			= &info->mtd;
 	mtd->priv		= &info->nand;
-	mtd->name		= dev_name(&pdev->dev);
-	mtd->owner		= THIS_MODULE;
+	mtd->dev.parent		= &pdev->dev;
 	nand_chip		= &info->nand;
 	nand_chip->ecc.priv	= NULL;
 
Signature · 1 line
2.4.0
#46 lore raw

PATCH v2 44/60 mtd: nand: orion_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/orion_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/orion_nand.c +1 -1
index c3c6d30..81897ef 100644
@@ -124,7 +124,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 	}
 
 	mtd->priv = nc;
-	mtd->owner = THIS_MODULE;
+	mtd->dev.parent = &pdev->dev;
 
 	nc->priv = board;
 	nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
Signature · 1 line
2.4.0
#47 lore raw

PATCH v2 45/60 mtd: nand: pasemi_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/pasemi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/pasemi_nand.c +1 -1
index 66c345b..83cf021 100644
@@ -124,7 +124,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
 
 	/* Link the private data with the MTD structure */
 	pasemi_nand_mtd->priv = chip;
-	pasemi_nand_mtd->owner = THIS_MODULE;
+	pasemi_nand_mtd->dev.parent = &ofdev->dev;
 
 	chip->IO_ADDR_R = of_iomap(np, 0);
 	chip->IO_ADDR_W = chip->IO_ADDR_R;
Signature · 1 line
2.4.0
#49 lore raw

PATCH v2 47/60 mtd: nand: pxa3xx_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/pxa3xx_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/pxa3xx_nand.c +1 -1
index a4615fc..ea06f5b 100644
@@ -1639,7 +1639,7 @@ static int alloc_nand_resource(struct platform_device *pdev)
 		host->cs = cs;
 		host->info_data = info;
 		mtd->priv = host;
-		mtd->owner = THIS_MODULE;
+		mtd->dev.parent = &pdev->dev;
 
 		chip->ecc.read_page	= pxa3xx_nand_read_page_hwecc;
 		chip->ecc.write_page	= pxa3xx_nand_write_page_hwecc;
Signature · 1 line
2.4.0
#48 lore raw

PATCH v2 46/60 mtd: nand: plat_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner and name set by mtdcore.

---
 drivers/mtd/nand/plat_nand.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/nand/plat_nand.c +1 -2
index 4535c26..72e321e 100644
@@ -61,8 +61,7 @@ static int plat_nand_probe(struct platform_device *pdev)
 
 	data->chip.priv = &data;
 	data->mtd.priv = &data->chip;
-	data->mtd.owner = THIS_MODULE;
-	data->mtd.name = dev_name(&pdev->dev);
+	data->mtd.dev.parent = &pdev->dev;
 
 	data->chip.IO_ADDR_R = data->io_base;
 	data->chip.IO_ADDR_W = data->io_base;
Signature · 1 line
2.4.0
#52 lore raw

PATCH v2 50/60 mtd: nand: sh_flctl: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/nand/sh_flctl.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/nand/sh_flctl.c +1 -0
index c3ce81c..2e4f762 100644
@@ -1123,6 +1123,7 @@ static int flctl_probe(struct platform_device *pdev)
 	flctl_mtd = &flctl->mtd;
 	nand = &flctl->chip;
 	flctl_mtd->priv = nand;
+	flctl_mtd->dev.parent = &pdev->dev;
 	flctl->pdev = pdev;
 	flctl->hwecc = pdata->has_hwecc;
 	flctl->holden = pdata->use_holden;
Signature · 1 line
2.4.0
#50 lore raw

PATCH v2 48/60 mtd: nand: r852: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/r852.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/r852.c +0 -1
index baea83f..2541a94 100644
@@ -641,7 +641,6 @@ static int r852_register_nand_device(struct r852_device *dev)
 
 	WARN_ON(dev->card_registred);
 
-	dev->mtd->owner = THIS_MODULE;
 	dev->mtd->priv = dev->chip;
 	dev->mtd->dev.parent = &dev->pci_dev->dev;
 
Signature · 1 line
2.4.0
#53 lore raw

PATCH v2 51/60 mtd: nand: sharpsl: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/sharpsl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/sharpsl.c +1 -1
index 842c47a..082b600 100644
@@ -144,7 +144,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)
 
 	/* Link the private data with the MTD structure */
 	sharpsl->mtd.priv = this;
-	sharpsl->mtd.owner = THIS_MODULE;
+	sharpsl->mtd.dev.parent = &pdev->dev;
 
 	platform_set_drvdata(pdev, sharpsl);
 
Signature · 1 line
2.4.0
#54 lore raw

PATCH v2 52/60 mtd: nand: socrates_nand: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/socrates_nand.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/socrates_nand.c +0 -1
index d710622..b94f534 100644
@@ -167,7 +167,6 @@ static int socrates_nand_probe(struct platform_device *ofdev)
 	nand_chip->priv = host;		/* link the private data structures */
 	mtd->priv = nand_chip;
 	mtd->name = "socrates_nand";
-	mtd->owner = THIS_MODULE;
 	mtd->dev.parent = &ofdev->dev;
 	ppdata.of_node = ofdev->dev.of_node;
 
Signature · 1 line
2.4.0
#51 lore raw

PATCH v2 49/60 mtd: nand: s3c2410: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner set by mtdcore.

---
 drivers/mtd/nand/s3c2410.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/s3c2410.c +1 -1
index 0e02be4..3ebfdd1 100644
@@ -832,7 +832,6 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
 
 	nmtd->info	   = info;
 	nmtd->mtd.priv	   = chip;
-	nmtd->mtd.owner    = THIS_MODULE;
 	nmtd->set	   = set;
 
 #ifdef CONFIG_MTD_NAND_S3C2410_HWECC
@@ -1016,6 +1015,7 @@ static int s3c24xx_nand_probe(struct platform_device *pdev)
 		pr_debug("initialising set %d (%p, info %p)\n",
 			 setno, nmtd, info);
 
+		nmtd->mtd.dev.parent = &pdev->dev;
 		s3c2410_nand_init_chip(info, nmtd, sets);
 
 		nmtd->scan_res = nand_scan_ident(&nmtd->mtd,
Signature · 1 line
2.4.0
#55 lore raw

PATCH v2 53/60 mtd: nand: sunxi_nand: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/nand/sunxi_nand.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/sunxi_nand.c +0 -1
index 6f93b29..14f5c50 100644
@@ -1245,7 +1245,6 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
 	mtd = &chip->mtd;
 	mtd->dev.parent = dev;
 	mtd->priv = nand;
-	mtd->owner = THIS_MODULE;
 
 	ret = nand_scan_ident(mtd, nsels, NULL);
 	if (ret)
Signature · 1 line
2.4.0
#56 lore raw

PATCH v2 54/60 mtd: nand: tmio_nand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/nand/tmio_nand.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/nand/tmio_nand.c +1 -0
index fb8fd35..befddf0 100644
@@ -382,6 +382,7 @@ static int tmio_probe(struct platform_device *dev)
 	nand_chip = &tmio->chip;
 	mtd->priv = nand_chip;
 	mtd->name = "tmio-nand";
+	mtd->dev.parent = &dev->dev;
 
 	tmio->ccr = devm_ioremap(&dev->dev, ccr->start, resource_size(ccr));
 	if (!tmio->ccr)
Signature · 1 line
2.4.0
#57 lore raw

PATCH v2 55/60 mtd: nand: txx9ndfmc: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner value set by mtdcore.

---
 drivers/mtd/nand/txx9ndfmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/txx9ndfmc.c +1 -1
index 9c0bc45..8572519 100644
@@ -323,7 +323,7 @@ static int __init txx9ndfmc_probe(struct platform_device *dev)
 			continue;
 		chip = &txx9_priv->chip;
 		mtd = &txx9_priv->mtd;
-		mtd->owner = THIS_MODULE;
+		mtd->dev.parent = &dev->dev;
 
 		mtd->priv = chip;
 
Signature · 1 line
2.4.0
#59 lore raw

PATCH v2 57/60 mtd: onenand: omap2: drop owner and name assignment

In reply to Frans Klaver

Owner and name are automatically set by mtdcore. Make use of that.

---
 drivers/mtd/onenand/omap2.c | 2 --
 1 file changed, 2 deletions(-)
drivers/mtd/onenand/omap2.c +0 -2
index 646ddd6..3e02856 100644
@@ -710,9 +710,7 @@ static int omap2_onenand_probe(struct platform_device *pdev)
 		 c->onenand.base, c->freq);
 
 	c->pdev = pdev;
-	c->mtd.name = dev_name(&pdev->dev);
 	c->mtd.priv = &c->onenand;
-	c->mtd.owner = THIS_MODULE;
 
 	c->mtd.dev.parent = &pdev->dev;
 
Signature · 1 line
2.4.0
#58 lore raw

PATCH v2 56/60 mtd: onenand: generic: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, take advantage of the default owner and name values set by mtdcore.

---
 drivers/mtd/onenand/generic.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/onenand/generic.c +1 -2
index 32a216d..9ed801b 100644
@@ -60,9 +60,8 @@ static int generic_onenand_probe(struct platform_device *pdev)
 	info->onenand.mmcontrol = pdata ? pdata->mmcontrol : NULL;
 	info->onenand.irq = platform_get_irq(pdev, 0);
 
-	info->mtd.name = dev_name(&pdev->dev);
+	info->mtd.dev.parent = &pdev->dev;
 	info->mtd.priv = &info->onenand;
-	info->mtd.owner = THIS_MODULE;
 
 	if (onenand_scan(&info->mtd, 1)) {
 		err = -ENXIO;
Signature · 1 line
2.4.0
#60 lore raw

PATCH v2 58/60 mtd: onenand: samsung: drop owner assignment

In reply to Frans Klaver

Owner is automatically set by mtdcore. Make use of that.

---
 drivers/mtd/onenand/samsung.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/onenand/samsung.c +0 -1
index 19cfb97..5685923 100644
@@ -864,7 +864,6 @@ static int s3c_onenand_probe(struct platform_device *pdev)
 	this = (struct onenand_chip *) &mtd[1];
 	mtd->priv = this;
 	mtd->dev.parent = &pdev->dev;
-	mtd->owner = THIS_MODULE;
 	onenand->pdev = pdev;
 	onenand->type = platform_get_device_id(pdev)->driver_data;
 
Signature · 1 line
2.4.0
#62 lore raw

PATCH v2 60/60 staging: mt29f_spinand: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

While at it, take advantage of the default owner and name values set by mtdcore.

---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/mt29f_spinand/mt29f_spinand.c +1 -2
index 7285c64..c066ee0 100644
@@ -912,8 +912,7 @@ static int spinand_probe(struct spi_device *spi_nand)
 	dev_set_drvdata(&spi_nand->dev, mtd);
 
 	mtd->priv = chip;
-	mtd->name = dev_name(&spi_nand->dev);
-	mtd->owner = THIS_MODULE;
+	mtd->dev.parent = &spi_nand->dev;
 	mtd->oobsize = 64;
 
 	if (nand_scan(mtd, 1))
Signature · 1 line
2.4.0
#61 lore raw

PATCH v2 59/60 mtd: spi-nor: fsl-quadspi: show parent device in sysfs

In reply to Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

---
 drivers/mtd/spi-nor/fsl-quadspi.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/fsl-quadspi.c +1 -0
index 5d5d362..f7cd06b 100644
@@ -874,6 +874,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
 
 		nor = &q->nor[i];
 		mtd = &q->mtd[i];
+		mtd->dev.parent = dev;
 
 		nor->mtd = mtd;
 		nor->dev = dev;
Signature · 1 line
2.4.0
#64 lore raw
In reply to Frans Klaver

Hi Frans,

Quoted 17 lines · Frans Klaver

Here's the second iteration of a series stemming from a previous discussion about mtd devices not showing up in sysfs properly[1]. While the original series 27 patches, this one should cover all drivers that suffer from this issue, and shamelessly hits 60. Again, if it's preferred that the patches are grouped differently, like by mtd subdir, I'd be happy to resend. Until then, we'll make do with this.

This series teaches add_mtd_device() to set name and owner based on the set parent device, if dev.parent is filled in, and name resp. owner isn't already filled in. All drivers that I could find that don't set the parent are touched to set the parent device, and remove the name and owner assignment in cases where I'm sure the resulting name will not change. Only the latter is done in cases where I would find the driver explicitly filling in the owner.

Thanks for having a go at your favorite MTD,
Frans

Quoted 8 lines

v1..v2
- Overall: make it more clear that it's about a parent device symlink gone missing (thanks, Brian)
- Fix compile error in 30: "fsmc_nand: show parent device in sysfs"
- Fix possible null-pointer dereference in 02: "mtd: core: set some

    defaults..."

[1] https://lkml.org/lkml/2014/5/26/586

Thanks for the patches. I've tested a few drivers and compile tested as much as I can, and everything looks good. Patches 5 and 59 (m25p80.c and fsl-quadspi.c) didn't apply cleanly yet, as those drivers have had some concurrent changes, so I didn't take them yet. If it's trivial to fix up, I'll apply themself. Stay tuned.

Regards,
Brian

#6 lore raw

Re: [PATCH v2 05/60] mtd: devices: m25p80: show parent device in sysfs

In reply to Frans Klaver
Quoted 3 lines · Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

This is one of the patches that didn't apply...

drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 209

Quoted 13 lines
---
 drivers/mtd/devices/m25p80.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/devices/m25p80.c +1 -0
index 3af137f..dfa6ee0 100644
@@ -206,6 +206,7 @@ static int m25p_probe(struct spi_device *spi)
 
 	spi_set_drvdata(spi, flash);
 	flash->mtd.priv = nor;
+	flash->mtd.dev.parent = &spi->dev;

...but I don't think this patch is actually necessary. See spi_nor_scan(), which assigns mtd->dev.parent for us. So as long as the driver assigns the spi_nor::dev field, the spi-nor framework handles this for us.

Same comment applies to fsl-quadspi.c (patch 59), which also didn't apply cleanly. So I don't think we need either of these patches.

drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 212

Quoted 3 lines
drivers/mtd/devices/m25p80.c +0 -0
 	flash->spi = spi;
 
 	if (spi->mode & SPI_RX_QUAD)

Regards,
Brian

#7 lore raw

Re: [PATCH v2 05/60] mtd: devices: m25p80: show parent device in sysfs

Quoted 26 lines · Brian Norris
Quoted 3 lines · Frans Klaver

Fix a bug where mtd parent device symlinks aren't shown in sysfs.

This is one of the patches that didn't apply...

drivers/mtd/devices/m25p80.c static int m25p_probe(struct spi_device *spi) · line 209

Quoted 13 lines
---
 drivers/mtd/devices/m25p80.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/devices/m25p80.c +1 -0
index 3af137f..dfa6ee0 100644
@@ -206,6 +206,7 @@ static int m25p_probe(struct spi_device *spi)
 
      spi_set_drvdata(spi, flash);
      flash->mtd.priv = nor;
+     flash->mtd.dev.parent = &spi->dev;

...but I don't think this patch is actually necessary. See spi_nor_scan(), which assigns mtd->dev.parent for us. So as long as the driver assigns the spi_nor::dev field, the spi-nor framework handles this for us.

Quoted 2 lines

Same comment applies to fsl-quadspi.c (patch 59), which also didn't apply cleanly. So I don't think we need either of these patches.

Sure. Feel free to drop them. The main reason these patches exist is based on the fact that these files didn't contain the "dev.parent =" pattern. I tried to only add those necessary based on code inspection, so it is very well possible that we don't need them. If someone runs into it on these drivers, that's the time to fix it I guess.

Thanks,
Frans