* [PATCH] mtd: grab a reference to the MTD of_node before registering it
@ 2015-11-12 0:26 Brian Norris
[not found] ` <1447287964-63309-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2015-11-12 0:26 UTC (permalink / raw)
To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Cc: Boris Brezillon, Brian Norris, devicetree-u79uwXL29TY76Z2rM5mHXA
We now stick the device node representing the current MTD (if any) into
sysfs, so let's make sure we have a reference to it before doing that.
Suggested-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Signed-off-by: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/mtd/mtdcore.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index a91cee90aef9..c393a1155376 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -32,6 +32,7 @@
#include <linux/err.h>
#include <linux/ioctl.h>
#include <linux/init.h>
+#include <linux/of.h>
#include <linux/proc_fs.h>
#include <linux/idr.h>
#include <linux/backing-dev.h>
@@ -454,6 +455,7 @@ int add_mtd_device(struct mtd_info *mtd)
mtd->dev.devt = MTD_DEVT(i);
dev_set_name(&mtd->dev, "mtd%d", i);
dev_set_drvdata(&mtd->dev, mtd);
+ of_node_get(mtd_get_of_node(mtd));
error = device_register(&mtd->dev);
if (error)
goto fail_added;
@@ -476,6 +478,7 @@ int add_mtd_device(struct mtd_info *mtd)
return 0;
fail_added:
+ of_node_put(mtd_get_of_node(mtd));
idr_remove(&mtd_idr, i);
fail_locked:
mutex_unlock(&mtd_table_mutex);
@@ -517,6 +520,7 @@ int del_mtd_device(struct mtd_info *mtd)
device_unregister(&mtd->dev);
idr_remove(&mtd_idr, mtd->index);
+ of_node_put(mtd_get_of_node(mtd));
module_put(THIS_MODULE);
ret = 0;
--
2.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <1447287964-63309-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH v2] mtd: assign mtd->dev.of_node when creating partition devices [not found] ` <1447287964-63309-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2015-11-12 1:04 ` Brian Norris 2015-11-12 8:51 ` [PATCH] mtd: grab a reference to the MTD of_node before registering it Boris Brezillon 1 sibling, 0 replies; 4+ messages in thread From: Brian Norris @ 2015-11-12 1:04 UTC (permalink / raw) To: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Cc: Boris Brezillon, devicetree-u79uwXL29TY76Z2rM5mHXA From: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> MTD partitions may have been created from a DT definition, and in this case the ->of_node of the struct device embedded in mtd_info should point to the DT node that was used to create the partition. Signed-off-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> Signed-off-by: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- v2: drop most of the get/put node handling; allow the MTD core to do this in {add,del}_mtd_device() depends on: http://patchwork.ozlabs.org/patch/543159/ v1: http://patchwork.ozlabs.org/patch/538838/ drivers/mtd/mtdpart.c | 1 + drivers/mtd/ofpart.c | 2 +- include/linux/mtd/partitions.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index f8ba153f63bf..c2b6e967a160 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -391,6 +391,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, slave->mtd.dev.parent = IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER) ? &master->dev : master->dev.parent; + mtd_set_of_node(&slave->mtd, part->of_node); slave->mtd._read = part_read; slave->mtd._write = part_write; diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index f78d2aea5545..dacf4c405dec 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -111,6 +111,7 @@ static int parse_ofpart_partitions(struct mtd_info *master, if (of_get_property(pp, "lock", &len)) (*pparts)[i].mask_flags |= MTD_POWERUP_LOCK; + (*pparts)[i].of_node = pp; i++; } @@ -124,7 +125,6 @@ ofpart_fail: master->name, pp->full_name, mtd_node->full_name); ret = -EINVAL; ofpart_none: - of_node_put(pp); kfree(*pparts); *pparts = NULL; return ret; diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h index 773975a3c9e6..282644c0c5c0 100644 --- a/include/linux/mtd/partitions.h +++ b/include/linux/mtd/partitions.h @@ -42,6 +42,7 @@ struct mtd_partition { uint64_t offset; /* offset within the master MTD space */ uint32_t mask_flags; /* master MTD flags to mask out for this partition */ struct nand_ecclayout *ecclayout; /* out of band layout for this partition (NAND only) */ + struct device_node *of_node; /* OF node attached to the partition */ }; #define MTDPART_OFS_RETAIN (-3) -- 2.6.0.rc2.230.g3dd15c0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: grab a reference to the MTD of_node before registering it [not found] ` <1447287964-63309-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2015-11-12 1:04 ` [PATCH v2] mtd: assign mtd->dev.of_node when creating partition devices Brian Norris @ 2015-11-12 8:51 ` Boris Brezillon 2015-11-12 18:12 ` Brian Norris 1 sibling, 1 reply; 4+ messages in thread From: Boris Brezillon @ 2015-11-12 8:51 UTC (permalink / raw) To: Brian Norris Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA On Wed, 11 Nov 2015 16:26:04 -0800 Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > We now stick the device node representing the current MTD (if any) into > sysfs, so let's make sure we have a reference to it before doing that. > > Suggested-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> > Signed-off-by: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Looks good to me, Reviewed-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> > --- > drivers/mtd/mtdcore.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index a91cee90aef9..c393a1155376 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -32,6 +32,7 @@ > #include <linux/err.h> > #include <linux/ioctl.h> > #include <linux/init.h> > +#include <linux/of.h> > #include <linux/proc_fs.h> > #include <linux/idr.h> > #include <linux/backing-dev.h> > @@ -454,6 +455,7 @@ int add_mtd_device(struct mtd_info *mtd) > mtd->dev.devt = MTD_DEVT(i); > dev_set_name(&mtd->dev, "mtd%d", i); > dev_set_drvdata(&mtd->dev, mtd); > + of_node_get(mtd_get_of_node(mtd)); > error = device_register(&mtd->dev); > if (error) > goto fail_added; > @@ -476,6 +478,7 @@ int add_mtd_device(struct mtd_info *mtd) > return 0; > > fail_added: > + of_node_put(mtd_get_of_node(mtd)); > idr_remove(&mtd_idr, i); > fail_locked: > mutex_unlock(&mtd_table_mutex); > @@ -517,6 +520,7 @@ int del_mtd_device(struct mtd_info *mtd) > device_unregister(&mtd->dev); > > idr_remove(&mtd_idr, mtd->index); > + of_node_put(mtd_get_of_node(mtd)); > > module_put(THIS_MODULE); > ret = 0; -- Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: grab a reference to the MTD of_node before registering it 2015-11-12 8:51 ` [PATCH] mtd: grab a reference to the MTD of_node before registering it Boris Brezillon @ 2015-11-12 18:12 ` Brian Norris 0 siblings, 0 replies; 4+ messages in thread From: Brian Norris @ 2015-11-12 18:12 UTC (permalink / raw) To: Boris Brezillon Cc: linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA On Thu, Nov 12, 2015 at 09:51:20AM +0100, Boris Brezillon wrote: > On Wed, 11 Nov 2015 16:26:04 -0800 > Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > We now stick the device node representing the current MTD (if any) into > > sysfs, so let's make sure we have a reference to it before doing that. > > > > Suggested-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> > > Signed-off-by: Brian Norris <computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > Looks good to me, > > Reviewed-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> Pushed to l2-mtd.git/next -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-12 18:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-12 0:26 [PATCH] mtd: grab a reference to the MTD of_node before registering it Brian Norris
[not found] ` <1447287964-63309-1-git-send-email-computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-12 1:04 ` [PATCH v2] mtd: assign mtd->dev.of_node when creating partition devices Brian Norris
2015-11-12 8:51 ` [PATCH] mtd: grab a reference to the MTD of_node before registering it Boris Brezillon
2015-11-12 18:12 ` Brian Norris
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).