sensor->ops->resume(sensor->client);\r
}\r
#endif\r
-\r
+
+#ifdef CONFIG_PM
+static int sensor_of_suspend(struct device *dev)
+{
+ struct sensor_private_data *sensor = dev_get_drvdata(dev);
+
+ if (sensor->ops->suspend)
+ sensor->ops->suspend(sensor->client);
+
+ return 0;
+}
+
+static int sensor_of_resume(struct device *dev)
+{
+ struct sensor_private_data *sensor = dev_get_drvdata(dev);
+
+ if (sensor->ops->resume)
+ sensor->ops->resume(sensor->client);
+ if (sensor->pdata->power_off_in_suspend)
+ sensor_initial(sensor->client);
+
+ return 0;
+}
+
+static const struct dev_pm_ops sensor_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(sensor_of_suspend, sensor_of_resume)
+};
+
+#define SENSOR_PM_OPS (&sensor_pm_ops)
+#else
+#define SENSOR_PM_OPS NULL
+#endif
+
static int angle_dev_open(struct inode *inode, struct file *file)\r
{\r
//struct sensor_private_data *sensor = g_sensor[SENSOR_TYPE_ACCEL]; \r
\r
of_property_read_u8(np,"address",&(pdata->address));\r
of_get_property(np, "project_name", pdata->project_name);\r
-\r
+
+ of_property_read_u32(np, "power-off-in-suspend",
+ &pdata->power_off_in_suspend);
\r
switch(pdata->layout)\r
{\r
.remove = sensor_remove,\r
.shutdown = sensor_shut_down,\r
.id_table = sensor_id,\r
- .driver = {\r
- .owner = THIS_MODULE,\r
- .name = "sensors",\r
- .of_match_table = of_match_ptr(sensor_dt_ids),\r
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "sensors",
+ .of_match_table = of_match_ptr(sensor_dt_ids),
+ .pm = SENSOR_PM_OPS,
},\r
};\r
\r