mirror of
https://github.com/torvalds/linux.git
synced 2026-08-02 05:12:01 +02:00
leds: qti-flash: Skip configuring a LED channel if it's configured already
Currently, brightness for a torch/flash device can be set on a channel that's already configured for a flash/torch device that shared the same LED channel. Though the target current configured at the end for that channel is correct, there is a transitional behavior where the channel can be disabled and enabled again. Fix this by not allowing the brightness to be set if it's attempted for the same channel id but another type (flash or torch) is configured before. Change-Id: I3ae5990121af1302e14dc2bd14f9baa178dd0cd2 Signed-off-by: Anjelique Melendez <quic_amelende@quicinc.com>
This commit is contained in:
parent
0ac549f68c
commit
24ca52d06d
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
#define pr_fmt(fmt) "qti-flash: %s: " fmt, __func__
|
||||
|
||||
|
|
@ -239,6 +239,22 @@ static int current_to_code(u32 target_curr_ma, u32 ires_ua)
|
|||
return DIV_ROUND_CLOSEST(target_curr_ma * 1000, ires_ua) - 1;
|
||||
}
|
||||
|
||||
static bool is_channel_configured(struct flash_node_data *fnode)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < fnode->led->num_fnodes; i++) {
|
||||
if (fnode->led->fnode[i].id == fnode->id &&
|
||||
fnode->led->fnode[i].type != fnode->type &&
|
||||
fnode->led->fnode[i].configured) {
|
||||
pr_debug("Channel %d for %s is already configured by %s\n", fnode->id,
|
||||
fnode->fdev.led_cdev.name, fnode->led->fnode[i].fdev.led_cdev.name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int qti_flash_led_read(struct qti_flash_led *led, u16 offset,
|
||||
u8 *data, u8 len)
|
||||
{
|
||||
|
|
@ -640,6 +656,9 @@ static void qti_flash_led_brightness_set(struct led_classdev *led_cdev,
|
|||
fnode = container_of(fdev, struct flash_node_data, fdev);
|
||||
led = fnode->led;
|
||||
|
||||
if (is_channel_configured(fnode))
|
||||
return;
|
||||
|
||||
rc = __qti_flash_led_brightness_set(led_cdev, brightness);
|
||||
if (!rc)
|
||||
fnode->user_current_ma = brightness;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user