History log of /linux-master/drivers/leds/leds-gpio.c
Revision Date Author Comments
# e7431bd7 02-Dec-2023 Stefan Wahren <wahrenst@gmx.net>

leds: gpio: Add kernel log if devm_fwnode_gpiod_get() fails

In case leds-gpio fails to get at least one of possibly many GPIOs
from the DT (e.g. the GPIO is already requested) neither gpiolib nor
the driver does provide any helpful error log:

leds-gpio: probe of leds failed with error -16

As the driver knows better how to handle errors with such mandatory
GPIOs, let's implement an error log which points to the affected
GPIO.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20231202183636.7055-1-wahrenst@gmx.net
Signed-off-by: Lee Jones <lee@kernel.org>


# 2038d3fd 16-Oct-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

leds: gpio: Update headers

Include headers which we are direct users of, no need
to have proxies.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>


# 7b2d8a05 16-Oct-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

leds: gpio: Remove unneeded assignment

The initial ret is not used anywhere, drop the unneeded assignment.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>


# 54e657d6 16-Oct-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

leds: gpio: Move temporary variable for struct device to gpio_led_probe()

Use temporary variable for struct device in gpio_led_probe() in order
to make code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>


# 5ac50ec7 16-Oct-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

leds: gpio: Refactor code to use devm_gpiod_get_index_optional()

Instead of checking for the specific error codes, replace
devm_gpiod_get_index() with devm_gpiod_get_index_optional().
In this case we just return all errors to the caller and
simply check for NULL in case if legacy GPIO is being used.
As the result the code is easier to read and maintain.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>


# f5ad594e 16-Oct-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

leds: gpio: Utilise PTR_ERR_OR_ZERO()

Avoid a boilerplate code by using PTR_ERR_OR_ZERO() in create_gpio_led().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>


# e80fc4bf 16-Oct-2023 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

leds: gpio: Keep driver firmware interface agnostic

The of.h is used as a proxy to mod_devicetable, replace former by
latter.

The commit 2d6180147e92 ("leds: gpio: Configure per-LED pin control")
added yet another unneeded OF APIs. Replace with direct use of fwnode.

Altogether this makes driver agnostic to the firmware interface in use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231016161005.1471768-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>


# 52cd7510 15-Sep-2023 Kees Cook <keescook@chromium.org>

leds: gpio: Annotate struct gpio_leds_priv with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct gpio_leds_priv.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20230915201003.never.148-kees@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>


# 2d618014 23-May-2023 Marek Vasut <marex@denx.de>

leds: gpio: Configure per-LED pin control

Each gpio-leds DT node DT subnode can have a pinctrl property assigned
to it, parse the DT subnode pinctrl properties and configure each pin
accordingly.

Tested-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20230523183151.5460-1-marex@denx.de
Signed-off-by: Lee Jones <lee@kernel.org>


# a055204b 02-Sep-2022 Dmitry Torokhov <dmitry.torokhov@gmail.com>

leds: gpio: switch to using devm_fwnode_gpiod_get()

devm_fwnode_get_gpiod_from_child() is going away as the name is too
unwieldy, let's switch to using the new devm_fwnode_gpiod_get().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


# 791bc411 08-Jun-2021 Denis Osterland-Heim <Denis.Osterland@diehl.com>

leds: move default_state read from fwnode to core

This patch introduces a new function to read initial
default_state from fwnode.

Suggested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# d8646452 29-Dec-2020 Dylan Van Assche <me@dylanvanassche.be>

leds: gpio: Set max brightness to 1

GPIO LEDs only know 2 states: ON or OFF and do not have PWM capabilities.
However, the max brightness is reported as 255.

This patch sets the max brightness value of a GPIO controlled LED to 1.

Tested on my PinePhone 1.2.

Signed-off-by: Dylan Van Assche <me@dylanvanassche.be>
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# c49d6cab 19-Sep-2020 Marek Behún <marek.behun@nic.cz>

leds: parse linux,default-trigger DT property in LED core

Do the parsing of `linux,default-trigger` DT property to LED core.
Currently it is done in many different drivers and the code is repeated.

This patch removes the parsing from 23 drivers:
an30259a, aw2013, bcm6328, bcm6358, cr0014114, el15203000, gpio,
is31fl32xx, lm3532, lm36274, lm3692x, lm3697, lp50xx, lp8860, lt3593,
max77650, mt6323, ns2, pm8058, pwm, syscon, tlc591xx and turris-omnia.

There is one driver in drivers/input which parses this property on it's
own. I shall send a separate patch there after this is applied.

There are still 8 drivers that parse this property on their own because
they do not pass the led_init_data structure to the registering
function. I will try to refactor those in the future.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# cf1a1a6a 19-Jun-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

leds: gpio: Use struct_size() in devm_kzalloc()

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes. Also, remove unnecessary
function sizeof_gpio_leds_priv().

This code was detected with the help of Coccinelle and, audited and
fixed manually.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# c4e94413 03-Jul-2020 Linus Walleij <linus.walleij@linaro.org>

leds: gpio: Fix semantic error

The leds-gpio driver mixes up the legacy GPIO flags with the
GPIO descriptor flags and passes a legacy flag to
devm_gpiod_get_index().

Fix this by replacing the flags variable with the strict
descriptor flag.

Fixes: 45d4c6de4e49 ("leds: gpio: Try to lookup gpiod from device")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# 90a8e82d 05-Dec-2019 Jacek Anaszewski <jacek.anaszewski@gmail.com>

leds: gpio: Fix uninitialized gpio label for fwnode based probe

When switching to using generic LED name composition mechanism via
devm_led_classdev_register_ext() API the part of code initializing
struct gpio_led's template name property was removed alongside.
It was however overlooked that the property was also passed to
devm_fwnode_get_gpiod_from_child() in place of "label" parameter,
which when set to NULL, results in gpio label being initialized to '?'.

It could be observed in debugfs and failed to properly identify
gpio association with LED consumer.

Fix this shortcoming by updating the GPIO label after the LED is
registered and its final name is known.

Fixes: d7235f5feaa0 ("leds: gpio: Use generic support for composing LED names")
Cc: Russell King <linux@armlinux.org.uk>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
[fixed comment]
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# 8e8d699b 05-Dec-2019 Jacek Anaszewski <jacek.anaszewski@gmail.com>

leds: gpio: Fix uninitialized gpio label for fwnode based probe

When switching to using generic LED name composition mechanism via
devm_led_classdev_register_ext() API the part of code initializing
struct gpio_led's template name property was removed alongside.
It was however overlooked that the property was also passed to
devm_fwnode_get_gpiod_from_child() in place of "label" parameter,
which when set to NULL, results in gpio label being initialized to '?'.

It could be observed in debugfs and failed to properly identify
gpio association with LED consumer.

Fix this shortcoming by updating the GPIO label after the LED is
registered and its final name is known.

Fixes: d7235f5feaa0 ("leds: gpio: Use generic support for composing LED names")
Cc: Russell King <linux@armlinux.org.uk>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
[fixed comment]
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# d7235f5f 09-Jun-2019 Jacek Anaszewski <jacek.anaszewski@gmail.com>

leds: gpio: Use generic support for composing LED names

Switch to using generic LED support for composing LED class
device name.

Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Pavel Machek <pavel@ucw.cz>


# b2b998c0 09-Jun-2019 Jacek Anaszewski <jacek.anaszewski@gmail.com>

leds: class: Improve LED and LED flash class registration API

Replace of_led_classdev_register() with led_classdev_register_ext(), which
accepts easily extendable struct led_init_data, instead of the fixed
struct device_node argument. The latter can be now passed in an fwnode
property of the struct led_init_data.

The modification is driven by the need for passing additional arguments
required for the forthcoming generic mechanism for composing LED names.
Currently the LED name is conveyed in the "name" char pointer property of
the struct led_classdev. This is redundant since LED class device name
is accessible throughout the whole LED class device life time via
associated struct device's kobj->name property.

The change will not break any existing clients since the patch alters
also existing led_classdev{_flash}_register() macro wrappers, that pass
NULL in place of init_data, which leads to using legacy name
initialization path basing on the struct led_classdev's "name" property.

Three existing users of devm_of_led_classdev_registers() are modified
to use devm_led_classdev_register(), which will not impact their
operation since they in fact didn't need to pass struct device_node on
registration from the beginning.

Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Baolin Wang <baolin.wang@linaro.org>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: Daniel Mack <daniel@zonque.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Oleh Kravchenko <oleg@kaa.org.ua>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Simon Shields <simon@lineageos.org>
Acked-by: Pavel Machek <pavel@ucw.cz>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b086592e 07-Dec-2018 Krzysztof Kozlowski <krzk@kernel.org>

leds: gpio: Drop unneeded manual of_node assignment

This reverts the main change of commit bff23714bc36 ("leds: leds-gpio:
Set of_node for created LED devices") because of_node assignment is
handled by core since commit 7ea79ae86c28 ("leds: gpio: use OF variant
of LED registering function"). Basically the code was overwriting the
of_node with same value.

No functional change expected.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


# 72b8ad40 17-Oct-2018 Liviu Dudau <liviu@dudau.co.uk>

leds: gpio: set led_dat->gpiod pointer for OF defined GPIO leds

Commit 45d4c6de4e49 ("leds: gpio: Try to lookup gpiod from device")
removed the common code path that set the led_dat->gpiod pointer in
create_gpio_led(), but only added it back for the devices that have
a valid gpio_led_platform_data structure. Calling gpio_leds_create()
in gpio_led_probe() is not enough to get a valid gpiod pointer.

Fortunately enough, gpio_leds_create() already gets the needed pointer,
we just need to assign it to the relevant gpio_led_data structure.

Fixes: 45d4c6de4e49 ("leds: gpio: Try to lookup gpiod from device")
Signed-off-by: Liviu Dudau <liviu@dudau.co.uk>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


# 45d4c6de 06-Sep-2018 Linus Walleij <linus.walleij@linaro.org>

leds: gpio: Try to lookup gpiod from device

This augments the GPIO lookup code in the GPIO LEDs to
attempt to look up a GPIO descriptor from the device with
index.

This makes it possible to use GPIO machine look-up tables
and stop passing global GPIO numbers through platform data.

Using this we can stepwise convert existing board files
to use machine descriptor tables and then eventually drop
the legacy GPIO support and only include
<linux/gpio/consumer.h> and use descriptors exclusively.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


# f5808ac1 27-Aug-2017 Andrew Jeffery <andrew@aj.id.au>

leds: gpio: Allow LED to retain state at shutdown

In some systems, such as Baseboard Management Controllers (BMCs), we
want to retain the state of LEDs across a reboot of the BMC (whilst the
host remains up). Implement support for the retain-state-shutdown
devicetree property in leds-gpio.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Acked-by: Pavel Machek <pavel@ucw.cz>
Tested-by: Brandon Wyman <bjwyman@gmail.com>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


# 7ea79ae8 05-Mar-2017 Rafał Miłecki <rafal@milecki.pl>

leds: gpio: use OF variant of LED registering function

In leds-gpio we support LEDs specified in DT so we should use
(devm_)of_led_classdev_register. This allows passing DT node as argument
for use by the LED subsystem.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


# 4b094797 02-Feb-2017 Boris Brezillon <bbrezillon@kernel.org>

gpio: Rename devm_get_gpiod_from_child()

Rename devm_get_gpiod_from_child() into
devm_fwnode_get_gpiod_from_child() to reflect the fact that this
function is operating on a fwnode object.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# b2987d74 12-Jan-2017 Alexander Stein <alexander.stein@systec-electronic.com>

gpio: Pass GPIO label down to gpiod_request

Currently all users of fwnode_get_named_gpiod() have no way to
specify a label for the GPIO. So GPIOs listed in debugfs are shown
with label "?". With this change a proper label is used.

Also adjust all users so they can pass a label, properly retrieved
from device tree properties.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# a264d10f 09-Jan-2017 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

gpiolib: Convert fwnode_get_named_gpiod() to configure GPIO

Make fwnode_get_named_gpiod() consistent with the rest of
gpiod_get() like API, i.e. configure GPIO pin immediately after
request.

Besides obvious clean up it will help to configure pins based
on firmware provided resources.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# 74b69e52 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: fix and simplify error handling in gpio_leds_create

Simplify the error handling and add a missing call to fwnode_handle_put
when checking led.name.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# bc2c0dd8 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: switch to managed version of led_classdev_register

Using the managed version of led_classdev_register allows to
significantly simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# bec69de8 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: fix and simplify reading property "label"

Checking for the presence of the property first isn't strictly needed
as we can react on the return code of fwnode_property_read_string.
Also, even if the presence of a property "label" was checked,
reading a string value for it theoretically still can fail and
this case isn't handled.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 8ca03da5 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: simplify gpio_leds_create

Definition of np can be moved into the loop as well to simplify
the code a little.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 45808094 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: add helper cdev_to_gpio_led_data

Add a helper for the container_of as it's used more than once.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 061b5c1d 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: fix an unhandled error case in create_gpio_led

gpiod_get_value_cansleep returns 0, 1, or an error code.
So far errors are not handled and treated the same as 1.
Change this to bail out if an error code is returned and
remove the double negation.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 68620e59 14-Sep-2016 Heiner Kallweit <hkallweit1@gmail.com>

leds: gpio: introduce gpio_blink_set_t

Introduce a typedef gpio_blink_set_t to improve readability of the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# bff23714 08-Jul-2016 Rafał Miłecki <zajec5@gmail.com>

leds: leds-gpio: Set of_node for created LED devices

When working with Device Tree we iterate over children of "gpio-leds"
compatible node and create LED device for each of them. We take care of
all common DT properties (label, default trigger, state, etc.), however
some triggers may want to support more of them.

It could be useful for timer trigger to support setting delay on/off
values with Device Tree property. Or for transient trigger to support
e.g. duration property.

We obviously should handle such properties in triggers, not in generic
code. To let trigger drivers read properties from DT node we need to set
of_node to point the relevant node. This change allows using all kind of
of helpers in e.g. "activate" callbacks.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 80d6737b 28-Apr-2016 Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

leds: gpio: Support the "panic-indicator" firmware property

Calling a GPIO LEDs is quite likely to work even if the kernel
has paniced, so they are ideal to blink in this situation.
This commit adds support for the new "panic-indicator"
firmware property, allowing to mark a given LED to blink on
a kernel panic.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# eae7c98a 19-Feb-2016 Geert Uytterhoeven <geert+renesas@glider.be>

leds: gpio: Use GPIOF_OUT_INIT_LOW instead of hardcoded zero

Use the GPIO flag definition instead of a numeric literal, so the casual
reader grepping for GPIOF_ will find the GPIO flags used.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 2d88a331 06-Feb-2016 Wei Yongjun <yongjun_wei@trendmicro.com.cn>

leds: leds-gpio: Fix return value check in create_gpio_led()

In case of error, the function gpio_to_desc() returns NULL
pointer not ERR_PTR(). The IS_ERR() test in the return value
check should be replaced with NULL test.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# d5b8a090 20-Aug-2015 Jacek Anaszewski <j.anaszewski@samsung.com>

leds: gpio: Remove work queue

Now the core implements the work queue, remove it from the drivers,
and switch to using brightness_set_blocking op.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Raphael Assenat <raph@8d.com>


# 707f33ed 12-Oct-2015 Heiko Schocher <hs@denx.de>

leds: leds-gpio: add shutdown function

add a shutdown function for setting the gpio-leds
into off state when shuting down.

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# c181fb3e 22-Jun-2015 Alexander Sverdlin <alexander.sverdlin@gmail.com>

ACPI / OF: Rename of_node() and acpi_node() to to_of_node() and to_acpi_node()

Commit 8a0662d9 introduced of_node and acpi_node symbols in global namespace
but there were already ~63 of_node local variables or function parameters
(no single acpi_node though, but anyway).

After debugging undefined but used of_node local varible (which turned out
to reference static function of_node() instead) it became clear that the names
for the functions are too short and too generic for global scope.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 403097f7 07-May-2015 Geert Uytterhoeven <geert@linux-m68k.org>

leds: leds-gpio: Add missing #include <linux/of.h>

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 0e14e0bf 16-Apr-2015 Jacek Anaszewski <j.anaszewski@samsung.com>

leds: gpio: Fix error handling for led name null pointer case

Make sure that already registered LEDs will be torn down properly
if the name of the next LED to create is unavailable.

Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 65c6b7e3 14-Apr-2015 Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

leds: gpio: Fix device teardown on probe deferral

In gpio_leds_create(), when devm_get_gpiod_from_child() fails with
-EPROBE_DEFER on the second gpio led to be created, the first already
registered led is not torn down properly. This causes create_gpio_led()
to fail for the first led on re-probe().

Fix this misbehaviour by incrementing num_leds only if all
potentially failing calls completed successfully.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 1feb57a2 21-Jan-2015 Olliver Schinagl <oliver@schinagl.nl>

gpio: add parameter to allow the use named gpios

The gpio binding document says that new code should always use named
gpios. Patch 40b73183 added support to parse a list of gpios from child
nodes, but does not make it possible to use named gpios. This patch adds
the con_id property and implements it is done in gpiolib.c, where the
old-style of using unnamed gpios still works.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Acked-by: Bryan Wu <cooloney@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


# c6e71f81 31-Jan-2015 Soren Brinkmann <soren.brinkmann@xilinx.com>

leds: leds-gpio: Pass on error codes unmodified

Instead of overriding error codes, pass them on unmodified. This
way a EPROBE_DEFER is correctly passed to the driver core. This results
in the LED driver correctly requesting probe deferral in cases the GPIO
controller is not yet available.

Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Reported-and-tested-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# d735d25e 09-Dec-2014 Fabio Estevam <fabio.estevam@freescale.com>

leds: leds-gpio: Fix the "default-state" property check

Commit a43f2cbbb009f9 ("leds: leds-gpio: Make use of device property API")
caused a regression by reading the incorrect string for the "default-state"
property.

Fix the property string check to restore the original behaviour.

Fixes: a43f2cbbb009 (leds: leds-gpio: Make use of device property API)
Reported-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 29470ea8 03-Dec-2014 Fabio Estevam <fabio.estevam@freescale.com>

leds: leds-gpio: Fix multiple instances registration without 'label' property

Since commit a43f2cbbb009f96 ("leds: leds-gpio: Make use of device property
API") it is no longer possible to register multiple gpio leds without passing
the 'label' property.

According to Documentation/devicetree/bindings/leds/common.txt:

"Optional properties for child nodes:
- label : The label for this LED. If omitted, the label is
taken from the node name (excluding the unit address)."

So retrieve the node name when the 'label' property is absent to keep the old
behaviour and fix this regression.

Fixes: a43f2cbbb009 (leds: leds-gpio: Make use of device property API)
Reported-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
Acked-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# ec98a497 05-Nov-2014 Geert Uytterhoeven <geert+renesas@glider.be>

leds: leds-gpio: Fix legacy GPIO number case

In the legacy case, led_dat->gpiod is initialized correctly, but
overwritten later by template->gpiod, which is NULL, causing leds-gpio
to fail with:

gpiod_direction_output: invalid GPIO
leds-gpio: probe of leds-gpio failed with error -22

Move the initialization of led_dat->gpiod from template->gpiod up, and
always use led_dat->gpiod later, to fix this.

Fixes: 5c51277a9ababfa4 (leds: leds-gpio: Add support for GPIO descriptors)
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# c673a2b4 31-Oct-2014 Mika Westerberg <mika.westerberg@linux.intel.com>

leds: leds-gpio: Convert gpio_blink_set() to use GPIO descriptors

Commit 21f2aae91e902aad ("leds: leds-gpio: Add support for GPIO
descriptors") already converted most of the driver to use GPIO descriptors.
What is still missing is the platform specific hook gpio_blink_set() and
board files which pass legacy GPIO numbers to this driver in platform data.

In this patch we handle the former and convert gpio_blink_set() to take
GPIO descriptor instead. In order to do this we convert the existing four
users to accept GPIO descriptor and translate it to legacy GPIO number in
the platform code. This effectively "pushes" legacy GPIO number usage from
the driver to platforms.

Also add comment to the remaining block describing that it is legacy code
path and we are getting rid of it eventually.

Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# a43f2cbb 27-Oct-2014 Rafael J. Wysocki <rafael.j.wysocki@intel.com>

leds: leds-gpio: Make use of device property API

Make use of device property API in this driver so that both OF and ACPI
based system can use the same driver.

This change contains material from Max Eliaser and Mika Westerberg.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Bryan Wu <cooloney@gmail.com>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 5c51277a 27-Oct-2014 Mika Westerberg <mika.westerberg@linux.intel.com>

leds: leds-gpio: Add support for GPIO descriptors

GPIO descriptors are the preferred way over legacy GPIO numbers
nowadays. Convert the driver to use GPIO descriptors internally but
still allow passing legacy GPIO numbers from platform data to support
existing platforms.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Bryan Wu <cooloney@gmail.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Grant Likely <grant.likely@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 81902d5f 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

leds: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# a4c84e6a 28-Sep-2014 Xiubo Li <Li.Xiubo@freescale.com>

leds: gpio: cleanup the leds-gpio driver

Remove stray blank line and space.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 4cc72346 28-Sep-2014 Xiubo Li <Li.Xiubo@freescale.com>

led: gpio: Sort include headers alphabetically

If the inlcude headers aren't sorted alphabetically, then the
logical choice is to append new ones, however that creates a
lot of potential for conflicts or duplicates because every change
will then add new includes in the same location.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 472b854b 06-Mar-2014 Paolo Pisati <paolo.pisati@canonical.com>

leds-gpio: of: introduce MODULE_DEVICE_TABLE for module autoloading

Enable autoloading of leds-gpio module when a corresponing DT entry is present.

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 7c7d2a26 21-Jan-2014 Paul Gortmaker <paul.gortmaker@windriver.com>

drivers/leds: delete non-required instances of include <linux/init.h>

None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

Cc: Bryan Wu <cooloney@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 4270a78d 20-Jan-2014 Robin Gong <b38343@freescale.com>

leds: leds-gpio: add retain-state-suspended property

Some gpio-leds need retain the state even in suspend, such as charger led.
But this property missed in devicetree, add it.

(cooloney@gmail.com: fold DT binding updates into this patch)

Signed-off-by: Robin Gong <b38343@freescale.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# b0bb83df 26-Sep-2013 Josh Wu <josh.wu@atmel.com>

leds-gpio: of: led should not be created if its status is disabled

now the leds-gpio driver will create every child led node without
checking the status is disabled or not.

for example, if we have a led node like d3, and its status is disabled:
leds {
d3 {
label = "d3";
gpios = <&pioE 24 0>;
status = "disabled";
};
};

we except the d3 should not be created. And the gpios should not be
request as well.

But current driver will create d3 and request its gpio.

This patch fix this by using for_each_available_child_of_node() and
of_get_available_child_count() to enumerate all child nodes. So the
disabled node will be inavailable.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# c68f46dd 28-Sep-2013 Sachin Kamat <sachin.kamat@linaro.org>

leds: Include linux/of.h header

'of_match_ptr' is defined in linux/of.h. Include it explicitly.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 87aae1ea 30-Jul-2013 Jingoo Han <jg1.han@samsung.com>

leds: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# bfa855ba 20-May-2013 Fabio Estevam <fabio.estevam@freescale.com>

leds: leds-gpio: Let device core handle pinctrl

Since commit ab78029 (drivers/pinctrl: grab default handles from device core)
we can rely on device core for handling pinctrl, so remove
devm_pinctrl_get_select_default() from the driver.

Reported-by: Stephen Warren <warren@wwwdotorg.org>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# d9041d58 03-May-2013 Jingoo Han <jg1.han@samsung.com>

leds: leds-gpio: remove unnecessary platform_set_drvdata()

The driver core clears the driver data to NULL after device_release
or on probe failure, since commit 0998d0631001288a5974afc0b2a5f568bcdecb4d
(device-core: Ensure drvdata = NULL when no driver is bound).
Thus, it is not needed to manually clear the device driver data to NULL.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 803d19d5 17-May-2013 Timo Teräs <timo.teras@iki.fi>

leds: leds-gpio: reserve gpio before using it

This reverts commit a99d76f (leds: leds-gpio: use gpio_request_one)
and commit 2d7c22f (leds: leds-gpio: set devm_gpio_request_one()
flags param correctly) which was a fix of the first one.

The conversion to devm_gpio_request in commit e3b1d44c (leds:
leds-gpio: use devm_gpio_request_one) is not reverted.

The problem is that gpio_cansleep() and gpio_get_value_cansleep()
calls can crash if the gpio is not first reserved. Incidentally this
same bug existed earlier and was fixed similarly in commit d95cbe61
(leds: Fix potential leds-gpio oops). But the OOPS is real. It happens
when GPIOs are provided by module which is not yet loaded.

So this fixes the following BUG during my ALIX boot (3.9.2-vanilla):

BUG: unable to handle kernel NULL pointer dereference at 0000004c
IP: [<c11287d6>] __gpio_cansleep+0xe/0x1a
*pde = 00000000
Oops: 0000 [#1] SMP
Modules linked in: leds_gpio(+) via_rhine mii cs5535_mfd mfd_core
geode_rng rng_core geode_aes isofs nls_utf8 nls_cp437 vfat fat
ata_generic pata_amd pata_cs5536 pata_acpi libata ehci_pci ehci_hcd
ohci_hcd usb_storage usbcore usb_common sd_mod scsi_mod squashfs loop
Pid: 881, comm: modprobe Not tainted 3.9.2 #1-Alpine
EIP: 0060:[<c11287d6>] EFLAGS: 00010282 CPU: 0
EIP is at __gpio_cansleep+0xe/0x1a
EAX: 00000000 EBX: cf364018 ECX: c132b8b9 EDX: 00000000
ESI: c13993a4 EDI: c1399370 EBP: cded9dbc ESP: cded9dbc
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
CR0: 8005003b CR2: 0000004c CR3: 0f0c4000 CR4: 00000090
DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
DR6: ffff0ff0 DR7: 00000400
Process modprobe (pid: 881, ti=cded8000 task=cf094aa0 task.ti=cded8000)
Stack:
cded9de0 d09471cb 00000000 c1399260 cf364014 00000000 c1399260 c1399254
d0949014 cded9df4 c118cd59 c1399260 d0949014 d0949014 cded9e08 c118ba47
c1399260 d0949014 c1399294 cded9e1c c118bb75 cded9e24 d0949014 00000000
Call Trace:
[<d09471cb>] gpio_led_probe+0xba/0x203 [leds_gpio]
[<c118cd59>] platform_drv_probe+0x26/0x48
[<c118ba47>] driver_probe_device+0x75/0x15c
[<c118bb75>] __driver_attach+0x47/0x63
[<c118a727>] bus_for_each_dev+0x3c/0x66
[<c118b6f9>] driver_attach+0x14/0x16
[<c118bb2e>] ? driver_probe_device+0x15c/0x15c
[<c118b3d5>] bus_add_driver+0xbd/0x1bc
[<d08b4000>] ? 0xd08b3fff
[<d08b4000>] ? 0xd08b3fff
[<c118bffc>] driver_register+0x74/0xec
[<d08b4000>] ? 0xd08b3fff
[<c118c8e8>] platform_driver_register+0x38/0x3a
[<d08b400d>] gpio_led_driver_init+0xd/0x1000 [leds_gpio]
[<c100116c>] do_one_initcall+0x6b/0x10f
[<d08b4000>] ? 0xd08b3fff
[<c105e918>] load_module+0x1631/0x1907
[<c10975d6>] ? insert_vmalloc_vmlist+0x14/0x43
[<c1098d5b>] ? __vmalloc_node_range+0x13e/0x15f
[<c105ec50>] sys_init_module+0x62/0x77
[<c1257888>] syscall_call+0x7/0xb
EIP: [<c11287d6>] __gpio_cansleep+0xe/0x1a SS:ESP 0068:cded9dbc
CR2: 000000000000004c
---[ end trace 5308fb20d2514822 ]---

Signed-off-by: Timo Teräs <timo.teras@iki.f>
Cc: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Raphael Assenat <raph@8d.com>
Cc: Trent Piepho <tpiepho@freescale.com>
Cc: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Cc: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 2d7c22f6 20-Dec-2012 Javier Martinez Canillas <javier@osg.samsung.com>

leds: leds-gpio: set devm_gpio_request_one() flags param correctly

commit a99d76f leds: leds-gpio: use gpio_request_one

changed the leds-gpio driver to use gpio_request_one() instead
of gpio_request() + gpio_direction_output()

Unfortunately, it also made a semantic change that breaks the
leds-gpio driver.

The gpio_request_one() flags parameter was set to:

GPIOF_DIR_OUT | (led_dat->active_low ^ state)

Since GPIOF_DIR_OUT is 0, the final flags value will just be the
XOR'ed value of led_dat->active_low and state.

This value were used to distinguish between HIGH/LOW output initial
level and call gpio_direction_output() accordingly.

With this new semantic gpio_request_one() will take the flags value
of 1 as a configuration of input direction (GPIOF_DIR_IN) and will
call gpio_direction_input() instead of gpio_direction_output().

int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
{
..
if (flags & GPIOF_DIR_IN)
err = gpio_direction_input(gpio);
else
err = gpio_direction_output(gpio,
(flags & GPIOF_INIT_HIGH) ? 1 : 0);
..
}

The right semantic is to evaluate led_dat->active_low ^ state and
set the output initial level explicitly.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Reported-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Tested-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 678e8a6b 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

leds: remove use of __devexit

CONFIG_HOTPLUG is going away as an option so __devexit is no
longer needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jan-Simon Moeller <jansimon.moeller@gmx.de>
Acked-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 98ea1ea2 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

leds: remove use of __devinit

CONFIG_HOTPLUG is going away as an option so __devinit is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jan-Simon Moeller <jansimon.moeller@gmx.de>
Acked-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# df07cf81 19-Nov-2012 Bill Pemberton <wfp5p@virginia.edu>

leds: remove use of __devexit_p

CONFIG_HOTPLUG is going away as an option so __devexit_p is no longer
needed.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Jan-Simon Moeller <jansimon.moeller@gmx.de>
Acked-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 39de81a9 24-Nov-2012 Sachin Kamat <sachin.kamat@linaro.org>

leds: leds-gpio: Use dev_info instead of printk

Fixes the following checkpatch warning:
WARNING: Prefer netdev_info(netdev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ...
FILE: leds/leds-gpio.c:105:
printk(KERN_INFO "Skipping unavailable LED gpio %d (%s)\n",

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# e3b1d44c 24-Nov-2012 Sachin Kamat <sachin.kamat@linaro.org>

leds: leds-gpio: use devm_gpio_request_one

devm_gpio_request_one is device managed and makes error handling
and cleanup simpler.

Cc: Raphael Assenat <raph@8d.com>
Cc: Trent Piepho <tpiepho@freescale.com>
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 04553e92 28-Oct-2012 Roland Stigge <stigge@antcom.de>

leds: leds-gpio: Defer probing in case of deferred gpio probing

This patch makes leds-gpio's probe() return -EPROBE_DEFER if any of the gpios
to register are deferred themselves. This makes a change of
gpio_leds_create_of()'s return value necessary: Instead of returning NULL on
error, we now use ERR_PTR() error coding.

Signed-off-by: Roland Stigge <stigge@antcom.de>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# a99d76f9 23-Oct-2012 Jingoo Han <jg1.han@samsung.com>

leds: leds-gpio: use gpio_request_one

Using gpio_request_one can make the code simpler because it can
set the direction and initial value in one shot.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# 8fe4554f 01-Sep-2012 AnilKumar Ch <anilkumar@ti.com>

leds: leds-gpio: adopt pinctrl support

Adopt pinctrl support to leds-gpio driver based on leds-gpio
device pointer, pinctrl driver configure SoC pins to GPIO
mode according to definitions provided in .dts file.

Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
Acked-by: Marek Vasut <marex@denx.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>


# 127aedc8 21-Aug-2012 Tobias Klauser <klto@zhaw.ch>

leds: leds-gpio: Use of_get_child_count() helper

Use of_get_child_count() instead of custom implementation.

Signed-off-by: Tobias Klauser <klto@zhaw.ch>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>


# 59c4dce1 16-Aug-2012 Tobias Klauser <tklauser@distanz.ch>

leds: leds-gpio: Use platform_{get,set}_drvdata

Use the wrapper functions, so we can directly pass a struct
platfrom_device.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>


# 6ebcebdd 16-Aug-2012 Tobias Klauser <tklauser@distanz.ch>

leds: leds-gpio: use of_match_ptr()

Instead of having to define the match table to NULL if CONFIG_OF isn't
set, use the of_match_ptr() macro which will do this for us.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>


# 198b8611 03-Jul-2012 Sachin Kamat <sachin.kamat@linaro.org>

leds: Use devm_kzalloc in leds-gpio.c file

devm_kzalloc() makes cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>


# 16db7f90 23-Mar-2012 Mark Brown <broonie@opensource.wolfsonmicro.com>

drivers/leds/leds-gpio.c: use linux/gpio.h rather than asm/gpio.h

Direct usage of the asm include has long been deprecated by the
introduction of gpiolib.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 892a8843 10-Jan-2012 Axel Lin <axel.lin@gmail.com>

leds: convert led platform drivers to module_platform_driver

Factor out some boilerplate code for platform driver registration into
module_platform_driver.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Haojian Zhuang <hzhuang1@marvell.com> [led-88pm860x.c]
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Michael Hennerich <hennerich@blackfin.uclinux.org>
Cc: Mike Rapoport <mike@compulab.co.il>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# dabc69c2 31-Oct-2011 David Daney <david.daney@cavium.com>

drivers/leds/leds-gpio.c: use gpio_get_value_cansleep() when initializing

I get the following warning:

------------[ cut here ]------------
WARNING: at drivers/gpio/gpiolib.c:1559 __gpio_get_value+0x90/0x98()
Modules linked in:
Call Trace:
[<ffffffff81440950>] dump_stack+0x8/0x34
[<ffffffff81141478>] warn_slowpath_common+0x78/0xa0
[<ffffffff812f0958>] __gpio_get_value+0x90/0x98
[<ffffffff81434f04>] create_gpio_led+0xdc/0x194
[<ffffffff8143524c>] gpio_led_probe+0x290/0x36c
[<ffffffff8130e8b0>] driver_probe_device+0x78/0x1b0
[<ffffffff8130eaa8>] __driver_attach+0xc0/0xc8
[<ffffffff8130d7ac>] bus_for_each_dev+0x64/0xb0
[<ffffffff8130e130>] bus_add_driver+0x1c8/0x2a8
[<ffffffff8130f100>] driver_register+0x90/0x180
[<ffffffff81100438>] do_one_initcall+0x38/0x160

---[ end trace ee38723fbefcd65c ]---

My GPIOs are on an I2C port expander, so we must use the *_cansleep()
variant of the GPIO functions. This is was not being done in
create_gpio_led().

We can change gpio_get_value() to gpio_get_value_cansleep() because it is
only called from the platform_driver probe function, which is a context
where we can sleep.

Only tested on my gpio_cansleep() system, but it seems safe for all
systems.

Signed-off-by: David Daney <david.daney@cavium.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Acked-by: Trent Piepho <tpiepho@gmail.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 54f4dedb 03-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

drivers/leds: Add module.h to files using it implicitly

A pending cleanup will mean that module.h won't be implicitly
everywhere anymore. Make sure the modular drivers in the leds
dir are actually calling out for <module.h> explicitly in advance.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# 2bcc7ed5 31-May-2011 Shawn Guo <shawn.guo@linaro.org>

leds: remove config option LEDS_GPIO_PLATFORM from Kconfig

Since the commit a314c5c0040aab51ebb1ecfd37a9198a91962243
(leds/leds-gpio: merge platform_driver with of_platform_driver),
the config option LEDS_GPIO_PLATFORM becomes useless, so remove it.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
[grant.likely: also remove LEDS_GPIO_OF for same reason]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# a314c5c0 22-Feb-2011 Grant Likely <grant.likely@secretlab.ca>

leds/leds-gpio: merge platform_driver with of_platform_driver

Both interfaces can be driven with the same driver, and
of_platform_driver is getting removed. This patch merges the two
driver registrations.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 25672b9d 11-Nov-2010 Davidlohr Bueso <dave@gnu.org>

drivers/leds/leds-gpio.c: properly initialize return value

In the event that none of the configs are set (CONFIG_LEDS_GPIO_PLATFORM,
CONFIG_LEDS_GPIO_OF, CONFIG_LEDS_GPIO_PLATFORM), we will return a bogus
value when initializing the module.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Acked-by: Richard Purdie <rpurdie@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 2dc11581 06-Aug-2010 Grant Likely <grant.likely@secretlab.ca>

of/device: Replace struct of_device with struct platform_device

of_device is just an alias for platform_device, so remove it entirely. Also
replace to_of_device() with to_platform_device() and update comment blocks.

This patch was initially generated from the following semantic patch, and then
edited by hand to pick up the bits that coccinelle didn't catch.

@@
@@
-struct of_device
+struct platform_device

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Reviewed-by: David S. Miller <davem@davemloft.net>


# 5f8269da 27-May-2010 Richard Purdie <rpurdie@linux.intel.com>

leds: Fix leds-gpio openfirmware compile issue

Fix a compile issue when openfirmware is enabled from commit
2146325df2c2640059a9e064890c30c6e259b458.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# 2146325d 22-May-2010 Benjamin Herrenschmidt <benh@kernel.crashing.org>

leds: leds-gpio: Change blink_set callback to be able to turn off blinking

The leds-gpio blink_set() callback follows the same prototype as the
main leds subsystem blink_set() one.

The problem is that to stop blink, normally, a leds driver does it
in the brightness_set() callback when asked to set a new fixed value.

However, with leds-gpio, the platform has no hook to do so, as this
later callback results in a standard GPIO manipulation.

This changes the leds-gpio specific callback to take a new argument
that indicates whether the LED should be blinking or not and in what
state it should be set if not. We also update the dns323 platform
which seems to be the only user of this so far.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# 4018294b 13-Apr-2010 Grant Likely <grant.likely@secretlab.ca>

of: Remove duplicate fields from of_platform_driver

.name, .match_table and .owner are duplicated in both of_platform_driver
and device_driver. This patch is a removes the extra copies from struct
of_platform_driver and converts all users to the device_driver members.

This patch is a pretty mechanical change. The usage model doesn't change
and if any drivers have been missed, or if anything has been fixed up
incorrectly, then it will fail with a compile time error, and the fixup
will be trivial. This patch looks big and scary because it touches so
many files, but it should be pretty safe.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Sean MacLennan <smaclennan@pikatech.com>


# 61c7a080 13-Apr-2010 Grant Likely <grant.likely@secretlab.ca>

of: Always use 'struct device.of_node' to get device node pointer.

The following structure elements duplicate the information in
'struct device.of_node' and so are being eliminated. This patch
makes all readers of these elements use device.of_node instead.

(struct of_device *)->node
(struct dev_archdata *)->prom_node (sparc)
(struct dev_archdata *)->of_node (powerpc & microblaze)

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>


# 5a0e3ad6 24-Mar-2010 Tejun Heo <tj@kernel.org>

include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>


# 0493a4ff 11-Mar-2010 Anton Vorontsov <avorontsov@ru.mvista.com>

leds-gpio: fix default state handling on OF platforms

The driver wrongly sets default state for LEDs that don't specify
default-state property.

Currently the driver handles default state this way:

memset(&led, 0, sizeof(led));
for_each_child_of_node(np, child) {
state = of_get_property(child, "default-state", NULL);
if (state) {
if (!strcmp(state, "keep"))
led.default_state = LEDS_GPIO_DEFSTATE_KEEP;
...
}
ret = create_gpio_led(&led, ...);
}

Which means that all LEDs that do not specify default-state will inherit
the last value of the default-state property, which is wrong.

This patch fixes the issue by moving LED's template initialization into
the loop body.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# 0b4634fc 15-Nov-2009 Dmitry Baryshkov <dbaryshkov@gmail.com>

leds-gpio: fix possible crash on OF device unbinding

If there are leds present in the OF tree, but the GPIOs for (some) of
them are unavailable, led_data doesn't get populated with correct
devices. Then, on device unbinding, one can crash the kernel.

Workaround this by setting led->gpio to invalid value early.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# 2fea0922 06-Aug-2009 Michal Simek <monstr@monstr.eu>

leds: gpio-leds: fix typographics fault

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# ed88bae6 12-May-2009 Trent Piepho <xyzzy@speakeasy.org>

leds: Add options to have GPIO LEDs start on or keep their state

There already is a "default-on" trigger but there are problems with it.

For one, it's a inefficient way to do it and requires led trigger support
to be compiled in.

But the real reason is that is produces a glitch on the LED. The GPIO is
allocate with the LED *off*, then *later* when the trigger runs it is
turned back on. If the LED was already on via the GPIO's reset default or
action of the firmware, this produces a glitch where the LED goes from on
to off to on. While normally this is fast enough that it wouldn't be
noticeable to a human observer, there are still serious problems.

One is that there may be something else on the GPIO line, like a hardware
alarm or watchdog, that is fast enough to notice the glitch.

Another is that the kernel may panic before the LED is turned back on, thus
hanging with the LED in the wrong state. This is not just speculation, but
actually happened to me with an embedded system that has an LED which
should turn off when the kernel finishes booting, which was left in the
incorrect state due to a bug in the OF LED binding code.

We also let GPIO LEDs get their initial value from whatever the current
state of the GPIO line is. On some systems the LEDs are put into some
state by the firmware or hardware before Linux boots, and it is desired to
have them keep this state which is otherwise unknown to Linux.

This requires that the underlying GPIO driver support reading the value of
output GPIOs. Some drivers support this and some do not.

The platform device binding gains a field in the platform data
"default_state" that controls this. There are three constants defined to
select from on, off, or keeping the current state. The OpenFirmware
binding uses a property named "default-state" that can be set to "on",
"off", or "keep". The default if the property isn't present is off.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Sean MacLennan <smaclennan@pikatech.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# 7fd02170 10-Jun-2009 Zhenwen Xu <helight.xu@gmail.com>

leds: leds-gpio - fix a section mismatch

WARNING: drivers/leds/leds-gpio.o(.text+0x153): Section mismatch in reference from the function gpio_led_probe() to the function .devinit.text:create_gpio_led()

The function gpio_led_probe() references the function __devinit
create_gpio_led(). This is often because gpio_led_probe lacks a __devinit
annotation or the annotation of create_gpio_led is wrong.

Signed-off-by: Zhenwen Xu <helight.xu@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# ac15e950 07-Apr-2009 David Brownell <david-b@pacbell.net>

leds: just ignore invalid GPIOs in leds-gpio

Fix build problems with leds-gpio:

CC drivers/leds/leds-gpio.o
drivers/leds/leds-gpio.c: In function 'create_gpio_led':
drivers/leds/leds-gpio.c:85: warning: 'return' with no value, in function returning non-void

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# d379ee8a 05-Mar-2009 David Brownell <dbrownell@users.sourceforge.net>

leds: just ignore invalid GPIOs in leds-gpio

Sometimes it's awkward to make sure that the array in the
platform_data handed to the leds-gpio driver has only valid
data ... some leds may not be always available, and coping
with that currently requires patching or rebuilding the array.

This patch fixes that by making it be OK to pass an invalid
GPIO (such as "-EINVAL") ... such table entries are skipped.

[rpurdie@linux.intel.com: adjusted to apply against other led tree changes]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Tested-by: Diego Dompe <diego.dompe@ridgerun.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# defb512d 17-Feb-2009 Richard Purdie <rpurdie@linux.intel.com>

leds: Add suspend/resume state flags to leds-gpio

Add an option to preserve LED state when suspending/resuming to the LED
gpio driver. Based on a suggestion from Robert Jarzmik.

Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# b2bdc3e7 02-Feb-2009 Richard Purdie <rpurdie@linux.intel.com>

leds: Fix leds-gpio driver multiple module_init/exit usage

You can't have multiple module_init()/module_exit calls so resort to messy
ifdefs potentially pending some code refactoring.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# a7d878af 10-Jan-2009 Trent Piepho <tpiepho@freescale.com>

leds: Add openfirmware platform device support

Add bindings to support LEDs defined as of_platform devices in addition to
the existing bindings for platform devices.

New options in Kconfig allow the platform binding code and/or the
of_platform code to be turned on. The of_platform code is of course only
available on archs that have OF support.

The existing probe and remove methods are refactored to use new functions
create_gpio_led(), to create and register one led, and delete_gpio_led(),
to unregister and free one led. The new probe and remove methods for the
of_platform driver can then share most of the common probe and remove code
with the platform driver.

The suspend and resume methods aren't shared, but they are very short. The
actual led driving code is the same for LEDs created by either binding.

The OF bindings are based on patch by Anton Vorontsov
<avorontsov@ru.mvista.com>. They have been extended to allow multiple LEDs
per device.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Sean MacLennan <smaclennan@pikatech.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>


# 859cb7f2 08-Jan-2009 Richard Purdie <rpurdie@linux.intel.com>

leds: Add suspend/resume to the core class

Add suspend/resume to the core class and remove all the now unneeded
code from various drivers. Originally the class code couldn't support
suspend/resume but since class_device can there is no reason for
each driver doing its own suspend/resume anymore.


# ca3259b3 09-Mar-2008 Herbert Valerio Riedel <hvr@gnu.org>

leds: enable support for blink_set() platform hook in leds-gpio

Enhance leds-gpio to provide hardware-based led flashing by passing
through the blink_set() call to a optionally set platform-specific
function pointer.

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>


# 3c4ded97 15-Apr-2008 Kay Sievers <kay.sievers@vrfy.org>

leds: fix platform driver hotplug/coldplug

Since 43cc71eed1250755986da4c0f9898f9a635cb3bf, the platform
modalias is prefixed with "platform:". Add MODULE_ALIAS() to the
hotpluggable platform LED drivers, to re-enable auto loading.

[dbrownell@users.sourceforge.net: more drivers, registration fixes]
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 306dd85c 26-Mar-2008 David Brownell <dbrownell@users.sourceforge.net>

leds: Remove incorrect use of preempt_count() from leds-gpio

It appears that we can't just check to see if we're in a task
context ... so instead of trying that, just make the relevant
leds always schedule a little worklet.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>


# d95cbe61 09-Mar-2008 Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>

leds: Fix potential leds-gpio oops

Call gpio_cansleep only after gpio_request succeeded avoiding an
oops.

Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>


# 2b7f1b8c 13-Jan-2008 Raphael Assenat <raph@8d.com>

leds: Fix led-gpio active_low default brightness

When gpio_direction_output() is called, led_dat->active_low is used
as default value. This means that the led will always be off by
default. cdev.brightness should really have been set to LED_OFF
unconditionally to reflect this behavior.

Signed-off-by: Raphael Assenat <raph@8d.com>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>


# 199fb21d 31-Oct-2007 David Brownell <dbrownell@users.sourceforge.net>

leds: bugfixes for leds-gpio

Three bugfixes to the leds-gpio driver, plus minor whitespace tweaks:

- Do the INIT_WORK() before registering each LED, so if its trigger
becomes immediately active it can schedule work without oopsing..

- Use normal registration, not platform_driver_probe(), so that
devices appearing "late" (hotplug type) can still be bound.

- Mark the driver remove code as "__devexit", preventing oopses
when the underlying device is removed.

These issues came up when using this driver with some GPIO expanders
living on serial busses, which act unlike "normal" platform devices:
they can appear and vanish along with the serial bus driver.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>


# 00852279 10-May-2007 David Brownell <david-b@pacbell.net>

leds: Teach leds-gpio to handle timer-unsafe GPIOs

Teach the new leds-gpio driver that some GPIOs can't be accessed from
timer callbacks ... which is how all today's standard triggers use them.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>


# 22e03f3b 27-Feb-2007 Raphael Assenat <raph@8d.com>

leds: Add generic GPIO LED driver

This patch adds support for GPIO connected leds via the new GPIO framework.

Information about leds (gpio, polarity, name, default trigger) is passed
to the driver via platform_data.

Signed-off-by: Raphael Assenat <raph@8d.com>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>