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 > +#include > +#include > +#include > +#include already provides of_device_id, so please drop (which adds a lot of unneeded dependencies). > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#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