From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Cc: Philippe Baetens <philippebaetens@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>,
Kieran Bingham <kieran.bingham@ideasonboard.com>,
Jai Luthra <jai.luthra@ideasonboard.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] media: i2c: mira016: Add driver for Mira016
Date: Thu, 1 Oct 2026 13:58:10 +0300 [thread overview]
Message-ID: <ar48wuZ5ExmCXyY7@kekkonen.localdomain> (raw)
In-Reply-To: <20260930-mira016-v5-2-499a34ab8204@ideasonboard.com>
Hi Jacopo,
One more small issue...
On Wed, Sep 30, 2026 at 12:51:20PM +0200, Jacopo Mondi wrote:
...
> +static int mira016_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct mira016 *mira016;
> + int ret;
> +
> + mira016 = devm_kzalloc(&client->dev, sizeof(*mira016), GFP_KERNEL);
> + if (!mira016)
> + return -ENOMEM;
> +
> + mira016->dev = &client->dev;
> +
> + ret = mira016_parse_endpoint(dev, mira016);
> + if (ret)
> + return ret;
> +
> + v4l2_i2c_subdev_init(&mira016->sd, client, &mira016_subdev_ops);
> +
> + mira016->regmap = devm_cci_regmap_init_i2c(client, 16);
> + if (IS_ERR(mira016->regmap))
> + return dev_err_probe(dev, PTR_ERR(mira016->regmap),
> + "failed to initialize CCI\n");
> +
> + mira016->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
> + if (IS_ERR(mira016->xclk))
> + return dev_err_probe(dev, PTR_ERR(mira016->xclk),
> + "failed to get xclk\n");
> +
> + mira016->xclk_freq = clk_get_rate(mira016->xclk);
> + if (mira016_validate_xclk_freq(mira016)) {
> + dev_err(dev, "xclk frequency not supported: %d Hz\n",
> + mira016->xclk_freq);
> + return -EINVAL;
> + }
> +
> + ret = mira016_get_regulators(mira016);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to get regulators\n");
> +
> + mira016->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> + GPIOD_OUT_HIGH);
> + if (IS_ERR(mira016->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(mira016->reset_gpio),
> + "failed to get reset gpio\n");
> +
> + /*
> + * Calculate the PLL configuration based on the link frequency
> + * selected by .dts and compute the sensor timing bases.
> + *
> + * Initialize row_length to a value matching the default format for
> + * exposure and frame time limits calculations.
> + */
> + mira016_pll_calc(mira016);
> + mira016_timings_calc(mira016);
> + mira016->timings.row_length = 1262;
> +
> + ret = mira016_power_on(dev);
> + if (ret)
> + return ret;
> +
> + /* Enable runtime PM and power on the device */
> + pm_runtime_set_active(dev);
> + pm_runtime_enable(dev);
> +
> + ret = mira016_identify_module(mira016);
> + if (ret)
> + goto error_power_off;
> +
> + ret = mira016_init_controls(mira016);
> + if (ret)
> + goto error_power_off;
> +
> + /* Initialize subdev */
> + mira016->sd.internal_ops = &mira016_internal_ops;
> + mira016->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
> + mira016->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> +
> + /* Initialize source pads */
> + mira016->pad.flags = MEDIA_PAD_FL_SOURCE;
> +
> + ret = media_entity_pads_init(&mira016->sd.entity, 1, &mira016->pad);
> + if (ret) {
> + dev_err_probe(dev, ret, "failed to init entity pads\n");
> + goto error_handler_free;
> + }
> +
> + mira016->sd.state_lock = mira016->ctrl_handler.lock;
> + ret = v4l2_subdev_init_finalize(&mira016->sd);
> + if (ret < 0) {
> + dev_err_probe(dev, ret, "subdev init error\n");
> + goto error_media_entity;
> + }
> +
> + ret = v4l2_async_register_subdev_sensor(&mira016->sd);
> + if (ret < 0) {
> + dev_err_probe(dev, ret,
> + "failed to register sensor sub-device\n");
> + goto error_subdev_cleanup;
> + }
> +
> + pm_runtime_set_autosuspend_delay(dev, 1000);
> + pm_runtime_use_autosuspend(dev);
> + pm_runtime_idle(dev);
> +
> + return 0;
> +
> +error_subdev_cleanup:
> + v4l2_subdev_cleanup(&mira016->sd);
> +error_media_entity:
> + media_entity_cleanup(&mira016->sd.entity);
> +error_handler_free:
> + v4l2_ctrl_handler_free(mira016->sd.ctrl_handler);
> +error_power_off:
> + pm_runtime_disable(dev);
> + if (!pm_runtime_status_suspended(&client->dev))
> + mira016_power_off(dev);
> + pm_runtime_set_suspended(dev);
These two come in pairs effectively. The sensor has been powered on earlier
and not powered off, so you can omit the suspended check above.
> + return ret;
> +}
--
Regards,
Sakari Ailus
prev parent reply other threads:[~2026-10-01 10:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 10:51 [PATCH v5 0/2] media: i2c: " Jacopo Mondi
2026-09-30 10:51 ` [PATCH v5 1/2] dt-bindings: media: i2c: Add Mira016 image sensor Jacopo Mondi
2026-09-30 10:51 ` [PATCH v5 2/2] media: i2c: mira016: Add driver for Mira016 Jacopo Mondi
2026-09-30 13:47 ` Tarang Raval
2026-09-30 16:34 ` Jacopo Mondi
2026-10-01 6:51 ` Sakari Ailus
2026-10-01 6:46 ` Sakari Ailus
2026-10-01 7:19 ` Jacopo Mondi
2026-10-01 7:52 ` Sakari Ailus
2026-10-01 10:07 ` Jacopo Mondi
2026-10-01 10:58 ` Sakari Ailus [this message]
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=ar48wuZ5ExmCXyY7@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jacopo.mondi@ideasonboard.com \
--cc=jai.luthra@ideasonboard.com \
--cc=kieran.bingham@ideasonboard.com \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=philippebaetens@gmail.com \
--cc=robh@kernel.org \
/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®