From: Shem Multinymous <multinymous@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Robert Love <rlove@rlove.org>, Pavel Machek <pavel@suse.cz>,
Jean Delvare <khali@linux-fr.org>,
Greg Kroah-Hartman <gregkh@suse.de>,
Andrew Morton <akpm@osdl.org>,
hdaps-devel@lists.sourceforge.net
Subject: [PATCH 10/12] hdaps: Power off accelerometer on suspend and unload
Date: Thu, 10 Aug 2006 12:48:48 +0300 [thread overview]
Message-ID: <1155203398339-git-send-email-multinymous@gmail.com> (raw)
In-Reply-To: <1155203330179-git-send-email-multinymous@gmail.com>
This patch disables accelerometer power and stops its polling by the
embedded controller upon suspend and module unload. The power saving
is negligible, but it's the right thing to do.
Signed-off-by: Shem Multinymous <multinymous@gmail.com>
Signed-off-by: Pavel Machek <pavel@suse.cz>
---
drivers/hwmon/hdaps.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -373,6 +373,23 @@ good:
return ret;
}
+/**
+ * hdaps_device_shutdown - power off the accelerometer
+ * Returns nonzero on failure. Can sleep.
+ */
+static int hdaps_device_shutdown(void)
+{
+ int ret;
+ ret = hdaps_set_power(0);
+ if (ret) {
+ printk(KERN_WARNING "hdaps: cannot power off\n");
+ return ret;
+ }
+ ret = hdaps_set_ec_config(0, 1);
+ if (ret)
+ printk(KERN_WARNING "hdaps: cannot stop EC sampling\n");
+ return ret;
+}
/* Device model stuff */
@@ -388,6 +405,12 @@ static int hdaps_probe(struct platform_d
return 0;
}
+static int hdaps_suspend(struct platform_device *dev, pm_message_t state)
+{
+ hdaps_device_shutdown(); /* ignore errors, effect is negligible */
+ return 0;
+}
+
static int hdaps_resume(struct platform_device *dev)
{
return hdaps_device_init();
@@ -395,6 +418,7 @@ static int hdaps_resume(struct platform_
static struct platform_driver hdaps_driver = {
.probe = hdaps_probe,
+ .suspend = hdaps_suspend,
.resume = hdaps_resume,
.driver = {
.name = "hdaps",
@@ -776,6 +800,7 @@ out_device:
platform_device_unregister(pdev);
out_driver:
platform_driver_unregister(&hdaps_driver);
+ hdaps_device_shutdown();
out:
printk(KERN_WARNING "hdaps: driver init failed (ret=%d)!\n", ret);
return ret;
@@ -785,6 +810,7 @@ static void __exit hdaps_exit(void)
{
del_timer_sync(&hdaps_timer);
input_unregister_device(hdaps_idev);
+ hdaps_device_shutdown(); /* ignore errors, effect is negligible */
sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
platform_device_unregister(pdev);
platform_driver_unregister(&hdaps_driver);
next prev parent reply other threads:[~2006-08-10 9:56 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-10 9:48 [PATCH 00/12] ThinkPad embedded controller and hdaps drivers (version 2) Shem Multinymous
2006-08-10 9:48 ` [PATCH 01/12] thinkpad_ec: New driver for ThinkPad embedded controller access Shem Multinymous
2006-08-10 9:48 ` [PATCH 02/12] hdaps: Use thinkpad_ec instead of direct port access Shem Multinymous
2006-08-10 9:48 ` [PATCH 03/12] hdaps: Unify and cache hdaps readouts Shem Multinymous
2006-08-10 9:48 ` [PATCH 04/12] hdaps: Correct readout and remove nonsensical attributes Shem Multinymous
2006-08-10 9:48 ` [PATCH 05/12] hdaps: Remember keyboard and mouse activity Shem Multinymous
2006-08-10 9:48 ` [PATCH 06/12] hdaps: Limit hardware query rate Shem Multinymous
2006-08-10 21:26 ` Pavel Machek
2006-08-10 21:46 ` Evgeni Golov
2006-08-10 9:48 ` [PATCH 07/12] hdaps: delay calibration to first hardware query Shem Multinymous
2006-08-10 9:48 ` [PATCH 08/12] hdaps: Add explicit hardware configuration functions Shem Multinymous
2006-08-10 9:48 ` [PATCH 09/12] hdaps: Add new sysfs attributes Shem Multinymous
2006-08-10 9:48 ` Shem Multinymous [this message]
2006-08-10 9:48 ` [PATCH 11/12] hdaps: Stop polling timer when suspended Shem Multinymous
2006-08-10 9:48 ` [PATCH 12/12] hdaps: Simplify whitelist Shem Multinymous
2006-08-10 13:46 ` [PATCH 00/12] ThinkPad embedded controller and hdaps drivers (version 2) Robert Love
2006-08-10 19:53 ` Robert Love
2006-08-10 20:18 ` Andrew Morton
2006-08-10 20:37 ` Greg KH
2006-08-10 21:05 ` Jean Delvare
2006-08-10 23:11 ` Jesper Juhl
2006-08-11 1:38 ` Shem Multinymous
2006-08-11 0:01 ` Shem Multinymous
2006-08-10 22:52 ` Pavel Machek
2006-08-10 23:26 ` Shem Multinymous
-- strict thread matches above, loose matches on Subject: below --
2006-08-06 7:26 [PATCH 00/12] ThinkPad embedded controller and hdaps drivers Shem Multinymous
2006-08-06 7:26 ` [PATCH 10/12] hdaps: Power off accelerometer on suspend and unload Shem Multinymous
2006-08-08 12:45 ` Pavel Machek
2006-08-08 13:28 ` Shem Multinymous
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1155203398339-git-send-email-multinymous@gmail.com \
--to=multinymous@gmail.com \
--cc=akpm@osdl.org \
--cc=gregkh@suse.de \
--cc=hdaps-devel@lists.sourceforge.net \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pavel@suse.cz \
--cc=rlove@rlove.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox