linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Hermes Zhang <chenhui.zhang@axis.com>
Cc: Dan Murphy <dmurphy@ti.com>,
	kernel@axis.com, Hermes Zhang <chenhuiz@axis.com>,
	linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org
Subject: Re: [PATCH] leds: leds-dual-gpio: Add dual GPIO LEDs driver
Date: Thu, 11 Mar 2021 18:56:46 +0100	[thread overview]
Message-ID: <20210311175646.GA11088@duo.ucw.cz> (raw)
In-Reply-To: <20210311130408.10820-1-chenhui.zhang@axis.com>

[-- Attachment #1: Type: text/plain, Size: 2141 bytes --]

Hi!


> From: Hermes Zhang <chenhuiz@axis.com>
> 
> Introduce a new Dual GPIO LED driver. These two GPIOs LED will act as
> one LED as normal GPIO LED but give the possibility to change the
> intensity in four levels: OFF, LOW, MIDDLE and HIGH.

Do you have hardware that uses it?

Seems reasonably sane, but:

> +config LEDS_DUAL_GPIO
> +	tristate "LED Support for Dual GPIO connected LEDs"
> +	depends on LEDS_CLASS
> +	depends on GPIOLIB || COMPILE_TEST

This will break compile, right?

Describe which hardware needs it in Kconfig.

> index 2a698df9da57..10015cc81f79 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile

Put it into leds/simple . You may need to create it.

No dts bindings etc?

> +#define GPIO_LOGICAL_ON   1
> +#define GPIO_LOGICAL_OFF  0

Let's not do that.

> +	priv = container_of(led_cdev, struct gpio_dual_leds_priv, cdev);
> +
> +	if (value == LED_FULL) {
> +		gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_ON);
> +		gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_ON);
> +	} else if (value < LED_FULL && value > LED_HALF) {
> +		/* Enable high only */
> +		gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_OFF);
> +		gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_ON);
> +	} else if (value <= LED_HALF && value > LED_OFF) {
> +		/* Enable low only */
> +		gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_ON);
> +		gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_OFF);
> +	} else {
> +		gpiod_set_value(priv->low_gpio, GPIO_LOGICAL_OFF);
> +		gpiod_set_value(priv->high_gpio, GPIO_LOGICAL_OFF);
> +	}
> +}

Make max brightness 4 and use logical operations to set the right
values.

> +	priv->cdev.name = of_get_property(node, "label", NULL);
> +	priv->cdev.max_brightness = LED_FULL;

= 3.


> +static const struct of_device_id of_gpio_dual_leds_match[] = {
> +	{ .compatible = "gpio-dual-leds", },

Need dts docs for this.


> +MODULE_DESCRIPTION("Dual GPIO LED driver");
> +MODULE_LICENSE("GPL v2");

MODULE_AUTHOR?

GPL v2+ if you can do that easily.

Best regards,
								Pavel

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  parent reply	other threads:[~2021-03-11 17:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 13:04 [PATCH] leds: leds-dual-gpio: Add dual GPIO LEDs driver Hermes Zhang
2021-03-11 15:38 ` Marek Behun
2021-03-11 15:39   ` Marek Behun
2021-03-12  4:48     ` Hermes Zhang
2021-03-12  5:59       ` Marek Behun
2021-03-11 17:56 ` Pavel Machek [this message]
2021-03-11 18:02 ` Pavel Machek
2021-03-18  2:11   ` Hermes Zhang
2021-03-12  8:31 ` Alexander Dahl
2021-03-12  8:48   ` Hermes Zhang
2021-03-12  9:03     ` Marek Behun

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=20210311175646.GA11088@duo.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=chenhui.zhang@axis.com \
    --cc=chenhuiz@axis.com \
    --cc=dmurphy@ti.com \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).