diff options
-rw-r--r-- | drivers/i2c/chips/tsl2550.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/drivers/i2c/chips/tsl2550.c b/drivers/i2c/chips/tsl2550.c index ef80330b855f..3de4b19ba08f 100644 --- a/drivers/i2c/chips/tsl2550.c +++ b/drivers/i2c/chips/tsl2550.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
28 | 28 | ||
29 | #define TSL2550_DRV_NAME "tsl2550" | 29 | #define TSL2550_DRV_NAME "tsl2550" |
30 | #define DRIVER_VERSION "1.1.0" | 30 | #define DRIVER_VERSION "1.1.1" |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Defines | 33 | * Defines |
@@ -333,13 +333,30 @@ static const struct attribute_group tsl2550_attr_group = { | |||
333 | * Initialization function | 333 | * Initialization function |
334 | */ | 334 | */ |
335 | 335 | ||
336 | static void tsl2550_init_client(struct i2c_client *client) | 336 | static int tsl2550_init_client(struct i2c_client *client) |
337 | { | 337 | { |
338 | struct tsl2550_data *data = i2c_get_clientdata(client); | 338 | struct tsl2550_data *data = i2c_get_clientdata(client); |
339 | int err; | ||
339 | 340 | ||
340 | /* Power up the device and set the default operating mode */ | 341 | /* |
341 | tsl2550_set_power_state(client, 1); | 342 | * Probe the chip. To do so we try to power up the device and then to |
342 | tsl2550_set_operating_mode(client, data->operating_mode); | 343 | * read back the 0x03 code |
344 | */ | ||
345 | err = i2c_smbus_write_byte(client, TSL2550_POWER_UP); | ||
346 | if (err < 0) | ||
347 | return err; | ||
348 | mdelay(1); | ||
349 | if (i2c_smbus_read_byte(client) != TSL2550_POWER_UP) | ||
350 | return -ENODEV; | ||
351 | data->power_state = 1; | ||
352 | |||
353 | /* Set the default operating mode */ | ||
354 | err = i2c_smbus_write_byte(client, | ||
355 | TSL2550_MODE_RANGE[data->operating_mode]); | ||
356 | if (err < 0) | ||
357 | return err; | ||
358 | |||
359 | return 0; | ||
343 | } | 360 | } |
344 | 361 | ||
345 | /* | 362 | /* |
@@ -381,24 +398,12 @@ static int __devinit tsl2550_probe(struct i2c_client *client) | |||
381 | dev_info(&client->dev, "%s operating mode\n", | 398 | dev_info(&client->dev, "%s operating mode\n", |
382 | data->operating_mode ? "extended" : "standard"); | 399 | data->operating_mode ? "extended" : "standard"); |
383 | 400 | ||
384 | /* | ||
385 | * Probe the chip. To do so we try to power up the device and then to | ||
386 | * read back the 0x03 code | ||
387 | */ | ||
388 | err = i2c_smbus_write_byte(client, TSL2550_POWER_UP); | ||
389 | if (err < 0) | ||
390 | goto exit_kfree; | ||
391 | mdelay(1); | ||
392 | err = i2c_smbus_read_byte(client); | ||
393 | if (err != TSL2550_POWER_UP) { | ||
394 | err = -ENODEV; | ||
395 | goto exit_kfree; | ||
396 | } | ||
397 | |||
398 | mutex_init(&data->update_lock); | 401 | mutex_init(&data->update_lock); |
399 | 402 | ||
400 | /* Initialize the TSL2550 chip */ | 403 | /* Initialize the TSL2550 chip */ |
401 | tsl2550_init_client(client); | 404 | err = tsl2550_init_client(client); |
405 | if (err) | ||
406 | goto exit_kfree; | ||
402 | 407 | ||
403 | /* Register sysfs hooks */ | 408 | /* Register sysfs hooks */ |
404 | err = sysfs_create_group(&client->dev.kobj, &tsl2550_attr_group); | 409 | err = sysfs_create_group(&client->dev.kobj, &tsl2550_attr_group); |
@@ -449,6 +454,7 @@ static void __exit tsl2550_exit(void) | |||
449 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); | 454 | MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); |
450 | MODULE_DESCRIPTION("TSL2550 ambient light sensor driver"); | 455 | MODULE_DESCRIPTION("TSL2550 ambient light sensor driver"); |
451 | MODULE_LICENSE("GPL"); | 456 | MODULE_LICENSE("GPL"); |
457 | MODULE_VERSION(DRIVER_VERSION); | ||
452 | 458 | ||
453 | module_init(tsl2550_init); | 459 | module_init(tsl2550_init); |
454 | module_exit(tsl2550_exit); | 460 | module_exit(tsl2550_exit); |