Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "YİĞİTCAN KAVAKLI" <kavakliyigitcan@gmail.com>
Cc: lee@kernel.org, linux-leds@vger.kernel.org,
	dmitry.torokhov@gmail.com, conor+dt@kernel.org,
	dri-devel@lists.freedesktop.org, linux-input@vger.kernel.org,
	robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH RFC 02/10] backlight: add Kinetic KTD3136 driver
Date: Fri, 11 Sep 2026 08:59:18 +0000	[thread overview]
Message-ID: <20260911085919.24FB01F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260911-ginkgo-submission-final-v1-2-0e68e63a18d4@gmail.com>

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] The 'vin' regulator is enabled during probe but never disabled on error paths or during module removal.
- [High] Missing `i2c_set_clientdata()` in probe causes `ktd3136_remove()` to silently skip hardware power-off.
- [Medium] Missing lock acquisition in `ktd3136_remove` causes a data race with concurrent backlight sysfs updates.
- [Medium] State mismatch leaves backlight physically ON when initial brightness is 0.
- [Low] Unnecessary and unused `select REGMAP_I2C` in Kconfig.
--

commit 15d6d172969378ae4661195e2320fcd1b4ed08c1
Author: YİĞİTCAN KAVAKLI <kavakliyigitcan@gmail.com>

backlight: add Kinetic KTD3136 driver

This commit implements a generic Linux backlight driver for the Kinetic
Technologies KTD3136 36V, 6-channel LED driver. It uses the standard
backlight class interface over I2C.

> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index dbf4ca23a9b6d..010e2ae3fa8cb 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
[ ... ]
> +config BACKLIGHT_KTD3136
> +	tristate "Backlight Driver for Kinetic KTD3136"
> +	depends on I2C
> +	select REGMAP_I2C

[Severity: Low]
Does this driver actually use the regmap API? Looking at the code, it appears
to exclusively use raw I2C SMBus operations (e.g., i2c_smbus_read_byte_data).
Could this select REGMAP_I2C be safely removed to avoid forcing an unnecessary
dependency?

> +	help
> +	  Say Y to enable the backlight driver for the Kinetic Technologies
[ ... ]
> diff --git a/drivers/video/backlight/ktd3136-backlight.c b/drivers/video/backlight/ktd3136-backlight.c
> new file mode 100644
> index 0000000000000..a8ebe3b23c99f
> --- /dev/null
> +++ b/drivers/video/backlight/ktd3136-backlight.c
[ ... ]
> +static int ktd3136_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	struct backlight_properties props;
> +	struct ktd3136_data *chip;
> +	int ret, val;
> +	u32 def_brightness = KTD3136_DEFAULT_BRIGHTNESS;
> +	u32 max_brightness = KTD3136_DEFAULT_MAX_BRIGHTNESS;
> +
> +	chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
> +	if (!chip)
> +		return -ENOMEM;
> +
> +	chip->client = client;
> +	mutex_init(&chip->lock);

[Severity: High]
Is a call to i2c_set_clientdata(client, chip) missing here? Later in
ktd3136_remove(), the code calls i2c_get_clientdata(client), which will
return NULL if it wasn't set, silently bypassing the hardware power-off.

> +
> +	chip->vin = devm_regulator_get_optional(dev, "vin");
> +	if (IS_ERR(chip->vin)) {
> +		ret = PTR_ERR(chip->vin);
> +		if (ret != -ENODEV)
> +			return dev_err_probe(dev, ret, "Failed to get vin regulator\n");
> +		chip->vin = NULL;
> +	}
> +
> +	if (chip->vin) {
> +		ret = regulator_enable(chip->vin);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "Failed to enable vin regulator\n");
> +	}
> +
> +	chip->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
> +	if (IS_ERR(chip->enable_gpio))
> +		return dev_err_probe(dev, PTR_ERR(chip->enable_gpio),
> +				     "Failed to get enable GPIO\n");

[Severity: High]
If devm_gpiod_get_optional() fails here, the function returns immediately.
Does this leave the vin regulator enabled since there is no devm action or
manual regulator_disable(chip->vin) on this error path?

[Severity: Medium]
The enable GPIO is asserted HIGH here (powering the hardware), but
chip->is_enabled remains false. If the default brightness evaluates to 0,
backlight_update_status() calls ktd3136_power_off(). Because chip->is_enabled
is false, ktd3136_power_off() returns early without de-asserting the GPIO.
Could this state mismatch leave the backlight physically ON when the initial
brightness is 0?

> +
> +	if (chip->enable_gpio)
> +		usleep_range(2000, 3000);
[ ... ]
> +static void ktd3136_remove(struct i2c_client *client)
> +{
> +	struct ktd3136_data *chip = i2c_get_clientdata(client);
> +
> +	if (chip)
> +		ktd3136_power_off(chip);

[Severity: Medium]
Does ktd3136_power_off(chip) need to be protected by mutex_lock(&chip->lock)
here? Since the backlight device is registered with
devm_backlight_device_register, its sysfs interface might still be active
during .remove(). Could this cause a data race with concurrent sysfs writes
to the brightness attribute?

[Severity: High]
Does the vin regulator need to be disabled here? It was enabled during probe
but there doesn't seem to be a corresponding regulator_disable() call when the
driver is unbound.

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-ginkgo-submission-final-v1-0-0e68e63a18d4@gmail.com?part=2

  reply	other threads:[~2026-09-11  8:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  8:50 [PATCH RFC 00/10] arm64: qcom: sm6125-ginkgo: display, backlight, and touch support YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  8:50 ` [PATCH RFC 01/10] dt-bindings: backlight: add Kinetic KTD3136 YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  8:56   ` sashiko-bot
2026-09-11  8:50 ` [PATCH RFC 02/10] backlight: add Kinetic KTD3136 driver YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  8:59   ` sashiko-bot [this message]
2026-09-11  8:51 ` [PATCH RFC 03/10] dt-bindings: display: panel: novatek,nt36672a: add Tianma FHD+ video mode variant YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  8:53   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 04/10] drm/panel: novatek-nt36672a: add Tianma FHD+ video mode panel YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  9:09   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 05/10] dt-bindings: input: touchscreen: add Novatek NT36672A SPI touchscreen YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  8:58   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 06/10] Input: novatek-nt36672a-spi: add driver for " YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  9:02   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 07/10] drm/msm/dpu: describe SM6125 programmable-fetch delayed-start quirk YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  9:01   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 08/10] drm/msm/dsi: make command and video mode configuration mutually exclusive YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  9:00   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 09/10] drm/msm/dsi: separate host link enable from video stream enable YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  9:04   ` sashiko-bot
2026-09-11  8:51 ` [PATCH RFC 10/10] arm64: dts: qcom: sm6125-xiaomi-ginkgo: enable display, backlight and touchscreen YİĞİTCAN KAVAKLI via B4 Relay
2026-09-11  9:04   ` 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=20260911085919.24FB01F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kavakliyigitcan@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-leds@vger.kernel.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