From: Nicolas Boichat <nicolas@boichat.ch>
To: Dmitry Torokhov <dtor@insightbb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
rlove@rlove.org, linux-kernel@hansmi.ch
Subject: [lm-sensors] [PATCH] Apple SMC driver - fix input device
Date: Mon, 09 Apr 2007 13:53:32 +0000 [thread overview]
Message-ID: <461A455C.9040508@boichat.ch> (raw)
In-Reply-To: <200703221137.35906.dtor@insightbb.com>
Hi Dmitry,
Sorry I did not receive your message originally, someone else pointed it
to me recently, and I recovered it from LKML archives.
Dmitry Torokhov wrote:
> Hi Nicolas,
>
> On Monday 19 March 2007 01:19, Nicolas Boichat wrote:
>
>> + /* initialize the input class */
>> + applesmc_idev->name = "applesmc";
>>
>
> You may want to set applesmc_idev->id.bus = BUS_HOST;
>
>
>> + applesmc_idev->cdev.dev = &pdev->dev;
>> + applesmc_idev->evbit[0] = BIT(EV_ABS);
>> + input_set_abs_params(applesmc_idev, ABS_X,
>> + -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
>> + input_set_abs_params(applesmc_idev, ABS_Y,
>> + -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
>> +
>> + input_register_device(applesmc_idev);
>>
>
> Please add error hanling here.
>
>
>> +
>> + /* start up our timer for the input device */
>> + init_timer(&applesmc_timer);
>> + applesmc_timer.function = applesmc_mousedev_poll;
>> + applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
>> + add_timer(&applesmc_timer);
>>
>>
>
> Please consider implemention open and close methods for the input
> device and start/stop timer from there - there is no point of checking
> hardware state if noone is listening to events.
>
Fixed all these. Thanks.
Andrew, could you please push this patch in mm too?
Best regards,
Nicolas
- Invert y axis on input device.
- Only activate the input device polling timer when the device is open.
- Others minor fixes asked by Dmitry Torokhov.
Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
---
drivers/hwmon/applesmc.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 4060667..f7b59fc 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -349,9 +349,22 @@ static void applesmc_calibrate(void)
{
applesmc_read_motion_sensor(SENSOR_X, &rest_x);
applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
+ rest_x = -rest_x;
}
-static void applesmc_mousedev_poll(unsigned long unused)
+static int applesmc_idev_open(struct input_dev *dev)
+{
+ add_timer(&applesmc_timer);
+
+ return 0;
+}
+
+static void applesmc_idev_close(struct input_dev *dev)
+{
+ del_timer_sync(&applesmc_timer);
+}
+
+static void applesmc_idev_poll(unsigned long unused)
{
s16 x, y;
@@ -366,6 +379,7 @@ static void applesmc_mousedev_poll(unsigned long unused)
if (applesmc_read_motion_sensor(SENSOR_Y, &y))
goto out;
+ x = -x;
input_report_abs(applesmc_idev, ABS_X, x - rest_x);
input_report_abs(applesmc_idev, ABS_Y, y - rest_y);
input_sync(applesmc_idev);
@@ -739,23 +753,30 @@ static int applesmc_create_accelerometer(void)
/* initialize the input class */
applesmc_idev->name = "applesmc";
+ applesmc_idev->id.bustype = BUS_HOST;
applesmc_idev->cdev.dev = &pdev->dev;
applesmc_idev->evbit[0] = BIT(EV_ABS);
+ applesmc_idev->open = applesmc_idev_open;
+ applesmc_idev->close = applesmc_idev_close;
input_set_abs_params(applesmc_idev, ABS_X,
-256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
input_set_abs_params(applesmc_idev, ABS_Y,
-256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
- input_register_device(applesmc_idev);
+ ret = input_register_device(applesmc_idev);
+ if (ret)
+ goto out_idev;
/* start up our timer for the input device */
init_timer(&applesmc_timer);
- applesmc_timer.function = applesmc_mousedev_poll;
+ applesmc_timer.function = applesmc_idev_poll;
applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
- add_timer(&applesmc_timer);
return 0;
+out_idev:
+ input_free_device(applesmc_idev);
+
out:
printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
return ret;
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Boichat <nicolas@boichat.ch>
To: Dmitry Torokhov <dtor@insightbb.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
rlove@rlove.org, linux-kernel@hansmi.ch
Subject: [PATCH] Apple SMC driver - fix input device
Date: Mon, 09 Apr 2007 21:53:32 +0800 [thread overview]
Message-ID: <461A455C.9040508@boichat.ch> (raw)
In-Reply-To: <200703221137.35906.dtor@insightbb.com>
Hi Dmitry,
Sorry I did not receive your message originally, someone else pointed it
to me recently, and I recovered it from LKML archives.
Dmitry Torokhov wrote:
> Hi Nicolas,
>
> On Monday 19 March 2007 01:19, Nicolas Boichat wrote:
>
>> + /* initialize the input class */
>> + applesmc_idev->name = "applesmc";
>>
>
> You may want to set applesmc_idev->id.bus = BUS_HOST;
>
>
>> + applesmc_idev->cdev.dev = &pdev->dev;
>> + applesmc_idev->evbit[0] = BIT(EV_ABS);
>> + input_set_abs_params(applesmc_idev, ABS_X,
>> + -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
>> + input_set_abs_params(applesmc_idev, ABS_Y,
>> + -256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
>> +
>> + input_register_device(applesmc_idev);
>>
>
> Please add error hanling here.
>
>
>> +
>> + /* start up our timer for the input device */
>> + init_timer(&applesmc_timer);
>> + applesmc_timer.function = applesmc_mousedev_poll;
>> + applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
>> + add_timer(&applesmc_timer);
>>
>>
>
> Please consider implemention open and close methods for the input
> device and start/stop timer from there - there is no point of checking
> hardware state if noone is listening to events.
>
Fixed all these. Thanks.
Andrew, could you please push this patch in mm too?
Best regards,
Nicolas
- Invert y axis on input device.
- Only activate the input device polling timer when the device is open.
- Others minor fixes asked by Dmitry Torokhov.
Signed-off-by: Nicolas Boichat <nicolas@boichat.ch>
---
drivers/hwmon/applesmc.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index 4060667..f7b59fc 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -349,9 +349,22 @@ static void applesmc_calibrate(void)
{
applesmc_read_motion_sensor(SENSOR_X, &rest_x);
applesmc_read_motion_sensor(SENSOR_Y, &rest_y);
+ rest_x = -rest_x;
}
-static void applesmc_mousedev_poll(unsigned long unused)
+static int applesmc_idev_open(struct input_dev *dev)
+{
+ add_timer(&applesmc_timer);
+
+ return 0;
+}
+
+static void applesmc_idev_close(struct input_dev *dev)
+{
+ del_timer_sync(&applesmc_timer);
+}
+
+static void applesmc_idev_poll(unsigned long unused)
{
s16 x, y;
@@ -366,6 +379,7 @@ static void applesmc_mousedev_poll(unsigned long unused)
if (applesmc_read_motion_sensor(SENSOR_Y, &y))
goto out;
+ x = -x;
input_report_abs(applesmc_idev, ABS_X, x - rest_x);
input_report_abs(applesmc_idev, ABS_Y, y - rest_y);
input_sync(applesmc_idev);
@@ -739,23 +753,30 @@ static int applesmc_create_accelerometer(void)
/* initialize the input class */
applesmc_idev->name = "applesmc";
+ applesmc_idev->id.bustype = BUS_HOST;
applesmc_idev->cdev.dev = &pdev->dev;
applesmc_idev->evbit[0] = BIT(EV_ABS);
+ applesmc_idev->open = applesmc_idev_open;
+ applesmc_idev->close = applesmc_idev_close;
input_set_abs_params(applesmc_idev, ABS_X,
-256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
input_set_abs_params(applesmc_idev, ABS_Y,
-256, 256, APPLESMC_INPUT_FUZZ, APPLESMC_INPUT_FLAT);
- input_register_device(applesmc_idev);
+ ret = input_register_device(applesmc_idev);
+ if (ret)
+ goto out_idev;
/* start up our timer for the input device */
init_timer(&applesmc_timer);
- applesmc_timer.function = applesmc_mousedev_poll;
+ applesmc_timer.function = applesmc_idev_poll;
applesmc_timer.expires = jiffies + APPLESMC_POLL_PERIOD;
- add_timer(&applesmc_timer);
return 0;
+out_idev:
+ input_free_device(applesmc_idev);
+
out:
printk(KERN_WARNING "applesmc: driver init failed (ret=%d)!\n", ret);
return ret;
next prev parent reply other threads:[~2007-04-09 13:53 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-14 9:29 [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring and Nicolas Boichat
2007-03-14 9:29 ` [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Nicolas Boichat
2007-03-14 11:11 ` Cong WANG
2007-03-14 14:00 ` Cong WANG
2007-03-15 11:31 ` Nicolas Boichat
2007-03-19 5:19 ` [lm-sensors] [PATCH] Apple SMC driver (hardware monitoring and Nicolas Boichat
2007-03-19 5:19 ` [PATCH] Apple SMC driver (hardware monitoring and control) Nicolas Boichat
2007-03-19 6:54 ` [lm-sensors] [PATCH] Apple SMC driver (hardware monitoring and Andrew Morton
2007-03-19 6:54 ` [PATCH] Apple SMC driver (hardware monitoring and control) Andrew Morton
2007-03-19 7:35 ` [lm-sensors] [PATCH] Apple SMC driver (hardware monitoring and Nicolas Boichat
2007-03-19 7:35 ` [PATCH] Apple SMC driver (hardware monitoring and control) Nicolas Boichat
2007-03-20 7:12 ` [lm-sensors] [PATCH] Apple SMC driver (hardware monitoring and Nicolas Boichat
2007-03-20 7:12 ` [PATCH] Apple SMC driver (hardware monitoring and control) Nicolas Boichat
2007-03-22 15:37 ` [lm-sensors] [PATCH] Apple SMC driver (hardware monitoring and Dmitry Torokhov
2007-03-22 15:37 ` [PATCH] Apple SMC driver (hardware monitoring and control) Dmitry Torokhov
2007-04-09 13:53 ` Nicolas Boichat [this message]
2007-04-09 13:53 ` [PATCH] Apple SMC driver - fix input device Nicolas Boichat
2007-04-09 15:17 ` [lm-sensors] " Dmitry Torokhov
2007-04-09 15:17 ` Dmitry Torokhov
2007-04-09 20:04 ` [lm-sensors] " Andrew Morton
2007-04-09 20:04 ` Andrew Morton
2007-04-09 20:11 ` [lm-sensors] " Dmitry Torokhov
2007-04-09 20:11 ` Dmitry Torokhov
2007-04-09 21:51 ` [lm-sensors] " Paul Mackerras
2007-04-09 21:51 ` Paul Mackerras
2007-03-19 21:43 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring Bob Copeland
2007-03-19 21:43 ` [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Bob Copeland
2007-03-20 7:02 ` Nicolas Boichat
2007-03-20 15:14 ` Bob Copeland
2007-03-21 4:03 ` Bob Copeland
[not found] ` <eb4a44160703200016i74786682n41f87f3d88f90409@mail.gmail.com>
2007-04-14 8:05 ` [PATCH] applesmc - fix crash when activating a led trigger on the keyboard backlight Nicolas Boichat
2007-04-14 8:45 ` Richard Purdie
2007-04-14 13:31 ` [PATCH] applesmc - fix crash when activating a led trigger on the keyboard backlight - use a workqueue Nicolas Boichat
2007-03-20 10:08 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring Jean Delvare
2007-03-20 10:08 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Jean Delvare
2007-03-22 10:36 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring Nicolas Boichat
2007-03-22 10:36 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Nicolas Boichat
2007-03-20 16:12 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring Gerb Stralko
2007-03-20 16:12 ` [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Gerb Stralko
2007-04-11 12:25 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring Jean Delvare
2007-04-11 12:25 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Jean Delvare
2007-04-11 12:47 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring Nicolas Boichat
2007-04-11 12:47 ` [lm-sensors] [RFC][PATCH] Apple SMC driver (hardware monitoring and control) Nicolas Boichat
2007-04-13 5:33 ` [lm-sensors] [PATCH 1/2] Apple SMC driver - standardize and Nicolas Boichat
2007-04-13 5:33 ` [PATCH 1/2] Apple SMC driver - standardize and sanitize sysfs tree + minor features addition Nicolas Boichat
2007-04-13 6:38 ` [lm-sensors] [PATCH 2/2] Apple SMC driver - implement key Nicolas Boichat
2007-04-13 6:38 ` [PATCH 2/2] Apple SMC driver - implement key enumeration Nicolas Boichat
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=461A455C.9040508@boichat.ch \
--to=nicolas@boichat.ch \
--cc=akpm@linux-foundation.org \
--cc=dtor@insightbb.com \
--cc=linux-kernel@hansmi.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--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 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.