aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/s3c24xx/patches-2.6.24/1306--lis302dl-refactor-and-cleanup.patch.patch
blob: 452b2aae246d2fe58cbe9cb7dfebfca122300c2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
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