misc: nct1008: error handling change
[linux-2.6.git] / drivers / misc / bh1780gli.c
index 714c6b4..82fe2d0 100644 (file)
@@ -49,8 +49,8 @@ static int bh1780_write(struct bh1780_data *ddata, u8 reg, u8 val, char *msg)
        int ret = i2c_smbus_write_byte_data(ddata->client, reg, val);
        if (ret < 0)
                dev_err(&ddata->client->dev,
-                       "i2c_smbus_write_byte_data failed error %d\
-                       Register (%s)\n", ret, msg);
+                       "i2c_smbus_write_byte_data failed error %d Register (%s)\n",
+                       ret, msg);
        return ret;
 }
 
@@ -59,8 +59,8 @@ static int bh1780_read(struct bh1780_data *ddata, u8 reg, char *msg)
        int ret = i2c_smbus_read_byte_data(ddata->client, reg);
        if (ret < 0)
                dev_err(&ddata->client->dev,
-                       "i2c_smbus_read_byte_data failed error %d\
-                        Register (%s)\n", ret, msg);
+                       "i2c_smbus_read_byte_data failed error %d Register (%s)\n",
+                       ret, msg);
        return ret;
 }
 
@@ -190,17 +190,17 @@ static int __devexit bh1780_remove(struct i2c_client *client)
 
        ddata = i2c_get_clientdata(client);
        sysfs_remove_group(&client->dev.kobj, &bh1780_attr_group);
-       i2c_set_clientdata(client, NULL);
        kfree(ddata);
 
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int bh1780_suspend(struct i2c_client *client, pm_message_t mesg)
+static int bh1780_suspend(struct device *dev)
 {
        struct bh1780_data *ddata;
        int state, ret;
+       struct i2c_client *client = to_i2c_client(dev);
 
        ddata = i2c_get_clientdata(client);
        state = bh1780_read(ddata, BH1780_REG_CONTROL, "CONTROL");
@@ -218,14 +218,14 @@ static int bh1780_suspend(struct i2c_client *client, pm_message_t mesg)
        return 0;
 }
 
-static int bh1780_resume(struct i2c_client *client)
+static int bh1780_resume(struct device *dev)
 {
        struct bh1780_data *ddata;
        int state, ret;
+       struct i2c_client *client = to_i2c_client(dev);
 
        ddata = i2c_get_clientdata(client);
        state = ddata->power_state;
-
        ret = bh1780_write(ddata, BH1780_REG_CONTROL, state,
                                "CONTROL");
 
@@ -234,9 +234,10 @@ static int bh1780_resume(struct i2c_client *client)
 
        return 0;
 }
+static SIMPLE_DEV_PM_OPS(bh1780_pm, bh1780_suspend, bh1780_resume);
+#define BH1780_PMOPS (&bh1780_pm)
 #else
-#define bh1780_suspend NULL
-#define bh1780_resume NULL
+#define BH1780_PMOPS NULL
 #endif /* CONFIG_PM */
 
 static const struct i2c_device_id bh1780_id[] = {
@@ -248,11 +249,10 @@ static struct i2c_driver bh1780_driver = {
        .probe          = bh1780_probe,
        .remove         = bh1780_remove,
        .id_table       = bh1780_id,
-       .suspend        = bh1780_suspend,
-       .resume         = bh1780_resume,
        .driver = {
-               .name = "bh1780"
-       },
+               .name = "bh1780",
+               .pm     = BH1780_PMOPS,
+},
 };
 
 static int __init bh1780_init(void)