misc: nct: error handling for no regulator
Bitan Biswas [Fri, 24 May 2013 14:49:03 +0000 (19:49 +0530)]
bug 1291015

Change-Id: I7abfa27fddf42e7f6f105d35c055eb31d4874a59
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: http://git-master/r/232623
Reviewed-by: Riham Haidar <rhaidar@nvidia.com>
Tested-by: Riham Haidar <rhaidar@nvidia.com>

drivers/misc/nct1008.c

index 433b07f..9bb38fe 100644 (file)
@@ -1112,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 */
@@ -1196,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);