Commit 7fafb54c authored by Linus Torvalds's avatar Linus Torvalds

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

Pull LED updates from Pavel Machek:
 "Quite a lot of stuff is going on here. Great cleanups/fixes from Marek
  and others are biggest part.

  I limited CPU LED trigger to 8 LEDs, because it was willing to
  register 1024 'triggers' on machine with 1024 CPUs. I don't believe it
  will cause any problems, but we can raise the limit if it does"

* tag 'leds-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: (84 commits)
  leds: pwm: Remove platform_data support
  leds: lm3697: Fix out-of-bound access
  leds: ns2: do not guard OF match pointer with of_match_ptr
  leds: ns2: convert to fwnode API
  leds: tlc591xx: fix leak of device node iterator
  leds: pca963x: use struct led_init_data when registering
  leds: pca963x: register LEDs immediately after parsing, get rid of platdata
  leds: tca6507: remove binding comment
  leds: tca6507: cosmetic change: use helper variable
  leds: tca6507: do not set GPIO names
  dt-bindings: leds: tca6507: convert to YAML
  ledtrig-cpu: Limit to 8 CPUs
  leds: TODO: Add documentation about possible subsystem improvements
  leds: pca9532: read pwm settings from device tree
  leds: pca9532: correct shift computation in pca9532_getled
  leds: lm36274: Fix warning for undefined parameters
  leds: lm3532: Fix warnings for undefined parameters
  leds: pca963x: use flexible array
  leds: pca963x: cosmetic: rename variables
  leds: pca963x: cosmetic: rename variables
  ...
parents 55e0500e 19d2e0ce
......@@ -16,6 +16,7 @@ Optional properties:
- audio-gain-db : audio gain selection for external analog modulation input.
Valid values: 0 - 21, step by 3 (rounded down)
Default: 0
- shutdown-gpios : Specifier of the GPIO connected to SDB pin of the chip.
Each led is represented as a sub-node of the issi,is31fl319x device.
There can be less leds subnodes than the chip can support but not more.
......@@ -44,6 +45,7 @@ fancy_leds: leds@65 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x65>;
shutdown-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
red_aux: led@1 {
label = "red:aux";
......
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/leds-lp50xx.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: LED driver for LP50XX RGB LED from Texas Instruments.
maintainers:
- Dan Murphy <dmurphy@ti.com>
description: |
The LP50XX is multi-channel, I2C RGB LED Drivers that can group RGB LEDs into
a LED group or control them individually.
The difference in these RGB LED drivers is the number of supported RGB
modules.
For more product information please see the link below:
https://www.ti.com/lit/ds/symlink/lp5012.pdf
https://www.ti.com/lit/ds/symlink/lp5024.pdf
https://www.ti.com/lit/ds/symlink/lp5036.pdf
properties:
compatible:
enum:
- ti,lp5009
- ti,lp5012
- ti,lp5018
- ti,lp5024
- ti,lp5030
- ti,lp5036
reg:
maxItems: 1
description:
I2C slave address
lp5009/12 - 0x14, 0x15, 0x16, 0x17
lp5018/24 - 0x28, 0x29, 0x2a, 0x2b
lp5030/36 - 0x30, 0x31, 0x32, 0x33
enable-gpios:
maxItems: 1
description: GPIO pin to enable/disable the device.
vled-supply:
description: LED supply.
patternProperties:
'^multi-led@[0-9a-f]$':
type: object
allOf:
- $ref: leds-class-multicolor.yaml#
properties:
reg:
minItems: 1
maxItems: 12
description:
This property denotes the LED module number(s) that is used on the
for the child node. The LED modules can either be used stand alone
or grouped into a module bank.
patternProperties:
"(^led-[0-9a-f]$|led)":
type: object
$ref: common.yaml#
required:
- compatible
- reg
examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
led-controller@14 {
compatible = "ti,lp5009";
reg = <0x14>;
#address-cells = <1>;
#size-cells = <0>;
enable-gpios = <&gpio1 16>;
multi-led@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x1>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_CHARGING;
led-0 {
color = <LED_COLOR_ID_RED>;
};
led-1 {
color = <LED_COLOR_ID_GREEN>;
};
led-2 {
color = <LED_COLOR_ID_BLUE>;
};
};
multi-led@2 {
#address-cells = <1>;
#size-cells = <2>;
reg = <0x2 0x3 0x5>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_STANDBY;
led-6 {
color = <LED_COLOR_ID_RED>;
};
led-7 {
color = <LED_COLOR_ID_GREEN>;
};
led-8 {
color = <LED_COLOR_ID_BLUE>;
};
};
};
};
...
......@@ -189,7 +189,7 @@ examples:
#address-cells = <1>;
#size-cells = <0>;
reg = <0x2>;
color = <LED_COLOR_ID_MULTI>;
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_STANDBY;
linux,default-trigger = "heartbeat";
......
......@@ -9,6 +9,7 @@ Required properties:
"nxp,pca9550"
"nxp,pca9551"
"nxp,pca9552"
"ibm,pca9552"
"nxp,pca9553"
- #address-cells: must be 1
- #size-cells: must be 0
......
LEDs connected to tca6507
Required properties:
- compatible : should be : "ti,tca6507".
- #address-cells: must be 1
- #size-cells: must be 0
- reg: typically 0x45.
Optional properties:
- gpio-controller: allows lines to be used as output-only GPIOs.
- #gpio-cells: if present, must not be 0.
Each led is represented as a sub-node of the ti,tca6507 device.
LED sub-node properties:
- label : (optional) see Documentation/devicetree/bindings/leds/common.txt
- reg : number of LED line (could be from 0 to 6)
- linux,default-trigger : (optional)
see Documentation/devicetree/bindings/leds/common.txt
- compatible: either "led" (the default) or "gpio".
Examples:
tca6507@45 {
compatible = "ti,tca6507";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x45>;
gpio-controller;
#gpio-cells = <2>;
led0: red-aux@0 {
label = "red:aux";
reg = <0x0>;
};
led1: green-aux@1 {
label = "green:aux";
reg = <0x5>;
linux,default-trigger = "default-on";
};
wifi-reset@6 {
reg = <0x6>;
compatible = "gpio";
};
};
# SPDX-License-Identifier: GPL-2.0-only
%YAML 1.2
---
$id: http://devicetree.org/schemas/leds/ti,tca6507.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: TCA6507 LED and GPIO controller
maintainers:
- NeilBrown <neilb@suse.de>
description:
The TCA6507 is a programmable LED controller connected via I2C that can drive
7 separate lines either by holding them low, or by pulsing them with modulated
width.
properties:
compatible:
const: ti,tca6507
reg:
description: I2C slave address of the controller.
maxItems: 1
"#address-cells":
const: 1
"#size-cells":
const: 0
gpio-controller: true
"#gpio-cells":
const: 2
gpio-line-names: true
patternProperties:
"^led@[0-6]$":
type: object
$ref: common.yaml#
properties:
reg:
minimum: 0
maximum: 6
required:
- reg
"^gpio@[0-6]$":
type: object
properties:
compatible:
const: gpio
reg:
minimum: 0
maximum: 6
additionalProperties: false
required:
- reg
- compatible
if:
patternProperties:
"^gpio@[0-6]$":
properties:
compatible:
contains:
const: gpio
then:
required:
- gpio-controller
- "#gpio-cells"
additionalProperties: false
examples:
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/leds/common.h>
i2c0 {
#address-cells = <1>;
#size-cells = <0>;
led-controller@45 {
compatible = "ti,tca6507";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x45>;
gpio-controller;
#gpio-cells = <2>;
gpio-line-names = "wifi_reset@6";
led@0 {
label = "gta04:red:aux";
reg = <0x0>;
};
led@1 {
label = "gta04:green:aux";
reg = <0x1>;
};
led@3 {
reg = <0x3>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_POWER;
linux,default-trigger = "default-on";
};
led@4 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_POWER;
reg = <0x4>;
};
gpio@6 {
compatible = "gpio";
reg = <0x6>;
};
};
};
...
......@@ -17,12 +17,6 @@ set a timer to hold a state, however when user space application crashes or
goes away without deactivating the timer, the hardware will be left in that
state permanently.
As a specific example of this use-case, let's look at vibrate feature on
phones. Vibrate function on phones is implemented using PWM pins on SoC or
PMIC. There is a need to activate one shot timer to control the vibrate
feature, to prevent user space crashes leaving the phone in vibrate mode
permanently causing the battery to drain.
Transient trigger addresses the need for one shot timer activation. The
transient trigger can be enabled and disabled just like the other leds
triggers.
......@@ -159,7 +153,6 @@ repeat the following step as needed::
This trigger is intended to be used for the following example use cases:
- Control of vibrate (phones, tablets etc.) hardware by user space app.
- Use of LED by user space app as activity indicator.
- Use of LED by user space app as a kind of watchdog indicator -- as
long as the app is alive, it can keep the LED illuminated, if it dies
......
......@@ -274,7 +274,7 @@ config LEDS_MT6323
config LEDS_S3C24XX
tristate "LED Support for Samsung S3C24XX GPIO LEDs"
depends on LEDS_CLASS
depends on ARCH_S3C24XX
depends on ARCH_S3C24XX || COMPILE_TEST
help
This option enables support for LEDs connected to GPIO lines
on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440.
......@@ -304,13 +304,13 @@ config LEDS_WRAP
config LEDS_COBALT_QUBE
tristate "LED Support for the Cobalt Qube series front LED"
depends on LEDS_CLASS
depends on MIPS_COBALT
depends on MIPS_COBALT || COMPILE_TEST
help
This option enables support for the front LED on Cobalt Qube series
config LEDS_COBALT_RAQ
bool "LED Support for the Cobalt Raq series"
depends on LEDS_CLASS=y && MIPS_COBALT
depends on LEDS_CLASS=y && (MIPS_COBALT || COMPILE_TEST)
select LEDS_TRIGGERS
help
This option enables support for the Cobalt Raq series LEDs.
......@@ -395,8 +395,20 @@ config LEDS_LP3952
To compile this driver as a module, choose M here: the
module will be called leds-lp3952.
config LEDS_LP50XX
tristate "LED Support for TI LP5036/30/24/18/12/9 LED driver chip"
depends on LEDS_CLASS && REGMAP_I2C
depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR
help
If you say yes here you get support for the Texas Instruments
LP5036, LP5030, LP5024, LP5018, LP5012 and LP5009 LED driver.
To compile this driver as a module, choose M here: the
module will be called leds-lp50xx.
config LEDS_LP55XX_COMMON
tristate "Common Driver for TI/National LP5521/5523/55231/5562/8501"
depends on LEDS_CLASS
depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR
depends on OF
depends on I2C
......@@ -632,7 +644,7 @@ config LEDS_MC13783
config LEDS_NS2
tristate "LED support for Network Space v2 GPIO LEDs"
depends on LEDS_CLASS
depends on MACH_KIRKWOOD || MACH_ARMADA_370
depends on MACH_KIRKWOOD || MACH_ARMADA_370 || COMPILE_TEST
default y
help
This option enables support for the dual-GPIO LEDs found on the
......@@ -646,7 +658,7 @@ config LEDS_NS2
config LEDS_NETXBIG
tristate "LED support for Big Network series LEDs"
depends on LEDS_CLASS
depends on MACH_KIRKWOOD
depends on MACH_KIRKWOOD || COMPILE_TEST
depends on OF_GPIO
default y
help
......@@ -893,7 +905,7 @@ config LEDS_TPS6105X
config LEDS_IP30
tristate "LED support for SGI Octane machines"
depends on LEDS_CLASS
depends on SGI_MFD_IOC3
depends on SGI_MFD_IOC3 || COMPILE_TEST
help
This option enables support for the Red and White LEDs of
SGI Octane machines.
......@@ -909,6 +921,13 @@ config LEDS_SGM3140
This option enables support for the SGM3140 500mA Buck/Boost Charge
Pump LED Driver.
config LEDS_ACER_A500
tristate "Power button LED support for Acer Iconia Tab A500"
depends on LEDS_CLASS && MFD_ACER_A500_EC
help
This option enables support for the Power Button LED of
Acer Iconia Tab A500.
comment "LED Triggers"
source "drivers/leds/trigger/Kconfig"
......
......@@ -10,6 +10,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o
# LED Platform Drivers (keep this sorted, M-| sort)
obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o
obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o
obj-$(CONFIG_LEDS_ACER_A500) += leds-acer-a500.o
obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
obj-$(CONFIG_LEDS_AN30259A) += leds-an30259a.o
obj-$(CONFIG_LEDS_APU) += leds-apu.o
......@@ -49,6 +50,7 @@ obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o
obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o
obj-$(CONFIG_LEDS_LP3952) += leds-lp3952.o
obj-$(CONFIG_LEDS_LP50XX) += leds-lp50xx.o
obj-$(CONFIG_LEDS_LP5521) += leds-lp5521.o
obj-$(CONFIG_LEDS_LP5523) += leds-lp5523.o
obj-$(CONFIG_LEDS_LP5562) += leds-lp5562.o
......
-*- org -*-
* On/off LEDs should have max_brightness of 1
* Get rid of enum led_brightness
It is really an integer, as maximum is configurable. Get rid of it, or
make it into typedef or something.
* Review atomicity requirements in LED subsystem
Calls that may and that may not block are mixed in same structure, and
semantics is sometimes non-intuitive. (For example blink callback may
not sleep.) Review the requirements for any bugs and document them
clearly.
* LED names are still a mess
No two LEDs have same name, so the names are probably unusable for the
userland. Nudge authors into creating common LED names for common
functionality.
? Perhaps check for known LED names during boot, and warn if there are
LEDs not on the list?
* Split drivers into subdirectories
The number of drivers is getting big, and driver for on/off LED on a
i/o port is really quite different from camera flash LED, which is
really different from driver for RGB color LED that can run its own
microcode. Split the drivers somehow.
* Figure out what to do with RGB leds
Multicolor is a bit too abstract. Yes, we can have
Green-Magenta-Ultraviolet LED, but so far all the LEDs we support are
RGB, and not even RGB-White or RGB-Yellow variants emerged.
Multicolor is not a good fit for RGB LED. It does not really know
about LED color. In particular, there's no way to make LED "white".
Userspace is interested in knowing "this LED can produce arbitrary
color", which not all multicolor LEDs can.
Proposal: let's add "rgb" to led_colors in drivers/leds/led-core.c,
add corresponding device tree defines, and use that, instead of
multicolor for RGB LEDs.
We really need to do that now; "white" stuff can wait.
RGB LEDs are quite common, and it would be good to be able to turn LED
white and to turn it into any arbitrary color. It is essential that
userspace is able to set arbitrary colors, and it might be good to
have that ability from kernel, too... to allow full-color triggers.
* Command line utility to manipulate the LEDs?
/sys interface is not really suitable to use by hand, should we have
an utility to perform LED control?
In particular, LED names are still a mess (see above) and utility
could help there by presenting both old and new names while we clean
them up.
In future, I'd like utility to accept both old and new names while we
clean them up.
It would be also nice to have useful listing mode -- name, type,
current brightness/trigger...
In future, it would be good to be able to set rgb led to particular
color.
And probably user-friendly interface to access LEDs for particular
ethernet interface would be nice.
......@@ -354,6 +354,11 @@ int led_classdev_register_ext(struct device *parent,
ret = led_compose_name(parent, init_data, composed_name);
if (ret < 0)
return ret;
if (init_data->fwnode)
fwnode_property_read_string(init_data->fwnode,
"linux,default-trigger",
&led_cdev->default_trigger);
} else {
proposed_name = led_cdev->name;
}
......
......@@ -118,14 +118,14 @@ static int pm860x_led_dt_init(struct platform_device *pdev,
struct device_node *nproot, *np;
int iset = 0;
if (!pdev->dev.parent->of_node)
if (!dev_of_node(pdev->dev.parent))
return -ENODEV;
nproot = of_get_child_by_name(pdev->dev.parent->of_node, "leds");
nproot = of_get_child_by_name(dev_of_node(pdev->dev.parent), "leds");
if (!nproot) {
dev_err(&pdev->dev, "failed to find leds node\n");
return -ENODEV;
}
for_each_child_of_node(nproot, np) {
for_each_available_child_of_node(nproot, np) {
if (of_node_name_eq(np, data->name)) {
of_property_read_u32(np, "marvell,88pm860x-iset",
&iset);
......
......@@ -248,7 +248,7 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
}
#endif
child_node = of_get_next_available_child(dev->of_node, NULL);
child_node = of_get_next_available_child(dev_of_node(dev), NULL);
if (!child_node) {
dev_err(dev, "No DT child node found for connected LED.\n");
return -EINVAL;
......
// SPDX-License-Identifier: GPL-2.0+
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#define A500_EC_LED_DELAY_USEC (100 * 1000)
enum {
REG_RESET_LEDS = 0x40,
REG_POWER_LED_ON = 0x42,
REG_CHARGE_LED_ON = 0x43,
REG_ANDROID_LEDS_OFF = 0x5a,
};
struct a500_led {
struct led_classdev cdev;
const struct reg_sequence *enable_seq;
struct a500_led *other;
struct regmap *rmap;
};
static const struct reg_sequence a500_ec_leds_reset_seq[] = {
REG_SEQ(REG_RESET_LEDS, 0x0, A500_EC_LED_DELAY_USEC),
REG_SEQ(REG_ANDROID_LEDS_OFF, 0x0, A500_EC_LED_DELAY_USEC),
};
static const struct reg_sequence a500_ec_white_led_enable_seq[] = {
REG_SEQ(REG_POWER_LED_ON, 0x0, A500_EC_LED_DELAY_USEC),
};
static const struct reg_sequence a500_ec_orange_led_enable_seq[] = {
REG_SEQ(REG_CHARGE_LED_ON, 0x0, A500_EC_LED_DELAY_USEC),
};
static int a500_ec_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct a500_led *led = container_of(led_cdev, struct a500_led, cdev);
struct reg_sequence control_seq[2];
unsigned int num_regs = 1;
if (value) {
control_seq[0] = led->enable_seq[0];
} else {
/*
* There is no separate controls which can disable LEDs
* individually, there is only RESET_LEDS command that turns
* off both LEDs.
*
* RESET_LEDS turns off both LEDs, thus restore other LED if
* it's turned ON.
*/
if (led->other->cdev.brightness)
num_regs = 2;
control_seq[0] = a500_ec_leds_reset_seq[0];
control_seq[1] = led->other->enable_seq[0];
}
return regmap_multi_reg_write(led->rmap, control_seq, num_regs);
}
static int a500_ec_leds_probe(struct platform_device *pdev)
{
struct a500_led *white_led, *orange_led;
struct regmap *rmap;
int err;
rmap = dev_get_regmap(pdev->dev.parent, "KB930");
if (!rmap)
return -EINVAL;
/* reset and turn off LEDs */
regmap_multi_reg_write(rmap, a500_ec_leds_reset_seq, 2);
white_led = devm_kzalloc(&pdev->dev, sizeof(*white_led), GFP_KERNEL);
if (!white_led)
return -ENOMEM;
white_led->cdev.name = "power:white";
white_led->cdev.brightness_set_blocking = a500_ec_led_brightness_set;
white_led->cdev.flags = LED_CORE_SUSPENDRESUME;
white_led->cdev.max_brightness = 1;
white_led->enable_seq = a500_ec_white_led_enable_seq;
white_led->rmap = rmap;
orange_led = devm_kzalloc(&pdev->dev, sizeof(*orange_led), GFP_KERNEL);
if (!orange_led)
return -ENOMEM;
orange_led->cdev.name = "power:orange";
orange_led->cdev.brightness_set_blocking = a500_ec_led_brightness_set;
orange_led->cdev.flags = LED_CORE_SUSPENDRESUME;
orange_led->cdev.max_brightness = 1;
orange_led->enable_seq = a500_ec_orange_led_enable_seq;
orange_led->rmap = rmap;
white_led->other = orange_led;
orange_led->other = white_led;
err = devm_led_classdev_register(&pdev->dev, &white_led->cdev);
if (err) {
dev_err(&pdev->dev, "failed to register white LED\n");
return err;
}
err = devm_led_classdev_register(&pdev->dev, &orange_led->cdev);
if (err) {
dev_err(&pdev->dev, "failed to register orange LED\n");
return err;
}
return 0;
}
static struct platform_driver a500_ec_leds_driver = {
.driver = {
.name = "acer-a500-iconia-leds",
},
.probe = a500_ec_leds_probe,
};
module_platform_driver(a500_ec_leds_driver);
MODULE_DESCRIPTION("LED driver for Acer Iconia Tab A500 Power Button");
MODULE_AUTHOR("Dmitry Osipenko <digetx@gmail.com>");
MODULE_ALIAS("platform:acer-a500-iconia-leds");
MODULE_LICENSE("GPL");
......@@ -202,13 +202,13 @@ static int an30259a_blink_set(struct led_classdev *cdev,
static int an30259a_dt_init(struct i2c_client *client,
struct an30259a *chip)
{
struct device_node *np = client->dev.of_node, *child;
struct device_node *np = dev_of_node(&client->dev), *child;
int count, ret;
int i = 0;
const char *str;
struct an30259a_led *led;
count = of_get_child_count(np);
count = of_get_available_child_count(np);
if (!count || count > AN30259A_MAX_LEDS)
return -EINVAL;
......@@ -238,9 +238,6 @@ static int an30259a_dt_init(struct i2c_client *client,
led->default_state = STATE_OFF;
}
of_property_read_string(child, "linux,default-trigger",
&led->cdev.default_trigger);
i++;
}
......
......@@ -261,11 +261,11 @@ static int aw2013_blink_set(struct led_classdev *cdev,
static int aw2013_probe_dt(struct aw2013 *chip)
{
struct device_node *np = chip->client->dev.of_node, *child;
struct device_node *np = dev_of_node(&chip->client->dev), *child;
int count, ret = 0, i = 0;
struct aw2013_led *led;
count = of_get_child_count(np);
count = of_get_available_child_count(np);
if (!count || count > AW2013_MAX_LEDS)
return -EINVAL;
......@@ -297,16 +297,15 @@ static int aw2013_probe_dt(struct aw2013 *chip)
"DT property led-max-microamp is missing\n");
}
of_property_read_string(child, "linux,default-trigger",
&led->cdev.default_trigger);
led->cdev.brightness_set_blocking = aw2013_brightness_set;
led->cdev.blink_set = aw2013_blink_set;
ret = devm_led_classdev_register_ext(&chip->client->dev,
&led->cdev, &init_data);
if (ret < 0)
if (ret < 0) {
of_node_put(child);
return ret;
}
i++;
}
......
......@@ -328,6 +328,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
void __iomem *mem, spinlock_t *lock,
unsigned long *blink_leds, unsigned long *blink_delay)
{
struct led_init_data init_data = {};
struct bcm6328_led *led;
const char *state;
int rc;
......@@ -345,11 +346,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
if (of_property_read_bool(nc, "active-low"))
led->active_low = true;
led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name;
led->cdev.default_trigger = of_get_property(nc,
"linux,default-trigger",
NULL);
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) {
led->cdev.brightness = LED_FULL;
......@@ -382,8 +378,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
led->cdev.brightness_set = bcm6328_led_set;
led->cdev.blink_set = bcm6328_blink_set;
init_data.fwnode = of_fwnode_handle(nc);
rc = led_classdev_register(dev, &led->cdev);
rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (rc < 0)
return rc;
......@@ -395,7 +392,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
static int bcm6328_leds_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = pdev->dev.of_node;
struct device_node *np = dev_of_node(&pdev->dev);
struct device_node *child;
void __iomem *mem;
spinlock_t *lock; /* memory lock */
......
......@@ -94,6 +94,7 @@ static void bcm6358_led_set(struct led_classdev *led_cdev,
static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
void __iomem *mem, spinlock_t *lock)
{
struct led_init_data init_data = {};
struct bcm6358_led *led;
const char *state;
int rc;
......@@ -109,11 +110,6 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
if (of_property_read_bool(nc, "active-low"))
led->active_low = true;
led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name;
led->cdev.default_trigger = of_get_property(nc,
"linux,default-trigger",
NULL);
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) {
led->cdev.brightness = LED_FULL;
......@@ -136,8 +132,9 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
bcm6358_led_set(&led->cdev, led->cdev.brightness);
led->cdev.brightness_set = bcm6358_led_set;
init_data.fwnode = of_fwnode_handle(nc);
rc = led_classdev_register(dev, &led->cdev);
rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (rc < 0)
return rc;
......@@ -149,7 +146,7 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
static int bcm6358_leds_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = pdev->dev.of_node;
struct device_node *np = dev_of_node(&pdev->dev);
struct device_node *child;
void __iomem *mem;
spinlock_t *lock; /* memory lock */
......
......@@ -158,19 +158,14 @@ MODULE_DEVICE_TABLE(of, cpcap_led_of_match);
static int cpcap_led_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
struct cpcap_led *led;
int err;
match = of_match_device(of_match_ptr(cpcap_led_of_match), &pdev->dev);
if (!match || !match->data)
return -EINVAL;
led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;
platform_set_drvdata(pdev, led);
led->info = match->data;
led->info = device_get_match_data(&pdev->dev);
led->dev = &pdev->dev;
if (led->info->reg == 0x0000) {
......
......@@ -188,9 +188,6 @@ static int cr0014114_probe_dt(struct cr0014114 *priv)
device_for_each_child_node(priv->dev, child) {
led = &priv->leds[i];
fwnode_property_read_string(child, "linux,default-trigger",
&led->ldev.default_trigger);
led->priv = priv;
led->ldev.max_brightness = CR_MAX_BRIGHTNESS;
led->ldev.brightness_set_blocking = cr0014114_set_sync;
......
......@@ -263,9 +263,6 @@ static int el15203000_probe_dt(struct el15203000 *priv)
return -EINVAL;
}
fwnode_property_read_string(child, "linux,default-trigger",
&led->ldev.default_trigger);
led->priv = priv;
led->ldev.max_brightness = LED_ON;
led->ldev.brightness_set_blocking = el15203000_set_blocking;
......
......@@ -160,9 +160,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
led_dat->gpiod = led.gpiod;
fwnode_property_read_string(child, "linux,default-trigger",
&led.default_trigger);
if (!fwnode_property_read_string(child, "default-state",
&state)) {
if (!strcmp(state, "keep"))
......
......@@ -3,6 +3,7 @@
* LED Driver for SGI Octane machines
*/
#include <asm/io.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
......
......@@ -16,6 +16,8 @@
#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
/* register numbers */
#define IS31FL319X_SHUTDOWN 0x00
......@@ -61,6 +63,7 @@
struct is31fl319x_chip {
const struct is31fl319x_chipdef *cdef;
struct i2c_client *client;
struct gpio_desc *shutdown_gpio;
struct regmap *regmap;
struct mutex lock;
u32 audio_gain_db;
......@@ -199,26 +202,27 @@ static int is31fl319x_parse_child_dt(const struct device *dev,
static int is31fl319x_parse_dt(struct device *dev,
struct is31fl319x_chip *is31)
{
struct device_node *np = dev->of_node, *child;
const struct of_device_id *of_dev_id;
struct device_node *np = dev_of_node(dev), *child;
int count;
int ret;
if (!np)
return -ENODEV;
of_dev_id = of_match_device(of_is31fl319x_match, dev);
if (!of_dev_id) {
dev_err(dev, "Failed to match device with supported chips\n");
return -EINVAL;
is31->shutdown_gpio = devm_gpiod_get_optional(dev,
"shutdown",
GPIOD_OUT_HIGH);
if (IS_ERR(is31->shutdown_gpio)) {
ret = PTR_ERR(is31->shutdown_gpio);
dev_err(dev, "Failed to get shutdown gpio: %d\n", ret);
return ret;
}
is31->cdef = of_dev_id->data;
is31->cdef = device_get_match_data(dev);
count = of_get_child_count(np);
count = of_get_available_child_count(np);
dev_dbg(dev, "probe %s with %d leds defined in DT\n",
of_dev_id->compatible, count);
dev_dbg(dev, "probing with %d leds defined in DT\n", count);
if (!count || count > is31->cdef->num_leds) {
dev_err(dev, "Number of leds defined must be between 1 and %u\n",
......@@ -226,7 +230,7 @@ static int is31fl319x_parse_dt(struct device *dev,
return -ENODEV;
}
for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
struct is31fl319x_led *led;
u32 reg;
......@@ -350,6 +354,12 @@ static int is31fl319x_probe(struct i2c_client *client,
if (err)
goto free_mutex;
if (is31->shutdown_gpio) {
gpiod_direction_output(is31->shutdown_gpio, 0);
mdelay(5);
gpiod_direction_output(is31->shutdown_gpio, 1);
}
is31->client = client;
is31->regmap = devm_regmap_init_i2c(client, &regmap_config);
if (IS_ERR(is31->regmap)) {
......
......@@ -332,9 +332,6 @@ static int is31fl32xx_parse_child_dt(const struct device *dev,
int ret = 0;
u32 reg;
if (of_property_read_string(child, "label", &cdev->name))
cdev->name = child->name;
ret = of_property_read_u32(child, "reg", &reg);
if (ret || reg < 1 || reg > led_data->priv->cdef->channels) {
dev_err(dev,
......@@ -344,9 +341,6 @@ static int is31fl32xx_parse_child_dt(const struct device *dev,
}
led_data->channel = reg;
of_property_read_string(child, "linux,default-trigger",
&cdev->default_trigger);
cdev->brightness_set_blocking = is31fl32xx_brightness_set;
return 0;
......@@ -372,7 +366,8 @@ static int is31fl32xx_parse_dt(struct device *dev,
struct device_node *child;
int ret = 0;
for_each_child_of_node(dev->of_node, child) {
for_each_available_child_of_node(dev_of_node(dev), child) {
struct led_init_data init_data = {};
struct is31fl32xx_led_data *led_data =
&priv->leds[priv->num_leds];
const struct is31fl32xx_led_data *other_led_data;
......@@ -388,17 +383,18 @@ static int is31fl32xx_parse_dt(struct device *dev,
led_data->channel);
if (other_led_data) {
dev_err(dev,
"%s and %s both attempting to use channel %d\n",
led_data->cdev.name,
other_led_data->cdev.name,
led_data->channel);
"Node %pOF 'reg' conflicts with another LED\n",
child);
goto err;
}
ret = devm_led_classdev_register(dev, &led_data->cdev);
init_data.fwnode = of_fwnode_handle(child);
ret = devm_led_classdev_register_ext(dev, &led_data->cdev,
&init_data);
if (ret) {
dev_err(dev, "failed to register PWM led for %s: %d\n",
led_data->cdev.name, ret);
dev_err(dev, "Failed to register LED for %pOF: %d\n",
child, ret);
goto err;
}
......@@ -428,19 +424,14 @@ static int is31fl32xx_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
const struct is31fl32xx_chipdef *cdef;
const struct of_device_id *of_dev_id;
struct device *dev = &client->dev;
struct is31fl32xx_priv *priv;
int count;
int ret = 0;
of_dev_id = of_match_device(of_is31fl32xx_match, dev);
if (!of_dev_id)
return -EINVAL;
cdef = of_dev_id->data;
cdef = device_get_match_data(dev);
count = of_get_child_count(dev->of_node);
count = of_get_available_child_count(dev_of_node(dev));
if (!count)
return -EINVAL;
......
......@@ -259,11 +259,11 @@ static void ktd2692_setup(struct ktd2692_context *led)
static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
struct ktd2692_led_config_data *cfg)
{
struct device_node *np = dev->of_node;
struct device_node *np = dev_of_node(dev);
struct device_node *child_node;
int ret;
if (!dev->of_node)
if (!dev_of_node(dev))
return -ENXIO;
led->ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS);
......
......@@ -96,15 +96,15 @@
/*
* struct lm3532_als_data
* @config - value of ALS configuration register
* @als1_imp_sel - value of ALS1 resistor select register
* @als2_imp_sel - value of ALS2 resistor select register
* @als_avrg_time - ALS averaging time
* @als_input_mode - ALS input mode for brightness control
* @als_vmin - Minimum ALS voltage
* @als_vmax - Maximum ALS voltage
* @zone_lo - values of ALS lo ZB(Zone Boundary) registers
* @zone_hi - values of ALS hi ZB(Zone Boundary) registers
* @config: value of ALS configuration register
* @als1_imp_sel: value of ALS1 resistor select register
* @als2_imp_sel: value of ALS2 resistor select register
* @als_avrg_time: ALS averaging time
* @als_input_mode: ALS input mode for brightness control
* @als_vmin: Minimum ALS voltage
* @als_vmax: Maximum ALS voltage
* @zone_lo: values of ALS lo ZB(Zone Boundary) registers
* @zone_hi: values of ALS hi ZB(Zone Boundary) registers
*/
struct lm3532_als_data {
u8 config;
......@@ -121,15 +121,14 @@ struct lm3532_als_data {
/**
* struct lm3532_led
* @led_dev: led class device
* @priv - Pointer the device data structure
* @control_bank - Control bank the LED is associated to
* @mode - Mode of the LED string
* @ctrl_brt_pointer - Zone target register that controls the sink
* @num_leds - Number of LED strings are supported in this array
* @full_scale_current - The full-scale current setting for the current sink.
* @led_strings - The LED strings supported in this array
* @enabled - Enabled status
* @label - LED label
* @priv: Pointer the device data structure
* @control_bank: Control bank the LED is associated to
* @mode: Mode of the LED string
* @ctrl_brt_pointer: Zone target register that controls the sink
* @num_leds: Number of LED strings are supported in this array
* @full_scale_current: The full-scale current setting for the current sink.
* @led_strings: The LED strings supported in this array
* @enabled: Enabled status
*/
struct lm3532_led {
struct led_classdev led_dev;
......@@ -142,21 +141,20 @@ struct lm3532_led {
int full_scale_current;
unsigned int enabled:1;
u32 led_strings[LM3532_MAX_CONTROL_BANKS];
char label[LED_MAX_NAME_SIZE];
};
/**
* struct lm3532_data
* @enable_gpio - Hardware enable gpio
* @enable_gpio: Hardware enable gpio
* @regulator: regulator
* @client: i2c client
* @regmap - Devices register map
* @dev - Pointer to the devices device struct
* @lock - Lock for reading/writing the device
* @als_data - Pointer to the als data struct
* @runtime_ramp_up - Runtime ramp up setting
* @runtime_ramp_down - Runtime ramp down setting
* @leds - Array of LED strings
* @regmap: Devices register map
* @dev: Pointer to the devices device struct
* @lock: Lock for reading/writing the device
* @als_data: Pointer to the als data struct
* @runtime_ramp_up: Runtime ramp up setting
* @runtime_ramp_down: Runtime ramp down setting
* @leds: Array of LED strings
*/
struct lm3532_data {
struct gpio_desc *enable_gpio;
......@@ -548,7 +546,6 @@ static int lm3532_parse_node(struct lm3532_data *priv)
{
struct fwnode_handle *child = NULL;
struct lm3532_led *led;
const char *name;
int control_bank;
u32 ramp_time;
size_t i = 0;
......@@ -643,19 +640,7 @@ static int lm3532_parse_node(struct lm3532_data *priv)
goto child_out;
}
fwnode_property_read_string(child, "linux,default-trigger",
&led->led_dev.default_trigger);
ret = fwnode_property_read_string(child, "label", &name);
if (ret)
snprintf(led->label, sizeof(led->label),
"%s::", priv->client->name);
else
snprintf(led->label, sizeof(led->label),
"%s:%s", priv->client->name, name);
led->priv = priv;
led->led_dev.name = led->label;
led->led_dev.brightness_set_blocking = lm3532_brightness_set;
ret = devm_led_classdev_register_ext(priv->dev, &led->led_dev, &idata);
......
......@@ -26,8 +26,8 @@
* @lmu_data: Register and setting values for common code
* @regmap: Devices register map
* @dev: Pointer to the devices device struct
* @led_sources - The LED strings supported in this array
* @num_leds - Number of LED strings are supported in this array
* @led_sources: The LED strings supported in this array
* @num_leds: Number of LED strings are supported in this array
*/
struct lm36274 {
struct platform_device *pdev;
......@@ -41,122 +41,113 @@ struct lm36274 {
};
static int lm36274_brightness_set(struct led_classdev *led_cdev,
enum led_brightness brt_val)
enum led_brightness brt_val)
{
struct lm36274 *led = container_of(led_cdev, struct lm36274, led_dev);
struct lm36274 *chip = container_of(led_cdev, struct lm36274, led_dev);
return ti_lmu_common_set_brightness(&led->lmu_data, brt_val);
return ti_lmu_common_set_brightness(&chip->lmu_data, brt_val);
}
static int lm36274_init(struct lm36274 *lm36274_data)
static int lm36274_init(struct lm36274 *chip)
{
int enable_val = 0;
int i;
for (i = 0; i < lm36274_data->num_leds; i++)
enable_val |= (1 << lm36274_data->led_sources[i]);
for (i = 0; i < chip->num_leds; i++)
enable_val |= (1 << chip->led_sources[i]);
if (!enable_val) {
dev_err(lm36274_data->dev, "No LEDs were enabled\n");
dev_err(chip->dev, "No LEDs were enabled\n");
return -EINVAL;
}
enable_val |= LM36274_BL_EN;
return regmap_write(lm36274_data->regmap, LM36274_REG_BL_EN,
enable_val);
return regmap_write(chip->regmap, LM36274_REG_BL_EN, enable_val);
}
static int lm36274_parse_dt(struct lm36274 *lm36274_data)
static int lm36274_parse_dt(struct lm36274 *chip,
struct led_init_data *init_data)
{
struct fwnode_handle *child = NULL;
char label[LED_MAX_NAME_SIZE];
struct device *dev = &lm36274_data->pdev->dev;
const char *name;
int child_cnt;
int ret = -EINVAL;
struct device *dev = chip->dev;
struct fwnode_handle *child;
int ret;
/* There should only be 1 node */
child_cnt = device_get_child_node_count(dev);
if (child_cnt != 1)
if (device_get_child_node_count(dev) != 1)
return -EINVAL;
device_for_each_child_node(dev, child) {
ret = fwnode_property_read_string(child, "label", &name);
if (ret)
snprintf(label, sizeof(label),
"%s::", lm36274_data->pdev->name);
else
snprintf(label, sizeof(label),
"%s:%s", lm36274_data->pdev->name, name);
lm36274_data->num_leds = fwnode_property_count_u32(child, "led-sources");
if (lm36274_data->num_leds <= 0)
return -ENODEV;
ret = fwnode_property_read_u32_array(child, "led-sources",
lm36274_data->led_sources,
lm36274_data->num_leds);
if (ret) {
dev_err(dev, "led-sources property missing\n");
return ret;
}
fwnode_property_read_string(child, "linux,default-trigger",
&lm36274_data->led_dev.default_trigger);
child = device_get_next_child_node(dev, NULL);
}
init_data->fwnode = child;
init_data->devicename = chip->pdev->name;
/* for backwards compatibility when `label` property is not present */
init_data->default_label = ":";
lm36274_data->lmu_data.regmap = lm36274_data->regmap;
lm36274_data->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
lm36274_data->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
lm36274_data->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB;
chip->num_leds = fwnode_property_count_u32(child, "led-sources");
if (chip->num_leds <= 0) {
ret = -ENODEV;
goto err;
}
lm36274_data->led_dev.name = label;
lm36274_data->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT;
lm36274_data->led_dev.brightness_set_blocking = lm36274_brightness_set;
ret = fwnode_property_read_u32_array(child, "led-sources",
chip->led_sources, chip->num_leds);
if (ret) {
dev_err(dev, "led-sources property missing\n");
goto err;
}
return 0;
err:
fwnode_handle_put(child);
return ret;
}
static int lm36274_probe(struct platform_device *pdev)
{
struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent);
struct lm36274 *lm36274_data;
struct led_init_data init_data = {};
struct lm36274 *chip;
int ret;
lm36274_data = devm_kzalloc(&pdev->dev, sizeof(*lm36274_data),
GFP_KERNEL);
if (!lm36274_data)
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
lm36274_data->pdev = pdev;
lm36274_data->dev = lmu->dev;
lm36274_data->regmap = lmu->regmap;
platform_set_drvdata(pdev, lm36274_data);
chip->pdev = pdev;
chip->dev = &pdev->dev;
chip->regmap = lmu->regmap;
platform_set_drvdata(pdev, chip);
ret = lm36274_parse_dt(lm36274_data);
ret = lm36274_parse_dt(chip, &init_data);
if (ret) {
dev_err(lm36274_data->dev, "Failed to parse DT node\n");
dev_err(chip->dev, "Failed to parse DT node\n");
return ret;
}
ret = lm36274_init(lm36274_data);
ret = lm36274_init(chip);
if (ret) {
dev_err(lm36274_data->dev, "Failed to init the device\n");
dev_err(chip->dev, "Failed to init the device\n");
return ret;
}
return led_classdev_register(lm36274_data->dev, &lm36274_data->led_dev);
}
chip->lmu_data.regmap = chip->regmap;
chip->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
chip->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
chip->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB;
static int lm36274_remove(struct platform_device *pdev)
{
struct lm36274 *lm36274_data = platform_get_drvdata(pdev);
chip->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT;
chip->led_dev.brightness_set_blocking = lm36274_brightness_set;
led_classdev_unregister(&lm36274_data->led_dev);
ret = devm_led_classdev_register_ext(chip->dev, &chip->led_dev,
&init_data);
if (ret)
dev_err(chip->dev, "Failed to register LED for node %pfw\n",
init_data.fwnode);
return 0;
fwnode_handle_put(init_data.fwnode);
return ret;
}
static const struct of_device_id of_lm36274_leds_match[] = {
......@@ -167,9 +158,9 @@ MODULE_DEVICE_TABLE(of, of_lm36274_leds_match);
static struct platform_driver lm36274_driver = {
.probe = lm36274_probe,
.remove = lm36274_remove,
.driver = {
.name = "lm36274-leds",
.of_match_table = of_lm36274_leds_match,
},
};
module_platform_driver(lm36274_driver)
......
......@@ -394,13 +394,10 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
led->regulator = devm_regulator_get_optional(&led->client->dev, "vled");
if (IS_ERR(led->regulator)) {
ret = PTR_ERR(led->regulator);
if (ret != -ENODEV) {
if (ret != -EPROBE_DEFER)
dev_err(&led->client->dev,
"Failed to get vled regulator: %d\n",
ret);
return ret;
}
if (ret != -ENODEV)
return dev_err_probe(&led->client->dev, ret,
"Failed to get vled regulator\n");
led->regulator = NULL;
}
......@@ -436,9 +433,6 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
return -ENODEV;
}
fwnode_property_read_string(child, "linux,default-trigger",
&led->led_dev.default_trigger);
ret = fwnode_property_read_u32(child, "reg", &led->led_enable);
if (ret) {
dev_err(&led->client->dev, "reg DT property missing\n");
......
......@@ -78,6 +78,7 @@ struct lm3697 {
struct mutex lock;
int bank_cfg;
int num_banks;
struct lm3697_led leds[];
};
......@@ -115,6 +116,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
struct lm3697_led *led = container_of(led_cdev, struct lm3697_led,
led_dev);
int ctrl_en_val = (1 << led->control_bank);
struct device *dev = led->priv->dev;
int ret;
mutex_lock(&led->priv->lock);
......@@ -123,7 +125,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE,
ctrl_en_val, ~ctrl_en_val);
if (ret) {
dev_err(&led->priv->client->dev, "Cannot write ctrl register\n");
dev_err(dev, "Cannot write ctrl register\n");
goto brightness_out;
}
......@@ -131,8 +133,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
} else {
ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val);
if (ret) {
dev_err(&led->priv->client->dev,
"Cannot write brightness\n");
dev_err(dev, "Cannot write brightness\n");
goto brightness_out;
}
......@@ -141,8 +142,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
LM3697_CTRL_ENABLE,
ctrl_en_val, ctrl_en_val);
if (ret) {
dev_err(&led->priv->client->dev,
"Cannot enable the device\n");
dev_err(dev, "Cannot enable the device\n");
goto brightness_out;
}
......@@ -157,6 +157,7 @@ static int lm3697_brightness_set(struct led_classdev *led_cdev,
static int lm3697_init(struct lm3697 *priv)
{
struct device *dev = priv->dev;
struct lm3697_led *led;
int i, ret;
......@@ -165,26 +166,26 @@ static int lm3697_init(struct lm3697 *priv)
} else {
ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET);
if (ret) {
dev_err(&priv->client->dev, "Cannot reset the device\n");
dev_err(dev, "Cannot reset the device\n");
goto out;
}
}
ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0);
if (ret) {
dev_err(&priv->client->dev, "Cannot write ctrl enable\n");
dev_err(dev, "Cannot write ctrl enable\n");
goto out;
}
ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, priv->bank_cfg);
if (ret)
dev_err(&priv->client->dev, "Cannot write OUTPUT config\n");
dev_err(dev, "Cannot write OUTPUT config\n");
for (i = 0; i < LM3697_MAX_CONTROL_BANKS; i++) {
for (i = 0; i < priv->num_banks; i++) {
led = &priv->leds[i];
ret = ti_lmu_common_set_ramp(&led->lmu_data);
if (ret)
dev_err(&priv->client->dev, "Setting the ramp rate failed\n");
dev_err(dev, "Setting the ramp rate failed\n");
}
out:
return ret;
......@@ -193,36 +194,37 @@ static int lm3697_init(struct lm3697 *priv)
static int lm3697_probe_dt(struct lm3697 *priv)
{
struct fwnode_handle *child = NULL;
struct device *dev = priv->dev;
struct lm3697_led *led;
const char *name;
int ret = -EINVAL;
int control_bank;
size_t i = 0;
int ret = -EINVAL;
int j;
priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev,
"enable", GPIOD_OUT_LOW);
priv->enable_gpio = devm_gpiod_get_optional(dev, "enable",
GPIOD_OUT_LOW);
if (IS_ERR(priv->enable_gpio)) {
ret = PTR_ERR(priv->enable_gpio);
dev_err(&priv->client->dev, "Failed to get enable gpio: %d\n",
ret);
dev_err(dev, "Failed to get enable gpio: %d\n", ret);
return ret;
}
priv->regulator = devm_regulator_get(&priv->client->dev, "vled");
priv->regulator = devm_regulator_get(dev, "vled");
if (IS_ERR(priv->regulator))
priv->regulator = NULL;
device_for_each_child_node(priv->dev, child) {
device_for_each_child_node(dev, child) {
struct led_init_data init_data = {};
ret = fwnode_property_read_u32(child, "reg", &control_bank);
if (ret) {
dev_err(&priv->client->dev, "reg property missing\n");
dev_err(dev, "reg property missing\n");
fwnode_handle_put(child);
goto child_out;
}
if (control_bank > LM3697_CONTROL_B) {
dev_err(&priv->client->dev, "reg property is invalid\n");
dev_err(dev, "reg property is invalid\n");
ret = -EINVAL;
fwnode_handle_put(child);
goto child_out;
......@@ -230,10 +232,10 @@ static int lm3697_probe_dt(struct lm3697 *priv)
led = &priv->leds[i];
ret = ti_lmu_common_get_brt_res(&priv->client->dev,
child, &led->lmu_data);
ret = ti_lmu_common_get_brt_res(dev, child, &led->lmu_data);
if (ret)
dev_warn(&priv->client->dev, "brightness resolution property missing\n");
dev_warn(dev,
"brightness resolution property missing\n");
led->control_bank = control_bank;
led->lmu_data.regmap = priv->regmap;
......@@ -246,7 +248,7 @@ static int lm3697_probe_dt(struct lm3697 *priv)
led->num_leds = fwnode_property_count_u32(child, "led-sources");
if (led->num_leds > LM3697_MAX_LED_STRINGS) {
dev_err(&priv->client->dev, "Too many LED strings defined\n");
dev_err(dev, "Too many LED strings defined\n");
continue;
}
......@@ -254,7 +256,7 @@ static int lm3697_probe_dt(struct lm3697 *priv)
led->hvled_strings,
led->num_leds);
if (ret) {
dev_err(&priv->client->dev, "led-sources property missing\n");
dev_err(dev, "led-sources property missing\n");
fwnode_handle_put(child);
goto child_out;
}
......@@ -263,31 +265,23 @@ static int lm3697_probe_dt(struct lm3697 *priv)
priv->bank_cfg |=
(led->control_bank << led->hvled_strings[j]);
ret = ti_lmu_common_get_ramp_params(&priv->client->dev,
child, &led->lmu_data);
ret = ti_lmu_common_get_ramp_params(dev, child, &led->lmu_data);
if (ret)
dev_warn(&priv->client->dev, "runtime-ramp properties missing\n");
dev_warn(dev, "runtime-ramp properties missing\n");
fwnode_property_read_string(child, "linux,default-trigger",
&led->led_dev.default_trigger);
ret = fwnode_property_read_string(child, "label", &name);
if (ret)
snprintf(led->label, sizeof(led->label),
"%s::", priv->client->name);
else
snprintf(led->label, sizeof(led->label),
"%s:%s", priv->client->name, name);
init_data.fwnode = child;
init_data.devicename = priv->client->name;
/* for backwards compatibility if `label` is not present */
init_data.default_label = ":";
led->priv = priv;
led->led_dev.name = led->label;
led->led_dev.max_brightness = led->lmu_data.max_brightness;
led->led_dev.brightness_set_blocking = lm3697_brightness_set;
ret = devm_led_classdev_register(priv->dev, &led->led_dev);
ret = devm_led_classdev_register_ext(dev, &led->led_dev,
&init_data);
if (ret) {
dev_err(&priv->client->dev, "led register err: %d\n",
ret);
dev_err(dev, "led register err: %d\n", ret);
fwnode_handle_put(child);
goto child_out;
}
......@@ -302,18 +296,18 @@ static int lm3697_probe_dt(struct lm3697 *priv)
static int lm3697_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct lm3697 *led;
int count;
int ret;
count = device_get_child_node_count(&client->dev);
if (!count) {
dev_err(&client->dev, "LEDs are not defined in device tree!");
count = device_get_child_node_count(dev);
if (!count || count > LM3697_MAX_CONTROL_BANKS) {
dev_err(dev, "Strange device tree!");
return -ENODEV;
}
led = devm_kzalloc(&client->dev, struct_size(led, leds, count),
GFP_KERNEL);
led = devm_kzalloc(dev, struct_size(led, leds, count), GFP_KERNEL);
if (!led)
return -ENOMEM;
......@@ -321,12 +315,12 @@ static int lm3697_probe(struct i2c_client *client,
i2c_set_clientdata(client, led);
led->client = client;
led->dev = &client->dev;
led->dev = dev;
led->num_banks = count;
led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config);
if (IS_ERR(led->regmap)) {
ret = PTR_ERR(led->regmap);
dev_err(&client->dev, "Failed to allocate register map: %d\n",
ret);
dev_err(dev, "Failed to allocate register map: %d\n", ret);
return ret;
}
......@@ -340,12 +334,13 @@ static int lm3697_probe(struct i2c_client *client,
static int lm3697_remove(struct i2c_client *client)
{
struct lm3697 *led = i2c_get_clientdata(client);
struct device *dev = &led->client->dev;
int ret;
ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE,
LM3697_CTRL_A_B_EN, 0);
if (ret) {
dev_err(&led->client->dev, "Failed to disable the device\n");
dev_err(dev, "Failed to disable the device\n");
return ret;
}
......@@ -355,8 +350,7 @@ static int lm3697_remove(struct i2c_client *client)
if (led->regulator) {
ret = regulator_disable(led->regulator);
if (ret)
dev_err(&led->client->dev,
"Failed to disable regulator\n");
dev_err(dev, "Failed to disable regulator\n");
}
mutex_destroy(&led->lock);
......
This diff is collapsed.
......@@ -523,7 +523,7 @@ static int lp5521_probe(struct i2c_client *client,
struct lp55xx_chip *chip;
struct lp55xx_led *led;
struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
struct device_node *np = client->dev.of_node;
struct device_node *np = dev_of_node(&client->dev);
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
......
......@@ -891,7 +891,7 @@ static int lp5523_probe(struct i2c_client *client,
struct lp55xx_chip *chip;
struct lp55xx_led *led;
struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
struct device_node *np = client->dev.of_node;
struct device_node *np = dev_of_node(&client->dev);
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
......
......@@ -518,7 +518,7 @@ static int lp5562_probe(struct i2c_client *client,
struct lp55xx_chip *chip;
struct lp55xx_led *led;
struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
struct device_node *np = client->dev.of_node;
struct device_node *np = dev_of_node(&client->dev);
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
......
......@@ -611,11 +611,13 @@ static int lp55xx_parse_multi_led(struct device_node *np,
struct device_node *child;
int num_colors = 0, ret;
for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
ret = lp55xx_parse_multi_led_child(child, cfg, child_number,
num_colors);
if (ret)
if (ret) {
of_node_put(child);
return ret;
}
num_colors++;
}
......@@ -665,7 +667,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
if (!pdata)
return ERR_PTR(-ENOMEM);
num_channels = of_get_child_count(np);
num_channels = of_get_available_child_count(np);
if (num_channels == 0) {
dev_err(dev, "no LED channels\n");
return ERR_PTR(-EINVAL);
......@@ -679,10 +681,12 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
pdata->num_channels = num_channels;
cfg->max_channel = chip->cfg->max_channel;
for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
ret = lp55xx_parse_logical_led(child, cfg, i);
if (ret)
if (ret) {
of_node_put(child);
return ERR_PTR(-EINVAL);
}
i++;
}
......
......@@ -306,7 +306,7 @@ static int lp8501_probe(struct i2c_client *client,
struct lp55xx_chip *chip;
struct lp55xx_led *led;
struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
struct device_node *np = client->dev.of_node;
struct device_node *np = dev_of_node(&client->dev);
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
......
......@@ -380,7 +380,7 @@ static int lp8860_probe(struct i2c_client *client,
{
int ret;
struct lp8860_led *led;
struct device_node *np = client->dev.of_node;
struct device_node *np = dev_of_node(&client->dev);
struct device_node *child_node;
struct led_init_data init_data = {};
......@@ -392,10 +392,6 @@ static int lp8860_probe(struct i2c_client *client,
if (!child_node)
return -EINVAL;
led->led_dev.default_trigger = of_get_property(child_node,
"linux,default-trigger",
NULL);
led->enable_gpio = devm_gpiod_get_optional(&client->dev,
"enable", GPIOD_OUT_LOW);
if (IS_ERR(led->enable_gpio)) {
......
......@@ -68,7 +68,7 @@ static int lt3593_led_probe(struct platform_device *pdev)
struct led_init_data init_data = {};
const char *tmp;
if (!dev->of_node)
if (!dev_of_node(dev))
return -ENODEV;
led_data = devm_kzalloc(dev, sizeof(*led_data), GFP_KERNEL);
......@@ -86,9 +86,6 @@ static int lt3593_led_probe(struct platform_device *pdev)
child = device_get_next_child_node(dev, NULL);
fwnode_property_read_string(child, "linux,default-trigger",
&led_data->cdev.default_trigger);
if (!fwnode_property_read_string(child, "default-state", &tmp)) {
if (!strcmp(tmp, "on"))
state = LEDS_GPIO_DEFSTATE_ON;
......@@ -107,7 +104,6 @@ static int lt3593_led_probe(struct platform_device *pdev)
return ret;
}
led_data->cdev.dev->of_node = dev->of_node;
platform_set_drvdata(pdev, led_data);
return 0;
......
......@@ -66,7 +66,6 @@ static int max77650_led_probe(struct platform_device *pdev)
struct max77650_led *leds, *led;
struct device *dev;
struct regmap *map;
const char *label;
int rv, num_leds;
u32 reg;
......@@ -86,6 +85,8 @@ static int max77650_led_probe(struct platform_device *pdev)
return -ENODEV;
device_for_each_child_node(dev, child) {
struct led_init_data init_data = {};
rv = fwnode_property_read_u32(child, "reg", &reg);
if (rv || reg >= MAX77650_LED_NUM_LEDS) {
rv = -EINVAL;
......@@ -99,22 +100,13 @@ static int max77650_led_probe(struct platform_device *pdev)
led->cdev.brightness_set_blocking = max77650_led_brightness_set;
led->cdev.max_brightness = MAX77650_LED_MAX_BRIGHTNESS;
rv = fwnode_property_read_string(child, "label", &label);
if (rv) {
led->cdev.name = "max77650::";
} else {
led->cdev.name = devm_kasprintf(dev, GFP_KERNEL,
"max77650:%s", label);
if (!led->cdev.name) {
rv = -ENOMEM;
goto err_node_put;
}
}
fwnode_property_read_string(child, "linux,default-trigger",
&led->cdev.default_trigger);
init_data.fwnode = child;
init_data.devicename = "max77650";
/* for backwards compatibility if `label` is not present */
init_data.default_label = ":";
rv = devm_led_classdev_register(dev, &led->cdev);
rv = devm_led_classdev_register_ext(dev, &led->cdev,
&init_data);
if (rv)
goto err_node_put;
......
......@@ -599,7 +599,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
{
struct device *dev = &led->pdev->dev;
struct max77693_sub_led *sub_leds = led->sub_leds;
struct device_node *node = dev->of_node, *child_node;
struct device_node *node = dev_of_node(dev), *child_node;
struct property *prop;
u32 led_sources[2];
int i, ret, fled_id;
......
......@@ -121,7 +121,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
if (!pdata)
return ERR_PTR(-ENOMEM);
parent = of_get_child_by_name(dev->parent->of_node, "leds");
parent = of_get_child_by_name(dev_of_node(dev->parent), "leds");
if (!parent)
goto out_node_put;
......@@ -131,7 +131,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
if (ret)
goto out_node_put;
pdata->num_leds = of_get_child_count(parent);
pdata->num_leds = of_get_available_child_count(parent);
pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led),
GFP_KERNEL);
......@@ -140,7 +140,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
goto out_node_put;
}
for_each_child_of_node(parent, child) {
for_each_available_child_of_node(parent, child) {
const char *str;
u32 tmp;
......@@ -192,7 +192,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
leds->master = mcdev;
platform_set_drvdata(pdev, leds);
if (dev->parent->of_node) {
if (dev_of_node(dev->parent)) {
pdata = mc13xxx_led_probe_dt(pdev);
if (IS_ERR(pdata))
return PTR_ERR(pdata);
......
......@@ -248,15 +248,6 @@ static int mt6323_led_set_blink(struct led_classdev *cdev,
u8 duty_hw;
int ret;
/*
* Units are in ms, if over the hardware able
* to support, fallback into software blink
*/
period = *delay_on + *delay_off;
if (period > MT6323_MAX_PERIOD)
return -EINVAL;
/*
* LED subsystem requires a default user
* friendly blink pattern for the LED so using
......@@ -268,6 +259,15 @@ static int mt6323_led_set_blink(struct led_classdev *cdev,
*delay_off = 500;
}
/*
* Units are in ms, if over the hardware able
* to support, fallback into software blink
*/
period = *delay_on + *delay_off;
if (period > MT6323_MAX_PERIOD)
return -EINVAL;
/*
* Calculate duty_hw based on the percentage of period during
* which the led is ON.
......@@ -342,11 +342,6 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
const char *state;
int ret = 0;
led->cdev.name = of_get_property(np, "label", NULL) ? : np->name;
led->cdev.default_trigger = of_get_property(np,
"linux,default-trigger",
NULL);
state = of_get_property(np, "default-state", NULL);
if (state) {
if (!strcmp(state, "keep")) {
......@@ -369,9 +364,9 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
static int mt6323_led_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = pdev->dev.of_node;
struct device_node *np = dev_of_node(dev);
struct device_node *child;
struct mt6397_chip *hw = dev_get_drvdata(pdev->dev.parent);
struct mt6397_chip *hw = dev_get_drvdata(dev->parent);
struct mt6323_leds *leds;
struct mt6323_led *led;
int ret;
......@@ -402,6 +397,8 @@ static int mt6323_led_probe(struct platform_device *pdev)
}
for_each_available_child_of_node(np, child) {
struct led_init_data init_data = {};
ret = of_property_read_u32(child, "reg", &reg);
if (ret) {
dev_err(dev, "Failed to read led 'reg' property\n");
......@@ -437,13 +434,14 @@ static int mt6323_led_probe(struct platform_device *pdev)
goto put_child_node;
}
ret = devm_led_classdev_register(dev, &leds->led[reg]->cdev);
init_data.fwnode = of_fwnode_handle(child);
ret = devm_led_classdev_register_ext(dev, &leds->led[reg]->cdev,
&init_data);
if (ret) {
dev_err(&pdev->dev, "Failed to register LED: %d\n",
ret);
dev_err(dev, "Failed to register LED: %d\n", ret);
goto put_child_node;
}
leds->led[reg]->cdev.dev->of_node = child;
}
return 0;
......
......@@ -419,7 +419,7 @@ static int netxbig_gpio_ext_get(struct device *dev,
static int netxbig_leds_get_of_pdata(struct device *dev,
struct netxbig_led_platform_data *pdata)
{
struct device_node *np = dev->of_node;
struct device_node *np = dev_of_node(dev);
struct device_node *gpio_ext_np;
struct platform_device *gpio_ext_pdev;
struct device *gpio_ext_dev;
......@@ -485,7 +485,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
}
/* LEDs */
num_leds = of_get_child_count(np);
num_leds = of_get_available_child_count(np);
if (!num_leds) {
dev_err(dev, "No LED subnodes found in DT\n");
return -ENODEV;
......@@ -496,7 +496,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
return -ENOMEM;
led = leds;
for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
const char *string;
int *mode_val;
int num_modes;
......
This diff is collapsed.
......@@ -27,6 +27,8 @@
#define PCA9532_REG_PWM(m, i) (PCA9532_REG_OFFSET(m) + 0x2 + (i) * 2)
#define LED_REG(m, led) (PCA9532_REG_OFFSET(m) + 0x5 + (led >> 2))
#define LED_NUM(led) (led & 0x3)
#define LED_SHIFT(led) (LED_NUM(led) * 2)
#define LED_MASK(led) (0x3 << LED_SHIFT(led))
#define ldev_to_led(c) container_of(c, struct pca9532_led, ldev)
......@@ -162,9 +164,9 @@ static void pca9532_setled(struct pca9532_led *led)
mutex_lock(&data->update_lock);
reg = i2c_smbus_read_byte_data(client, LED_REG(maxleds, led->id));
/* zero led bits */
reg = reg & ~(0x3<<LED_NUM(led->id)*2);
reg = reg & ~LED_MASK(led->id);
/* set the new value */
reg = reg | (led->state << LED_NUM(led->id)*2);
reg = reg | (led->state << LED_SHIFT(led->id));
i2c_smbus_write_byte_data(client, LED_REG(maxleds, led->id), reg);
mutex_unlock(&data->update_lock);
}
......@@ -260,7 +262,7 @@ static enum pca9532_state pca9532_getled(struct pca9532_led *led)
mutex_lock(&data->update_lock);
reg = i2c_smbus_read_byte_data(client, LED_REG(maxleds, led->id));
ret = reg >> LED_NUM(led->id)/2;
ret = (reg & LED_MASK(led->id)) >> LED_SHIFT(led->id);
mutex_unlock(&data->update_lock);
return ret;
}
......@@ -478,7 +480,12 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
if (!pdata)
return ERR_PTR(-ENOMEM);
for_each_child_of_node(np, child) {
of_property_read_u8_array(np, "nxp,pwm", &pdata->pwm[0],
ARRAY_SIZE(pdata->pwm));
of_property_read_u8_array(np, "nxp,psc", &pdata->psc[0],
ARRAY_SIZE(pdata->psc));
for_each_available_child_of_node(np, child) {
if (of_property_read_string(child, "label",
&pdata->leds[i].name))
pdata->leds[i].name = child->name;
......@@ -507,7 +514,7 @@ static int pca9532_probe(struct i2c_client *client,
struct pca9532_data *data = i2c_get_clientdata(client);
struct pca9532_platform_data *pca9532_pdata =
dev_get_platdata(&client->dev);
struct device_node *np = client->dev.of_node;
struct device_node *np = dev_of_node(&client->dev);
if (!pca9532_pdata) {
if (np) {
......@@ -545,13 +552,8 @@ static int pca9532_probe(struct i2c_client *client,
static int pca9532_remove(struct i2c_client *client)
{
struct pca9532_data *data = i2c_get_clientdata(client);
int err;
err = pca9532_destroy_devices(data, data->chip_info->num_leds);
if (err)
return err;
return 0;
return pca9532_destroy_devices(data, data->chip_info->num_leds);
}
module_i2c_driver(pca9532_driver);
......
......@@ -65,6 +65,7 @@ enum pca955x_type {
pca9550,
pca9551,
pca9552,
ibm_pca9552,
pca9553,
};
......@@ -90,6 +91,11 @@ static struct pca955x_chipdef pca955x_chipdefs[] = {
.slv_addr = /* 1100xxx */ 0x60,
.slv_addr_shift = 3,
},
[ibm_pca9552] = {
.bits = 16,
.slv_addr = /* 0110xxx */ 0x30,
.slv_addr_shift = 3,
},
[pca9553] = {
.bits = 4,
.slv_addr = /* 110001x */ 0x62,
......@@ -101,6 +107,7 @@ static const struct i2c_device_id pca955x_id[] = {
{ "pca9550", pca9550 },
{ "pca9551", pca9551 },
{ "pca9552", pca9552 },
{ "ibm-pca9552", ibm_pca9552 },
{ "pca9553", pca9553 },
{ }
};
......@@ -412,6 +419,7 @@ static const struct of_device_id of_pca955x_match[] = {
{ .compatible = "nxp,pca9550", .data = (void *)pca9550 },
{ .compatible = "nxp,pca9551", .data = (void *)pca9551 },
{ .compatible = "nxp,pca9552", .data = (void *)pca9552 },
{ .compatible = "ibm,pca9552", .data = (void *)ibm_pca9552 },
{ .compatible = "nxp,pca9553", .data = (void *)pca9553 },
{},
};
......
This diff is collapsed.
......@@ -87,36 +87,36 @@ static enum led_brightness pm8058_led_get(struct led_classdev *cled)
static int pm8058_led_probe(struct platform_device *pdev)
{
struct led_init_data init_data = {};
struct device *dev = &pdev->dev;
struct pm8058_led *led;
struct device_node *np = pdev->dev.of_node;
struct device_node *np;
int ret;
struct regmap *map;
const char *state;
enum led_brightness maxbright;
led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led)
return -ENOMEM;
led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);
led->ledtype = (u32)(unsigned long)of_device_get_match_data(dev);
map = dev_get_regmap(pdev->dev.parent, NULL);
map = dev_get_regmap(dev->parent, NULL);
if (!map) {
dev_err(&pdev->dev, "Parent regmap unavailable.\n");
dev_err(dev, "Parent regmap unavailable.\n");
return -ENXIO;
}
led->map = map;
np = dev_of_node(dev);
ret = of_property_read_u32(np, "reg", &led->reg);
if (ret) {
dev_err(&pdev->dev, "no register offset specified\n");
dev_err(dev, "no register offset specified\n");
return -EINVAL;
}
/* Use label else node name */
led->cdev.name = of_get_property(np, "label", NULL) ? : np->name;
led->cdev.default_trigger =
of_get_property(np, "linux,default-trigger", NULL);
led->cdev.brightness_set = pm8058_led_set;
led->cdev.brightness_get = pm8058_led_get;
if (led->ledtype == PM8058_LED_TYPE_COMMON)
......@@ -142,14 +142,13 @@ static int pm8058_led_probe(struct platform_device *pdev)
led->ledtype == PM8058_LED_TYPE_FLASH)
led->cdev.flags = LED_CORE_SUSPENDRESUME;
ret = devm_led_classdev_register(&pdev->dev, &led->cdev);
if (ret) {
dev_err(&pdev->dev, "unable to register led \"%s\"\n",
led->cdev.name);
return ret;
}
init_data.fwnode = of_fwnode_handle(np);
ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (ret)
dev_err(dev, "Failed to register LED for %pOF\n", np);
return 0;
return ret;
}
static const struct of_device_id pm8058_leds_id_table[] = {
......
......@@ -250,7 +250,7 @@ static int powernv_led_classdev(struct platform_device *pdev,
struct powernv_led_data *powernv_led;
struct device *dev = &pdev->dev;
for_each_child_of_node(led_node, np) {
for_each_available_child_of_node(led_node, np) {
p = of_find_property(np, "led-types", NULL);
while ((cur = of_prop_next_string(p, cur)) != NULL) {
......
......@@ -20,16 +20,10 @@
struct led_pwm {
const char *name;
const char *default_trigger;
u8 active_low;
unsigned int max_brightness;
};
struct led_pwm_platform_data {
int num_leds;
struct led_pwm *leds;
};
struct led_pwm_data {
struct led_classdev cdev;
struct pwm_device *pwm;
......@@ -61,36 +55,31 @@ static int led_pwm_set(struct led_classdev *led_cdev,
return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate);
}
__attribute__((nonnull))
static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
struct led_pwm *led, struct fwnode_handle *fwnode)
{
struct led_pwm_data *led_data = &priv->leds[priv->num_leds];
struct led_init_data init_data = { .fwnode = fwnode };
int ret;
led_data->active_low = led->active_low;
led_data->cdev.name = led->name;
led_data->cdev.default_trigger = led->default_trigger;
led_data->cdev.brightness = LED_OFF;
led_data->cdev.max_brightness = led->max_brightness;
led_data->cdev.flags = LED_CORE_SUSPENDRESUME;
if (fwnode)
led_data->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL);
else
led_data->pwm = devm_pwm_get(dev, led->name);
if (IS_ERR(led_data->pwm)) {
ret = PTR_ERR(led_data->pwm);
if (ret != -EPROBE_DEFER)
dev_err(dev, "unable to request PWM for %s: %d\n",
led->name, ret);
return ret;
}
led_data->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL);
if (IS_ERR(led_data->pwm))
return dev_err_probe(dev, PTR_ERR(led_data->pwm),
"unable to request PWM for %s\n",
led->name);
led_data->cdev.brightness_set_blocking = led_pwm_set;
pwm_init_state(led_data->pwm, &led_data->pwmstate);
ret = devm_led_classdev_register(dev, &led_data->cdev);
ret = devm_led_classdev_register_ext(dev, &led_data->cdev, &init_data);
if (ret) {
dev_err(dev, "failed to register PWM led for %s: %d\n",
led->name, ret);
......@@ -126,9 +115,6 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
return -EINVAL;
}
fwnode_property_read_string(fwnode, "linux,default-trigger",
&led.default_trigger);
led.active_low = fwnode_property_read_bool(fwnode,
"active-low");
fwnode_property_read_u32(fwnode, "max-brightness",
......@@ -146,15 +132,11 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
static int led_pwm_probe(struct platform_device *pdev)
{
struct led_pwm_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct led_pwm_priv *priv;
int count, i;
int ret = 0;
int count;
if (pdata)
count = pdata->num_leds;
else
count = device_get_child_node_count(&pdev->dev);
count = device_get_child_node_count(&pdev->dev);
if (!count)
return -EINVAL;
......@@ -164,16 +146,7 @@ static int led_pwm_probe(struct platform_device *pdev)
if (!priv)
return -ENOMEM;
if (pdata) {
for (i = 0; i < count; i++) {
ret = led_pwm_add(&pdev->dev, priv, &pdata->leds[i],
NULL);
if (ret)
break;
}
} else {
ret = led_pwm_create_fwnode(&pdev->dev, priv);
}
ret = led_pwm_create_fwnode(&pdev->dev, priv);
if (ret)
return ret;
......
......@@ -16,8 +16,6 @@
#include <linux/module.h>
#include <linux/platform_data/leds-s3c24xx.h>
#include <mach/regs-gpio.h>
/* our context */
struct s3c24xx_gpio_led {
......
......@@ -276,12 +276,12 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv)
static int sc27xx_led_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node, *child;
struct device_node *np = dev_of_node(dev), *child;
struct sc27xx_led_priv *priv;
u32 base, count, reg;
int err;
count = of_get_child_count(np);
count = of_get_available_child_count(np);
if (!count || count > SC27XX_LEDS_MAX)
return -EINVAL;
......@@ -305,7 +305,7 @@ static int sc27xx_led_probe(struct platform_device *pdev)
return err;
}
for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
err = of_property_read_u32(child, "reg", &reg);
if (err) {
of_node_put(child);
......
......@@ -195,30 +195,21 @@ static int sgm3140_probe(struct platform_device *pdev)
priv->flash_gpio = devm_gpiod_get(&pdev->dev, "flash", GPIOD_OUT_LOW);
ret = PTR_ERR_OR_ZERO(priv->flash_gpio);
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"Failed to request flash gpio: %d\n", ret);
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret,
"Failed to request flash gpio\n");
priv->enable_gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
ret = PTR_ERR_OR_ZERO(priv->enable_gpio);
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"Failed to request enable gpio: %d\n", ret);
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret,
"Failed to request enable gpio\n");
priv->vin_regulator = devm_regulator_get(&pdev->dev, "vin");
ret = PTR_ERR_OR_ZERO(priv->vin_regulator);
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"Failed to request regulator: %d\n", ret);
return ret;
}
if (ret)
return dev_err_probe(&pdev->dev, ret,
"Failed to request regulator\n");
child_node = fwnode_get_next_available_child_node(pdev->dev.fwnode,
NULL);
......@@ -316,5 +307,5 @@ static struct platform_driver sgm3140_driver = {
module_platform_driver(sgm3140_driver);
MODULE_AUTHOR("Luca Weiss <luca@z3ntu.xyz>");
MODULE_DESCRIPTION("SG Micro SGM3140 charge pump led driver");
MODULE_DESCRIPTION("SG Micro SGM3140 charge pump LED driver");
MODULE_LICENSE("GPL v2");
......@@ -80,7 +80,6 @@ static int spi_byte_brightness_set_blocking(struct led_classdev *dev,
static int spi_byte_probe(struct spi_device *spi)
{
const struct of_device_id *of_dev_id;
struct device_node *child;
struct device *dev = &spi->dev;
struct spi_byte_led *led;
......@@ -88,15 +87,11 @@ static int spi_byte_probe(struct spi_device *spi)
const char *state;
int ret;
of_dev_id = of_match_device(spi_byte_dt_ids, dev);
if (!of_dev_id)
return -EINVAL;
if (of_get_child_count(dev->of_node) != 1) {
if (of_get_available_child_count(dev_of_node(dev)) != 1) {
dev_err(dev, "Device must have exactly one LED sub-node.");
return -EINVAL;
}
child = of_get_next_child(dev->of_node, NULL);
child = of_get_next_available_child(dev_of_node(dev), NULL);
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led)
......@@ -106,7 +101,7 @@ static int spi_byte_probe(struct spi_device *spi)
strlcpy(led->name, name, sizeof(led->name));
led->spi = spi;
mutex_init(&led->mutex);
led->cdef = of_dev_id->data;
led->cdef = device_get_match_data(dev);
led->ldev.name = led->name;
led->ldev.brightness = LED_OFF;
led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value;
......
......@@ -55,8 +55,9 @@ static void syscon_led_set(struct led_classdev *led_cdev,
static int syscon_led_probe(struct platform_device *pdev)
{
struct led_init_data init_data = {};
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
struct device_node *np = dev_of_node(dev);
struct device *parent;
struct regmap *map;
struct syscon_led *sled;
......@@ -68,7 +69,7 @@ static int syscon_led_probe(struct platform_device *pdev)
dev_err(dev, "no parent for syscon LED\n");
return -ENODEV;
}
map = syscon_node_to_regmap(parent->of_node);
map = syscon_node_to_regmap(dev_of_node(parent));
if (IS_ERR(map)) {
dev_err(dev, "no regmap for syscon LED parent\n");
return PTR_ERR(map);
......@@ -84,10 +85,6 @@ static int syscon_led_probe(struct platform_device *pdev)
return -EINVAL;
if (of_property_read_u32(np, "mask", &sled->mask))
return -EINVAL;
sled->cdev.name =
of_get_property(np, "label", NULL) ? : np->name;
sled->cdev.default_trigger =
of_get_property(np, "linux,default-trigger", NULL);
state = of_get_property(np, "default-state", NULL);
if (state) {
......@@ -115,7 +112,9 @@ static int syscon_led_probe(struct platform_device *pdev)
}
sled->cdev.brightness_set = syscon_led_set;
ret = devm_led_classdev_register(dev, &sled->cdev);
init_data.fwnode = of_fwnode_handle(np);
ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data);
if (ret < 0)
return ret;
......
......@@ -69,23 +69,6 @@
* defaulted. Similarly the banks know if each time was explicit or a
* default. Defaults are permitted to be changed freely - they are
* not recognised when matching.
*
*
* An led-tca6507 device must be provided with platform data or
* configured via devicetree.
*
* The platform-data lists for each output: the name, default trigger,
* and whether the signal is being used as a GPIO rather than an LED.
* 'struct led_plaform_data' is used for this. If 'name' is NULL, the
* output isn't used. If 'flags' is TCA6507_MAKE_GPIO, the output is
* a GPO. The "struct led_platform_data" can be embedded in a "struct
* tca6507_platform_data" which adds a 'gpio_base' for the GPIOs, and
* a 'setup' callback which is called once the GPIOs are available.
*
* When configured via devicetree there is one child for each output.
* The "reg" determines the output number and "compatible" determines
* whether it is an LED or a GPIO. "linux,default-trigger" can set a
* default trigger.
*/
#include <linux/module.h>
......@@ -94,9 +77,8 @@
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/gpio/driver.h>
#include <linux/property.h>
#include <linux/workqueue.h>
#include <linux/leds-tca6507.h>
#include <linux/of.h>
/* LED select registers determine the source that drives LED outputs */
#define TCA6507_LS_LED_OFF 0x0 /* Output HI-Z (off) */
......@@ -108,6 +90,15 @@
#define TCA6507_LS_BLINK0 0x6 /* Blink at Bank0 rate */
#define TCA6507_LS_BLINK1 0x7 /* Blink at Bank1 rate */
struct tca6507_platform_data {
struct led_platform_data leds;
#ifdef CONFIG_GPIOLIB
int gpio_base;
#endif
};
#define TCA6507_MAKE_GPIO 1
enum {
BANK0,
BANK1,
......@@ -189,7 +180,6 @@ struct tca6507_chip {
} leds[NUM_LEDS];
#ifdef CONFIG_GPIOLIB
struct gpio_chip gpio;
const char *gpio_name[NUM_LEDS];
int gpio_map[NUM_LEDS];
#endif
};
......@@ -628,7 +618,7 @@ static int tca6507_gpio_direction_output(struct gpio_chip *gc,
return 0;
}
static int tca6507_probe_gpios(struct i2c_client *client,
static int tca6507_probe_gpios(struct device *dev,
struct tca6507_chip *tca,
struct tca6507_platform_data *pdata)
{
......@@ -639,7 +629,6 @@ static int tca6507_probe_gpios(struct i2c_client *client,
for (i = 0; i < NUM_LEDS; i++)
if (pdata->leds.leds[i].name && pdata->leds.leds[i].flags) {
/* Configure as a gpio */
tca->gpio_name[gpios] = pdata->leds.leds[i].name;
tca->gpio_map[gpios] = i;
gpios++;
}
......@@ -648,23 +637,20 @@ static int tca6507_probe_gpios(struct i2c_client *client,
return 0;
tca->gpio.label = "gpio-tca6507";
tca->gpio.names = tca->gpio_name;
tca->gpio.ngpio = gpios;
tca->gpio.base = pdata->gpio_base;
tca->gpio.owner = THIS_MODULE;
tca->gpio.direction_output = tca6507_gpio_direction_output;
tca->gpio.set = tca6507_gpio_set_value;
tca->gpio.parent = &client->dev;
tca->gpio.parent = dev;
#ifdef CONFIG_OF_GPIO
tca->gpio.of_node = of_node_get(client->dev.of_node);
tca->gpio.of_node = of_node_get(dev_of_node(dev));
#endif
err = gpiochip_add_data(&tca->gpio, tca);
if (err) {
tca->gpio.ngpio = 0;
return err;
}
if (pdata->setup)
pdata->setup(tca->gpio.base, tca->gpio.ngpio);
return 0;
}
......@@ -674,7 +660,7 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca)
gpiochip_remove(&tca->gpio);
}
#else /* CONFIG_GPIOLIB */
static int tca6507_probe_gpios(struct i2c_client *client,
static int tca6507_probe_gpios(struct device *dev,
struct tca6507_chip *tca,
struct tca6507_platform_data *pdata)
{
......@@ -685,44 +671,50 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca)
}
#endif /* CONFIG_GPIOLIB */
#ifdef CONFIG_OF
static struct tca6507_platform_data *
tca6507_led_dt_init(struct i2c_client *client)
tca6507_led_dt_init(struct device *dev)
{
struct device_node *np = client->dev.of_node, *child;
struct tca6507_platform_data *pdata;
struct fwnode_handle *child;
struct led_info *tca_leds;
int count;
count = of_get_child_count(np);
count = device_get_child_node_count(dev);
if (!count || count > NUM_LEDS)
return ERR_PTR(-ENODEV);
tca_leds = devm_kcalloc(&client->dev,
NUM_LEDS, sizeof(struct led_info), GFP_KERNEL);
tca_leds = devm_kcalloc(dev, NUM_LEDS, sizeof(struct led_info),
GFP_KERNEL);
if (!tca_leds)
return ERR_PTR(-ENOMEM);
for_each_child_of_node(np, child) {
device_for_each_child_node(dev, child) {
struct led_info led;
u32 reg;
int ret;
led.name =
of_get_property(child, "label", NULL) ? : child->name;
led.default_trigger =
of_get_property(child, "linux,default-trigger", NULL);
if (fwnode_property_read_string(child, "label", &led.name))
led.name = fwnode_get_name(child);
fwnode_property_read_string(child, "linux,default-trigger",
&led.default_trigger);
led.flags = 0;
if (of_property_match_string(child, "compatible", "gpio") >= 0)
if (fwnode_property_match_string(child, "compatible",
"gpio") >= 0)
led.flags |= TCA6507_MAKE_GPIO;
ret = of_property_read_u32(child, "reg", &reg);
if (ret != 0 || reg >= NUM_LEDS)
continue;
ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret || reg >= NUM_LEDS) {
fwnode_handle_put(child);
return ERR_PTR(ret ? : -EINVAL);
}
tca_leds[reg] = led;
}
pdata = devm_kzalloc(&client->dev,
sizeof(struct tca6507_platform_data), GFP_KERNEL);
pdata = devm_kzalloc(dev, sizeof(struct tca6507_platform_data),
GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
......@@ -731,48 +723,37 @@ tca6507_led_dt_init(struct i2c_client *client)
#ifdef CONFIG_GPIOLIB
pdata->gpio_base = -1;
#endif
return pdata;
}
static const struct of_device_id of_tca6507_leds_match[] = {
static const struct of_device_id __maybe_unused of_tca6507_leds_match[] = {
{ .compatible = "ti,tca6507", },
{},
};
MODULE_DEVICE_TABLE(of, of_tca6507_leds_match);
#else
static struct tca6507_platform_data *
tca6507_led_dt_init(struct i2c_client *client)
{
return ERR_PTR(-ENODEV);
}
#endif
static int tca6507_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tca6507_chip *tca;
struct device *dev = &client->dev;
struct i2c_adapter *adapter;
struct tca6507_chip *tca;
struct tca6507_platform_data *pdata;
int err;
int i = 0;
adapter = client->adapter;
pdata = dev_get_platdata(&client->dev);
if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
return -EIO;
if (!pdata || pdata->leds.num_leds != NUM_LEDS) {
pdata = tca6507_led_dt_init(client);
if (IS_ERR(pdata)) {
dev_err(&client->dev, "Need %d entries in platform-data list\n",
NUM_LEDS);
return PTR_ERR(pdata);
}
pdata = tca6507_led_dt_init(dev);
if (IS_ERR(pdata)) {
dev_err(dev, "Need %d entries in platform-data list\n", NUM_LEDS);
return PTR_ERR(pdata);
}
tca = devm_kzalloc(&client->dev, sizeof(*tca), GFP_KERNEL);
tca = devm_kzalloc(dev, sizeof(*tca), GFP_KERNEL);
if (!tca)
return -ENOMEM;
......@@ -793,13 +774,12 @@ static int tca6507_probe(struct i2c_client *client,
l->led_cdev.brightness_set = tca6507_brightness_set;
l->led_cdev.blink_set = tca6507_blink_set;
l->bank = -1;
err = led_classdev_register(&client->dev,
&l->led_cdev);
err = led_classdev_register(dev, &l->led_cdev);
if (err < 0)
goto exit;
}
}
err = tca6507_probe_gpios(client, tca, pdata);
err = tca6507_probe_gpios(dev, tca, pdata);
if (err)
goto exit;
/* set all registers to known state - zero */
......
......@@ -148,22 +148,17 @@ static int
tlc591xx_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device_node *np = client->dev.of_node, *child;
struct device_node *np = dev_of_node(&client->dev), *child;
struct device *dev = &client->dev;
const struct of_device_id *match;
const struct tlc591xx *tlc591xx;
struct tlc591xx_priv *priv;
int err, count, reg;
match = of_match_device(of_tlc591xx_leds_match, dev);
if (!match)
return -ENODEV;
tlc591xx = match->data;
tlc591xx = device_get_match_data(dev);
if (!np)
return -ENODEV;
count = of_get_child_count(np);
count = of_get_available_child_count(np);
if (!count || count > tlc591xx->max_leds)
return -EINVAL;
......@@ -185,7 +180,7 @@ tlc591xx_probe(struct i2c_client *client,
if (err < 0)
return err;
for_each_child_of_node(np, child) {
for_each_available_child_of_node(np, child) {
struct tlc591xx_led *led;
struct led_init_data init_data = {};
......@@ -204,9 +199,6 @@ tlc591xx_probe(struct i2c_client *client,
led = &priv->leds[reg];
led->active = true;
led->ldev.default_trigger =
of_get_property(child, "linux,default-trigger", NULL);
led->priv = priv;
led->led_no = reg;
led->ldev.brightness_set_blocking = tlc591xx_brightness_set;
......@@ -214,10 +206,10 @@ tlc591xx_probe(struct i2c_client *client,
err = devm_led_classdev_register_ext(dev, &led->ldev,
&init_data);
if (err < 0) {
if (err != -EPROBE_DEFER)
dev_err(dev, "couldn't register LED %s\n",
led->ldev.name);
return err;
of_node_put(child);
return dev_err_probe(dev, err,
"couldn't register LED %s\n",
led->ldev.name);
}
}
return 0;
......
......@@ -121,8 +121,6 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
cdev->max_brightness = 255;
cdev->brightness_set_blocking = omnia_led_brightness_set_blocking;
of_property_read_string(np, "linux,default-trigger", &cdev->default_trigger);
/* put the LED into software mode */
ret = i2c_smbus_write_byte_data(client, CMD_LED_MODE,
CMD_LED_MODE_LED(led->reg) |
......@@ -210,7 +208,7 @@ static int omnia_leds_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device *dev = &client->dev;
struct device_node *np = dev->of_node, *child;
struct device_node *np = dev_of_node(dev), *child;
struct omnia_leds *leds;
struct omnia_led *led;
int ret, count;
......@@ -236,8 +234,10 @@ static int omnia_leds_probe(struct i2c_client *client,
led = &leds->leds[0];
for_each_available_child_of_node(np, child) {
ret = omnia_led_register(client, led, child);
if (ret < 0)
if (ret < 0) {
of_node_put(child);
return ret;
}
led += ret;
}
......
......@@ -2,14 +2,18 @@
/*
* ledtrig-cpu.c - LED trigger based on CPU activity
*
* This LED trigger will be registered for each possible CPU and named as
* cpu0, cpu1, cpu2, cpu3, etc.
* This LED trigger will be registered for first 8 CPUs and named
* as cpu0..cpu7. There's additional trigger called cpu that
* is on when any CPU is active.
*
* If you want support for arbitrary number of CPUs, make it one trigger,
* with additional sysfs file selecting which CPU to watch.
*
* It can be bound to any LED just like other triggers using either a
* board file or via sysfs interface.
*
* An API named ledtrig_cpu is exported for any user, who want to add CPU
* activity indication in their code
* activity indication in their code.
*
* Copyright 2011 Linus Walleij <linus.walleij@linaro.org>
* Copyright 2011 - 2012 Bryan Wu <bryan.wu@canonical.com>
......@@ -145,6 +149,9 @@ static int __init ledtrig_cpu_init(void)
for_each_possible_cpu(cpu) {
struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
if (cpu >= 8)
continue;
snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
led_trigger_register_simple(trig->name, &trig->_trig);
......
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* TCA6507 LED chip driver.
*
* Copyright (C) 2011 Neil Brown <neil@brown.name>
*/
#ifndef __LINUX_TCA6507_H
#define __LINUX_TCA6507_H
#include <linux/leds.h>
struct tca6507_platform_data {
struct led_platform_data leds;
#ifdef CONFIG_GPIOLIB
int gpio_base;
void (*setup)(unsigned gpio_base, unsigned ngpio);
#endif
};
#define TCA6507_MAKE_GPIO 1
#endif /* __LINUX_TCA6507_H*/
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* PCA963X LED chip driver.
*
* Copyright 2012 bct electronic GmbH
* Copyright 2013 Qtechnology A/S
*/
#ifndef __LINUX_PCA963X_H
#define __LINUX_PCA963X_H
#include <linux/leds.h>
enum pca963x_outdrv {
PCA963X_OPEN_DRAIN,
PCA963X_TOTEM_POLE, /* aka push-pull */
};
enum pca963x_blink_type {
PCA963X_SW_BLINK,
PCA963X_HW_BLINK,
};
enum pca963x_direction {
PCA963X_NORMAL,
PCA963X_INVERTED,
};
struct pca963x_platform_data {
struct led_platform_data leds;
enum pca963x_outdrv outdrv;
enum pca963x_blink_type blink_type;
enum pca963x_direction dir;
};
#endif /* __LINUX_PCA963X_H*/
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