File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 38
38
39
39
#define MMA8450_CTRL_REG1 0x38
40
40
#define MMA8450_CTRL_REG2 0x39
41
+ #define MMA8450_ID 0xc6
42
+ #define MMA8450_WHO_AM_I 0x0f
41
43
42
44
static int mma8450_read (struct i2c_client * c , unsigned int off )
43
45
{
@@ -148,8 +150,20 @@ static void mma8450_close(struct input_dev *input)
148
150
*/
149
151
static int mma8450_probe (struct i2c_client * c )
150
152
{
153
+ struct i2c_adapter * adapter = c -> adapter ;
151
154
struct input_dev * input ;
152
- int err ;
155
+ int err , client_id ;
156
+
157
+ if (!i2c_check_functionality (adapter , I2C_FUNC_SMBUS_BYTE |
158
+ I2C_FUNC_SMBUS_BYTE_DATA ))
159
+ return dev_err_probe (& c -> dev , - EINVAL ,
160
+ "I2C adapter doesn't support SMBUS BYTE" );
161
+
162
+ client_id = i2c_smbus_read_byte_data (c , MMA8450_WHO_AM_I );
163
+ if (client_id != MMA8450_ID )
164
+ return dev_err_probe (& c -> dev , - EINVAL ,
165
+ "unexpected chip ID 0x%x (vs 0x%x)\n" ,
166
+ client_id , MMA8450_ID );
153
167
154
168
input = devm_input_allocate_device (& c -> dev );
155
169
if (!input )
You can’t perform that action at this time.
0 commit comments