aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuwei Zhou <b45643@freescale.com>2013-09-03 05:32:55 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:05:31 -0400
commit208d97f2441fc0f796713610b541c5fad6da6fc2 (patch)
treef4a9a734deac3fa8426ac1061c98508f3e8d6d1e
parent9815135e2a3ff1cf1d276d12bc703fc1c7dbd4cb (diff)
ENGR00277864 input: mma8450: Add chip id check in probe
Add chip ID check in probe function. The mma8450 is on the E-INK daughter board. When the daughter board is not pluged, there would be polling error log continuously. Add the check to avoid this. Signed-off-by: Luwei Zhou <b45643@freescale.com>
-rw-r--r--drivers/input/misc/mma8450.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c
index f3309696d053..9d3868211fc2 100644
--- a/drivers/input/misc/mma8450.c
+++ b/drivers/input/misc/mma8450.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for Freescale's 3-Axis Accelerometer MMA8450 2 * Driver for Freescale's 3-Axis Accelerometer MMA8450
3 * 3 *
4 * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. 4 * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -51,6 +51,8 @@
51 51
52#define MMA8450_CTRL_REG1 0x38 52#define MMA8450_CTRL_REG1 0x38
53#define MMA8450_CTRL_REG2 0x39 53#define MMA8450_CTRL_REG2 0x39
54#define MMA8450_ID 0xC6
55#define MMA8450_WHO_AM_I 0x0F
54 56
55/* mma8450 status */ 57/* mma8450 status */
56struct mma8450 { 58struct mma8450 {
@@ -172,7 +174,25 @@ static int mma8450_probe(struct i2c_client *c,
172{ 174{
173 struct input_polled_dev *idev; 175 struct input_polled_dev *idev;
174 struct mma8450 *m; 176 struct mma8450 *m;
175 int err; 177 int err, client_id;
178 struct i2c_adapter *adapter = NULL;
179
180 adapter = to_i2c_adapter(c->dev.parent);
181 err = i2c_check_functionality(adapter,
182 I2C_FUNC_SMBUS_BYTE |
183 I2C_FUNC_SMBUS_BYTE_DATA);
184 if (!err)
185 goto err_out;
186
187 client_id = i2c_smbus_read_byte_data(c, MMA8450_WHO_AM_I);
188
189 if (MMA8450_ID != client_id) {
190 dev_err(&c->dev,
191 "read chip ID 0x%x is not equal to 0x%x!\n", client_id,
192 MMA8450_ID);
193 err = -EINVAL;
194 goto err_out;
195 }
176 196
177 m = kzalloc(sizeof(struct mma8450), GFP_KERNEL); 197 m = kzalloc(sizeof(struct mma8450), GFP_KERNEL);
178 idev = input_allocate_polled_device(); 198 idev = input_allocate_polled_device();
@@ -209,6 +229,7 @@ static int mma8450_probe(struct i2c_client *c,
209err_free_mem: 229err_free_mem:
210 input_free_polled_device(idev); 230 input_free_polled_device(idev);
211 kfree(m); 231 kfree(m);
232err_out:
212 return err; 233 return err;
213} 234}
214 235