All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Kosina <jkosina@suse.cz>
To: Eric Piel <eric.piel@tremplin-utc.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Samu Onkalo <samu.p.onkalo@nokia.com>,
	Pavel Machek <pavel@ucw.cz>
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
	Marcin Derlukiewicz <marcin@derlukiewicz.pl>
Subject: [PATCH] lis3lv02d: provide means to disable polled input interface
Date: Fri, 9 Apr 2010 14:56:18 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1004091453530.8345@pobox.suse.cz> (raw)

lis3lv02d driver creates emulated joystick interface for events reported 
by the sensor.
Because of HW, this has to be implemented as polled input device, with
20Hz frequency.

This is reported to create 20% CPU usage increase (and proportionaly higher
power consumption) just for the ipolldevd kernel thread (which is used
to read the sensor).

As most users probably only use the freefall functionality of the driver
and not the joystick interface, provide means for disabling the registration
of joystick device altogether via module parameter.
(I'd rather make it default to 0, but this will break backwards compatibility).

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

--- 
 drivers/hwmon/lis3lv02d.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index b2f2277..bfbc02c 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -41,6 +41,9 @@
 
 /* joystick device poll interval in milliseconds */
 #define MDPS_POLL_INTERVAL 50
+static int enable_joystick = 1;
+module_param_named(joystick, enable_joystick, int, 0400);
+MODULE_PARM_DESC(joystick, "Enable joystick emulation (0 = disable, 1 = enable). Default: 1");
 /*
  * The sensor can also generate interrupts (DRDY) but it's pretty pointless
  * because they are generated even if the data do not change. So it's better
@@ -434,14 +437,13 @@ EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable);
 
 void lis3lv02d_joystick_disable(void)
 {
-	if (!lis3_dev.idev)
-		return;
-
 	if (lis3_dev.irq)
 		misc_deregister(&lis3lv02d_misc_device);
-	input_unregister_polled_device(lis3_dev.idev);
-	input_free_polled_device(lis3_dev.idev);
-	lis3_dev.idev = NULL;
+	if (lis3_dev.idev) {
+		input_unregister_polled_device(lis3_dev.idev);
+		input_free_polled_device(lis3_dev.idev);
+		lis3_dev.idev = NULL;
+	}
 }
 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable);
 
@@ -559,7 +561,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
 	lis3lv02d_add_fs(dev);
 	lis3lv02d_poweron(dev);
 
-	if (lis3lv02d_joystick_enable())
+	if (enable_joystick && lis3lv02d_joystick_enable())
 		printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n");
 
 	/* passing in platform specific data is purely optional and only

WARNING: multiple messages have this Message-ID (diff)
From: Jiri Kosina <jkosina@suse.cz>
To: Eric Piel <eric.piel@tremplin-utc.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Samu Onkalo <samu.p.onkalo@nokia.com>,
	Pavel Machek <pavel@ucw.cz>
Cc: lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
	Marcin Derlukiewicz <marcin@derlukiewicz.pl>
Subject: [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled
Date: Fri, 09 Apr 2010 12:56:18 +0000	[thread overview]
Message-ID: <alpine.LNX.2.00.1004091453530.8345@pobox.suse.cz> (raw)

lis3lv02d driver creates emulated joystick interface for events reported 
by the sensor.
Because of HW, this has to be implemented as polled input device, with
20Hz frequency.

This is reported to create 20% CPU usage increase (and proportionaly higher
power consumption) just for the ipolldevd kernel thread (which is used
to read the sensor).

As most users probably only use the freefall functionality of the driver
and not the joystick interface, provide means for disabling the registration
of joystick device altogether via module parameter.
(I'd rather make it default to 0, but this will break backwards compatibility).

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

--- 
 drivers/hwmon/lis3lv02d.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index b2f2277..bfbc02c 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -41,6 +41,9 @@
 
 /* joystick device poll interval in milliseconds */
 #define MDPS_POLL_INTERVAL 50
+static int enable_joystick = 1;
+module_param_named(joystick, enable_joystick, int, 0400);
+MODULE_PARM_DESC(joystick, "Enable joystick emulation (0 = disable, 1 = enable). Default: 1");
 /*
  * The sensor can also generate interrupts (DRDY) but it's pretty pointless
  * because they are generated even if the data do not change. So it's better
@@ -434,14 +437,13 @@ EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable);
 
 void lis3lv02d_joystick_disable(void)
 {
-	if (!lis3_dev.idev)
-		return;
-
 	if (lis3_dev.irq)
 		misc_deregister(&lis3lv02d_misc_device);
-	input_unregister_polled_device(lis3_dev.idev);
-	input_free_polled_device(lis3_dev.idev);
-	lis3_dev.idev = NULL;
+	if (lis3_dev.idev) {
+		input_unregister_polled_device(lis3_dev.idev);
+		input_free_polled_device(lis3_dev.idev);
+		lis3_dev.idev = NULL;
+	}
 }
 EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable);
 
@@ -559,7 +561,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
 	lis3lv02d_add_fs(dev);
 	lis3lv02d_poweron(dev);
 
-	if (lis3lv02d_joystick_enable())
+	if (enable_joystick && lis3lv02d_joystick_enable())
 		printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n");
 
 	/* passing in platform specific data is purely optional and only

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

             reply	other threads:[~2010-04-09 12:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09 12:56 Jiri Kosina [this message]
2010-04-09 12:56 ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Jiri Kosina
2010-04-09 13:29 ` [PATCH] lis3lv02d: provide means to disable polled input interface Éric Piel
2010-04-09 13:29   ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Éric Piel
2010-04-09 13:32   ` [PATCH] lis3lv02d: provide means to disable polled input interface Jiri Kosina
2010-04-09 13:32     ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Jiri Kosina
2010-04-09 18:11     ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled input interface Jean Delvare
2010-04-09 18:11       ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Jean Delvare
2010-04-16 11:41     ` [PATCH] lis3lv02d: provide means to disable polled input interface Marcin Derlukiewicz
2010-04-16 11:41       ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Marcin Derlukiewicz
2010-04-16 12:00       ` [PATCH] lis3lv02d: provide means to disable polled input interface samu.p.onkalo
2010-04-16 12:00         ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled samu.p.onkalo
2010-04-16 12:13         ` [PATCH] lis3lv02d: provide means to disable polled input interface Marcin Derlukiewicz
2010-04-16 12:13           ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Marcin Derlukiewicz
2010-04-16 13:56           ` [PATCH] lis3lv02d: provide means to disable polled input interface Éric Piel
2010-04-16 13:56             ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Éric Piel
2010-04-16 14:26             ` [PATCH] lis3lv02d: provide means to disable polled input interface Marcin Derlukiewicz
2010-04-16 14:26               ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Marcin Derlukiewicz
2010-04-16 14:30               ` [PATCH] lis3lv02d: provide means to disable polled input interface Éric Piel
2010-04-16 14:30                 ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Éric Piel
2010-04-16 12:06       ` [PATCH] lis3lv02d: provide means to disable polled input interface Éric Piel
2010-04-16 12:06         ` [lm-sensors] [PATCH] lis3lv02d: provide means to disable polled Éric Piel
2010-04-09 21:41   ` [PATCH] lis3lv02d: provide means to disable polled input interface Frans Pop

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=alpine.LNX.2.00.1004091453530.8345@pobox.suse.cz \
    --to=jkosina@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=eric.piel@tremplin-utc.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=marcin@derlukiewicz.pl \
    --cc=pavel@ucw.cz \
    --cc=samu.p.onkalo@nokia.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.