From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: Hikmah Gumelar <hikmahgumelar@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Abel Vesa <abelvesa@kernel.org>, Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-clk@vger.kernel.org
Subject: Re: [PATCH v2 3/7] media: i2c: add s5k5e8 image sensor driver
Date: Mon, 23 Nov 2026 14:56:04 +0100 [thread overview]
Message-ID: <awRDMjtMC74v5zQq@monoceros> (raw)
In-Reply-To: <20261123123546.152162-4-hikmahgumelar@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 8825 bytes --]
Hello,
On Mon, Nov 23, 2026 at 07:35:42PM +0700, Hikmah Gumelar wrote:
> diff --git a/drivers/media/i2c/s5k5e8.c b/drivers/media/i2c/s5k5e8.c
> new file mode 100644
> index 000000000000..80931e5a1c6b
> --- /dev/null
> +++ b/drivers/media/i2c/s5k5e8.c
> @@ -0,0 +1,500 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/clk.h>
> +#include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/i2c.h>
> +#include <linux/mod_devicetable.h>
<linux/i2c.h> already provides of_device_id, so please drop
<linux/mod_devicetable.h> (which adds a lot of unneeded dependencies).
> +#include <linux/module.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/unaligned.h>
> +#include <media/v4l2-ctrls.h>
> +#include <media/v4l2-device.h>
> +#include <media/v4l2-fwnode.h>
> +
> +#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;
> +};
> +
> +static const char * const s5k5e8_supply_names[] = { "avdd", "dvdd", "dovdd" };
> +#define S5K5E8_NUM_SUPPLIES ARRAY_SIZE(s5k5e8_supply_names)
> +
> +static const struct s5k5e8_reg s5k5e8_common_regs[] = {
> + { 0x0100, 0x00 }, { 0x3906, 0x7e }, { 0x3c01, 0x0f }, { 0x3c14, 0x00 },
> + { 0x3235, 0x08 }, { 0x3063, 0x2e }, { 0x307a, 0x10 }, { 0x307b, 0x0e },
> + { 0x3079, 0x20 }, { 0x3070, 0x05 }, { 0x3067, 0x06 }, { 0x3071, 0x62 },
> + { 0x3072, 0x16 }, { 0x3203, 0x43 }, { 0x3205, 0x43 }, { 0x320b, 0x42 },
> + { 0x3007, 0x00 }, { 0x3008, 0x14 }, { 0x3020, 0x58 }, { 0x300d, 0x34 },
> + { 0x300e, 0x17 }, { 0x3021, 0x02 }, { 0x3010, 0x59 }, { 0x3002, 0x01 },
> + { 0x3005, 0x01 }, { 0x3008, 0x04 }, { 0x300f, 0x70 }, { 0x3010, 0x69 },
> + { 0x3017, 0x10 }, { 0x3019, 0x19 }, { 0x300c, 0x62 }, { 0x3064, 0x10 },
> + { 0x3c08, 0x0e }, { 0x3c09, 0x10 }, { 0x3c31, 0x0d }, { 0x3c32, 0xac },
> +};
> +
> +static const struct s5k5e8_reg s5k5e8_2592x1944_regs[] = {
> + { 0x0100, 0x00 }, { 0x0136, 0x18 }, { 0x0137, 0x00 }, { 0x0305, 0x06 },
> + { 0x0306, 0x18 }, { 0x0307, 0xa8 }, { 0x0308, 0x34 }, { 0x0309, 0x42 },
> + { 0x3c1f, 0x00 }, { 0x3c17, 0x00 }, { 0x3c0b, 0x04 }, { 0x3c1c, 0x47 },
> + { 0x3c1d, 0x15 }, { 0x3c14, 0x04 }, { 0x3c16, 0x00 }, { 0x0820, 0x03 },
> + { 0x0821, 0x44 }, { 0x0114, 0x01 }, { 0x0344, 0x00 }, { 0x0345, 0x08 },
> + { 0x0346, 0x00 }, { 0x0347, 0x08 }, { 0x0348, 0x0a }, { 0x0349, 0x27 },
> + { 0x034a, 0x07 }, { 0x034b, 0x9f }, { 0x034c, 0x0a }, { 0x034d, 0x20 },
> + { 0x034e, 0x07 }, { 0x034f, 0x98 }, { 0x0900, 0x00 }, { 0x0901, 0x00 },
> + { 0x0381, 0x01 }, { 0x0383, 0x01 }, { 0x0385, 0x01 }, { 0x0387, 0x01 },
> + { 0x0340, 0x07 }, { 0x0341, 0xb0 }, { 0x0342, 0x0b }, { 0x0343, 0x28 },
> + { 0x0200, 0x00 }, { 0x0201, 0x00 }, { 0x0202, 0x03 }, { 0x0203, 0xde },
> + { 0x3303, 0x02 }, { 0x3400, 0x00 }, { 0x323b, 0x02 }, { 0x3301, 0x00 },
> + { 0x3321, 0x04 }, { 0x3306, 0x00 }, { 0x3307, 0x08 }, { 0x3308, 0x0a },
> + { 0x3309, 0x27 }, { 0x330a, 0x01 }, { 0x330b, 0x01 }, { 0x330e, 0x00 },
> + { 0x330f, 0x08 }, { 0x3310, 0x07 }, { 0x3311, 0x9f }, { 0x3312, 0x01 },
> + { 0x3313, 0x01 },
> +};
Is this a reverse engineered table of initial register values? A comment
would be awesome.
> +static const struct s5k5e8_mode supported_modes[] = {
> + {
> + .width = 2592, .height = 1944, .hts_def = 2856,
> + .vts_def = 1968, .vts_min = 1968,
> + .num_regs = ARRAY_SIZE(s5k5e8_2592x1944_regs),
> + .regs = s5k5e8_2592x1944_regs,
> + },
> +};
> +
> [...]
> +static int s5k5e8_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state,
> + struct v4l2_subdev_frame_size_enum *fse)
> +{
> + if (fse->index >= ARRAY_SIZE(supported_modes) ||
> + fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
> + return -EINVAL;
ARRAY_SIZE(supported_modes) is one. Does supported_modes really need to
be an array?
> + fse->min_width = fse->max_width = supported_modes[fse->index].width;
> + fse->min_height = fse->max_height = supported_modes[fse->index].height;
> + return 0;
> +}
> +
> [...]
> +static int s5k5e8_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct s5k5e8 *s5k5e8;
> + u32 val = 0;
> + unsigned int i;
> + int ret;
> +
> + s5k5e8 = devm_kzalloc(dev, sizeof(*s5k5e8), GFP_KERNEL);
> + if (!s5k5e8)
> + return -ENOMEM;
> + s5k5e8->dev = dev;
> + v4l2_i2c_subdev_init(&s5k5e8->sd, client, &s5k5e8_subdev_ops);
> + s5k5e8->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
> + if (IS_ERR(s5k5e8->xvclk))
> + return dev_err_probe(dev, PTR_ERR(s5k5e8->xvclk), "xvclk\n");
> + clk_set_rate(s5k5e8->xvclk, S5K5E8_XVCLK_FREQ);
> + s5k5e8->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(s5k5e8->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(s5k5e8->reset_gpio), "reset\n");
> + for (i = 0; i < S5K5E8_NUM_SUPPLIES; i++)
> + s5k5e8->supplies[i].supply = s5k5e8_supply_names[i];
> + ret = devm_regulator_bulk_get(dev, S5K5E8_NUM_SUPPLIES, s5k5e8->supplies);
> + if (ret)
> + return dev_err_probe(dev, ret, "regulators\n");
> + ret = s5k5e8_power_on(dev);
> + if (ret)
> + return ret;
> + ret = s5k5e8_read_reg(s5k5e8, S5K5E8_CHIP_ID_REG, 2, &val);
> + if (ret || val != S5K5E8_CHIP_ID) {
> + dev_err(dev, "failed to identify s5k5e8 (ret=%d, id=0x%x)\n", ret, val);
Use dev_err_probe() for error messages in the probe function.
> + ret = ret ? ret : -ENXIO;
> + goto err_power;
> + }
> + dev_info(dev, "identified Samsung S5K5E8 sensor (0x%04x)\n", val);
Degrade to dev_dbg() or drop. Once the driver is considered ok, messages
of this kind only clutter the kernel log with very little value and add
to the boot time.
> + mutex_init(&s5k5e8->mutex);
> + s5k5e8->cur_mode = &supported_modes[0];
> + ret = s5k5e8_init_controls(s5k5e8);
> + if (ret)
> + goto err_mutex;
> + s5k5e8->sd.internal_ops = &s5k5e8_internal_ops;
> + s5k5e8->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> + s5k5e8->sd.entity.ops = &s5k5e8_entity_ops;
> + s5k5e8->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> + s5k5e8->pad.flags = MEDIA_PAD_FL_SOURCE;
> + ret = media_entity_pads_init(&s5k5e8->sd.entity, 1, &s5k5e8->pad);
> + if (ret)
> + goto err_ctrl;
Use newlines to separate function call + its error handling from the
other code.
> + s5k5e8->sd.state_lock = &s5k5e8->mutex;
> + ret = v4l2_subdev_init_finalize(&s5k5e8->sd);
> + if (ret)
> + goto err_media;
> + ret = v4l2_async_register_subdev_sensor(&s5k5e8->sd);
> + if (ret)
> + goto err_media;
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> + pm_runtime_idle(dev);
> + return 0;
> +err_media: media_entity_cleanup(&s5k5e8->sd.entity);
> +err_ctrl: v4l2_ctrl_handler_free(s5k5e8->sd.ctrl_handler);
> +err_mutex: mutex_destroy(&s5k5e8->mutex);
> +err_power: s5k5e8_power_off(dev);
A label should be on its own line.
> + return ret;
> +}
> +
> +static void s5k5e8_remove(struct i2c_client *client)
> +{
> + struct v4l2_subdev *sd = i2c_get_clientdata(client);
> + struct s5k5e8 *s5k5e8 = to_s5k5e8(sd);
> +
> + v4l2_async_unregister_subdev(sd);
> + media_entity_cleanup(&sd->entity);
> + v4l2_ctrl_handler_free(sd->ctrl_handler);
> + mutex_destroy(&s5k5e8->mutex);
> + pm_runtime_disable(&client->dev);
> + if (!pm_runtime_status_suspended(&client->dev))
> + s5k5e8_power_off(&client->dev);
> + pm_runtime_set_suspended(&client->dev);
> +}
> +
> +static const struct dev_pm_ops s5k5e8_pm_ops = { SET_RUNTIME_PM_OPS(s5k5e8_power_off,
> + s5k5e8_power_on, NULL) };
This looks strange. I'd add a \n before SET_RUNTIME_PM_OPS. In general
align continuation lines to the previous opening brace or parenthesis.
> +static const struct of_device_id s5k5e8_of_match[] = { { .compatible = "samsung,s5k5e8" }, { } };
Please fix the layout of this struct. It should look like:
static const struct of_device_id s5k5e8_of_match[] = {
{ .compatible = "samsung,s5k5e8" },
{ }
};
> +MODULE_DEVICE_TABLE(of, s5k5e8_of_match);
> +static struct i2c_driver s5k5e8_i2c_driver = {
> + .driver = { .name = "s5k5e8", .pm = &s5k5e8_pm_ops, .of_match_table = s5k5e8_of_match },
> + .probe = s5k5e8_probe, .remove = s5k5e8_remove,
This also lacks newlines.
> +};
> +module_i2c_driver(s5k5e8_i2c_driver);
> +MODULE_DESCRIPTION("Samsung S5K5E8 5MP sensor driver");
> +MODULE_LICENSE("GPL");
The same critics apply to (at least) patch #5, too.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-11-23 13:56 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 [this message]
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
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=awRDMjtMC74v5zQq@monoceros \
--to=u.kleine-koenig@baylibre.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hikmahgumelar@gmail.com \
--cc=jbrunet+clk@baylibre.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sboyd@kernel.org \
/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.