mtd: core: set some defaults when dev.parent is set
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Nov 6 10:59:12 PST 2015
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=807f16d4db956b364ae852a63ad7d79460838866
Commit: 807f16d4db956b364ae852a63ad7d79460838866
Parent: 260e89a6e0d6dcaccd484cf13a69285c3d22268f
Author: Frans Klaver <fransklaver at gmail.com>
AuthorDate: Wed Jun 10 22:38:16 2015 +0200
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Oct 13 09:21:13 2015 -0700
mtd: core: set some defaults when dev.parent is set
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.
Signed-off-by: Frans Klaver <fransklaver at gmail.com>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/mtdcore.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index ac280ee..bbcba0d 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -418,6 +418,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);
More information about the linux-mtd-cvs
mailing list