Hi! > From: Hermes Zhang <chenhuiz@xxxxxxxx> > > 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:
signature.asc
Description: PGP signature