mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Tommaso Merciai <tomm.merciai@gmail.com>
Cc: martin.hecht@avnet.eu, michael.roeder@avnet.eu,
	mhecht73@gmail.com, linuxfancy@googlegroups.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Marco Felsch <m.felsch@pengutronix.de>,
	Gerald Loacker <gerald.loacker@wolfvision.net>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Daniel Scally <djrscally@gmail.com>,
	Shawn Tu <shawnx.tu@intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	linux-kernel@vger.kernel.org,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH v10 3/3] media: i2c: Add support for alvium camera
Date: Wed, 1 Nov 2023 15:22:18 +0100	[thread overview]
Message-ID: <7fc8435a-6a96-447b-af85-8ae5242cabfd@wanadoo.fr> (raw)
In-Reply-To: <ZUJc-p_i4JjqkM9i@kekkonen.localdomain>

Le 01/11/2023 à 15:13, Sakari Ailus a écrit :
> Hi Tommaso,
> 
> On Tue, Oct 31, 2023 at 12:46:09PM +0100, Tommaso Merciai wrote:
>>>> +static int alvium_get_dt_data(struct alvium_dev *alvium)
>>>> +{
>>>> +	struct device *dev = &alvium->i2c_client->dev;
>>>> +	struct fwnode_handle *fwnode = dev_fwnode(dev);
>>>> +	struct fwnode_handle *endpoint;
>>>> +	int ret = -EINVAL;
>>>> +
>>>> +	if (!fwnode)
>>>> +		return -EINVAL;
>>>> +
>>>> +	/* Only CSI2 is supported for now: */
>>>> +	alvium->ep.bus_type = V4L2_MBUS_CSI2_DPHY;
>>>> +
>>>> +	endpoint = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0);
>>>> +	if (!endpoint) {
>>>> +		dev_err(dev, "endpoint node not found\n");
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	if (v4l2_fwnode_endpoint_alloc_parse(endpoint, &alvium->ep)) {
>>>> +		dev_err(dev, "could not parse endpoint\n");
>>>> +		goto error_out;
>>>
>>> This could go to another label to be less confusing, but
>>> v4l2_fwnode_endpoint_free() looks to be a no-op here, so good enough.
>>
>> Thanks for the comment.
>> To be honest right now this is clear to me
>> I prefere to stay on the following :)
>> Prefer to keep just only one path.
> 
> You can safely call v4l2_fwnode_endpoint_free() on an unparsed endpoint (or
> on and endpoint the parsing of which failed). I prefer this too.
> 
>>>> +		ret = -ENODEV;
>>>> +		goto err_powerdown;
>>>> +	}
>>>> +
>>>> +	ret = alvium_get_hw_info(alvium);
>>>> +	if (ret) {
>>>> +		dev_err(dev, "get_hw_info fail %d\n", ret);
>>>> +		goto err_powerdown;
>>>> +	}
>>>> +
>>>> +	ret = alvium_hw_init(alvium);
>>>> +	if (ret) {
>>>> +		dev_err(dev, "hw_init fail %d\n", ret);
>>>> +		goto err_powerdown;
>>>> +	}
>>>> +
>>>> +	ret = alvium_setup_mipi_fmt(alvium);
>>>> +	if (ret) {
>>>> +		dev_err(dev, "setup_mipi_fmt fail %d\n", ret);
>>>> +		goto err_powerdown;
>>>> +	}
>>>> +
>>>> +	/*
>>>> +	 * Enable runtime PM without autosuspend:
>>>> +	 *
>>>> +	 * Don't use pm autosuspend (alvium have ~7s boot time).
>>>> +	 * Alvium has been powered manually:
>>>> +	 *  - mark it as active
>>>> +	 *  - increase the usage count without resuming the device.
>>>> +	 */
>>>> +	pm_runtime_set_active(dev);
>>>> +	pm_runtime_get_noresume(dev);
>>>> +	pm_runtime_enable(dev);
>>>> +
>>>> +	/* Initialize the V4L2 subdev. */
>>>> +	ret = alvium_subdev_init(alvium);
>>>> +	if (ret)
>>>> +		goto err_pm;
>>>> +
>>>> +	ret = v4l2_async_register_subdev(&alvium->sd);
>>>> +	if (ret < 0) {
>>>> +		dev_err(dev, "Could not register v4l2 device\n");
>>>> +		goto err_subdev;
>>>> +	}
>>>> +
>>>> +	return 0;
>>>> +
>>>> +err_subdev:
>>>> +	alvium_subdev_cleanup(alvium);
>>>
>>> Should this also be called by the remove function?
>>> Or is it already handled by an un-register mechanism?
>>
>> Right, I miss this.
>> Thanks.
>> I put this to remove function like:
>>
>> static void alvium_remove(struct i2c_client *client)
>> {
>> 	struct v4l2_subdev *sd = i2c_get_clientdata(client);
>> 	struct alvium_dev *alvium = sd_to_alvium(sd);
>> 	struct device *dev = &alvium->i2c_client->dev;
>>
>> 	/*
>> 	 * Disable runtime PM. In case runtime PM is disabled in the kernel,
>> 	 * make sure to turn power off manually.
>> 	 */
>> 	pm_runtime_disable(dev);
>> 	if (!pm_runtime_status_suspended(dev))
>> 		alvium_power_on(alvium, false);
>> 	pm_runtime_set_suspended(dev);
>>
>> 	alvium_subdev_cleanup(alvium);
>> 	i2c_unregister_device(alvium->i2c_client);
> 
> This doesn't belong here (as you didn't register it). It was missed in the
> review earlier.

Should be v4l2_async_unregister_subdev()?

CJ

> 
>> }
>>
>>
>> If for you Cristophe, Sakari, Laurent,
>> it's ok I prefer to skip v11 that I sent this morning too early.
>> I collected hints from Cristophe right now and I plan to send v12
>> this afternoon/evening if for you all is ok.
>>
>> https://github.com/avs-sas/linux/blob/tm/media_stage/v6.6.0-rc3/alvium_drv/v12/drivers/media/i2c/alvium-csi2.c
>>
>> Please let me know.
>>
>> Thanks again to all! :)
> 


  reply	other threads:[~2023-11-01 14:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 14:13 [PATCH v10 0/3] " Tommaso Merciai
2023-10-20 14:13 ` [PATCH v10 1/3] dt-bindings: vendor-prefixes: Add prefix alliedvision Tommaso Merciai
2023-10-20 14:13 ` [PATCH v10 2/3] media: dt-bindings: alvium: add document YAML binding Tommaso Merciai
2023-10-20 14:13 ` [PATCH v10 3/3] media: i2c: Add support for alvium camera Tommaso Merciai
2023-10-26 13:18   ` Sakari Ailus
2023-10-30 12:26     ` Tommaso Merciai
2023-10-30 12:37       ` Laurent Pinchart
2023-10-30 13:29         ` Tommaso Merciai
2023-10-30 13:37           ` Laurent Pinchart
2023-10-30 14:32             ` Tommaso Merciai
2023-10-30 14:44               ` Laurent Pinchart
2023-10-30 22:43       ` Sakari Ailus
2023-10-30 23:38         ` Laurent Pinchart
2023-10-31  6:34           ` Sakari Ailus
2023-10-31  8:53             ` Laurent Pinchart
2023-10-31  9:07               ` Sakari Ailus
2023-10-31 10:14                 ` Sakari Ailus
2023-10-31 10:18                   ` Laurent Pinchart
2023-10-31 10:34                     ` Sakari Ailus
2023-10-31 10:49                       ` Laurent Pinchart
2023-10-31  8:13         ` Tommaso Merciai
2023-10-31 10:23   ` Christophe JAILLET
2023-10-31 11:46     ` Tommaso Merciai
2023-11-01 14:13       ` Sakari Ailus
2023-11-01 14:22         ` Christophe JAILLET [this message]
2023-11-01 17:16           ` Tommaso Merciai
2023-11-01 20:10             ` Tommaso Merciai
2023-11-01 17:12         ` Tommaso Merciai

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=7fc8435a-6a96-447b-af85-8ae5242cabfd@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=djrscally@gmail.com \
    --cc=gerald.loacker@wolfvision.net \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxfancy@googlegroups.com \
    --cc=m.felsch@pengutronix.de \
    --cc=martin.hecht@avnet.eu \
    --cc=mchehab@kernel.org \
    --cc=mhecht73@gmail.com \
    --cc=michael.roeder@avnet.eu \
    --cc=sakari.ailus@linux.intel.com \
    --cc=shawnx.tu@intel.com \
    --cc=tomi.valkeinen@ideasonboard.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

all inboxes | Powered by JetHome®