diff options
author | Samu Onkalo <samu.p.onkalo@nokia.com> | 2010-05-24 17:33:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-25 11:07:06 -0400 |
commit | ecc437aeee65afeea2e1bed963ccf6c384c555ea (patch) | |
tree | 583091c4dc2c01e4de7d936d492a5cf7cc35b336 /drivers/hwmon | |
parent | 58e814227de9e8b5a4a50fb8018a770de9e974a0 (diff) |
lis3: separate configuration function for 8 bit device
Separate configuration function for 8 bit version of the chip. This way
generic part of the init function stays little bit more readable.
Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com>
Acked-by: Eric Piel <eric.piel@tremplin-utc.net>
Tested-by: Daniel Mack <daniel@caiaq.de>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/lis3lv02d.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c index b2f2277cad3c..99fd45deda41 100644 --- a/drivers/hwmon/lis3lv02d.c +++ b/drivers/hwmon/lis3lv02d.c | |||
@@ -521,6 +521,30 @@ int lis3lv02d_remove_fs(struct lis3lv02d *lis3) | |||
521 | } | 521 | } |
522 | EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); | 522 | EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); |
523 | 523 | ||
524 | static void lis3lv02d_8b_configure(struct lis3lv02d *dev, | ||
525 | struct lis3lv02d_platform_data *p) | ||
526 | { | ||
527 | if (p->click_flags) { | ||
528 | dev->write(dev, CLICK_CFG, p->click_flags); | ||
529 | dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); | ||
530 | dev->write(dev, CLICK_LATENCY, p->click_latency); | ||
531 | dev->write(dev, CLICK_WINDOW, p->click_window); | ||
532 | dev->write(dev, CLICK_THSZ, p->click_thresh_z & 0xf); | ||
533 | dev->write(dev, CLICK_THSY_X, | ||
534 | (p->click_thresh_x & 0xf) | | ||
535 | (p->click_thresh_y << 4)); | ||
536 | } | ||
537 | |||
538 | if (p->wakeup_flags) { | ||
539 | dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); | ||
540 | dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | ||
541 | /* default to 2.5ms for now */ | ||
542 | dev->write(dev, FF_WU_DURATION_1, 1); | ||
543 | /* enable high pass filter for both free-fall units */ | ||
544 | dev->write(dev, CTRL_REG2, HP_FF_WU1 | HP_FF_WU2); | ||
545 | } | ||
546 | } | ||
547 | |||
524 | /* | 548 | /* |
525 | * Initialise the accelerometer and the various subsystems. | 549 | * Initialise the accelerometer and the various subsystems. |
526 | * Should be rather independent of the bus system. | 550 | * Should be rather independent of the bus system. |
@@ -567,25 +591,8 @@ int lis3lv02d_init_device(struct lis3lv02d *dev) | |||
567 | if (dev->pdata) { | 591 | if (dev->pdata) { |
568 | struct lis3lv02d_platform_data *p = dev->pdata; | 592 | struct lis3lv02d_platform_data *p = dev->pdata; |
569 | 593 | ||
570 | if (p->click_flags && (dev->whoami == WAI_8B)) { | 594 | if (dev->whoami == WAI_8B) |
571 | dev->write(dev, CLICK_CFG, p->click_flags); | 595 | lis3lv02d_8b_configure(dev, p); |
572 | dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); | ||
573 | dev->write(dev, CLICK_LATENCY, p->click_latency); | ||
574 | dev->write(dev, CLICK_WINDOW, p->click_window); | ||
575 | dev->write(dev, CLICK_THSZ, p->click_thresh_z & 0xf); | ||
576 | dev->write(dev, CLICK_THSY_X, | ||
577 | (p->click_thresh_x & 0xf) | | ||
578 | (p->click_thresh_y << 4)); | ||
579 | } | ||
580 | |||
581 | if (p->wakeup_flags && (dev->whoami == WAI_8B)) { | ||
582 | dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); | ||
583 | dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | ||
584 | /* default to 2.5ms for now */ | ||
585 | dev->write(dev, FF_WU_DURATION_1, 1); | ||
586 | /* enable high pass filter for both free-fall units */ | ||
587 | dev->write(dev, CTRL_REG2, HP_FF_WU1 | HP_FF_WU2); | ||
588 | } | ||
589 | 596 | ||
590 | if (p->irq_cfg) | 597 | if (p->irq_cfg) |
591 | dev->write(dev, CTRL_REG3, p->irq_cfg); | 598 | dev->write(dev, CTRL_REG3, p->irq_cfg); |