All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Suresh Mangipudi <smangipudi@nvidia.com>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	linux-tegra@vger.kernel.org
Subject: Re: [PATCH] gpio: Add Tegra186 support
Date: Thu, 24 Nov 2016 12:23:56 +0530	[thread overview]
Message-ID: <58368E84.6040104@nvidia.com> (raw)
In-Reply-To: <20161122175539.3897-1-thierry.reding@gmail.com>


On Tuesday 22 November 2016 11:25 PM, Thierry Reding wrote:
> +static inline struct tegra_gpio *to_tegra_gpio(struct gpio_chip *chip)
> +{
> +	return container_of(chip, struct tegra_gpio, gpio);
> +}

You dont need this as gpiochip_get_data(chip); can provide the required 
driver specific data.

> +
> +static const struct tegra_gpio_port *
> +tegra186_gpio_get_port(struct tegra_gpio *gpio, unsigned int *pin)
> +{
> +	unsigned int start = 0, i;
> +
> +	for (i = 0; i < gpio->soc->num_ports; i++) {
> +		const struct tegra_gpio_port *port = &gpio->soc->ports[i];
> +
> +		if (*pin >= start && *pin < start + port->pins) {
> +			*pin -= start;
> +			return port;
> +		}
> +
> +		start += port->pins;
> +	}
> +
Why not get the port from pins and then calculate with fixed offset.
We will not need the loop if we know the port number.

>
> +
> +static int tegra186_gpio_direction_output(struct gpio_chip *chip,
> +					  unsigned int offset, int level)
> +{
> +	struct tegra_gpio *gpio = to_tegra_gpio(chip);
> +	void __iomem *base;
> +	u32 value;
> +
> +	/* configure output level first */
> +	chip->set(chip, offset, level);
We can directly call the apis instead of function pointer at this point.
>
> +
> +static struct lock_class_key tegra186_gpio_lock_class;
We will have two instance of the driver (normal and AON) and so this 
will be shared between them.
Do we really support multiple instance with same variable?


> +
> +	gpio->gpio.label = "tegra186-gpio";
Two instance will have same name. Better to say tegra186-gpio and 
tegra186-gpio-aon.


> +	gpio->gpio.parent = &pdev->dev;
> +
> +	gpio->gpio.get_direction = tegra186_gpio_get_direction;
> +	gpio->gpio.direction_input = tegra186_gpio_direction_input;
> +	gpio->gpio.direction_output = tegra186_gpio_direction_output;
> +	gpio->gpio.get = tegra186_gpio_get,
> +	gpio->gpio.set = tegra186_gpio_set;
> +	gpio->gpio.to_irq = tegra186_gpio_to_irq;
> +
> +	gpio->gpio.base = -1;
> +
> +	for (i = 0; i < gpio->soc->num_ports; i++)
> +		gpio->gpio.ngpio += gpio->soc->ports[i].pins;
> +

Our DT binding does not say this. We assume that we have 8 gpios per 
port. so this will not work at all.



>
> +
> +static const struct tegra_gpio_port tegra186_main_ports[] = {
> +	[TEGRA_MAIN_GPIO_PORT_A]  = { 0x2000, 7 },
Use C99 style initialization which is like
    .offset =
    .pins =
>


WARNING: multiple messages have this Message-ID (diff)
From: Laxman Dewangan <ldewangan@nvidia.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	"Suresh Mangipudi" <smangipudi@nvidia.com>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	<linux-kernel@vger.kernel.org>, <linux-gpio@vger.kernel.org>,
	<linux-tegra@vger.kernel.org>
Subject: Re: [PATCH] gpio: Add Tegra186 support
Date: Thu, 24 Nov 2016 12:23:56 +0530	[thread overview]
Message-ID: <58368E84.6040104@nvidia.com> (raw)
In-Reply-To: <20161122175539.3897-1-thierry.reding@gmail.com>


On Tuesday 22 November 2016 11:25 PM, Thierry Reding wrote:
> +static inline struct tegra_gpio *to_tegra_gpio(struct gpio_chip *chip)
> +{
> +	return container_of(chip, struct tegra_gpio, gpio);
> +}

You dont need this as gpiochip_get_data(chip); can provide the required 
driver specific data.

> +
> +static const struct tegra_gpio_port *
> +tegra186_gpio_get_port(struct tegra_gpio *gpio, unsigned int *pin)
> +{
> +	unsigned int start = 0, i;
> +
> +	for (i = 0; i < gpio->soc->num_ports; i++) {
> +		const struct tegra_gpio_port *port = &gpio->soc->ports[i];
> +
> +		if (*pin >= start && *pin < start + port->pins) {
> +			*pin -= start;
> +			return port;
> +		}
> +
> +		start += port->pins;
> +	}
> +
Why not get the port from pins and then calculate with fixed offset.
We will not need the loop if we know the port number.

>
> +
> +static int tegra186_gpio_direction_output(struct gpio_chip *chip,
> +					  unsigned int offset, int level)
> +{
> +	struct tegra_gpio *gpio = to_tegra_gpio(chip);
> +	void __iomem *base;
> +	u32 value;
> +
> +	/* configure output level first */
> +	chip->set(chip, offset, level);
We can directly call the apis instead of function pointer at this point.
>
> +
> +static struct lock_class_key tegra186_gpio_lock_class;
We will have two instance of the driver (normal and AON) and so this 
will be shared between them.
Do we really support multiple instance with same variable?


> +
> +	gpio->gpio.label = "tegra186-gpio";
Two instance will have same name. Better to say tegra186-gpio and 
tegra186-gpio-aon.


> +	gpio->gpio.parent = &pdev->dev;
> +
> +	gpio->gpio.get_direction = tegra186_gpio_get_direction;
> +	gpio->gpio.direction_input = tegra186_gpio_direction_input;
> +	gpio->gpio.direction_output = tegra186_gpio_direction_output;
> +	gpio->gpio.get = tegra186_gpio_get,
> +	gpio->gpio.set = tegra186_gpio_set;
> +	gpio->gpio.to_irq = tegra186_gpio_to_irq;
> +
> +	gpio->gpio.base = -1;
> +
> +	for (i = 0; i < gpio->soc->num_ports; i++)
> +		gpio->gpio.ngpio += gpio->soc->ports[i].pins;
> +

Our DT binding does not say this. We assume that we have 8 gpios per 
port. so this will not work at all.



>
> +
> +static const struct tegra_gpio_port tegra186_main_ports[] = {
> +	[TEGRA_MAIN_GPIO_PORT_A]  = { 0x2000, 7 },
Use C99 style initialization which is like
    .offset =
    .pins =
>

  parent reply	other threads:[~2016-11-24  7:13 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 10:48 [PATCH] gpio: tegra186: Add support for T186 GPIO Suresh Mangipudi
2016-11-02 10:48 ` Suresh Mangipudi
2016-11-07  7:53 ` Linus Walleij
2016-11-07 13:21   ` Thierry Reding
     [not found]     ` <20161107132127.GE12559-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-11-08  1:42       ` Olof Johansson
2016-11-08  1:42         ` Olof Johansson
     [not found]         ` <CAOesGMgJUepmq2JTT7imKh74BsnGobcpBWFuNp94WnX1WtzEjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-08 15:55           ` Thierry Reding
2016-11-08 15:55             ` Thierry Reding
2016-11-08 16:49             ` Stephen Warren
     [not found]               ` <08947785-2e7f-0117-2392-b6b1a774bbb8-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2016-11-08 17:58                 ` Thierry Reding
2016-11-08 17:58                   ` Thierry Reding
     [not found] ` <1478083719-14836-1-git-send-email-smangipudi-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-11-08 19:07   ` Stephen Warren
2016-11-08 19:07     ` Stephen Warren
2016-11-22 17:30     ` Thierry Reding
2016-11-22 17:55       ` [PATCH] gpio: Add Tegra186 support Thierry Reding
     [not found]         ` <20161122175539.3897-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-23 13:30           ` Linus Walleij
2016-11-23 13:30             ` Linus Walleij
2016-11-23 19:44             ` Thierry Reding
2016-11-24 15:40               ` Linus Walleij
2016-11-24  6:53         ` Laxman Dewangan [this message]
2016-11-24  6:53           ` Laxman Dewangan
     [not found]           ` <58368E84.6040104-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-11-24 14:44             ` Thierry Reding
2016-11-24 14:44               ` Thierry Reding
     [not found]               ` <20161124144411.GA26657-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-11-24 14:44                 ` Laxman Dewangan
2016-11-24 14:44                   ` Laxman Dewangan
2016-11-24 15:08                   ` Thierry Reding
     [not found]                     ` <20161124150841.GC26657-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-11-25 12:10                       ` Laxman Dewangan
2016-11-25 12:10                         ` Laxman Dewangan
     [not found]       ` <20161122173042.GA3239-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-11-23 13:25         ` [PATCH] gpio: tegra186: Add support for T186 GPIO Linus Walleij
2016-11-23 13:25           ` Linus Walleij
     [not found]           ` <CACRpkdbfkv7Yt3cOah_BGcgnqVtxvzWOqm2+HH_rkrpnJt0nFA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-23 19:40             ` Thierry Reding
2016-11-23 19:40               ` Thierry Reding
     [not found]               ` <20161123194036.GA25876-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-11-24  6:36                 ` Laxman Dewangan
2016-11-24  6:36                   ` Laxman Dewangan
2016-11-24 15:01                   ` Thierry Reding
2016-11-24 15:08                 ` Linus Walleij
2016-11-24 15:08                   ` Linus Walleij
2016-11-24 16:32                   ` Thierry Reding
     [not found]                     ` <20161124163231.GD26657-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-11-24 23:24                       ` Linus Walleij
2016-11-24 23:24                         ` Linus Walleij

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=58368E84.6040104@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=smangipudi@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@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.