From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: linux-leds@vger.kernel.org, dri-devel@lists.freedesktop.org,
lee@kernel.org
Subject: Re: [PATCH v1] video: leds: backlight: lm3533: Support getting LED sources from DT
Date: Sun, 01 Nov 2026 14:32:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-192448@kernel.org> (raw)
In-Reply-To: <20261101142435.130520-1-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] leds: lm3533: unmasked upper bits in lm3533_led_setup() regmap update
--
commit 65c330f7377fc6ec85de7b076ec8dcd4d456b54b
Author: Svyatoslav Ryhel <clamor95@gmail.com>
video: leds: backlight: lm3533: Support getting LED sources from DT
This commit adds Control Bank to HVLED and LVLED muxing support to the
lm3533 LED and backlight drivers based on the led-sources device tree
property.
> diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c
> index 7259097bd6a71..a1aeff70a90fc 100644
> --- a/drivers/leds/leds-lm3533.c
> +++ b/drivers/leds/leds-lm3533.c
> @@ -26,6 +26,11 @@
> #define LM3533_ALS_CHANNEL_LV_MIN 1
> #define LM3533_ALS_CHANNEL_LV_MAX 2
>
> +#define LM3533_REG_OUTPUT_CONF1 0x10
> +#define OUTPUT_CONF1_SHIFT 2
> +#define OUTPUT_LVLED_MASK 0x3
> +#define LM3533_REG_OUTPUT_CONF2 0x11
> +#define OUTPUT_CONF2_SHIFT 6
> #define LM3533_REG_CTRLBANK_BCONF_BASE 0x1b
> #define LM3533_REG_PATTERN_ENABLE 0x28
> #define LM3533_REG_PATTERN_LOW_TIME_BASE 0x71
> @@ -54,6 +59,9 @@ struct lm3533_led {
> u32 max_current;
> u32 pwm;
>
> + int num_leds;
> + u32 leds[LM3533_LVCTRLBANK_MAX];
> +
> bool have_als;
> };
>
> @@ -622,8 +630,36 @@ static const struct attribute_group *lm3533_led_attribute_groups[] = {
>
> static int lm3533_led_setup(struct lm3533_led *led)
> {
> + u32 output_cfg_shift = 0;
> + u32 output_cfg_val = 0;
> + u32 output_cfg_mask = 0;
> int ret;
>
> + if (led->num_leds) {
> + for (int i = 0; i < led->num_leds; i++) {
> + if (led->leds[i] >= LM3533_LVCTRLBANK_MAX)
> + continue;
> +
> + output_cfg_shift = led->leds[i] * 2;
> + output_cfg_val |= led->id << output_cfg_shift;
> + output_cfg_mask |= OUTPUT_LVLED_MASK << output_cfg_shift;
> + }
> +
> + /* LVLED1, LVLED2 and LVLED3 */
> + ret = regmap_update_bits(led->regmap, LM3533_REG_OUTPUT_CONF1,
> + output_cfg_mask << OUTPUT_CONF1_SHIFT,
> + output_cfg_val << OUTPUT_CONF1_SHIFT);
[Severity: Medium]
In drivers/leds/leds-lm3533.c, when lm3533_led_setup() configures LVLED4
(3) or LVLED5 (4) on control bank D, E, or F (led->id > 0), output_cfg_mask
and output_cfg_val have bits [9:6] set. Left-shifting them by
OUTPUT_CONF1_SHIFT (2) without masking to 8 bits leaves bits [11:8] set
when updating the 8-bit register LM3533_REG_OUTPUT_CONF1.
In drivers/base/regmap/regmap.c:_regmap_update_bits():
ret = _regmap_read(map, reg, &orig);
if (ret != 0)
return ret;
tmp = orig & ~mask;
tmp |= val & mask;
if (force_write || (tmp != orig) || map->force_write_field) {
ret = _regmap_write(map, reg, tmp);
Because orig is an 8-bit value (<= 0xff) and val & mask has bits [11:8]
set, tmp exceeds 0xff and tmp != orig is always true. This forces a
register write with tmp > 0xff, which causes regmap_smbus_byte_reg_write()
in drivers/base/regmap/regmap-i2c.c:
if (val > 0xff || reg > 0xff)
return -EINVAL;
to reject the write with -EINVAL and fail lm3533_led_probe() on SMBus
byte-data I2C controllers, or issue an unnecessary write on raw I2C
controllers.
Should the mask and value passed to regmap_update_bits() for
LM3533_REG_OUTPUT_CONF1 be masked to 8 bits (e.g. & 0xff or u8)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261101142435.130520-1-clamor95@gmail.com?part=1
prev parent reply other threads:[~2026-11-01 14:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 14:24 [PATCH v1] video: leds: backlight: lm3533: Support getting LED sources from DT Svyatoslav Ryhel
2026-11-01 14:32 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-192448@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox