All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: Lior Amsalem <alior@marvell.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Jason Cooper <jason@lakedaemon.net>,
	Artem Bityutskiy <dedekind1@gmail.com>,
	Daniel Mack <zonque@gmail.com>,
	devicetree@vger.kernel.org, linux-mtd@lists.infradead.org,
	Gregory Clement <gregory.clement@free-electrons.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH v2 01/14] mtd: nand: pxa3xx: Introduce 'marvell,armada370-nand' compatible string
Date: Sat, 10 Aug 2013 15:41:17 -0300	[thread overview]
Message-ID: <20130810184116.GA2756@localhost> (raw)
In-Reply-To: <20130810182854.GA10830@norris.computersforpeace.net>

On Sat, Aug 10, 2013 at 11:28:57AM -0700, Brian Norris wrote:
> On Wed, Aug 07, 2013 at 09:31:06AM -0300, Ezequiel Garcia wrote:
> > This driver supports NFCv1 (as found in PXA SoC) and NFCv2 (as found in
> > Armada 370/XP SoC). As both controller has a few differences, a way of
> > distinguishing between the two is needed.
> > 
> > This commit introduces a new compatible string 'marvell,armada370-nand'
> > and assigns a compatible data of type enum pxa3xx_nand_variant to allow
> > such distinction.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/mtd/nand/pxa3xx_nand.c | 38 +++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 37 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> > index 501e380..2582e1f 100644
> > --- a/drivers/mtd/nand/pxa3xx_nand.c
> > +++ b/drivers/mtd/nand/pxa3xx_nand.c
> > @@ -123,6 +123,11 @@ enum {
> >  	STATE_READY,
> >  };
> >  
> > +enum pxa3xx_nand_variant {
> > +	PXA3XX_NAND_VARIANT_PXA,
> > +	PXA3XX_NAND_VARIANT_ARMADA370,
> > +};
> > +
> >  struct pxa3xx_nand_host {
> >  	struct nand_chip	chip;
> >  	struct pxa3xx_nand_cmdset *cmdset;
> > @@ -171,6 +176,12 @@ struct pxa3xx_nand_info {
> >  	struct pxa3xx_nand_host *host[NUM_CHIP_SELECT];
> >  	unsigned int		state;
> >  
> > +	/*
> > +	 * This driver supports NFCv1 (as found in PXA SoC)
> > +	 * and NFCv2 (as found in Armada 370/XP SoC).
> > +	 */
> > +	enum pxa3xx_nand_variant variant;
> > +
> >  	int			cs;
> >  	int			use_ecc;	/* use HW ECC ? */
> >  	int			use_dma;	/* use DMA ? */
> > @@ -1192,7 +1203,14 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
> >  
> >  #ifdef CONFIG_OF
> >  static struct of_device_id pxa3xx_nand_dt_ids[] = {
> > -	{ .compatible = "marvell,pxa3xx-nand" },
> > +	{
> > +		.compatible = "marvell,pxa3xx-nand",
> > +		.data       = (void *) PXA3XX_NAND_VARIANT_PXA,
> 
> It's a little more common to avoid a space between the cast and the
> rvalue. But that's a nitpick that can go either way (it's not in
> CodingStyle, for one).
> 

Sure.

> > +	},
> > +	{
> > +		.compatible = "marvell,armada370-nand",
> > +		.data       = (void *) PXA3XX_NAND_VARIANT_ARMADA370,
> > +	},
> >  	{}
> >  };
> >  MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
> > @@ -1221,11 +1239,28 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
> >  
> >  	return 0;
> >  }
> > +
> > +static enum pxa3xx_nand_variant
> > +pxa3xx_nand_get_variant(struct platform_device *pdev)
> > +{
> > +	const struct of_device_id *of_id =
> > +			of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
> > +	if (!of_id)
> > +		return PXA3XX_NAND_VARIANT_PXA;
> > +	return (enum pxa3xx_nand_variant) of_id->data;
> > +}
> >  #else
> >  static inline int pxa3xx_nand_probe_dt(struct platform_device *pdev)
> >  {
> >  	return 0;
> >  }
> 
> It looks like before this patch, you don't actually need the whole
> #ifdef/#else CONFIG_OF block. All the of_* helpers have default inline
> implementations that allow things to compile even without CONFIG_OF. So
> without CONFIG_OF, of_match_device() will just return NULL and the
> compiler can easiliy figure out that pxa3xx_nand_probe_dt() always
> should return 0.
> 
> IOW, you only need a single pxa3xx_nand_probe_dt() implementation.
> 
> And directly related to this patch: you don't need two
> pxa3xx_nand_get_variant() implementations either. Again,
> of_match_device() returns NULL in the !defined(CONFIG_OF) case.
> 
> > +
> > +static enum pxa3xx_nand_variant
> > +pxa3xx_nand_get_variant(struct platform_device *pdev)
> > +{
> > +	/* Default lefacy (non-DT) variant */
> 
> s/lefacy/legacy/
> 
> > +	return PXA3XX_NAND_VARIANT_PXA;
> > +}
> 
> Given the above comments, you won't need this version of
> pxa3xx_nand_get_variant().
> 
> >  #endif
> >  
> >  static int pxa3xx_nand_probe(struct platform_device *pdev)
> > @@ -1252,6 +1287,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
> >  	}
> >  
> >  	info = platform_get_drvdata(pdev);
> > +	info->variant = pxa3xx_nand_get_variant(pdev);
> >  	probe_success = 0;
> >  	for (cs = 0; cs < pdata->num_cs; cs++) {
> >  		info->cs = cs;
> 
> I would recommend rewriting this patch to remove the #ifdef CONFIG_OF.
> 

Good to hear this! It was my intention in the first place, but refrained
from doing so for I thought someone might complain about the CONFIG_OF removal.

So if I remember correct, I'd say this means a patch split (right?):
one patch to remove CONFIG_OF, one patch to introduce the SoC variant.

Thanks for reviewing!
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

WARNING: multiple messages have this Message-ID (diff)
From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org,
	Jason Cooper <jason@lakedaemon.net>,
	Lior Amsalem <alior@marvell.com>,
	Artem Bityutskiy <dedekind1@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	Gregory Clement <gregory.clement@free-electrons.com>,
	Daniel Mack <zonque@gmail.com>,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v2 01/14] mtd: nand: pxa3xx: Introduce 'marvell,armada370-nand' compatible string
Date: Sat, 10 Aug 2013 15:41:17 -0300	[thread overview]
Message-ID: <20130810184116.GA2756@localhost> (raw)
In-Reply-To: <20130810182854.GA10830@norris.computersforpeace.net>

On Sat, Aug 10, 2013 at 11:28:57AM -0700, Brian Norris wrote:
> On Wed, Aug 07, 2013 at 09:31:06AM -0300, Ezequiel Garcia wrote:
> > This driver supports NFCv1 (as found in PXA SoC) and NFCv2 (as found in
> > Armada 370/XP SoC). As both controller has a few differences, a way of
> > distinguishing between the two is needed.
> > 
> > This commit introduces a new compatible string 'marvell,armada370-nand'
> > and assigns a compatible data of type enum pxa3xx_nand_variant to allow
> > such distinction.
> > 
> > Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> > ---
> >  drivers/mtd/nand/pxa3xx_nand.c | 38 +++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 37 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
> > index 501e380..2582e1f 100644
> > --- a/drivers/mtd/nand/pxa3xx_nand.c
> > +++ b/drivers/mtd/nand/pxa3xx_nand.c
> > @@ -123,6 +123,11 @@ enum {
> >  	STATE_READY,
> >  };
> >  
> > +enum pxa3xx_nand_variant {
> > +	PXA3XX_NAND_VARIANT_PXA,
> > +	PXA3XX_NAND_VARIANT_ARMADA370,
> > +};
> > +
> >  struct pxa3xx_nand_host {
> >  	struct nand_chip	chip;
> >  	struct pxa3xx_nand_cmdset *cmdset;
> > @@ -171,6 +176,12 @@ struct pxa3xx_nand_info {
> >  	struct pxa3xx_nand_host *host[NUM_CHIP_SELECT];
> >  	unsigned int		state;
> >  
> > +	/*
> > +	 * This driver supports NFCv1 (as found in PXA SoC)
> > +	 * and NFCv2 (as found in Armada 370/XP SoC).
> > +	 */
> > +	enum pxa3xx_nand_variant variant;
> > +
> >  	int			cs;
> >  	int			use_ecc;	/* use HW ECC ? */
> >  	int			use_dma;	/* use DMA ? */
> > @@ -1192,7 +1203,14 @@ static int pxa3xx_nand_remove(struct platform_device *pdev)
> >  
> >  #ifdef CONFIG_OF
> >  static struct of_device_id pxa3xx_nand_dt_ids[] = {
> > -	{ .compatible = "marvell,pxa3xx-nand" },
> > +	{
> > +		.compatible = "marvell,pxa3xx-nand",
> > +		.data       = (void *) PXA3XX_NAND_VARIANT_PXA,
> 
> It's a little more common to avoid a space between the cast and the
> rvalue. But that's a nitpick that can go either way (it's not in
> CodingStyle, for one).
> 

Sure.

> > +	},
> > +	{
> > +		.compatible = "marvell,armada370-nand",
> > +		.data       = (void *) PXA3XX_NAND_VARIANT_ARMADA370,
> > +	},
> >  	{}
> >  };
> >  MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
> > @@ -1221,11 +1239,28 @@ static int pxa3xx_nand_probe_dt(struct platform_device *pdev)
> >  
> >  	return 0;
> >  }
> > +
> > +static enum pxa3xx_nand_variant
> > +pxa3xx_nand_get_variant(struct platform_device *pdev)
> > +{
> > +	const struct of_device_id *of_id =
> > +			of_match_device(pxa3xx_nand_dt_ids, &pdev->dev);
> > +	if (!of_id)
> > +		return PXA3XX_NAND_VARIANT_PXA;
> > +	return (enum pxa3xx_nand_variant) of_id->data;
> > +}
> >  #else
> >  static inline int pxa3xx_nand_probe_dt(struct platform_device *pdev)
> >  {
> >  	return 0;
> >  }
> 
> It looks like before this patch, you don't actually need the whole
> #ifdef/#else CONFIG_OF block. All the of_* helpers have default inline
> implementations that allow things to compile even without CONFIG_OF. So
> without CONFIG_OF, of_match_device() will just return NULL and the
> compiler can easiliy figure out that pxa3xx_nand_probe_dt() always
> should return 0.
> 
> IOW, you only need a single pxa3xx_nand_probe_dt() implementation.
> 
> And directly related to this patch: you don't need two
> pxa3xx_nand_get_variant() implementations either. Again,
> of_match_device() returns NULL in the !defined(CONFIG_OF) case.
> 
> > +
> > +static enum pxa3xx_nand_variant
> > +pxa3xx_nand_get_variant(struct platform_device *pdev)
> > +{
> > +	/* Default lefacy (non-DT) variant */
> 
> s/lefacy/legacy/
> 
> > +	return PXA3XX_NAND_VARIANT_PXA;
> > +}
> 
> Given the above comments, you won't need this version of
> pxa3xx_nand_get_variant().
> 
> >  #endif
> >  
> >  static int pxa3xx_nand_probe(struct platform_device *pdev)
> > @@ -1252,6 +1287,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
> >  	}
> >  
> >  	info = platform_get_drvdata(pdev);
> > +	info->variant = pxa3xx_nand_get_variant(pdev);
> >  	probe_success = 0;
> >  	for (cs = 0; cs < pdata->num_cs; cs++) {
> >  		info->cs = cs;
> 
> I would recommend rewriting this patch to remove the #ifdef CONFIG_OF.
> 

Good to hear this! It was my intention in the first place, but refrained
from doing so for I thought someone might complain about the CONFIG_OF removal.

So if I remember correct, I'd say this means a patch split (right?):
one patch to remove CONFIG_OF, one patch to introduce the SoC variant.

Thanks for reviewing!
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

  reply	other threads:[~2013-08-10 18:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-07 12:31 [PATCH v2 00/14] pxa3xx-nand patches to support mvebu builds Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 01/14] mtd: nand: pxa3xx: Introduce 'marvell, armada370-nand' compatible string Ezequiel Garcia
2013-08-08  7:58   ` Brian Norris
2013-08-08  7:58     ` [PATCH v2 01/14] mtd: nand: pxa3xx: Introduce 'marvell,armada370-nand' " Brian Norris
2013-08-10 18:28   ` Brian Norris
2013-08-10 18:28     ` Brian Norris
2013-08-10 18:41     ` Ezequiel Garcia [this message]
2013-08-10 18:41       ` Ezequiel Garcia
2013-08-10 20:33       ` Brian Norris
2013-08-10 20:33         ` Brian Norris
2013-08-07 12:31 ` [PATCH v2 02/14] mtd: nand: pxa3xx: Handle ECC and DMA enable/disable properly Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 03/14] mtd: nand: pxa3xx: Allow to set/clear the 'spare enable' field Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 04/14] mtd: nand: pxa3xx: Support command buffer #3 Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 05/14] mtd: nand: pxa3xx: Use 'length override' in ONFI paramater page read Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 06/14] mtd: nand: pxa3xx: Add a local loop variable Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 07/14] mtd: nand: pxa3xx: Remove hardcoded mtd name Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 08/14] mtd: nand: pxa3xx: Remove uneeded internal cmdset Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 09/14] mtd: nand: pxa3xx: Move cached registers to info structure Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 10/14] mtd: nand: pxa3xx: Make dma code dependent on dma capable platforms Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 11/14] mtd: nand: pxa3xx: Add __maybe_unused keyword to enable_int() Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 12/14] mtd: nand: pxa3xx: Allow devices with no dma resources Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 13/14] mtd: nand: pxa3xx: Increase data buffer size Ezequiel Garcia
2013-08-07 12:31 ` [PATCH v2 14/14] mtd: nand: Allow to build pxa3xx_nand on Orion platforms Ezequiel Garcia
2013-08-07 12:45 ` [PATCH v2 00/14] pxa3xx-nand patches to support mvebu builds Daniel Mack
2013-08-07 13:02   ` Ezequiel Garcia
2013-08-10 12:12 ` Ezequiel Garcia
2013-08-10 17:30   ` Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130810184116.GA2756@localhost \
    --to=ezequiel.garcia@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-mtd@lists.infradead.org \
    --cc=thomas.petazzoni@free-electrons.com \
    --cc=zonque@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.