devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Richard Acayan <mailingradian@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Tianshu Qiu <tian.shu.qiu@intel.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 2/5] media: i2c: imx355: Support device tree probing and resource management
Date: Tue, 1 Jul 2025 15:08:40 +0200	[thread overview]
Message-ID: <39ee70ab-fc5b-462d-860b-aeeabea7417d@kernel.org> (raw)
In-Reply-To: <20250630225944.320755-9-mailingradian@gmail.com>

On 01/07/2025 00:59, Richard Acayan wrote:

>  static const struct imx355_reg imx355_global_regs[] = {
> @@ -1683,6 +1698,7 @@ static struct imx355_hwcfg *imx355_get_hwcfg(struct device *dev)
>  static int imx355_probe(struct i2c_client *client)
>  {
>  	struct imx355 *imx355;
> +	size_t i;
>  	int ret;
>  
>  	imx355 = devm_kzalloc(&client->dev, sizeof(*imx355), GFP_KERNEL);
> @@ -1694,6 +1710,42 @@ static int imx355_probe(struct i2c_client *client)
>  	/* Initialize subdev */
>  	v4l2_i2c_subdev_init(&imx355->sd, client, &imx355_subdev_ops);
>  
> +	for (i = 0; i < ARRAY_SIZE(imx355_supply_names); i++)
> +		imx355->supplies[i].supply = imx355_supply_names[i];
> +
> +	ret = devm_regulator_bulk_get(&client->dev,
> +				      ARRAY_SIZE(imx355->supplies),
> +				      imx355->supplies);
> +	if (ret) {
> +		dev_err_probe(&client->dev, ret, "could not get regulators");

Syntax is return dev_err_probe

> +		return ret;
> +	}
> +
> +	ret = regulator_bulk_enable(ARRAY_SIZE(imx355->supplies),
> +				    imx355->supplies);
> +	if (ret) {
> +		dev_err(&client->dev, "failed to enable regulators: %d\n", ret);
> +		return ret;
> +	}
> +
> +	imx355->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
> +						     GPIOD_OUT_HIGH);

So you keep the device disabled all the time... this makes no sense. How
can it work if it is always disabled?

> +	if (IS_ERR(imx355->reset_gpio)) {
> +		ret = PTR_ERR(imx355->reset_gpio);
> +		dev_err_probe(&client->dev, ret, "failed to get gpios");
> +		goto error_vreg_disable;
> +	}
> +
> +	imx355->mclk = devm_clk_get(&client->dev, "mclk");
> +	if (IS_ERR(imx355->mclk)) {
> +		ret = PTR_ERR(imx355->mclk);
> +		dev_err_probe(&client->dev, ret, "failed to get mclk");

No, syntax is ret = dev_err_probe.

> +		goto error_vreg_disable;
> +	}
> +
> +	clk_prepare_enable(imx355->mclk);
> +	usleep_range(12000, 13000);
> +
>  	/* Check module identity */
>  	ret = imx355_identify_module(imx355);
>  	if (ret) {
> @@ -1756,6 +1808,10 @@ static int imx355_probe(struct i2c_client *client)
>  
>  error_probe:
>  	mutex_destroy(&imx355->mutex);
> +	clk_disable_unprepare(imx355->mclk);



And where do you clean in remove()? No, just use devm_clk_get_enabled. I
think you are trying to upstream some old code. No, don't. You repeat
several poor patterns, like these err_probe handling or above clock bug
(actual bug). Just look how newest drivers are doing, not the
downstream. Downstream is the greatest antipattern. Absolute antipattern.


Best regards,
Krzysztof

  parent reply	other threads:[~2025-07-01 13:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 22:59 [PATCH 0/5] media: i2c: IMX355 for the Pixel 3a Richard Acayan
2025-06-30 22:59 ` [PATCH 1/5] dt-bindings: media: i2c: Add Sony IMX355 Richard Acayan
2025-07-01 13:06   ` Krzysztof Kozlowski
2025-06-30 22:59 ` [PATCH 2/5] media: i2c: imx355: Support device tree probing and resource management Richard Acayan
2025-07-01 12:43   ` Bryan O'Donoghue
2025-07-01 13:08   ` Krzysztof Kozlowski [this message]
2025-06-30 22:59 ` [PATCH 3/5] media: i2c: imx355: Add power management for managed resources Richard Acayan
2025-07-01 12:48   ` Bryan O'Donoghue
2025-06-30 22:59 ` [PATCH 4/5] arm64: dts: qcom: sdm670-google-sargo: add imx355 front camera Richard Acayan
2025-07-01 10:52   ` Konrad Dybcio
2025-07-01 12:23   ` Bryan O'Donoghue
2025-07-01 23:15     ` Richard Acayan
2025-07-02  0:48       ` Bryan O'Donoghue
2025-07-01 13:10   ` Krzysztof Kozlowski
2025-06-30 22:59 ` [PATCH 5/5] arm64: dts: qcom: sdm670-google-sargo: Add front camera rotation/orientation Richard Acayan
2025-07-01 10:53   ` Konrad Dybcio
2025-07-01 13:11   ` Krzysztof Kozlowski

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=39ee70ab-fc5b-462d-860b-aeeabea7417d@kernel.org \
    --to=krzk@kernel.org \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mailingradian@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@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;
as well as URLs for NNTP newsgroup(s).