From: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
To: R Sundar <prosunofficial@gmail.com>,
<sylvain.petinot@foss.st.com>, <mchehab@kernel.org>,
<sakari.ailus@linux.intel.com>,
<laurent.pinchart@ideasonboard.com>
Cc: <linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<skhan@linuxfoundation.org>, <javier.carrasco.cruz@gmail.com>,
Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH v2 linux-next] media: i2c: st-mipid02: replace of_node_put() with __free
Date: Mon, 13 May 2024 13:43:46 +0200 [thread overview]
Message-ID: <a688b2f2-d972-450a-9bec-2b506b58a21f@foss.st.com> (raw)
In-Reply-To: <20240429163736.11544-1-prosunofficial@gmail.com>
Hi,
I took sometime to reflect on this. Currently I favor drivers consistency.
Merging this patch as is would introduce some differences between the
vgxy61 and other drivers that follow the 'of_node_put' flow, which I
think is not an improvement.
Now, this patch is certainly good. Would it be possible to extend it to
all other drivers using the 'of_node_put' ?
That would the consistency issue while improving code quality at the
same time.
Thank you.
On 4/29/24 18:37, R Sundar wrote:
> Use the new cleanup magic to replace of_node_put() with
> __free(device_node) marking to auto release and to simplify the error
> paths.
>
> Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: R Sundar <prosunofficial@gmail.com>
> ---
>
> Changes since v1 -
>
> - Added missed out __free() marking in mipid02_parse_tx_ep().
> - In mipid02_parse_tx_ep(), In error case, return value is always -EINVAL. so
> sending the -EINVAL instead of ret variable value.
>
> Link to v1 - https://lore.kernel.org/all/20240427095643.11486-1-prosunofficial@gmail.com/#t
>
> drivers/media/i2c/st-mipid02.c | 37 +++++++++-------------------------
> 1 file changed, 9 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> index f250640729ca..bd3cf94f8534 100644
> --- a/drivers/media/i2c/st-mipid02.c
> +++ b/drivers/media/i2c/st-mipid02.c
> @@ -715,31 +715,28 @@ static int mipid02_parse_rx_ep(struct mipid02_dev *bridge)
> struct v4l2_fwnode_endpoint ep = { .bus_type = V4L2_MBUS_CSI2_DPHY };
> struct i2c_client *client = bridge->i2c_client;
> struct v4l2_async_connection *asd;
> - struct device_node *ep_node;
> int ret;
>
> /* parse rx (endpoint 0) */
> - ep_node = of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node,
> - 0, 0);
> + struct device_node *ep_node __free(device_node) =
> + of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node, 0, 0);
> if (!ep_node) {
> dev_err(&client->dev, "unable to find port0 ep");
> - ret = -EINVAL;
> - goto error;
> + return -EINVAL;
> }
>
> ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), &ep);
> if (ret) {
> dev_err(&client->dev, "Could not parse v4l2 endpoint %d\n",
> ret);
> - goto error_of_node_put;
> + return ret;
> }
>
> /* do some sanity checks */
> if (ep.bus.mipi_csi2.num_data_lanes > 2) {
> dev_err(&client->dev, "max supported data lanes is 2 / got %d",
> ep.bus.mipi_csi2.num_data_lanes);
> - ret = -EINVAL;
> - goto error_of_node_put;
> + return -EINVAL;
> }
>
> /* register it for later use */
> @@ -750,7 +747,6 @@ static int mipid02_parse_rx_ep(struct mipid02_dev *bridge)
> asd = v4l2_async_nf_add_fwnode_remote(&bridge->notifier,
> of_fwnode_handle(ep_node),
> struct v4l2_async_connection);
> - of_node_put(ep_node);
>
> if (IS_ERR(asd)) {
> dev_err(&client->dev, "fail to register asd to notifier %ld",
> @@ -764,46 +760,31 @@ static int mipid02_parse_rx_ep(struct mipid02_dev *bridge)
> v4l2_async_nf_cleanup(&bridge->notifier);
>
> return ret;
> -
> -error_of_node_put:
> - of_node_put(ep_node);
> -error:
> -
> - return ret;
> }
>
> static int mipid02_parse_tx_ep(struct mipid02_dev *bridge)
> {
> struct v4l2_fwnode_endpoint ep = { .bus_type = V4L2_MBUS_PARALLEL };
> struct i2c_client *client = bridge->i2c_client;
> - struct device_node *ep_node;
> int ret;
>
> /* parse tx (endpoint 2) */
> - ep_node = of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node,
> - 2, 0);
> + struct device_node *ep_node __free(device_node) =
> + of_graph_get_endpoint_by_regs(bridge->i2c_client->dev.of_node, 2, 0);
> if (!ep_node) {
> dev_err(&client->dev, "unable to find port1 ep");
> - ret = -EINVAL;
> - goto error;
> + return -EINVAL;
> }
>
> ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep_node), &ep);
> if (ret) {
> dev_err(&client->dev, "Could not parse v4l2 endpoint\n");
> - goto error_of_node_put;
> + return -EINVAL;
> }
>
> - of_node_put(ep_node);
> bridge->tx = ep;
>
> return 0;
> -
> -error_of_node_put:
> - of_node_put(ep_node);
> -error:
> -
> - return -EINVAL;
> }
>
> static int mipid02_probe(struct i2c_client *client)
--
Regards,
Benjamin
next prev parent reply other threads:[~2024-05-13 11:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 16:37 [PATCH v2 linux-next] media: i2c: st-mipid02: replace of_node_put() with __free R Sundar
2024-05-13 11:43 ` Benjamin Mugnier [this message]
2024-05-14 15:20 ` R Sundar
2024-05-15 13:47 ` Benjamin Mugnier
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=a688b2f2-d972-450a-9bec-2b506b58a21f@foss.st.com \
--to=benjamin.mugnier@foss.st.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=julia.lawall@inria.fr \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=prosunofficial@gmail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=skhan@linuxfoundation.org \
--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 read-only IMAP folder(s) and NNTP newsgroup(s).