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
(cherry picked from commit e960eaf4a5c9c13054f474bae247a88185626d56)
Reviewed-on: http://git-master/r/239782
(cherry picked from commit ce0df13f7caeb79ff32dd27dd32bda4e17d162f0)
Reviewed-on: http://git-master/r/247088
Reviewed-by: Automatic_Commit_Validation_User

drivers/misc/nct1008.c

index 446883b..005eaca 100644 (file)
@@ -1111,6 +1111,11 @@ static int 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 */
@@ -1195,6 +1200,7 @@ static int 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);