Re: [PATCH V2 1/2] soc: qcom: aoss: Expose send for generic usecase

Deepak Kumar Singh
2021-05-05T07:44:22Z

On 4/14/2021 2:42 AM, Bjorn Andersson wrote:
> On Thu 08 Apr 23:39 CDT 2021, Deepak Kumar Singh wrote:
> [..]
>> +/**
>> + * qmp_get() - get a qmp handle from a device
>> + * @dev: client device pointer
>> + *
>> + * Return: handle to qmp device on success, ERR_PTR() on failure
>> + */
>> +struct qmp *qmp_get(struct device *dev)
>> +{
>> + struct platform_device *pdev;
>> + struct device_node *np;
>> + struct qmp *qmp;
>> +
>> + if (!dev || !dev->of_node)
>> + return ERR_PTR(-EINVAL);
>> +
>> + np = of_parse_phandle(dev->of_node, "qcom,qmp", 0);
>> + if (!np)
>> + return ERR_PTR(-ENODEV);
>> +
>> + pdev = of_find_device_by_node(np);
>> + if (!pdev)
>> + return ERR_PTR(-EINVAL);
>> +
>> + qmp = platform_get_drvdata(pdev);
>> + return qmp ? qmp : ERR_PTR(-EPROBE_DEFER);
>> +}
>> +EXPORT_SYMBOL(qmp_get);
>> +
>> +void qmp_put(struct platform_device *pdev)
>> +{
>> + platform_device_put(pdev);
> I was expecting that the devres allocated struct qmp would stick around
> until the struct device's release callback came. As described in my
> answer to Mani yesterday I was wrong.
>
> As such you need to make sure that struct qmp stays around until
> qmp_remove() and all qmp_put() calls has been made.
>
> I presume a reasonable way to achieve this is to not use devm to
> allocate our struct qmp, add a kref to the object. So this would have to
> be a kref_put() on that instead of the platform_device_put() I asked you
> to implement here.
>
> Sorry about that.
>
>
> The rest of the patch looks good.
>
> Regards,
> Bjorn

Hi Bjorn,

Even if we use kref_put(), would it not require platform_device_put()?
As per my understanding of_find_device_by_node(np) will increment
node/pdev kobj refcount which both needs to be decremented.