[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1551418672-12822-3-git-send-email-parav@mellanox.com>
Date: Thu, 28 Feb 2019 23:37:46 -0600
From: Parav Pandit <parav@...lanox.com>
To: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
michal.lkml@...kovi.net, davem@...emloft.net,
gregkh@...uxfoundation.org, jiri@...lanox.com
Cc: parav@...lanox.com
Subject: [RFC net-next 2/8] subdev: Introduce pm callbacks
Keep power management callbacks in place to optionally notify drivers
who register them.
Signed-off-by: Parav Pandit <parav@...lanox.com>
---
drivers/subdev/subdev_main.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/drivers/subdev/subdev_main.c b/drivers/subdev/subdev_main.c
index 4aabcaa..e213331 100644
--- a/drivers/subdev/subdev_main.c
+++ b/drivers/subdev/subdev_main.c
@@ -23,10 +23,69 @@ static int subdev_bus_match(struct device *dev, struct device_driver *drv)
return 0;
}
+static int subdev_pm_prepare(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->prepare)
+ return dev->driver->pm->prepare(dev);
+ return 0;
+}
+
+static void subdev_pm_complete(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->complete)
+ dev->driver->pm->complete(dev);
+}
+
+static int subdev_pm_suspend(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->suspend)
+ return dev->driver->pm->suspend(dev);
+ return 0;
+}
+
+static int subdev_pm_suspend_late(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->suspend_late)
+ return dev->driver->pm->suspend_late(dev);
+ return 0;
+}
+
+static int subdev_pm_resume(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->resume)
+ return dev->driver->pm->resume(dev);
+ return 0;
+}
+
+static int subdev_pm_freeze(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->freeze)
+ return dev->driver->pm->freeze(dev);
+ return 0;
+}
+
+static int subdev_pm_freeze_late(struct device *dev)
+{
+ if (dev->driver->pm && dev->driver->pm->freeze_late)
+ return dev->driver->pm->freeze_late(dev);
+ return 0;
+}
+
+static const struct dev_pm_ops subdev_dev_pm_ops = {
+ .prepare = subdev_pm_prepare,
+ .complete = subdev_pm_complete,
+ .suspend = subdev_pm_suspend,
+ .suspend_late = subdev_pm_suspend_late,
+ .resume = subdev_pm_resume,
+ .freeze = subdev_pm_freeze,
+ .freeze_late = subdev_pm_freeze_late,
+};
+
static struct bus_type subdev_bus_type = {
.dev_name = "subdev",
.name = "subdev",
.match = subdev_bus_match,
+ .pm = &subdev_dev_pm_ops,
};
int __subdev_register_driver(struct subdev_driver *drv, struct module *owner,
--
1.8.3.1
Powered by blists - more mailing lists