All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamie Iles <jamie@jamieiles.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: devicetree-discuss@lists.ozlabs.org,
	Grant Likely <grant.likely@secretlab.ca>,
	linux-mtd@lists.infradead.org,
	Scott Wood <scottwood@freescale.com>,
	Jamie Iles <jamie@jamieiles.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCHv4] mtd: gpio-nand: add device tree bindings
Date: Mon, 15 Aug 2011 14:58:43 +0100	[thread overview]
Message-ID: <20110815135843.GD2636@pulham.picochip.com> (raw)
In-Reply-To: <1313416681.2553.2.camel@sauron>

On Mon, Aug 15, 2011 at 04:57:56PM +0300, Artem Bityutskiy wrote:
> On Tue, 2011-08-09 at 16:12 +0100, Jamie Iles wrote:
> > +static int gpio_nand_of_get_options(struct device *dev,
> > +				    struct gpio_nand_platdata *plat)
> > +{
> > +	u32 width;
> > +
> > +	if (!of_property_read_u32(dev->of_node, "bank-width", &width)) {
> > +		if (width == 2) {
> > +			plat->options |= NAND_BUSWIDTH_16;
> > +		} else if (width != 1) {
> > +			dev_err(dev, "invalid bank-width %u\n", width);
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static void gpio_nand_of_get_gpio(struct device *dev,
> > +				  struct gpio_nand_platdata *plat)
> > +{
> > +	plat->gpio_rdy = of_get_gpio(dev->of_node, 0);
> > +	plat->gpio_nce = of_get_gpio(dev->of_node, 1);
> > +	plat->gpio_ale = of_get_gpio(dev->of_node, 2);
> > +	plat->gpio_cle = of_get_gpio(dev->of_node, 3);
> > +	plat->gpio_nwp = of_get_gpio(dev->of_node, 4);
> > +}
> > +
> > +static void gpio_nand_of_get_chip_delay(struct device *dev,
> > +					struct gpio_nand_platdata *plat)
> > +{
> > +	u32 chip_delay;
> > +
> > +	if (!of_property_read_u32(dev->of_node, "chip-delay", &chip_delay))
> > +		plat->chip_delay = (int)chip_delay;
> > +}
> > +
> > +static int gpio_nand_of_get_config(struct device *dev,
> > +				   struct gpio_nand_platdata *plat)
> > +{
> > +	int ret = gpio_nand_of_get_options(dev, plat);
> > +
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	gpio_nand_of_get_gpio(dev, plat);
> > +	gpio_nand_of_get_chip_delay(dev, plat);
> > +
> > +	return 0;
> > +}
> 
> Do we really need to have 3 additional helper functions for
> 'gpio_nand_of_get_config()' ?

Not really, I'm happy to fold those all into one if you prefer.

Jamie

WARNING: multiple messages have this Message-ID (diff)
From: Jamie Iles <jamie-wmLquQDDieKakBO8gow8eQ@public.gmane.org>
To: Artem Bityutskiy <dedekind1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Scott Wood <scottwood-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Subject: Re: [PATCHv4] mtd: gpio-nand: add device tree bindings
Date: Mon, 15 Aug 2011 14:58:43 +0100	[thread overview]
Message-ID: <20110815135843.GD2636@pulham.picochip.com> (raw)
In-Reply-To: <1313416681.2553.2.camel@sauron>

On Mon, Aug 15, 2011 at 04:57:56PM +0300, Artem Bityutskiy wrote:
> On Tue, 2011-08-09 at 16:12 +0100, Jamie Iles wrote:
> > +static int gpio_nand_of_get_options(struct device *dev,
> > +				    struct gpio_nand_platdata *plat)
> > +{
> > +	u32 width;
> > +
> > +	if (!of_property_read_u32(dev->of_node, "bank-width", &width)) {
> > +		if (width == 2) {
> > +			plat->options |= NAND_BUSWIDTH_16;
> > +		} else if (width != 1) {
> > +			dev_err(dev, "invalid bank-width %u\n", width);
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static void gpio_nand_of_get_gpio(struct device *dev,
> > +				  struct gpio_nand_platdata *plat)
> > +{
> > +	plat->gpio_rdy = of_get_gpio(dev->of_node, 0);
> > +	plat->gpio_nce = of_get_gpio(dev->of_node, 1);
> > +	plat->gpio_ale = of_get_gpio(dev->of_node, 2);
> > +	plat->gpio_cle = of_get_gpio(dev->of_node, 3);
> > +	plat->gpio_nwp = of_get_gpio(dev->of_node, 4);
> > +}
> > +
> > +static void gpio_nand_of_get_chip_delay(struct device *dev,
> > +					struct gpio_nand_platdata *plat)
> > +{
> > +	u32 chip_delay;
> > +
> > +	if (!of_property_read_u32(dev->of_node, "chip-delay", &chip_delay))
> > +		plat->chip_delay = (int)chip_delay;
> > +}
> > +
> > +static int gpio_nand_of_get_config(struct device *dev,
> > +				   struct gpio_nand_platdata *plat)
> > +{
> > +	int ret = gpio_nand_of_get_options(dev, plat);
> > +
> > +	if (ret < 0)
> > +		return ret;
> > +
> > +	gpio_nand_of_get_gpio(dev, plat);
> > +	gpio_nand_of_get_chip_delay(dev, plat);
> > +
> > +	return 0;
> > +}
> 
> Do we really need to have 3 additional helper functions for
> 'gpio_nand_of_get_config()' ?

Not really, I'm happy to fold those all into one if you prefer.

Jamie

  reply	other threads:[~2011-08-15 13:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-09 15:12 [PATCHv4] mtd: gpio-nand: add device tree bindings Jamie Iles
2011-08-09 15:12 ` Jamie Iles
2011-08-10 15:13 ` Scott Wood
2011-08-10 15:13   ` Scott Wood
2011-08-11  9:00   ` Jamie Iles
2011-08-11  9:00     ` Jamie Iles
2011-08-15 13:57 ` Artem Bityutskiy
2011-08-15 13:57   ` Artem Bityutskiy
2011-08-15 13:58   ` Jamie Iles [this message]
2011-08-15 13:58     ` Jamie Iles
2011-08-15 14:28 ` Artem Bityutskiy
2011-08-15 14:28   ` Artem Bityutskiy
2011-08-15 14:38   ` Jamie Iles
2011-08-15 14:38     ` Jamie Iles
2011-08-15 14:45     ` Artem Bityutskiy
2011-08-15 14:45       ` Artem Bityutskiy
2011-08-15 15:24       ` Jamie Iles
2011-08-15 15:24         ` Jamie Iles
2011-08-19 19:51         ` Artem Bityutskiy
2011-08-19 19:51           ` Artem Bityutskiy
2011-08-19 21:18           ` Jamie Iles
2011-08-19 21:18             ` Jamie Iles
2011-08-20  3:39         ` Artem Bityutskiy
2011-08-20  3:39           ` Artem Bityutskiy
2011-08-20  6:38           ` Jamie Iles
2011-08-20  6:38             ` Jamie Iles
2011-08-20 12:09             ` Artem Bityutskiy
2011-08-20 12:09               ` Artem Bityutskiy

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=20110815135843.GD2636@pulham.picochip.com \
    --to=jamie@jamieiles.com \
    --cc=dedekind1@gmail.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=dwmw2@infradead.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-mtd@lists.infradead.org \
    --cc=scottwood@freescale.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.