Hi Prabhakar, Thank you for the patch. On Fri, Oct 18, 2024 at 04:32:23PM +0100, Prabhakar wrote: > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> > > Refactor error handling in the ov5645_probe() function by replacing > multiple dev_err() calls with dev_err_probe(). > > - Note that during this process, the error string "external clock > frequency %u is not supported" was replaced with "unsupported xclk > frequency %u" to ensure it wraps at 80 columns. > - Additionally, the error string for control initialization failure was > changed from "%s: control initialization error %d\n" to "failed to add > controls\n" as there is no need to print the function name and error code > in the string, since dev_err_probe() already provides this information. > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@xxxxxxxxxxxxxxxx> > --- > drivers/media/i2c/ov5645.c | 82 +++++++++++++++++--------------------- > 1 file changed, 36 insertions(+), 46 deletions(-) > > diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c > index d344d3447a95..520afd3d2aa3 100644 > --- a/drivers/media/i2c/ov5645.c > +++ b/drivers/media/i2c/ov5645.c > @@ -1076,51 +1076,44 @@ static int ov5645_probe(struct i2c_client *client) > ov5645->dev = dev; > > endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1); > - if (!endpoint) { > - dev_err(dev, "endpoint node not found\n"); > - return -EINVAL; > - } > + if (!endpoint) > + return dev_err_probe(dev, -EINVAL, > + "endpoint node not found\n"); > > ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), > &ov5645->ep); > > of_node_put(endpoint); > > - if (ret < 0) { > - dev_err(dev, "parsing endpoint node failed\n"); > - return ret; > - } > + if (ret < 0) > + return dev_err_probe(dev, ret, > + "parsing endpoint node failed\n"); > > - if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY) { > - dev_err(dev, "invalid bus type, must be CSI2\n"); > - return -EINVAL; > - } > + if (ov5645->ep.bus_type != V4L2_MBUS_CSI2_DPHY) > + return dev_err_probe(dev, -EINVAL, > + "invalid bus type, must be CSI2\n"); > > /* get system clock (xclk) */ > ov5645->xclk = devm_clk_get(dev, NULL); > - if (IS_ERR(ov5645->xclk)) { > - dev_err(dev, "could not get xclk"); > - return PTR_ERR(ov5645->xclk); > - } > + if (IS_ERR(ov5645->xclk)) > + return dev_err_probe(dev, PTR_ERR(ov5645->xclk), > + "could not get xclk"); > > ret = of_property_read_u32(dev->of_node, "clock-frequency", &xclk_freq); > - if (ret) { > - dev_err(dev, "could not get xclk frequency\n"); > - return ret; > - } > + if (ret) > + return dev_err_probe(dev, ret, > + "could not get xclk frequency\n"); > > /* external clock must be 24MHz, allow 1% tolerance */ > - if (xclk_freq < 23760000 || xclk_freq > 24240000) { > - dev_err(dev, "external clock frequency %u is not supported\n", > - xclk_freq); > - return -EINVAL; > - } > + if (xclk_freq < 23760000 || xclk_freq > 24240000) > + return dev_err_probe(dev, -EINVAL, > + "unsupported xclk frequency %u\n", > + xclk_freq); > > ret = clk_set_rate(ov5645->xclk, xclk_freq); > - if (ret) { > - dev_err(dev, "could not set xclk frequency\n"); > - return ret; > - } > + if (ret) > + return dev_err_probe(dev, ret, > + "could not set xclk frequency\n"); > > for (i = 0; i < OV5645_NUM_SUPPLIES; i++) > ov5645->supplies[i].supply = ov5645_supply_name[i]; > @@ -1131,16 +1124,14 @@ static int ov5645_probe(struct i2c_client *client) > return ret; > > ov5645->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH); > - if (IS_ERR(ov5645->enable_gpio)) { > - dev_err(dev, "cannot get enable gpio\n"); > - return PTR_ERR(ov5645->enable_gpio); > - } > + if (IS_ERR(ov5645->enable_gpio)) > + return dev_err_probe(dev, PTR_ERR(ov5645->enable_gpio), > + "cannot get enable gpio\n"); > > ov5645->rst_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); > - if (IS_ERR(ov5645->rst_gpio)) { > - dev_err(dev, "cannot get reset gpio\n"); > - return PTR_ERR(ov5645->rst_gpio); > - } > + if (IS_ERR(ov5645->rst_gpio)) > + return dev_err_probe(dev, PTR_ERR(ov5645->rst_gpio), > + "cannot get reset gpio\n"); > > mutex_init(&ov5645->power_lock); > > @@ -1177,9 +1168,8 @@ static int ov5645_probe(struct i2c_client *client) > ov5645->sd.ctrl_handler = &ov5645->ctrls; > > if (ov5645->ctrls.error) { > - dev_err(dev, "%s: control initialization error %d\n", > - __func__, ov5645->ctrls.error); > ret = ov5645->ctrls.error; > + dev_err_probe(dev, ret, "failed to add controls\n"); > goto free_ctrl; > } > > @@ -1193,7 +1183,7 @@ static int ov5645_probe(struct i2c_client *client) > > ret = media_entity_pads_init(&ov5645->sd.entity, 1, &ov5645->pad); > if (ret < 0) { > - dev_err(dev, "could not register media entity\n"); > + dev_err_probe(dev, ret, "could not register media entity\n"); > goto free_ctrl; > } > > @@ -1203,14 +1193,14 @@ static int ov5645_probe(struct i2c_client *client) > > ret = ov5645_read_reg(ov5645, OV5645_CHIP_ID_HIGH, &chip_id_high); > if (ret < 0 || chip_id_high != OV5645_CHIP_ID_HIGH_BYTE) { > - dev_err(dev, "could not read ID high\n"); > ret = -ENODEV; > + dev_err_probe(dev, ret, "could not read ID high\n"); > goto power_down; > } > ret = ov5645_read_reg(ov5645, OV5645_CHIP_ID_LOW, &chip_id_low); > if (ret < 0 || chip_id_low != OV5645_CHIP_ID_LOW_BYTE) { > - dev_err(dev, "could not read ID low\n"); > ret = -ENODEV; > + dev_err_probe(dev, ret, "could not read ID low\n"); > goto power_down; > } > > @@ -1219,24 +1209,24 @@ static int ov5645_probe(struct i2c_client *client) > ret = ov5645_read_reg(ov5645, OV5645_AEC_PK_MANUAL, > &ov5645->aec_pk_manual); > if (ret < 0) { > - dev_err(dev, "could not read AEC/AGC mode\n"); > ret = -ENODEV; > + dev_err_probe(dev, ret, "could not read AEC/AGC mode\n"); > goto power_down; > } > > ret = ov5645_read_reg(ov5645, OV5645_TIMING_TC_REG20, > &ov5645->timing_tc_reg20); > if (ret < 0) { > - dev_err(dev, "could not read vflip value\n"); > ret = -ENODEV; > + dev_err_probe(dev, ret, "could not read vflip value\n"); > goto power_down; > } > > ret = ov5645_read_reg(ov5645, OV5645_TIMING_TC_REG21, > &ov5645->timing_tc_reg21); > if (ret < 0) { > - dev_err(dev, "could not read hflip value\n"); > ret = -ENODEV; > + dev_err_probe(dev, ret, "could not read hflip value\n"); > goto power_down; > } > > @@ -1248,7 +1238,7 @@ static int ov5645_probe(struct i2c_client *client) > > ret = v4l2_async_register_subdev(&ov5645->sd); > if (ret < 0) { > - dev_err(dev, "could not register v4l2 device\n"); > + dev_err_probe(dev, ret, "could not register v4l2 device\n"); > goto err_pm_runtime; > } > -- Regards, Laurent Pinchart