From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
Biju Das <biju.das.jz@bp.renesas.com>,
Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [PATCH v3 03/10] media: i2c: ov5645: Replace dev_err with dev_err_probe in probe function
Date: Mon, 21 Oct 2024 01:33:01 +0300 [thread overview]
Message-ID: <20241020223301.GA14328@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20241018153230.235647-4-prabhakar.mahadev-lad.rj@bp.renesas.com>
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@bp.renesas.com>
>
> 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@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
> 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
next prev parent reply other threads:[~2024-10-20 22:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 15:32 [PATCH v3 00/10] media: ov5645: Add support for streams Prabhakar
2024-10-18 15:32 ` [PATCH v3 01/10] media: i2c: ov5645: Add V4L2_SUBDEV_FL_HAS_EVENTS and subscribe hooks Prabhakar
2024-10-18 15:32 ` [PATCH v3 02/10] media: i2c: ov5645: Use local `dev` pointer for subdev device assignment Prabhakar
2024-10-21 7:16 ` Tommaso Merciai
2024-10-18 15:32 ` [PATCH v3 03/10] media: i2c: ov5645: Replace dev_err with dev_err_probe in probe function Prabhakar
2024-10-20 22:33 ` Laurent Pinchart [this message]
2024-10-18 15:32 ` [PATCH v3 04/10] media: i2c: ov5645: Use v4l2_async_register_subdev_sensor() Prabhakar
2024-10-18 15:32 ` [PATCH v3 05/10] media: i2c: ov5645: Drop `power_lock` mutex Prabhakar
2024-10-18 15:32 ` [PATCH v3 06/10] media: i2c: ov5645: Use subdev active state Prabhakar
2024-10-18 15:32 ` [PATCH v3 07/10] media: i2c: ov5645: Switch to {enable,disable}_streams Prabhakar
2024-10-18 15:32 ` [PATCH v3 08/10] media: i2c: ov5645: Report streams using frame descriptors Prabhakar
2024-11-05 12:07 ` Sakari Ailus
2024-10-18 15:32 ` [PATCH v3 09/10] media: i2c: ov5645: Add internal image sink pad Prabhakar
2024-10-18 15:32 ` [PATCH v3 10/10] media: i2c: ov5645: Report internal routes to userspace Prabhakar
2024-10-20 22:39 ` [PATCH v3 00/10] media: ov5645: Add support for streams Laurent Pinchart
2024-10-21 8:06 ` Lad, Prabhakar
2024-11-04 23:32 ` Lad, Prabhakar
2024-10-21 8:10 ` Tommaso Merciai
2024-10-21 9:22 ` Lad, Prabhakar
2024-11-05 11:18 ` Sakari Ailus
2024-11-05 11:23 ` Lad, Prabhakar
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=20241020223301.GA14328@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=fabrizio.castro.jz@renesas.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=prabhakar.csengg@gmail.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=sakari.ailus@linux.intel.com \
/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
all inboxes | Powered by JetHome®