mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
Cc: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: Re: [RFC 04/12] staging: media: max96712: change DT parsing routine
Date: Sat, 1 Feb 2025 13:30:48 +0300	[thread overview]
Message-ID: <e2b7b98d-fb16-497e-9102-ba49e04e1748@stanley.mountain> (raw)
In-Reply-To: <20250131163408.2019144-5-laurentiu.palcu@oss.nxp.com>

On Fri, Jan 31, 2025 at 06:33:58PM +0200, Laurentiu Palcu wrote:
> -static int max96712_parse_dt(struct max96712_priv *priv)
> +static int max96712_parse_rx_ports(struct max96712_priv *priv, struct device_node *node,
> +				   struct of_endpoint *ep)
> +{
> +	struct device *dev = &priv->client->dev;
> +	struct max96712_rx_port *source;
> +	struct fwnode_handle *remote_port_parent;
> +
> +	if (priv->rx_ports[ep->port].fwnode) {
> +		dev_info(dev, "Multiple port endpoints are not supported: %d", ep->port);
> +		return 0;
> +	}
> +
> +	source = &priv->rx_ports[ep->port];
> +	source->fwnode = fwnode_graph_get_remote_endpoint(of_fwnode_handle(node));
> +	if (!source->fwnode) {
> +		dev_info(dev, "Endpoint %pOF has no remote endpoint connection\n", ep->local_node);
> +		return 0;
> +	}
> +
> +	remote_port_parent = fwnode_graph_get_remote_port_parent(of_fwnode_handle(node));
> +
> +	if (!fwnode_device_is_available(remote_port_parent)) {
> +		dev_dbg(dev, "Skipping port %d as remote port parent is disabled.\n",
> +			ep->port);
> +		source->fwnode = NULL;

I don't understand the refcounting in this function.  Should we call
fwnode_handle_put(source->fwnode); before setting this to NULL?

> +		goto fwnode_put;
> +	}
> +
> +	priv->rx_port_mask |= BIT(ep->port);
> +	priv->n_rx_ports++;
> +
> +fwnode_put:
> +	fwnode_handle_put(remote_port_parent);
> +	fwnode_handle_put(source->fwnode);
> +	return 0;

I don't understand why we save source->fwnode but drop the refcount on
the success path.  My instinct says that it should be a source_fwnode
local stack variable instead.  (But again, I've only glanced at this
code so I could be wrong).


> +}
> +

regards,
dan carpenter


  reply	other threads:[~2025-02-01 10:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-31 16:33 [RFC 00/12] staging: media: max96712: Add support for streams and multiple sensors Laurentiu Palcu
2025-01-31 16:33 ` [RFC 01/12] media: mc: Add INTERNAL pad flag Laurentiu Palcu
2025-01-31 16:33 ` [RFC 02/12] dt-bindings: i2c: maxim,max96712: add a couple of new properties Laurentiu Palcu
2025-02-03 22:00   ` Rob Herring
2025-01-31 16:33 ` [RFC 03/12] staging: media: max96712: convert to using CCI register access helpers Laurentiu Palcu
2025-01-31 16:33 ` [RFC 04/12] staging: media: max96712: change DT parsing routine Laurentiu Palcu
2025-02-01 10:30   ` Dan Carpenter [this message]
2025-01-31 16:33 ` [RFC 05/12] staging: media: max96712: add link frequency V4L2 control Laurentiu Palcu
2025-01-31 16:34 ` [RFC 06/12] staging: media: max96712: add I2C mux support Laurentiu Palcu
2025-01-31 16:34 ` [RFC 07/12] staging: media: max96712: add support for streams Laurentiu Palcu
2025-01-31 16:34 ` [RFC 08/12] staging: media: max96712: allow enumerating MBUS codes Laurentiu Palcu
2025-01-31 16:34 ` [RFC 09/12] staging: media: max96712: add set_fmt routine Laurentiu Palcu
2025-01-31 16:34 ` [RFC 10/12] staging: media: max96712: add gpiochip functionality Laurentiu Palcu
2025-02-06 18:40   ` Linus Walleij
2025-01-31 16:34 ` [RFC 11/12] staging: media: max96712: add fsync support Laurentiu Palcu
2025-01-31 16:34 ` [RFC 12/12] staging: media: max96712: allow streaming from connected sensors Laurentiu Palcu
2025-02-04 12:39 ` [RFC 00/12] staging: media: max96712: Add support for streams and multiple sensors Niklas Söderlund
2025-02-04 13:37   ` Laurentiu Palcu

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=e2b7b98d-fb16-497e-9102-ba49e04e1748@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurentiu.palcu@oss.nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    /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®