From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796421910; b=XCwMO1sGtGz/IoOR2PeGKiLDWKKc1FixCNTCI/r46tIKQNYaHrB1dhcBNT6zT8qHw5wn x/8PtnIkBBdGBZytq4xAibHrr0uGtL+GXMu2LTMkbk0KVrc7Y+sRkh7CtOZKXnovXBZRN nl8LXNd7dDuMFTFmpDCivAoE1FE/U2IeiOkKNvpNwC7Nz2smdwLuYdNYwJdZYN+B7an+8 D4f4YjvyV59d2ac+PAXmaQSsTFZ1vfR7S/V4B4OXuDsXT8UZpEbm0ZN+QDK7UqZIwT/z1 RmKu5m+KFvxiyvQMVvxNsXV8AM+KlIcc0WGbPcjOVbH2PcadMBPbJONlFuG1f9EJH3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796421910; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=WdaaStU1rP3CZfjM9mJI+EHvXXek5Zs11ayJF02kAXg=; b=VudCxT5Podm9eQs0DoPlMeGp684YptGzkW+nzRwl1X+RvNUFvYWjaZh5deY6kZmxPRqd QjgJZ3+UF0OYpTCSExkNylGQKWZS5yP/aJPfj5s/FNw57PRFCqQt96IirazQrTGiJI124 i9O9eh2WlwmPlY0HSJx49H1a+ZAhypUGKKKDun/J3tHQhUmPr9Js/WSQSIqlFvqbSK6T8 DQXFc5vbVfscVFtwOOKNY8qItKhdGz9jGp/Y0FeKatxlvs34LPc1Pci+RL9PEzxrDRKPx Ml6CRCxN7cFJpVFOG2I/UFV+CbLkbE/gbj+0JK9YVyOS1xDPqfQJvbyhp8MZlEE0uUg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="h/oJ6OkF"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD6C6606A33F; Fri, 4 Dec 2026 22:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=h/oJ6OkF Received: by smtp.kernel.org (Postfix) with ESMTPSA id E600F1F0093B; Fri, 4 Dec 2026 22:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796421910; bh=WdaaStU1rP3CZfjM9mJI+EHvXXek5Zs11ayJF02kAXg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=h/oJ6OkFrYrTR4R+m1i2JY5mCfdolCfZSuhIeU7ibv2faDM8k+oFw7tzWQWb60CP0 mpHaPmDhup5jQQOAZ6ujL6qyrl7VR2p2s9+afDRaMhtom9lycOB8UgQmEpTqjPuq6K HiPPYlNvGuMTA5K0kJ7yLnBwxOFyz6thpnvK5tcAVcRynULoy5TGXYFJxZr2CS5Ge6 BDJ+0CcG/cw/2czOQDq41b9EvKDawdHSb1XUP9OUB90XmVZS0KJ0ErLBkYqBBEi6+J XWapamgQMSOay+N0h6l4H5gu/w+Ix0EOtk0NaF1EQjc/Hrplpq+RtyOSIABmsPT4IR WMtk40IRyAb9Q== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/4] video: backlight: Add Awinic AW99703 Reply-To: sashiko-reviews@lists.linux.dev To: "Andreas Kemnade" Cc: dri-devel@lists.freedesktop.org, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, robh@kernel.org, conor+dt@kernel.org, Frank.Li@kernel.org, lee@kernel.org In-Reply-To: <20261204-bl-aw99703-upstr-v3-2-b98b78720ac2@kemnade.info> References: <20261204-bl-aw99703-upstr-v3-0-b98b78720ac2@kemnade.info> <20261204-bl-aw99703-upstr-v3-2-b98b78720ac2@kemnade.info> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 22:05:09 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] backlight: aw99703: active backlight stuck on when enable-gpios is omitted - [Medium] backlight: aw99703: bad GPIO rollback and missing delay in aw99703_powerdown() - [Medium] backlight: aw99703_set_brightness() does not roll back power-up on I2C error - [Medium] backlight: aw99703: aw99703_disable() skips regulator_disable() on GPIO error - [Low] backlight: aw99703: dead code, stale comment, unused clientdata, and typo -- commit a7edb5550dd3db5f8028fc516fa870bc9433a82c Author: Andreas Kemnade video: backlight: Add Awinic AW99703 This commit adds a backlight driver for the Awinic AW99703 LED driver supporting brightness control over I2C. > diff --git a/drivers/video/backlight/aw99703.c b/drivers/video/backlight/= aw99703.c > new file mode 100644 > index 0000000000000..cc6715b246839 > --- /dev/null > +++ b/drivers/video/backlight/aw99703.c > @@ -0,0 +1,467 @@ [ ... ] > +#define AW99703_REG_TURNCFG 0x09 [ ... ] > +/* TURNCFG:0x09 */ > +#define AW99703_TURNCFG_ON_TIM_MASK GENMASK(7, 4) > +#define AW99703_TURNCFG_OFF_TIM_MASK GENMASK(3, 0) [Severity: Low] This isn't a bug, but AW99703_REG_TURNCFG, AW99703_TURNCFG_ON_TIM_MASK, and AW99703_TURNCFG_OFF_TIM_MASK are defined without being used anywhere. aw99703_backlight_init() also calls seven single-use wrappers that do separate regmap_update_bits() cycles on AW99703_REG_BSTCTR1, AW99703_REG_LEDCUR, and AW99703_REG_MODE; combining fields per register would avoid the extra I2C traffic and boilerplate. Lastly, the "/* auto freq high/low */" comment above channel_mask_vals[] looks stale, i2c_set_clientdata() in aw99703_probe() is never read back, and the Kconfig help text spells the vendor name "Awininc" instead of "Awinic". [ ... ] > +static int aw99703_powerdown(struct aw99703_data *drvdata) > +{ > + int ret; > + > + ret =3D gpiod_set_value_cansleep(drvdata->hwen_gpio, 0); > + if (ret < 0) > + return ret; > + > + ret =3D regulator_disable(drvdata->vin); > + if (ret < 0) { > + gpiod_set_value_cansleep(drvdata->hwen_gpio, 1); > + return ret; > + } > + > + return 0; > +} [Severity: Medium] Can this rollback leave the chip unready for I2C when regulator_disable() fails? Re-asserting hwen_gpio after pulling it low omits the usleep_range(250, 1000) wake-up delay used in aw99703_powerup() and ignores any error from gpiod_set_value_cansleep(). Because aw99703_set_brightness() clears drvdata->initialized but leaves drvdata->enable true on error, the next non-zero brightness update skips aw99703_powerup() and runs aw99703_backlight_init() immediately before the chip exits reset (or while hwen_gpio stays low if rollback failed). When called from aw99703_disable() during driver removal, this rollback also re-asserts hwen_gpio high right before teardown. [ ... ] > +static int aw99703_set_brightness(struct aw99703_data *drvdata, int brt_= val) > +{ > + int ret; > + > + if (brt_val > 0) { > + if (!drvdata->enable) { > + ret =3D aw99703_powerup(drvdata); > + if (ret < 0) > + return ret; > + > + drvdata->enable =3D true; > + } > + > + if (!drvdata->initialized) { > + ret =3D aw99703_backlight_init(drvdata); > + if (ret < 0) > + return ret; > + > + drvdata->initialized =3D true; > + } > + > + ret =3D regmap_write(drvdata->regmap, > + AW99703_REG_LEDLSB, > + brt_val & 0x07); > + if (ret < 0) > + return ret; > + > + ret =3D regmap_write(drvdata->regmap, > + AW99703_REG_LEDMSB, > + (brt_val >> 3) & 0xff); > + if (ret < 0) > + return ret; > + > + ret =3D aw99703_set_work_mode(drvdata, AW99703_MODE_WORKMODE_BACKLIGHT= ); > + if (ret < 0) > + return ret; [Severity: Medium] Should an I2C failure after a fresh aw99703_powerup() roll back vin and hwen_gpio? When userspace transitions bl_power from BACKLIGHT_POWER_OFF to BACKLIGHT_POWER_ON with a non-zero brightness and an I2C write fails here, bl_power_store() reverts bd->props.power back to BACKLIGHT_POWER_OFF. Subsequent BACKLIGHT_POWER_OFF writes then become no-ops in the backlight core while vin stays enabled and hwen_gpio stays high. Rolling back with aw99703_powerdown() and clearing drvdata->enable and drvdata->initialized on error when powering up from off would keep hardware and core in sync. > + } else { > + if (drvdata->initialized) { > + ret =3D aw99703_set_work_mode(drvdata, AW99703_MODE_WORKMODE_STANDBY); > + if (ret < 0) > + return ret; > + } > + > + if (drvdata->enable) { > + /* > + * do not report error, the backlight is off with a bit > + * more power consumption, turning it back on together > + * with an error is probably even worse. > + * Do not assume tha backlight is initialized after > + * successful or unsuccesful call to powerdown. > + */ > + drvdata->initialized =3D false; > + ret =3D aw99703_powerdown(drvdata); > + if (ret < 0) > + return 0; > + } > + drvdata->enable =3D false; > + } [Severity: Medium] Can an already-lit backlight stay stuck on when enable-gpios is omitted? enable-gpios is optional, and aw99703_probe() does not reset, standby, or read back chip state, leaving drvdata->enable and drvdata->initialized false. If the bootloader left the AW99703 active on an always-on or boot-enabled vin supply, writing 0 to brightness, blanking, or suspending hits these guards and returns 0 as a no-op while the backlight remains physically lit. aw99703_disable() has the same drvdata->enable guard, so unbinding the driver also leaves the chip running until a non-zero brightness has been written first. [ ... ] > +static void aw99703_disable(void *d) > +{ > + struct aw99703_data *drvdata =3D d; > + > + if (drvdata->enable) { > + aw99703_set_work_mode(drvdata, AW99703_MODE_WORKMODE_STANDBY); > + aw99703_powerdown(drvdata); > + } > +} [Severity: Medium] Does aw99703_disable() leak the vin regulator enable count if lowering hwen_gpio fails during unbind? If gpiod_set_value_cansleep(drvdata->hwen_gpio, 0) returns an error (for example, -ENODEV if the GPIO chip was already removed or a bus error on a GPIO expander), aw99703_powerdown() returns early without calling regulator_disable(drvdata->vin). devm_regulator_release() then runs regulator_put(drvdata->vin) -> _regulator_put(), which triggers WARN_ON(regulator->enable_count) and destroys the consumer handle without decrementing rdev->use_count, permanently leaking the enable count on vin. During teardown, aw99703_disable() should still call regulator_disable(drvdata->vin) even if lowering hwen_gpio fails, and avoid re-asserting hwen_gpio if regulator_disable() fails. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-bl-aw99703= -upstr-v3-0-b98b78720ac2@kemnade.info?part=3D2