summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Cai <R63905@freescale.com>2013-06-17 16:07:34 +0800
committerRobby Cai <R63905@freescale.com>2013-06-19 11:47:09 +0800
commit6450da3b878ddbac7f80083a2b666d0e5ecb9f93 (patch)
tree4dcba1fa525660a324e2b5fda913fe4845b1a0fb
parente0100972d9637dda237221d453e287701080b4e1 (diff)
ENGR00267228-3 pmic: max17135: do the detection before mfd device register
add a detection earlier than mfd_add_devices() thus if the pmic chip is not detected then the regulator device will not be registered. Signed-off-by: Robby Cai <R63905@freescale.com> (cherry picked from commit d9864db4288410315ef52d8b5f9f1d0ee0302ee3)
-rw-r--r--drivers/mfd/max17135-core.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mfd/max17135-core.c b/drivers/mfd/max17135-core.c
index 52efe22964e5..261c26e26a57 100644
--- a/drivers/mfd/max17135-core.c
+++ b/drivers/mfd/max17135-core.c
@@ -40,7 +40,6 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
-
#include <linux/platform_device.h>
#include <linux/regulator/machine.h>
#include <linux/pmic_status.h>
@@ -48,6 +47,8 @@
#include <linux/mfd/max17135.h>
#include <asm/mach-types.h>
+static int max17135_detect(struct i2c_client *client,
+ struct i2c_board_info *info);
struct i2c_client *max17135_client;
static struct regulator *gpio_regulator;
@@ -160,6 +161,9 @@ static int max17135_probe(struct i2c_client *client,
max17135->i2c_client = client;
max17135_client = client;
+ ret = max17135_detect(client, NULL);
+ if (ret)
+ goto err1;
mfd_add_devices(max17135->dev, -1, max17135_devs,
ARRAY_SIZE(max17135_devs),
@@ -169,7 +173,7 @@ static int max17135_probe(struct i2c_client *client,
pdata = max17135_i2c_parse_dt_pdata(max17135->dev);
if (IS_ERR(pdata)) {
ret = PTR_ERR(pdata);
- goto err;
+ goto err2;
}
}
@@ -178,8 +182,9 @@ static int max17135_probe(struct i2c_client *client,
dev_info(&client->dev, "PMIC MAX17135 for eInk display\n");
return ret;
-err:
+err2:
mfd_remove_devices(max17135->dev);
+err1:
kfree(max17135);
return ret;
@@ -235,7 +240,8 @@ static int max17135_detect(struct i2c_client *client,
return -ENODEV;
}
- strlcpy(info->type, "max17135_sensor", I2C_NAME_SIZE);
+ if (info)
+ strlcpy(info->type, "max17135_sensor", I2C_NAME_SIZE);
return 0;
}