Re: [PATCH v9 2/4] media: i2c: Add MAX9286 driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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().

--
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



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux