Commit fecfd015 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'leds-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds

Pull LED updates from Pavel Machek:
 "Besides the usual fixes and new drivers, we are changing CLASS_FLASH
  to return success to make it easier to work with V4L2 stuff disabled,
  and we are getting rid of enum that should have been plain integer
  long time ago. I'm slightly nervous about potential warnings, but it
  needed to be fixed at some point"

* tag 'leds-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds:
  leds: lp50xx: Get rid of redundant explicit casting
  leds: lp50xx: Update headers block to reflect reality
  leds: lp50xx: Get rid of redundant check in lp50xx_enable_disable()
  leds: lp50xx: Reduce level of dereferences
  leds: lp50xx: Switch to new style i2c-driver probe function
  leds: lp50xx: Don't spam logs when probe is deferred
  leds: apu: extend support for PC Engines APU1 with newer firmware
  leds: flash: Fix multicolor no-ops registration by return 0
  leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
  leds: lgm: Add LED controller driver for LGM SoC
  dt-bindings: leds: Add bindings for Intel LGM SoC
  leds: led-core: Get rid of enum led_brightness
  leds: gpio: Set max brightness to 1
  leds: lm3533: Switch to using the new API kobj_to_dev()
  leds: ss4200: simplify the return expression of register_nasgpio_led()
  leds: Use DEVICE_ATTR_{RW, RO, WO} macros
parents 360db2b4 b0a82efa
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/leds-lgm.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Intel Lightning Mountain (LGM) SoC LED Serial Shift Output (SSO) Controller driver
maintainers:
- Zhu, Yi Xin <Yixin.zhu@intel.com>
- Amireddy Mallikarjuna reddy <mallikarjunax.reddy@intel.com>
properties:
compatible:
const: intel,lgm-ssoled
gpio-controller: true
'#gpio-cells':
const: 2
ngpios:
minimum: 0
maximum: 32
description:
Number of GPIOs this controller provides.
intel,sso-update-rate-hz:
description:
Blink frequency for SOUTs in Hz.
led-controller:
type: object
description:
This sub-node must contain a sub-node for each leds.
additionalProperties: false
patternProperties:
"^led@[0-23]$":
type: object
properties:
reg:
description: Index of the LED.
minimum: 0
maximum: 2
intel,sso-hw-trigger:
type: boolean
description: This property indicates Hardware driven/control LED.
intel,sso-hw-blink:
type: boolean
description: This property indicates Enable LED blink by Hardware.
intel,sso-blink-rate-hz:
description: LED HW blink frequency.
retain-state-suspended:
type: boolean
description: The suspend state of LED can be retained.
retain-state-shutdown:
type: boolean
description: Retain the state of the LED on shutdown.
required:
- compatible
- reg
- clocks
- clock-names
- "#gpio-cells"
- gpio-controller
additionalProperties: false
examples:
- |
#include <dt-bindings/clock/intel,lgm-clk.h>
#include <dt-bindings/leds/common.h>
ssogpio: ssogpio@e0d40000 {
compatible = "intel,sso-led";
reg = <0xE0D40000 0x2E4>;
gpio-controller;
#gpio-cells = <2>;
ngpios = <32>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ledc>;
clocks = <&cgu0 LGM_GCLK_LEDC0>, <&afeclk>;
clock-names = "sso", "fpid";
intel,sso-update-rate-hz = <250000>;
led-controller {
#address-cells = <1>;
#size-cells = <0>;
led@0 {
reg = <0>;
function = "gphy";
color = <LED_COLOR_ID_GREEN>;
led-gpio = <&ssogpio 0 0>;
};
led@23 {
reg = <23>;
function = LED_FUNCTION_POWER;
color = <LED_COLOR_ID_GREEN>;
led-gpio = <&ssogpio 23 0>;
};
};
};
...@@ -934,4 +934,7 @@ source "drivers/leds/flash/Kconfig" ...@@ -934,4 +934,7 @@ source "drivers/leds/flash/Kconfig"
comment "LED Triggers" comment "LED Triggers"
source "drivers/leds/trigger/Kconfig" source "drivers/leds/trigger/Kconfig"
comment "LED Blink"
source "drivers/leds/blink/Kconfig"
endif # NEW_LEDS endif # NEW_LEDS
...@@ -108,3 +108,6 @@ obj-$(CONFIG_LEDS_CLASS_FLASH) += flash/ ...@@ -108,3 +108,6 @@ obj-$(CONFIG_LEDS_CLASS_FLASH) += flash/
# LED Triggers # LED Triggers
obj-$(CONFIG_LEDS_TRIGGERS) += trigger/ obj-$(CONFIG_LEDS_TRIGGERS) += trigger/
# LED Blink
obj-$(CONFIG_LEDS_BLINK) += blink/
menuconfig LEDS_BLINK
bool "LED Blink support"
depends on LEDS_CLASS
help
This option enables blink support for the leds class.
If unsure, say Y.
if LEDS_BLINK
config LEDS_BLINK_LGM
tristate "LED support for Intel LGM SoC series"
depends on LEDS_CLASS
depends on MFD_SYSCON
depends on OF
help
Parallel to serial conversion, which is also called SSO controller,
can drive external shift register for LED outputs.
This enables LED support for Serial Shift Output controller(SSO).
endif # LEDS_BLINK
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_LEDS_BLINK_LGM) += leds-lgm-sso.o
This diff is collapsed.
...@@ -145,8 +145,7 @@ static void led_remove_brightness_hw_changed(struct led_classdev *led_cdev) ...@@ -145,8 +145,7 @@ static void led_remove_brightness_hw_changed(struct led_classdev *led_cdev)
device_remove_file(led_cdev->dev, &dev_attr_brightness_hw_changed); device_remove_file(led_cdev->dev, &dev_attr_brightness_hw_changed);
} }
void led_classdev_notify_brightness_hw_changed(struct led_classdev *led_cdev, void led_classdev_notify_brightness_hw_changed(struct led_classdev *led_cdev, unsigned int brightness)
enum led_brightness brightness)
{ {
if (WARN_ON(!led_cdev->brightness_hw_changed_kn)) if (WARN_ON(!led_cdev->brightness_hw_changed_kn))
return; return;
......
...@@ -39,8 +39,7 @@ const char * const led_colors[LED_COLOR_ID_MAX] = { ...@@ -39,8 +39,7 @@ const char * const led_colors[LED_COLOR_ID_MAX] = {
}; };
EXPORT_SYMBOL_GPL(led_colors); EXPORT_SYMBOL_GPL(led_colors);
static int __led_set_brightness(struct led_classdev *led_cdev, static int __led_set_brightness(struct led_classdev *led_cdev, unsigned int value)
enum led_brightness value)
{ {
if (!led_cdev->brightness_set) if (!led_cdev->brightness_set)
return -ENOTSUPP; return -ENOTSUPP;
...@@ -50,8 +49,7 @@ static int __led_set_brightness(struct led_classdev *led_cdev, ...@@ -50,8 +49,7 @@ static int __led_set_brightness(struct led_classdev *led_cdev,
return 0; return 0;
} }
static int __led_set_brightness_blocking(struct led_classdev *led_cdev, static int __led_set_brightness_blocking(struct led_classdev *led_cdev, unsigned int value)
enum led_brightness value)
{ {
if (!led_cdev->brightness_set_blocking) if (!led_cdev->brightness_set_blocking)
return -ENOTSUPP; return -ENOTSUPP;
...@@ -240,8 +238,7 @@ void led_stop_software_blink(struct led_classdev *led_cdev) ...@@ -240,8 +238,7 @@ void led_stop_software_blink(struct led_classdev *led_cdev)
} }
EXPORT_SYMBOL_GPL(led_stop_software_blink); EXPORT_SYMBOL_GPL(led_stop_software_blink);
void led_set_brightness(struct led_classdev *led_cdev, void led_set_brightness(struct led_classdev *led_cdev, unsigned int brightness)
enum led_brightness brightness)
{ {
/* /*
* If software blink is active, delay brightness setting * If software blink is active, delay brightness setting
...@@ -253,7 +250,7 @@ void led_set_brightness(struct led_classdev *led_cdev, ...@@ -253,7 +250,7 @@ void led_set_brightness(struct led_classdev *led_cdev,
* work queue task to avoid problems in case we are called * work queue task to avoid problems in case we are called
* from hard irq context. * from hard irq context.
*/ */
if (brightness == LED_OFF) { if (!brightness) {
set_bit(LED_BLINK_DISABLE, &led_cdev->work_flags); set_bit(LED_BLINK_DISABLE, &led_cdev->work_flags);
schedule_work(&led_cdev->set_brightness_work); schedule_work(&led_cdev->set_brightness_work);
} else { } else {
...@@ -268,8 +265,7 @@ void led_set_brightness(struct led_classdev *led_cdev, ...@@ -268,8 +265,7 @@ void led_set_brightness(struct led_classdev *led_cdev,
} }
EXPORT_SYMBOL_GPL(led_set_brightness); EXPORT_SYMBOL_GPL(led_set_brightness);
void led_set_brightness_nopm(struct led_classdev *led_cdev, void led_set_brightness_nopm(struct led_classdev *led_cdev, unsigned int value)
enum led_brightness value)
{ {
/* Use brightness_set op if available, it is guaranteed not to sleep */ /* Use brightness_set op if available, it is guaranteed not to sleep */
if (!__led_set_brightness(led_cdev, value)) if (!__led_set_brightness(led_cdev, value))
...@@ -281,8 +277,7 @@ void led_set_brightness_nopm(struct led_classdev *led_cdev, ...@@ -281,8 +277,7 @@ void led_set_brightness_nopm(struct led_classdev *led_cdev,
} }
EXPORT_SYMBOL_GPL(led_set_brightness_nopm); EXPORT_SYMBOL_GPL(led_set_brightness_nopm);
void led_set_brightness_nosleep(struct led_classdev *led_cdev, void led_set_brightness_nosleep(struct led_classdev *led_cdev, unsigned int value)
enum led_brightness value)
{ {
led_cdev->brightness = min(value, led_cdev->max_brightness); led_cdev->brightness = min(value, led_cdev->max_brightness);
...@@ -293,8 +288,7 @@ void led_set_brightness_nosleep(struct led_classdev *led_cdev, ...@@ -293,8 +288,7 @@ void led_set_brightness_nosleep(struct led_classdev *led_cdev,
} }
EXPORT_SYMBOL_GPL(led_set_brightness_nosleep); EXPORT_SYMBOL_GPL(led_set_brightness_nosleep);
int led_set_brightness_sync(struct led_classdev *led_cdev, int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value)
enum led_brightness value)
{ {
if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) if (led_cdev->blink_delay_on || led_cdev->blink_delay_off)
return -EBUSY; return -EBUSY;
......
...@@ -83,6 +83,7 @@ static const struct apu_led_profile apu1_led_profile[] = { ...@@ -83,6 +83,7 @@ static const struct apu_led_profile apu1_led_profile[] = {
}; };
static const struct dmi_system_id apu_led_dmi_table[] __initconst = { static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
/* PC Engines APU with factory bios "SageBios_PCEngines_APU-45" */
{ {
.ident = "apu", .ident = "apu",
.matches = { .matches = {
...@@ -90,6 +91,14 @@ static const struct dmi_system_id apu_led_dmi_table[] __initconst = { ...@@ -90,6 +91,14 @@ static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
DMI_MATCH(DMI_PRODUCT_NAME, "APU") DMI_MATCH(DMI_PRODUCT_NAME, "APU")
} }
}, },
/* PC Engines APU with "Mainline" bios >= 4.6.8 */
{
.ident = "apu",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
DMI_MATCH(DMI_PRODUCT_NAME, "apu1")
}
},
{} {}
}; };
MODULE_DEVICE_TABLE(dmi, apu_led_dmi_table); MODULE_DEVICE_TABLE(dmi, apu_led_dmi_table);
...@@ -173,7 +182,7 @@ static int __init apu_led_init(void) ...@@ -173,7 +182,7 @@ static int __init apu_led_init(void)
int err; int err;
if (!(dmi_match(DMI_SYS_VENDOR, "PC Engines") && if (!(dmi_match(DMI_SYS_VENDOR, "PC Engines") &&
dmi_match(DMI_PRODUCT_NAME, "APU"))) { (dmi_match(DMI_PRODUCT_NAME, "APU") || dmi_match(DMI_PRODUCT_NAME, "apu1")))) {
pr_err("No PC Engines APUv1 board detected. For APUv2,3 support, enable CONFIG_PCENGINES_APU2\n"); pr_err("No PC Engines APUv1 board detected. For APUv2,3 support, enable CONFIG_PCENGINES_APU2\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -192,13 +192,13 @@ static int store_color_common(struct device *dev, const char *buf, int color) ...@@ -192,13 +192,13 @@ static int store_color_common(struct device *dev, const char *buf, int color)
return 0; return 0;
} }
static ssize_t show_red(struct device *dev, struct device_attribute *attr, static ssize_t red_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return show_color_common(dev, buf, RED); return show_color_common(dev, buf, RED);
} }
static ssize_t store_red(struct device *dev, struct device_attribute *attr, static ssize_t red_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int ret; int ret;
...@@ -209,15 +209,15 @@ static ssize_t store_red(struct device *dev, struct device_attribute *attr, ...@@ -209,15 +209,15 @@ static ssize_t store_red(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(red, S_IRUGO | S_IWUSR, show_red, store_red); static DEVICE_ATTR_RW(red);
static ssize_t show_green(struct device *dev, struct device_attribute *attr, static ssize_t green_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return show_color_common(dev, buf, GREEN); return show_color_common(dev, buf, GREEN);
} }
static ssize_t store_green(struct device *dev, struct device_attribute *attr, static ssize_t green_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -229,15 +229,15 @@ static ssize_t store_green(struct device *dev, struct device_attribute *attr, ...@@ -229,15 +229,15 @@ static ssize_t store_green(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(green, S_IRUGO | S_IWUSR, show_green, store_green); static DEVICE_ATTR_RW(green);
static ssize_t show_blue(struct device *dev, struct device_attribute *attr, static ssize_t blue_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return show_color_common(dev, buf, BLUE); return show_color_common(dev, buf, BLUE);
} }
static ssize_t store_blue(struct device *dev, struct device_attribute *attr, static ssize_t blue_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int ret; int ret;
...@@ -248,16 +248,16 @@ static ssize_t store_blue(struct device *dev, struct device_attribute *attr, ...@@ -248,16 +248,16 @@ static ssize_t store_blue(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(blue, S_IRUGO | S_IWUSR, show_blue, store_blue); static DEVICE_ATTR_RW(blue);
static ssize_t show_test(struct device *dev, struct device_attribute *attr, static ssize_t test_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, return scnprintf(buf, PAGE_SIZE,
"#Write into test to start test sequence!#\n"); "#Write into test to start test sequence!#\n");
} }
static ssize_t store_test(struct device *dev, struct device_attribute *attr, static ssize_t test_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -273,7 +273,7 @@ static ssize_t store_test(struct device *dev, struct device_attribute *attr, ...@@ -273,7 +273,7 @@ static ssize_t store_test(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(test, S_IRUGO | S_IWUSR, show_test, store_test); static DEVICE_ATTR_RW(test);
/* TODO: HSB, fade, timeadj, script ... */ /* TODO: HSB, fade, timeadj, script ... */
......
...@@ -96,7 +96,8 @@ static int create_gpio_led(const struct gpio_led *template, ...@@ -96,7 +96,8 @@ static int create_gpio_led(const struct gpio_led *template,
} else { } else {
state = (template->default_state == LEDS_GPIO_DEFSTATE_ON); state = (template->default_state == LEDS_GPIO_DEFSTATE_ON);
} }
led_dat->cdev.brightness = state ? LED_FULL : LED_OFF; led_dat->cdev.brightness = state;
led_dat->cdev.max_brightness = 1;
if (!template->retain_state_suspended) if (!template->retain_state_suspended)
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
if (template->panic_indicator) if (template->panic_indicator)
......
...@@ -346,7 +346,7 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev, ...@@ -346,7 +346,7 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
} }
} }
static ssize_t lm3530_mode_get(struct device *dev, static ssize_t mode_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -365,7 +365,7 @@ static ssize_t lm3530_mode_get(struct device *dev, ...@@ -365,7 +365,7 @@ static ssize_t lm3530_mode_get(struct device *dev,
return len; return len;
} }
static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute static ssize_t mode_store(struct device *dev, struct device_attribute
*attr, const char *buf, size_t size) *attr, const char *buf, size_t size)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -397,7 +397,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute ...@@ -397,7 +397,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute
return sizeof(drvdata->mode); return sizeof(drvdata->mode);
} }
static DEVICE_ATTR(mode, 0644, lm3530_mode_get, lm3530_mode_set); static DEVICE_ATTR_RW(mode);
static struct attribute *lm3530_attrs[] = { static struct attribute *lm3530_attrs[] = {
&dev_attr_mode.attr, &dev_attr_mode.attr,
......
...@@ -608,7 +608,7 @@ static struct attribute *lm3533_led_attributes[] = { ...@@ -608,7 +608,7 @@ static struct attribute *lm3533_led_attributes[] = {
static umode_t lm3533_led_attr_is_visible(struct kobject *kobj, static umode_t lm3533_led_attr_is_visible(struct kobject *kobj,
struct attribute *attr, int n) struct attribute *attr, int n)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = kobj_to_dev(kobj);
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct lm3533_led *led = to_lm3533_led(led_cdev); struct lm3533_led *led = to_lm3533_led(led_cdev);
umode_t mode = attr->mode; umode_t mode = attr->mode;
......
...@@ -349,7 +349,7 @@ static int lm355x_indicator_brightness_set(struct led_classdev *cdev, ...@@ -349,7 +349,7 @@ static int lm355x_indicator_brightness_set(struct led_classdev *cdev,
} }
/* indicator pattern only for lm3556*/ /* indicator pattern only for lm3556*/
static ssize_t lm3556_indicator_pattern_store(struct device *dev, static ssize_t pattern_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
...@@ -381,7 +381,7 @@ static ssize_t lm3556_indicator_pattern_store(struct device *dev, ...@@ -381,7 +381,7 @@ static ssize_t lm3556_indicator_pattern_store(struct device *dev,
return ret; return ret;
} }
static DEVICE_ATTR(pattern, S_IWUSR, NULL, lm3556_indicator_pattern_store); static DEVICE_ATTR_WO(pattern);
static struct attribute *lm355x_indicator_attrs[] = { static struct attribute *lm355x_indicator_attrs[] = {
&dev_attr_pattern.attr, &dev_attr_pattern.attr,
......
...@@ -165,7 +165,7 @@ static int lm3642_control(struct lm3642_chip_data *chip, ...@@ -165,7 +165,7 @@ static int lm3642_control(struct lm3642_chip_data *chip,
/* torch */ /* torch */
/* torch pin config for lm3642 */ /* torch pin config for lm3642 */
static ssize_t lm3642_torch_pin_store(struct device *dev, static ssize_t torch_pin_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
...@@ -193,7 +193,7 @@ static ssize_t lm3642_torch_pin_store(struct device *dev, ...@@ -193,7 +193,7 @@ static ssize_t lm3642_torch_pin_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store); static DEVICE_ATTR_WO(torch_pin);
static int lm3642_torch_brightness_set(struct led_classdev *cdev, static int lm3642_torch_brightness_set(struct led_classdev *cdev,
enum led_brightness brightness) enum led_brightness brightness)
...@@ -212,7 +212,7 @@ static int lm3642_torch_brightness_set(struct led_classdev *cdev, ...@@ -212,7 +212,7 @@ static int lm3642_torch_brightness_set(struct led_classdev *cdev,
/* flash */ /* flash */
/* strobe pin config for lm3642*/ /* strobe pin config for lm3642*/
static ssize_t lm3642_strobe_pin_store(struct device *dev, static ssize_t strobe_pin_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
...@@ -240,7 +240,7 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev, ...@@ -240,7 +240,7 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store); static DEVICE_ATTR_WO(strobe_pin);
static int lm3642_strobe_brightness_set(struct led_classdev *cdev, static int lm3642_strobe_brightness_set(struct led_classdev *cdev,
enum led_brightness brightness) enum led_brightness brightness)
......
...@@ -6,10 +6,9 @@ ...@@ -6,10 +6,9 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -322,7 +321,7 @@ static int lp50xx_brightness_set(struct led_classdev *cdev, ...@@ -322,7 +321,7 @@ static int lp50xx_brightness_set(struct led_classdev *cdev,
ret = regmap_write(led->priv->regmap, reg_val, brightness); ret = regmap_write(led->priv->regmap, reg_val, brightness);
if (ret) { if (ret) {
dev_err(&led->priv->client->dev, dev_err(led->priv->dev,
"Cannot write brightness value %d\n", ret); "Cannot write brightness value %d\n", ret);
goto out; goto out;
} }
...@@ -338,7 +337,7 @@ static int lp50xx_brightness_set(struct led_classdev *cdev, ...@@ -338,7 +337,7 @@ static int lp50xx_brightness_set(struct led_classdev *cdev,
ret = regmap_write(led->priv->regmap, reg_val, ret = regmap_write(led->priv->regmap, reg_val,
mc_dev->subled_info[i].intensity); mc_dev->subled_info[i].intensity);
if (ret) { if (ret) {
dev_err(&led->priv->client->dev, dev_err(led->priv->dev,
"Cannot write intensity value %d\n", ret); "Cannot write intensity value %d\n", ret);
goto out; goto out;
} }
...@@ -360,8 +359,8 @@ static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[]) ...@@ -360,8 +359,8 @@ static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[])
bank_enable_mask |= (1 << led_banks[i]); bank_enable_mask |= (1 << led_banks[i]);
} }
led_config_lo = (u8)(bank_enable_mask & 0xff); led_config_lo = bank_enable_mask;
led_config_hi = (u8)(bank_enable_mask >> 8) & 0xff; led_config_hi = bank_enable_mask >> 8;
ret = regmap_write(priv->regmap, LP50XX_LED_CFG0, led_config_lo); ret = regmap_write(priv->regmap, LP50XX_LED_CFG0, led_config_lo);
if (ret) if (ret)
...@@ -382,11 +381,9 @@ static int lp50xx_enable_disable(struct lp50xx *priv, int enable_disable) ...@@ -382,11 +381,9 @@ static int lp50xx_enable_disable(struct lp50xx *priv, int enable_disable)
{ {
int ret; int ret;
if (priv->enable_gpio) {
ret = gpiod_direction_output(priv->enable_gpio, enable_disable); ret = gpiod_direction_output(priv->enable_gpio, enable_disable);
if (ret) if (ret)
return ret; return ret;
}
if (enable_disable) if (enable_disable)
return regmap_write(priv->regmap, LP50XX_DEV_CFG0, LP50XX_CHIP_EN); return regmap_write(priv->regmap, LP50XX_DEV_CFG0, LP50XX_CHIP_EN);
...@@ -404,7 +401,7 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv, ...@@ -404,7 +401,7 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
if (num_leds > 1) { if (num_leds > 1) {
if (num_leds > priv->chip_info->max_modules) { if (num_leds > priv->chip_info->max_modules) {
dev_err(&priv->client->dev, "reg property is invalid\n"); dev_err(priv->dev, "reg property is invalid\n");
return -EINVAL; return -EINVAL;
} }
...@@ -412,13 +409,13 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv, ...@@ -412,13 +409,13 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
ret = fwnode_property_read_u32_array(child, "reg", led_banks, num_leds); ret = fwnode_property_read_u32_array(child, "reg", led_banks, num_leds);
if (ret) { if (ret) {
dev_err(&priv->client->dev, "reg property is missing\n"); dev_err(priv->dev, "reg property is missing\n");
return ret; return ret;
} }
ret = lp50xx_set_banks(priv, led_banks); ret = lp50xx_set_banks(priv, led_banks);
if (ret) { if (ret) {
dev_err(&priv->client->dev, "Cannot setup banked LEDs\n"); dev_err(priv->dev, "Cannot setup banked LEDs\n");
return ret; return ret;
} }
...@@ -426,12 +423,12 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv, ...@@ -426,12 +423,12 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
} else { } else {
ret = fwnode_property_read_u32(child, "reg", &led_number); ret = fwnode_property_read_u32(child, "reg", &led_number);
if (ret) { if (ret) {
dev_err(&priv->client->dev, "led reg property missing\n"); dev_err(priv->dev, "led reg property missing\n");
return ret; return ret;
} }
if (led_number > priv->chip_info->num_leds) { if (led_number > priv->chip_info->num_leds) {
dev_err(&priv->client->dev, "led-sources property is invalid\n"); dev_err(priv->dev, "led-sources property is invalid\n");
return -EINVAL; return -EINVAL;
} }
...@@ -455,12 +452,9 @@ static int lp50xx_probe_dt(struct lp50xx *priv) ...@@ -455,12 +452,9 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
int i = 0; int i = 0;
priv->enable_gpio = devm_gpiod_get_optional(priv->dev, "enable", GPIOD_OUT_LOW); priv->enable_gpio = devm_gpiod_get_optional(priv->dev, "enable", GPIOD_OUT_LOW);
if (IS_ERR(priv->enable_gpio)) { if (IS_ERR(priv->enable_gpio))
ret = PTR_ERR(priv->enable_gpio); return dev_err_probe(priv->dev, PTR_ERR(priv->enable_gpio),
dev_err(&priv->client->dev, "Failed to get enable gpio: %d\n", "Failed to get enable GPIO\n");
ret);
return ret;
}
priv->regulator = devm_regulator_get(priv->dev, "vled"); priv->regulator = devm_regulator_get(priv->dev, "vled");
if (IS_ERR(priv->regulator)) if (IS_ERR(priv->regulator))
...@@ -470,7 +464,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv) ...@@ -470,7 +464,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
led = &priv->leds[i]; led = &priv->leds[i];
ret = fwnode_property_count_u32(child, "reg"); ret = fwnode_property_count_u32(child, "reg");
if (ret < 0) { if (ret < 0) {
dev_err(&priv->client->dev, "reg property is invalid\n"); dev_err(priv->dev, "reg property is invalid\n");
goto child_out; goto child_out;
} }
...@@ -510,12 +504,11 @@ static int lp50xx_probe_dt(struct lp50xx *priv) ...@@ -510,12 +504,11 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
led_cdev = &led->mc_cdev.led_cdev; led_cdev = &led->mc_cdev.led_cdev;
led_cdev->brightness_set_blocking = lp50xx_brightness_set; led_cdev->brightness_set_blocking = lp50xx_brightness_set;
ret = devm_led_classdev_multicolor_register_ext(&priv->client->dev, ret = devm_led_classdev_multicolor_register_ext(priv->dev,
&led->mc_cdev, &led->mc_cdev,
&init_data); &init_data);
if (ret) { if (ret) {
dev_err(&priv->client->dev, "led register err: %d\n", dev_err(priv->dev, "led register err: %d\n", ret);
ret);
goto child_out; goto child_out;
} }
i++; i++;
...@@ -529,8 +522,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv) ...@@ -529,8 +522,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
return ret; return ret;
} }
static int lp50xx_probe(struct i2c_client *client, static int lp50xx_probe(struct i2c_client *client)
const struct i2c_device_id *id)
{ {
struct lp50xx *led; struct lp50xx *led;
int count; int count;
...@@ -550,7 +542,7 @@ static int lp50xx_probe(struct i2c_client *client, ...@@ -550,7 +542,7 @@ static int lp50xx_probe(struct i2c_client *client,
mutex_init(&led->lock); mutex_init(&led->lock);
led->client = client; led->client = client;
led->dev = &client->dev; led->dev = &client->dev;
led->chip_info = &lp50xx_chip_info_tbl[id->driver_data]; led->chip_info = device_get_match_data(&client->dev);
i2c_set_clientdata(client, led); i2c_set_clientdata(client, led);
led->regmap = devm_regmap_init_i2c(client, led->regmap = devm_regmap_init_i2c(client,
led->chip_info->lp50xx_regmap_config); led->chip_info->lp50xx_regmap_config);
...@@ -579,15 +571,14 @@ static int lp50xx_remove(struct i2c_client *client) ...@@ -579,15 +571,14 @@ static int lp50xx_remove(struct i2c_client *client)
ret = lp50xx_enable_disable(led, 0); ret = lp50xx_enable_disable(led, 0);
if (ret) { if (ret) {
dev_err(&led->client->dev, "Failed to disable chip\n"); dev_err(led->dev, "Failed to disable chip\n");
return ret; return ret;
} }
if (led->regulator) { if (led->regulator) {
ret = regulator_disable(led->regulator); ret = regulator_disable(led->regulator);
if (ret) if (ret)
dev_err(&led->client->dev, dev_err(led->dev, "Failed to disable regulator\n");
"Failed to disable regulator\n");
} }
mutex_destroy(&led->lock); mutex_destroy(&led->lock);
...@@ -596,24 +587,24 @@ static int lp50xx_remove(struct i2c_client *client) ...@@ -596,24 +587,24 @@ static int lp50xx_remove(struct i2c_client *client)
} }
static const struct i2c_device_id lp50xx_id[] = { static const struct i2c_device_id lp50xx_id[] = {
{ "lp5009", LP5009 }, { "lp5009", (kernel_ulong_t)&lp50xx_chip_info_tbl[LP5009] },
{ "lp5012", LP5012 }, { "lp5012", (kernel_ulong_t)&lp50xx_chip_info_tbl[LP5012] },
{ "lp5018", LP5018 }, { "lp5018", (kernel_ulong_t)&lp50xx_chip_info_tbl[LP5018] },
{ "lp5024", LP5024 }, { "lp5024", (kernel_ulong_t)&lp50xx_chip_info_tbl[LP5024] },
{ "lp5030", LP5030 }, { "lp5030", (kernel_ulong_t)&lp50xx_chip_info_tbl[LP5030] },
{ "lp5036", LP5036 }, { "lp5036", (kernel_ulong_t)&lp50xx_chip_info_tbl[LP5036] },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, lp50xx_id); MODULE_DEVICE_TABLE(i2c, lp50xx_id);
static const struct of_device_id of_lp50xx_leds_match[] = { static const struct of_device_id of_lp50xx_leds_match[] = {
{ .compatible = "ti,lp5009", .data = (void *)LP5009 }, { .compatible = "ti,lp5009", .data = &lp50xx_chip_info_tbl[LP5009] },
{ .compatible = "ti,lp5012", .data = (void *)LP5012 }, { .compatible = "ti,lp5012", .data = &lp50xx_chip_info_tbl[LP5012] },
{ .compatible = "ti,lp5018", .data = (void *)LP5018 }, { .compatible = "ti,lp5018", .data = &lp50xx_chip_info_tbl[LP5018] },
{ .compatible = "ti,lp5024", .data = (void *)LP5024 }, { .compatible = "ti,lp5024", .data = &lp50xx_chip_info_tbl[LP5024] },
{ .compatible = "ti,lp5030", .data = (void *)LP5030 }, { .compatible = "ti,lp5030", .data = &lp50xx_chip_info_tbl[LP5030] },
{ .compatible = "ti,lp5036", .data = (void *)LP5036 }, { .compatible = "ti,lp5036", .data = &lp50xx_chip_info_tbl[LP5036] },
{}, {}
}; };
MODULE_DEVICE_TABLE(of, of_lp50xx_leds_match); MODULE_DEVICE_TABLE(of, of_lp50xx_leds_match);
...@@ -622,7 +613,7 @@ static struct i2c_driver lp50xx_driver = { ...@@ -622,7 +613,7 @@ static struct i2c_driver lp50xx_driver = {
.name = "lp50xx", .name = "lp50xx",
.of_match_table = of_lp50xx_leds_match, .of_match_table = of_lp50xx_leds_match,
}, },
.probe = lp50xx_probe, .probe_new = lp50xx_probe,
.remove = lp50xx_remove, .remove = lp50xx_remove,
.id_table = lp50xx_id, .id_table = lp50xx_id,
}; };
......
...@@ -160,7 +160,7 @@ static void max8997_led_brightness_set(struct led_classdev *led_cdev, ...@@ -160,7 +160,7 @@ static void max8997_led_brightness_set(struct led_classdev *led_cdev,
} }
} }
static ssize_t max8997_led_show_mode(struct device *dev, static ssize_t mode_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -193,7 +193,7 @@ static ssize_t max8997_led_show_mode(struct device *dev, ...@@ -193,7 +193,7 @@ static ssize_t max8997_led_show_mode(struct device *dev,
return ret; return ret;
} }
static ssize_t max8997_led_store_mode(struct device *dev, static ssize_t mode_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
...@@ -222,7 +222,7 @@ static ssize_t max8997_led_store_mode(struct device *dev, ...@@ -222,7 +222,7 @@ static ssize_t max8997_led_store_mode(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode); static DEVICE_ATTR_RW(mode);
static struct attribute *max8997_attrs[] = { static struct attribute *max8997_attrs[] = {
&dev_attr_mode.attr, &dev_attr_mode.attr,
......
...@@ -204,7 +204,7 @@ static void netxbig_led_set(struct led_classdev *led_cdev, ...@@ -204,7 +204,7 @@ static void netxbig_led_set(struct led_classdev *led_cdev,
spin_unlock_irqrestore(&led_dat->lock, flags); spin_unlock_irqrestore(&led_dat->lock, flags);
} }
static ssize_t netxbig_led_sata_store(struct device *dev, static ssize_t sata_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buff, size_t count) const char *buff, size_t count)
{ {
...@@ -255,7 +255,7 @@ static ssize_t netxbig_led_sata_store(struct device *dev, ...@@ -255,7 +255,7 @@ static ssize_t netxbig_led_sata_store(struct device *dev,
return ret; return ret;
} }
static ssize_t netxbig_led_sata_show(struct device *dev, static ssize_t sata_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -265,7 +265,7 @@ static ssize_t netxbig_led_sata_show(struct device *dev, ...@@ -265,7 +265,7 @@ static ssize_t netxbig_led_sata_show(struct device *dev,
return sprintf(buf, "%d\n", led_dat->sata); return sprintf(buf, "%d\n", led_dat->sata);
} }
static DEVICE_ATTR(sata, 0644, netxbig_led_sata_show, netxbig_led_sata_store); static DEVICE_ATTR_RW(sata);
static struct attribute *netxbig_led_attrs[] = { static struct attribute *netxbig_led_attrs[] = {
&dev_attr_sata.attr, &dev_attr_sata.attr,
......
...@@ -441,7 +441,7 @@ static void set_power_light_amber_noblink(void) ...@@ -441,7 +441,7 @@ static void set_power_light_amber_noblink(void)
nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL); nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL);
} }
static ssize_t nas_led_blink_show(struct device *dev, static ssize_t blink_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led = dev_get_drvdata(dev); struct led_classdev *led = dev_get_drvdata(dev);
...@@ -451,7 +451,7 @@ static ssize_t nas_led_blink_show(struct device *dev, ...@@ -451,7 +451,7 @@ static ssize_t nas_led_blink_show(struct device *dev,
return sprintf(buf, "%u\n", blinking); return sprintf(buf, "%u\n", blinking);
} }
static ssize_t nas_led_blink_store(struct device *dev, static ssize_t blink_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
...@@ -468,7 +468,7 @@ static ssize_t nas_led_blink_store(struct device *dev, ...@@ -468,7 +468,7 @@ static ssize_t nas_led_blink_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store); static DEVICE_ATTR_RW(blink);
static struct attribute *nasgpio_led_attrs[] = { static struct attribute *nasgpio_led_attrs[] = {
&dev_attr_blink.attr, &dev_attr_blink.attr,
...@@ -478,7 +478,6 @@ ATTRIBUTE_GROUPS(nasgpio_led); ...@@ -478,7 +478,6 @@ ATTRIBUTE_GROUPS(nasgpio_led);
static int register_nasgpio_led(int led_nr) static int register_nasgpio_led(int led_nr)
{ {
int ret;
struct nasgpio_led *nas_led = &nasgpio_leds[led_nr]; struct nasgpio_led *nas_led = &nasgpio_leds[led_nr];
struct led_classdev *led = get_classdev_for_led_nr(led_nr); struct led_classdev *led = get_classdev_for_led_nr(led_nr);
...@@ -489,11 +488,8 @@ static int register_nasgpio_led(int led_nr) ...@@ -489,11 +488,8 @@ static int register_nasgpio_led(int led_nr)
led->brightness_set = nasgpio_led_set_brightness; led->brightness_set = nasgpio_led_set_brightness;
led->blink_set = nasgpio_led_set_blink; led->blink_set = nasgpio_led_set_blink;
led->groups = nasgpio_led_groups; led->groups = nasgpio_led_groups;
ret = led_classdev_register(&nas_gpio_pci_dev->dev, led);
if (ret)
return ret;
return 0; return led_classdev_register(&nas_gpio_pci_dev->dev, led);
} }
static void unregister_nasgpio_led(int led_nr) static void unregister_nasgpio_led(int led_nr)
......
...@@ -155,7 +155,7 @@ static const char * const led_src_texts[] = { ...@@ -155,7 +155,7 @@ static const char * const led_src_texts[] = {
"soft", "soft",
}; };
static ssize_t wm831x_status_src_show(struct device *dev, static ssize_t src_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -178,7 +178,7 @@ static ssize_t wm831x_status_src_show(struct device *dev, ...@@ -178,7 +178,7 @@ static ssize_t wm831x_status_src_show(struct device *dev,
return ret; return ret;
} }
static ssize_t wm831x_status_src_store(struct device *dev, static ssize_t src_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
...@@ -197,7 +197,7 @@ static ssize_t wm831x_status_src_store(struct device *dev, ...@@ -197,7 +197,7 @@ static ssize_t wm831x_status_src_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(src, 0644, wm831x_status_src_show, wm831x_status_src_store); static DEVICE_ATTR_RW(src);
static struct attribute *wm831x_status_attrs[] = { static struct attribute *wm831x_status_attrs[] = {
&dev_attr_src.attr, &dev_attr_src.attr,
......
...@@ -19,10 +19,8 @@ static inline int led_get_brightness(struct led_classdev *led_cdev) ...@@ -19,10 +19,8 @@ static inline int led_get_brightness(struct led_classdev *led_cdev)
void led_init_core(struct led_classdev *led_cdev); void led_init_core(struct led_classdev *led_cdev);
void led_stop_software_blink(struct led_classdev *led_cdev); void led_stop_software_blink(struct led_classdev *led_cdev);
void led_set_brightness_nopm(struct led_classdev *led_cdev, void led_set_brightness_nopm(struct led_classdev *led_cdev, unsigned int value);
enum led_brightness value); void led_set_brightness_nosleep(struct led_classdev *led_cdev, unsigned int value);
void led_set_brightness_nosleep(struct led_classdev *led_cdev,
enum led_brightness value);
ssize_t led_trigger_read(struct file *filp, struct kobject *kobj, ssize_t led_trigger_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *attr, char *buf, struct bin_attribute *attr, char *buf,
loff_t pos, size_t count); loff_t pos, size_t count);
......
...@@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( ...@@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev(
return container_of(lcdev, struct led_classdev_flash, led_cdev); return container_of(lcdev, struct led_classdev_flash, led_cdev);
} }
#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH)
/** /**
* led_classdev_flash_register_ext - register a new object of LED class with * led_classdev_flash_register_ext - register a new object of LED class with
* init data and with support for flash LEDs * init data and with support for flash LEDs
...@@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, ...@@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent,
struct led_classdev_flash *fled_cdev, struct led_classdev_flash *fled_cdev,
struct led_init_data *init_data); struct led_init_data *init_data);
static inline int led_classdev_flash_register(struct device *parent,
struct led_classdev_flash *fled_cdev)
{
return led_classdev_flash_register_ext(parent, fled_cdev, NULL);
}
/** /**
* led_classdev_flash_unregister - unregisters an object of led_classdev class * led_classdev_flash_unregister - unregisters an object of led_classdev class
* with support for flash LEDs * with support for flash LEDs
...@@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, ...@@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent,
struct led_init_data *init_data); struct led_init_data *init_data);
void devm_led_classdev_flash_unregister(struct device *parent,
struct led_classdev_flash *fled_cdev);
#else
static inline int led_classdev_flash_register_ext(struct device *parent,
struct led_classdev_flash *fled_cdev,
struct led_init_data *init_data)
{
return 0;
}
static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {};
static inline int devm_led_classdev_flash_register_ext(struct device *parent,
struct led_classdev_flash *fled_cdev,
struct led_init_data *init_data)
{
return 0;
}
static inline void devm_led_classdev_flash_unregister(struct device *parent,
struct led_classdev_flash *fled_cdev)
{};
#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */
static inline int led_classdev_flash_register(struct device *parent,
struct led_classdev_flash *fled_cdev)
{
return led_classdev_flash_register_ext(parent, fled_cdev, NULL);
}
static inline int devm_led_classdev_flash_register(struct device *parent, static inline int devm_led_classdev_flash_register(struct device *parent,
struct led_classdev_flash *fled_cdev) struct led_classdev_flash *fled_cdev)
{ {
return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL);
} }
void devm_led_classdev_flash_unregister(struct device *parent,
struct led_classdev_flash *fled_cdev);
/** /**
* led_set_flash_strobe - setup flash strobe * led_set_flash_strobe - setup flash strobe
* @fled_cdev: the flash LED to set strobe on * @fled_cdev: the flash LED to set strobe on
......
...@@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, ...@@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent,
struct led_classdev_mc *mcled_cdev, struct led_classdev_mc *mcled_cdev,
struct led_init_data *init_data); struct led_init_data *init_data);
static inline int led_classdev_multicolor_register(struct device *parent,
struct led_classdev_mc *mcled_cdev)
{
return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL);
}
/** /**
* led_classdev_multicolor_unregister - unregisters an object of led_classdev * led_classdev_multicolor_unregister - unregisters an object of led_classdev
* class with support for multicolor LEDs * class with support for multicolor LEDs
...@@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, ...@@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent,
struct led_classdev_mc *mcled_cdev, struct led_classdev_mc *mcled_cdev,
struct led_init_data *init_data); struct led_init_data *init_data);
static inline int devm_led_classdev_multicolor_register(struct device *parent,
struct led_classdev_mc *mcled_cdev)
{
return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev,
NULL);
}
void devm_led_classdev_multicolor_unregister(struct device *parent, void devm_led_classdev_multicolor_unregister(struct device *parent,
struct led_classdev_mc *mcled_cdev); struct led_classdev_mc *mcled_cdev);
#else #else
...@@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, ...@@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent,
struct led_classdev_mc *mcled_cdev, struct led_classdev_mc *mcled_cdev,
struct led_init_data *init_data) struct led_init_data *init_data)
{ {
return -EINVAL; return 0;
}
static inline int led_classdev_multicolor_register(struct device *parent,
struct led_classdev_mc *mcled_cdev)
{
return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL);
} }
static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {};
static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
return -EINVAL; return 0;
} }
static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, static inline int devm_led_classdev_multicolor_register_ext(struct device *parent,
struct led_classdev_mc *mcled_cdev, struct led_classdev_mc *mcled_cdev,
struct led_init_data *init_data) struct led_init_data *init_data)
{ {
return -EINVAL; return 0;
}
static inline void devm_led_classdev_multicolor_unregister(struct device *parent,
struct led_classdev_mc *mcled_cdev)
{};
#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */
static inline int led_classdev_multicolor_register(struct device *parent,
struct led_classdev_mc *mcled_cdev)
{
return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL);
} }
static inline int devm_led_classdev_multicolor_register(struct device *parent, static inline int devm_led_classdev_multicolor_register(struct device *parent,
...@@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, ...@@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent,
NULL); NULL);
} }
static inline void devm_led_classdev_multicolor_unregister(struct device *parent,
struct led_classdev_mc *mcled_cdev)
{};
#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */
#endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */
...@@ -63,8 +63,8 @@ struct led_hw_trigger_type { ...@@ -63,8 +63,8 @@ struct led_hw_trigger_type {
struct led_classdev { struct led_classdev {
const char *name; const char *name;
enum led_brightness brightness; unsigned int brightness;
enum led_brightness max_brightness; unsigned int max_brightness;
int flags; int flags;
/* Lower 16 bits reflect status */ /* Lower 16 bits reflect status */
...@@ -253,8 +253,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev, ...@@ -253,8 +253,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
* software blink timer that implements blinking when the * software blink timer that implements blinking when the
* hardware doesn't. This function is guaranteed not to sleep. * hardware doesn't. This function is guaranteed not to sleep.
*/ */
void led_set_brightness(struct led_classdev *led_cdev, void led_set_brightness(struct led_classdev *led_cdev, unsigned int brightness);
enum led_brightness brightness);
/** /**
* led_set_brightness_sync - set LED brightness synchronously * led_set_brightness_sync - set LED brightness synchronously
...@@ -267,8 +266,7 @@ void led_set_brightness(struct led_classdev *led_cdev, ...@@ -267,8 +266,7 @@ void led_set_brightness(struct led_classdev *led_cdev,
* *
* Returns: 0 on success or negative error value on failure * Returns: 0 on success or negative error value on failure
*/ */
int led_set_brightness_sync(struct led_classdev *led_cdev, int led_set_brightness_sync(struct led_classdev *led_cdev, unsigned int value);
enum led_brightness value);
/** /**
* led_update_brightness - update LED brightness * led_update_brightness - update LED brightness
...@@ -565,7 +563,7 @@ static inline void ledtrig_cpu(enum cpu_led_event evt) ...@@ -565,7 +563,7 @@ static inline void ledtrig_cpu(enum cpu_led_event evt)
#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED #ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED
void led_classdev_notify_brightness_hw_changed( void led_classdev_notify_brightness_hw_changed(
struct led_classdev *led_cdev, enum led_brightness brightness); struct led_classdev *led_cdev, unsigned int brightness);
#else #else
static inline void led_classdev_notify_brightness_hw_changed( static inline void led_classdev_notify_brightness_hw_changed(
struct led_classdev *led_cdev, enum led_brightness brightness) { } struct led_classdev *led_cdev, enum led_brightness brightness) { }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment