From aa14318aa02f14044acf81f418e1a1cbda29fcfc Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Fri, 10 Apr 2015 10:36:56 +0200 Subject: DT: leds: Improve description of flash LEDs related properties 1. Since max-microamp property has had no users so far, then rename it to more descriptive led-max-microamp. 2. Since flash-timeout-us property has had no users so far, then rename it to more accurate flash-max-timeout-us. 3. Describe led-max-microamp property as mandatory for specific board configurations. 4. Make flash-max-microamp and flash-max-timeout-us properties mandatory for devices with configurable flash current and flash timeout settings respectively. Signed-off-by: Jacek Anaszewski Cc: Richard Purdie Cc: Pavel Machek Cc: devicetree@vger.kernel.org Acked-by: Sakari Ailus Acked-by: Sylwester Nawrocki diff --git a/Documentation/devicetree/bindings/leds/common.txt b/Documentation/devicetree/bindings/leds/common.txt index 747c538..6841984 100644 --- a/Documentation/devicetree/bindings/leds/common.txt +++ b/Documentation/devicetree/bindings/leds/common.txt @@ -29,14 +29,23 @@ Optional properties for child nodes: "ide-disk" - LED indicates disk activity "timer" - LED flashes at a fixed, configurable rate -- max-microamp : maximum intensity in microamperes of the LED - (torch LED for flash devices) -- flash-max-microamp : maximum intensity in microamperes of the - flash LED; it is mandatory if the LED should - support the flash mode -- flash-timeout-us : timeout in microseconds after which the flash - LED is turned off +- led-max-microamp : Maximum LED supply current in microamperes. This property + can be made mandatory for the board configurations + introducing a risk of hardware damage in case an excessive + current is set. + For flash LED controllers with configurable current this + property is mandatory for the LEDs in the non-flash modes + (e.g. torch or indicator). +Required properties for flash LED child nodes: +- flash-max-microamp : Maximum flash LED supply current in microamperes. +- flash-max-timeout-us : Maximum timeout in microseconds after which the flash + LED is turned off. + +For controllers that have no configurable current the flash-max-microamp +property can be omitted. +For controllers that have no configurable timeout the flash-max-timeout-us +property can be omitted. Examples: @@ -49,7 +58,7 @@ system-status { camera-flash { label = "Flash"; led-sources = <0>, <1>; - max-microamp = <50000>; + led-max-microamp = <50000>; flash-max-microamp = <320000>; - flash-timeout-us = <500000>; + flash-max-timeout-us = <500000>; }; -- cgit v0.10.2 From 823227419588001f2d4accf3c5660cd99442a0f8 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 5 May 2015 18:32:25 +0200 Subject: leds: Allow compile test of GPIO consumers if !GPIOLIB The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer functionality only, can still be compiled if GPIOLIB is not enabled. Relax the dependency on GPIOLIB if COMPILE_TEST is enabled, where appropriate. Signed-off-by: Geert Uytterhoeven Cc: Richard Purdie Cc: linux-leds@vger.kernel.org Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 9ad35f7..94eced6 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -419,7 +419,7 @@ config LEDS_INTEL_SS4200 config LEDS_LT3593 tristate "LED driver for LT3593 controllers" depends on LEDS_CLASS - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help This option enables support for LEDs driven by a Linear Technology LT3593 controller. This controller uses a special one-wire pulse diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig index 49794b4..5bda6a9 100644 --- a/drivers/leds/trigger/Kconfig +++ b/drivers/leds/trigger/Kconfig @@ -72,7 +72,7 @@ config LEDS_TRIGGER_CPU config LEDS_TRIGGER_GPIO tristate "LED GPIO Trigger" depends on LEDS_TRIGGERS - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST help This allows LEDs to be controlled by gpio events. It's good when using gpios as switches and triggering the needed LEDs -- cgit v0.10.2 From 6e3956cd532d8c263e68ebae1252828e297aac4d Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 6 Jul 2015 15:42:34 +0200 Subject: leds: Allow compile test of LEDS_AAT1290 and LEDS_KTD2692 if !GPIOLIB The GPIO subsystem provides dummy GPIO consumer functions if GPIOLIB is not enabled. Hence drivers that depend on GPIOLIB, but use GPIO consumer functionality only, can still be compiled if GPIOLIB is not enabled. If COMPILE_TEST is enabled, relax the dependency on GPIOLIB for the recently introduced symbols LEDS_AAT1290 and LEDS_KTD2692. Signed-off-by: Geert Uytterhoeven Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 94eced6..cf0248b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -43,7 +43,7 @@ config LEDS_AAT1290 tristate "LED support for the AAT1290" depends on LEDS_CLASS_FLASH depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS - depends on GPIOLIB + depends on GPIOLIB || COMPILE_TEST depends on OF depends on PINCTRL help @@ -543,7 +543,8 @@ config LEDS_MENF21BMC config LEDS_KTD2692 tristate "LED support for KTD2692 flash LED controller" - depends on LEDS_CLASS_FLASH && GPIOLIB && OF + depends on LEDS_CLASS_FLASH && OF + depends on GPIOLIB || COMPILE_TEST help This option enables support for KTD2692 LED flash connected through ExpressWire interface. -- cgit v0.10.2 From 44ab901f91b22dcfc7d03d6f0da15c5354042367 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Fri, 10 Jul 2015 15:00:52 +0900 Subject: leds: Drop owner assignment from i2c_driver i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index 91325de..b38430c 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -492,7 +492,6 @@ static struct i2c_driver lm3530_i2c_driver = { .id_table = lm3530_id, .driver = { .name = LM3530_NAME, - .owner = THIS_MODULE, }, }; diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c index f5112cb..48872997 100644 --- a/drivers/leds/leds-lm355x.c +++ b/drivers/leds/leds-lm355x.c @@ -555,7 +555,6 @@ MODULE_DEVICE_TABLE(i2c, lm355x_id); static struct i2c_driver lm355x_i2c_driver = { .driver = { .name = LM355x_NAME, - .owner = THIS_MODULE, .pm = NULL, }, .probe = lm355x_probe, diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c index d3dec01..02ebe34 100644 --- a/drivers/leds/leds-lm3642.c +++ b/drivers/leds/leds-lm3642.c @@ -446,7 +446,6 @@ MODULE_DEVICE_TABLE(i2c, lm3642_id); static struct i2c_driver lm3642_i2c_driver = { .driver = { .name = LM3642_NAME, - .owner = THIS_MODULE, .pm = NULL, }, .probe = lm3642_probe, diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index c3a08b6..b775e1e 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -379,7 +379,6 @@ static int pca955x_remove(struct i2c_client *client) static struct i2c_driver pca955x_driver = { .driver = { .name = "leds-pca955x", - .owner = THIS_MODULE, }, .probe = pca955x_probe, .remove = pca955x_remove, diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index bee3e1a..3f63a1b 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -458,7 +458,6 @@ static int pca963x_remove(struct i2c_client *client) static struct i2c_driver pca963x_driver = { .driver = { .name = "leds-pca963x", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(of_pca963x_match), }, .probe = pca963x_probe, diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index 20fa8e7..c1f9109 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -830,7 +830,6 @@ static int tca6507_remove(struct i2c_client *client) static struct i2c_driver tca6507_driver = { .driver = { .name = "leds-tca6507", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(of_tca6507_leds_match), }, .probe = tca6507_probe, -- cgit v0.10.2 From de88e71a91ed7c8de321b44882e0805f0b24d734 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Wed, 8 Jul 2015 10:43:26 +0800 Subject: leds: lp8860: Constify reg_default tables These reg_default tables are not modified after initialized, so make them const. Signed-off-by: Axel Lin Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index 8c2b7fb..79f0843 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -302,7 +302,7 @@ out: return ret; } -static struct reg_default lp8860_reg_defs[] = { +static const struct reg_default lp8860_reg_defs[] = { { LP8860_DISP_CL1_BRT_MSB, 0x00}, { LP8860_DISP_CL1_BRT_LSB, 0x00}, { LP8860_DISP_CL1_CURR_MSB, 0x00}, @@ -332,7 +332,7 @@ static const struct regmap_config lp8860_regmap_config = { .cache_type = REGCACHE_NONE, }; -static struct reg_default lp8860_eeprom_defs[] = { +static const struct reg_default lp8860_eeprom_defs[] = { { LP8860_EEPROM_REG_0, 0x00 }, { LP8860_EEPROM_REG_1, 0x00 }, { LP8860_EEPROM_REG_2, 0x00 }, -- cgit v0.10.2 From f7fafd083ccc340502448903aaddc76f10785c8c Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Thu, 2 Jul 2015 19:56:40 +0200 Subject: leds: leds-ns2: move LED modes mapping outside of the driver On the board n090401 (Seagate NAS 4-Bay), the LED mode mapping (GPIO values to LED mode) is different from the one used on other boards supported by the leds-ns2 driver. With this patch the hardcoded mapping is removed from leds-ns2. Now, it must be defined either in the platform data (if an old-fashion board setup file is used) or in the DT node. In order to allow the later, this patch also introduces a modes-map property for the leds-ns2 DT binding. Signed-off-by: Vincent Donnefort Signed-off-by: Jacek Anaszewski diff --git a/Documentation/devicetree/bindings/leds/leds-ns2.txt b/Documentation/devicetree/bindings/leds/leds-ns2.txt index aef3aca..9f81258 100644 --- a/Documentation/devicetree/bindings/leds/leds-ns2.txt +++ b/Documentation/devicetree/bindings/leds/leds-ns2.txt @@ -8,6 +8,9 @@ Each LED is represented as a sub-node of the ns2-leds device. Required sub-node properties: - cmd-gpio: Command LED GPIO. See OF device-tree GPIO specification. - slow-gpio: Slow LED GPIO. See OF device-tree GPIO specification. +- modes-map: A mapping between LED modes (off, on or SATA activity blinking) and + the corresponding cmd-gpio/slow-gpio values. All the GPIO values combinations + should be given in order to avoid having an unknown mode at driver probe time. Optional sub-node properties: - label: Name for this LED. If omitted, the label is taken from the node name. @@ -15,6 +18,8 @@ Optional sub-node properties: Example: +#include + ns2-leds { compatible = "lacie,ns2-leds"; @@ -22,5 +27,9 @@ ns2-leds { label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = ; }; }; diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 1fd6adb..b0bc035 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -33,46 +33,20 @@ #include /* - * The Network Space v2 dual-GPIO LED is wired to a CPLD and can blink in - * relation with the SATA activity. This capability is exposed through the - * "sata" sysfs attribute. - * - * The following array detail the different LED registers and the combination - * of their possible values: - * - * cmd_led | slow_led | /SATA active | LED state - * | | | - * 1 | 0 | x | off - * - | 1 | x | on - * 0 | 0 | 1 | on - * 0 | 0 | 0 | blink (rate 300ms) + * The Network Space v2 dual-GPIO LED is wired to a CPLD. Three different LED + * modes are available: off, on and SATA activity blinking. The LED modes are + * controlled through two GPIOs (command and slow): each combination of values + * for the command/slow GPIOs corresponds to a LED mode. */ -enum ns2_led_modes { - NS_V2_LED_OFF, - NS_V2_LED_ON, - NS_V2_LED_SATA, -}; - -struct ns2_led_mode_value { - enum ns2_led_modes mode; - int cmd_level; - int slow_level; -}; - -static struct ns2_led_mode_value ns2_led_modval[] = { - { NS_V2_LED_OFF , 1, 0 }, - { NS_V2_LED_ON , 0, 1 }, - { NS_V2_LED_ON , 1, 1 }, - { NS_V2_LED_SATA, 0, 0 }, -}; - struct ns2_led_data { struct led_classdev cdev; unsigned cmd; unsigned slow; unsigned char sata; /* True when SATA mode active. */ rwlock_t rw_lock; /* Lock GPIOs. */ + int num_modes; + struct ns2_led_modval *modval; }; static int ns2_led_get_mode(struct ns2_led_data *led_dat, @@ -88,10 +62,10 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, cmd_level = gpio_get_value(led_dat->cmd); slow_level = gpio_get_value(led_dat->slow); - for (i = 0; i < ARRAY_SIZE(ns2_led_modval); i++) { - if (cmd_level == ns2_led_modval[i].cmd_level && - slow_level == ns2_led_modval[i].slow_level) { - *mode = ns2_led_modval[i].mode; + for (i = 0; i < led_dat->num_modes; i++) { + if (cmd_level == led_dat->modval[i].cmd_level && + slow_level == led_dat->modval[i].slow_level) { + *mode = led_dat->modval[i].mode; ret = 0; break; } @@ -110,12 +84,12 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, write_lock_irqsave(&led_dat->rw_lock, flags); - for (i = 0; i < ARRAY_SIZE(ns2_led_modval); i++) { - if (mode == ns2_led_modval[i].mode) { + for (i = 0; i < led_dat->num_modes; i++) { + if (mode == led_dat->modval[i].mode) { gpio_set_value(led_dat->cmd, - ns2_led_modval[i].cmd_level); + led_dat->modval[i].cmd_level); gpio_set_value(led_dat->slow, - ns2_led_modval[i].slow_level); + led_dat->modval[i].slow_level); } } @@ -228,6 +202,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.groups = ns2_led_groups; led_dat->cmd = template->cmd; led_dat->slow = template->slow; + led_dat->modval = template->modval; + led_dat->num_modes = template->num_modes; ret = ns2_led_get_mode(led_dat, &mode); if (ret < 0) @@ -259,9 +235,8 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) { struct device_node *np = dev->of_node; struct device_node *child; - struct ns2_led *leds; + struct ns2_led *led, *leds; int num_leds = 0; - int i = 0; num_leds = of_get_child_count(np); if (!num_leds) @@ -272,26 +247,57 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) if (!leds) return -ENOMEM; + led = leds; for_each_child_of_node(np, child) { const char *string; - int ret; + int ret, i, num_modes; + struct ns2_led_modval *modval; ret = of_get_named_gpio(child, "cmd-gpio", 0); if (ret < 0) return ret; - leds[i].cmd = ret; + led->cmd = ret; ret = of_get_named_gpio(child, "slow-gpio", 0); if (ret < 0) return ret; - leds[i].slow = ret; + led->slow = ret; ret = of_property_read_string(child, "label", &string); - leds[i].name = (ret == 0) ? string : child->name; + led->name = (ret == 0) ? string : child->name; ret = of_property_read_string(child, "linux,default-trigger", &string); if (ret == 0) - leds[i].default_trigger = string; + led->default_trigger = string; + + ret = of_property_count_u32_elems(child, "modes-map"); + if (ret < 0 || ret % 3) { + dev_err(dev, + "Missing or malformed modes-map property\n"); + return -EINVAL; + } + + num_modes = ret / 3; + modval = devm_kzalloc(dev, + num_modes * sizeof(struct ns2_led_modval), + GFP_KERNEL); + if (!modval) + return -ENOMEM; + + for (i = 0; i < num_modes; i++) { + of_property_read_u32_index(child, + "modes-map", 3 * i, + (u32 *) &modval[i].mode); + of_property_read_u32_index(child, + "modes-map", 3 * i + 1, + (u32 *) &modval[i].cmd_level); + of_property_read_u32_index(child, + "modes-map", 3 * i + 2, + (u32 *) &modval[i].slow_level); + } + + led->num_modes = num_modes; + led->modval = modval; - i++; + led++; } pdata->leds = leds; diff --git a/include/dt-bindings/leds/leds-ns2.h b/include/dt-bindings/leds/leds-ns2.h new file mode 100644 index 0000000..491c5f9 --- /dev/null +++ b/include/dt-bindings/leds/leds-ns2.h @@ -0,0 +1,8 @@ +#ifndef _DT_BINDINGS_LEDS_NS2_H +#define _DT_BINDINGS_LEDS_NS2_H + +#define NS_V2_LED_OFF 0 +#define NS_V2_LED_ON 1 +#define NS_V2_LED_SATA 2 + +#endif diff --git a/include/linux/platform_data/leds-kirkwood-ns2.h b/include/linux/platform_data/leds-kirkwood-ns2.h index 6a9fed5..eb8a686 100644 --- a/include/linux/platform_data/leds-kirkwood-ns2.h +++ b/include/linux/platform_data/leds-kirkwood-ns2.h @@ -9,11 +9,25 @@ #ifndef __LEDS_KIRKWOOD_NS2_H #define __LEDS_KIRKWOOD_NS2_H +enum ns2_led_modes { + NS_V2_LED_OFF, + NS_V2_LED_ON, + NS_V2_LED_SATA, +}; + +struct ns2_led_modval { + enum ns2_led_modes mode; + int cmd_level; + int slow_level; +}; + struct ns2_led { const char *name; const char *default_trigger; unsigned cmd; unsigned slow; + int num_modes; + struct ns2_led_modval *modval; }; struct ns2_led_platform_data { -- cgit v0.10.2 From 4b90432dc1edca6cfc0bb338794beed46af3a472 Mon Sep 17 00:00:00 2001 From: Simon Guinot Date: Thu, 2 Jul 2015 19:56:42 +0200 Subject: leds: leds-ns2: handle can_sleep GPIOs On the board n090401 (Seagate NAS 4-Bay), some of the LEDs are handled by the leds-ns2 driver. This LEDs are connected to an I2C GPIO expander (PCA95554PW) which means that GPIO access may sleep. This patch makes leds-ns2 compatible with such GPIOs by using the *_cansleep() variant of the GPIO functions. As a drawback this functions can't be used safely in a timer context (with the timer LED trigger for example). To fix this issue, a workqueue mechanism (copied from the leds-gpio driver) is used. Note that this patch also updates slightly the ns2_led_sata_store function. The LED state is now retrieved from cached values instead of reading the GPIOs previously. This prevents ns2_led_sata_store from working with a stale LED state (which may happen when a delayed work is pending). Signed-off-by: Simon Guinot Signed-off-by: Vincent Donnefort Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index b0bc035..b33514d 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -31,6 +31,7 @@ #include #include #include +#include "leds.h" /* * The Network Space v2 dual-GPIO LED is wired to a CPLD. Three different LED @@ -43,12 +44,25 @@ struct ns2_led_data { struct led_classdev cdev; unsigned cmd; unsigned slow; + bool can_sleep; + int mode_index; unsigned char sata; /* True when SATA mode active. */ rwlock_t rw_lock; /* Lock GPIOs. */ + struct work_struct work; int num_modes; struct ns2_led_modval *modval; }; +static void ns2_led_work(struct work_struct *work) +{ + struct ns2_led_data *led_dat = + container_of(work, struct ns2_led_data, work); + int i = led_dat->mode_index; + + gpio_set_value_cansleep(led_dat->cmd, led_dat->modval[i].cmd_level); + gpio_set_value_cansleep(led_dat->slow, led_dat->modval[i].slow_level); +} + static int ns2_led_get_mode(struct ns2_led_data *led_dat, enum ns2_led_modes *mode) { @@ -57,10 +71,8 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, int cmd_level; int slow_level; - read_lock_irq(&led_dat->rw_lock); - - cmd_level = gpio_get_value(led_dat->cmd); - slow_level = gpio_get_value(led_dat->slow); + cmd_level = gpio_get_value_cansleep(led_dat->cmd); + slow_level = gpio_get_value_cansleep(led_dat->slow); for (i = 0; i < led_dat->num_modes; i++) { if (cmd_level == led_dat->modval[i].cmd_level && @@ -71,8 +83,6 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, } } - read_unlock_irq(&led_dat->rw_lock); - return ret; } @@ -80,19 +90,32 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, enum ns2_led_modes mode) { int i; + bool found = false; unsigned long flags; - write_lock_irqsave(&led_dat->rw_lock, flags); - - for (i = 0; i < led_dat->num_modes; i++) { + for (i = 0; i < led_dat->num_modes; i++) if (mode == led_dat->modval[i].mode) { - gpio_set_value(led_dat->cmd, - led_dat->modval[i].cmd_level); - gpio_set_value(led_dat->slow, - led_dat->modval[i].slow_level); + found = true; + break; } + + if (!found) + return; + + write_lock_irqsave(&led_dat->rw_lock, flags); + + if (!led_dat->can_sleep) { + gpio_set_value(led_dat->cmd, + led_dat->modval[i].cmd_level); + gpio_set_value(led_dat->slow, + led_dat->modval[i].slow_level); + goto exit_unlock; } + led_dat->mode_index = i; + schedule_work(&led_dat->work); + +exit_unlock: write_unlock_irqrestore(&led_dat->rw_lock, flags); } @@ -122,7 +145,6 @@ static ssize_t ns2_led_sata_store(struct device *dev, container_of(led_cdev, struct ns2_led_data, cdev); int ret; unsigned long enable; - enum ns2_led_modes mode; ret = kstrtoul(buff, 10, &enable); if (ret < 0) @@ -131,19 +153,19 @@ static ssize_t ns2_led_sata_store(struct device *dev, enable = !!enable; if (led_dat->sata == enable) - return count; + goto exit; - ret = ns2_led_get_mode(led_dat, &mode); - if (ret < 0) - return ret; + led_dat->sata = enable; + + if (!led_get_brightness(led_cdev)) + goto exit; - if (enable && mode == NS_V2_LED_ON) + if (enable) ns2_led_set_mode(led_dat, NS_V2_LED_SATA); - if (!enable && mode == NS_V2_LED_SATA) + else ns2_led_set_mode(led_dat, NS_V2_LED_ON); - led_dat->sata = enable; - +exit: return count; } @@ -173,7 +195,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, enum ns2_led_modes mode; ret = devm_gpio_request_one(&pdev->dev, template->cmd, - gpio_get_value(template->cmd) ? + gpio_get_value_cansleep(template->cmd) ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, template->name); if (ret) { @@ -183,7 +205,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, } ret = devm_gpio_request_one(&pdev->dev, template->slow, - gpio_get_value(template->slow) ? + gpio_get_value_cansleep(template->slow) ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, template->name); if (ret) { @@ -202,6 +224,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.groups = ns2_led_groups; led_dat->cmd = template->cmd; led_dat->slow = template->slow; + led_dat->can_sleep = gpio_cansleep(led_dat->cmd) | + gpio_cansleep(led_dat->slow); led_dat->modval = template->modval; led_dat->num_modes = template->num_modes; @@ -214,6 +238,8 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, led_dat->cdev.brightness = (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; + INIT_WORK(&led_dat->work, ns2_led_work); + ret = led_classdev_register(&pdev->dev, &led_dat->cdev); if (ret < 0) return ret; @@ -224,6 +250,7 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, static void delete_ns2_led(struct ns2_led_data *led_dat) { led_classdev_unregister(&led_dat->cdev); + cancel_work_sync(&led_dat->work); } #ifdef CONFIG_OF_GPIO -- cgit v0.10.2 From 259f5ba308ee46c616ced3d336d7ab8e06f5a6ce Mon Sep 17 00:00:00 2001 From: Simon Guinot Date: Thu, 2 Jul 2015 19:56:43 +0200 Subject: leds: leds-ns2: depends on MACH_ARMADA_370 The leds-ns2 driver is also used by the n090401 board (Seagate NAS 4-Bay), which is based on the Marvell Armada-370 SoC. Then this patch allows to select the leds-ns2 driver if MACH_ARMADA_370 is enabled. Additionally, this also updates the Kconfig help message. Signed-off-by: Simon Guinot Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index cf0248b..23408bd 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -455,12 +455,16 @@ config LEDS_MC13783 config LEDS_NS2 tristate "LED support for Network Space v2 GPIO LEDs" depends on LEDS_CLASS - depends on MACH_KIRKWOOD + depends on MACH_KIRKWOOD || MACH_ARMADA_370 default y help - This option enable support for the dual-GPIO LED found on the - Network Space v2 board (and parents). This include Internet Space v2, - Network Space (Max) v2 and d2 Network v2 boards. + This option enables support for the dual-GPIO LEDs found on the + following LaCie/Seagate boards: + + Network Space v2 (and parents: Max, Mini) + Internet Space v2 + d2 Network v2 + n090401 (Seagate NAS 4-Bay) config LEDS_NETXBIG tristate "LED support for Big Network series LEDs" -- cgit v0.10.2 From f3a2a097a37acfb7c28da171248d15b9bb2e657b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 26 Jul 2015 12:05:16 +0800 Subject: leds: tlc591xx: Remove redundant I2C_FUNC_SMBUS_BYTE_DATA functionality check This checking is done by regmap_get_i2c_bus() which is called in devm_regmap_init_i2c(). Signed-off-by: Axel Lin Reviewed-by: Andrew Lunn Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c index de16c29..b806eca 100644 --- a/drivers/leds/leds-tlc591xx.c +++ b/drivers/leds/leds-tlc591xx.c @@ -231,10 +231,6 @@ tlc591xx_probe(struct i2c_client *client, if (!count || count > tlc591xx->max_leds) return -EINVAL; - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) - return -EIO; - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; -- cgit v0.10.2 From 4fc5af86837d983d7b1dd4edad245454e1874fa0 Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Thu, 2 Jul 2015 19:56:41 +0200 Subject: ARM: Kirkwood: add modes-map property to ns2-leds nodes Since the LED modes mapping is no longer hardcoded inside the leds-ns2 driver, then it must be provided through the modes-map property in the ns2-leds nodes. Signed-off-by: Vincent Donnefort Acked-by: Gregory CLEMENT Signed-off-by: Jacek Anaszewski diff --git a/arch/arm/boot/dts/kirkwood-d2net.dts b/arch/arm/boot/dts/kirkwood-d2net.dts index 6b78560..e1c25c3 100644 --- a/arch/arm/boot/dts/kirkwood-d2net.dts +++ b/arch/arm/boot/dts/kirkwood-d2net.dts @@ -10,6 +10,7 @@ /dts-v1/; +#include #include "kirkwood-netxbig.dtsi" / { @@ -28,6 +29,10 @@ label = "d2net_v2:blue:sata"; slow-gpio = <&gpio0 29 GPIO_ACTIVE_HIGH>; cmd-gpio = <&gpio0 30 GPIO_ACTIVE_HIGH>; + modes-map = ; }; }; diff --git a/arch/arm/boot/dts/kirkwood-is2.dts b/arch/arm/boot/dts/kirkwood-is2.dts index da674bb..4121674 100644 --- a/arch/arm/boot/dts/kirkwood-is2.dts +++ b/arch/arm/boot/dts/kirkwood-is2.dts @@ -1,5 +1,6 @@ /dts-v1/; +#include #include "kirkwood-ns2-common.dtsi" / { @@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = ; }; }; }; diff --git a/arch/arm/boot/dts/kirkwood-ns2.dts b/arch/arm/boot/dts/kirkwood-ns2.dts index 53368d1..190189d 100644 --- a/arch/arm/boot/dts/kirkwood-ns2.dts +++ b/arch/arm/boot/dts/kirkwood-ns2.dts @@ -1,5 +1,6 @@ /dts-v1/; +#include #include "kirkwood-ns2-common.dtsi" / { @@ -27,6 +28,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = ; }; }; }; diff --git a/arch/arm/boot/dts/kirkwood-ns2max.dts b/arch/arm/boot/dts/kirkwood-ns2max.dts index 72c78d0..55cc41d 100644 --- a/arch/arm/boot/dts/kirkwood-ns2max.dts +++ b/arch/arm/boot/dts/kirkwood-ns2max.dts @@ -1,5 +1,6 @@ /dts-v1/; +#include #include "kirkwood-ns2-common.dtsi" / { @@ -46,6 +47,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = ; }; }; }; diff --git a/arch/arm/boot/dts/kirkwood-ns2mini.dts b/arch/arm/boot/dts/kirkwood-ns2mini.dts index c441bf6..9935f3e 100644 --- a/arch/arm/boot/dts/kirkwood-ns2mini.dts +++ b/arch/arm/boot/dts/kirkwood-ns2mini.dts @@ -1,5 +1,6 @@ /dts-v1/; +#include #include "kirkwood-ns2-common.dtsi" / { @@ -47,6 +48,10 @@ label = "ns2:blue:sata"; slow-gpio = <&gpio0 29 0>; cmd-gpio = <&gpio0 30 0>; + modes-map = ; }; }; }; -- cgit v0.10.2 From e5b5a61fcb3743f1dacf9e20d28f48423cecf0c1 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Delgado Date: Fri, 31 Jul 2015 13:36:21 +0200 Subject: leds/led-class: Add missing put_device() Devices found by class_find_device must be freed with put_device(). Otherwise the reference count will not work properly. Fixes: a96aa64cb572 ("leds/led-class: Handle LEDs with the same name") Reported-by: Alan Tull Signed-off-by: Ricardo Ribalda Delgado Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index beabfbc..ca51d58 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -228,12 +228,15 @@ static int led_classdev_next_name(const char *init_name, char *name, { unsigned int i = 0; int ret = 0; + struct device *dev; strlcpy(name, init_name, len); - while (class_find_device(leds_class, NULL, name, match_name) && - (ret < len)) + while ((ret < len) && + (dev = class_find_device(leds_class, NULL, name, match_name))) { + put_device(dev); ret = snprintf(name, len, "%s_%u", init_name, ++i); + } if (ret >= len) return -ENOMEM; -- cgit v0.10.2 From b8926ba0d7fd74e140d408f6dfeff5f5b9c2afae Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Thu, 20 Aug 2015 08:59:35 +0200 Subject: MAINTAINERS: Change LED subsystem git tree URL This patch removes Bryan Wu from the list of LED subsystem maintainers and replaces related git tree URL with the one maintained by Jacek Anaszewski. Signed-off-by: Jacek Anaszewski Cc: Richard Purdie Acked-by: Bryan Wu diff --git a/MAINTAINERS b/MAINTAINERS index 569568f..f8ebbef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6040,11 +6040,10 @@ F: Documentation/scsi/53c700.txt F: drivers/scsi/53c700* LED SUBSYSTEM -M: Bryan Wu M: Richard Purdie M: Jacek Anaszewski L: linux-leds@vger.kernel.org -T: git git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds.git +T: git git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git S: Maintained F: drivers/leds/ F: include/linux/leds.h -- cgit v0.10.2 From c2d4af9370b1757714b895f005479393e4ec14b8 Mon Sep 17 00:00:00 2001 From: Vaishali Thakkar Date: Tue, 18 Aug 2015 19:50:16 +0530 Subject: leds: leds-fsg: Use devm_led_classdev_register Use resource-managed function devm_led_classdev_register instead of led_classdev_register to make the error-path simpler. To be compatible with the change, various gotos are replaced with direct returns and unneeded labels are dropped. Also, remove fsg_led_remove as it is now redundant. Signed-off-by: Vaishali Thakkar Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c index 2b4dc73..257a813 100644 --- a/drivers/leds/leds-fsg.c +++ b/drivers/leds/leds-fsg.c @@ -156,63 +156,35 @@ static int fsg_led_probe(struct platform_device *pdev) latch_value = 0xffff; *latch_address = latch_value; - ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); + ret = devm_led_classdev_register(&pdev->dev, &fsg_wlan_led); if (ret < 0) - goto failwlan; + return ret; - ret = led_classdev_register(&pdev->dev, &fsg_wan_led); + ret = devm_led_classdev_register(&pdev->dev, &fsg_wan_led); if (ret < 0) - goto failwan; + return ret; - ret = led_classdev_register(&pdev->dev, &fsg_sata_led); + ret = devm_led_classdev_register(&pdev->dev, &fsg_sata_led); if (ret < 0) - goto failsata; + return ret; - ret = led_classdev_register(&pdev->dev, &fsg_usb_led); + ret = devm_led_classdev_register(&pdev->dev, &fsg_usb_led); if (ret < 0) - goto failusb; + return ret; - ret = led_classdev_register(&pdev->dev, &fsg_sync_led); + ret = devm_led_classdev_register(&pdev->dev, &fsg_sync_led); if (ret < 0) - goto failsync; + return ret; - ret = led_classdev_register(&pdev->dev, &fsg_ring_led); + ret = devm_led_classdev_register(&pdev->dev, &fsg_ring_led); if (ret < 0) - goto failring; - - return ret; - - failring: - led_classdev_unregister(&fsg_sync_led); - failsync: - led_classdev_unregister(&fsg_usb_led); - failusb: - led_classdev_unregister(&fsg_sata_led); - failsata: - led_classdev_unregister(&fsg_wan_led); - failwan: - led_classdev_unregister(&fsg_wlan_led); - failwlan: + return ret; return ret; } -static int fsg_led_remove(struct platform_device *pdev) -{ - led_classdev_unregister(&fsg_wlan_led); - led_classdev_unregister(&fsg_wan_led); - led_classdev_unregister(&fsg_sata_led); - led_classdev_unregister(&fsg_usb_led); - led_classdev_unregister(&fsg_sync_led); - led_classdev_unregister(&fsg_ring_led); - - return 0; -} - - static struct platform_driver fsg_led_driver = { .probe = fsg_led_probe, - .remove = fsg_led_remove, .driver = { .name = "fsg-led", }, -- cgit v0.10.2 From 991a3f61fa93c1752a47ae157a8238395850c730 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Tue, 18 Aug 2015 12:25:26 -0700 Subject: leds: syscon: Correct check for syscon_node_to_regmap() errors syscon_node_to_regmap() returns a regmap or an ERR_PTR(). Signed-off-by: Bjorn Andersson Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-syscon.c b/drivers/leds/leds-syscon.c index d1660b0..b88900d 100644 --- a/drivers/leds/leds-syscon.c +++ b/drivers/leds/leds-syscon.c @@ -83,9 +83,9 @@ static int syscon_led_probe(struct platform_device *pdev) return -ENODEV; } map = syscon_node_to_regmap(parent->of_node); - if (!map) { + if (IS_ERR(map)) { dev_err(dev, "no regmap for syscon LED parent\n"); - return -ENODEV; + return PTR_ERR(map); } sled = devm_kzalloc(dev, sizeof(*sled), GFP_KERNEL); -- cgit v0.10.2 From ed133352047e46687afd98c299ec8ce7f6ea07bd Mon Sep 17 00:00:00 2001 From: Milo Kim Date: Mon, 24 Aug 2015 16:09:55 +0900 Subject: leds:lp55xx: use the private data instead of updating I2C device platform data Currently, lp55xx_of_populate_pdata() allocates lp55xx_platform_data if it's null. And it parses the DT and copies values into the 'client->dev.platform_data'. This may have architectural issue. Platform data is configurable through the DT or I2C board info inside the platform area. However, lp55xx common driver changes this configuration when it is loaded. So 'client->dev.platform_data' is not null anymore. Eventually, the driver initialization is not identical when it's unloaded and loaded again. The lp55xx common driver should use the private data, 'lp55xx_chip->pdata' instead of changing the original platform data. So, lp55xx_of_populate_pdata() is modified as follows. * Do not update 'dev->platform_data'. Return the pointer of new allocated lp55xx_platform_data. Then the driver points it to private data, 'lp55xx_chip->pdata'. * Each lp55xx driver checks the pointer and handles an error case. Then, original platform data configuration will be kept regardless of loading or unloading the driver. The driver allocates the memory and copies them from the DT if it's NULL. After the driver is loaded again, 'client->dev.platform_data' is same as initial load, so the driver is initialized identically. Cc: Toshi Kikuchi Cc: linux-leds@vger.kernel.org Signed-off-by: Milo Kim Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 8ca197a..63a9254 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -514,20 +514,19 @@ static int lp5521_probe(struct i2c_client *client, int ret; struct lp55xx_chip *chip; struct lp55xx_led *led; - struct lp55xx_platform_data *pdata; + struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); struct device_node *np = client->dev.of_node; - if (!dev_get_platdata(&client->dev)) { + if (!pdata) { if (np) { - ret = lp55xx_of_populate_pdata(&client->dev, np); - if (ret < 0) - return ret; + pdata = lp55xx_of_populate_pdata(&client->dev, np); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } else { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } } - pdata = dev_get_platdata(&client->dev); chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 584dbbc..1d0187f 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -880,20 +880,19 @@ static int lp5523_probe(struct i2c_client *client, int ret; struct lp55xx_chip *chip; struct lp55xx_led *led; - struct lp55xx_platform_data *pdata; + struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); struct device_node *np = client->dev.of_node; - if (!dev_get_platdata(&client->dev)) { + if (!pdata) { if (np) { - ret = lp55xx_of_populate_pdata(&client->dev, np); - if (ret < 0) - return ret; + pdata = lp55xx_of_populate_pdata(&client->dev, np); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } else { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } } - pdata = dev_get_platdata(&client->dev); chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c index ca85724..0360c59 100644 --- a/drivers/leds/leds-lp5562.c +++ b/drivers/leds/leds-lp5562.c @@ -515,20 +515,19 @@ static int lp5562_probe(struct i2c_client *client, int ret; struct lp55xx_chip *chip; struct lp55xx_led *led; - struct lp55xx_platform_data *pdata; + struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); struct device_node *np = client->dev.of_node; - if (!dev_get_platdata(&client->dev)) { + if (!pdata) { if (np) { - ret = lp55xx_of_populate_pdata(&client->dev, np); - if (ret < 0) - return ret; + pdata = lp55xx_of_populate_pdata(&client->dev, np); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } else { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } } - pdata = dev_get_platdata(&client->dev); chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 96d51e9..59b7683 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -543,7 +543,8 @@ void lp55xx_unregister_sysfs(struct lp55xx_chip *chip) } EXPORT_SYMBOL_GPL(lp55xx_unregister_sysfs); -int lp55xx_of_populate_pdata(struct device *dev, struct device_node *np) +struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, + struct device_node *np) { struct device_node *child; struct lp55xx_platform_data *pdata; @@ -553,17 +554,17 @@ int lp55xx_of_populate_pdata(struct device *dev, struct device_node *np) pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) - return -ENOMEM; + return ERR_PTR(-ENOMEM); num_channels = of_get_child_count(np); if (num_channels == 0) { dev_err(dev, "no LED channels\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL); if (!cfg) - return -ENOMEM; + return ERR_PTR(-ENOMEM); pdata->led_config = &cfg[0]; pdata->num_channels = num_channels; @@ -588,9 +589,7 @@ int lp55xx_of_populate_pdata(struct device *dev, struct device_node *np) /* LP8501 specific */ of_property_read_u8(np, "pwr-sel", (u8 *)&pdata->pwr_sel); - dev->platform_data = pdata; - - return 0; + return pdata; } EXPORT_SYMBOL_GPL(lp55xx_of_populate_pdata); diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h index cceab48..c7f1e61 100644 --- a/drivers/leds/leds-lp55xx-common.h +++ b/drivers/leds/leds-lp55xx-common.h @@ -202,7 +202,7 @@ extern int lp55xx_register_sysfs(struct lp55xx_chip *chip); extern void lp55xx_unregister_sysfs(struct lp55xx_chip *chip); /* common device tree population function */ -extern int lp55xx_of_populate_pdata(struct device *dev, - struct device_node *np); +extern struct lp55xx_platform_data +*lp55xx_of_populate_pdata(struct device *dev, struct device_node *np); #endif /* _LEDS_LP55XX_COMMON_H */ diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c index d3098e3..3f54f6f 100644 --- a/drivers/leds/leds-lp8501.c +++ b/drivers/leds/leds-lp8501.c @@ -308,20 +308,19 @@ static int lp8501_probe(struct i2c_client *client, int ret; struct lp55xx_chip *chip; struct lp55xx_led *led; - struct lp55xx_platform_data *pdata; + struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); struct device_node *np = client->dev.of_node; - if (!dev_get_platdata(&client->dev)) { + if (!pdata) { if (np) { - ret = lp55xx_of_populate_pdata(&client->dev, np); - if (ret < 0) - return ret; + pdata = lp55xx_of_populate_pdata(&client->dev, np); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); } else { dev_err(&client->dev, "no platform data\n"); return -EINVAL; } } - pdata = dev_get_platdata(&client->dev); chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); if (!chip) -- cgit v0.10.2 From 4d59ed85451befda203d72462f1b7ead0fde3267 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 25 Aug 2015 08:31:16 +0200 Subject: leds: Export OF module alias information in missing drivers The I2C core always reports the MODALIAS uevent as "i2c:" regardless of the mechanism that was used to register the device (i.e: OF or board code) and the table that is used later to match the driver with the device (i.e: I2C id table or OF match table). So drivers needs to export the I2C id table and this be built into the module or udev won't have the necessary information to autoload the needed driver module when the device is added. But this means that OF-only drivers needs to have both OF and I2C id tables that have to be kept in sync and also the dev node compatible manufacturer prefix is stripped when reporting the MODALIAS. Which can lead to issues if two vendors use the same I2C device name for example. To avoid the above, the I2C core behavior may be changed in the future to not require an SPI device table for OF-only drivers and report the OF module alias. So, it's better to also export the OF table even when is unused now to prevent breaking module loading when the core changes. Signed-off-by: Javier Martinez Canillas Signed-off-by: Jacek Anaszewski diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 3f63a1b..41f269f 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -332,6 +332,7 @@ static const struct of_device_id of_pca963x_match[] = { { .compatible = "nxp,pca9635", }, {}, }; +MODULE_DEVICE_TABLE(of, of_pca963x_match); #else static struct pca963x_platform_data * pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index c1f9109..edbecc4 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -735,6 +735,7 @@ static const struct of_device_id of_tca6507_leds_match[] = { { .compatible = "ti,tca6507", }, {}, }; +MODULE_DEVICE_TABLE(of, of_tca6507_leds_match); #else static struct tca6507_platform_data * -- cgit v0.10.2