On Thu 08 Apr 23:39 CDT 2021, Deepak Kumar Singh wrote:
[..]
+/**I was expecting that the devres allocated struct qmp would stick around
+ * 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);
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