Linux Media Controller development
 help / color / mirror / Atom feed
From: Umang Jain <umang.jain@ideasonboard.com>
To: Tommaso Merciai <tomm.merciai@gmail.com>
Cc: linux-media@vger.kernel.org, dave.stevenson@raspberrypi.com,
	sakari.ailus@linux.intel.com,
	Kieran Bingham <kieran.bingham@ideasonboard.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCH] media: i2c: imx219: Use dev_err_probe on probe
Date: Thu, 14 Mar 2024 18:51:04 +0530	[thread overview]
Message-ID: <b949d192-9ea5-489a-91a9-2b055ec47b22@ideasonboard.com> (raw)
In-Reply-To: <Ze7shcxM/v1+FHCm@tom-HP-ZBook-Fury-15-G7-Mobile-Workstation>

Hi Tommaso,

On 11/03/24 5:05 pm, Tommaso Merciai wrote:
> Hi Umang,
> Thanks for the patch.
>
> On Mon, Mar 11, 2024 at 02:30:42PM +0530, Umang Jain wrote:
>> Drop dev_err() and use the dev_err_probe() helper on probe path.
>>
>> No functional changes intended.
>>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>> ---
>>   drivers/media/i2c/imx219.c | 64 +++++++++++++++++++-------------------
>>   1 file changed, 32 insertions(+), 32 deletions(-)
>>
>> diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
>> index e17ef2e9d9d0..acd27e2ef849 100644
>> --- a/drivers/media/i2c/imx219.c
>> +++ b/drivers/media/i2c/imx219.c
>> @@ -551,8 +551,9 @@ static int imx219_init_controls(struct imx219 *imx219)
>>   
>>   	if (ctrl_hdlr->error) {
>>   		ret = ctrl_hdlr->error;
>> -		dev_err(&client->dev, "%s control init failed (%d)\n",
>> -			__func__, ret);
>> +		dev_err_probe(&client->dev, ret,
>> +			      "%s control init failed\n",
>> +			      __func__);
>>   		goto error;
>>   	}
>>   
>> @@ -1025,15 +1026,15 @@ static int imx219_identify_module(struct imx219 *imx219)
>>   
>>   	ret = cci_read(imx219->regmap, IMX219_REG_CHIP_ID, &val, NULL);
>>   	if (ret) {
>> -		dev_err(&client->dev, "failed to read chip id %x\n",
>> -			IMX219_CHIP_ID);
>> -		return ret;
>> +		return dev_err_probe(&client->dev, ret,
>> +				     "failed to read chip id %x\n",
>> +				     IMX219_CHIP_ID);
>>   	}
> I think you can remove also here the curve brakets we don't need that
> anymore.

I think multi-line single statement like this one, is better with { ... 
} and is actually preferred?

I actually got a review-comment about this long ago(don't remember when) 
in a non-related, kernel patch series.

I'll leaving this upto maintainers probably
>
>>   
>>   	if (val != IMX219_CHIP_ID) {
>> -		dev_err(&client->dev, "chip id mismatch: %x!=%llx\n",
>> -			IMX219_CHIP_ID, val);
>> -		return -EIO;
>> +		return dev_err_probe(&client->dev, -EIO,
>> +				     "chip id mismatch: %x!=%llx\n",
>> +				     IMX219_CHIP_ID, val);
>>   	}
> ditto
>
>>   
>>   	return 0;
>> @@ -1048,35 +1049,36 @@ static int imx219_check_hwcfg(struct device *dev, struct imx219 *imx219)
>>   	int ret = -EINVAL;
>>   
>>   	endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL);
>> -	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");
>>   
>>   	if (v4l2_fwnode_endpoint_alloc_parse(endpoint, &ep_cfg)) {
>> -		dev_err(dev, "could not parse endpoint\n");
>> +		dev_err_probe(dev, -EINVAL, "could not parse endpoint\n");
>>   		goto error_out;
>>   	}
>>   
>>   	/* Check the number of MIPI CSI2 data lanes */
>>   	if (ep_cfg.bus.mipi_csi2.num_data_lanes != 2 &&
>>   	    ep_cfg.bus.mipi_csi2.num_data_lanes != 4) {
>> -		dev_err(dev, "only 2 or 4 data lanes are currently supported\n");
>> +		dev_err_probe(dev, -EINVAL,
>> +			      "only 2 or 4 data lanes are currently supported\n");
>>   		goto error_out;
>>   	}
>>   	imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;
>>   
>>   	/* Check the link frequency set in device tree */
>>   	if (!ep_cfg.nr_of_link_frequencies) {
>> -		dev_err(dev, "link-frequency property not found in DT\n");
>> +		dev_err_probe(dev, -EINVAL,
>> +			      "link-frequency property not found in DT\n");
>>   		goto error_out;
>>   	}
>>   
>>   	if (ep_cfg.nr_of_link_frequencies != 1 ||
>>   	   (ep_cfg.link_frequencies[0] != ((imx219->lanes == 2) ?
>>   	    IMX219_DEFAULT_LINK_FREQ : IMX219_DEFAULT_LINK_FREQ_4LANE))) {
>> -		dev_err(dev, "Link frequency not supported: %lld\n",
>> -			ep_cfg.link_frequencies[0]);
>> +		dev_err_probe(dev, -EINVAL,
>> +			      "Link frequency not supported: %lld\n",
>> +			      ep_cfg.link_frequencies[0]);
>>   		goto error_out;
>>   	}
>>   
>> @@ -1108,30 +1110,27 @@ static int imx219_probe(struct i2c_client *client)
>>   
>>   	imx219->regmap = devm_cci_regmap_init_i2c(client, 16);
>>   	if (IS_ERR(imx219->regmap)) {
>> -		ret = PTR_ERR(imx219->regmap);
>> -		dev_err(dev, "failed to initialize CCI: %d\n", ret);
>> -		return ret;
>> +		return dev_err_probe(dev, PTR_ERR(imx219->regmap),
>> +				     "failed to initialize CCI\n");
>>   	}
> ditto
>
>>   
>>   	/* Get system clock (xclk) */
>>   	imx219->xclk = devm_clk_get(dev, NULL);
>>   	if (IS_ERR(imx219->xclk)) {
>> -		dev_err(dev, "failed to get xclk\n");
>> -		return PTR_ERR(imx219->xclk);
>> +		return dev_err_probe(dev, PTR_ERR(imx219->xclk),
>> +				     "failed to get xclk\n");
>>   	}
> ditto
>
>>   
>>   	imx219->xclk_freq = clk_get_rate(imx219->xclk);
>>   	if (imx219->xclk_freq != IMX219_XCLK_FREQ) {
>> -		dev_err(dev, "xclk frequency not supported: %d Hz\n",
>> -			imx219->xclk_freq);
>> -		return -EINVAL;
>> +		return dev_err_probe(dev, -EINVAL,
>> +				     "xclk frequency not supported: %d Hz\n",
>> +				     imx219->xclk_freq);
>>   	}
> ditto
>
>>   
>>   	ret = imx219_get_regulators(imx219);
>> -	if (ret) {
>> -		dev_err(dev, "failed to get regulators\n");
>> -		return ret;
>> -	}
>> +	if (ret)
>> +		return dev_err_probe(dev, ret, "failed to get regulators\n");
>>   
>>   	/* Request optional enable pin */
>>   	imx219->reset_gpio = devm_gpiod_get_optional(dev, "reset",
>> @@ -1183,20 +1182,21 @@ static int imx219_probe(struct i2c_client *client)
>>   
>>   	ret = media_entity_pads_init(&imx219->sd.entity, 1, &imx219->pad);
>>   	if (ret) {
>> -		dev_err(dev, "failed to init entity pads: %d\n", ret);
>> +		dev_err_probe(dev, ret, "failed to init entity pads\n");
>>   		goto error_handler_free;
>>   	}
>>   
>>   	imx219->sd.state_lock = imx219->ctrl_handler.lock;
>>   	ret = v4l2_subdev_init_finalize(&imx219->sd);
>>   	if (ret < 0) {
>> -		dev_err(dev, "subdev init error: %d\n", ret);
>> +		dev_err_probe(dev, ret, "subdev init error\n");
>>   		goto error_media_entity;
>>   	}
>>   
>>   	ret = v4l2_async_register_subdev_sensor(&imx219->sd);
>>   	if (ret < 0) {
>> -		dev_err(dev, "failed to register sensor sub-device: %d\n", ret);
>> +		dev_err_probe(dev, ret,
>> +			      "failed to register sensor sub-device\n");
>>   		goto error_subdev_cleanup;
>>   	}
>>   
>> -- 
>> 2.43.0
> Thanks & Regards,
> Tommaso
>
>>


  reply	other threads:[~2024-03-14 13:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11  9:00 [PATCH] media: i2c: imx219: Use dev_err_probe on probe Umang Jain
2024-03-11 11:35 ` Tommaso Merciai
2024-03-14 13:21   ` Umang Jain [this message]
2024-03-14 14:58     ` Tommaso Merciai
2024-03-15  6:38       ` Sakari Ailus
2024-03-14 15:21     ` Laurent Pinchart
2024-03-15  6:43       ` Umang Jain
2024-03-28 10:53         ` Laurent Pinchart
2024-03-28 10:59           ` Umang Jain
2024-03-28 11:09             ` Laurent Pinchart
2024-03-28 11:22               ` Umang Jain
2024-04-15  9:13               ` Sakari Ailus

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=b949d192-9ea5-489a-91a9-2b055ec47b22@ideasonboard.com \
    --to=umang.jain@ideasonboard.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomm.merciai@gmail.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