Merge git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen/avr32-2.6
[pandora-kernel.git] / drivers / i2c / chips / tsl2550.c
index a10fd27..b96f302 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/delay.h>
 
 #define TSL2550_DRV_NAME       "tsl2550"
-#define DRIVER_VERSION         "1.1.1"
+#define DRIVER_VERSION         "1.1.2"
 
 /*
  * Defines
@@ -189,13 +189,16 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
        u8 r = 128;
 
        /* Avoid division by 0 and count 1 cannot be greater than count 0 */
-       if (c0 && (c1 <= c0))
-               r = c1 * 128 / c0;
+       if (c1 <= c0)
+               if (c0) {
+                       r = c1 * 128 / c0;
+
+                       /* Calculate LUX */
+                       lux = ((c0 - c1) * ratio_lut[r]) / 256;
+               } else
+                       lux = 0;
        else
-               return -1;
-
-       /* Calculate LUX */
-       lux = ((c0 - c1) * ratio_lut[r]) / 256;
+               return -EAGAIN;
 
        /* LUX range check */
        return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux;
@@ -364,7 +367,8 @@ static int tsl2550_init_client(struct i2c_client *client)
  */
 
 static struct i2c_driver tsl2550_driver;
-static int __devinit tsl2550_probe(struct i2c_client *client)
+static int __devinit tsl2550_probe(struct i2c_client *client,
+                                  const struct i2c_device_id *id)
 {
        struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
        struct tsl2550_data *data;
@@ -451,6 +455,12 @@ static int tsl2550_resume(struct i2c_client *client)
 
 #endif /* CONFIG_PM */
 
+static const struct i2c_device_id tsl2550_id[] = {
+       { "tsl2550", 0 },
+       { }
+};
+MODULE_DEVICE_TABLE(i2c, tsl2550_id);
+
 static struct i2c_driver tsl2550_driver = {
        .driver = {
                .name   = TSL2550_DRV_NAME,
@@ -460,6 +470,7 @@ static struct i2c_driver tsl2550_driver = {
        .resume = tsl2550_resume,
        .probe  = tsl2550_probe,
        .remove = __devexit_p(tsl2550_remove),
+       .id_table = tsl2550_id,
 };
 
 static int __init tsl2550_init(void)