linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] input: kxtj9: who_am_i check value and initial data rate fixes
@ 2012-02-03 15:27 Chris, Hudson
       [not found] ` <CAB7Re7UT7tULwGqcwn+iQRC+nciDUS4J8LSVP5NasK3p1SOfsw@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Chris, Hudson @ 2012-02-03 15:27 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, chris.hudson.comp.eng, Chris Hudson

From: Chris Hudson <chudson@kionix.com>

Several fixes based on customer feedback:
- WHO_AM_I value has changed since preliminary parts used for initial testing
- Output of le16_to_cpu must be saved to memory before shifting to preserve sign
- Initial data rate was not extracted from data control register init.  This was
  causing the initial data rate to be set to maximum until it was changed.  To
  fix this problem, it made more sense to specify an initial data rate and
  extract the register mask from that.

Signed-off-by: Chris Hudson <chudson@kionix.com>
---
 drivers/input/misc/kxtj9.c  |   25 ++++++++++++++++++++-----
 include/linux/input/kxtj9.h |   11 +----------
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c
index 783597a..7c4b955 100644
--- a/drivers/input/misc/kxtj9.c
+++ b/drivers/input/misc/kxtj9.c
@@ -41,6 +41,14 @@
 #define PC1_ON			(1 << 7)
 /* Data ready funtion enable bit: set during probe if using irq mode */
 #define DRDYE			(1 << 5)
+/* DATA CONTROL REGISTER BITS */
+#define ODR12_5F		0
+#define ODR25F			1
+#define ODR50F			2
+#define ODR100F			3
+#define ODR200F			4
+#define ODR400F			5
+#define ODR800F			6
 /* INTERRUPT CONTROL REGISTER 1 BITS */
 /* Set these during probe if using irq mode */
 #define KXTJ9_IEL		(1 << 3)
@@ -116,9 +124,13 @@ static void kxtj9_report_acceleration_data(struct kxtj9_data *tj9)
 	if (err < 0)
 		dev_err(&tj9->client->dev, "accelerometer data read failed\n");
 
-	x = le16_to_cpu(acc_data[tj9->pdata.axis_map_x]) >> tj9->shift;
-	y = le16_to_cpu(acc_data[tj9->pdata.axis_map_y]) >> tj9->shift;
-	z = le16_to_cpu(acc_data[tj9->pdata.axis_map_z]) >> tj9->shift;
+	x = le16_to_cpu(acc_data[tj9->pdata.axis_map_x]);
+	y = le16_to_cpu(acc_data[tj9->pdata.axis_map_y]);
+	z = le16_to_cpu(acc_data[tj9->pdata.axis_map_z]);
+
+	x >>= tj9->shift;
+	y >>= tj9->shift;
+	z >>= tj9->shift;
 
 	input_report_abs(tj9->input_dev, ABS_X, tj9->pdata.negate_x ? -x : x);
 	input_report_abs(tj9->input_dev, ABS_Y, tj9->pdata.negate_y ? -y : y);
@@ -487,7 +499,10 @@ static int __devinit kxtj9_verify(struct kxtj9_data *tj9)
 		goto out;
 	}
 
-	retval = retval != 0x06 ? -EIO : 0;
+	if ((retval != 0x07) && (retval != 0x08))
+		retval = -EIO;
+	else
+		retval = 0;
 
 out:
 	kxtj9_device_power_off(tj9);
@@ -537,7 +552,7 @@ static int __devinit kxtj9_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, tj9);
 
 	tj9->ctrl_reg1 = tj9->pdata.res_12bit | tj9->pdata.g_range;
-	tj9->data_ctrl = tj9->pdata.data_odr_init;
+	tj9->last_poll_interval = tj9->pdata.init_interval;
 
 	if (client->irq) {
 		/* If in irq mode, populate INT_CTRL_REG1 and enable DRDY. */
diff --git a/include/linux/input/kxtj9.h b/include/linux/input/kxtj9.h
index f6bac89..d415579 100644
--- a/include/linux/input/kxtj9.h
+++ b/include/linux/input/kxtj9.h
@@ -24,6 +24,7 @@
 
 struct kxtj9_platform_data {
 	unsigned int min_interval;	/* minimum poll interval (in milli-seconds) */
+	unsigned int init_interval;	/* initial poll interval (in milli-seconds) */
 
 	/*
 	 * By default, x is axis 0, y is axis 1, z is axis 2; these can be
@@ -52,16 +53,6 @@ struct kxtj9_platform_data {
 	#define KXTJ9_G_8G		(1 << 4)
 	u8 g_range;
 
-	/* DATA_CTRL_REG: controls the output data rate of the part */
-	#define ODR12_5F		0
-	#define ODR25F			1
-	#define ODR50F			2
-	#define ODR100F			3
-	#define ODR200F			4
-	#define ODR400F			5
-	#define ODR800F			6
-	u8 data_odr_init;
-
 	int (*init)(void);
 	void (*exit)(void);
 	int (*power_on)(void);
-- 
1.5.4.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RESEND] input: kxtj9: who_am_i check value and initial data rate fixes
       [not found] ` <CAB7Re7UT7tULwGqcwn+iQRC+nciDUS4J8LSVP5NasK3p1SOfsw@mail.gmail.com>
@ 2012-03-18  4:19   ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2012-03-18  4:19 UTC (permalink / raw)
  To: Christopher Hudson; +Cc: linux-input, Chris Hudson

Hi Christopher,

On Fri, Mar 16, 2012 at 02:53:33PM -0400, Christopher Hudson wrote:
> ---------- Forwarded message ----------
> From: <chris.hudson.comp.eng@gmail.com>
> Date: Fri, Feb 3, 2012 at 10:27 AM
> Subject: [PATCH 1/1] input: kxtj9: who_am_i check value and initial data
> rate fixes
> To: linux-input@vger.kernel.org
> Cc: dmitry.torokhov@gmail.com, chris.hudson.comp.eng@gmail.com, Chris
> Hudson <chudson@kionix.com>
> 
> From: Chris Hudson <chudson@kionix.com>
> 
> Several fixes based on customer feedback:
> - WHO_AM_I value has changed since preliminary parts used for initial
> testing
> - Output of le16_to_cpu must be saved to memory before shifting to preserve
> sign
> - Initial data rate was not extracted from data control register init.
>  This was
>  causing the initial data rate to be set to maximum until it was changed.
>  To
>  fix this problem, it made more sense to specify an initial data rate and
>  extract the register mask from that.
> 
> Signed-off-by: Chris Hudson <chudson@kionix.com>

Your mailer messed up the patch (tabs converted to spaces, lines wrapped
up). I fixed it up and applied but please use proper MTA next time
around.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-18  4:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 15:27 [PATCH 1/1] input: kxtj9: who_am_i check value and initial data rate fixes Chris, Hudson
     [not found] ` <CAB7Re7UT7tULwGqcwn+iQRC+nciDUS4J8LSVP5NasK3p1SOfsw@mail.gmail.com>
2012-03-18  4:19   ` [PATCH RESEND] " Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).