[alsa-devel] [PATCH v2 1/3] ASoC: codecs: wm8904: add dt ids table
From: Alexander Morozov linux@meltdown.ru
Signed-off-by: Alexander Morozov linux@meltdown.ru [Add driver data to distinguish device type] Signed-off-by: Bo Shen voice.shen@atmel.com ---
Changes in v2: - Add driver data for distinguish the device capability.
sound/soc/codecs/wm8904.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4d2d2b1..6e3f175 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -2255,10 +2255,32 @@ static const struct i2c_device_id wm8904_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, wm8904_i2c_id);
+#ifdef CONFIG_OF +static enum wm8904_type wm8904_data = WM8904; +static enum wm8904_type wm8912_data = WM8912; + +static const struct of_device_id wm8904_of_match[] = { + { + .compatible = "wlf,wm8904", + .data = &wm8904_data, + }, { + .compatible = "wlf,wm8912", + .data = &wm8912_data, + }, { + .compatible = "wlf,wm8918", + .data = &wm8904_data, + }, { + /* sentinel */ + } +}; +MODULE_DEVICE_TABLE(of, wm8904_of_match); +#endif + static struct i2c_driver wm8904_i2c_driver = { .driver = { .name = "wm8904", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(wm8904_of_match), }, .probe = wm8904_i2c_probe, .remove = wm8904_i2c_remove,
From: Alexander Morozov linux@meltdown.ru
Using the wm8904 device tree compatible string.
Signed-off-by: Alexander Morozov linux@meltdown.ru Signed-off-by: Bo Shen voice.shen@atmel.com ---
Changes in v2: None
arch/arm/boot/dts/sama5d3xmb.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/sama5d3xmb.dtsi b/arch/arm/boot/dts/sama5d3xmb.dtsi index 49c10d3..2a1aa58 100644 --- a/arch/arm/boot/dts/sama5d3xmb.dtsi +++ b/arch/arm/boot/dts/sama5d3xmb.dtsi @@ -45,7 +45,7 @@ */ i2c0: i2c@f0014000 { wm8904: wm8904@1a { - compatible = "wm8904"; + compatible = "wlf,wm8904"; reg = <0x1a>; clocks = <&pck0>; clock-names = "mclk";
Using the device tree ids for wm8904 codec.
Signed-off-by: Bo Shen voice.shen@atmel.com ---
Changes in v2: None
arch/arm/boot/dts/at91sam9n12ek.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/at91sam9n12ek.dts b/arch/arm/boot/dts/at91sam9n12ek.dts index 13bb24e..9575c0d 100644 --- a/arch/arm/boot/dts/at91sam9n12ek.dts +++ b/arch/arm/boot/dts/at91sam9n12ek.dts @@ -54,7 +54,7 @@ status = "okay";
wm8904: codec@1a { - compatible = "wm8904"; + compatible = "wlf,wm8904"; reg = <0x1a>; clocks = <&pck0>; clock-names = "mclk";
Le 15/12/2014 04:31, Bo Shen a écrit :
From: Alexander Morozov linux@meltdown.ru
Signed-off-by: Alexander Morozov linux@meltdown.ru [Add driver data to distinguish device type] Signed-off-by: Bo Shen voice.shen@atmel.com
Changes in v2:
- Add driver data for distinguish the device capability.
sound/soc/codecs/wm8904.c | 22 ++++++++++++++++++++++
Mark,
Do you want us to re-send this patch or can you take it?
On my side, I'm planning to take the 2 last ones of this series: is it okay for you?
Thanks, bye.
1 file changed, 22 insertions(+)
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4d2d2b1..6e3f175 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -2255,10 +2255,32 @@ static const struct i2c_device_id wm8904_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, wm8904_i2c_id);
+#ifdef CONFIG_OF +static enum wm8904_type wm8904_data = WM8904; +static enum wm8904_type wm8912_data = WM8912;
+static const struct of_device_id wm8904_of_match[] = {
- {
.compatible = "wlf,wm8904",
.data = &wm8904_data,
- }, {
.compatible = "wlf,wm8912",
.data = &wm8912_data,
- }, {
.compatible = "wlf,wm8918",
.data = &wm8904_data,
- }, {
/* sentinel */
- }
+}; +MODULE_DEVICE_TABLE(of, wm8904_of_match); +#endif
static struct i2c_driver wm8904_i2c_driver = { .driver = { .name = "wm8904", .owner = THIS_MODULE,
}, .probe = wm8904_i2c_probe, .remove = wm8904_i2c_remove,.of_match_table = of_match_ptr(wm8904_of_match),
On Mon, Dec 15, 2014 at 11:31:11AM +0800, Bo Shen wrote:
+#ifdef CONFIG_OF +static enum wm8904_type wm8904_data = WM8904; +static enum wm8904_type wm8912_data = WM8912;
+static const struct of_device_id wm8904_of_match[] = {
- {
.compatible = "wlf,wm8904",
.data = &wm8904_data,
Does this end up in the i2c_driver_id driver data or do we need some extra code when devtype is assigned to check for an of_node and look at the DT data instead? That certainly used to be the case...
Hi Mark,
On 01/15/2015 07:54 PM, Mark Brown wrote:
On Mon, Dec 15, 2014 at 11:31:11AM +0800, Bo Shen wrote:
+#ifdef CONFIG_OF +static enum wm8904_type wm8904_data = WM8904; +static enum wm8904_type wm8912_data = WM8912;
+static const struct of_device_id wm8904_of_match[] = {
- {
.compatible = "wlf,wm8904",
.data = &wm8904_data,
Does this end up in the i2c_driver_id driver data or do we need some extra code when devtype is assigned to check for an of_node and look at the DT data instead? That certainly used to be the case...
At the beginning I think as the same as you, and also add the code to get the data as I do in <drivers/misc/atmel-ssc.c>. However, as I remember, I2C seems only use the compatible string after the comma, that means only for "wlf,wm8904", it uses "wm8904" to match. So, I remove all the code I added, and just keep these, and it can get the device type correctly.
So, when I submit the patch and keep the code as simple as possible.
Thanks.
Best Regards, Bo Shen
Le 16/01/2015 02:17, Bo Shen a écrit :
Hi Mark,
On 01/15/2015 07:54 PM, Mark Brown wrote:
On Mon, Dec 15, 2014 at 11:31:11AM +0800, Bo Shen wrote:
+#ifdef CONFIG_OF +static enum wm8904_type wm8904_data = WM8904; +static enum wm8904_type wm8912_data = WM8912;
+static const struct of_device_id wm8904_of_match[] = {
- {
.compatible = "wlf,wm8904",
.data = &wm8904_data,
Does this end up in the i2c_driver_id driver data or do we need some extra code when devtype is assigned to check for an of_node and look at the DT data instead? That certainly used to be the case...
At the beginning I think as the same as you, and also add the code to get the data as I do in <drivers/misc/atmel-ssc.c>. However, as I remember, I2C seems only use the compatible string after the comma, that means only for "wlf,wm8904", it uses "wm8904" to match. So, I remove all the code I added, and just keep these, and it can get the device type correctly.
So, when I submit the patch and keep the code as simple as possible.
Thanks.
Best Regards, Bo Shen
I don't understand what's keeping this patch from being applied. Voice, do you mind re-sending?
On my side, I take the two patches that apply on AT91 DT (2/3 and 3/3).
Bye,
On Mon, Jan 26, 2015 at 04:24:38PM +0100, Nicolas Ferre wrote:
Le 16/01/2015 02:17, Bo Shen a écrit :
Does this end up in the i2c_driver_id driver data or do we need some extra code when devtype is assigned to check for an of_node and look at the DT data instead? That certainly used to be the case...
At the beginning I think as the same as you, and also add the code to get the data as I do in <drivers/misc/atmel-ssc.c>. However, as I remember, I2C seems only use the compatible string after the comma, that means only for "wlf,wm8904", it uses "wm8904" to match. So, I remove all the code I added, and just keep these, and it can get the device type correctly.
So, when I submit the patch and keep the code as simple as possible.
I don't understand what's keeping this patch from being applied. Voice, do you mind re-sending?
I need to convince myself that the above actually works and is doing the right thing; the above explanation sounds like if it works it might be relying on a bug.
On 01/26/2015 05:42 PM, Mark Brown wrote:
On Mon, Jan 26, 2015 at 04:24:38PM +0100, Nicolas Ferre wrote:
Le 16/01/2015 02:17, Bo Shen a écrit :
Does this end up in the i2c_driver_id driver data or do we need some extra code when devtype is assigned to check for an of_node and look at the DT data instead? That certainly used to be the case...
At the beginning I think as the same as you, and also add the code to get the data as I do in <drivers/misc/atmel-ssc.c>. However, as I remember, I2C seems only use the compatible string after the comma, that means only for "wlf,wm8904", it uses "wm8904" to match. So, I remove all the code I added, and just keep these, and it can get the device type correctly.
So, when I submit the patch and keep the code as simple as possible.
I don't understand what's keeping this patch from being applied. Voice, do you mind re-sending?
I need to convince myself that the above actually works and is doing the right thing; the above explanation sounds like if it works it might be relying on a bug.
I'd call it a undocumented feature. But I wouldn't rely on it being around for ever. In my opinion to be future proof the driver should explicitly handle the OF case in the probe function.
Hi Mark, Lars-Perter,
On 01/27/2015 12:49 AM, Lars-Peter Clausen wrote:
On 01/26/2015 05:42 PM, Mark Brown wrote:
On Mon, Jan 26, 2015 at 04:24:38PM +0100, Nicolas Ferre wrote:
Le 16/01/2015 02:17, Bo Shen a écrit :
Does this end up in the i2c_driver_id driver data or do we need some extra code when devtype is assigned to check for an of_node and look at the DT data instead? That certainly used to be the case...
At the beginning I think as the same as you, and also add the code to get the data as I do in <drivers/misc/atmel-ssc.c>. However, as I remember, I2C seems only use the compatible string after the comma, that means only for "wlf,wm8904", it uses "wm8904" to match. So, I remove all the code I added, and just keep these, and it can get the device type correctly.
So, when I submit the patch and keep the code as simple as possible.
I don't understand what's keeping this patch from being applied. Voice, do you mind re-sending?
I need to convince myself that the above actually works and is doing the right thing; the above explanation sounds like if it works it might be relying on a bug.
I'd call it a undocumented feature. But I wouldn't rely on it being around for ever. In my opinion to be future proof the driver should explicitly handle the OF case in the probe function.
I will add this into probe function in next version. Thanks.
Best Regards, Bo Shen
participants (4)
-
Bo Shen
-
Lars-Peter Clausen
-
Mark Brown
-
Nicolas Ferre