Commit e4bc1588 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'leds-next-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds

Pull LED updates from Lee Jones:
 "Removed Drivers:
   - HTC ASIC3 LED

  New Functionality:
   - Provide generic led_get() which can be used by both DT and !DT
     platforms

  Fix-ups:
   - Convert a bunch of I2C subsystem users to the new probing API
   - Explicitly provide missing include files
   - Make use of led_init_default_state_get() and rid the custom
     variants
   - Use simplified fwnode_device_is_compatible() API
   - Provide some Device Tree additions / adaptions
   - Fix some trivial spelling issues

  Bug Fixes:
   - Prevent device refcount leak during led_put() and of_led_get()
   - Clear previous data from temporary led_pwm structure before
     processing next child
   - Fix Clang's warning about incompatible function types when using
     devm_add_action*()"

* tag 'leds-next-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: (41 commits)
  leds: Remove ide-disk trigger
  dt-bindings: leds: Add disk write/read and usb-host/usb-gadget
  Documentation: leds: Correct spelling
  dt-bindings: leds: Document Bluetooth and WLAN triggers
  leds: Remove asic3 driver
  leds: simatic-ipc-leds-gpio: Make sure we have the GPIO providing driver
  leds: tca6507: Convert to use fwnode_device_is_compatible()
  leds: syscon: Get rid of custom led_init_default_state_get()
  leds: pm8058: Get rid of custom led_init_default_state_get()
  leds: pca955x: Get rid of custom led_init_default_state_get()
  leds: mt6360: Get rid of custom led_init_default_state_get()
  leds: mt6323: Get rid of custom led_init_default_state_get()
  leds: bcm6358: Get rid of custom led_init_default_state_get()
  leds: bcm6328: Get rid of custom led_init_default_state_get()
  leds: an30259a: Get rid of custom led_init_default_state_get()
  leds: Move led_init_default_state_get() to the global header
  leds: Add missing includes and forward declarations in leds.h
  leds: is31fl319x: Wrap mutex_destroy() for devm_add_action_or_rest()
  leds: turris-omnia: Convert to i2c's .probe_new()
  leds: tlc591xx: Convert to i2c's .probe_new()
  ...
parents 025cf4dc 056f65c3
......@@ -90,17 +90,22 @@ properties:
- heartbeat
# LED indicates disk activity
- disk-activity
# LED indicates IDE disk activity (deprecated), in new implementations
# use "disk-activity"
- ide-disk
- disk-read
- disk-write
# LED flashes at a fixed, configurable rate
- timer
# LED alters the brightness for the specified duration with one software
# timer (requires "led-pattern" property)
- pattern
# LED is triggered by SD/MMC activity
- pattern: "^mmc[0-9]+$"
- usb-gadget
- usb-host
- pattern: "^cpu[0-9]*$"
- pattern: "^hci[0-9]+-power$"
# LED is triggered by Bluetooth activity
- pattern: "^mmc[0-9]+$"
# LED is triggered by SD/MMC activity
- pattern: "^phy[0-9]+tx$"
# LED is triggered by WLAN activity
led-pattern:
description: |
......
......@@ -34,7 +34,7 @@ Specify a hardware pattern for a Qualcomm LPG LED.
The pattern is a series of brightness and hold-time pairs, with the hold-time
expressed in milliseconds. The hold time is a property of the pattern and must
therefor be identical for each element in the pattern (except for the pauses
therefore be identical for each element in the pattern (except for the pauses
described below). As the LPG hardware is not able to perform the linear
transitions expected by the leds-trigger-pattern format, each entry in the
pattern must be followed a zero-length entry of the same brightness.
......@@ -66,7 +66,7 @@ Low-pause pattern::
+----------------------------->
0 5 10 15 20 25 time (100ms)
Similarily, the last entry can be stretched by using a higher hold-time on the
Similarly, the last entry can be stretched by using a higher hold-time on the
last entry.
In order to save space in the shared lookup table the LPG supports "ping-pong"
......
......@@ -623,17 +623,6 @@ config LEDS_NETXBIG
and 5Big Network v2 boards. The LEDs are wired to a CPLD and are
controlled through a GPIO extension bus.
config LEDS_ASIC3
bool "LED support for the HTC ASIC3"
depends on LEDS_CLASS=y
depends on MFD_ASIC3
default y
help
This option enables support for the LEDs on the HTC ASIC3. The HTC
ASIC3 LED GPIOs are inputs, not outputs, thus the leds-gpio driver
cannot be used. This driver supports hardware blinking with an on+off
period from 62ms to 125s. Say Y to enable LEDs on the HP iPAQ hx4700.
config LEDS_TCA6507
tristate "LED Support for TCA6507 I2C chip"
depends on LEDS_CLASS && I2C
......
......@@ -14,7 +14,6 @@ obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o
obj-$(CONFIG_LEDS_AN30259A) += leds-an30259a.o
obj-$(CONFIG_LEDS_APU) += leds-apu.o
obj-$(CONFIG_LEDS_ARIEL) += leds-ariel.o
obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o
obj-$(CONFIG_LEDS_AW2013) += leds-aw2013.o
obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o
obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o
......
......@@ -71,10 +71,6 @@ enum {
#define MT6360_STRBTO_STEPUS 32000
#define MT6360_STRBTO_MAXUS 2432000
#define STATE_OFF 0
#define STATE_KEEP 1
#define STATE_ON 2
struct mt6360_led {
union {
struct led_classdev isnk;
......@@ -84,7 +80,7 @@ struct mt6360_led {
struct v4l2_flash *v4l2_flash;
struct mt6360_priv *priv;
u32 led_no;
u32 default_state;
enum led_default_state default_state;
};
struct mt6360_priv {
......@@ -405,10 +401,10 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led)
level = LED_OFF;
switch (led->default_state) {
case STATE_ON:
case LEDS_DEFSTATE_ON:
led->isnk.brightness = led->isnk.max_brightness;
break;
case STATE_KEEP:
case LEDS_DEFSTATE_KEEP:
led->isnk.brightness = min(level, led->isnk.max_brightness);
break;
default:
......@@ -443,10 +439,10 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led)
level = LED_OFF;
switch (led->default_state) {
case STATE_ON:
case LEDS_DEFSTATE_ON:
flash->led_cdev.brightness = flash->led_cdev.max_brightness;
break;
case STATE_KEEP:
case LEDS_DEFSTATE_KEEP:
flash->led_cdev.brightness =
min(level, flash->led_cdev.max_brightness);
break;
......@@ -760,25 +756,6 @@ static int mt6360_init_flash_properties(struct mt6360_led *led,
return 0;
}
static int mt6360_init_common_properties(struct mt6360_led *led,
struct led_init_data *init_data)
{
const char *const states[] = { "off", "keep", "on" };
const char *str;
int ret;
if (!fwnode_property_read_string(init_data->fwnode,
"default-state", &str)) {
ret = match_string(states, ARRAY_SIZE(states), str);
if (ret < 0)
ret = STATE_OFF;
led->default_state = ret;
}
return 0;
}
static void mt6360_v4l2_flash_release(struct mt6360_priv *priv)
{
int i;
......@@ -852,10 +829,7 @@ static int mt6360_led_probe(struct platform_device *pdev)
led->led_no = reg;
led->priv = priv;
ret = mt6360_init_common_properties(led, &init_data);
if (ret)
goto out_flash_release;
led->default_state = led_init_default_state_get(child);
if (reg == MT6360_VIRTUAL_MULTICOLOR ||
reg <= MT6360_LED_ISNKML)
......
......@@ -253,6 +253,7 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
led_dev = class_find_device_by_of_node(leds_class, led_node);
of_node_put(led_node);
put_device(led_dev);
return led_module_get(led_dev);
}
......
......@@ -55,10 +55,6 @@
#define AN30259A_NAME "an30259a"
#define STATE_OFF 0
#define STATE_KEEP 1
#define STATE_ON 2
struct an30259a;
struct an30259a_led {
......@@ -66,7 +62,7 @@ struct an30259a_led {
struct fwnode_handle *fwnode;
struct led_classdev cdev;
u32 num;
u32 default_state;
enum led_default_state default_state;
bool sloping;
};
......@@ -205,7 +201,6 @@ static int an30259a_dt_init(struct i2c_client *client,
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_available_child_count(np);
......@@ -228,15 +223,7 @@ static int an30259a_dt_init(struct i2c_client *client,
led->num = source;
led->chip = chip;
led->fwnode = of_fwnode_handle(child);
if (!of_property_read_string(child, "default-state", &str)) {
if (!strcmp(str, "on"))
led->default_state = STATE_ON;
else if (!strcmp(str, "keep"))
led->default_state = STATE_KEEP;
else
led->default_state = STATE_OFF;
}
led->default_state = led_init_default_state_get(led->fwnode);
i++;
}
......@@ -261,10 +248,10 @@ static void an30259a_init_default_state(struct an30259a_led *led)
int led_on, err;
switch (led->default_state) {
case STATE_ON:
case LEDS_DEFSTATE_ON:
led->cdev.brightness = LED_FULL;
break;
case STATE_KEEP:
case LEDS_DEFSTATE_KEEP:
err = regmap_read(chip->regmap, AN30259A_REG_LED_ON, &led_on);
if (err)
break;
......
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2011 Paul Parsons <lost.distance@yahoo.com>
*/
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/slab.h>
#include <linux/mfd/asic3.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
/*
* The HTC ASIC3 LED GPIOs are inputs, not outputs.
* Hence we turn the LEDs on/off via the TimeBase register.
*/
/*
* When TimeBase is 4 the clock resolution is about 32Hz.
* This driver supports hardware blinking with an on+off
* period from 62ms (2 clocks) to 125s (4000 clocks).
*/
#define MS_TO_CLK(ms) DIV_ROUND_CLOSEST(((ms)*1024), 32000)
#define CLK_TO_MS(clk) (((clk)*32000)/1024)
#define MAX_CLK 4000 /* Fits into 12-bit Time registers */
#define MAX_MS CLK_TO_MS(MAX_CLK)
static const unsigned int led_n_base[ASIC3_NUM_LEDS] = {
[0] = ASIC3_LED_0_Base,
[1] = ASIC3_LED_1_Base,
[2] = ASIC3_LED_2_Base,
};
static void brightness_set(struct led_classdev *cdev,
enum led_brightness value)
{
struct platform_device *pdev = to_platform_device(cdev->dev->parent);
const struct mfd_cell *cell = mfd_get_cell(pdev);
struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
u32 timebase;
unsigned int base;
timebase = (value == LED_OFF) ? 0 : (LED_EN|0x4);
base = led_n_base[cell->id];
asic3_write_register(asic, (base + ASIC3_LED_PeriodTime), 32);
asic3_write_register(asic, (base + ASIC3_LED_DutyTime), 32);
asic3_write_register(asic, (base + ASIC3_LED_AutoStopCount), 0);
asic3_write_register(asic, (base + ASIC3_LED_TimeBase), timebase);
}
static int blink_set(struct led_classdev *cdev,
unsigned long *delay_on,
unsigned long *delay_off)
{
struct platform_device *pdev = to_platform_device(cdev->dev->parent);
const struct mfd_cell *cell = mfd_get_cell(pdev);
struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
u32 on;
u32 off;
unsigned int base;
if (*delay_on > MAX_MS || *delay_off > MAX_MS)
return -EINVAL;
if (*delay_on == 0 && *delay_off == 0) {
/* If both are zero then a sensible default should be chosen */
on = MS_TO_CLK(500);
off = MS_TO_CLK(500);
} else {
on = MS_TO_CLK(*delay_on);
off = MS_TO_CLK(*delay_off);
if ((on + off) > MAX_CLK)
return -EINVAL;
}
base = led_n_base[cell->id];
asic3_write_register(asic, (base + ASIC3_LED_PeriodTime), (on + off));
asic3_write_register(asic, (base + ASIC3_LED_DutyTime), on);
asic3_write_register(asic, (base + ASIC3_LED_AutoStopCount), 0);
asic3_write_register(asic, (base + ASIC3_LED_TimeBase), (LED_EN|0x4));
*delay_on = CLK_TO_MS(on);
*delay_off = CLK_TO_MS(off);
return 0;
}
static int asic3_led_probe(struct platform_device *pdev)
{
struct asic3_led *led = dev_get_platdata(&pdev->dev);
int ret;
ret = mfd_cell_enable(pdev);
if (ret < 0)
return ret;
led->cdev = devm_kzalloc(&pdev->dev, sizeof(struct led_classdev),
GFP_KERNEL);
if (!led->cdev) {
ret = -ENOMEM;
goto out;
}
led->cdev->name = led->name;
led->cdev->flags = LED_CORE_SUSPENDRESUME;
led->cdev->brightness_set = brightness_set;
led->cdev->blink_set = blink_set;
led->cdev->default_trigger = led->default_trigger;
ret = led_classdev_register(&pdev->dev, led->cdev);
if (ret < 0)
goto out;
return 0;
out:
(void) mfd_cell_disable(pdev);
return ret;
}
static int asic3_led_remove(struct platform_device *pdev)
{
struct asic3_led *led = dev_get_platdata(&pdev->dev);
led_classdev_unregister(led->cdev);
return mfd_cell_disable(pdev);
}
#ifdef CONFIG_PM_SLEEP
static int asic3_led_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
const struct mfd_cell *cell = mfd_get_cell(pdev);
int ret;
ret = 0;
if (cell->suspend)
ret = (*cell->suspend)(pdev);
return ret;
}
static int asic3_led_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
const struct mfd_cell *cell = mfd_get_cell(pdev);
int ret;
ret = 0;
if (cell->resume)
ret = (*cell->resume)(pdev);
return ret;
}
#endif
static SIMPLE_DEV_PM_OPS(asic3_led_pm_ops, asic3_led_suspend, asic3_led_resume);
static struct platform_driver asic3_led_driver = {
.probe = asic3_led_probe,
.remove = asic3_led_remove,
.driver = {
.name = "leds-asic3",
.pm = &asic3_led_pm_ops,
},
};
module_platform_driver(asic3_led_driver);
MODULE_AUTHOR("Paul Parsons <lost.distance@yahoo.com>");
MODULE_DESCRIPTION("HTC ASIC3 LED driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:leds-asic3");
......@@ -330,7 +330,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
{
struct led_init_data init_data = {};
struct bcm6328_led *led;
const char *state;
enum led_default_state state;
unsigned long val, shift;
void __iomem *mode;
int rc;
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
......@@ -346,31 +348,29 @@ 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;
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) {
init_data.fwnode = of_fwnode_handle(nc);
state = led_init_default_state_get(init_data.fwnode);
switch (state) {
case LEDS_DEFSTATE_ON:
led->cdev.brightness = LED_FULL;
break;
case LEDS_DEFSTATE_KEEP:
shift = bcm6328_pin2shift(led->pin);
if (shift / 16)
mode = mem + BCM6328_REG_MODE_HI;
else
mode = mem + BCM6328_REG_MODE_LO;
val = bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16);
val &= BCM6328_LED_MODE_MASK;
if ((led->active_low && val == BCM6328_LED_MODE_OFF) ||
(!led->active_low && val == BCM6328_LED_MODE_ON))
led->cdev.brightness = LED_FULL;
} else if (!strcmp(state, "keep")) {
void __iomem *mode;
unsigned long val, shift;
shift = bcm6328_pin2shift(led->pin);
if (shift / 16)
mode = mem + BCM6328_REG_MODE_HI;
else
mode = mem + BCM6328_REG_MODE_LO;
val = bcm6328_led_read(mode) >>
BCM6328_LED_SHIFT(shift % 16);
val &= BCM6328_LED_MODE_MASK;
if ((led->active_low && val == BCM6328_LED_MODE_OFF) ||
(!led->active_low && val == BCM6328_LED_MODE_ON))
led->cdev.brightness = LED_FULL;
else
led->cdev.brightness = LED_OFF;
} else {
else
led->cdev.brightness = LED_OFF;
}
} else {
break;
default:
led->cdev.brightness = LED_OFF;
}
......@@ -378,7 +378,6 @@ 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 = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (rc < 0)
......
......@@ -96,7 +96,8 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
{
struct led_init_data init_data = {};
struct bcm6358_led *led;
const char *state;
enum led_default_state state;
unsigned long val;
int rc;
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
......@@ -110,29 +111,28 @@ 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;
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) {
init_data.fwnode = of_fwnode_handle(nc);
state = led_init_default_state_get(init_data.fwnode);
switch (state) {
case LEDS_DEFSTATE_ON:
led->cdev.brightness = LED_FULL;
break;
case LEDS_DEFSTATE_KEEP:
val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
val &= BIT(led->pin);
if ((led->active_low && !val) || (!led->active_low && val))
led->cdev.brightness = LED_FULL;
} else if (!strcmp(state, "keep")) {
unsigned long val;
val = bcm6358_led_read(led->mem + BCM6358_REG_MODE);
val &= BIT(led->pin);
if ((led->active_low && !val) ||
(!led->active_low && val))
led->cdev.brightness = LED_FULL;
else
led->cdev.brightness = LED_OFF;
} else {
else
led->cdev.brightness = LED_OFF;
}
} else {
break;
default:
led->cdev.brightness = LED_OFF;
}
bcm6358_led_set(&led->cdev, led->cdev.brightness);
led->cdev.brightness_set = bcm6358_led_set;
init_data.fwnode = of_fwnode_handle(nc);
rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (rc < 0)
......
......@@ -656,8 +656,7 @@ static void bd2802_unregister_led_classdev(struct bd2802_led *led)
led_classdev_unregister(&led->cdev_led1r);
}
static int bd2802_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int bd2802_probe(struct i2c_client *client)
{
struct bd2802_led *led;
int ret, i;
......@@ -787,7 +786,7 @@ static struct i2c_driver bd2802_i2c_driver = {
.name = "BD2802",
.pm = &bd2802_pm,
},
.probe = bd2802_probe,
.probe_new = bd2802_probe,
.remove = bd2802_remove,
.id_table = bd2802_id,
};
......
......@@ -565,8 +565,7 @@ static int blinkm_detect(struct i2c_client *client, struct i2c_board_info *info)
return 0;
}
static int blinkm_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int blinkm_probe(struct i2c_client *client)
{
struct blinkm_data *data;
struct blinkm_led *led[3];
......@@ -731,7 +730,7 @@ static struct i2c_driver blinkm_driver = {
.driver = {
.name = "blinkm",
},
.probe = blinkm_probe,
.probe_new = blinkm_probe,
.remove = blinkm_remove,
.id_table = blinkm_id,
.detect = blinkm_detect,
......
......@@ -495,6 +495,11 @@ static inline int is31fl3196_db_to_gain(u32 dezibel)
return dezibel / IS31FL3196_AUDIO_GAIN_DB_STEP;
}
static void is31f1319x_mutex_destroy(void *lock)
{
mutex_destroy(lock);
}
static int is31fl319x_probe(struct i2c_client *client)
{
struct is31fl319x_chip *is31;
......@@ -511,7 +516,7 @@ static int is31fl319x_probe(struct i2c_client *client)
return -ENOMEM;
mutex_init(&is31->lock);
err = devm_add_action(dev, (void (*)(void *))mutex_destroy, &is31->lock);
err = devm_add_action_or_reset(dev, is31f1319x_mutex_destroy, &is31->lock);
if (err)
return err;
......
......@@ -422,8 +422,7 @@ static const struct of_device_id of_is31fl32xx_match[] = {
MODULE_DEVICE_TABLE(of, of_is31fl32xx_match);
static int is31fl32xx_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int is31fl32xx_probe(struct i2c_client *client)
{
const struct is31fl32xx_chipdef *cdef;
struct device *dev = &client->dev;
......@@ -489,7 +488,7 @@ static struct i2c_driver is31fl32xx_driver = {
.name = "is31fl32xx",
.of_match_table = of_is31fl32xx_match,
},
.probe = is31fl32xx_probe,
.probe_new = is31fl32xx_probe,
.remove = is31fl32xx_remove,
.id_table = is31fl32xx_id,
};
......
......@@ -405,8 +405,7 @@ static struct attribute *lm3530_attrs[] = {
};
ATTRIBUTE_GROUPS(lm3530);
static int lm3530_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lm3530_probe(struct i2c_client *client)
{
struct lm3530_platform_data *pdata = dev_get_platdata(&client->dev);
struct lm3530_data *drvdata;
......@@ -485,7 +484,7 @@ static const struct i2c_device_id lm3530_id[] = {
MODULE_DEVICE_TABLE(i2c, lm3530_id);
static struct i2c_driver lm3530_i2c_driver = {
.probe = lm3530_probe,
.probe_new = lm3530_probe,
.remove = lm3530_remove,
.id_table = lm3530_id,
.driver = {
......
......@@ -663,8 +663,7 @@ static int lm3532_parse_node(struct lm3532_data *priv)
return ret;
}
static int lm3532_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lm3532_probe(struct i2c_client *client)
{
struct lm3532_data *drvdata;
int ret = 0;
......@@ -727,7 +726,7 @@ static const struct i2c_device_id lm3532_id[] = {
MODULE_DEVICE_TABLE(i2c, lm3532_id);
static struct i2c_driver lm3532_i2c_driver = {
.probe = lm3532_probe,
.probe_new = lm3532_probe,
.remove = lm3532_remove,
.id_table = lm3532_id,
.driver = {
......
......@@ -396,9 +396,9 @@ static const struct regmap_config lm355x_regmap = {
};
/* module initialize */
static int lm355x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lm355x_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct lm355x_platform_data *pdata = dev_get_platdata(&client->dev);
struct lm355x_chip_data *chip;
......@@ -516,7 +516,7 @@ static struct i2c_driver lm355x_i2c_driver = {
.name = LM355x_NAME,
.pm = NULL,
},
.probe = lm355x_probe,
.probe_new = lm355x_probe,
.remove = lm355x_remove,
.id_table = lm355x_id,
};
......
......@@ -289,8 +289,7 @@ static struct attribute *lm3642_torch_attrs[] = {
};
ATTRIBUTE_GROUPS(lm3642_torch);
static int lm3642_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lm3642_probe(struct i2c_client *client)
{
struct lm3642_platform_data *pdata = dev_get_platdata(&client->dev);
struct lm3642_chip_data *chip;
......@@ -402,7 +401,7 @@ static struct i2c_driver lm3642_i2c_driver = {
.name = LM3642_NAME,
.pm = NULL,
},
.probe = lm3642_probe,
.probe_new = lm3642_probe,
.remove = lm3642_remove,
.id_table = lm3642_id,
};
......
......@@ -456,9 +456,9 @@ static int lm3692x_probe_dt(struct lm3692x_led *led)
return ret;
}
static int lm3692x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lm3692x_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct lm3692x_led *led;
int ret;
......@@ -518,7 +518,7 @@ static struct i2c_driver lm3692x_driver = {
.name = "lm3692x",
.of_match_table = of_lm3692x_leds_match,
},
.probe = lm3692x_probe,
.probe_new = lm3692x_probe,
.remove = lm3692x_remove,
.id_table = lm3692x_id,
};
......
......@@ -299,8 +299,7 @@ static int lm3697_probe_dt(struct lm3697 *priv)
return ret;
}
static int lm3697_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lm3697_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct lm3697 *led;
......@@ -377,7 +376,7 @@ static struct i2c_driver lm3697_driver = {
.name = "lm3697",
.of_match_table = of_lm3697_leds_match,
},
.probe = lm3697_probe,
.probe_new = lm3697_probe,
.remove = lm3697_remove,
.id_table = lm3697_id,
};
......
......@@ -359,8 +359,7 @@ static int lp3944_configure(struct i2c_client *client,
return err;
}
static int lp3944_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp3944_probe(struct i2c_client *client)
{
struct lp3944_platform_data *lp3944_pdata =
dev_get_platdata(&client->dev);
......@@ -428,7 +427,7 @@ static struct i2c_driver lp3944_driver = {
.driver = {
.name = "lp3944",
},
.probe = lp3944_probe,
.probe_new = lp3944_probe,
.remove = lp3944_remove,
.id_table = lp3944_id,
};
......
......@@ -207,8 +207,7 @@ static const struct regmap_config lp3952_regmap = {
.cache_type = REGCACHE_RBTREE,
};
static int lp3952_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp3952_probe(struct i2c_client *client)
{
int status;
struct lp3952_led_array *priv;
......@@ -274,7 +273,7 @@ static struct i2c_driver lp3952_i2c_driver = {
.driver = {
.name = LP3952_NAME,
},
.probe = lp3952_probe,
.probe_new = lp3952_probe,
.remove = lp3952_remove,
.id_table = lp3952_id,
};
......
......@@ -516,9 +516,9 @@ static struct lp55xx_device_config lp5521_cfg = {
.dev_attr_group = &lp5521_group,
};
static int lp5521_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp5521_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
int ret;
struct lp55xx_chip *chip;
struct lp55xx_led *led;
......@@ -608,7 +608,7 @@ static struct i2c_driver lp5521_driver = {
.name = "lp5521",
.of_match_table = of_match_ptr(of_lp5521_leds_match),
},
.probe = lp5521_probe,
.probe_new = lp5521_probe,
.remove = lp5521_remove,
.id_table = lp5521_id,
};
......
......@@ -887,9 +887,9 @@ static struct lp55xx_device_config lp5523_cfg = {
.dev_attr_group = &lp5523_group,
};
static int lp5523_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp5523_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
int ret;
struct lp55xx_chip *chip;
struct lp55xx_led *led;
......@@ -983,7 +983,7 @@ static struct i2c_driver lp5523_driver = {
.name = "lp5523x",
.of_match_table = of_match_ptr(of_lp5523_leds_match),
},
.probe = lp5523_probe,
.probe_new = lp5523_probe,
.remove = lp5523_remove,
.id_table = lp5523_id,
};
......
......@@ -511,8 +511,7 @@ static struct lp55xx_device_config lp5562_cfg = {
.dev_attr_group = &lp5562_group,
};
static int lp5562_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp5562_probe(struct i2c_client *client)
{
int ret;
struct lp55xx_chip *chip;
......@@ -604,7 +603,7 @@ static struct i2c_driver lp5562_driver = {
.name = "lp5562",
.of_match_table = of_match_ptr(of_lp5562_leds_match),
},
.probe = lp5562_probe,
.probe_new = lp5562_probe,
.remove = lp5562_remove,
.id_table = lp5562_id,
};
......
......@@ -299,9 +299,9 @@ static struct lp55xx_device_config lp8501_cfg = {
.run_engine = lp8501_run_engine,
};
static int lp8501_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp8501_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
int ret;
struct lp55xx_chip *chip;
struct lp55xx_led *led;
......@@ -392,7 +392,7 @@ static struct i2c_driver lp8501_driver = {
.name = "lp8501",
.of_match_table = of_match_ptr(of_lp8501_leds_match),
},
.probe = lp8501_probe,
.probe_new = lp8501_probe,
.remove = lp8501_remove,
.id_table = lp8501_id,
};
......
......@@ -375,8 +375,7 @@ static const struct regmap_config lp8860_eeprom_regmap_config = {
.cache_type = REGCACHE_NONE,
};
static int lp8860_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int lp8860_probe(struct i2c_client *client)
{
int ret;
struct lp8860_led *led;
......@@ -480,7 +479,7 @@ static struct i2c_driver lp8860_driver = {
.name = "lp8860",
.of_match_table = of_lp8860_leds_match,
},
.probe = lp8860_probe,
.probe_new = lp8860_probe,
.remove = lp8860_remove,
.id_table = lp8860_id,
};
......
......@@ -339,23 +339,23 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
struct device_node *np)
{
struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev);
const char *state;
enum led_default_state state;
int ret = 0;
state = of_get_property(np, "default-state", NULL);
if (state) {
if (!strcmp(state, "keep")) {
ret = mt6323_get_led_hw_brightness(cdev);
if (ret < 0)
return ret;
led->current_brightness = ret;
ret = 0;
} else if (!strcmp(state, "on")) {
ret =
mt6323_led_set_brightness(cdev, cdev->max_brightness);
} else {
ret = mt6323_led_set_brightness(cdev, LED_OFF);
}
state = led_init_default_state_get(of_fwnode_handle(np));
switch (state) {
case LEDS_DEFSTATE_ON:
ret = mt6323_led_set_brightness(cdev, cdev->max_brightness);
break;
case LEDS_DEFSTATE_KEEP:
ret = mt6323_get_led_hw_brightness(cdev);
if (ret < 0)
return ret;
led->current_brightness = ret;
ret = 0;
break;
default:
ret = mt6323_led_set_brightness(cdev, LED_OFF);
}
return ret;
......
......@@ -50,8 +50,7 @@ struct pca9532_data {
u8 psc[2];
};
static int pca9532_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int pca9532_probe(struct i2c_client *client);
static void pca9532_remove(struct i2c_client *client);
enum {
......@@ -103,7 +102,7 @@ static struct i2c_driver pca9532_driver = {
.name = "leds-pca953x",
.of_match_table = of_match_ptr(of_pca9532_leds_match),
},
.probe = pca9532_probe,
.probe_new = pca9532_probe,
.remove = pca9532_remove,
.id_table = pca9532_id,
};
......@@ -504,9 +503,9 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
return pdata;
}
static int pca9532_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int pca9532_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
int devid;
struct pca9532_data *data = i2c_get_clientdata(client);
struct pca9532_platform_data *pca9532_pdata =
......
......@@ -130,7 +130,7 @@ struct pca955x_led {
struct led_classdev led_cdev;
int led_num; /* 0 .. 15 potentially */
u32 type;
int default_state;
enum led_default_state default_state;
struct fwnode_handle *fwnode;
};
......@@ -437,7 +437,6 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
return ERR_PTR(-ENOMEM);
device_for_each_child_node(&client->dev, child) {
const char *state;
u32 reg;
int res;
......@@ -448,19 +447,9 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
led = &pdata->leds[reg];
led->type = PCA955X_TYPE_LED;
led->fwnode = child;
fwnode_property_read_u32(child, "type", &led->type);
led->default_state = led_init_default_state_get(child);
if (!fwnode_property_read_string(child, "default-state",
&state)) {
if (!strcmp(state, "keep"))
led->default_state = LEDS_GPIO_DEFSTATE_KEEP;
else if (!strcmp(state, "on"))
led->default_state = LEDS_GPIO_DEFSTATE_ON;
else
led->default_state = LEDS_GPIO_DEFSTATE_OFF;
} else {
led->default_state = LEDS_GPIO_DEFSTATE_OFF;
}
fwnode_property_read_u32(child, "type", &led->type);
}
pdata->num_leds = chip->bits;
......@@ -572,13 +561,11 @@ static int pca955x_probe(struct i2c_client *client)
led->brightness_set_blocking = pca955x_led_set;
led->brightness_get = pca955x_led_get;
if (pdata->leds[i].default_state ==
LEDS_GPIO_DEFSTATE_OFF) {
if (pdata->leds[i].default_state == LEDS_DEFSTATE_OFF) {
err = pca955x_led_set(led, LED_OFF);
if (err)
return err;
} else if (pdata->leds[i].default_state ==
LEDS_GPIO_DEFSTATE_ON) {
} else if (pdata->leds[i].default_state == LEDS_DEFSTATE_ON) {
err = pca955x_led_set(led, LED_FULL);
if (err)
return err;
......@@ -617,8 +604,7 @@ static int pca955x_probe(struct i2c_client *client)
* brightness to see if it's using PWM1. If so, PWM1
* should not be written below.
*/
if (pdata->leds[i].default_state ==
LEDS_GPIO_DEFSTATE_KEEP) {
if (pdata->leds[i].default_state == LEDS_DEFSTATE_KEEP) {
if (led->brightness != LED_FULL &&
led->brightness != LED_OFF &&
led->brightness != LED_HALF)
......
......@@ -389,9 +389,9 @@ static const struct of_device_id of_pca963x_match[] = {
};
MODULE_DEVICE_TABLE(of, of_pca963x_match);
static int pca963x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int pca963x_probe(struct i2c_client *client)
{
const struct i2c_device_id *id = i2c_client_get_device_id(client);
struct device *dev = &client->dev;
struct pca963x_chipdef *chipdef;
struct pca963x *chip;
......@@ -431,7 +431,7 @@ static struct i2c_driver pca963x_driver = {
.name = "leds-pca963x",
.of_match_table = of_pca963x_match,
},
.probe = pca963x_probe,
.probe_new = pca963x_probe,
.id_table = pca963x_id,
};
......
......@@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev)
struct device_node *np;
int ret;
struct regmap *map;
const char *state;
enum led_brightness maxbright;
enum led_default_state state;
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led)
......@@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev)
maxbright = 15; /* 4 bits */
led->cdev.max_brightness = maxbright;
state = of_get_property(np, "default-state", NULL);
if (state) {
if (!strcmp(state, "keep")) {
led->cdev.brightness = pm8058_led_get(&led->cdev);
} else if (!strcmp(state, "on")) {
led->cdev.brightness = maxbright;
pm8058_led_set(&led->cdev, maxbright);
} else {
led->cdev.brightness = LED_OFF;
pm8058_led_set(&led->cdev, LED_OFF);
}
init_data.fwnode = of_fwnode_handle(np);
state = led_init_default_state_get(init_data.fwnode);
switch (state) {
case LEDS_DEFSTATE_ON:
led->cdev.brightness = maxbright;
pm8058_led_set(&led->cdev, maxbright);
break;
case LEDS_DEFSTATE_KEEP:
led->cdev.brightness = pm8058_led_get(&led->cdev);
break;
default:
led->cdev.brightness = LED_OFF;
pm8058_led_set(&led->cdev, LED_OFF);
}
if (led->ledtype == PM8058_LED_TYPE_KEYPAD ||
led->ledtype == PM8058_LED_TYPE_FLASH)
led->cdev.flags = LED_CORE_SUSPENDRESUME;
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);
......
......@@ -138,9 +138,9 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
struct led_pwm led;
int ret;
memset(&led, 0, sizeof(led));
device_for_each_child_node(dev, fwnode) {
memset(&led, 0, sizeof(led));
ret = fwnode_property_read_string(fwnode, "label", &led.name);
if (ret && is_of_node(fwnode))
led.name = to_of_node(fwnode)->name;
......
......@@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev)
struct device *parent;
struct regmap *map;
struct syscon_led *sled;
const char *state;
enum led_default_state state;
u32 value;
int ret;
parent = dev->parent;
......@@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev)
if (of_property_read_u32(np, "mask", &sled->mask))
return -EINVAL;
state = of_get_property(np, "default-state", NULL);
if (state) {
if (!strcmp(state, "keep")) {
u32 val;
ret = regmap_read(map, sled->offset, &val);
if (ret < 0)
return ret;
sled->state = !!(val & sled->mask);
} else if (!strcmp(state, "on")) {
sled->state = true;
ret = regmap_update_bits(map, sled->offset,
sled->mask,
sled->mask);
if (ret < 0)
return ret;
} else {
sled->state = false;
ret = regmap_update_bits(map, sled->offset,
sled->mask, 0);
if (ret < 0)
return ret;
}
init_data.fwnode = of_fwnode_handle(np);
state = led_init_default_state_get(init_data.fwnode);
switch (state) {
case LEDS_DEFSTATE_ON:
ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask);
if (ret < 0)
return ret;
sled->state = true;
break;
case LEDS_DEFSTATE_KEEP:
ret = regmap_read(map, sled->offset, &value);
if (ret < 0)
return ret;
sled->state = !!(value & sled->mask);
break;
default:
ret = regmap_update_bits(map, sled->offset, sled->mask, 0);
if (ret < 0)
return ret;
sled->state = false;
}
sled->cdev.brightness_set = syscon_led_set;
init_data.fwnode = of_fwnode_handle(np);
ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data);
if (ret < 0)
return ret;
......
......@@ -695,8 +695,7 @@ tca6507_led_dt_init(struct device *dev)
&led.default_trigger);
led.flags = 0;
if (fwnode_property_match_string(child, "compatible",
"gpio") >= 0)
if (fwnode_device_is_compatible(child, "gpio"))
led.flags |= TCA6507_MAKE_GPIO;
ret = fwnode_property_read_u32(child, "reg", &reg);
......@@ -728,8 +727,7 @@ static const struct of_device_id __maybe_unused of_tca6507_leds_match[] = {
};
MODULE_DEVICE_TABLE(of, of_tca6507_leds_match);
static int tca6507_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int tca6507_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct i2c_adapter *adapter;
......@@ -809,7 +807,7 @@ static struct i2c_driver tca6507_driver = {
.name = "leds-tca6507",
.of_match_table = of_match_ptr(of_tca6507_leds_match),
},
.probe = tca6507_probe,
.probe_new = tca6507_probe,
.remove = tca6507_remove,
.id_table = tca6507_id,
};
......
......@@ -145,8 +145,7 @@ static const struct of_device_id of_tlc591xx_leds_match[] = {
MODULE_DEVICE_TABLE(of, of_tlc591xx_leds_match);
static int
tlc591xx_probe(struct i2c_client *client,
const struct i2c_device_id *id)
tlc591xx_probe(struct i2c_client *client)
{
struct device_node *np, *child;
struct device *dev = &client->dev;
......@@ -231,7 +230,7 @@ static struct i2c_driver tlc591xx_driver = {
.name = "tlc591xx",
.of_match_table = of_match_ptr(of_tlc591xx_leds_match),
},
.probe = tlc591xx_probe,
.probe_new = tlc591xx_probe,
.id_table = tlc591xx_id,
};
......
......@@ -201,8 +201,7 @@ static struct attribute *omnia_led_controller_attrs[] = {
};
ATTRIBUTE_GROUPS(omnia_led_controller);
static int omnia_leds_probe(struct i2c_client *client,
const struct i2c_device_id *id)
static int omnia_leds_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct device_node *np = dev_of_node(dev), *child;
......@@ -272,7 +271,7 @@ static const struct i2c_device_id omnia_id[] = {
MODULE_DEVICE_TABLE(i2c, omnia_id);
static struct i2c_driver omnia_leds_driver = {
.probe = omnia_leds_probe,
.probe_new = omnia_leds_probe,
.remove = omnia_leds_remove,
.id_table = omnia_id,
.driver = {
......
......@@ -27,7 +27,6 @@ ssize_t led_trigger_read(struct file *filp, struct kobject *kobj,
ssize_t led_trigger_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr, char *buf,
loff_t pos, size_t count);
enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode);
extern struct rw_semaphore leds_list_lock;
extern struct list_head leds_list;
......
......@@ -77,6 +77,8 @@ static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev)
switch (plat->devmode) {
case SIMATIC_IPC_DEVICE_127E:
if (!IS_ENABLED(CONFIG_PINCTRL_BROXTON))
return -ENODEV;
simatic_ipc_led_gpio_table = &simatic_ipc_led_gpio_table_127e;
break;
case SIMATIC_IPC_DEVICE_227G:
......
......@@ -16,7 +16,6 @@
DEFINE_LED_TRIGGER(ledtrig_disk);
DEFINE_LED_TRIGGER(ledtrig_disk_read);
DEFINE_LED_TRIGGER(ledtrig_disk_write);
DEFINE_LED_TRIGGER(ledtrig_ide);
void ledtrig_disk_activity(bool write)
{
......@@ -24,8 +23,6 @@ void ledtrig_disk_activity(bool write)
led_trigger_blink_oneshot(ledtrig_disk,
&blink_delay, &blink_delay, 0);
led_trigger_blink_oneshot(ledtrig_ide,
&blink_delay, &blink_delay, 0);
if (write)
led_trigger_blink_oneshot(ledtrig_disk_write,
&blink_delay, &blink_delay, 0);
......@@ -40,7 +37,6 @@ static int __init ledtrig_disk_init(void)
led_trigger_register_simple("disk-activity", &ledtrig_disk);
led_trigger_register_simple("disk-read", &ledtrig_disk_read);
led_trigger_register_simple("disk-write", &ledtrig_disk_write);
led_trigger_register_simple("ide-disk", &ledtrig_ide);
return 0;
}
......
......@@ -10,17 +10,21 @@
#include <dt-bindings/leds/common.h>
#include <linux/device.h>
#include <linux/kernfs.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/rwsem.h>
#include <linux/spinlock.h>
#include <linux/timer.h>
#include <linux/types.h>
#include <linux/workqueue.h>
struct device;
struct led_pattern;
struct attribute_group;
struct device_node;
struct fwnode_handle;
struct gpio_desc;
struct kernfs_node;
struct led_pattern;
struct platform_device;
/*
* LED Core
*/
......@@ -78,6 +82,8 @@ struct led_init_data {
bool devname_mandatory;
};
enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode);
struct led_hw_trigger_type {
int dummy;
};
......@@ -529,7 +535,6 @@ struct led_properties {
const char *label;
};
struct gpio_desc;
typedef int (*gpio_blink_set_t)(struct gpio_desc *desc, int state,
unsigned long *delay_on,
unsigned long *delay_off);
......
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