Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1259922 > unrolled thread

[PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers

Started byBrian Norris <computersforpeace@gmail.com>
First post2015-10-31 04:40 +0100
Last post2015-11-11 22:50 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers Brian Norris <computersforpeace@gmail.com> - 2015-10-31 04:40 +0100
    Re: [PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-11-02 00:30 +0100
      Re: [PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers Brian Norris <computersforpeace@gmail.com> - 2015-11-02 22:20 +0100
    Re: [PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers Brian Norris <computersforpeace@gmail.com> - 2015-11-11 22:50 +0100

#1259922 — [PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers

FromBrian Norris <computersforpeace@gmail.com>
Date2015-10-31 04:40 +0100
Subject[PATCH v2 01/11] mtd: add get/set of_node/flash_node helpers
Message-ID<qpvbj-69C-19@gated-at.bofh.it>
We are going to begin using the mtd->dev.of_node field for MTD device
nodes, so let's add helpers for it. Also, we'll be making some
conversions on spi_nor (and nand_chip eventually) too, so get that ready
with their own helpers.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
v2: new

 include/linux/mtd/mtd.h     | 11 +++++++++++
 include/linux/mtd/nand.h    | 11 +++++++++++
 include/linux/mtd/spi-nor.h | 11 +++++++++++
 3 files changed, 33 insertions(+)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index f17fa75809aa..cc84923011c0 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -254,6 +254,17 @@ struct mtd_info {
 	int usecount;
 };
 
+static inline void mtd_set_of_node(struct mtd_info *mtd,
+				   struct device_node *np)
+{
+	mtd->dev.of_node = np;
+}
+
+static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
+{
+	return mtd->dev.of_node;
+}
+
 int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
 int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
 	      void **virt, resource_size_t *phys);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 5a9d1d4c2487..4f7c9b97982f 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -719,6 +719,17 @@ struct nand_chip {
 	void *priv;
 };
 
+static inline void nand_set_flash_node(struct nand_chip *chip,
+				       struct device_node *np)
+{
+	chip->flash_node = np;
+}
+
+static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
+{
+	return chip->flash_node;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index c8723b62c4cd..6d991df8f986 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -185,6 +185,17 @@ struct spi_nor {
 	void *priv;
 };
 
+static inline void spi_nor_set_flash_node(struct spi_nor *nor,
+					  struct device_node *np)
+{
+	nor->flash_node = np;
+}
+
+static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
+{
+	return nor->flash_node;
+}
+
 /**
  * spi_nor_scan() - scan the SPI NOR
  * @nor:	the spi_nor structure
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1260262

FromBoris Brezillon <boris.brezillon@free-electrons.com>
Date2015-11-02 00:30 +0100
Message-ID<qqaev-6c1-35@gated-at.bofh.it>
In reply to#1259922
On Fri, 30 Oct 2015 20:33:20 -0700
Brian Norris <computersforpeace@gmail.com> wrote:

> We are going to begin using the mtd->dev.of_node field for MTD device
> nodes, so let's add helpers for it. Also, we'll be making some
> conversions on spi_nor (and nand_chip eventually) too, so get that ready
> with their own helpers.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> v2: new
> 
>  include/linux/mtd/mtd.h     | 11 +++++++++++
>  include/linux/mtd/nand.h    | 11 +++++++++++
>  include/linux/mtd/spi-nor.h | 11 +++++++++++
>  3 files changed, 33 insertions(+)
> 
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index f17fa75809aa..cc84923011c0 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -254,6 +254,17 @@ struct mtd_info {
>  	int usecount;
>  };
>  
> +static inline void mtd_set_of_node(struct mtd_info *mtd,
> +				   struct device_node *np)
> +{
> +	mtd->dev.of_node = np;

Maybe we should retain a reference to the device_node here (IOW,
replace '= np' by '= of_node_get(np)'). Of course this implies calling
of_node_put() when the mtd device is unregistered.

> +}
> +
> +static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
> +{
> +	return mtd->dev.of_node;

Not sure this is relevant to to the same here before returning the
device_node because it's mostly used by the MTD drivers and those are
the ones who called mtd_set_of_node() in the first place, so we can
assume it's safe to return an non-retained reference to a device_node.


-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1260981

FromBrian Norris <computersforpeace@gmail.com>
Date2015-11-02 22:20 +0100
Message-ID<qquGi-1YL-111@gated-at.bofh.it>
In reply to#1260262
On Mon, Nov 02, 2015 at 12:27:58AM +0100, Boris Brezillon wrote:
> On Fri, 30 Oct 2015 20:33:20 -0700
> Brian Norris <computersforpeace@gmail.com> wrote:
> 
> > We are going to begin using the mtd->dev.of_node field for MTD device
> > nodes, so let's add helpers for it. Also, we'll be making some
> > conversions on spi_nor (and nand_chip eventually) too, so get that ready
> > with their own helpers.
> > 
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > ---
> > v2: new
> > 
> >  include/linux/mtd/mtd.h     | 11 +++++++++++
> >  include/linux/mtd/nand.h    | 11 +++++++++++
> >  include/linux/mtd/spi-nor.h | 11 +++++++++++
> >  3 files changed, 33 insertions(+)
> > 
> > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> > index f17fa75809aa..cc84923011c0 100644
> > --- a/include/linux/mtd/mtd.h
> > +++ b/include/linux/mtd/mtd.h
> > @@ -254,6 +254,17 @@ struct mtd_info {
> >  	int usecount;
> >  };
> >  
> > +static inline void mtd_set_of_node(struct mtd_info *mtd,
> > +				   struct device_node *np)
> > +{
> > +	mtd->dev.of_node = np;
> 
> Maybe we should retain a reference to the device_node here (IOW,
> replace '= np' by '= of_node_get(np)'). Of course this implies calling
> of_node_put() when the mtd device is unregistered.

I'll admit I never really followed (nor verified) the OF get/put logic
that well. But I suppose that makes sense.

> > +}
> > +
> > +static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
> > +{
> > +	return mtd->dev.of_node;
> 
> Not sure this is relevant to to the same here before returning the
> device_node because it's mostly used by the MTD drivers and those are
> the ones who called mtd_set_of_node() in the first place, so we can
> assume it's safe to return an non-retained reference to a device_node.

I think once the node has been "set", its consumers should stay in sync
with the lifetime of the MTD; so I think just that initial refcount is
sufficient.

IOW, if MTD drivers are still fiddling with an MTD's of_node after the
MTD is unregistered, then we've failed somewhere else.

Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1267463

FromBrian Norris <computersforpeace@gmail.com>
Date2015-11-11 22:50 +0100
Message-ID<qtLrc-8iQ-19@gated-at.bofh.it>
In reply to#1259922
On Fri, Oct 30, 2015 at 08:33:20PM -0700, Brian Norris wrote:
> We are going to begin using the mtd->dev.of_node field for MTD device
> nodes, so let's add helpers for it. Also, we'll be making some
> conversions on spi_nor (and nand_chip eventually) too, so get that ready
> with their own helpers.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> v2: new

Pushed the first 5 to l2-mtd.git/next. Still re-reviewing the comments
on the latter half of the series.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web