From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org,
dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 11/14] video: backlight: lm3533_bl: Improve logic of sysfs functions
Date: Sat, 06 Jun 2026 05:12:25 +0000 [thread overview]
Message-ID: <20260606051226.4AC861F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260606045738.21050-12-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] sysfs show functions `show_als_en` and `show_linear` return prematurely when the tested bits are set, breaking the sysfs read and returning an empty/uninitialized buffer.
--
commit 549a7f316072e9f93bfcd3d182e73739a35c0c7a
Author: Svyatoslav Ryhel <clamor95@gmail.com>
video: backlight: lm3533_bl: Improve logic of sysfs functions
Simplify the sysfs logic of properties by switching to macros and proper
regmap helpers.
> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
> --- a/drivers/video/backlight/lm3533_bl.c
> +++ b/drivers/video/backlight/lm3533_bl.c
[ ... ]
> @@ -85,88 +87,68 @@ static ssize_t show_als_channel(struct device *dev,
> return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
> }
>
> -static ssize_t show_als_en(struct device *dev,
> - struct device_attribute *attr, char *buf)
> +static ssize_t show_als_en(struct device *dev, struct device_attribute *attr,
> + char *buf)
> {
> struct lm3533_bl *bl = dev_get_drvdata(dev);
> int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
> - u32 val;
> - u8 mask;
> - bool enable;
> int ret;
>
> - ret = regmap_read(bl->regmap, LM3533_REG_CTRLBANK_AB_BCONF, &val);
> + ret = regmap_test_bits(bl->regmap, LM3533_REG_CTRLBANK_AB_BCONF,
> + CTRLBANK_AB_BCONF_ALS(ctrlbank));
> if (ret)
> return ret;
[Severity: High]
Does this error check prematurely exit the function when the bit is set?
regmap_test_bits() returns 1 if the specified bit is set. If the bit is set,
the if (ret) condition evaluates to true, causing the function to return 1
immediately instead of formatting the buffer.
This could break the sysfs API contract and return a single null byte to
userspace instead of the expected string. Should this check be if (ret < 0)
instead?
>
> - mask = 1 << (2 * ctrlbank);
> - enable = val & mask;
> -
> - return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
> + return scnprintf(buf, PAGE_SIZE, "%d\n", ret);
> }
[ ... ]
> -static ssize_t show_linear(struct device *dev,
> - struct device_attribute *attr, char *buf)
> +static ssize_t show_linear(struct device *dev, struct device_attribute *attr,
> + char *buf)
> {
> struct lm3533_bl *bl = dev_get_drvdata(dev);
> - u32 val;
> - u8 mask;
> - int linear;
> + int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
> int ret;
>
> - ret = regmap_read(bl->regmap, LM3533_REG_CTRLBANK_AB_BCONF, &val);
> + ret = regmap_test_bits(bl->regmap, LM3533_REG_CTRLBANK_AB_BCONF,
> + CTRLBANK_AB_BCONF_MODE(ctrlbank));
> if (ret)
> return ret;
[Severity: High]
Could this have the same issue as show_als_en() above?
When the linear mode bit is set, regmap_test_bits() returns 1, triggering
this error path and returning 1 directly instead of calling scnprintf().
>
> - mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
> -
> - if (val & mask)
> - linear = 1;
> - else
> - linear = 0;
> -
> - return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
> + return scnprintf(buf, PAGE_SIZE, "%x\n", ret);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260606045738.21050-1-clamor95@gmail.com?part=11
next prev parent reply other threads:[~2026-06-06 5:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 4:57 [PATCH v4 00/14] mfd: lm3533: convert to OF bindings, improve support Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 01/14] dt-bindings: leds: Document TI LM3533 LED controller Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 02/14] mfd: lm3533: Remove driver specific regmap wrappers Svyatoslav Ryhel
2026-06-06 6:53 ` Andy Shevchenko
2026-06-06 7:22 ` Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 03/14] mfd: lm3533: Remove extern from shared functions in the header Svyatoslav Ryhel
2026-06-06 6:46 ` Andy Shevchenko
2026-06-06 4:57 ` [PATCH v4 04/14] mfd: lm3533: Pass only regmap and light sensor presence to child devices Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 05/14] iio: light: lm3533-als: Remove redundant pdata helpers Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 06/14] mfd: lm3533-core: " Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 07/14] mfd: lm3533: Switch sysfs_create_group() to device_add_group() Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 08/14] mfd: lm3533: Convert to use OF bindings Svyatoslav Ryhel
2026-06-06 5:14 ` sashiko-bot
2026-06-06 4:57 ` [PATCH v4 09/14] mfd: lm3533: Add support for VIN power supply Svyatoslav Ryhel
2026-06-06 4:57 ` [PATCH v4 10/14] mfd: lm3533: Set DMA mask Svyatoslav Ryhel
2026-06-06 5:08 ` sashiko-bot
2026-06-06 4:57 ` [PATCH v4 11/14] video: backlight: lm3533_bl: Improve logic of sysfs functions Svyatoslav Ryhel
2026-06-06 5:12 ` sashiko-bot [this message]
2026-06-06 4:57 ` [PATCH v4 12/14] video: backlight: lm3533_bl: Set initial mapping mode from DT Svyatoslav Ryhel
2026-06-06 5:16 ` sashiko-bot
2026-06-06 4:57 ` [PATCH v4 13/14] video: backlight: lm3533_bl: Implement backlight_scale property Svyatoslav Ryhel
2026-06-06 5:17 ` sashiko-bot
2026-06-06 4:57 ` [PATCH v4 14/14] video: leds: backlight: lm3533: Support getting LED sources from DT Svyatoslav Ryhel
2026-06-06 5:21 ` sashiko-bot
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=20260606051226.4AC861F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robh@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