Linux Input/HID development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Hefei <3066883572@qq.com>, dri-devel@lists.freedesktop.org
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3 6/6] backlight: add VIEWE I2C backlight driver
Date: Wed, 25 Nov 2026 02:22:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-232405@kernel.org> (raw)
In-Reply-To: <tencent_5185BF35A815E3151FD856BCDF3E84F14F08@qq.com>

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] backlight: viewe_bl_i2c: missing DT property parsing and
  initial HW sync in viewe_bl_probe()
- [Low] backlight: viewe_bl_i2c: positional initializer and mismatched
  ID in viewe_bl_id
- [Low] backlight: viewe_bl_i2c: open-coded byte write in
  viewe_bl_update_status()
- [Low] backlight: viewe_bl_i2c: hardcoded device name in
  viewe_bl_probe() breaks multi-instance probe
- [Low] backlight: viewe_bl_i2c: empty commit message body lacking
  hardware and driver description
--

commit 4e7ef9a994e068f00aa52e87d93462c70437631d
Author: Hefei <3066883572@qq.com>

> backlight: add VIEWE I2C backlight driver
> 
> Signed-off-by: Hefei <3066883572@qq.com>

[Severity: Low]
The commit message has an empty body.  Could you add a description of the
VIEWE 7KF82 I2C backlight MCU hardware and explain why a dedicated driver
is needed?

> diff --git a/drivers/video/backlight/viewe_bl_i2c.c b/drivers/video/backlight/viewe_bl_i2c.c
> new file mode 100644
> index 0000000000000..53dcf0834dcb2
> --- /dev/null
> +++ b/drivers/video/backlight/viewe_bl_i2c.c
> @@ -0,0 +1,79 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2026 VIEWE
> + *
> + * I2C backlight for VIEWE 7KF82 DSI modules (MCU @0x45, register 0x86, 0..255).
> + */
> +
> +#include <linux/backlight.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +
> +#define VIEWE_BL_REG		0x86
> +#define VIEWE_BL_MAX		255
> +#define VIEWE_BL_DEFAULT	200
> +
> +static int viewe_bl_update_status(struct backlight_device *bd)
> +{
> +	struct i2c_client *client = bl_get_data(bd);
> +	u8 buf[2] = { VIEWE_BL_REG, (u8)backlight_get_brightness(bd) };
> +	struct i2c_msg msg = {
> +		.addr = client->addr,
> +		.flags = 0,
> +		.len = sizeof(buf),
> +		.buf = buf,
> +	};
> +	int ret;
> +
> +	ret = i2c_transfer(client->adapter, &msg, 1);
> +	return ret == 1 ? 0 : (ret < 0 ? ret : -EIO);
> +}

[Severity: Low]
Could viewe_bl_update_status() use i2c_smbus_write_byte_data(client,
VIEWE_BL_REG, backlight_get_brightness(bd)) instead of open-coding a raw
i2c_transfer()?  Using the SMBus helper preserves client->flags and works
on SMBus-only adapters that do not implement raw I2C master_xfer.

> +
> +static const struct backlight_ops viewe_bl_ops = {
> +	.update_status = viewe_bl_update_status,
> +};
> +
> +static int viewe_bl_probe(struct i2c_client *client)
> +{
> +	struct backlight_properties props = {
> +		.type = BACKLIGHT_RAW,
> +		.brightness = VIEWE_BL_DEFAULT,
> +		.max_brightness = VIEWE_BL_MAX,
> +	};
> +	struct backlight_device *bd;
> +
> +	bd = devm_backlight_device_register(&client->dev, "viewe_bl",
> +					   &client->dev, client, &viewe_bl_ops,
> +					   &props);
> +	if (IS_ERR(bd))
> +		return PTR_ERR(bd);
> +
> +	i2c_set_clientdata(client, bd);

[Severity: Low]
Does passing the constant string "viewe_bl" to
devm_backlight_device_register() cause probing a second panel instance to
fail with -EEXIST when creating /sys/class/backlight/viewe_bl?  Passing
dev_name(&client->dev) avoids the name collision, and the
i2c_set_clientdata() call can be dropped since client data is never read.

> +	return 0;
> +}

[Severity: Medium]
Does viewe_bl_probe() ignore the default-brightness property from Device
Tree and leave the hardware brightness uninitialized at probe?

devm_backlight_device_register() neither parses default-brightness (or
max-brightness) from device properties nor calls backlight_update_status().
Any default-brightness configured per the viewe,7kf82-backlight binding is
silently ignored in favor of VIEWE_BL_DEFAULT, sysfs brightness is out of
sync with register 0x86 until userspace writes to it, and probe succeeds
even if the MCU at 0x45 does not respond.  In addition, viewe_bl_ops omits
.options = BL_CORE_SUSPENDRESUME, so the backlight is not blanked and
restored across system suspend and resume.

> +
> +static const struct of_device_id viewe_bl_of_match[] = {
> +	{ .compatible = "viewe,7kf82-backlight" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, viewe_bl_of_match);
> +
> +static const struct i2c_device_id viewe_bl_id[] = {
> +	{ "viewe_bl", 0 },
> +	{ }
> +};

[Severity: Low]
New struct i2c_device_id entries should use named initializers (such as
{ .name = "7kf82-backlight" }), and the ID string should match the
vendor-stripped compatible name ("7kf82-backlight" rather than "viewe_bl")
so fallback I2C ID matching works with the OF compatible string.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_A3BF23A8B6E3691F0D567ADF8B84194F4408@qq.com?part=6

      reply	other threads:[~2026-11-25  2:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261125021127.1430-1-3066883572@qq.com>
2026-11-25  2:11 ` [PATCH v3 1/6] dt-bindings: display: add VIEWE JD9365TX panel binding Hefei
2026-11-25  2:18   ` sashiko-bot
2026-11-25  2:11 ` [PATCH v3 2/6] dt-bindings: input: add Jadard JD9365TX touchscreen binding Hefei
2026-11-25  2:22   ` sashiko-bot
2026-11-25  2:11 ` [PATCH v3 3/6] dt-bindings: backlight: add VIEWE I2C backlight binding Hefei
2026-11-25  2:19   ` sashiko-bot
2026-11-25  2:11 ` [PATCH v3 4/6] drm/panel: add VIEWE JD9365TX 7 inch DSI panel Hefei
2026-11-25  2:26   ` sashiko-bot
2026-11-25  2:11 ` [PATCH v3 5/6] Input: add Jadard JD9365TX in-cell touchscreen driver Hefei
2026-11-25  2:24   ` sashiko-bot
2026-11-25  2:32   ` Dmitry Torokhov
2026-11-25  2:11 ` [PATCH v3 6/6] backlight: add VIEWE I2C backlight driver Hefei
2026-11-25  2:22   ` 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=sashiko-outbox-232405@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=3066883572@qq.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-input@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