public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control
@ 2015-10-02 12:29 Charles Keepax
  2015-10-02 12:29 ` [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state Charles Keepax
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Charles Keepax @ 2015-10-02 12:29 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel, rf, sameo

From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

Currently DCVDD isolation is enabled and disabled for
runtime_suspend and runtime_resume. Future codecs will not
have the isolation control so to prepare for these codecs
this patch factors out the isolation control allowing it to
be called as needed in the existing codec-specific switch cases.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c |  108 +++++++++++++++++++++++++-------------------
 1 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index acf3548..29be262 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -460,6 +460,33 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona)
 }
 
 #ifdef CONFIG_PM
+static int arizona_isolate_dcvdd(struct arizona *arizona)
+{
+	int ret;
+
+	ret = regmap_update_bits(arizona->regmap,
+				 ARIZONA_ISOLATION_CONTROL,
+				 ARIZONA_ISOLATE_DCVDD1,
+				 ARIZONA_ISOLATE_DCVDD1);
+	if (ret != 0)
+		dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n", ret);
+
+	return ret;
+}
+
+static int arizona_connect_dcvdd(struct arizona *arizona)
+{
+	int ret;
+
+	ret = regmap_update_bits(arizona->regmap,
+				 ARIZONA_ISOLATION_CONTROL,
+				 ARIZONA_ISOLATE_DCVDD1, 0);
+	if (ret != 0)
+		dev_err(arizona->dev, "Failed to connect DCVDD: %d\n", ret);
+
+	return ret;
+}
+
 static int arizona_runtime_resume(struct device *dev)
 {
 	struct arizona *arizona = dev_get_drvdata(dev);
@@ -499,14 +526,9 @@ static int arizona_runtime_resume(struct device *dev)
 	switch (arizona->type) {
 	case WM5102:
 		if (arizona->external_dcvdd) {
-			ret = regmap_update_bits(arizona->regmap,
-						 ARIZONA_ISOLATION_CONTROL,
-						 ARIZONA_ISOLATE_DCVDD1, 0);
-			if (ret != 0) {
-				dev_err(arizona->dev,
-					"Failed to connect DCVDD: %d\n", ret);
+			ret = arizona_connect_dcvdd(arizona);
+			if (ret != 0)
 				goto err;
-			}
 		}
 
 		ret = wm5102_patch(arizona);
@@ -531,14 +553,9 @@ static int arizona_runtime_resume(struct device *dev)
 			goto err;
 
 		if (arizona->external_dcvdd) {
-			ret = regmap_update_bits(arizona->regmap,
-						 ARIZONA_ISOLATION_CONTROL,
-						 ARIZONA_ISOLATE_DCVDD1, 0);
-			if (ret) {
-				dev_err(arizona->dev,
-					"Failed to connect DCVDD: %d\n", ret);
+			ret = arizona_connect_dcvdd(arizona);
+			if (ret != 0)
 				goto err;
-			}
 		} else {
 			/*
 			 * As this is only called for the internal regulator
@@ -569,14 +586,9 @@ static int arizona_runtime_resume(struct device *dev)
 			goto err;
 
 		if (arizona->external_dcvdd) {
-			ret = regmap_update_bits(arizona->regmap,
-						 ARIZONA_ISOLATION_CONTROL,
-						 ARIZONA_ISOLATE_DCVDD1, 0);
-			if (ret != 0) {
-				dev_err(arizona->dev,
-					"Failed to connect DCVDD: %d\n", ret);
+			ret = arizona_connect_dcvdd(arizona);
+			if (ret != 0)
 				goto err;
-			}
 		}
 		break;
 	}
@@ -609,37 +621,36 @@ static int arizona_runtime_suspend(struct device *dev)
 		return ret;
 	}
 
-	if (arizona->external_dcvdd) {
-		ret = regmap_update_bits(arizona->regmap,
-					 ARIZONA_ISOLATION_CONTROL,
-					 ARIZONA_ISOLATE_DCVDD1,
-					 ARIZONA_ISOLATE_DCVDD1);
-		if (ret != 0) {
-			dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n",
-				ret);
-			return ret;
-		}
-	}
-
 	switch (arizona->type) {
 	case WM5110:
 	case WM8280:
-		if (arizona->external_dcvdd)
-			break;
-
-		/*
-		 * As this is only called for the internal regulator
-		 * (where we know voltage ranges available) it is ok
-		 * to request an exact range.
-		 */
-		ret = regulator_set_voltage(arizona->dcvdd, 1175000, 1175000);
-		if (ret < 0) {
-			dev_err(arizona->dev,
-				"Failed to set suspend voltage: %d\n", ret);
-			return ret;
+		if (arizona->external_dcvdd) {
+			ret = arizona_isolate_dcvdd(arizona);
+			if (ret != 0)
+				return ret;
+		} else {
+			/*
+			 * As this is only called for the internal regulator
+			 * (where we know voltage ranges available) it is ok
+			 * to request an exact range.
+			 */
+			ret = regulator_set_voltage(arizona->dcvdd,
+						    1175000, 1175000);
+			if (ret < 0) {
+				dev_err(arizona->dev,
+					"Failed to set suspend voltage: %d\n",
+					ret);
+				return ret;
+			}
 		}
 		break;
 	case WM5102:
+		if (arizona->external_dcvdd) {
+			ret = arizona_isolate_dcvdd(arizona);
+			if (ret != 0)
+				return ret;
+		}
+
 		if (!(val & ARIZONA_JD1_ENA)) {
 			ret = regmap_write(arizona->regmap,
 					   ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
@@ -652,6 +663,11 @@ static int arizona_runtime_suspend(struct device *dev)
 		}
 		break;
 	default:
+		if (arizona->external_dcvdd) {
+			ret = arizona_isolate_dcvdd(arizona);
+			if (ret != 0)
+				return ret;
+		}
 		break;
 	}
 
-- 
1.7.2.5


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

* [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state
  2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
@ 2015-10-02 12:29 ` Charles Keepax
  2015-10-13  9:24   ` Lee Jones
  2015-10-02 12:29 ` [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn Charles Keepax
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Charles Keepax @ 2015-10-02 12:29 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel, rf, sameo

From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

Currently runtime_suspend will fully power off the codec if
the jack detection is not enabled. Not all future codecs will
have jack detection so to prepare for these codecs this patch
factors out the check so that it be called as needed in the
existing codec-specific switch cases.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c |   41 ++++++++++++++++++++++++++++++++---------
 1 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 29be262..e32d0d3 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -487,6 +487,23 @@ static int arizona_connect_dcvdd(struct arizona *arizona)
 	return ret;
 }
 
+static int arizona_is_jack_det_active(struct arizona *arizona)
+{
+	unsigned int val;
+	int ret;
+
+	ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
+	if (ret) {
+		dev_err(arizona->dev,
+			"Failed to check jack det status: %d\n", ret);
+		return ret;
+	} else if (val & ARIZONA_JD1_ENA) {
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
 static int arizona_runtime_resume(struct device *dev)
 {
 	struct arizona *arizona = dev_get_drvdata(dev);
@@ -610,20 +627,18 @@ err:
 static int arizona_runtime_suspend(struct device *dev)
 {
 	struct arizona *arizona = dev_get_drvdata(dev);
-	unsigned int val;
+	unsigned int jd_active = 0;
 	int ret;
 
 	dev_dbg(arizona->dev, "Entering AoD mode\n");
 
-	ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
-	if (ret) {
-		dev_err(dev, "Failed to check jack det status: %d\n", ret);
-		return ret;
-	}
-
 	switch (arizona->type) {
 	case WM5110:
 	case WM8280:
+		jd_active = arizona_is_jack_det_active(arizona);
+		if (jd_active < 0)
+			return jd_active;
+
 		if (arizona->external_dcvdd) {
 			ret = arizona_isolate_dcvdd(arizona);
 			if (ret != 0)
@@ -645,13 +660,17 @@ static int arizona_runtime_suspend(struct device *dev)
 		}
 		break;
 	case WM5102:
+		jd_active = arizona_is_jack_det_active(arizona);
+		if (jd_active < 0)
+			return jd_active;
+
 		if (arizona->external_dcvdd) {
 			ret = arizona_isolate_dcvdd(arizona);
 			if (ret != 0)
 				return ret;
 		}
 
-		if (!(val & ARIZONA_JD1_ENA)) {
+		if (!jd_active) {
 			ret = regmap_write(arizona->regmap,
 					   ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
 			if (ret) {
@@ -663,6 +682,10 @@ static int arizona_runtime_suspend(struct device *dev)
 		}
 		break;
 	default:
+		jd_active = arizona_is_jack_det_active(arizona);
+		if (jd_active < 0)
+			return jd_active;
+
 		if (arizona->external_dcvdd) {
 			ret = arizona_isolate_dcvdd(arizona);
 			if (ret != 0)
@@ -676,7 +699,7 @@ static int arizona_runtime_suspend(struct device *dev)
 	regulator_disable(arizona->dcvdd);
 
 	/* Allow us to completely power down if no jack detection */
-	if (!(val & ARIZONA_JD1_ENA)) {
+	if (!jd_active) {
 		dev_dbg(arizona->dev, "Fully powering off\n");
 
 		arizona->has_fully_powered_off = true;
-- 
1.7.2.5


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

* [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn
  2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
  2015-10-02 12:29 ` [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state Charles Keepax
@ 2015-10-02 12:29 ` Charles Keepax
  2015-10-13  9:24   ` Lee Jones
  2015-10-02 12:29 ` [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices Charles Keepax
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Charles Keepax @ 2015-10-02 12:29 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel, rf, sameo

From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

If the declared codec type doesn't match the detected type
we issue a log message but carry on registering the device,
so a dev_warn() is appropriate rather than a dev_err()

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index e32d0d3..c3f88e5 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -1130,8 +1130,8 @@ int arizona_dev_init(struct arizona *arizona)
 	case 0x5102:
 		type_name = "WM5102";
 		if (arizona->type != WM5102) {
-			dev_err(arizona->dev, "WM5102 registered as %d\n",
-				arizona->type);
+			dev_warn(arizona->dev, "WM5102 registered as %d\n",
+				 arizona->type);
 			arizona->type = WM5102;
 		}
 		apply_patch = wm5102_patch;
@@ -1149,8 +1149,8 @@ int arizona_dev_init(struct arizona *arizona)
 			break;
 		default:
 			type_name = "WM5110";
-			dev_err(arizona->dev, "WM5110 registered as %d\n",
-				arizona->type);
+			dev_warn(arizona->dev, "WM5110 registered as %d\n",
+				 arizona->type);
 			arizona->type = WM5110;
 			break;
 		}
@@ -1161,8 +1161,8 @@ int arizona_dev_init(struct arizona *arizona)
 	case 0x8997:
 		type_name = "WM8997";
 		if (arizona->type != WM8997) {
-			dev_err(arizona->dev, "WM8997 registered as %d\n",
-				arizona->type);
+			dev_warn(arizona->dev, "WM8997 registered as %d\n",
+				 arizona->type);
 			arizona->type = WM8997;
 		}
 		apply_patch = wm8997_patch;
@@ -1181,8 +1181,8 @@ int arizona_dev_init(struct arizona *arizona)
 
 		default:
 			type_name = "WM8998";
-			dev_err(arizona->dev, "WM8998 registered as %d\n",
-				arizona->type);
+			dev_warn(arizona->dev, "WM8998 registered as %d\n",
+				 arizona->type);
 			arizona->type = WM8998;
 		}
 
-- 
1.7.2.5


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

* [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices
  2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
  2015-10-02 12:29 ` [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state Charles Keepax
  2015-10-02 12:29 ` [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn Charles Keepax
@ 2015-10-02 12:29 ` Charles Keepax
  2015-10-13  9:24   ` Lee Jones
  2015-10-02 12:29 ` [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs Charles Keepax
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Charles Keepax @ 2015-10-02 12:29 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel, rf, sameo

From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

The code was using a switch on the code type to execute
one of several mfd_add_devices() calls. We're already
switching on the code type earlier in the function to
select the correct patch function so we can roll selection
of the mfd device table into the same switch.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c |   36 ++++++++++++++----------------------
 1 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index c3f88e5..39899bf 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -24,6 +24,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/regulator/machine.h>
 #include <linux/slab.h>
+#include <linux/platform_device.h>
 
 #include <linux/mfd/arizona/core.h>
 #include <linux/mfd/arizona/registers.h>
@@ -965,7 +966,8 @@ int arizona_dev_init(struct arizona *arizona)
 	const char *type_name;
 	unsigned int reg, val, mask;
 	int (*apply_patch)(struct arizona *) = NULL;
-	int ret, i;
+	const struct mfd_cell *subdevs = NULL;
+	int n_subdevs, ret, i;
 
 	dev_set_drvdata(arizona->dev, arizona);
 	mutex_init(&arizona->clk_lock);
@@ -1136,6 +1138,8 @@ int arizona_dev_init(struct arizona *arizona)
 		}
 		apply_patch = wm5102_patch;
 		arizona->rev &= 0x7;
+		subdevs = wm5102_devs;
+		n_subdevs = ARRAY_SIZE(wm5102_devs);
 		break;
 #endif
 #ifdef CONFIG_MFD_WM5110
@@ -1155,6 +1159,8 @@ int arizona_dev_init(struct arizona *arizona)
 			break;
 		}
 		apply_patch = wm5110_patch;
+		subdevs = wm5110_devs;
+		n_subdevs = ARRAY_SIZE(wm5110_devs);
 		break;
 #endif
 #ifdef CONFIG_MFD_WM8997
@@ -1166,6 +1172,8 @@ int arizona_dev_init(struct arizona *arizona)
 			arizona->type = WM8997;
 		}
 		apply_patch = wm8997_patch;
+		subdevs = wm8997_devs;
+		n_subdevs = ARRAY_SIZE(wm8997_devs);
 		break;
 #endif
 #ifdef CONFIG_MFD_WM8998
@@ -1187,6 +1195,8 @@ int arizona_dev_init(struct arizona *arizona)
 		}
 
 		apply_patch = wm8998_patch;
+		subdevs = wm8998_devs;
+		n_subdevs = ARRAY_SIZE(wm8998_devs);
 		break;
 #endif
 	default:
@@ -1379,28 +1389,10 @@ int arizona_dev_init(struct arizona *arizona)
 	arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked",
 			    arizona_underclocked, arizona);
 
-	switch (arizona->type) {
-	case WM5102:
-		ret = mfd_add_devices(arizona->dev, -1, wm5102_devs,
-				      ARRAY_SIZE(wm5102_devs), NULL, 0, NULL);
-		break;
-	case WM5110:
-	case WM8280:
-		ret = mfd_add_devices(arizona->dev, -1, wm5110_devs,
-				      ARRAY_SIZE(wm5110_devs), NULL, 0, NULL);
-		break;
-	case WM8997:
-		ret = mfd_add_devices(arizona->dev, -1, wm8997_devs,
-				      ARRAY_SIZE(wm8997_devs), NULL, 0, NULL);
-		break;
-	case WM8998:
-	case WM1814:
-		ret = mfd_add_devices(arizona->dev, -1, wm8998_devs,
-				      ARRAY_SIZE(wm8998_devs), NULL, 0, NULL);
-		break;
-	}
+	ret = mfd_add_devices(arizona->dev, PLATFORM_DEVID_NONE,
+			      subdevs, n_subdevs, NULL, 0, NULL);
 
-	if (ret != 0) {
+	if (ret) {
 		dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret);
 		goto err_irq;
 	}
-- 
1.7.2.5


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

* [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs
  2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
                   ` (2 preceding siblings ...)
  2015-10-02 12:29 ` [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices Charles Keepax
@ 2015-10-02 12:29 ` Charles Keepax
  2015-10-13  9:23   ` Lee Jones
  2015-10-13  9:25   ` Lee Jones
  2015-10-02 12:29 ` [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config Charles Keepax
  2015-10-13  9:23 ` [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Lee Jones
  5 siblings, 2 replies; 13+ messages in thread
From: Charles Keepax @ 2015-10-02 12:29 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel, rf, sameo

From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

Remove the use of #ifdefs around each case statement of the chip ID
and type validation switches.

We must ensure that the contained code still compiles to nothing if
support for that codec was not built into the kernel, to prevent
creation of link references to missing functions. So the ifdefs are
replaced with a use of the IS_ENABLED() macro.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---

Changes since v1:
 - Changed IS_ENABLED if statements such that they wrap all code
   that we want eliminated, to ensure that it does indeed get
   eliminated.

Thanks,
Charles

 drivers/mfd/arizona-core.c |  129 ++++++++++++++++++++++++--------------------
 drivers/mfd/arizona-i2c.c  |   28 +++++-----
 drivers/mfd/arizona-spi.c  |   18 ++++---
 3 files changed, 97 insertions(+), 78 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 39899bf..4e49210 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -1128,82 +1128,95 @@ int arizona_dev_init(struct arizona *arizona)
 	arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
 
 	switch (reg) {
-#ifdef CONFIG_MFD_WM5102
 	case 0x5102:
-		type_name = "WM5102";
-		if (arizona->type != WM5102) {
-			dev_warn(arizona->dev, "WM5102 registered as %d\n",
-				 arizona->type);
-			arizona->type = WM5102;
+		if (IS_ENABLED(CONFIG_MFD_WM5102)) {
+			type_name = "WM5102";
+			if (arizona->type != WM5102) {
+				dev_warn(arizona->dev,
+					 "WM5102 registered as %d\n",
+					 arizona->type);
+				arizona->type = WM5102;
+			}
+
+			apply_patch = wm5102_patch;
+			arizona->rev &= 0x7;
+			subdevs = wm5102_devs;
+			n_subdevs = ARRAY_SIZE(wm5102_devs);
 		}
-		apply_patch = wm5102_patch;
-		arizona->rev &= 0x7;
-		subdevs = wm5102_devs;
-		n_subdevs = ARRAY_SIZE(wm5102_devs);
 		break;
-#endif
-#ifdef CONFIG_MFD_WM5110
 	case 0x5110:
-		switch (arizona->type) {
-		case WM5110:
-			type_name = "WM5110";
-			break;
-		case WM8280:
-			type_name = "WM8280";
-			break;
-		default:
-			type_name = "WM5110";
-			dev_warn(arizona->dev, "WM5110 registered as %d\n",
-				 arizona->type);
-			arizona->type = WM5110;
-			break;
+		if (IS_ENABLED(CONFIG_MFD_WM5110)) {
+			switch (arizona->type) {
+			case WM5110:
+				type_name = "WM5110";
+				break;
+			case WM8280:
+				type_name = "WM8280";
+				break;
+			default:
+				type_name = "WM5110";
+				dev_warn(arizona->dev,
+					 "WM5110 registered as %d\n",
+					 arizona->type);
+				arizona->type = WM5110;
+				break;
+			}
+
+			apply_patch = wm5110_patch;
+			subdevs = wm5110_devs;
+			n_subdevs = ARRAY_SIZE(wm5110_devs);
 		}
-		apply_patch = wm5110_patch;
-		subdevs = wm5110_devs;
-		n_subdevs = ARRAY_SIZE(wm5110_devs);
 		break;
-#endif
-#ifdef CONFIG_MFD_WM8997
 	case 0x8997:
-		type_name = "WM8997";
-		if (arizona->type != WM8997) {
-			dev_warn(arizona->dev, "WM8997 registered as %d\n",
-				 arizona->type);
-			arizona->type = WM8997;
+		if (IS_ENABLED(CONFIG_MFD_WM8997)) {
+			type_name = "WM8997";
+			if (arizona->type != WM8997) {
+				dev_warn(arizona->dev,
+					 "WM8997 registered as %d\n",
+					 arizona->type);
+				arizona->type = WM8997;
+			}
+
+			apply_patch = wm8997_patch;
+			subdevs = wm8997_devs;
+			n_subdevs = ARRAY_SIZE(wm8997_devs);
 		}
-		apply_patch = wm8997_patch;
-		subdevs = wm8997_devs;
-		n_subdevs = ARRAY_SIZE(wm8997_devs);
 		break;
-#endif
-#ifdef CONFIG_MFD_WM8998
 	case 0x6349:
-		switch (arizona->type) {
-		case WM8998:
-			type_name = "WM8998";
-			break;
-
-		case WM1814:
-			type_name = "WM1814";
-			break;
+		if (IS_ENABLED(CONFIG_MFD_WM8998)) {
+			switch (arizona->type) {
+			case WM8998:
+				type_name = "WM8998";
+				break;
+
+			case WM1814:
+				type_name = "WM1814";
+				break;
+
+			default:
+				type_name = "WM8998";
+				dev_warn(arizona->dev,
+					 "WM8998 registered as %d\n",
+					 arizona->type);
+				arizona->type = WM8998;
+			}
 
-		default:
-			type_name = "WM8998";
-			dev_warn(arizona->dev, "WM8998 registered as %d\n",
-				 arizona->type);
-			arizona->type = WM8998;
+			apply_patch = wm8998_patch;
+			subdevs = wm8998_devs;
+			n_subdevs = ARRAY_SIZE(wm8998_devs);
 		}
-
-		apply_patch = wm8998_patch;
-		subdevs = wm8998_devs;
-		n_subdevs = ARRAY_SIZE(wm8998_devs);
 		break;
-#endif
 	default:
 		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
 		goto err_reset;
 	}
 
+	if (!subdevs) {
+		dev_err(arizona->dev,
+			"No kernel support for device ID %x\n", reg);
+		goto err_reset;
+	}
+
 	dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
 
 	if (apply_patch) {
diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
index cea1b40..914bdce 100644
--- a/drivers/mfd/arizona-i2c.c
+++ b/drivers/mfd/arizona-i2c.c
@@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
 			     const struct i2c_device_id *id)
 {
 	struct arizona *arizona;
-	const struct regmap_config *regmap_config;
+	const struct regmap_config *regmap_config = NULL;
 	unsigned long type;
 	int ret;
 
@@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
 		type = id->driver_data;
 
 	switch (type) {
-#ifdef CONFIG_MFD_WM5102
 	case WM5102:
-		regmap_config = &wm5102_i2c_regmap;
+		if (IS_ENABLED(CONFIG_MFD_WM5102))
+			regmap_config = &wm5102_i2c_regmap;
 		break;
-#endif
-#ifdef CONFIG_MFD_WM5110
 	case WM5110:
 	case WM8280:
-		regmap_config = &wm5110_i2c_regmap;
+		if (IS_ENABLED(CONFIG_MFD_WM5110))
+			regmap_config = &wm5110_i2c_regmap;
 		break;
-#endif
-#ifdef CONFIG_MFD_WM8997
 	case WM8997:
-		regmap_config = &wm8997_i2c_regmap;
+		if (IS_ENABLED(CONFIG_MFD_WM8997))
+			regmap_config = &wm8997_i2c_regmap;
 		break;
-#endif
-#ifdef CONFIG_MFD_WM8998
 	case WM8998:
 	case WM1814:
-		regmap_config = &wm8998_i2c_regmap;
+		if (IS_ENABLED(CONFIG_MFD_WM8998))
+			regmap_config = &wm8998_i2c_regmap;
 		break;
-#endif
 	default:
 		dev_err(&i2c->dev, "Unknown device type %ld\n",
 			id->driver_data);
 		return -EINVAL;
 	}
 
+	if (!regmap_config) {
+		dev_err(&i2c->dev,
+			"No kernel support for device type %ld\n", type);
+		return -EINVAL;
+	}
+
 	arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL);
 	if (arizona == NULL)
 		return -ENOMEM;
diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
index 1e845f6..850a63a 100644
--- a/drivers/mfd/arizona-spi.c
+++ b/drivers/mfd/arizona-spi.c
@@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi)
 {
 	const struct spi_device_id *id = spi_get_device_id(spi);
 	struct arizona *arizona;
-	const struct regmap_config *regmap_config;
+	const struct regmap_config *regmap_config = NULL;
 	unsigned long type;
 	int ret;
 
@@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi)
 		type = id->driver_data;
 
 	switch (type) {
-#ifdef CONFIG_MFD_WM5102
 	case WM5102:
-		regmap_config = &wm5102_spi_regmap;
+		if (IS_ENABLED(CONFIG_MFD_WM5102))
+			regmap_config = &wm5102_spi_regmap;
 		break;
-#endif
-#ifdef CONFIG_MFD_WM5110
 	case WM5110:
 	case WM8280:
-		regmap_config = &wm5110_spi_regmap;
+		if (IS_ENABLED(CONFIG_MFD_WM5110))
+			regmap_config = &wm5110_spi_regmap;
 		break;
-#endif
 	default:
 		dev_err(&spi->dev, "Unknown device type %ld\n",
 			id->driver_data);
 		return -EINVAL;
 	}
 
+	if (!regmap_config) {
+		dev_err(&spi->dev,
+			"No kernel support for device type %ld\n", type);
+		return -EINVAL;
+	}
+
 	arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL);
 	if (arizona == NULL)
 		return -ENOMEM;
-- 
1.7.2.5


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

* [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config
  2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
                   ` (3 preceding siblings ...)
  2015-10-02 12:29 ` [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs Charles Keepax
@ 2015-10-02 12:29 ` Charles Keepax
  2015-10-13  9:25   ` Lee Jones
  2015-10-13  9:23 ` [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Lee Jones
  5 siblings, 1 reply; 13+ messages in thread
From: Charles Keepax @ 2015-10-02 12:29 UTC (permalink / raw)
  To: lee.jones; +Cc: patches, linux-kernel, rf, sameo

From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>

In the case of a device tree config the code uses the device ID
from the DT entry to check which codec is required but when storing
the ID into struct arizona it was always using the non-DT SPI device
table to get an ID.

This patch changes the code to store the correct ID into struct arizona.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-i2c.c |    5 ++---
 drivers/mfd/arizona-spi.c |    5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
index 914bdce..4e3afd1 100644
--- a/drivers/mfd/arizona-i2c.c
+++ b/drivers/mfd/arizona-i2c.c
@@ -56,8 +56,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
 			regmap_config = &wm8998_i2c_regmap;
 		break;
 	default:
-		dev_err(&i2c->dev, "Unknown device type %ld\n",
-			id->driver_data);
+		dev_err(&i2c->dev, "Unknown device type %ld\n", type);
 		return -EINVAL;
 	}
 
@@ -79,7 +78,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
 		return ret;
 	}
 
-	arizona->type = id->driver_data;
+	arizona->type = type;
 	arizona->dev = &i2c->dev;
 	arizona->irq = i2c->irq;
 
diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
index 850a63a..8cffb1c 100644
--- a/drivers/mfd/arizona-spi.c
+++ b/drivers/mfd/arizona-spi.c
@@ -47,8 +47,7 @@ static int arizona_spi_probe(struct spi_device *spi)
 			regmap_config = &wm5110_spi_regmap;
 		break;
 	default:
-		dev_err(&spi->dev, "Unknown device type %ld\n",
-			id->driver_data);
+		dev_err(&spi->dev, "Unknown device type %ld\n", type);
 		return -EINVAL;
 	}
 
@@ -70,7 +69,7 @@ static int arizona_spi_probe(struct spi_device *spi)
 		return ret;
 	}
 
-	arizona->type = id->driver_data;
+	arizona->type = type;
 	arizona->dev = &spi->dev;
 	arizona->irq = spi->irq;
 
-- 
1.7.2.5


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

* Re: [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs
  2015-10-02 12:29 ` [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs Charles Keepax
@ 2015-10-13  9:23   ` Lee Jones
  2015-10-13  9:25   ` Lee Jones
  1 sibling, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:23 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> Remove the use of #ifdefs around each case statement of the chip ID
> and type validation switches.
> 
> We must ensure that the contained code still compiles to nothing if
> support for that codec was not built into the kernel, to prevent
> creation of link references to missing functions. So the ifdefs are
> replaced with a use of the IS_ENABLED() macro.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
> 
> Changes since v1:
>  - Changed IS_ENABLED if statements such that they wrap all code
>    that we want eliminated, to ensure that it does indeed get
>    eliminated.
> 
> Thanks,
> Charles
> 
>  drivers/mfd/arizona-core.c |  129 ++++++++++++++++++++++++--------------------
>  drivers/mfd/arizona-i2c.c  |   28 +++++-----
>  drivers/mfd/arizona-spi.c  |   18 ++++---
>  3 files changed, 97 insertions(+), 78 deletions(-)

Acked-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index 39899bf..4e49210 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -1128,82 +1128,95 @@ int arizona_dev_init(struct arizona *arizona)
>  	arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
>  
>  	switch (reg) {
> -#ifdef CONFIG_MFD_WM5102
>  	case 0x5102:
> -		type_name = "WM5102";
> -		if (arizona->type != WM5102) {
> -			dev_warn(arizona->dev, "WM5102 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM5102;
> +		if (IS_ENABLED(CONFIG_MFD_WM5102)) {
> +			type_name = "WM5102";
> +			if (arizona->type != WM5102) {
> +				dev_warn(arizona->dev,
> +					 "WM5102 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM5102;
> +			}
> +
> +			apply_patch = wm5102_patch;
> +			arizona->rev &= 0x7;
> +			subdevs = wm5102_devs;
> +			n_subdevs = ARRAY_SIZE(wm5102_devs);
>  		}
> -		apply_patch = wm5102_patch;
> -		arizona->rev &= 0x7;
> -		subdevs = wm5102_devs;
> -		n_subdevs = ARRAY_SIZE(wm5102_devs);
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
>  	case 0x5110:
> -		switch (arizona->type) {
> -		case WM5110:
> -			type_name = "WM5110";
> -			break;
> -		case WM8280:
> -			type_name = "WM8280";
> -			break;
> -		default:
> -			type_name = "WM5110";
> -			dev_warn(arizona->dev, "WM5110 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM5110;
> -			break;
> +		if (IS_ENABLED(CONFIG_MFD_WM5110)) {
> +			switch (arizona->type) {
> +			case WM5110:
> +				type_name = "WM5110";
> +				break;
> +			case WM8280:
> +				type_name = "WM8280";
> +				break;
> +			default:
> +				type_name = "WM5110";
> +				dev_warn(arizona->dev,
> +					 "WM5110 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM5110;
> +				break;
> +			}
> +
> +			apply_patch = wm5110_patch;
> +			subdevs = wm5110_devs;
> +			n_subdevs = ARRAY_SIZE(wm5110_devs);
>  		}
> -		apply_patch = wm5110_patch;
> -		subdevs = wm5110_devs;
> -		n_subdevs = ARRAY_SIZE(wm5110_devs);
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8997
>  	case 0x8997:
> -		type_name = "WM8997";
> -		if (arizona->type != WM8997) {
> -			dev_warn(arizona->dev, "WM8997 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM8997;
> +		if (IS_ENABLED(CONFIG_MFD_WM8997)) {
> +			type_name = "WM8997";
> +			if (arizona->type != WM8997) {
> +				dev_warn(arizona->dev,
> +					 "WM8997 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM8997;
> +			}
> +
> +			apply_patch = wm8997_patch;
> +			subdevs = wm8997_devs;
> +			n_subdevs = ARRAY_SIZE(wm8997_devs);
>  		}
> -		apply_patch = wm8997_patch;
> -		subdevs = wm8997_devs;
> -		n_subdevs = ARRAY_SIZE(wm8997_devs);
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8998
>  	case 0x6349:
> -		switch (arizona->type) {
> -		case WM8998:
> -			type_name = "WM8998";
> -			break;
> -
> -		case WM1814:
> -			type_name = "WM1814";
> -			break;
> +		if (IS_ENABLED(CONFIG_MFD_WM8998)) {
> +			switch (arizona->type) {
> +			case WM8998:
> +				type_name = "WM8998";
> +				break;
> +
> +			case WM1814:
> +				type_name = "WM1814";
> +				break;
> +
> +			default:
> +				type_name = "WM8998";
> +				dev_warn(arizona->dev,
> +					 "WM8998 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM8998;
> +			}
>  
> -		default:
> -			type_name = "WM8998";
> -			dev_warn(arizona->dev, "WM8998 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM8998;
> +			apply_patch = wm8998_patch;
> +			subdevs = wm8998_devs;
> +			n_subdevs = ARRAY_SIZE(wm8998_devs);
>  		}
> -
> -		apply_patch = wm8998_patch;
> -		subdevs = wm8998_devs;
> -		n_subdevs = ARRAY_SIZE(wm8998_devs);
>  		break;
> -#endif
>  	default:
>  		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
>  		goto err_reset;
>  	}
>  
> +	if (!subdevs) {
> +		dev_err(arizona->dev,
> +			"No kernel support for device ID %x\n", reg);
> +		goto err_reset;
> +	}
> +
>  	dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
>  
>  	if (apply_patch) {
> diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
> index cea1b40..914bdce 100644
> --- a/drivers/mfd/arizona-i2c.c
> +++ b/drivers/mfd/arizona-i2c.c
> @@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
>  			     const struct i2c_device_id *id)
>  {
>  	struct arizona *arizona;
> -	const struct regmap_config *regmap_config;
> +	const struct regmap_config *regmap_config = NULL;
>  	unsigned long type;
>  	int ret;
>  
> @@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
>  		type = id->driver_data;
>  
>  	switch (type) {
> -#ifdef CONFIG_MFD_WM5102
>  	case WM5102:
> -		regmap_config = &wm5102_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5102))
> +			regmap_config = &wm5102_i2c_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
>  	case WM5110:
>  	case WM8280:
> -		regmap_config = &wm5110_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5110))
> +			regmap_config = &wm5110_i2c_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8997
>  	case WM8997:
> -		regmap_config = &wm8997_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM8997))
> +			regmap_config = &wm8997_i2c_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8998
>  	case WM8998:
>  	case WM1814:
> -		regmap_config = &wm8998_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM8998))
> +			regmap_config = &wm8998_i2c_regmap;
>  		break;
> -#endif
>  	default:
>  		dev_err(&i2c->dev, "Unknown device type %ld\n",
>  			id->driver_data);
>  		return -EINVAL;
>  	}
>  
> +	if (!regmap_config) {
> +		dev_err(&i2c->dev,
> +			"No kernel support for device type %ld\n", type);
> +		return -EINVAL;
> +	}
> +
>  	arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL);
>  	if (arizona == NULL)
>  		return -ENOMEM;
> diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
> index 1e845f6..850a63a 100644
> --- a/drivers/mfd/arizona-spi.c
> +++ b/drivers/mfd/arizona-spi.c
> @@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi)
>  {
>  	const struct spi_device_id *id = spi_get_device_id(spi);
>  	struct arizona *arizona;
> -	const struct regmap_config *regmap_config;
> +	const struct regmap_config *regmap_config = NULL;
>  	unsigned long type;
>  	int ret;
>  
> @@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi)
>  		type = id->driver_data;
>  
>  	switch (type) {
> -#ifdef CONFIG_MFD_WM5102
>  	case WM5102:
> -		regmap_config = &wm5102_spi_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5102))
> +			regmap_config = &wm5102_spi_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
>  	case WM5110:
>  	case WM8280:
> -		regmap_config = &wm5110_spi_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5110))
> +			regmap_config = &wm5110_spi_regmap;
>  		break;
> -#endif
>  	default:
>  		dev_err(&spi->dev, "Unknown device type %ld\n",
>  			id->driver_data);
>  		return -EINVAL;
>  	}
>  
> +	if (!regmap_config) {
> +		dev_err(&spi->dev,
> +			"No kernel support for device type %ld\n", type);
> +		return -EINVAL;
> +	}
> +
>  	arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL);
>  	if (arizona == NULL)
>  		return -ENOMEM;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control
  2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
                   ` (4 preceding siblings ...)
  2015-10-02 12:29 ` [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config Charles Keepax
@ 2015-10-13  9:23 ` Lee Jones
  5 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:23 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> Currently DCVDD isolation is enabled and disabled for
> runtime_suspend and runtime_resume. Future codecs will not
> have the isolation control so to prepare for these codecs
> this patch factors out the isolation control allowing it to
> be called as needed in the existing codec-specific switch cases.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c |  108 +++++++++++++++++++++++++-------------------
>  1 files changed, 62 insertions(+), 46 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index acf3548..29be262 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -460,6 +460,33 @@ static int wm5102_clear_write_sequencer(struct arizona *arizona)
>  }
>  
>  #ifdef CONFIG_PM
> +static int arizona_isolate_dcvdd(struct arizona *arizona)
> +{
> +	int ret;
> +
> +	ret = regmap_update_bits(arizona->regmap,
> +				 ARIZONA_ISOLATION_CONTROL,
> +				 ARIZONA_ISOLATE_DCVDD1,
> +				 ARIZONA_ISOLATE_DCVDD1);
> +	if (ret != 0)
> +		dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n", ret);
> +
> +	return ret;
> +}
> +
> +static int arizona_connect_dcvdd(struct arizona *arizona)
> +{
> +	int ret;
> +
> +	ret = regmap_update_bits(arizona->regmap,
> +				 ARIZONA_ISOLATION_CONTROL,
> +				 ARIZONA_ISOLATE_DCVDD1, 0);
> +	if (ret != 0)
> +		dev_err(arizona->dev, "Failed to connect DCVDD: %d\n", ret);
> +
> +	return ret;
> +}
> +
>  static int arizona_runtime_resume(struct device *dev)
>  {
>  	struct arizona *arizona = dev_get_drvdata(dev);
> @@ -499,14 +526,9 @@ static int arizona_runtime_resume(struct device *dev)
>  	switch (arizona->type) {
>  	case WM5102:
>  		if (arizona->external_dcvdd) {
> -			ret = regmap_update_bits(arizona->regmap,
> -						 ARIZONA_ISOLATION_CONTROL,
> -						 ARIZONA_ISOLATE_DCVDD1, 0);
> -			if (ret != 0) {
> -				dev_err(arizona->dev,
> -					"Failed to connect DCVDD: %d\n", ret);
> +			ret = arizona_connect_dcvdd(arizona);
> +			if (ret != 0)
>  				goto err;
> -			}
>  		}
>  
>  		ret = wm5102_patch(arizona);
> @@ -531,14 +553,9 @@ static int arizona_runtime_resume(struct device *dev)
>  			goto err;
>  
>  		if (arizona->external_dcvdd) {
> -			ret = regmap_update_bits(arizona->regmap,
> -						 ARIZONA_ISOLATION_CONTROL,
> -						 ARIZONA_ISOLATE_DCVDD1, 0);
> -			if (ret) {
> -				dev_err(arizona->dev,
> -					"Failed to connect DCVDD: %d\n", ret);
> +			ret = arizona_connect_dcvdd(arizona);
> +			if (ret != 0)
>  				goto err;
> -			}
>  		} else {
>  			/*
>  			 * As this is only called for the internal regulator
> @@ -569,14 +586,9 @@ static int arizona_runtime_resume(struct device *dev)
>  			goto err;
>  
>  		if (arizona->external_dcvdd) {
> -			ret = regmap_update_bits(arizona->regmap,
> -						 ARIZONA_ISOLATION_CONTROL,
> -						 ARIZONA_ISOLATE_DCVDD1, 0);
> -			if (ret != 0) {
> -				dev_err(arizona->dev,
> -					"Failed to connect DCVDD: %d\n", ret);
> +			ret = arizona_connect_dcvdd(arizona);
> +			if (ret != 0)
>  				goto err;
> -			}
>  		}
>  		break;
>  	}
> @@ -609,37 +621,36 @@ static int arizona_runtime_suspend(struct device *dev)
>  		return ret;
>  	}
>  
> -	if (arizona->external_dcvdd) {
> -		ret = regmap_update_bits(arizona->regmap,
> -					 ARIZONA_ISOLATION_CONTROL,
> -					 ARIZONA_ISOLATE_DCVDD1,
> -					 ARIZONA_ISOLATE_DCVDD1);
> -		if (ret != 0) {
> -			dev_err(arizona->dev, "Failed to isolate DCVDD: %d\n",
> -				ret);
> -			return ret;
> -		}
> -	}
> -
>  	switch (arizona->type) {
>  	case WM5110:
>  	case WM8280:
> -		if (arizona->external_dcvdd)
> -			break;
> -
> -		/*
> -		 * As this is only called for the internal regulator
> -		 * (where we know voltage ranges available) it is ok
> -		 * to request an exact range.
> -		 */
> -		ret = regulator_set_voltage(arizona->dcvdd, 1175000, 1175000);
> -		if (ret < 0) {
> -			dev_err(arizona->dev,
> -				"Failed to set suspend voltage: %d\n", ret);
> -			return ret;
> +		if (arizona->external_dcvdd) {
> +			ret = arizona_isolate_dcvdd(arizona);
> +			if (ret != 0)
> +				return ret;
> +		} else {
> +			/*
> +			 * As this is only called for the internal regulator
> +			 * (where we know voltage ranges available) it is ok
> +			 * to request an exact range.
> +			 */
> +			ret = regulator_set_voltage(arizona->dcvdd,
> +						    1175000, 1175000);
> +			if (ret < 0) {
> +				dev_err(arizona->dev,
> +					"Failed to set suspend voltage: %d\n",
> +					ret);
> +				return ret;
> +			}
>  		}
>  		break;
>  	case WM5102:
> +		if (arizona->external_dcvdd) {
> +			ret = arizona_isolate_dcvdd(arizona);
> +			if (ret != 0)
> +				return ret;
> +		}
> +
>  		if (!(val & ARIZONA_JD1_ENA)) {
>  			ret = regmap_write(arizona->regmap,
>  					   ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
> @@ -652,6 +663,11 @@ static int arizona_runtime_suspend(struct device *dev)
>  		}
>  		break;
>  	default:
> +		if (arizona->external_dcvdd) {
> +			ret = arizona_isolate_dcvdd(arizona);
> +			if (ret != 0)
> +				return ret;
> +		}
>  		break;
>  	}
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state
  2015-10-02 12:29 ` [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state Charles Keepax
@ 2015-10-13  9:24   ` Lee Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:24 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> Currently runtime_suspend will fully power off the codec if
> the jack detection is not enabled. Not all future codecs will
> have jack detection so to prepare for these codecs this patch
> factors out the check so that it be called as needed in the
> existing codec-specific switch cases.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c |   41 ++++++++++++++++++++++++++++++++---------
>  1 files changed, 32 insertions(+), 9 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index 29be262..e32d0d3 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -487,6 +487,23 @@ static int arizona_connect_dcvdd(struct arizona *arizona)
>  	return ret;
>  }
>  
> +static int arizona_is_jack_det_active(struct arizona *arizona)
> +{
> +	unsigned int val;
> +	int ret;
> +
> +	ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
> +	if (ret) {
> +		dev_err(arizona->dev,
> +			"Failed to check jack det status: %d\n", ret);
> +		return ret;
> +	} else if (val & ARIZONA_JD1_ENA) {
> +		return 1;
> +	} else {
> +		return 0;
> +	}
> +}
> +
>  static int arizona_runtime_resume(struct device *dev)
>  {
>  	struct arizona *arizona = dev_get_drvdata(dev);
> @@ -610,20 +627,18 @@ err:
>  static int arizona_runtime_suspend(struct device *dev)
>  {
>  	struct arizona *arizona = dev_get_drvdata(dev);
> -	unsigned int val;
> +	unsigned int jd_active = 0;
>  	int ret;
>  
>  	dev_dbg(arizona->dev, "Entering AoD mode\n");
>  
> -	ret = regmap_read(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE, &val);
> -	if (ret) {
> -		dev_err(dev, "Failed to check jack det status: %d\n", ret);
> -		return ret;
> -	}
> -
>  	switch (arizona->type) {
>  	case WM5110:
>  	case WM8280:
> +		jd_active = arizona_is_jack_det_active(arizona);
> +		if (jd_active < 0)
> +			return jd_active;
> +
>  		if (arizona->external_dcvdd) {
>  			ret = arizona_isolate_dcvdd(arizona);
>  			if (ret != 0)
> @@ -645,13 +660,17 @@ static int arizona_runtime_suspend(struct device *dev)
>  		}
>  		break;
>  	case WM5102:
> +		jd_active = arizona_is_jack_det_active(arizona);
> +		if (jd_active < 0)
> +			return jd_active;
> +
>  		if (arizona->external_dcvdd) {
>  			ret = arizona_isolate_dcvdd(arizona);
>  			if (ret != 0)
>  				return ret;
>  		}
>  
> -		if (!(val & ARIZONA_JD1_ENA)) {
> +		if (!jd_active) {
>  			ret = regmap_write(arizona->regmap,
>  					   ARIZONA_WRITE_SEQUENCER_CTRL_3, 0x0);
>  			if (ret) {
> @@ -663,6 +682,10 @@ static int arizona_runtime_suspend(struct device *dev)
>  		}
>  		break;
>  	default:
> +		jd_active = arizona_is_jack_det_active(arizona);
> +		if (jd_active < 0)
> +			return jd_active;
> +
>  		if (arizona->external_dcvdd) {
>  			ret = arizona_isolate_dcvdd(arizona);
>  			if (ret != 0)
> @@ -676,7 +699,7 @@ static int arizona_runtime_suspend(struct device *dev)
>  	regulator_disable(arizona->dcvdd);
>  
>  	/* Allow us to completely power down if no jack detection */
> -	if (!(val & ARIZONA_JD1_ENA)) {
> +	if (!jd_active) {
>  		dev_dbg(arizona->dev, "Fully powering off\n");
>  
>  		arizona->has_fully_powered_off = true;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn
  2015-10-02 12:29 ` [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn Charles Keepax
@ 2015-10-13  9:24   ` Lee Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:24 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> If the declared codec type doesn't match the detected type
> we issue a log message but carry on registering the device,
> so a dev_warn() is appropriate rather than a dev_err()
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c |   16 ++++++++--------
>  1 files changed, 8 insertions(+), 8 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index e32d0d3..c3f88e5 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -1130,8 +1130,8 @@ int arizona_dev_init(struct arizona *arizona)
>  	case 0x5102:
>  		type_name = "WM5102";
>  		if (arizona->type != WM5102) {
> -			dev_err(arizona->dev, "WM5102 registered as %d\n",
> -				arizona->type);
> +			dev_warn(arizona->dev, "WM5102 registered as %d\n",
> +				 arizona->type);
>  			arizona->type = WM5102;
>  		}
>  		apply_patch = wm5102_patch;
> @@ -1149,8 +1149,8 @@ int arizona_dev_init(struct arizona *arizona)
>  			break;
>  		default:
>  			type_name = "WM5110";
> -			dev_err(arizona->dev, "WM5110 registered as %d\n",
> -				arizona->type);
> +			dev_warn(arizona->dev, "WM5110 registered as %d\n",
> +				 arizona->type);
>  			arizona->type = WM5110;
>  			break;
>  		}
> @@ -1161,8 +1161,8 @@ int arizona_dev_init(struct arizona *arizona)
>  	case 0x8997:
>  		type_name = "WM8997";
>  		if (arizona->type != WM8997) {
> -			dev_err(arizona->dev, "WM8997 registered as %d\n",
> -				arizona->type);
> +			dev_warn(arizona->dev, "WM8997 registered as %d\n",
> +				 arizona->type);
>  			arizona->type = WM8997;
>  		}
>  		apply_patch = wm8997_patch;
> @@ -1181,8 +1181,8 @@ int arizona_dev_init(struct arizona *arizona)
>  
>  		default:
>  			type_name = "WM8998";
> -			dev_err(arizona->dev, "WM8998 registered as %d\n",
> -				arizona->type);
> +			dev_warn(arizona->dev, "WM8998 registered as %d\n",
> +				 arizona->type);
>  			arizona->type = WM8998;
>  		}
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices
  2015-10-02 12:29 ` [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices Charles Keepax
@ 2015-10-13  9:24   ` Lee Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:24 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> The code was using a switch on the code type to execute
> one of several mfd_add_devices() calls. We're already
> switching on the code type earlier in the function to
> select the correct patch function so we can roll selection
> of the mfd device table into the same switch.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c |   36 ++++++++++++++----------------------
>  1 files changed, 14 insertions(+), 22 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index c3f88e5..39899bf 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -24,6 +24,7 @@
>  #include <linux/regulator/consumer.h>
>  #include <linux/regulator/machine.h>
>  #include <linux/slab.h>
> +#include <linux/platform_device.h>
>  
>  #include <linux/mfd/arizona/core.h>
>  #include <linux/mfd/arizona/registers.h>
> @@ -965,7 +966,8 @@ int arizona_dev_init(struct arizona *arizona)
>  	const char *type_name;
>  	unsigned int reg, val, mask;
>  	int (*apply_patch)(struct arizona *) = NULL;
> -	int ret, i;
> +	const struct mfd_cell *subdevs = NULL;
> +	int n_subdevs, ret, i;
>  
>  	dev_set_drvdata(arizona->dev, arizona);
>  	mutex_init(&arizona->clk_lock);
> @@ -1136,6 +1138,8 @@ int arizona_dev_init(struct arizona *arizona)
>  		}
>  		apply_patch = wm5102_patch;
>  		arizona->rev &= 0x7;
> +		subdevs = wm5102_devs;
> +		n_subdevs = ARRAY_SIZE(wm5102_devs);
>  		break;
>  #endif
>  #ifdef CONFIG_MFD_WM5110
> @@ -1155,6 +1159,8 @@ int arizona_dev_init(struct arizona *arizona)
>  			break;
>  		}
>  		apply_patch = wm5110_patch;
> +		subdevs = wm5110_devs;
> +		n_subdevs = ARRAY_SIZE(wm5110_devs);
>  		break;
>  #endif
>  #ifdef CONFIG_MFD_WM8997
> @@ -1166,6 +1172,8 @@ int arizona_dev_init(struct arizona *arizona)
>  			arizona->type = WM8997;
>  		}
>  		apply_patch = wm8997_patch;
> +		subdevs = wm8997_devs;
> +		n_subdevs = ARRAY_SIZE(wm8997_devs);
>  		break;
>  #endif
>  #ifdef CONFIG_MFD_WM8998
> @@ -1187,6 +1195,8 @@ int arizona_dev_init(struct arizona *arizona)
>  		}
>  
>  		apply_patch = wm8998_patch;
> +		subdevs = wm8998_devs;
> +		n_subdevs = ARRAY_SIZE(wm8998_devs);
>  		break;
>  #endif
>  	default:
> @@ -1379,28 +1389,10 @@ int arizona_dev_init(struct arizona *arizona)
>  	arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked",
>  			    arizona_underclocked, arizona);
>  
> -	switch (arizona->type) {
> -	case WM5102:
> -		ret = mfd_add_devices(arizona->dev, -1, wm5102_devs,
> -				      ARRAY_SIZE(wm5102_devs), NULL, 0, NULL);
> -		break;
> -	case WM5110:
> -	case WM8280:
> -		ret = mfd_add_devices(arizona->dev, -1, wm5110_devs,
> -				      ARRAY_SIZE(wm5110_devs), NULL, 0, NULL);
> -		break;
> -	case WM8997:
> -		ret = mfd_add_devices(arizona->dev, -1, wm8997_devs,
> -				      ARRAY_SIZE(wm8997_devs), NULL, 0, NULL);
> -		break;
> -	case WM8998:
> -	case WM1814:
> -		ret = mfd_add_devices(arizona->dev, -1, wm8998_devs,
> -				      ARRAY_SIZE(wm8998_devs), NULL, 0, NULL);
> -		break;
> -	}
> +	ret = mfd_add_devices(arizona->dev, PLATFORM_DEVID_NONE,
> +			      subdevs, n_subdevs, NULL, 0, NULL);
>  
> -	if (ret != 0) {
> +	if (ret) {
>  		dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret);
>  		goto err_irq;
>  	}

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs
  2015-10-02 12:29 ` [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs Charles Keepax
  2015-10-13  9:23   ` Lee Jones
@ 2015-10-13  9:25   ` Lee Jones
  1 sibling, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:25 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> Remove the use of #ifdefs around each case statement of the chip ID
> and type validation switches.
> 
> We must ensure that the contained code still compiles to nothing if
> support for that codec was not built into the kernel, to prevent
> creation of link references to missing functions. So the ifdefs are
> replaced with a use of the IS_ENABLED() macro.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
> 
> Changes since v1:
>  - Changed IS_ENABLED if statements such that they wrap all code
>    that we want eliminated, to ensure that it does indeed get
>    eliminated.
> 
> Thanks,
> Charles
> 
>  drivers/mfd/arizona-core.c |  129 ++++++++++++++++++++++++--------------------
>  drivers/mfd/arizona-i2c.c  |   28 +++++-----
>  drivers/mfd/arizona-spi.c  |   18 ++++---
>  3 files changed, 97 insertions(+), 78 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index 39899bf..4e49210 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -1128,82 +1128,95 @@ int arizona_dev_init(struct arizona *arizona)
>  	arizona->rev &= ARIZONA_DEVICE_REVISION_MASK;
>  
>  	switch (reg) {
> -#ifdef CONFIG_MFD_WM5102
>  	case 0x5102:
> -		type_name = "WM5102";
> -		if (arizona->type != WM5102) {
> -			dev_warn(arizona->dev, "WM5102 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM5102;
> +		if (IS_ENABLED(CONFIG_MFD_WM5102)) {
> +			type_name = "WM5102";
> +			if (arizona->type != WM5102) {
> +				dev_warn(arizona->dev,
> +					 "WM5102 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM5102;
> +			}
> +
> +			apply_patch = wm5102_patch;
> +			arizona->rev &= 0x7;
> +			subdevs = wm5102_devs;
> +			n_subdevs = ARRAY_SIZE(wm5102_devs);
>  		}
> -		apply_patch = wm5102_patch;
> -		arizona->rev &= 0x7;
> -		subdevs = wm5102_devs;
> -		n_subdevs = ARRAY_SIZE(wm5102_devs);
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
>  	case 0x5110:
> -		switch (arizona->type) {
> -		case WM5110:
> -			type_name = "WM5110";
> -			break;
> -		case WM8280:
> -			type_name = "WM8280";
> -			break;
> -		default:
> -			type_name = "WM5110";
> -			dev_warn(arizona->dev, "WM5110 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM5110;
> -			break;
> +		if (IS_ENABLED(CONFIG_MFD_WM5110)) {
> +			switch (arizona->type) {
> +			case WM5110:
> +				type_name = "WM5110";
> +				break;
> +			case WM8280:
> +				type_name = "WM8280";
> +				break;
> +			default:
> +				type_name = "WM5110";
> +				dev_warn(arizona->dev,
> +					 "WM5110 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM5110;
> +				break;
> +			}
> +
> +			apply_patch = wm5110_patch;
> +			subdevs = wm5110_devs;
> +			n_subdevs = ARRAY_SIZE(wm5110_devs);
>  		}
> -		apply_patch = wm5110_patch;
> -		subdevs = wm5110_devs;
> -		n_subdevs = ARRAY_SIZE(wm5110_devs);
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8997
>  	case 0x8997:
> -		type_name = "WM8997";
> -		if (arizona->type != WM8997) {
> -			dev_warn(arizona->dev, "WM8997 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM8997;
> +		if (IS_ENABLED(CONFIG_MFD_WM8997)) {
> +			type_name = "WM8997";
> +			if (arizona->type != WM8997) {
> +				dev_warn(arizona->dev,
> +					 "WM8997 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM8997;
> +			}
> +
> +			apply_patch = wm8997_patch;
> +			subdevs = wm8997_devs;
> +			n_subdevs = ARRAY_SIZE(wm8997_devs);
>  		}
> -		apply_patch = wm8997_patch;
> -		subdevs = wm8997_devs;
> -		n_subdevs = ARRAY_SIZE(wm8997_devs);
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8998
>  	case 0x6349:
> -		switch (arizona->type) {
> -		case WM8998:
> -			type_name = "WM8998";
> -			break;
> -
> -		case WM1814:
> -			type_name = "WM1814";
> -			break;
> +		if (IS_ENABLED(CONFIG_MFD_WM8998)) {
> +			switch (arizona->type) {
> +			case WM8998:
> +				type_name = "WM8998";
> +				break;
> +
> +			case WM1814:
> +				type_name = "WM1814";
> +				break;
> +
> +			default:
> +				type_name = "WM8998";
> +				dev_warn(arizona->dev,
> +					 "WM8998 registered as %d\n",
> +					 arizona->type);
> +				arizona->type = WM8998;
> +			}
>  
> -		default:
> -			type_name = "WM8998";
> -			dev_warn(arizona->dev, "WM8998 registered as %d\n",
> -				 arizona->type);
> -			arizona->type = WM8998;
> +			apply_patch = wm8998_patch;
> +			subdevs = wm8998_devs;
> +			n_subdevs = ARRAY_SIZE(wm8998_devs);
>  		}
> -
> -		apply_patch = wm8998_patch;
> -		subdevs = wm8998_devs;
> -		n_subdevs = ARRAY_SIZE(wm8998_devs);
>  		break;
> -#endif
>  	default:
>  		dev_err(arizona->dev, "Unknown device ID %x\n", reg);
>  		goto err_reset;
>  	}
>  
> +	if (!subdevs) {
> +		dev_err(arizona->dev,
> +			"No kernel support for device ID %x\n", reg);
> +		goto err_reset;
> +	}
> +
>  	dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A');
>  
>  	if (apply_patch) {
> diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
> index cea1b40..914bdce 100644
> --- a/drivers/mfd/arizona-i2c.c
> +++ b/drivers/mfd/arizona-i2c.c
> @@ -27,7 +27,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
>  			     const struct i2c_device_id *id)
>  {
>  	struct arizona *arizona;
> -	const struct regmap_config *regmap_config;
> +	const struct regmap_config *regmap_config = NULL;
>  	unsigned long type;
>  	int ret;
>  
> @@ -37,34 +37,36 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
>  		type = id->driver_data;
>  
>  	switch (type) {
> -#ifdef CONFIG_MFD_WM5102
>  	case WM5102:
> -		regmap_config = &wm5102_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5102))
> +			regmap_config = &wm5102_i2c_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
>  	case WM5110:
>  	case WM8280:
> -		regmap_config = &wm5110_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5110))
> +			regmap_config = &wm5110_i2c_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8997
>  	case WM8997:
> -		regmap_config = &wm8997_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM8997))
> +			regmap_config = &wm8997_i2c_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM8998
>  	case WM8998:
>  	case WM1814:
> -		regmap_config = &wm8998_i2c_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM8998))
> +			regmap_config = &wm8998_i2c_regmap;
>  		break;
> -#endif
>  	default:
>  		dev_err(&i2c->dev, "Unknown device type %ld\n",
>  			id->driver_data);
>  		return -EINVAL;
>  	}
>  
> +	if (!regmap_config) {
> +		dev_err(&i2c->dev,
> +			"No kernel support for device type %ld\n", type);
> +		return -EINVAL;
> +	}
> +
>  	arizona = devm_kzalloc(&i2c->dev, sizeof(*arizona), GFP_KERNEL);
>  	if (arizona == NULL)
>  		return -ENOMEM;
> diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
> index 1e845f6..850a63a 100644
> --- a/drivers/mfd/arizona-spi.c
> +++ b/drivers/mfd/arizona-spi.c
> @@ -27,7 +27,7 @@ static int arizona_spi_probe(struct spi_device *spi)
>  {
>  	const struct spi_device_id *id = spi_get_device_id(spi);
>  	struct arizona *arizona;
> -	const struct regmap_config *regmap_config;
> +	const struct regmap_config *regmap_config = NULL;
>  	unsigned long type;
>  	int ret;
>  
> @@ -37,23 +37,27 @@ static int arizona_spi_probe(struct spi_device *spi)
>  		type = id->driver_data;
>  
>  	switch (type) {
> -#ifdef CONFIG_MFD_WM5102
>  	case WM5102:
> -		regmap_config = &wm5102_spi_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5102))
> +			regmap_config = &wm5102_spi_regmap;
>  		break;
> -#endif
> -#ifdef CONFIG_MFD_WM5110
>  	case WM5110:
>  	case WM8280:
> -		regmap_config = &wm5110_spi_regmap;
> +		if (IS_ENABLED(CONFIG_MFD_WM5110))
> +			regmap_config = &wm5110_spi_regmap;
>  		break;
> -#endif
>  	default:
>  		dev_err(&spi->dev, "Unknown device type %ld\n",
>  			id->driver_data);
>  		return -EINVAL;
>  	}
>  
> +	if (!regmap_config) {
> +		dev_err(&spi->dev,
> +			"No kernel support for device type %ld\n", type);
> +		return -EINVAL;
> +	}
> +
>  	arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL);
>  	if (arizona == NULL)
>  		return -ENOMEM;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config
  2015-10-02 12:29 ` [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config Charles Keepax
@ 2015-10-13  9:25   ` Lee Jones
  0 siblings, 0 replies; 13+ messages in thread
From: Lee Jones @ 2015-10-13  9:25 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, linux-kernel, rf, sameo

On Fri, 02 Oct 2015, Charles Keepax wrote:

> From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> 
> In the case of a device tree config the code uses the device ID
> from the DT entry to check which codec is required but when storing
> the ID into struct arizona it was always using the non-DT SPI device
> table to get an ID.
> 
> This patch changes the code to store the correct ID into struct arizona.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-i2c.c |    5 ++---
>  drivers/mfd/arizona-spi.c |    5 ++---
>  2 files changed, 4 insertions(+), 6 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/arizona-i2c.c b/drivers/mfd/arizona-i2c.c
> index 914bdce..4e3afd1 100644
> --- a/drivers/mfd/arizona-i2c.c
> +++ b/drivers/mfd/arizona-i2c.c
> @@ -56,8 +56,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
>  			regmap_config = &wm8998_i2c_regmap;
>  		break;
>  	default:
> -		dev_err(&i2c->dev, "Unknown device type %ld\n",
> -			id->driver_data);
> +		dev_err(&i2c->dev, "Unknown device type %ld\n", type);
>  		return -EINVAL;
>  	}
>  
> @@ -79,7 +78,7 @@ static int arizona_i2c_probe(struct i2c_client *i2c,
>  		return ret;
>  	}
>  
> -	arizona->type = id->driver_data;
> +	arizona->type = type;
>  	arizona->dev = &i2c->dev;
>  	arizona->irq = i2c->irq;
>  
> diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
> index 850a63a..8cffb1c 100644
> --- a/drivers/mfd/arizona-spi.c
> +++ b/drivers/mfd/arizona-spi.c
> @@ -47,8 +47,7 @@ static int arizona_spi_probe(struct spi_device *spi)
>  			regmap_config = &wm5110_spi_regmap;
>  		break;
>  	default:
> -		dev_err(&spi->dev, "Unknown device type %ld\n",
> -			id->driver_data);
> +		dev_err(&spi->dev, "Unknown device type %ld\n", type);
>  		return -EINVAL;
>  	}
>  
> @@ -70,7 +69,7 @@ static int arizona_spi_probe(struct spi_device *spi)
>  		return ret;
>  	}
>  
> -	arizona->type = id->driver_data;
> +	arizona->type = type;
>  	arizona->dev = &spi->dev;
>  	arizona->irq = spi->irq;
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

end of thread, other threads:[~2015-10-13  9:25 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02 12:29 [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Charles Keepax
2015-10-02 12:29 ` [PATCH v2 2/6] mfd: arizona: factor out checking of jack detection state Charles Keepax
2015-10-13  9:24   ` Lee Jones
2015-10-02 12:29 ` [PATCH v2 3/6] mfd: arizona: Downgrade type mismatch messages to dev_warn Charles Keepax
2015-10-13  9:24   ` Lee Jones
2015-10-02 12:29 ` [PATCH v2 4/6] mfd: arizona: Simplify adding subdevices Charles Keepax
2015-10-13  9:24   ` Lee Jones
2015-10-02 12:29 ` [PATCH v2 5/6] mfd: arizona: Remove use of codec build config #ifdefs Charles Keepax
2015-10-13  9:23   ` Lee Jones
2015-10-13  9:25   ` Lee Jones
2015-10-02 12:29 ` [PATCH v2 6/6] mfd: arizona: use correct type ID for device tree config Charles Keepax
2015-10-13  9:25   ` Lee Jones
2015-10-13  9:23 ` [PATCH v2 1/6] mfd: arizona: factor out DCVDD isolation control Lee Jones

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