lkml.org 
[lkml]   [2020]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v9 2/4] media: i2c: Add MAX9286 driver
On Thu, May 14, 2020 at 01:27:01PM +0100, Kieran Bingham wrote:
> Hi Mani,
>
> On 14/05/2020 12:47, Kieran Bingham wrote:
> > On 14/05/2020 11:13, Manivannan Sadhasivam wrote:
> >> Hi Kieran,
> <snip>
>
> >>>>> +static int max9286_parse_dt(struct max9286_priv *priv)
> >>>>> +{
> >>>>> + struct device *dev = &priv->client->dev;
> >>>>> + struct device_node *i2c_mux;
> >>>>> + struct device_node *node = NULL;
> >>>>> + unsigned int i2c_mux_mask = 0;
> >>>>> +
> >>>>> + of_node_get(dev->of_node);
> >>>>
> >>>> Why this is needed?
> >>>
> >>> Hrm .. I recall adding it to solve dt reference balancing.
> >>>
> >>> I wish I'd added a comment at the time ... as I can't recall the details
> >>> now.
> >>>
> >>
> >> I understand that it is for the refcount balancing but I certainly don't see
> >> a need for it.
> >
> > I'll go through and try to validate this again now.
>
> Aha, that's why:
>
> * of_find_node_by_name - Find a node by its "name" property
> * @from: The node to start searching from or NULL; the node
> * you pass will not be searched, only the next one
> * will. Typically, you pass what the previous call
> * returned. of_node_put() will be called on @from.
> * @name: The name string to match against
>
> I'll add a comment to state that it is to balance the of_node_put during
> of_find_node_by_name().
>

Ah, right. I mostly use of_find_node_by_name() with NULL, so didn't realize
this.

And yeah, a comment would be helpful.

Thanks,
Mani

> --
> Kieran
>
>
> >>>>> + i2c_mux = of_find_node_by_name(dev->of_node, "i2c-mux");
> >>>>> + if (!i2c_mux) {
> >>>>> + dev_err(dev, "Failed to find i2c-mux node\n");
> >>>>> + of_node_put(dev->of_node);
> >>>>> + return -EINVAL;
> >>>>> + }
> >>>>> +
> >> [...]
> >>>>
> --
> Regards
> --
> Kieran

\
 
 \ /
  Last update: 2020-05-14 14:55    [W:0.061 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site