misc: Removed warnings from MAX1749 driver
[linux-2.6.git] / drivers / misc / nct1008.c
index 31b1d19..d8e8e6b 100644 (file)
@@ -101,6 +101,13 @@ struct nct1008_data {
        struct thermal_zone_device *nct_ext;
 };
 
+static const struct i2c_device_id nct1008_id[] = {
+       { "nct1008", NCT1008 },
+       { "nct72", NCT72},
+       { "nct218", NCT218 },
+       {}
+};
+
 static int conv_period_ms_table[] =
        {16000, 8000, 4000, 2000, 1000, 500, 250, 125, 63, 32, 16};
 
@@ -742,7 +749,7 @@ static void print_reg(const char *reg_name, struct seq_file *s,
 
 static int dbg_nct1008_show(struct seq_file *s, void *unused)
 {
-       seq_printf(s, "nct1008 nct72 Registers\n");
+       seq_printf(s, "NCT Thermal Sensor Registers\n");
        seq_printf(s, "------------------\n");
        print_reg("Local Temp Value    ",     s, 0x00);
        print_reg("Ext Temp Value Hi   ",     s, 0x01);
@@ -781,12 +788,12 @@ static int nct1008_debuginit(struct nct1008_data *nct)
 {
        int err = 0;
        struct dentry *d;
-       if (nct->chip == NCT72)
-               d = debugfs_create_file("nct72", S_IRUGO, NULL,
-                               (void *)nct, &debug_fops);
-       else
-               d = debugfs_create_file("nct1008", S_IRUGO, NULL,
-                               (void *)nct, &debug_fops);
+       const char *name = nct1008_id[nct->chip].name;
+
+       /* create debugfs by selecting chipid */
+       d = debugfs_create_file(name, S_IRUGO, NULL,
+               (void *)nct, &debug_fops);
+
        if ((!d) || IS_ERR(d)) {
                dev_err(&nct->client->dev, "Error: %s debugfs_create_file"
                        " returned an error\n", __func__);
@@ -887,6 +894,8 @@ static irqreturn_t nct1008_irq(int irq, void *dev_id)
 static void nct1008_power_control(struct nct1008_data *data, bool is_enable)
 {
        int ret;
+       const char *name = nct1008_id[data->chip].name;
+
        if (!data->nct_reg) {
                data->nct_reg = regulator_get(&data->client->dev, "vdd");
                if (IS_ERR_OR_NULL(data->nct_reg)) {
@@ -910,14 +919,16 @@ static void nct1008_power_control(struct nct1008_data *data, bool is_enable)
        }
 
        if (ret < 0)
-               dev_err(&data->client->dev, "Error in %s rail vdd_nct%s, "
+               dev_err(&data->client->dev, "Error in %s rail vdd_%s, "
                        "error %d\n", (is_enable) ? "enabling" : "disabling",
-                       (data->chip == NCT72) ? "72" : "1008",
+                       name,
                        ret);
        else
                dev_info(&data->client->dev, "success in %s rail vdd_nct%s\n",
                        (is_enable) ? "enabling" : "disabling",
-                       (data->chip == NCT72) ? "72" : "1008");
+                       name);
+
+
 }
 
 static int nct1008_configure_sensor(struct nct1008_data *data)
@@ -1048,8 +1059,9 @@ error:
 
 static int __devinit nct1008_configure_irq(struct nct1008_data *data)
 {
-       data->workqueue = create_singlethread_workqueue((data->chip == NCT72) \
-                                                       ? "nct72" : "nct1008");
+       const char *name = nct1008_id[data->chip].name;
+
+       data->workqueue = create_singlethread_workqueue(name);
 
        INIT_WORK(&data->work, nct1008_work_func);
 
@@ -1058,7 +1070,7 @@ static int __devinit nct1008_configure_irq(struct nct1008_data *data)
        else
                return request_irq(data->client->irq, nct1008_irq,
                        IRQF_TRIGGER_LOW,
-                       (data->chip == NCT72) ? "nct72" : "nct1008",
+                       name,
                        data);
 }
 
@@ -1100,6 +1112,11 @@ static int __devinit nct1008_probe(struct i2c_client *client,
        mutex_init(&data->mutex);
 
        nct1008_power_control(data, true);
+       if (!data->nct_reg) {
+               /* power up failure */
+               err = -EIO;
+               goto cleanup;
+       }
        /* extended range recommended steps 1 through 4 taken care
         * in nct1008_configure_sensor function */
        err = nct1008_configure_sensor(data);   /* sensor is in standby */
@@ -1141,15 +1158,15 @@ static int __devinit nct1008_probe(struct i2c_client *client,
                mask |= (1 << i);
 
        if (data->plat_data.loc_name) {
-               strcpy(nct_int_name, "Tdiode_");
-               strcpy(nct_ext_name, "Tboard_");
+               strcpy(nct_int_name, "Tboard_");
+               strcpy(nct_ext_name, "Tdiode_");
                strncat(nct_int_name, data->plat_data.loc_name,
-                       (THERMAL_NAME_LENGTH - strlen("Tdiode_")) - 1);
-               strncat(nct_ext_name, data->plat_data.loc_name,
                        (THERMAL_NAME_LENGTH - strlen("Tboard_")) - 1);
+               strncat(nct_ext_name, data->plat_data.loc_name,
+                       (THERMAL_NAME_LENGTH - strlen("Tdiode_")) - 1);
        } else {
-               strcpy(nct_int_name, "Tdiode");
-               strcpy(nct_ext_name, "Tboard");
+               strcpy(nct_int_name, "Tboard");
+               strcpy(nct_ext_name, "Tdiode");
        }
 
        data->nct_int = thermal_zone_device_register(nct_int_name,
@@ -1184,6 +1201,7 @@ static int __devinit nct1008_probe(struct i2c_client *client,
 error:
        dev_err(&client->dev, "\n exit %s, err=%d ", __func__, err);
        nct1008_power_control(data, false);
+cleanup:
        mutex_destroy(&data->mutex);
        if (data->nct_reg)
                regulator_put(data->nct_reg);
@@ -1354,16 +1372,11 @@ static const struct dev_pm_ops nct1008_pm_ops = {
 
 #endif
 
-static const struct i2c_device_id nct1008_id[] = {
-       { "nct1008", NCT1008 },
-       { "nct72", NCT72},
-       {}
-};
 MODULE_DEVICE_TABLE(i2c, nct1008_id);
 
 static struct i2c_driver nct1008_driver = {
        .driver = {
-               .name   = "nct1008_nct72",
+               .name   = "nct_thermal",
 #ifdef CONFIG_PM_SLEEP
                .pm = &nct1008_pm_ops,
 #endif