Skip to content

Commit 831462f

Browse files
committed
Merge tag 'leds-next-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds
Pull LED updates from Lee Jones: "Improvements & Fixes: - A fix for QCOM Flash to prevent incorrect register access when the driver is re-bound. This is solved by duplicating a static register array during the probe function, which prevents register addresses from being miscalculated after multiple binds - The LP50xx driver now correctly handles the 'reg' property in device tree child nodes to ensure the multi_index is set correctly. This prevents issues where LEDs could be controlled incorrectly if the device tree nodes were processed in a different order. An error is returned if the reg property is missing or out of range - Add a Kconfig dependency on between TPS6131x and V4L2_FLASH_LED_CLASS to prevent a build failure when the driver is built-in and the V4L2 flash infrastructure is a loadable module - Fix a potential buffer overflow warning in PCA955x reported by older GCC versions by using a more precise format specifier when creating the default LED label. Cleanups & Refactoring: - Correct the MAINTAINERS file entry for the TPS6131X flash LED driver to point to the correct device tree binding file name - Fix a comment in the Flash Class for the flash_timeout setter to "flash timeout" from "flash duration" for accuracy - The of_led_get() function is no longer exported as it has no users outside of its own module. Removals: - Revert the commit to configure LED blink intervals for hardware offload in the Netdev Trigger. This change was found to break existing PHY drivers by putting their LEDs into a permanent, unconditional blinking state. Device Tree Bindings Updates: - Update the binding for LP50xx to document that the child reg property is the index within the LED bank. The example was also updated to use correct values - Update the JNCP5623 binding to add 0x39 as a valid I2C address, as it is used by the NCP5623C variant" * tag 'leds-next-6.17' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/leds: dt-bindings: leds: ncp5623: Add 0x39 as a valid I2C address Revert "leds: trigger: netdev: Configure LED blink interval for HW offload" leds: pca955x: Avoid potential overflow when filling default_label (take 2) leds: Unexport of_led_get() leds: tps6131x: Add V4L2_FLASH_LED_CLASS dependency dt-bindings: leds: lp50xx: Document child reg, fix example leds: leds-lp50xx: Handle reg to get correct multi_index leds: led-class-flash:: Fix flash_timeout comment MAINTAINERS: Adjust file entry in TPS6131X FLASH LED DRIVER leds: flash: leds-qcom-flash: Fix registry access after re-bind
2 parents 24e5c32 + 4903924 commit 831462f

File tree

11 files changed

+45
-33
lines changed

11 files changed

+45
-33
lines changed

Documentation/devicetree/bindings/leds/leds-lp50xx.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ patternProperties:
8181

8282
properties:
8383
reg:
84-
maxItems: 1
84+
items:
85+
- minimum: 0
86+
maximum: 2
87+
88+
description:
89+
This property denotes the index within the LED bank.
8590

8691
required:
8792
- reg
@@ -138,18 +143,18 @@ examples:
138143
color = <LED_COLOR_ID_RGB>;
139144
function = LED_FUNCTION_STANDBY;
140145
141-
led@3 {
142-
reg = <0x3>;
146+
led@0 {
147+
reg = <0x0>;
143148
color = <LED_COLOR_ID_RED>;
144149
};
145150
146-
led@4 {
147-
reg = <0x4>;
151+
led@1 {
152+
reg = <0x1>;
148153
color = <LED_COLOR_ID_GREEN>;
149154
};
150155
151-
led@5 {
152-
reg = <0x5>;
156+
led@2 {
157+
reg = <0x2>;
153158
color = <LED_COLOR_ID_BLUE>;
154159
};
155160
};

Documentation/devicetree/bindings/leds/onnn,ncp5623.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ properties:
1919
- onnn,ncp5623
2020

2121
reg:
22-
const: 0x38
22+
enum:
23+
- 0x38
24+
- 0x39
2325

2426
multi-led:
2527
type: object

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24813,7 +24813,7 @@ TEXAS INSTRUMENTS TPS6131X FLASH LED DRIVER
2481324813
M: Matthias Fend <[email protected]>
2481424814
2481524815
S: Maintained
24816-
F: Documentation/devicetree/bindings/leds/ti,tps6131x.yaml
24816+
F: Documentation/devicetree/bindings/leds/ti,tps61310.yaml
2481724817
F: drivers/leds/flash/leds-tps6131x.c
2481824818

2481924819
TEXAS INSTRUMENTS' DAC7612 DAC DRIVER

drivers/leds/flash/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ config LEDS_TPS6131X
136136
tristate "LED support for TI TPS6131x flash LED driver"
137137
depends on I2C && OF
138138
depends on GPIOLIB
139+
depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
139140
select REGMAP_I2C
140141
help
141142
This option enables support for Texas Instruments TPS61310/TPS61311

drivers/leds/flash/leds-qcom-flash.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ enum {
117117
REG_MAX_COUNT,
118118
};
119119

120-
static struct reg_field mvflash_3ch_regs[REG_MAX_COUNT] = {
120+
static const struct reg_field mvflash_3ch_regs[REG_MAX_COUNT] = {
121121
REG_FIELD(0x08, 0, 7), /* status1 */
122122
REG_FIELD(0x09, 0, 7), /* status2 */
123123
REG_FIELD(0x0a, 0, 7), /* status3 */
@@ -132,7 +132,7 @@ static struct reg_field mvflash_3ch_regs[REG_MAX_COUNT] = {
132132
REG_FIELD(0x58, 0, 2), /* therm_thrsh3 */
133133
};
134134

135-
static struct reg_field mvflash_4ch_regs[REG_MAX_COUNT] = {
135+
static const struct reg_field mvflash_4ch_regs[REG_MAX_COUNT] = {
136136
REG_FIELD(0x06, 0, 7), /* status1 */
137137
REG_FIELD(0x07, 0, 6), /* status2 */
138138
REG_FIELD(0x09, 0, 7), /* status3 */
@@ -854,11 +854,17 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
854854
if (val == FLASH_SUBTYPE_3CH_PM8150_VAL || val == FLASH_SUBTYPE_3CH_PMI8998_VAL) {
855855
flash_data->hw_type = QCOM_MVFLASH_3CH;
856856
flash_data->max_channels = 3;
857-
regs = mvflash_3ch_regs;
857+
regs = devm_kmemdup(dev, mvflash_3ch_regs, sizeof(mvflash_3ch_regs),
858+
GFP_KERNEL);
859+
if (!regs)
860+
return -ENOMEM;
858861
} else if (val == FLASH_SUBTYPE_4CH_VAL) {
859862
flash_data->hw_type = QCOM_MVFLASH_4CH;
860863
flash_data->max_channels = 4;
861-
regs = mvflash_4ch_regs;
864+
regs = devm_kmemdup(dev, mvflash_4ch_regs, sizeof(mvflash_4ch_regs),
865+
GFP_KERNEL);
866+
if (!regs)
867+
return -ENOMEM;
862868

863869
rc = regmap_read(regmap, reg_base + FLASH_REVISION_REG, &val);
864870
if (rc < 0) {
@@ -880,6 +886,7 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
880886
dev_err(dev, "Failed to allocate regmap field, rc=%d\n", rc);
881887
return rc;
882888
}
889+
devm_kfree(dev, regs); /* devm_regmap_field_bulk_alloc() makes copies */
883890

884891
platform_set_drvdata(pdev, flash_data);
885892
mutex_init(&flash_data->lock);

drivers/leds/led-class.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static const struct class leds_class = {
256256
* Returns the LED device parsed from the phandle specified in the "leds"
257257
* property of a device tree node or a negative error-code on failure.
258258
*/
259-
struct led_classdev *of_led_get(struct device_node *np, int index)
259+
static struct led_classdev *of_led_get(struct device_node *np, int index)
260260
{
261261
struct device *led_dev;
262262
struct device_node *led_node;
@@ -270,7 +270,6 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
270270

271271
return led_module_get(led_dev);
272272
}
273-
EXPORT_SYMBOL_GPL(of_led_get);
274273

275274
/**
276275
* led_put() - release a LED device

drivers/leds/leds-lp50xx.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,24 @@ static int lp50xx_probe_dt(struct lp50xx *priv)
476476
return -ENOMEM;
477477

478478
fwnode_for_each_child_node(child, led_node) {
479+
int multi_index;
479480
ret = fwnode_property_read_u32(led_node, "color",
480481
&color_id);
481482
if (ret) {
482483
fwnode_handle_put(led_node);
483484
dev_err(priv->dev, "Cannot read color\n");
484485
return ret;
485486
}
487+
ret = fwnode_property_read_u32(led_node, "reg", &multi_index);
488+
if (ret != 0) {
489+
dev_err(priv->dev, "reg must be set\n");
490+
return -EINVAL;
491+
} else if (multi_index >= LP50XX_LEDS_PER_MODULE) {
492+
dev_err(priv->dev, "reg %i out of range\n", multi_index);
493+
return -EINVAL;
494+
}
486495

487-
mc_led_info[num_colors].color_index = color_id;
496+
mc_led_info[multi_index].color_index = color_id;
488497
num_colors++;
489498
}
490499

drivers/leds/leds-pca955x.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static int pca955x_probe(struct i2c_client *client)
587587
struct pca955x_platform_data *pdata;
588588
bool keep_psc0 = false;
589589
bool set_default_label = false;
590-
char default_label[8];
590+
char default_label[4];
591591
int bit, err, reg;
592592

593593
chip = i2c_get_match_data(client);
@@ -693,7 +693,7 @@ static int pca955x_probe(struct i2c_client *client)
693693
}
694694

695695
if (set_default_label) {
696-
snprintf(default_label, sizeof(default_label), "%u", i);
696+
snprintf(default_label, sizeof(default_label), "%hhu", i);
697697
init_data.default_label = default_label;
698698
} else {
699699
init_data.default_label = NULL;

drivers/leds/trigger/ledtrig-netdev.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ struct led_netdev_data {
6868
unsigned int last_activity;
6969

7070
unsigned long mode;
71-
unsigned long blink_delay;
7271
int link_speed;
7372
__ETHTOOL_DECLARE_LINK_MODE_MASK(supported_link_modes);
7473
u8 duplex;
@@ -87,10 +86,6 @@ static void set_baseline_state(struct led_netdev_data *trigger_data)
8786
/* Already validated, hw control is possible with the requested mode */
8887
if (trigger_data->hw_control) {
8988
led_cdev->hw_control_set(led_cdev, trigger_data->mode);
90-
if (led_cdev->blink_set) {
91-
led_cdev->blink_set(led_cdev, &trigger_data->blink_delay,
92-
&trigger_data->blink_delay);
93-
}
9489

9590
return;
9691
}
@@ -459,11 +454,10 @@ static ssize_t interval_store(struct device *dev,
459454
size_t size)
460455
{
461456
struct led_netdev_data *trigger_data = led_trigger_get_drvdata(dev);
462-
struct led_classdev *led_cdev = trigger_data->led_cdev;
463457
unsigned long value;
464458
int ret;
465459

466-
if (trigger_data->hw_control && !led_cdev->blink_set)
460+
if (trigger_data->hw_control)
467461
return -EINVAL;
468462

469463
ret = kstrtoul(buf, 0, &value);
@@ -472,13 +466,9 @@ static ssize_t interval_store(struct device *dev,
472466

473467
/* impose some basic bounds on the timer interval */
474468
if (value >= 5 && value <= 10000) {
475-
if (trigger_data->hw_control) {
476-
trigger_data->blink_delay = value;
477-
} else {
478-
cancel_delayed_work_sync(&trigger_data->work);
469+
cancel_delayed_work_sync(&trigger_data->work);
479470

480-
atomic_set(&trigger_data->interval, msecs_to_jiffies(value));
481-
}
471+
atomic_set(&trigger_data->interval, msecs_to_jiffies(value));
482472
set_baseline_state(trigger_data); /* resets timer */
483473
}
484474

include/linux/led-class-flash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ int led_update_flash_brightness(struct led_classdev_flash *fled_cdev);
197197
* @fled_cdev: the flash LED to set
198198
* @timeout: the flash timeout to set it to
199199
*
200-
* Set the flash strobe duration.
200+
* Set the flash strobe timeout.
201201
*
202202
* Returns: 0 on success or negative error value on failure
203203
*/

0 commit comments

Comments
 (0)