@@ -1401,9 +1401,15 @@ static int platform_probe(struct device *_dev)
goto out;
if (drv->probe) {
+ dev->devres_group_id = devres_open_group(&dev->dev, NULL, GFP_KERNEL);
+ if (!dev->devres_group_id)
+ return -ENOMEM;
+
ret = drv->probe(dev);
- if (ret)
+ if (ret) {
+ devres_close_group(&dev->dev, dev->devres_group_id);
dev_pm_domain_detach(_dev, true);
+ }
}
out:
@@ -1422,6 +1428,8 @@ static void platform_remove(struct device *_dev)
if (drv->remove)
drv->remove(dev);
+ if (dev->devres_group_id)
+ devres_release_group(&dev->dev, dev->devres_group_id);
dev_pm_domain_detach(_dev, true);
}
@@ -40,6 +40,9 @@ struct platform_device {
/* MFD cell pointer */
struct mfd_cell *mfd_cell;
+ /* ID of the probe devres group. */
+ void *devres_group_id;
+
/* arch specific additions */
struct pdev_archdata archdata;
};