From: sashiko-bot@kernel.org
To: "Hikmah Gumelar" <hikmahgumelar@gmail.com>
Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v3 3/7] media: i2c: add s5k5e8 image sensor driver
Date: Mon, 23 Nov 2026 15:53:12 +0000 [thread overview]
Message-ID: <sashiko-outbox-229619@kernel.org> (raw)
In-Reply-To: <20261123152722.168879-4-hikmahgumelar@gmail.com>
Thank you for your contribution! Sashiko AI review found 8 potential
issues to consider:
- [Medium] media: i2c: s5k5e8: broken !PM check and unchecked range
update in s5k5e8_set_ctrl()
- [Medium] media: i2c: s5k5e8: skipped startup delay in
s5k5e8_power_on() without reset_gpio
- [Medium] media: i2c: s5k5e8: unset colorimetry and missing stream
check in s5k5e8_set_format()
- [Low] media: i2c: s5k5e8: explicit clk_set_rate() call in
s5k5e8_probe()
- [Low] media: i2c: s5k5e8: open-coded CCI I2C helpers instead of
v4l2-cci framework
- [Low] media: i2c: s5k5e8: legacy s_stream and manual mutex/streaming
state
- [Low] media: i2c: s5k5e8: redundant Kconfig selects, unsorted entries,
no MAINTAINERS
- [Low] media: i2c: s5k5e8: unused definitions, indentation issues, and
redundant Kconfig
--
commit 282d70890b56a8ec58d98af6f85d1c752c59afcd
Author: Hikmah Gumelar <hikmahgumelar@gmail.com>
media: i2c: add s5k5e8 image sensor driver
This commit adds a V4L2 subdevice driver for the Samsung S5K5E8 5-megapixel
MIPI CSI-2 CMOS image sensor.
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 9e42b380e3f20..fb6bb91f897cb 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -881,6 +881,19 @@ config VIDEO_S5K3M5
> To compile this driver as a module, choose M here: the
> module will be called s5k3m5.
>
> +config VIDEO_S5K5E8
> + tristate "Samsung S5K5E8 sensor support"
> + depends on I2C && VIDEO_DEV
> + select MEDIA_CONTROLLER
> + select VIDEO_V4L2_SUBDEV_API
> + select V4L2_FWNODE
> + help
> + This is a Video4Linux2 sensor-level driver for the Samsung
> + S5K5E8 5-megapixel MIPI CSI-2 CMOS image sensor.
> +
> + To compile this driver as a module, choose M here: the
> + module will be called s5k3m5.
> +
> config VIDEO_S5K5BAF
> tristate "Samsung S5K5BAF sensor support"
> help
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index 604b19dbc7b75..7be5217889916 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -137,6 +137,7 @@ obj-$(CONFIG_VIDEO_RDACM21) += rdacm21.o
> obj-$(CONFIG_VIDEO_RJ54N1) += rj54n1cb0c.o
> obj-$(CONFIG_VIDEO_S5C73M3) += s5c73m3/
> obj-$(CONFIG_VIDEO_S5K3M5) += s5k3m5.o
> +obj-$(CONFIG_VIDEO_S5K5E8) += s5k5e8.o
> obj-$(CONFIG_VIDEO_S5K5BAF) += s5k5baf.o
> obj-$(CONFIG_VIDEO_S5K6A3) += s5k6a3.o
> obj-$(CONFIG_VIDEO_S5KJN1) += s5kjn1.o
[Severity: Low]
This isn't a bug, but VIDEO_S5K5E8 is inside the if VIDEO_DEV and
if VIDEO_CAMERA_SENSOR blocks in drivers/media/i2c/Kconfig, which already
depend on I2C and select MEDIA_CONTROLLER, VIDEO_V4L2_SUBDEV_API and
V4L2_FWNODE. Also, VIDEO_S5K5E8 and s5k5e8.o are placed before
VIDEO_S5K5BAF / s5k5baf.o instead of in alphabetical order, and no
MAINTAINERS entry is added for the new driver.
> diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c
> new file mode 100644
> index 0000000000000..b4f0783593e93
> --- /dev/null
> +++ b/drivers/media/i2c/s5k5e8.c
> @@ -0,0 +1,555 @@
[ ... ]
> +#define S5K5E8_CHIP_ID_REG 0x0000
> +#define S5K5E8_CHIP_ID 0x5e80
> +#define S5K5E8_REG_MODE_SELECT 0x0100
> +#define S5K5E8_MODE_STANDBY 0x00
> +#define S5K5E8_MODE_STREAMING 0x01
> +#define S5K5E8_REG_VTS 0x0340
> +#define S5K5E8_REG_EXPOSURE 0x0202
> +#define S5K5E8_REG_ANALOG_GAIN 0x0204
> +#define S5K5E8_REG_TEST_PATTERN 0x0600
> +#define S5K5E8_XVCLK_FREQ 24000000
> +#define S5K5E8_LINK_FREQ_418MHZ 418000000ULL
> +#define S5K5E8_PIXEL_RATE 167200000ULL
> +
> +struct s5k5e8_reg { u16 address;
> +u8 val;
> +};
> +struct s5k5e8_mode {
> + u32 width, height, hts_def, vts_def, vts_min, num_regs;
> + const struct s5k5e8_reg *regs;
> +};
[Severity: Low]
This isn't a bug, but there are a few unused definitions and indentation
issues in this driver:
- S5K5E8_MODE_STREAMING is unused because stream_on_regs[] hardcodes
{ 0x0100, 0x01 }.
- vts_def and vts_min in struct s5k5e8_mode are never read because
s5k5e8_init_controls() hardcodes 24 for V4L2_CID_VBLANK, and pixel_rate
and vblank in struct s5k5e8 are assigned in s5k5e8_init_controls() but
never read.
- struct s5k5e8_reg and the break statements in s5k5e8_set_ctrl() have
broken indentation.
[ ... ]
> +static int s5k5e8_read_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 *val)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
> + struct i2c_msg msgs[2];
> + u8 addr_buf[2], data_buf[4] = { 0 };
> + int ret;
> +
> + put_unaligned_be16(reg, addr_buf);
> + msgs[0].addr = client->addr;
> + msgs[0].flags = 0;
> + msgs[0].len = 2;
> + msgs[0].buf = addr_buf;
> + msgs[1].addr = client->addr;
> + msgs[1].flags = I2C_M_RD;
> + msgs[1].len = len;
> + msgs[1].buf = &data_buf[4 - len];
> + ret = i2c_transfer(client->adapter, msgs, 2);
> + if (ret != 2)
> + return ret < 0 ? ret : -EIO;
> + *val = get_unaligned_be32(data_buf);
> + return 0;
> +}
> +
> +static int s5k5e8_write_reg(struct s5k5e8 *s5k5e8, u16 reg, u32 len, u32 val)
> +{
> + struct i2c_client *client = v4l2_get_subdevdata(&s5k5e8->sd);
> + u8 buf[6];
> + int ret;
> +
> + put_unaligned_be16(reg, buf);
> + put_unaligned_be32(val << (8 * (4 - len)), buf + 2);
> + ret = i2c_master_send(client, buf, len + 2);
> + return ret == len + 2 ? 0 : (ret < 0 ? ret : -EIO);
> +}
> +
> +static int s5k5e8_write_regs(struct s5k5e8 *s5k5e8, const struct s5k5e8_reg *regs, u32 len)
> +{
> + u32 i;
> + int ret;
> +
> + for (i = 0; i < len; i++) {
> + ret = s5k5e8_write_reg(s5k5e8, regs[i].address, 1, regs[i].val);
> + if (ret)
> + return ret;
> + }
> + return 0;
> +}
[Severity: Low]
Could this use the v4l2-cci framework (select V4L2_CCI_I2C in Kconfig,
devm_cci_regmap_init_i2c(), cci_read(), cci_write() and
cci_multi_reg_write()) instead of open-coding 16-bit big-endian I2C register
accessors? Similarly, s5k5e8_probe() could use v4l2_link_freq_to_bitmap()
to validate link-frequencies.
> +
> +static int s5k5e8_power_on(struct device *dev)
> +{
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(dev_get_drvdata(dev));
> + int ret = regulator_bulk_enable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);
> +
> + if (ret)
> + return ret;
> + ret = clk_prepare_enable(s5k5e8->xvclk);
> + if (ret) {
> + regulator_bulk_disable(S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);
> + return ret;
> + }
> + if (s5k5e8->reset_gpio) {
> + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 1);
> + usleep_range(1000, 2000);
> + gpiod_set_value_cansleep(s5k5e8->reset_gpio, 0);
> + usleep_range(3000, 5000);
> + }
> + return 0;
> +}
[Severity: Medium]
Does s5k5e8_power_on() skip the 3-5 ms post-power-on stabilization delay
when the optional reset_gpio is NULL? On boards without reset-gpios,
s5k5e8_power_on() returns immediately after clk_prepare_enable() and
s5k5e8_probe() issues an I2C read of S5K5E8_CHIP_ID_REG with no startup
delay (and gpiod_set_value_cansleep() already accepts a NULL descriptor).
[ ... ]
> +static int s5k5e8_set_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct s5k5e8 *s5k5e8 = container_of(ctrl->handler, struct s5k5e8, ctrl_handler);
> + int ret = 0;
> +
> + if (ctrl->id == V4L2_CID_VBLANK) {
> + s64 exp_max = s5k5e8->cur_mode->height + ctrl->val - 4;
> + s64 exp_def = min_t(s64, 1960, exp_max);
> +
> + __v4l2_ctrl_modify_range(s5k5e8->exposure, 4, exp_max, 1, exp_def);
> + }
> +
> + if (pm_runtime_get_if_in_use(s5k5e8->dev) <= 0)
> + return 0;
[Severity: Medium]
Does checking pm_runtime_get_if_in_use(s5k5e8->dev) <= 0 skip all control
register writes when CONFIG_PM is disabled?
When CONFIG_PM is disabled (or runtime PM is disabled on the device),
pm_runtime_get_if_in_use() returns -EINVAL, so s5k5e8_set_ctrl() returns 0
without writing S5K5E8_REG_ANALOG_GAIN, S5K5E8_REG_EXPOSURE,
S5K5E8_REG_VTS or S5K5E8_REG_TEST_PATTERN even during stream start via
__v4l2_ctrl_handler_setup(). Using pm_runtime_get_if_active() (or checking
pm_runtime_get_if_in_use() == 0) allows writes to proceed when runtime PM is
disabled. Also, the return value of __v4l2_ctrl_modify_range() above is
ignored.
[ ... ]
> +static void s5k5e8_update_pad_format(const struct s5k5e8_mode *mode,
> + struct v4l2_mbus_framefmt *fmt)
> +{
> + fmt->width = mode->width;
> + fmt->height = mode->height;
> + fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
> + fmt->field = V4L2_FIELD_NONE;
> + fmt->colorspace = V4L2_COLORSPACE_SRGB;
> +}
> +
> +static int s5k5e8_set_format(struct v4l2_subdev *sd,
> + const struct v4l2_subdev_client_info *ci,
> + struct v4l2_subdev_state *sd_state,
> + struct v4l2_subdev_format *fmt)
> +{
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
> +
> + s5k5e8_update_pad_format(&supported_modes[0], &fmt->format);
> + *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
> + if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
> + s5k5e8->cur_mode = &supported_modes[0];
> +
> + return 0;
> +}
[Severity: Medium]
Does s5k5e8_update_pad_format() leave fmt->ycbcr_enc, fmt->quantization and
fmt->xfer_func uninitialized? In VIDIOC_SUBDEV_S_FMT, any arbitrary values
passed by userspace in those fields are copied directly into the subdev pad
state. Also, when fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE,
s5k5e8_set_format() does not check if the sensor is streaming and return
-EBUSY.
[ ... ]
> +static int s5k5e8_set_stream(struct v4l2_subdev *sd, int enable)
> +{
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
> + int ret = 0;
> +
> + mutex_lock(&s5k5e8->mutex);
> + if (s5k5e8->streaming == enable) {
> + mutex_unlock(&s5k5e8->mutex);
> + return 0;
> + }
[ ... ]
> +static const struct v4l2_subdev_video_ops s5k5e8_video_ops = { .s_stream = s5k5e8_set_stream };
[Severity: Low]
Could this driver implement .enable_streams and .disable_streams in
s5k5e8_pad_ops with .s_stream = v4l2_subdev_s_stream_helper instead of
open-coding .s_stream and s5k5e8->streaming? With active subdev state
management, s5k5e8->sd.state_lock can also be aliased directly to
s5k5e8->ctrl_handler.lock, dropping the separate s5k5e8->mutex.
[ ... ]
> + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
> + if (IS_ERR(s5k5e8->xvclk))
> + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "failed to get xvclk\n");
> +
> + ret = clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to set xvclk rate\n");
> +
> + if (clk_get_rate(s5k5e8->xvclk) != S5K5E8_XVCLK_FREQ)
> + return dev_err_probe(dev, -EINVAL, "unexpected xvclk rate\n");
[Severity: Low]
Should clk_set_rate() be dropped here? devm_v4l2_sensor_clk_get() already
handles setting the clock rate on non-OF platforms while leaving OF clock
rate assignment to firmware (assigned-clock-rates), so camera sensor drivers
should only check clk_get_rate().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123152722.168879-1-hikmahgumelar@gmail.com?part=3
next prev parent reply other threads:[~2026-11-23 15:53 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 11:07 [PATCH 0/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 1/6] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 2/6] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 15:11 ` Rob Herring (Arm)
2026-11-23 11:08 ` [PATCH 3/6] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 4/6] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 5/6] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 11:08 ` [PATCH 6/6] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 0/7] " Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 12:42 ` sashiko-bot
2026-11-23 12:35 ` [PATCH v2 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 12:43 ` sashiko-bot
2026-11-23 15:11 ` Rob Herring (Arm)
2026-11-23 12:35 ` [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 12:52 ` sashiko-bot
2026-11-23 13:56 ` Uwe Kleine-König
2026-11-23 14:14 ` Hikmah Gumelar
2026-11-23 12:35 ` [PATCH v2 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 12:45 ` sashiko-bot
2026-11-23 15:11 ` Rob Herring (Arm)
2026-11-23 12:35 ` [PATCH v2 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 12:57 ` sashiko-bot
2026-11-23 12:35 ` [PATCH v2 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-23 12:49 ` sashiko-bot
2026-11-23 12:35 ` [PATCH v2 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 12:52 ` sashiko-bot
2026-11-23 15:27 ` [PATCH v3 0/7] " Hikmah Gumelar
2026-11-23 15:27 ` [PATCH v3 1/7] clk: qcom: gcc-msm8953: fix csi_phytimer_clk_src 100MHz parent Hikmah Gumelar
2026-11-23 19:18 ` Abel Vesa
2026-11-23 15:27 ` [PATCH v3 2/7] media: dt-bindings: media: i2c: add Samsung S5K5E8 Hikmah Gumelar
2026-11-23 17:25 ` Konrad Dybcio
2026-11-23 15:27 ` [PATCH v3 3/7] media: i2c: add s5k5e8 image sensor driver Hikmah Gumelar
2026-11-23 15:53 ` sashiko-bot [this message]
2026-11-23 15:27 ` [PATCH v3 4/7] media: dt-bindings: media: i2c: add OmniVision OV12A10 Hikmah Gumelar
2026-11-23 15:27 ` [PATCH v3 5/7] media: i2c: add ov12a10 image sensor driver Hikmah Gumelar
2026-11-23 15:50 ` sashiko-bot
2026-11-23 15:27 ` [PATCH v3 6/7] arm64: dts: qcom: msm8953: add CAMSS node and MCLK pinctrl states Hikmah Gumelar
2026-11-23 15:27 ` [PATCH v3 7/7] arm64: dts: qcom: msm8953-xiaomi-tissot: enable front and rear cameras Hikmah Gumelar
2026-11-23 15:46 ` 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=sashiko-outbox-229619@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hikmahgumelar@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=media-ci@linuxtv.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 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.