lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 11 Mar 2021 18:56:46 +0100
From:   Pavel Machek <pavel@....cz>
To:     Hermes Zhang <chenhui.zhang@...s.com>
Cc:     Dan Murphy <dmurphy@...com>, kernel@...s.com,
        Hermes Zhang <chenhuiz@...s.com>, linux-kernel@...r.kernel.org,
        linux-leds@...r.kernel.org
Subject: Re: [PATCH] leds: leds-dual-gpio: Add dual GPIO LEDs driver

Hi!


> From: Hermes Zhang <chenhuiz@...s.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

Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ