Linux-LEDs Archive on lore.kernel.org
 help / color / Atom feed
From: Dan Murphy <dmurphy@ti.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Pavel Machek <pavel@ucw.cz>
Cc: <linux-leds@vger.kernel.org>, Kim Kyuwon <chammoru@gmail.com>
Subject: Re: [PATCH] leds: bd2802: Convert to use GPIO descriptors
Date: Tue, 3 Dec 2019 06:41:19 -0600
Message-ID: <01c5b357-549b-060a-4bc7-724b8f7479ed@ti.com> (raw)
In-Reply-To: <20191203095908.52926-1-linus.walleij@linaro.org>

Linus

On 12/3/19 3:59 AM, Linus Walleij wrote:
> The Rohm BD2802 have no in-kernel users so we can drop the
> GPIO number from the platform data and require users to
> provide the GPIO line using machine descriptors.
>
> As the descriptors come with inherent polarity inversion
> semantics, we invert the calls to set the GPIO line such
> that 0 means "unasserted" and 1 means "asserted".
>
> Put a note in the driver that machine descriptor tables
> will need to specify that the line is active low.
>
> Cc: Kim Kyuwon <chammoru@gmail.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>   drivers/leds/leds-bd2802.c  | 27 ++++++++++++++++++---------
>   include/linux/leds-bd2802.h |  1 -
>   2 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/leds/leds-bd2802.c b/drivers/leds/leds-bd2802.c
> index e7ec6bff2b5f..d551f7434897 100644
> --- a/drivers/leds/leds-bd2802.c
> +++ b/drivers/leds/leds-bd2802.c
> @@ -10,7 +10,7 @@
>   
>   #include <linux/module.h>
>   #include <linux/i2c.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
>   #include <linux/delay.h>
>   #include <linux/leds.h>
>   #include <linux/leds-bd2802.h>
> @@ -67,6 +67,7 @@ struct led_state {
>   struct bd2802_led {
>   	struct bd2802_led_platform_data	*pdata;
>   	struct i2c_client		*client;
> +	struct gpio_desc		*reset;
>   	struct rw_semaphore		rwsem;
>   
>   	struct led_state		led[2];
> @@ -200,7 +201,7 @@ static void bd2802_update_state(struct bd2802_led *led, enum led_ids id,
>   		return;
>   
>   	if (bd2802_is_all_off(led) && !led->adf_on) {
> -		gpio_set_value(led->pdata->reset_gpio, 0);
> +		gpiod_set_value(led->reset, 1);
>   		return;
>   	}
>   
> @@ -226,7 +227,7 @@ static void bd2802_configure(struct bd2802_led *led)
>   
>   static void bd2802_reset_cancel(struct bd2802_led *led)
>   {
> -	gpio_set_value(led->pdata->reset_gpio, 1);
> +	gpiod_set_value(led->reset, 0);
>   	udelay(100);
>   	bd2802_configure(led);
>   }
> @@ -420,7 +421,7 @@ static void bd2802_disable_adv_conf(struct bd2802_led *led)
>   						bd2802_addr_attributes[i]);
>   
>   	if (bd2802_is_all_off(led))
> -		gpio_set_value(led->pdata->reset_gpio, 0);
> +		gpiod_set_value(led->reset, 1);
>   
>   	led->adf_on = 0;
>   }
> @@ -670,8 +671,16 @@ static int bd2802_probe(struct i2c_client *client,
>   	pdata = led->pdata = dev_get_platdata(&client->dev);
>   	i2c_set_clientdata(client, led);
>   
> -	/* Configure RESET GPIO (L: RESET, H: RESET cancel) */
> -	gpio_request_one(pdata->reset_gpio, GPIOF_OUT_INIT_HIGH, "RGB_RESETB");
> +	/*
> +	 * Configure RESET GPIO (L: RESET, H: RESET cancel)
> +	 *
> +	 * We request the reset GPIO as OUT_LOW which means de-asserted,
> +	 * board files specifying this GPIO line in a machine descriptor
> +	 * table should take care to specify GPIO_ACTIVE_LOW for this line.
> +	 */
> +	led->reset = devm_gpiod_get(&client->dev, "rgb-resetb", GPIOD_OUT_LOW);

We usually use "reset" for the property of the reset-gpios.

Unless there are other reset lines for this chip or you are keeping the 
name for compatibiilty

Dan



      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03  9:59 Linus Walleij
2019-12-03 12:41 ` Dan Murphy [this message]

Reply instructions:

You may reply publically 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=01c5b357-549b-060a-4bc7-724b8f7479ed@ti.com \
    --to=dmurphy@ti.com \
    --cc=chammoru@gmail.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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

Linux-LEDs Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-leds/0 linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ https://lore.kernel.org/linux-leds \
		linux-leds@vger.kernel.org
	public-inbox-index linux-leds

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-leds


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git