diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2012-06-20 12:00:06 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:44 -0400 |
commit | edf48f3a73b027a99c92edab2b07d78fe77523cc (patch) | |
tree | 851d43702f41fec315f4c0704d71300c8264bffc /drivers/hwmon/applesmc.c | |
parent | 0ef63e48f0247a9f9b9ffeef0f2641ac880728ab (diff) |
hwmon: (applesmc) Skip sensor mapping
The special motion sensor mapping is unnecessary; remove it.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/applesmc.c')
-rw-r--r-- | drivers/hwmon/applesmc.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c index 2cde9ecf7731..0162f5527805 100644 --- a/drivers/hwmon/applesmc.c +++ b/drivers/hwmon/applesmc.c | |||
@@ -96,10 +96,6 @@ static const char *const fan_speed_fmt[] = { | |||
96 | #define APPLESMC_INPUT_FUZZ 4 /* input event threshold */ | 96 | #define APPLESMC_INPUT_FUZZ 4 /* input event threshold */ |
97 | #define APPLESMC_INPUT_FLAT 4 | 97 | #define APPLESMC_INPUT_FLAT 4 |
98 | 98 | ||
99 | #define SENSOR_X 0 | ||
100 | #define SENSOR_Y 1 | ||
101 | #define SENSOR_Z 2 | ||
102 | |||
103 | #define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff) | 99 | #define to_index(attr) (to_sensor_dev_attr(attr)->index & 0xffff) |
104 | #define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16) | 100 | #define to_option(attr) (to_sensor_dev_attr(attr)->index >> 16) |
105 | 101 | ||
@@ -432,30 +428,19 @@ static int applesmc_has_key(const char *key, bool *value) | |||
432 | } | 428 | } |
433 | 429 | ||
434 | /* | 430 | /* |
435 | * applesmc_read_motion_sensor - Read motion sensor (X, Y or Z). | 431 | * applesmc_read_s16 - Read 16-bit signed big endian register |
436 | */ | 432 | */ |
437 | static int applesmc_read_motion_sensor(int index, s16 *value) | 433 | static int applesmc_read_s16(const char *key, s16 *value) |
438 | { | 434 | { |
439 | u8 buffer[2]; | 435 | u8 buffer[2]; |
440 | int ret; | 436 | int ret; |
441 | 437 | ||
442 | switch (index) { | 438 | ret = applesmc_read_key(key, buffer, 2); |
443 | case SENSOR_X: | 439 | if (ret) |
444 | ret = applesmc_read_key(MOTION_SENSOR_X_KEY, buffer, 2); | 440 | return ret; |
445 | break; | ||
446 | case SENSOR_Y: | ||
447 | ret = applesmc_read_key(MOTION_SENSOR_Y_KEY, buffer, 2); | ||
448 | break; | ||
449 | case SENSOR_Z: | ||
450 | ret = applesmc_read_key(MOTION_SENSOR_Z_KEY, buffer, 2); | ||
451 | break; | ||
452 | default: | ||
453 | ret = -EINVAL; | ||
454 | } | ||
455 | 441 | ||
456 | *value = ((s16)buffer[0] << 8) | buffer[1]; | 442 | *value = ((s16)buffer[0] << 8) | buffer[1]; |
457 | 443 | return 0; | |
458 | return ret; | ||
459 | } | 444 | } |
460 | 445 | ||
461 | /* | 446 | /* |
@@ -624,8 +609,8 @@ static struct platform_driver applesmc_driver = { | |||
624 | */ | 609 | */ |
625 | static void applesmc_calibrate(void) | 610 | static void applesmc_calibrate(void) |
626 | { | 611 | { |
627 | applesmc_read_motion_sensor(SENSOR_X, &rest_x); | 612 | applesmc_read_s16(MOTION_SENSOR_X_KEY, &rest_x); |
628 | applesmc_read_motion_sensor(SENSOR_Y, &rest_y); | 613 | applesmc_read_s16(MOTION_SENSOR_Y_KEY, &rest_y); |
629 | rest_x = -rest_x; | 614 | rest_x = -rest_x; |
630 | } | 615 | } |
631 | 616 | ||
@@ -634,9 +619,9 @@ static void applesmc_idev_poll(struct input_polled_dev *dev) | |||
634 | struct input_dev *idev = dev->input; | 619 | struct input_dev *idev = dev->input; |
635 | s16 x, y; | 620 | s16 x, y; |
636 | 621 | ||
637 | if (applesmc_read_motion_sensor(SENSOR_X, &x)) | 622 | if (applesmc_read_s16(MOTION_SENSOR_X_KEY, &x)) |
638 | return; | 623 | return; |
639 | if (applesmc_read_motion_sensor(SENSOR_Y, &y)) | 624 | if (applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y)) |
640 | return; | 625 | return; |
641 | 626 | ||
642 | x = -x; | 627 | x = -x; |
@@ -659,13 +644,13 @@ static ssize_t applesmc_position_show(struct device *dev, | |||
659 | int ret; | 644 | int ret; |
660 | s16 x, y, z; | 645 | s16 x, y, z; |
661 | 646 | ||
662 | ret = applesmc_read_motion_sensor(SENSOR_X, &x); | 647 | ret = applesmc_read_s16(MOTION_SENSOR_X_KEY, &x); |
663 | if (ret) | 648 | if (ret) |
664 | goto out; | 649 | goto out; |
665 | ret = applesmc_read_motion_sensor(SENSOR_Y, &y); | 650 | ret = applesmc_read_s16(MOTION_SENSOR_Y_KEY, &y); |
666 | if (ret) | 651 | if (ret) |
667 | goto out; | 652 | goto out; |
668 | ret = applesmc_read_motion_sensor(SENSOR_Z, &z); | 653 | ret = applesmc_read_s16(MOTION_SENSOR_Z_KEY, &z); |
669 | if (ret) | 654 | if (ret) |
670 | goto out; | 655 | goto out; |
671 | 656 | ||