]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/i2c/chips/menelaus.c
menelaus minor cleanups
[linux-2.6-omap-h63xx.git] / drivers / i2c / chips / menelaus.c
index eaa4e1caba0a82b119f58aa259a7440c055115b9..624413b08815332f8e062cf469650d33a541a05b 100644 (file)
@@ -1,7 +1,4 @@
-#define DEBUG
 /*
- * drivers/i2c/chips/menelaus.c
- *
  * Copyright (C) 2004 Texas Instruments, Inc.
  *
  * Some parts based tps65010.c:
@@ -40,6 +37,7 @@
 #include <linux/sched.h>
 #include <linux/mutex.h>
 #include <linux/workqueue.h>
+#include <linux/delay.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
 
@@ -51,8 +49,6 @@
 
 #define DRIVER_NAME                    "menelaus"
 
-#define pr_err(fmt, arg...)    printk(KERN_ERR DRIVER_NAME ": ", ## arg);
-
 #define MENELAUS_I2C_ADDRESS           0x72
 
 #define MENELAUS_REV                   0x01
@@ -157,7 +153,7 @@ static int menelaus_write_reg(int reg, u8 value)
        int val = i2c_smbus_write_byte_data(the_menelaus->client, reg, value);
 
        if (val < 0) {
-               pr_err("write error");
+               dev_err(&the_menelaus->client->dev, "write error");
                return val;
        }
 
@@ -169,7 +165,7 @@ static int menelaus_read_reg(int reg)
        int val = i2c_smbus_read_byte_data(the_menelaus->client, reg);
 
        if (val < 0)
-               pr_err("read error");
+               dev_err(&the_menelaus->client->dev, "read error");
 
        return val;
 }
@@ -243,7 +239,7 @@ static int menelaus_remove_irq_work(int irq)
  * in each slot. In this case the cards are not seen by menelaus.
  * FIXME: Add handling for D1 too
  */
-static void menelaus_mmc_cd_work(struct menelaus_chip * menelaus_hw)
+static void menelaus_mmc_cd_work(struct menelaus_chip *menelaus_hw)
 {
        int reg;
        unsigned char card_mask = 0;
@@ -379,8 +375,6 @@ out:
 }
 EXPORT_SYMBOL(menelaus_set_mmc_slot);
 
-#include <linux/delay.h>
-
 int menelaus_register_mmc_callback(void (*callback)(void *data, u8 card_mask),
                                   void *data)
 {
@@ -448,8 +442,9 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV,
        val = ret & ~(((1 << vtg->vtg_bits) - 1) << vtg->vtg_shift);
        val |= vtg_val << vtg->vtg_shift;
 
-       dev_dbg(&c->dev, "Setting voltage '%s' to %d mV (reg 0x%02x, val 0x%02x)\n",
-              vtg->name, mV, vtg->vtg_reg, val);
+       dev_dbg(&c->dev, "Setting voltage '%s'"
+                        "to %d mV (reg 0x%02x, val 0x%02x)\n",
+                       vtg->name, mV, vtg->vtg_reg, val);
 
        ret = menelaus_write_reg(vtg->vtg_reg, val);
        if (ret < 0)
@@ -512,7 +507,8 @@ int menelaus_set_vcore_sw(unsigned int mV)
        int val, ret;
        struct i2c_client *c = the_menelaus->client;
 
-       val = menelaus_get_vtg_value(mV, vcore_values, ARRAY_SIZE(vcore_values));
+       val = menelaus_get_vtg_value(mV, vcore_values,
+                                    ARRAY_SIZE(vcore_values));
        if (val < 0)
                return -EINVAL;
 
@@ -934,8 +930,8 @@ static int menelaus_set_time(struct device *dev, struct rtc_time *t)
                return status;
        status = menelaus_write_reg(MENELAUS_RTC_WKDAY, BIN2BCD(t->tm_wday));
        if (status < 0) {
-               dev_err(&the_menelaus->client->dev, "rtc write reg %02x, err %d\n",
-                               MENELAUS_RTC_WKDAY, status);
+               dev_err(&the_menelaus->client->dev, "rtc write reg %02x"
+                               "err %d\n", MENELAUS_RTC_WKDAY, status);
                return status;
        }
 
@@ -1177,8 +1173,9 @@ static int menelaus_probe(struct i2c_client *client)
        menelaus->client = client;
 
        /* If a true probe check the device */
-       if ((rev = menelaus_read_reg(MENELAUS_REV)) < 0) {
-               pr_err("device not found");
+       rev = menelaus_read_reg(MENELAUS_REV);
+       if (rev < 0) {
+               dev_err(&client->dev, "device not found");
                err = -ENODEV;
                goto fail1;
        }
@@ -1207,7 +1204,7 @@ static int menelaus_probe(struct i2c_client *client)
        mutex_init(&menelaus->lock);
        INIT_WORK(&menelaus->work, menelaus_work);
 
-       pr_info("Menelaus rev %d.%d\n", rev >> 4, rev & 0x0f);
+       dev_info(&client->dev, "Menelaus rev %d.%d\n", rev >> 4, rev & 0x0f);
 
        val = menelaus_read_reg(MENELAUS_VCORE_CTRL1);
        if (val < 0)
@@ -1239,6 +1236,8 @@ static int __exit menelaus_remove(struct i2c_client *client)
        struct menelaus_chip    *menelaus = i2c_get_clientdata(client);
 
        free_irq(client->irq, menelaus);
+       kfree(menelaus);
+       i2c_set_clientdata(client, NULL);
        the_menelaus = NULL;
        return 0;
 }
@@ -1247,8 +1246,6 @@ static struct i2c_driver menelaus_i2c_driver = {
        .driver = {
                .name           = DRIVER_NAME,
        },
-       .id             = I2C_DRIVERID_MISC, /*FIXME:accroding to i2c-ids.h */
-       .class          = I2C_CLASS_HWMON,
        .probe          = menelaus_probe,
        .remove         = __exit_p(menelaus_remove),
 };
@@ -1257,8 +1254,9 @@ static int __init menelaus_init(void)
 {
        int res;
 
-       if ((res = i2c_add_driver(&menelaus_i2c_driver)) < 0) {
-               pr_err("driver registration failed\n");
+       res = i2c_add_driver(&menelaus_i2c_driver);
+       if (res < 0) {
+               dev_err(&the_menelaus->client->dev, "driver registration failed\n");
                return res;
        }
 
@@ -1272,7 +1270,7 @@ static void __exit menelaus_exit(void)
        /* FIXME: Shutdown menelaus parts that can be shut down */
 }
 
-MODULE_AUTHOR("Texas Instruments, Inc.");
+MODULE_AUTHOR("Texas Instruments, Inc. (and others)");
 MODULE_DESCRIPTION("I2C interface for Menelaus.");
 MODULE_LICENSE("GPL");