diff mbox

[1/2] input: qt2160: Fix I2C write function.

Message ID 1350400771-7950-1-git-send-email-javier.martin@vista-silicon.com (mailing list archive)
State New, archived
Headers show

Commit Message

Javier Martin Oct. 16, 2012, 3:19 p.m. UTC
The previous implementation of qt2160_write() didn't work
properly. Use a similar aproach as qt1070 instead.

Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
 drivers/input/keyboard/qt2160.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

Comments

Dmitry Torokhov Oct. 16, 2012, 5:31 p.m. UTC | #1
On Tue, Oct 16, 2012 at 05:19:30PM +0200, Javier Martin wrote:
> The previous implementation of qt2160_write() didn't work
> properly. Use a similar aproach as qt1070 instead.

I think your editor lost the end of the sentence: "... qt2160_write()
didn't work properly because ..." :)

Thanks!
Javier Martin Oct. 17, 2012, 6:59 a.m. UTC | #2
Hi Dmitry,
thank you for your answer.

On 16 October 2012 19:31, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> On Tue, Oct 16, 2012 at 05:19:30PM +0200, Javier Martin wrote:
>> The previous implementation of qt2160_write() didn't work
>> properly. Use a similar aproach as qt1070 instead.
>
> I think your editor lost the end of the sentence: "... qt2160_write()
> didn't work properly because ..." :)
>
> Thanks!
>
> --
> Dmitry

Because the requested value was actually not written to the device.
Probably nobody detected this because the only write that was issued
was the one related to auto calibration.

It was while I was trying to add support for the LEDs when I realized
that they were not being powered on.

Do you want me to send a v2 patch with these information added to the changelog?

Regards.
diff mbox

Patch

diff --git a/drivers/input/keyboard/qt2160.c b/drivers/input/keyboard/qt2160.c
index e7a5e36..73ea4b0 100644
--- a/drivers/input/keyboard/qt2160.c
+++ b/drivers/input/keyboard/qt2160.c
@@ -207,23 +207,14 @@  static int __devinit qt2160_read(struct i2c_client *client, u8 reg)
 
 static int __devinit qt2160_write(struct i2c_client *client, u8 reg, u8 data)
 {
-	int error;
-
-	error = i2c_smbus_write_byte(client, reg);
-	if (error) {
-		dev_err(&client->dev,
-			"couldn't send request. Returned %d\n", error);
-		return error;
-	}
+	int ret;
 
-	error = i2c_smbus_write_byte(client, data);
-	if (error) {
+	ret = i2c_smbus_write_byte_data(client, reg, data);
+	if (ret < 0)
 		dev_err(&client->dev,
-			"couldn't write data. Returned %d\n", error);
-		return error;
-	}
+			"couldn't write data. Returned %d\n", ret);
 
-	return error;
+	return ret;
 }