Re: [RESEND PATCH v1 3/6] staging: greybus: audio: Resolve compilation errors for GB codec module

2020-06-02 Thread Dan Carpenter
On Tue, Jun 02, 2020 at 10:51:12AM +0530, Vaibhav Agarwal wrote:
> Due to dependencies on ASoC framework changes, GB dummy codec module
> compilation is currently disabled. This patch updates codec driver as
> per the latest ASoC APIs.
> 
> Signed-off-by: Vaibhav Agarwal 
> ---
>  drivers/staging/greybus/audio_codec.c | 87 +--
>  drivers/staging/greybus/audio_codec.h |  2 +-
>  2 files changed, 44 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/staging/greybus/audio_codec.c 
> b/drivers/staging/greybus/audio_codec.c
> index a2ee587e5a79..bbd072acda5c 100644
> --- a/drivers/staging/greybus/audio_codec.c
> +++ b/drivers/staging/greybus/audio_codec.c
> @@ -832,7 +832,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info 
> *module,
>  int gbaudio_register_module(struct gbaudio_module_info *module)
>  {
>   int ret;
> - struct snd_soc_codec *codec;
> + struct snd_soc_component *component;

I quite like the "component" pointer because it's assigned once at the
start of the function and used consistently throughout.  The other
pointers I complained about were just temporary pointers which meant
different things depending on which line you were on.  They made the
code harder to read.

My only quible is that in the next patch it's called "comp" and here
it's called "component".  Let's just use "comp" for all the local
variables.


regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[RESEND PATCH v1 3/6] staging: greybus: audio: Resolve compilation errors for GB codec module

2020-06-01 Thread Vaibhav Agarwal
Due to dependencies on ASoC framework changes, GB dummy codec module
compilation is currently disabled. This patch updates codec driver as
per the latest ASoC APIs.

Signed-off-by: Vaibhav Agarwal 
---
 drivers/staging/greybus/audio_codec.c | 87 +--
 drivers/staging/greybus/audio_codec.h |  2 +-
 2 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/greybus/audio_codec.c 
b/drivers/staging/greybus/audio_codec.c
index a2ee587e5a79..bbd072acda5c 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -832,7 +832,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info 
*module,
 int gbaudio_register_module(struct gbaudio_module_info *module)
 {
int ret;
-   struct snd_soc_codec *codec;
+   struct snd_soc_component *component;
struct snd_card *card;
struct gbaudio_jack *gba_jack = NULL;
struct snd_soc_jack *jack = NULL;
@@ -842,8 +842,8 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
return -EAGAIN;
}
 
-   codec = gbcodec->codec;
-   card = codec->card->snd_card;
+   component = gbcodec->component;
+   card = component->card->snd_card;
 
down_write(>controls_rwsem);
 
@@ -862,19 +862,20 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
}
 
if (module->dapm_widgets)
-   snd_soc_dapm_new_controls(>dapm, module->dapm_widgets,
+   snd_soc_dapm_new_controls(>dapm,
+ module->dapm_widgets,
  module->num_dapm_widgets);
if (module->controls)
-   snd_soc_add_codec_controls(codec, module->controls,
-  module->num_controls);
+   snd_soc_add_component_controls(component, module->controls,
+  module->num_controls);
if (module->dapm_routes)
-   snd_soc_dapm_add_routes(>dapm, module->dapm_routes,
+   snd_soc_dapm_add_routes(>dapm, module->dapm_routes,
module->num_dapm_routes);
 
/* card already instantiated, create widgets here only */
-   if (codec->card->instantiated) {
-   snd_soc_dapm_link_component_dai_widgets(codec->card,
-   >dapm);
+   if (component->card->instantiated) {
+   snd_soc_dapm_link_component_dai_widgets(component->card,
+   >dapm);
 #ifdef CONFIG_SND_JACK
/*
 * register jack devices for this module
@@ -882,7 +883,7 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
 */
list_for_each_entry(gba_jack, >jack_list, list) {
jack = _jack->jack;
-   snd_device_register(codec->card->snd_card,
+   snd_device_register(component->card->snd_card,
jack->jack);
}
 #endif
@@ -892,9 +893,9 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
list_add(>list, >module_list);
mutex_unlock(>lock);
 
-   if (codec->card->instantiated)
-   ret = snd_soc_dapm_new_widgets(>dapm);
-   dev_dbg(codec->dev, "Registered %s module\n", module->name);
+   if (component->card->instantiated)
+   ret = snd_soc_dapm_new_widgets(component->card);
+   dev_dbg(component->dev, "Registered %s module\n", module->name);
 
up_write(>controls_rwsem);
return ret;
@@ -965,19 +966,19 @@ static void gbaudio_codec_cleanup(struct 
gbaudio_module_info *module)
 
 void gbaudio_unregister_module(struct gbaudio_module_info *module)
 {
-   struct snd_soc_codec *codec = gbcodec->codec;
-   struct snd_card *card = codec->card->snd_card;
+   struct snd_soc_component *component = gbcodec->component;
+   struct snd_card *card = component->card->snd_card;
struct gbaudio_jack *gba_jack, *n;
struct snd_soc_jack *jack;
int mask;
 
-   dev_dbg(codec->dev, "Unregister %s module\n", module->name);
+   dev_dbg(component->dev, "Unregister %s module\n", module->name);
 
down_write(>controls_rwsem);
mutex_lock(>lock);
gbaudio_codec_cleanup(module);
list_del(>list);
-   dev_dbg(codec->dev, "Process Unregister %s module\n", module->name);
+   dev_dbg(component->dev, "Process Unregister %s module\n", module->name);
mutex_unlock(>lock);
 
 #ifdef CONFIG_SND_JACK
@@ -994,99 +995,97 @@ void gbaudio_unregister_module(struct gbaudio_module_info 
*module)
dev_dbg(module->dev, "Report %s removal\n",
jack->jack->id);
snd_soc_jack_report(jack, 0, mask);
- 

[PATCH V1 3/6] staging: greybus: audio: Resolve compilation errors for GB codec module

2020-05-17 Thread Vaibhav Agarwal
Due to dependencies on ASoC framework changes, GB dummy codec module
compilation is currently disabled. This patch updates codec driver as
per the latest ASoC APIs.

Signed-off-by: Vaibhav Agarwal 
---
 drivers/staging/greybus/audio_codec.c | 87 +--
 drivers/staging/greybus/audio_codec.h |  2 +-
 2 files changed, 44 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/greybus/audio_codec.c 
b/drivers/staging/greybus/audio_codec.c
index a2ee587e5a79..bbd072acda5c 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -832,7 +832,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info 
*module,
 int gbaudio_register_module(struct gbaudio_module_info *module)
 {
int ret;
-   struct snd_soc_codec *codec;
+   struct snd_soc_component *component;
struct snd_card *card;
struct gbaudio_jack *gba_jack = NULL;
struct snd_soc_jack *jack = NULL;
@@ -842,8 +842,8 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
return -EAGAIN;
}
 
-   codec = gbcodec->codec;
-   card = codec->card->snd_card;
+   component = gbcodec->component;
+   card = component->card->snd_card;
 
down_write(>controls_rwsem);
 
@@ -862,19 +862,20 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
}
 
if (module->dapm_widgets)
-   snd_soc_dapm_new_controls(>dapm, module->dapm_widgets,
+   snd_soc_dapm_new_controls(>dapm,
+ module->dapm_widgets,
  module->num_dapm_widgets);
if (module->controls)
-   snd_soc_add_codec_controls(codec, module->controls,
-  module->num_controls);
+   snd_soc_add_component_controls(component, module->controls,
+  module->num_controls);
if (module->dapm_routes)
-   snd_soc_dapm_add_routes(>dapm, module->dapm_routes,
+   snd_soc_dapm_add_routes(>dapm, module->dapm_routes,
module->num_dapm_routes);
 
/* card already instantiated, create widgets here only */
-   if (codec->card->instantiated) {
-   snd_soc_dapm_link_component_dai_widgets(codec->card,
-   >dapm);
+   if (component->card->instantiated) {
+   snd_soc_dapm_link_component_dai_widgets(component->card,
+   >dapm);
 #ifdef CONFIG_SND_JACK
/*
 * register jack devices for this module
@@ -882,7 +883,7 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
 */
list_for_each_entry(gba_jack, >jack_list, list) {
jack = _jack->jack;
-   snd_device_register(codec->card->snd_card,
+   snd_device_register(component->card->snd_card,
jack->jack);
}
 #endif
@@ -892,9 +893,9 @@ int gbaudio_register_module(struct gbaudio_module_info 
*module)
list_add(>list, >module_list);
mutex_unlock(>lock);
 
-   if (codec->card->instantiated)
-   ret = snd_soc_dapm_new_widgets(>dapm);
-   dev_dbg(codec->dev, "Registered %s module\n", module->name);
+   if (component->card->instantiated)
+   ret = snd_soc_dapm_new_widgets(component->card);
+   dev_dbg(component->dev, "Registered %s module\n", module->name);
 
up_write(>controls_rwsem);
return ret;
@@ -965,19 +966,19 @@ static void gbaudio_codec_cleanup(struct 
gbaudio_module_info *module)
 
 void gbaudio_unregister_module(struct gbaudio_module_info *module)
 {
-   struct snd_soc_codec *codec = gbcodec->codec;
-   struct snd_card *card = codec->card->snd_card;
+   struct snd_soc_component *component = gbcodec->component;
+   struct snd_card *card = component->card->snd_card;
struct gbaudio_jack *gba_jack, *n;
struct snd_soc_jack *jack;
int mask;
 
-   dev_dbg(codec->dev, "Unregister %s module\n", module->name);
+   dev_dbg(component->dev, "Unregister %s module\n", module->name);
 
down_write(>controls_rwsem);
mutex_lock(>lock);
gbaudio_codec_cleanup(module);
list_del(>list);
-   dev_dbg(codec->dev, "Process Unregister %s module\n", module->name);
+   dev_dbg(component->dev, "Process Unregister %s module\n", module->name);
mutex_unlock(>lock);
 
 #ifdef CONFIG_SND_JACK
@@ -994,99 +995,97 @@ void gbaudio_unregister_module(struct gbaudio_module_info 
*module)
dev_dbg(module->dev, "Report %s removal\n",
jack->jack->id);
snd_soc_jack_report(jack, 0, mask);
-