diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-03-27 14:09:48 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-03-27 14:09:48 -0700 |
commit | dfb0a0b715fdda25a5a1f54cb9c73e1410a868e8 (patch) | |
tree | afe6d503b462c1265a2903be5479a1f2d22955ff | |
parent | 7b58b82b86c8b65a2b57a4c6cb96a460654f9e09 (diff) | |
parent | e26557a0aa68acfb705b51947b7c756401a1ab71 (diff) | |
download | linux-dfb0a0b715fdda25a5a1f54cb9c73e1410a868e8.tar.bz2 |
Merge tag 'leds-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds
Pull LED updates from Pavel Machek:
"Nothing major here, there are two drivers that need review and did not
make it into this round"
* tag 'leds-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds:
leds: pca955x: Allow zero LEDs to be specified
leds: pca955x: Make the gpiochip always expose all pins
leds: simatic-ipc-leds: Don't directly deref ioremap_resource() returned ptr
leds: simatic-ipc-leds: Make simatic_ipc_led_mem_res static
leds: lm3692x: Return 0 from remove callback
leds: sgm3140: Add ocs,ocp8110 compatible
dt-bindings: vendor-prefixes: Add ocs prefix
dt-bindings: leds: common: fix unit address in max77693 example
-rw-r--r-- | Documentation/devicetree/bindings/leds/common.yaml | 9 | ||||
-rw-r--r-- | Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 | ||||
-rw-r--r-- | drivers/leds/flash/leds-sgm3140.c | 1 | ||||
-rw-r--r-- | drivers/leds/leds-lm3692x.c | 5 | ||||
-rw-r--r-- | drivers/leds/leds-pca955x.c | 67 | ||||
-rw-r--r-- | drivers/leds/simple/simatic-ipc-leds.c | 34 |
6 files changed, 65 insertions, 53 deletions
diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index 697102707703..328952d7acbb 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -185,9 +185,11 @@ examples: }; }; - led-controller@0 { + - | + #include <dt-bindings/leds/common.h> + + led-controller { compatible = "maxim,max77693-led"; - reg = <0 0x100>; led { function = LED_FUNCTION_FLASH; @@ -199,6 +201,9 @@ examples: }; }; + - | + #include <dt-bindings/leds/common.h> + i2c { #address-cells = <1>; #size-cells = <0>; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index c57367f582f4..1eebff4842e0 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -876,6 +876,8 @@ patternProperties: description: NXP Semiconductors "^oceanic,.*": description: Oceanic Systems (UK) Ltd. + "^ocs,.*": + description: Orient Chip Technology Co., Ltd. "^oct,.*": description: Octavo Systems LLC "^okaya,.*": diff --git a/drivers/leds/flash/leds-sgm3140.c b/drivers/leds/flash/leds-sgm3140.c index f4f831570f11..d3a30ad94ac4 100644 --- a/drivers/leds/flash/leds-sgm3140.c +++ b/drivers/leds/flash/leds-sgm3140.c @@ -290,6 +290,7 @@ static int sgm3140_remove(struct platform_device *pdev) } static const struct of_device_id sgm3140_dt_match[] = { + { .compatible = "ocs,ocp8110" }, { .compatible = "sgmicro,sgm3140" }, { /* sentinel */ } }; diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index afe6fb297855..87cd24ce3f95 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -494,11 +494,8 @@ static int lm3692x_probe(struct i2c_client *client, static int lm3692x_remove(struct i2c_client *client) { struct lm3692x_led *led = i2c_get_clientdata(client); - int ret; - ret = lm3692x_leds_disable(led); - if (ret) - return ret; + lm3692x_leds_disable(led); mutex_destroy(&led->lock); return 0; diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index a6b5699aeae4..81aaf21212d7 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -37,6 +37,7 @@ * bits the chip supports. */ +#include <linux/bitops.h> #include <linux/ctype.h> #include <linux/delay.h> #include <linux/err.h> @@ -118,6 +119,7 @@ struct pca955x { struct pca955x_led *leds; struct pca955x_chipdef *chipdef; struct i2c_client *client; + unsigned long active_pins; #ifdef CONFIG_LEDS_PCA955X_GPIO struct gpio_chip gpio; #endif @@ -360,12 +362,15 @@ static int pca955x_read_input(struct i2c_client *client, int n, u8 *val) static int pca955x_gpio_request_pin(struct gpio_chip *gc, unsigned int offset) { struct pca955x *pca955x = gpiochip_get_data(gc); - struct pca955x_led *led = &pca955x->leds[offset]; - if (led->type == PCA955X_TYPE_GPIO) - return 0; + return test_and_set_bit(offset, &pca955x->active_pins) ? -EBUSY : 0; +} + +static void pca955x_gpio_free_pin(struct gpio_chip *gc, unsigned int offset) +{ + struct pca955x *pca955x = gpiochip_get_data(gc); - return -EBUSY; + clear_bit(offset, &pca955x->active_pins); } static int pca955x_set_value(struct gpio_chip *gc, unsigned int offset, @@ -424,7 +429,7 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip) int count; count = device_get_child_node_count(&client->dev); - if (!count || count > chip->bits) + if (count > chip->bits) return ERR_PTR(-ENODEV); pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); @@ -489,7 +494,6 @@ static int pca955x_probe(struct i2c_client *client) struct i2c_adapter *adapter; int i, err; struct pca955x_platform_data *pdata; - int ngpios = 0; bool set_default_label = false; bool keep_pwm = false; char default_label[8]; @@ -567,9 +571,7 @@ static int pca955x_probe(struct i2c_client *client) switch (pca955x_led->type) { case PCA955X_TYPE_NONE: - break; case PCA955X_TYPE_GPIO: - ngpios++; break; case PCA955X_TYPE_LED: led = &pca955x_led->led_cdev; @@ -613,6 +615,8 @@ static int pca955x_probe(struct i2c_client *client) if (err) return err; + set_bit(i, &pca955x->active_pins); + /* * For default-state == "keep", let the core update the * brightness from the hardware, then check the @@ -650,31 +654,30 @@ static int pca955x_probe(struct i2c_client *client) return err; #ifdef CONFIG_LEDS_PCA955X_GPIO - if (ngpios) { - pca955x->gpio.label = "gpio-pca955x"; - pca955x->gpio.direction_input = pca955x_gpio_direction_input; - pca955x->gpio.direction_output = pca955x_gpio_direction_output; - pca955x->gpio.set = pca955x_gpio_set_value; - pca955x->gpio.get = pca955x_gpio_get_value; - pca955x->gpio.request = pca955x_gpio_request_pin; - pca955x->gpio.can_sleep = 1; - pca955x->gpio.base = -1; - pca955x->gpio.ngpio = ngpios; - pca955x->gpio.parent = &client->dev; - pca955x->gpio.owner = THIS_MODULE; - - err = devm_gpiochip_add_data(&client->dev, &pca955x->gpio, - pca955x); - if (err) { - /* Use data->gpio.dev as a flag for freeing gpiochip */ - pca955x->gpio.parent = NULL; - dev_warn(&client->dev, "could not add gpiochip\n"); - return err; - } - dev_info(&client->dev, "gpios %i...%i\n", - pca955x->gpio.base, pca955x->gpio.base + - pca955x->gpio.ngpio - 1); + pca955x->gpio.label = "gpio-pca955x"; + pca955x->gpio.direction_input = pca955x_gpio_direction_input; + pca955x->gpio.direction_output = pca955x_gpio_direction_output; + pca955x->gpio.set = pca955x_gpio_set_value; + pca955x->gpio.get = pca955x_gpio_get_value; + pca955x->gpio.request = pca955x_gpio_request_pin; + pca955x->gpio.free = pca955x_gpio_free_pin; + pca955x->gpio.can_sleep = 1; + pca955x->gpio.base = -1; + pca955x->gpio.ngpio = chip->bits; + pca955x->gpio.parent = &client->dev; + pca955x->gpio.owner = THIS_MODULE; + + err = devm_gpiochip_add_data(&client->dev, &pca955x->gpio, + pca955x); + if (err) { + /* Use data->gpio.dev as a flag for freeing gpiochip */ + pca955x->gpio.parent = NULL; + dev_warn(&client->dev, "could not add gpiochip\n"); + return err; } + dev_info(&client->dev, "gpios %i...%i\n", + pca955x->gpio.base, pca955x->gpio.base + + pca955x->gpio.ngpio - 1); #endif return 0; diff --git a/drivers/leds/simple/simatic-ipc-leds.c b/drivers/leds/simple/simatic-ipc-leds.c index ff2c96e73241..078d43f5ba38 100644 --- a/drivers/leds/simple/simatic-ipc-leds.c +++ b/drivers/leds/simple/simatic-ipc-leds.c @@ -39,9 +39,9 @@ static struct simatic_ipc_led simatic_ipc_leds_io[] = { }; /* the actual start will be discovered with PCI, 0 is a placeholder */ -struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME); +static struct resource simatic_ipc_led_mem_res = DEFINE_RES_MEM_NAMED(0, SZ_4K, KBUILD_MODNAME); -static void *simatic_ipc_led_memory; +static void __iomem *simatic_ipc_led_memory; static struct simatic_ipc_led simatic_ipc_leds_mem[] = { {0x500 + 0x1A0, "red:" LED_FUNCTION_STATUS "-1"}, @@ -92,21 +92,22 @@ static void simatic_ipc_led_set_mem(struct led_classdev *led_cd, enum led_brightness brightness) { struct simatic_ipc_led *led = cdev_to_led(led_cd); + void __iomem *reg = simatic_ipc_led_memory + led->value; + u32 val; - u32 *p; - - p = simatic_ipc_led_memory + led->value; - *p = (*p & ~1) | (brightness == LED_OFF); + val = readl(reg); + val = (val & ~1) | (brightness == LED_OFF); + writel(val, reg); } static enum led_brightness simatic_ipc_led_get_mem(struct led_classdev *led_cd) { struct simatic_ipc_led *led = cdev_to_led(led_cd); + void __iomem *reg = simatic_ipc_led_memory + led->value; + u32 val; - u32 *p; - - p = simatic_ipc_led_memory + led->value; - return (*p & 1) ? LED_OFF : led_cd->max_brightness; + val = readl(reg); + return (val & 1) ? LED_OFF : led_cd->max_brightness; } static int simatic_ipc_leds_probe(struct platform_device *pdev) @@ -116,8 +117,9 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) struct simatic_ipc_led *ipcled; struct led_classdev *cdev; struct resource *res; + void __iomem *reg; int err, type; - u32 *p; + u32 val; switch (plat->devmode) { case SIMATIC_IPC_DEVICE_227D: @@ -157,11 +159,13 @@ static int simatic_ipc_leds_probe(struct platform_device *pdev) return PTR_ERR(simatic_ipc_led_memory); /* initialize power/watchdog LED */ - p = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */ - *p = (*p & ~1); - p = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */ - *p = (*p | 1); + reg = simatic_ipc_led_memory + 0x500 + 0x1D8; /* PM_WDT_OUT */ + val = readl(reg); + writel(val & ~1, reg); + reg = simatic_ipc_led_memory + 0x500 + 0x1C0; /* PM_BIOS_BOOT_N */ + val = readl(reg); + writel(val | 1, reg); break; default: return -ENODEV; |