[alsa-devel] [PATCH 1/3] ASoC: alc5632: add an of_match table
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Signed-off-by: Stephen Warren swarren@nvidia.com --- sound/soc/codecs/alc5632.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index 3ee8d4e41a99..85942ca36cbf 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -1190,11 +1190,18 @@ static const struct i2c_device_id alc5632_i2c_table[] = { }; MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
+static const struct of_device_id alc5632_of_match[] = { + { .compatible = "realtek,alc5632", }, + { } +}; +MODULE_DEVICE_TABLE(of, alc5632_of_match); + /* i2c codec control layer */ static struct i2c_driver alc5632_i2c_driver = { .driver = { .name = "alc5632", .owner = THIS_MODULE, + .of_match_table = of_match_ptr(alc5632_of_match), }, .probe = alc5632_i2c_probe, .remove = alc5632_i2c_remove,
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Signed-off-by: Stephen Warren swarren@nvidia.com --- sound/soc/codecs/tlv320aic23-i2c.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/tlv320aic23-i2c.c b/sound/soc/codecs/tlv320aic23-i2c.c index 20fc46092c2c..b73c94ebcc2a 100644 --- a/sound/soc/codecs/tlv320aic23-i2c.c +++ b/sound/soc/codecs/tlv320aic23-i2c.c @@ -43,9 +43,16 @@ static const struct i2c_device_id tlv320aic23_id[] = {
MODULE_DEVICE_TABLE(i2c, tlv320aic23_id);
+static const struct of_device_id tlv320aic23_of_match[] = { + { .compatible = "ti,tlv320aic23", }, + { } +}; +MODULE_DEVICE_TABLE(of, tlv320aic23_of_match); + static struct i2c_driver tlv320aic23_i2c_driver = { .driver = { .name = "tlv320aic23-codec", + .of_match_table = of_match_ptr(tlv320aic23_of_match), }, .probe = tlv320aic23_i2c_probe, .remove = __exit_p(tlv320aic23_i2c_remove),
On Mon, Mar 31, 2014 at 12:38:17PM -0600, Stephen Warren wrote:
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Applied, thanks.
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Signed-off-by: Stephen Warren swarren@nvidia.com --- sound/soc/codecs/max98090.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 98c6e104357c..f7b0b37aa858 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -2399,11 +2399,18 @@ static const struct i2c_device_id max98090_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, max98090_i2c_id);
+static const struct of_device_id max98090_of_match[] = { + { .compatible = "maxim,max98090", }, + { } +}; +MODULE_DEVICE_TABLE(of, max98090_of_match); + static struct i2c_driver max98090_i2c_driver = { .driver = { .name = "max98090", .owner = THIS_MODULE, .pm = &max98090_pm, + .of_match_table = of_match_ptr(max98090_of_match), }, .probe = max98090_i2c_probe, .remove = max98090_i2c_remove,
On Mon, Mar 31, 2014 at 12:38:18PM -0600, Stephen Warren wrote:
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Applied, thanks.
On 03/31/2014 08:38 PM, Stephen Warren wrote:
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Signed-off-by: Stephen Warren swarren@nvidia.com
sound/soc/codecs/alc5632.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index 3ee8d4e41a99..85942ca36cbf 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -1190,11 +1190,18 @@ static const struct i2c_device_id alc5632_i2c_table[] = { }; MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
+static const struct of_device_id alc5632_of_match[] = {
- { .compatible = "realtek,alc5632", },
In order to make them usable with the simple-card machine driver, all codecs that have DT bindings should be visible in Kconfig. Maybe this can be done in a subsequent patch though.
Daniel
On 03/31/2014 12:53 PM, Daniel Mack wrote:
On 03/31/2014 08:38 PM, Stephen Warren wrote:
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Signed-off-by: Stephen Warren swarren@nvidia.com
sound/soc/codecs/alc5632.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index 3ee8d4e41a99..85942ca36cbf 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -1190,11 +1190,18 @@ static const struct i2c_device_id alc5632_i2c_table[] = { }; MODULE_DEVICE_TABLE(i2c, alc5632_i2c_table);
+static const struct of_device_id alc5632_of_match[] = {
- { .compatible = "realtek,alc5632", },
In order to make them usable with the simple-card machine driver, all codecs that have DT bindings should be visible in Kconfig. Maybe this can be done in a subsequent patch though.
I personally don't need to use that machine driver; the drivers patched in this series are all already in use on Tegra using DT via other machine drivers.
On Mon, Mar 31, 2014 at 12:38:16PM -0600, Stephen Warren wrote: [...]
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c
[...]
+static const struct of_device_id alc5632_of_match[] = {
- { .compatible = "realtek,alc5632", },
- { }
+}; +MODULE_DEVICE_TABLE(of, alc5632_of_match);
Doesn't this need #ifdef protection to prevent warnings about this being unused for !OF?
Thierry
On 03/31/2014 01:23 PM, Thierry Reding wrote:
On Mon, Mar 31, 2014 at 12:38:16PM -0600, Stephen Warren wrote: [...]
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c
[...]
+static const struct of_device_id alc5632_of_match[] = {
- { .compatible = "realtek,alc5632", },
- { }
+}; +MODULE_DEVICE_TABLE(of, alc5632_of_match);
Doesn't this need #ifdef protection to prevent warnings about this being unused for !OF?
What I really meant to do was reference these tables directly rather than using of_match_ptr().
There seems to be a mix of ifdef'ing the table and using of_match_ptr() vs. the other way around in ASoC. Mark, do you have a preference which way to go?
On Mon, Mar 31, 2014 at 01:47:04PM -0600, Stephen Warren wrote:
There seems to be a mix of ifdef'ing the table and using of_match_ptr() vs. the other way around in ASoC. Mark, do you have a preference which way to go?
of_match_ptr() is supposed to avoid the warnings that the ifdefs fixed more prettily - I suspect you'll find that the ones that don't use it either predate of_match_ptr() or copied something that did.
On 03/31/2014 04:45 PM, Mark Brown wrote:
On Mon, Mar 31, 2014 at 01:47:04PM -0600, Stephen Warren wrote:
There seems to be a mix of ifdef'ing the table and using of_match_ptr() vs. the other way around in ASoC. Mark, do you have a preference which way to go?
of_match_ptr() is supposed to avoid the warnings that the ifdefs fixed more prettily - I suspect you'll find that the ones that don't use it either predate of_match_ptr() or copied something that did.
I believe you either have the ifdef and the of_match_ptr(), or you have neither. The use of of_match_ptr() is required when you wrap the struct/array in an ifdef, so that the struct/array is only referenced when it's declared.
I guess from your response you want the struct/array wrapped in an ifdef, and to use of_match_ptr() when referencing it. I'll go ahead with that; no need to reply if that's what you meant.
On Mon, Mar 31, 2014 at 04:53:57PM -0600, Stephen Warren wrote:
On 03/31/2014 04:45 PM, Mark Brown wrote:
of_match_ptr() is supposed to avoid the warnings that the ifdefs fixed more prettily - I suspect you'll find that the ones that don't use it either predate of_match_ptr() or copied something that did.
I believe you either have the ifdef and the of_match_ptr(), or you have neither. The use of of_match_ptr() is required when you wrap the struct/array in an ifdef, so that the struct/array is only referenced when it's declared.
I guess from your response you want the struct/array wrapped in an ifdef, and to use of_match_ptr() when referencing it. I'll go ahead with that; no need to reply if that's what you meant.
No, what I'm saying is you shouldn't need the ifdef any more if you use of_match_ptr() and that's the more modern way to do things.
On Tue, Apr 01, 2014 at 12:05:17AM +0100, Mark Brown wrote:
On Mon, Mar 31, 2014 at 04:53:57PM -0600, Stephen Warren wrote:
On 03/31/2014 04:45 PM, Mark Brown wrote:
of_match_ptr() is supposed to avoid the warnings that the ifdefs fixed more prettily - I suspect you'll find that the ones that don't use it either predate of_match_ptr() or copied something that did.
I believe you either have the ifdef and the of_match_ptr(), or you have neither. The use of of_match_ptr() is required when you wrap the struct/array in an ifdef, so that the struct/array is only referenced when it's declared.
I guess from your response you want the struct/array wrapped in an ifdef, and to use of_match_ptr() when referencing it. I'll go ahead with that; no need to reply if that's what you meant.
No, what I'm saying is you shouldn't need the ifdef any more if you use of_match_ptr() and that's the more modern way to do things.
But I don't think that's the way it works. If you drop the #ifdef around the struct of_device_id table and use of_match_ptr() when referencing it then you'll get a warning from the compiler because the table is in fact unreferenced. So all that of_match_ptr() really gives you is a way to omit the:
#else # define of_match_table NULL
So it doesn't really give you all that much in the end.
Thierry
On Mon, Mar 31, 2014 at 12:38:16PM -0600, Stephen Warren wrote:
From: Stephen Warren swarren@nvidia.com
Add a device tree match table. This serves to make the driver's support of device tree more explicit. Perhaps the fallback for DT matching to using the i2c_device_id table will go away one day, since it fails in face of devices from different vendors with the same name.
Applied, thanks.
participants (4)
-
Daniel Mack
-
Mark Brown
-
Stephen Warren
-
Thierry Reding