From: sashiko-bot@kernel.org
To: "Wim de With" <wf@dewith.io>
Cc: dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org,
lee@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
robh@kernel.org
Subject: Re: [PATCH v2 2/2] backlight: Add support for Orient Chip OCP8178
Date: Wed, 12 Aug 2026 19:34:56 +0000 [thread overview]
Message-ID: <20260812193457.002A61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812-ocp8178-backlight-v2-2-4ad18b48bef8@dewith.io>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver fails to re-initialize the 1-Wire mode after a power loss (e.g., during suspend), leaving the device stuck in PWM mode.
- [Medium] Lack of atomicity and timing validation across the 2-byte 1-Wire transaction can cause silent brightness update failures due to preemption.
--
--- Patch [2]: [PATCH v2 2/2] backlight: Add support for Orient Chip OCP8178 ---
commit 11ca2bd66a2c85f8bb56c8b3475708379c8ddf5e
Author: Wim de With <wf@dewith.io>
backlight: Add support for Orient Chip OCP8178
Add a driver for the Orient Chip OCP8178 backlight controller.
The OCP8178 supports either PWM or a vendor-specific onewire protocol
over GPIO.
> diff --git a/drivers/video/backlight/ocp8178_bl.c b/drivers/video/backlight/ocp8178_bl.c
> new file mode 100644
> index 0000000000000..bc48636ef64e4
> --- /dev/null
> +++ b/drivers/video/backlight/ocp8178_bl.c
[ ... ]
> +static void ocp8178_bl_set_brightness(struct ocp8178_bl *ocp8178, u8 brightness)
> +{
> + u8 data = 0;
> +
> + /*
> + * We cannot set RFA (request for acknowledge) unless the GPIO pin is
> + * configured as open drain.
> + */
> + data |= FIELD_PREP(OCP8178_DATA_RFA, 0);
> + data |= FIELD_PREP(OCP8178_DATA_ADDR, 0);
> + data |= FIELD_PREP(OCP8178_DATA_VALUE, brightness);
> +
> + ocp8178_bl_write_u8(ocp8178, OCP8178_DEVICE_ADDRESS);
> + ocp8178_bl_write_u8(ocp8178, data);
[Severity: Medium]
Can a preemption or interrupt between these two byte writes delay the second
byte and violate the 1-Wire protocol timing?
The initialization sequence ocp8178_bl_enable_onewire() explicitly checks
duration >= OCP8178_1W_T_WIN_NS to verify that timing wasn't ruined by
preemption. However, in ocp8178_bl_set_brightness(), if the thread is preempted
between the two ocp8178_bl_write_u8() calls, the GPIO line is left idle HIGH.
Would this cause the hardware's 1-Wire state machine to time out and treat the
subsequent data byte as a new command, resulting in a silently lost brightness
update since the driver doesn't read an ACK?
> +}
[ ... ]
> +static const struct backlight_ops ocp8178_bl_ops = {
> + .options = BL_CORE_SUSPENDRESUME,
> + .update_status = ocp8178_bl_update_status,
> +};
[ ... ]
> +static struct platform_driver ocp8178_bl_driver = {
> + .driver = {
> + .name = "ocp8178-bl",
> + .of_match_table = ocp8178_bl_of_match,
> + },
> + .probe = ocp8178_bl_probe,
> +};
[Severity: High]
Does this driver need a resume PM hook to re-initialize the 1-Wire mode?
The BL_CORE_SUSPENDRESUME option causes the backlight core to call
update_status() on resume. Since power to the chip may be cut during suspend,
the device defaults to PWM mode upon power-on.
Without a resume hook in the platform driver to call
ocp8178_bl_enable_onewire(), the chip will misinterpret the 1-Wire brightness
data as a PWM signal. This leaves the GPIO HIGH at the end of the transaction,
which translates to 100% brightness in PWM mode.
> +module_platform_driver(ocp8178_bl_driver);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812-ocp8178-backlight-v2-0-4ad18b48bef8@dewith.io?part=2
prev parent reply other threads:[~2026-08-12 19:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 19:21 [PATCH v2 0/2] backlight: Add support for Orient Chip OCP8178 Wim de With
2026-08-12 19:21 ` [PATCH v2 1/2] dt-bindings: backlight: Add " Wim de With
2026-08-12 19:28 ` sashiko-bot
2026-08-12 19:21 ` [PATCH v2 2/2] backlight: Add support for " Wim de With
2026-08-12 19:34 ` 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=20260812193457.002A61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lee@kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wf@dewith.io \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.