mirror of https://github.com/hak5/openwrt-owl.git
479 lines
16 KiB
Diff
479 lines
16 KiB
Diff
From 3318a7cb3165a33046e122294e1878e3bd6555d8 Mon Sep 17 00:00:00 2001
|
|
From: Simon Kagstrom <simon.kagstrom@gmail.com>
|
|
Date: Thu, 16 Oct 2008 01:19:20 +0100
|
|
Subject: [PATCH] : lis302dl-refactor-and-cleanup.patch
|
|
|
|
Some code refactoring.
|
|
|
|
From: Simon Kagstrom <simon.kagstrom@gmail.com>
|
|
|
|
Re-added __reg_read and __reg_write and re-indent the code according to
|
|
these. Move some input-related functions to get a more "logical" order,
|
|
e.g., in the future we might want to support clicks again and call these
|
|
from read_sample. Removed unused function pointer in the structure
|
|
|
|
Signed-off-by: Simon Kagstrom <simon.kagstrom@gmail.com>
|
|
---
|
|
drivers/input/misc/lis302dl.c | 260 ++++++++++++++++++++---------------------
|
|
include/linux/lis302dl.h | 1 -
|
|
2 files changed, 125 insertions(+), 136 deletions(-)
|
|
|
|
diff --git a/drivers/input/misc/lis302dl.c b/drivers/input/misc/lis302dl.c
|
|
index 1013f4a..300918d 100644
|
|
--- a/drivers/input/misc/lis302dl.c
|
|
+++ b/drivers/input/misc/lis302dl.c
|
|
@@ -43,19 +43,58 @@
|
|
|
|
#include <linux/lis302dl.h>
|
|
|
|
+/* Utility functions */
|
|
+static u8 __reg_read(struct lis302dl_info *lis, u8 reg)
|
|
+{
|
|
+ return (lis->pdata->lis302dl_bitbang_reg_read)(lis, reg);
|
|
+}
|
|
|
|
+static void __reg_write(struct lis302dl_info *lis, u8 reg, u8 val)
|
|
+{
|
|
+ (lis->pdata->lis302dl_bitbang_reg_write)(lis, reg, val);
|
|
+}
|
|
|
|
static void __reg_set_bit_mask(struct lis302dl_info *lis, u8 reg, u8 mask,
|
|
- u8 val)
|
|
+ u8 val)
|
|
{
|
|
u_int8_t tmp;
|
|
|
|
val &= mask;
|
|
|
|
- tmp = (lis->pdata->lis302dl_bitbang_reg_read)(lis, reg);
|
|
+ tmp = __reg_read(lis, reg);
|
|
tmp &= ~mask;
|
|
tmp |= val;
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, reg, tmp);
|
|
+ __reg_write(lis, reg, tmp);
|
|
+}
|
|
+
|
|
+static int __ms_to_duration(struct lis302dl_info *lis, int ms)
|
|
+{
|
|
+ u8 r = __reg_read(lis, LIS302DL_REG_CTRL1);
|
|
+
|
|
+ /* If we have 400 ms sampling rate, the stepping is 2.5 ms,
|
|
+ * on 100 ms the stepping is 10ms */
|
|
+ if (r & LIS302DL_CTRL1_DR) {
|
|
+ /* Too large */
|
|
+ if (ms > 637)
|
|
+ return -1;
|
|
+
|
|
+ return (ms * 10) / 25;
|
|
+ }
|
|
+
|
|
+ /* Too large value */
|
|
+ if (ms > 2550)
|
|
+ return -1;
|
|
+ return ms / 10;
|
|
+}
|
|
+
|
|
+static int __duration_to_ms(struct lis302dl_info *lis, int duration)
|
|
+{
|
|
+ u8 r = __reg_read(lis, LIS302DL_REG_CTRL1);
|
|
+
|
|
+ if (r & LIS302DL_CTRL1_DR)
|
|
+ return (duration * 25) / 10;
|
|
+
|
|
+ return duration * 10;
|
|
}
|
|
|
|
/* interrupt handling related */
|
|
@@ -69,30 +108,6 @@ enum lis302dl_intmode {
|
|
LIS302DL_INTMODE_CLICK = 0x07,
|
|
};
|
|
|
|
-#define MG_PER_SAMPLE 18
|
|
-
|
|
-static void lis302dl_bitbang_read_sample(struct lis302dl_info *lis)
|
|
-{
|
|
- u8 data = 0xc0 | LIS302DL_REG_OUT_X; /* read, autoincrement */
|
|
- u8 read[5];
|
|
- unsigned long flags;
|
|
-
|
|
- local_irq_save(flags);
|
|
-
|
|
- (lis->pdata->lis302dl_bitbang)(lis, &data, 1, &read[0], 5);
|
|
-
|
|
- local_irq_restore(flags);
|
|
-
|
|
- input_report_rel(lis->input_dev, REL_X, MG_PER_SAMPLE * (s8)read[0]);
|
|
- input_report_rel(lis->input_dev, REL_Y, MG_PER_SAMPLE * (s8)read[2]);
|
|
- input_report_rel(lis->input_dev, REL_Z, MG_PER_SAMPLE * (s8)read[4]);
|
|
-
|
|
- input_sync(lis->input_dev);
|
|
-
|
|
- /* Reset the HP filter */
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis,
|
|
- LIS302DL_REG_HP_FILTER_RESET);
|
|
-}
|
|
|
|
static void __lis302dl_int_mode(struct device *dev, int int_pin,
|
|
enum lis302dl_intmode mode)
|
|
@@ -110,6 +125,7 @@ static void __lis302dl_int_mode(struct device *dev, int int_pin,
|
|
BUG();
|
|
}
|
|
}
|
|
+
|
|
#if 0
|
|
static void _report_btn_single(struct input_dev *inp, int btn)
|
|
{
|
|
@@ -130,6 +146,29 @@ static void _report_btn_double(struct input_dev *inp, int btn)
|
|
}
|
|
#endif
|
|
|
|
+#define MG_PER_SAMPLE 18
|
|
+
|
|
+static void lis302dl_bitbang_read_sample(struct lis302dl_info *lis)
|
|
+{
|
|
+ u8 data = 0xc0 | LIS302DL_REG_OUT_X; /* read, autoincrement */
|
|
+ u8 read[5];
|
|
+ unsigned long flags;
|
|
+
|
|
+ local_irq_save(flags);
|
|
+
|
|
+ (lis->pdata->lis302dl_bitbang)(lis, &data, 1, &read[0], 5);
|
|
+
|
|
+ local_irq_restore(flags);
|
|
+
|
|
+ input_report_rel(lis->input_dev, REL_X, MG_PER_SAMPLE * (s8)read[0]);
|
|
+ input_report_rel(lis->input_dev, REL_Y, MG_PER_SAMPLE * (s8)read[2]);
|
|
+ input_report_rel(lis->input_dev, REL_Z, MG_PER_SAMPLE * (s8)read[4]);
|
|
+
|
|
+ input_sync(lis->input_dev);
|
|
+
|
|
+ /* Reset the HP filter */
|
|
+ __reg_read(lis, LIS302DL_REG_HP_FILTER_RESET);
|
|
+}
|
|
|
|
static irqreturn_t lis302dl_interrupt(int irq, void *_lis)
|
|
{
|
|
@@ -149,8 +188,7 @@ static ssize_t show_rate(struct device *dev, struct device_attribute *attr,
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
- ctrl1 = (lis->pdata->lis302dl_bitbang_reg_read)
|
|
- (lis, LIS302DL_REG_CTRL1);
|
|
+ ctrl1 = __reg_read(lis, LIS302DL_REG_CTRL1);
|
|
local_irq_restore(flags);
|
|
|
|
return sprintf(buf, "%d\n", ctrl1 & LIS302DL_CTRL1_DR ? 400 : 100);
|
|
@@ -185,8 +223,7 @@ static ssize_t show_scale(struct device *dev, struct device_attribute *attr,
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
- ctrl1 = (lis->pdata->lis302dl_bitbang_reg_read)(lis,
|
|
- LIS302DL_REG_CTRL1);
|
|
+ ctrl1 = __reg_read(lis, LIS302DL_REG_CTRL1);
|
|
local_irq_restore(flags);
|
|
|
|
return sprintf(buf, "%s\n", ctrl1 & LIS302DL_CTRL1_FS ? "9.2" : "2.3");
|
|
@@ -236,8 +273,7 @@ static ssize_t set_threshold(struct device *dev, struct device_attribute *attr,
|
|
/* Set the threshold and write it out if the device is used */
|
|
lis->threshold = val;
|
|
if (lis->flags & LIS302DL_F_INPUT_OPEN)
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_THS_1, lis->threshold);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, lis->threshold);
|
|
|
|
return count;
|
|
}
|
|
@@ -256,7 +292,7 @@ static ssize_t lis302dl_dump(struct device *dev, struct device_attribute *attr,
|
|
local_irq_save(flags);
|
|
|
|
for (n = 0; n < sizeof(reg); n++)
|
|
- reg[n] = (lis->pdata->lis302dl_bitbang_reg_read)(lis, n);
|
|
+ reg[n] = __reg_read(lis, n);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
@@ -271,36 +307,6 @@ static ssize_t lis302dl_dump(struct device *dev, struct device_attribute *attr,
|
|
}
|
|
static DEVICE_ATTR(dump, S_IRUGO, lis302dl_dump, NULL);
|
|
|
|
-static int __freefall_ms_to_duration(struct lis302dl_info *lis, int ms)
|
|
-{
|
|
- u8 r = (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_CTRL1);
|
|
-
|
|
- /* If we have 400 ms sampling rate, the stepping is 2.5 ms,
|
|
- * on 100 ms the stepping is 10ms */
|
|
- if (r & LIS302DL_CTRL1_DR) {
|
|
- /* Too large */
|
|
- if (ms > 637)
|
|
- return -1;
|
|
-
|
|
- return (ms * 10) / 25;
|
|
- }
|
|
-
|
|
- /* Too large value */
|
|
- if (ms > 2550)
|
|
- return -1;
|
|
- return ms / 10;
|
|
-}
|
|
-
|
|
-static int __freefall_duration_to_ms(struct lis302dl_info *lis, int duration)
|
|
-{
|
|
- u8 r = (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_CTRL1);
|
|
-
|
|
- if (r & LIS302DL_CTRL1_DR)
|
|
- return (duration * 25) / 10;
|
|
-
|
|
- return duration * 10;
|
|
-}
|
|
-
|
|
/* Configure freefall/wakeup interrupts */
|
|
static ssize_t set_freefall_common(int which, struct device *dev,
|
|
struct device_attribute *attr, const char *buf, size_t count)
|
|
@@ -342,9 +348,9 @@ static ssize_t set_freefall_common(int which, struct device *dev,
|
|
LIS302DL_INTMODE_DATA_READY);
|
|
lis->flags &= ~(flag_mask | LIS302DL_F_IRQ_WAKE);
|
|
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_cfg, 0);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_ths, 0);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_duration, 0);
|
|
+ __reg_write(lis, r_cfg, 0);
|
|
+ __reg_write(lis, r_ths, 0);
|
|
+ __reg_write(lis, r_duration, 0);
|
|
|
|
/* Power off unless the input subsystem is using the device */
|
|
if (!(lis->flags & LIS302DL_F_INPUT_OPEN))
|
|
@@ -361,7 +367,7 @@ static ssize_t set_freefall_common(int which, struct device *dev,
|
|
return -EINVAL;
|
|
|
|
local_irq_save(flags);
|
|
- duration = __freefall_ms_to_duration(lis, ms);
|
|
+ duration = __ms_to_duration(lis, ms);
|
|
local_irq_save(flags);
|
|
|
|
if (duration < 0)
|
|
@@ -382,13 +388,12 @@ static ssize_t set_freefall_common(int which, struct device *dev,
|
|
/* Setup the configuration registers */
|
|
local_irq_save(flags);
|
|
/* First zero to get to a known state */
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_cfg, 0);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_cfg,
|
|
+ __reg_write(lis, r_cfg, 0);
|
|
+ __reg_write(lis, r_cfg,
|
|
(and_events ? LIS302DL_FFWUCFG_AOI : 0) |
|
|
x_lo | x_hi | y_lo | y_hi | z_lo | z_hi);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_ths,
|
|
- threshold & ~LIS302DL_FFWUTHS_DCRM);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, r_duration, duration);
|
|
+ __reg_write(lis, r_ths, threshold & ~LIS302DL_FFWUTHS_DCRM);
|
|
+ __reg_write(lis, r_duration, duration);
|
|
|
|
/* Route the interrupt for wakeup */
|
|
__lis302dl_int_mode(lis->dev, which, intmode);
|
|
@@ -443,12 +448,12 @@ static ssize_t show_freefall_common(int which, struct device *dev,
|
|
}
|
|
|
|
local_irq_save(flags);
|
|
- config = (lis->pdata->lis302dl_bitbang_reg_read)(lis, r_cfg);
|
|
- threshold = (lis->pdata->lis302dl_bitbang_reg_read)(lis, r_ths);
|
|
- duration = (lis->pdata->lis302dl_bitbang_reg_read)(lis, r_duration);
|
|
- r4 = (lis->pdata->lis302dl_bitbang_reg_read)(lis, r_src);
|
|
- r5 = (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_CTRL3);
|
|
- ms = __freefall_duration_to_ms(lis, duration);
|
|
+ config = __reg_read(lis, r_cfg);
|
|
+ threshold = __reg_read(lis, r_ths);
|
|
+ duration = __reg_read(lis, r_duration);
|
|
+ r4 = __reg_read(lis, r_src);
|
|
+ r5 = __reg_read(lis, LIS302DL_REG_CTRL3);
|
|
+ ms = __duration_to_ms(lis, duration);
|
|
local_irq_restore(flags);
|
|
|
|
/* All events off? */
|
|
@@ -519,18 +524,14 @@ static int lis302dl_input_open(struct input_dev *inp)
|
|
/* make sure we're powered up and generate data ready */
|
|
__reg_set_bit_mask(lis, LIS302DL_REG_CTRL1, ctrl1, ctrl1);
|
|
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL2,
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL2,
|
|
ctrl2);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_THS_1, lis->threshold);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_DURATION_1, 0);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, lis->threshold);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_DURATION_1, 0);
|
|
|
|
/* Clear the HP filter "starting point" */
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis,
|
|
- LIS302DL_REG_HP_FILTER_RESET);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_CFG_1, LIS302DL_FFWUCFG_XHIE |
|
|
+ __reg_read(lis, LIS302DL_REG_HP_FILTER_RESET);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_CFG_1, LIS302DL_FFWUCFG_XHIE |
|
|
LIS302DL_FFWUCFG_YHIE | LIS302DL_FFWUCFG_ZHIE);
|
|
|
|
lis->flags |= LIS302DL_F_INPUT_OPEN;
|
|
@@ -576,11 +577,11 @@ static int __lis302dl_reset_device(struct lis302dl_info *lis)
|
|
{
|
|
int timeout = 10;
|
|
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL2,
|
|
- LIS302DL_CTRL2_BOOT | LIS302DL_CTRL2_FDS);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL2,
|
|
+ LIS302DL_CTRL2_BOOT | LIS302DL_CTRL2_FDS);
|
|
|
|
- while (((lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_CTRL2)
|
|
- & LIS302DL_CTRL2_BOOT) && (timeout--))
|
|
+ while ((__reg_read(lis, LIS302DL_REG_CTRL2)
|
|
+ & LIS302DL_CTRL2_BOOT) && (timeout--))
|
|
mdelay(1);
|
|
|
|
return !!(timeout < 0);
|
|
@@ -609,8 +610,7 @@ static int __devinit lis302dl_probe(struct platform_device *pdev)
|
|
/* Configure our IO */
|
|
(lis->pdata->lis302dl_suspend_io)(lis, 1);
|
|
|
|
- wai = (lis->pdata->lis302dl_bitbang_reg_read)(lis,
|
|
- LIS302DL_REG_WHO_AM_I);
|
|
+ wai = __reg_read(lis, LIS302DL_REG_WHO_AM_I);
|
|
if (wai != LIS302DL_WHO_AM_I_MAGIC) {
|
|
dev_err(lis->dev, "unknown who_am_i signature 0x%02x\n", wai);
|
|
dev_set_drvdata(lis->dev, NULL);
|
|
@@ -659,46 +659,38 @@ static int __devinit lis302dl_probe(struct platform_device *pdev)
|
|
dev_err(lis->dev, "device BOOT reload failed\n");
|
|
|
|
/* force us powered */
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL1,
|
|
- LIS302DL_CTRL1_PD |
|
|
- LIS302DL_CTRL1_Xen |
|
|
- LIS302DL_CTRL1_Yen |
|
|
- LIS302DL_CTRL1_Zen);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL1, LIS302DL_CTRL1_PD |
|
|
+ LIS302DL_CTRL1_Xen |
|
|
+ LIS302DL_CTRL1_Yen |
|
|
+ LIS302DL_CTRL1_Zen);
|
|
mdelay(1);
|
|
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL2, 0);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL3,
|
|
- LIS302DL_CTRL3_PP_OD | LIS302DL_CTRL3_IHL);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_THS_1, 0x0);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_DURATION_1, 0x00);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_FF_WU_CFG_1, 0x0);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL2, 0);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL3,
|
|
+ LIS302DL_CTRL3_PP_OD | LIS302DL_CTRL3_IHL);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_THS_1, 0x0);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_DURATION_1, 0x00);
|
|
+ __reg_write(lis, LIS302DL_REG_FF_WU_CFG_1, 0x0);
|
|
|
|
/* start off in powered down mode; we power up when someone opens us */
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL1,
|
|
- LIS302DL_CTRL1_Xen |
|
|
- LIS302DL_CTRL1_Yen |
|
|
- LIS302DL_CTRL1_Zen);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL1, LIS302DL_CTRL1_Xen |
|
|
+ LIS302DL_CTRL1_Yen | LIS302DL_CTRL1_Zen);
|
|
|
|
if (pdata->open_drain)
|
|
/* switch interrupt to open collector, active-low */
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_CTRL3, LIS302DL_CTRL3_PP_OD |
|
|
- LIS302DL_CTRL3_IHL);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL3,
|
|
+ LIS302DL_CTRL3_PP_OD | LIS302DL_CTRL3_IHL);
|
|
else
|
|
/* push-pull, active-low */
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- LIS302DL_REG_CTRL3, LIS302DL_CTRL3_IHL);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL3, LIS302DL_CTRL3_IHL);
|
|
|
|
__lis302dl_int_mode(lis->dev, 1, LIS302DL_INTMODE_FF_WU_12);
|
|
__lis302dl_int_mode(lis->dev, 2, LIS302DL_INTMODE_FF_WU_12);
|
|
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_STATUS);
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_FF_WU_SRC_1);
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_FF_WU_SRC_2);
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_CLICK_SRC);
|
|
+ __reg_read(lis, LIS302DL_REG_STATUS);
|
|
+ __reg_read(lis, LIS302DL_REG_FF_WU_SRC_1);
|
|
+ __reg_read(lis, LIS302DL_REG_FF_WU_SRC_2);
|
|
+ __reg_read(lis, LIS302DL_REG_CLICK_SRC);
|
|
|
|
dev_info(lis->dev, "Found %s\n", pdata->name);
|
|
|
|
@@ -733,9 +725,9 @@ static int __devexit lis302dl_remove(struct platform_device *pdev)
|
|
|
|
/* Reset and power down the device */
|
|
local_irq_save(flags);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL3, 0x00);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL2, 0x00);
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL1, 0x00);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL3, 0x00);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL2, 0x00);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL1, 0x00);
|
|
local_irq_restore(flags);
|
|
|
|
/* Cleanup resources */
|
|
@@ -798,13 +790,12 @@ static int lis302dl_suspend(struct platform_device *pdev, pm_message_t state)
|
|
/* save registers */
|
|
for (n = 0; n < ARRAY_SIZE(regs_to_save); n++)
|
|
lis->regs[regs_to_save[n]] =
|
|
- (lis->pdata->lis302dl_bitbang_reg_read)(lis,
|
|
- regs_to_save[n]);
|
|
+ __reg_read(lis, regs_to_save[n]);
|
|
|
|
/* power down */
|
|
- tmp = (lis->pdata->lis302dl_bitbang_reg_read)(lis, LIS302DL_REG_CTRL1);
|
|
+ tmp = __reg_read(lis, LIS302DL_REG_CTRL1);
|
|
tmp &= ~LIS302DL_CTRL1_PD;
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL1, tmp);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL1, tmp);
|
|
|
|
/* place our IO to the device in sleep-compatible states */
|
|
(lis->pdata->lis302dl_suspend_io)(lis, 0);
|
|
@@ -830,11 +821,11 @@ static int lis302dl_resume(struct platform_device *pdev)
|
|
(lis->pdata->lis302dl_suspend_io)(lis, 1);
|
|
|
|
/* resume from powerdown first! */
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis, LIS302DL_REG_CTRL1,
|
|
- LIS302DL_CTRL1_PD |
|
|
- LIS302DL_CTRL1_Xen |
|
|
- LIS302DL_CTRL1_Yen |
|
|
- LIS302DL_CTRL1_Zen);
|
|
+ __reg_write(lis, LIS302DL_REG_CTRL1,
|
|
+ LIS302DL_CTRL1_PD |
|
|
+ LIS302DL_CTRL1_Xen |
|
|
+ LIS302DL_CTRL1_Yen |
|
|
+ LIS302DL_CTRL1_Zen);
|
|
mdelay(1);
|
|
|
|
if (__lis302dl_reset_device(lis))
|
|
@@ -847,8 +838,7 @@ static int lis302dl_resume(struct platform_device *pdev)
|
|
|
|
/* restore registers after resume */
|
|
for (n = 0; n < ARRAY_SIZE(regs_to_save); n++)
|
|
- (lis->pdata->lis302dl_bitbang_reg_write)(lis,
|
|
- regs_to_save[n], lis->regs[regs_to_save[n]]);
|
|
+ __reg_write(lis, regs_to_save[n], lis->regs[regs_to_save[n]]);
|
|
|
|
local_irq_restore(flags);
|
|
enable_irq(lis->pdata->interrupt);
|
|
diff --git a/include/linux/lis302dl.h b/include/linux/lis302dl.h
|
|
index f3f994d..a756f55 100644
|
|
--- a/include/linux/lis302dl.h
|
|
+++ b/include/linux/lis302dl.h
|
|
@@ -18,7 +18,6 @@ struct lis302dl_platform_data {
|
|
int interrupt;
|
|
void (*lis302dl_bitbang)(struct lis302dl_info *lis, u8 *tx,
|
|
int tx_bytes, u8 *rx, int rx_bytes);
|
|
- void (*lis302dl_bitbang_read_sample)(struct lis302dl_info *);
|
|
void (*lis302dl_suspend_io)(struct lis302dl_info *, int resuming);
|
|
int (*lis302dl_bitbang_reg_read)(struct lis302dl_info *, u8 reg);
|
|
void (*lis302dl_bitbang_reg_write)(struct lis302dl_info *, u8 reg,
|
|
--
|
|
1.5.6.5
|
|
|