public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mfd: max77686: Init max77686->dev before using it
@ 2012-12-24 16:16 Axel Lin
  2012-12-24 16:28 ` [PATCH 2/2] mfd: max77693: Init max77693->dev " Axel Lin
  2013-01-22  3:24 ` [PATCH 1/2] mfd: max77686: Init max77686->dev " Samuel Ortiz
  0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2012-12-24 16:16 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Chiwoong Byun, Jonghwa Lee, Myungjoo Ham, Kyungmin Park,
	linux-kernel

Current code uses max77686->dev in the dev_err call before setting it to
&i2c->dev. Fix it.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/mfd/max77686.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index f6878f8..4d73963 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -93,15 +93,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	if (max77686 == NULL)
 		return -ENOMEM;
 
-	max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
-	if (IS_ERR(max77686->regmap)) {
-		ret = PTR_ERR(max77686->regmap);
-		dev_err(max77686->dev, "Failed to allocate register map: %d\n",
-				ret);
-		kfree(max77686);
-		return ret;
-	}
-
 	i2c_set_clientdata(i2c, max77686);
 	max77686->dev = &i2c->dev;
 	max77686->i2c = i2c;
@@ -111,6 +102,15 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
 	max77686->irq_gpio = pdata->irq_gpio;
 	max77686->irq = i2c->irq;
 
+	max77686->regmap = regmap_init_i2c(i2c, &max77686_regmap_config);
+	if (IS_ERR(max77686->regmap)) {
+		ret = PTR_ERR(max77686->regmap);
+		dev_err(max77686->dev, "Failed to allocate register map: %d\n",
+				ret);
+		kfree(max77686);
+		return ret;
+	}
+
 	if (regmap_read(max77686->regmap,
 			 MAX77686_REG_DEVICE_ID, &data) < 0) {
 		dev_err(max77686->dev,
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mfd: max77693: Init max77693->dev before using it
  2012-12-24 16:16 [PATCH 1/2] mfd: max77686: Init max77686->dev before using it Axel Lin
@ 2012-12-24 16:28 ` Axel Lin
  2013-01-22  3:30   ` Samuel Ortiz
  2013-01-22  3:24 ` [PATCH 1/2] mfd: max77686: Init max77686->dev " Samuel Ortiz
  1 sibling, 1 reply; 4+ messages in thread
From: Axel Lin @ 2012-12-24 16:28 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Chiwoong Byun, Jonghwa Lee, Myungjoo Ham, Kyungmin Park,
	linux-kernel

Current code uses max77693->dev in the dev_err call before setting it to
&i2c->dev. Fix it.

This patch also includes below cleanups:
 - Move checking pdata earlier and show dev_err if no platform data found.
 - Remove unnecessary err_regmap goto label.
 - Unregister i2c devices if regmap init for muic fails.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/mfd/max77693.c |   34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/mfd/max77693.c b/drivers/mfd/max77693.c
index cc5155e..9e60fed 100644
--- a/drivers/mfd/max77693.c
+++ b/drivers/mfd/max77693.c
@@ -114,35 +114,37 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 	u8 reg_data;
 	int ret = 0;
 
+	if (!pdata) {
+		dev_err(&i2c->dev, "No platform data found.\n");
+		return -EINVAL;
+	}
+
 	max77693 = devm_kzalloc(&i2c->dev,
 			sizeof(struct max77693_dev), GFP_KERNEL);
 	if (max77693 == NULL)
 		return -ENOMEM;
 
-	max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
-	if (IS_ERR(max77693->regmap)) {
-		ret = PTR_ERR(max77693->regmap);
-		dev_err(max77693->dev,"failed to allocate register map: %d\n",
-				ret);
-		goto err_regmap;
-	}
-
 	i2c_set_clientdata(i2c, max77693);
 	max77693->dev = &i2c->dev;
 	max77693->i2c = i2c;
 	max77693->irq = i2c->irq;
 	max77693->type = id->driver_data;
 
-	if (!pdata)
-		goto err_regmap;
+	max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
+	if (IS_ERR(max77693->regmap)) {
+		ret = PTR_ERR(max77693->regmap);
+		dev_err(max77693->dev, "failed to allocate register map: %d\n",
+				ret);
+		return ret;
+	}
 
 	max77693->wakeup = pdata->wakeup;
 
-	if (max77693_read_reg(max77693->regmap,
-				MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
+	ret = max77693_read_reg(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2,
+				&reg_data);
+	if (ret < 0) {
 		dev_err(max77693->dev, "device not found on this channel\n");
-		ret = -ENODEV;
-		goto err_regmap;
+		return ret;
 	} else
 		dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);
 
@@ -163,7 +165,7 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 		ret = PTR_ERR(max77693->regmap_muic);
 		dev_err(max77693->dev,
 			"failed to allocate register map: %d\n", ret);
-		goto err_regmap;
+		goto err_regmap_muic;
 	}
 
 	ret = max77693_irq_init(max77693);
@@ -184,9 +186,9 @@ static int max77693_i2c_probe(struct i2c_client *i2c,
 err_mfd:
 	max77693_irq_exit(max77693);
 err_irq:
+err_regmap_muic:
 	i2c_unregister_device(max77693->muic);
 	i2c_unregister_device(max77693->haptic);
-err_regmap:
 	return ret;
 }
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mfd: max77686: Init max77686->dev before using it
  2012-12-24 16:16 [PATCH 1/2] mfd: max77686: Init max77686->dev before using it Axel Lin
  2012-12-24 16:28 ` [PATCH 2/2] mfd: max77693: Init max77693->dev " Axel Lin
@ 2013-01-22  3:24 ` Samuel Ortiz
  1 sibling, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2013-01-22  3:24 UTC (permalink / raw)
  To: Axel Lin
  Cc: Chiwoong Byun, Jonghwa Lee, Myungjoo Ham, Kyungmin Park,
	linux-kernel

Hi Axel,

On Tue, Dec 25, 2012 at 12:16:43AM +0800, Axel Lin wrote:
> Current code uses max77686->dev in the dev_err call before setting it to
> &i2c->dev. Fix it.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/mfd/max77686.c |   18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
Applied to my for-linus branch, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] mfd: max77693: Init max77693->dev before using it
  2012-12-24 16:28 ` [PATCH 2/2] mfd: max77693: Init max77693->dev " Axel Lin
@ 2013-01-22  3:30   ` Samuel Ortiz
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2013-01-22  3:30 UTC (permalink / raw)
  To: Axel Lin
  Cc: Chiwoong Byun, Jonghwa Lee, Myungjoo Ham, Kyungmin Park,
	linux-kernel

Hi Axel,

On Tue, Dec 25, 2012 at 12:28:36AM +0800, Axel Lin wrote:
> Current code uses max77693->dev in the dev_err call before setting it to
> &i2c->dev. Fix it.
> 
> This patch also includes below cleanups:
>  - Move checking pdata earlier and show dev_err if no platform data found.
>  - Remove unnecessary err_regmap goto label.
>  - Unregister i2c devices if regmap init for muic fails.
> 
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/mfd/max77693.c |   34 ++++++++++++++++++----------------
>  1 file changed, 18 insertions(+), 16 deletions(-)
Applied as well, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-01-22  3:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-24 16:16 [PATCH 1/2] mfd: max77686: Init max77686->dev before using it Axel Lin
2012-12-24 16:28 ` [PATCH 2/2] mfd: max77693: Init max77693->dev " Axel Lin
2013-01-22  3:30   ` Samuel Ortiz
2013-01-22  3:24 ` [PATCH 1/2] mfd: max77686: Init max77686->dev " Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox