From: Lee Jones <lee@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: Pavel Machek <pavel@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Daniel Thompson <danielt@kernel.org>,
Jingoo Han <jingoohan1@gmail.com>,
linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, mfd@lists.linux.dev,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 2/4] mfd: aat2870: Derive brightness steps from max current
Date: Mon, 19 Oct 2026 15:44:13 +0100 [thread overview]
Message-ID: <179198332384.839288.13126529382772558553@kernel.org> (raw)
In-Reply-To: <20261013180933.487013-3-clamor95@gmail.com>
Wrong subject line.
Please review, explain or fix the Sashiko review(s).
If this is a set, this request includes the other patches too.
> The AAT2870 allows only 32 steps of brightness, with this amount defined
> by the maximum supported current. Remove the need for max_brightness by
> calculating the allowed number of steps from the maximum current.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> drivers/video/backlight/aat2870_bl.c | 30 ++++++++++------------------
> 1 file changed, 10 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/video/backlight/aat2870_bl.c b/drivers/video/backlight/aat2870_bl.c
> index 8b790df1e842b..eb686e315921d 100644
> --- a/drivers/video/backlight/aat2870_bl.c
> +++ b/drivers/video/backlight/aat2870_bl.c
> @@ -24,18 +24,6 @@ struct aat2870_bl_driver_data {
> int brightness; /* current brightness */
> };
>
> -static inline int aat2870_brightness(struct aat2870_bl_driver_data *aat2870_bl,
> - int brightness)
> -{
> - struct backlight_device *bd = aat2870_bl->bd;
> - int val;
> -
> - val = brightness * (aat2870_bl->max_current - 1);
> - val /= bd->props.max_brightness;
> -
> - return val;
> -}
> -
> static inline int aat2870_bl_enable(struct aat2870_bl_driver_data *aat2870_bl)
> {
> struct aat2870_data *aat2870
> @@ -69,10 +57,11 @@ static int aat2870_bl_update_status(struct backlight_device *bd)
> dev_dbg(&bd->dev, "brightness=%d, power=%d, state=%d\n",
> bd->props.brightness, bd->props.power, bd->props.state);
>
> - ret = aat2870->write(aat2870, AAT2870_BLM,
> - (u8)aat2870_brightness(aat2870_bl, brightness));
> - if (ret < 0)
> - return ret;
> + if (brightness) {
> + ret = aat2870->write(aat2870, AAT2870_BLM, (u8)brightness - 1);
> + if (ret < 0)
> + return ret;
> + }
>
> if (brightness == 0) {
> ret = aat2870_bl_disable(aat2870_bl);
> @@ -150,10 +139,11 @@ static int aat2870_bl_probe(struct platform_device *pdev)
> else
> aat2870_bl->max_current = AAT2870_CURRENT_27_9;
>
> - if (pdata->max_brightness > 0)
> - bd->props.max_brightness = pdata->max_brightness;
> - else
> - bd->props.max_brightness = 255;
> + /*
> + * The maximum number of brightness steps is determined by the max current.
> + * The aat2870_current enum maps directly to the allowed brightness steps.
> + */
> + bd->props.max_brightness = pdata->max_current;
What happens if 'pdata->max_current' is 0? Above, we fall back to
AAT2870_CURRENT_27_9 when assigning 'aat2870_bl->max_current'. Shouldn't this
use 'aat2870_bl->max_current' instead, and if 'aat2870_bl->max_current' is no
longer used anywhere else, should it be dropped from 'aat2870_bl_driver_data'?
>
> aat2870_bl->brightness = 0;
> bd->props.power = BACKLIGHT_POWER_ON;
> --
> 2.53.0
>
--
Lee Jones
next prev parent reply other threads:[~2026-10-19 14:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 18:09 [PATCH v3 0/4] mfd: aat2870: Convert to use OF bindings Svyatoslav Ryhel
2026-10-13 18:09 ` [PATCH v3 1/4] dt-bindings: mfd: Document Skyworks AAT2870 Svyatoslav Ryhel
2026-10-16 15:23 ` Daniel Thompson
2026-10-19 14:52 ` Lee Jones
2026-10-19 14:59 ` Svyatoslav Ryhel
2026-10-19 16:02 ` Lee Jones
2026-10-19 16:07 ` Svyatoslav Ryhel
2026-10-13 18:09 ` [PATCH v3 2/4] mfd: aat2870: Derive brightness steps from max current Svyatoslav Ryhel
2026-10-16 15:30 ` Daniel Thompson
2026-10-16 16:27 ` Svyatoslav Ryhel
2026-10-19 14:44 ` Lee Jones [this message]
2026-10-19 14:55 ` Svyatoslav Ryhel
2026-10-19 16:02 ` Lee Jones
2026-10-13 18:09 ` [PATCH v3 3/4] mfd: aat2870: Convert to use OF bindings Svyatoslav Ryhel
2026-10-16 15:34 ` Daniel Thompson
2026-10-19 14:51 ` Lee Jones
2026-10-19 14:56 ` Svyatoslav Ryhel
2026-10-13 18:09 ` [PATCH v3 4/4] mfd: aat2870: Add support for VIN and IN-LDO power supplies Svyatoslav Ryhel
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=179198332384.839288.13126529382772558553@kernel.org \
--to=lee@kernel.org \
--cc=broonie@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=danielt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=pavel@kernel.org \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®