Skip to content

Commit 75caf59

Browse files
committed
Merge tag 'leds-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds
Pull LED updates from Pavel Machek: "Lee Jones offered his help with maintaining LEDs, thanks a lot. Plus, there are some bugfixes as a bonus" * tag 'leds-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds: leds: MAINTAINERS: include dt-bindings headers leds: qcom,pm8058-led: Convert to DT schema leds: use sysfs_emit() to instead of scnprintf() leds: is31fl319x: Fix setting current limit for is31fl319{0,1,3} MAINTAINERS: Add additional co-maintainer to LEDs leds: lp5523: fix out-of-bounds bug in lp5523_selftest() dt-bindings: leds: Add 'cpuX' to 'linux,default-trigger' led: qcom-lpg: Fix sleeping in atomic leds: max8997: Don't error if there is no pdata leds: lp55xx: remove variable j leds-pca955x: Remove the unused function pca95xx_num_led_regs()
2 parents ed56954 + 7cb092a commit 75caf59

File tree

15 files changed

+108
-115
lines changed

15 files changed

+108
-115
lines changed

Documentation/devicetree/bindings/leds/common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ properties:
100100
- pattern
101101
# LED is triggered by SD/MMC activity
102102
- pattern: "^mmc[0-9]+$"
103+
- pattern: "^cpu[0-9]*$"
103104

104105
led-pattern:
105106
description: |

Documentation/devicetree/bindings/leds/leds-pm8058.txt

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/leds/qcom,pm8058-led.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Qualcomm PM8058 PMIC LED
8+
9+
maintainers:
10+
- Krzysztof Kozlowski <[email protected]>
11+
12+
description: |
13+
The Qualcomm PM8058 contains an LED block for up to six LEDs:: three normal
14+
LEDs, two "flash" LEDs and one "keypad backlight" LED. The names are quoted
15+
because sometimes these LED drivers are used for wildly different things than
16+
flash or keypad backlight:: their names are more of a suggestion than a
17+
hard-wired usecase.
18+
19+
Hardware-wise the different LEDs support slightly different output currents.
20+
The "flash" LEDs do not need to charge nor do they support external triggers.
21+
They are just powerful LED drivers.
22+
23+
allOf:
24+
- $ref: common.yaml#
25+
26+
properties:
27+
compatible:
28+
enum:
29+
- qcom,pm8058-led
30+
- qcom,pm8058-keypad-led
31+
- qcom,pm8058-flash-led
32+
33+
reg:
34+
maxItems: 1
35+
36+
required:
37+
- compatible
38+
- reg
39+
40+
unevaluatedProperties: false
41+
42+
examples:
43+
- |
44+
#include <dt-bindings/leds/common.h>
45+
46+
pmic {
47+
#address-cells = <1>;
48+
#size-cells = <0>;
49+
50+
led@131 {
51+
compatible = "qcom,pm8058-led";
52+
reg = <0x131>;
53+
label = "pm8058:red";
54+
color = <LED_COLOR_ID_RED>;
55+
default-state = "off";
56+
};
57+
};

Documentation/devicetree/bindings/mfd/qcom-pm8xxx.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ properties:
3939
interrupt-controller: true
4040

4141
patternProperties:
42+
"led@[0-9a-f]+$":
43+
type: object
44+
$ref: /schemas/leds/qcom,pm8058-led.yaml#
45+
4246
"rtc@[0-9a-f]+$":
4347
type: object
4448
$ref: "../rtc/qcom-pm8xxx-rtc.yaml"

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11732,11 +11732,13 @@ F: scripts/leaking_addresses.pl
1173211732

1173311733
LED SUBSYSTEM
1173411734
M: Pavel Machek <[email protected]>
11735+
M: Lee Jones <[email protected]>
1173511736
1173611737
S: Maintained
1173711738
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git
1173811739
F: Documentation/devicetree/bindings/leds/
1173911740
F: drivers/leds/
11741+
F: include/dt-bindings/leds/
1174011742
F: include/linux/leds.h
1174111743

1174211744
LEGACY EEPROM DRIVER

drivers/leds/leds-blinkm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ static ssize_t show_color_common(struct device *dev, char *buf, int color)
139139
return ret;
140140
switch (color) {
141141
case RED:
142-
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->red);
142+
return sysfs_emit(buf, "%02X\n", data->red);
143143
case GREEN:
144-
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->green);
144+
return sysfs_emit(buf, "%02X\n", data->green);
145145
case BLUE:
146-
return scnprintf(buf, PAGE_SIZE, "%02X\n", data->blue);
146+
return sysfs_emit(buf, "%02X\n", data->blue);
147147
default:
148148
return -EINVAL;
149149
}
@@ -253,7 +253,7 @@ static DEVICE_ATTR_RW(blue);
253253
static ssize_t test_show(struct device *dev, struct device_attribute *attr,
254254
char *buf)
255255
{
256-
return scnprintf(buf, PAGE_SIZE,
256+
return sysfs_emit(buf,
257257
"#Write into test to start test sequence!#\n");
258258
}
259259

drivers/leds/leds-is31fl319x.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define IS31FL3190_CURRENT_uA_MIN 5000
3939
#define IS31FL3190_CURRENT_uA_DEFAULT 42000
4040
#define IS31FL3190_CURRENT_uA_MAX 42000
41+
#define IS31FL3190_CURRENT_SHIFT 2
4142
#define IS31FL3190_CURRENT_MASK GENMASK(4, 2)
4243
#define IS31FL3190_CURRENT_5_mA 0x02
4344
#define IS31FL3190_CURRENT_10_mA 0x01
@@ -553,7 +554,7 @@ static int is31fl319x_probe(struct i2c_client *client)
553554
is31fl3196_db_to_gain(is31->audio_gain_db));
554555
else
555556
regmap_update_bits(is31->regmap, IS31FL3190_CURRENT, IS31FL3190_CURRENT_MASK,
556-
is31fl3190_microamp_to_cs(dev, aggregated_led_microamp));
557+
is31fl3190_microamp_to_cs(dev, aggregated_led_microamp) << IS31FL3190_CURRENT_SHIFT);
557558

558559
for (i = 0; i < is31->cdef->num_leds; i++) {
559560
struct is31fl319x_led *led = &is31->leds[i];

drivers/leds/leds-lm3533.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static ssize_t show_id(struct device *dev,
314314
struct led_classdev *led_cdev = dev_get_drvdata(dev);
315315
struct lm3533_led *led = to_lm3533_led(led_cdev);
316316

317-
return scnprintf(buf, PAGE_SIZE, "%d\n", led->id);
317+
return sysfs_emit(buf, "%d\n", led->id);
318318
}
319319

320320
/*
@@ -344,7 +344,7 @@ static ssize_t show_risefalltime(struct device *dev,
344344
if (ret)
345345
return ret;
346346

347-
return scnprintf(buf, PAGE_SIZE, "%x\n", val);
347+
return sysfs_emit(buf, "%x\n", val);
348348
}
349349

350350
static ssize_t show_risetime(struct device *dev,
@@ -415,7 +415,7 @@ static ssize_t show_als_channel(struct device *dev,
415415

416416
channel = (val & LM3533_REG_CTRLBANK_BCONF_ALS_CHANNEL_MASK) + 1;
417417

418-
return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
418+
return sysfs_emit(buf, "%u\n", channel);
419419
}
420420

421421
static ssize_t store_als_channel(struct device *dev,
@@ -465,7 +465,7 @@ static ssize_t show_als_en(struct device *dev,
465465

466466
enable = val & LM3533_REG_CTRLBANK_BCONF_ALS_EN_MASK;
467467

468-
return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
468+
return sysfs_emit(buf, "%d\n", enable);
469469
}
470470

471471
static ssize_t store_als_en(struct device *dev,
@@ -518,7 +518,7 @@ static ssize_t show_linear(struct device *dev,
518518
else
519519
linear = 0;
520520

521-
return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
521+
return sysfs_emit(buf, "%x\n", linear);
522522
}
523523

524524
static ssize_t store_linear(struct device *dev,
@@ -564,7 +564,7 @@ static ssize_t show_pwm(struct device *dev,
564564
if (ret)
565565
return ret;
566566

567-
return scnprintf(buf, PAGE_SIZE, "%u\n", val);
567+
return sysfs_emit(buf, "%u\n", val);
568568
}
569569

570570
static ssize_t store_pwm(struct device *dev,

drivers/leds/leds-lp5521.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ static ssize_t lp5521_selftest(struct device *dev,
469469
ret = lp5521_run_selftest(chip, buf);
470470
mutex_unlock(&chip->lock);
471471

472-
return scnprintf(buf, PAGE_SIZE, "%s\n", ret ? "FAIL" : "OK");
472+
return sysfs_emit(buf, "%s\n", ret ? "FAIL" : "OK");
473473
}
474474

475475
/* device attributes */

drivers/leds/leds-lp5523.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ static ssize_t lp5523_selftest(struct device *dev,
581581
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
582582
struct lp55xx_chip *chip = led->chip;
583583
struct lp55xx_platform_data *pdata = chip->pdata;
584-
int i, ret, pos = 0;
585-
u8 status, adc, vdd;
584+
int ret, pos = 0;
585+
u8 status, adc, vdd, i;
586586

587587
mutex_lock(&chip->lock);
588588

@@ -612,41 +612,44 @@ static ssize_t lp5523_selftest(struct device *dev,
612612

613613
vdd--; /* There may be some fluctuation in measurement */
614614

615-
for (i = 0; i < LP5523_MAX_LEDS; i++) {
616-
/* Skip non-existing channels */
615+
for (i = 0; i < pdata->num_channels; i++) {
616+
/* Skip disabled channels */
617617
if (pdata->led_config[i].led_current == 0)
618618
continue;
619619

620620
/* Set default current */
621-
lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + i,
621+
lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + led->chan_nr,
622622
pdata->led_config[i].led_current);
623623

624-
lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0xff);
624+
lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr,
625+
0xff);
625626
/* let current stabilize 2 - 4ms before measurements start */
626627
usleep_range(2000, 4000);
627628
lp55xx_write(chip, LP5523_REG_LED_TEST_CTRL,
628-
LP5523_EN_LEDTEST | i);
629+
LP5523_EN_LEDTEST | led->chan_nr);
629630
/* ADC conversion time is 2.7 ms typically */
630631
usleep_range(3000, 6000);
631632
ret = lp55xx_read(chip, LP5523_REG_STATUS, &status);
632633
if (ret < 0)
633634
goto fail;
634635

635636
if (!(status & LP5523_LEDTEST_DONE))
636-
usleep_range(3000, 6000);/* Was not ready. Wait. */
637+
usleep_range(3000, 6000); /* Was not ready. Wait. */
637638

638639
ret = lp55xx_read(chip, LP5523_REG_LED_TEST_ADC, &adc);
639640
if (ret < 0)
640641
goto fail;
641642

642643
if (adc >= vdd || adc < LP5523_ADC_SHORTCIRC_LIM)
643-
pos += sprintf(buf + pos, "LED %d FAIL\n", i);
644+
pos += sprintf(buf + pos, "LED %d FAIL\n",
645+
led->chan_nr);
644646

645-
lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0x00);
647+
lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr,
648+
0x00);
646649

647650
/* Restore current */
648-
lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + i,
649-
led->led_current);
651+
lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + led->chan_nr,
652+
led->led_current);
650653
led++;
651654
}
652655
if (pos == 0)

0 commit comments

Comments
 (0)