lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 18 May 2015 19:25:27 +0300
From:	Daniel Baluta <daniel.baluta@...el.com>
To:	jic23@...nel.org, srinivas.pandruvada@...ux.intel.com
Cc:	knaack.h@....de, lars@...afoo.de, pmeerw@...erw.net,
	daniel.baluta@...el.com, linux-iio@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/2] iio: pm_runtime: Introduce PM runtime helper functions

We need this in order to avoid reimplementing the same functions each time
we add PM runtime support in a driver.

Simple grep shows the following users:
	* accel/mma9551.c
	* accel/mmc9553.c
	* accel/kxcjk1013.c
	* accel/bmc150-accel.c
	* gyro/bmg160.c
	* imu/kmx61.c
	* common/hid-sensors.

Signed-off-by: Daniel Baluta <daniel.baluta@...el.com>
---
 include/linux/iio/pm_runtime.h | 63 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 include/linux/iio/pm_runtime.h

diff --git a/include/linux/iio/pm_runtime.h b/include/linux/iio/pm_runtime.h
new file mode 100644
index 0000000..dc2bca7
--- /dev/null
+++ b/include/linux/iio/pm_runtime.h
@@ -0,0 +1,63 @@
+/*
+ * Industrial I/O runtime PM helper functions
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License.  See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ */
+#ifndef __IIO_PM_RUNTIME
+#define __IIO_PM_RUNTIME
+
+#include <linux/pm_runtime.h>
+
+static inline int iio_pm_runtime_setup(struct device *dev, int delay,
+				       bool ignore_children)
+{
+	int ret;
+
+	ret = pm_runtime_set_active(dev);
+	if (ret)
+		return ret;
+
+	pm_suspend_ignore_children(dev, ignore_children);
+	pm_runtime_enable(dev);
+	pm_runtime_set_autosuspend_delay(dev, delay);
+	pm_runtime_use_autosuspend(dev);
+
+	return 0;
+}
+
+static inline void iio_pm_runtime_cleanup(struct device *dev)
+{
+	pm_runtime_disable(dev);
+	pm_runtime_set_suspended(dev);
+	pm_runtime_put_noidle(dev);
+}
+
+static inline int iio_pm_runtime_set_power(struct device *dev, bool on)
+{
+#ifdef CONFIG_PM
+	int ret;
+
+	if (on)
+		ret = pm_runtime_get_sync(dev);
+	else {
+		pm_runtime_mark_last_busy(dev);
+		ret = pm_runtime_put_autosuspend(dev);
+	}
+
+	if (ret < 0) {
+		dev_err(dev, "Failed: iio_set_power_state for %d\n", on);
+		if (on)
+			pm_runtime_put_noidle(dev);
+
+		return ret;
+	}
+#endif
+	return 0;
+}
+
+#endif /* __IIO_PM_RUNTIME */
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ