From: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
Sylvain Petinot <sylvain.petinot@foss.st.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: <linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] media: i2c: Add driver for ST VD55G1 camera sensor
Date: Mon, 31 Mar 2025 14:34:09 +0200 [thread overview]
Message-ID: <3cdc3771-c61e-427f-ad59-12bcb41e7e8d@foss.st.com> (raw)
In-Reply-To: <7556a0a8-47f3-4cf7-ae4d-9ea444d98c6b@kernel.org>
Hi Krzysztof,
Thank you for your review.
On 3/29/25 06:46, Krzysztof Kozlowski wrote:
> On 28/03/2025 14:40, Benjamin Mugnier wrote:
>> +
>> +static void vd55g1_subdev_cleanup(struct vd55g1 *sensor)
>> +{
>> + v4l2_async_unregister_subdev(&sensor->sd);
>> + v4l2_subdev_cleanup(&sensor->sd);
>> + media_entity_cleanup(&sensor->sd.entity);
>> + v4l2_ctrl_handler_free(sensor->sd.ctrl_handler);
>> +}
>> +
>> +static int vd55g1_err_probe(struct device *dev, int ret, char *msg)
>
> Drop, it's really useless. Don't create own abstraction layers for other
> systems.
>
>> +{
>> + return dev_err_probe(dev, ret, msg);
>> +}
>> +
>> +static int vd55g1_probe(struct i2c_client *client)
>> +{
>> + struct device *dev = &client->dev;
>> + struct vd55g1 *sensor;
>> + int ret;
>> +
>> + sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
>> + if (!sensor)
>> + return -ENOMEM;
>> +
>> + v4l2_i2c_subdev_init(&sensor->sd, client, &vd55g1_subdev_ops);
>> + sensor->i2c_client = client;
>> +
>> + ret = vd55g1_parse_dt(sensor);
>> + if (ret)
>> + return vd55g1_err_probe(dev, ret,
>> + "Failed to parse Device Tree.");
>> +
>> + /* Get (and check) resources : power regs, ext clock, reset gpio */
>> + ret = vd55g1_get_regulators(sensor);
>> + if (ret)
>> + return vd55g1_err_probe(dev, ret, "Failed to get regulators.");
>> +
>> + sensor->xclk = devm_clk_get(dev, NULL);
>> + if (IS_ERR(sensor->xclk)) {
>
> Drop {}
>
> Please run scripts/checkpatch.pl on the patches and fix reported
> warnings. After that, run also 'scripts/checkpatch.pl --strict' on the
> patches and (probably) fix more warnings. Some warnings can be ignored,
> especially from --strict run, but the code here looks like it needs a
> fix. Feel free to get in touch if the warning is not clear.
>
While it should, checkpatch does not complain about that. Maybe because
the function call is on two lines ? Anyway thanks a lot for pointing
this. Fixed.
>> + return vd55g1_err_probe(dev, PTR_ERR(sensor->xclk),
>
> No. Syntax is return dev_err_probe, not some custom wrappers over single
> function.
>
>> + "Failed to get xclk.");
>> + }
>> + sensor->xclk_freq = clk_get_rate(sensor->xclk);
>> + ret = vd55g1_prepare_clock_tree(sensor);
>> + if (ret)
>> + return ret;
>> +
>> + sensor->reset_gpio =
>> + devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
>
> Odd wrapping. This should be one line with optionally wrapped last argument.
>
>> + if (IS_ERR(sensor->reset_gpio))
>> + return vd55g1_err_probe(dev, PTR_ERR(sensor->reset_gpio),
>> + "Failed to get reset gpio.");
>> +
>> + sensor->regmap = devm_cci_regmap_init_i2c(client, 16);
>> + if (IS_ERR(sensor->regmap))
>> + return vd55g1_err_probe(dev, PTR_ERR(sensor->regmap),
>> + "Failed to init regmap.");
>> +
>> + /* Detect if sensor is present and if its revision is supported */
>> + ret = vd55g1_power_on(dev);
>> + if (ret)
>> + return ret;
>> +
>> + ret = vd55g1_subdev_init(sensor);
>> + if (ret) {
>> + dev_err(dev, "V4l2 init failed : %d", ret);
>> + goto err_power_off;
>> + }
>> +
>> + ret = v4l2_async_register_subdev(&sensor->sd);
>> + if (ret) {
>> + dev_err(dev, "async subdev register failed %d", ret);
>> + goto err_subdev;
>> + }
>> +
>> + /* Enable pm_runtime and power off the sensor */
>> + pm_runtime_set_active(dev);
>> + pm_runtime_get_noresume(dev);
>> + pm_runtime_enable(dev);
>> + pm_runtime_set_autosuspend_delay(dev, 4000);
>> + pm_runtime_use_autosuspend(dev);
>> + pm_runtime_mark_last_busy(dev);
>> +
>> + dev_dbg(dev, "vd55g1 probe successfully");
>
> Drop. Kernel already provides you such debugging/tracing.
Interesting, do you know how to enable this kind of tracing ?
>
> Best regards,
> Krzysztof
--
Regards,
Benjamin
next prev parent reply other threads:[~2025-03-31 12:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 13:40 [PATCH 0/2] media: Add support for ST VD55G1 camera sensor Benjamin Mugnier
2025-03-28 13:40 ` [PATCH 1/2] media: dt-bindings: Add ST VD55G1 camera sensor binding Benjamin Mugnier
2025-03-29 5:42 ` Krzysztof Kozlowski
2025-03-31 12:34 ` Benjamin Mugnier
2025-03-28 13:40 ` [PATCH 2/2] media: i2c: Add driver for ST VD55G1 camera sensor Benjamin Mugnier
2025-03-28 18:07 ` kernel test robot
2025-03-29 5:46 ` Krzysztof Kozlowski
2025-03-31 12:34 ` Benjamin Mugnier [this message]
2025-03-29 9:16 ` kernel test robot
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=3cdc3771-c61e-427f-ad59-12bcb41e7e8d@foss.st.com \
--to=benjamin.mugnier@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@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=sylvain.petinot@foss.st.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;
as well as URLs for NNTP newsgroup(s).