All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: soc-core: add missing component functions
@ 2017-09-27 23:57 Kuninori Morimoto
  2017-09-27 23:58 ` [PATCH 1/2] ASoC: soc-core: add component lookup functions Kuninori Morimoto
  2017-09-27 23:59 ` [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component() Kuninori Morimoto
  0 siblings, 2 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-27 23:57 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon


Hi Mark

These are resend of one of "replace to component" patch set.
These add missing functions which exist in "platforms" but not
exist in "component".

Kuninori Morimoto (2):
  ASoC: soc-core: add component lookup functions
  ASoC: soc-core: add snd_soc_add_component()

 include/sound/soc.h  |  7 ++++++
 sound/soc/soc-core.c | 60 ++++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 56 insertions(+), 11 deletions(-)

-- 
1.9.1

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

* [PATCH 1/2] ASoC: soc-core: add component lookup functions
  2017-09-27 23:57 [PATCH 0/2] ASoC: soc-core: add missing component functions Kuninori Morimoto
@ 2017-09-27 23:58 ` Kuninori Morimoto
  2017-09-27 23:59 ` [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component() Kuninori Morimoto
  1 sibling, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-27 23:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC platform/codec will be replaced to component soon.
This means 1 device might have multiple components. But current
unregister component function checks "dev" only to find it.
This means, unexpected component might be unregistered by current
function.
But, it is no problem if driver registered only 1 component.

To prepare avoid this issue, this patch adds new component
lookup function. it finds component by "dev" and "driver name".

Here, the reason why it uses "driver name" is that "component name"
was created by fmt_single_name() and difficult to use it from driver.
Driver of course knows its "driver name", thus, using it is more easy.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  2 ++
 sound/soc/soc-core.c | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index d776cde..11ca867 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -475,6 +475,8 @@ int devm_snd_soc_register_component(struct device *dev,
 			 const struct snd_soc_component_driver *component_driver,
 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_component(struct device *dev);
+struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
+						   const char *driver_name);
 int snd_soc_cache_init(struct snd_soc_codec *codec);
 int snd_soc_cache_exit(struct snd_soc_codec *codec);
 
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fb34351..6ec1273 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3481,6 +3481,32 @@ void snd_soc_unregister_component(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
 
+struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
+						   const char *driver_name)
+{
+	struct snd_soc_component *component;
+	struct snd_soc_component *ret;
+
+	ret = NULL;
+	mutex_lock(&client_mutex);
+	list_for_each_entry(component, &component_list, list) {
+		if (dev != component->dev)
+			continue;
+
+		if (driver_name &&
+		    (driver_name != component->driver->name) &&
+		    (strcmp(component->driver->name, driver_name) != 0))
+			continue;
+
+		ret = component;
+		break;
+	}
+	mutex_unlock(&client_mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_lookup_component);
+
 static int snd_soc_platform_drv_probe(struct snd_soc_component *component)
 {
 	struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
-- 
1.9.1

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

* [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-27 23:57 [PATCH 0/2] ASoC: soc-core: add missing component functions Kuninori Morimoto
  2017-09-27 23:58 ` [PATCH 1/2] ASoC: soc-core: add component lookup functions Kuninori Morimoto
@ 2017-09-27 23:59 ` Kuninori Morimoto
  2017-09-28  7:37   ` Daniel Baluta
  1 sibling, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-27 23:59 UTC (permalink / raw)
  To: Mark Brown; +Cc: Linux-ALSA, Simon


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

ALSA SoC platform/codec will be replaced to component soon.
But, some function exist in "platform" doesn't exist in "component".
Current soc-core has snd_soc_register_component(), but
doesn't have snd_soc_add_component() like snd_soc_add_platform().
This patch adds it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  5 +++++
 sound/soc/soc-core.c | 34 +++++++++++++++++++++++-----------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 11ca867..eea3007 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -468,6 +468,11 @@ int snd_soc_register_codec(struct device *dev,
 		const struct snd_soc_codec_driver *codec_drv,
 		struct snd_soc_dai_driver *dai_drv, int num_dai);
 void snd_soc_unregister_codec(struct device *dev);
+int snd_soc_add_component(struct device *dev,
+		struct snd_soc_component *component,
+		const struct snd_soc_component_driver *component_driver,
+		struct snd_soc_dai_driver *dai_drv,
+		int num_dai);
 int snd_soc_register_component(struct device *dev,
 			 const struct snd_soc_component_driver *component_driver,
 			 struct snd_soc_dai_driver *dai_drv, int num_dai);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 6ec1273..166b6d2 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3404,20 +3404,14 @@ static void snd_soc_component_del_unlocked(struct snd_soc_component *component)
 	list_del(&component->list);
 }
 
-int snd_soc_register_component(struct device *dev,
-			       const struct snd_soc_component_driver *component_driver,
-			       struct snd_soc_dai_driver *dai_drv,
-			       int num_dai)
+int snd_soc_add_component(struct device *dev,
+			struct snd_soc_component *component,
+			const struct snd_soc_component_driver *component_driver,
+			struct snd_soc_dai_driver *dai_drv,
+			int num_dai)
 {
-	struct snd_soc_component *component;
 	int ret;
 
-	component = kzalloc(sizeof(*component), GFP_KERNEL);
-	if (!component) {
-		dev_err(dev, "ASoC: Failed to allocate memory\n");
-		return -ENOMEM;
-	}
-
 	ret = snd_soc_component_initialize(component, component_driver, dev);
 	if (ret)
 		goto err_free;
@@ -3441,6 +3435,24 @@ int snd_soc_register_component(struct device *dev,
 	kfree(component);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(snd_soc_add_component);
+
+int snd_soc_register_component(struct device *dev,
+			const struct snd_soc_component_driver *component_driver,
+			struct snd_soc_dai_driver *dai_drv,
+			int num_dai)
+{
+	struct snd_soc_component *component;
+
+	component = kzalloc(sizeof(*component), GFP_KERNEL);
+	if (!component) {
+		dev_err(dev, "ASoC: Failed to allocate memory\n");
+		return -ENOMEM;
+	}
+
+	return snd_soc_add_component(dev, component, component_driver,
+				     dai_drv, num_dai);
+}
 EXPORT_SYMBOL_GPL(snd_soc_register_component);
 
 /**
-- 
1.9.1

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

* Re: [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-27 23:59 ` [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component() Kuninori Morimoto
@ 2017-09-28  7:37   ` Daniel Baluta
  2017-09-28  8:10     ` Kuninori Morimoto
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2017-09-28  7:37 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown, Simon

Minor comment inline

On Thu, Sep 28, 2017 at 2:59 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> ALSA SoC platform/codec will be replaced to component soon.
> But, some function exist in "platform" doesn't exist in "component".
> Current soc-core has snd_soc_register_component(), but
> doesn't have snd_soc_add_component() like snd_soc_add_platform().
> This patch adds it.
>

<snip>

> +int snd_soc_register_component(struct device *dev,
> +                       const struct snd_soc_component_driver *component_driver,
> +                       struct snd_soc_dai_driver *dai_drv,
> +                       int num_dai)
> +{
> +       struct snd_soc_component *component;
> +
> +       component = kzalloc(sizeof(*component), GFP_KERNEL);
> +       if (!component) {
> +               dev_err(dev, "ASoC: Failed to allocate memory\n");
> +               return -ENOMEM;

No need to print an error message if kzalloc fails. The core will print it.

> +       }
> +
> +       return snd_soc_add_component(dev, component, component_driver,
> +                                    dai_drv, num_dai);
> +}
>  EXPORT_SYMBOL_GPL(snd_soc_register_component);


thanks,
Daniel.

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

* Re: [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-28  7:37   ` Daniel Baluta
@ 2017-09-28  8:10     ` Kuninori Morimoto
  2017-09-28  8:12       ` Daniel Baluta
  0 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-28  8:10 UTC (permalink / raw)
  To: Daniel Baluta; +Cc: Linux-ALSA, Mark Brown, Simon


Hi Daniel

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> >
> > ALSA SoC platform/codec will be replaced to component soon.
> > But, some function exist in "platform" doesn't exist in "component".
> > Current soc-core has snd_soc_register_component(), but
> > doesn't have snd_soc_add_component() like snd_soc_add_platform().
> > This patch adds it.
<snip>
> > +int snd_soc_register_component(struct device *dev,
> > +                       const struct snd_soc_component_driver *component_driver,
> > +                       struct snd_soc_dai_driver *dai_drv,
> > +                       int num_dai)
> > +{
> > +       struct snd_soc_component *component;
> > +
> > +       component = kzalloc(sizeof(*component), GFP_KERNEL);
> > +       if (!component) {
> > +               dev_err(dev, "ASoC: Failed to allocate memory\n");
> > +               return -ENOMEM;
> 
> No need to print an error message if kzalloc fails. The core will print it.

Thanks. Yes I had noticed this warning from checkpatch.
The main purpose of this patch is separate "register" function into
"register" and "add".
Thus, I keeped existing all code.
I think "remove unneeded message" should be increment patch,
but can you agree ?

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-28  8:10     ` Kuninori Morimoto
@ 2017-09-28  8:12       ` Daniel Baluta
  2017-09-28  8:15         ` Kuninori Morimoto
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2017-09-28  8:12 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown, Simon

Hi Kuninori,

>> > +       component = kzalloc(sizeof(*component), GFP_KERNEL);
>> > +       if (!component) {
>> > +               dev_err(dev, "ASoC: Failed to allocate memory\n");
>> > +               return -ENOMEM;
>>
>> No need to print an error message if kzalloc fails. The core will print it.
>
> Thanks. Yes I had noticed this warning from checkpatch.
> The main purpose of this patch is separate "register" function into
> "register" and "add".
> Thus, I keeped existing all code.
> I think "remove unneeded message" should be increment patch,
> but can you agree ?

Makes sense. It's better to be sent as a separate patch.

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

* Re: [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-28  8:12       ` Daniel Baluta
@ 2017-09-28  8:15         ` Kuninori Morimoto
  2017-09-28  8:17           ` Daniel Baluta
  0 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-28  8:15 UTC (permalink / raw)
  To: Daniel Baluta; +Cc: Linux-ALSA, Mark Brown, Simon


Hi Daniel

> >> > +       component = kzalloc(sizeof(*component), GFP_KERNEL);
> >> > +       if (!component) {
> >> > +               dev_err(dev, "ASoC: Failed to allocate memory\n");
> >> > +               return -ENOMEM;
> >>
> >> No need to print an error message if kzalloc fails. The core will print it.
> >
> > Thanks. Yes I had noticed this warning from checkpatch.
> > The main purpose of this patch is separate "register" function into
> > "register" and "add".
> > Thus, I keeped existing all code.
> > I think "remove unneeded message" should be increment patch,
> > but can you agree ?
> 
> Makes sense. It's better to be sent as a separate patch.

Thanks.
If you have no objection, I will post it if this patch was accepted.
Or do you do this ?

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-28  8:15         ` Kuninori Morimoto
@ 2017-09-28  8:17           ` Daniel Baluta
  2017-10-02  5:05             ` Kuninori Morimoto
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2017-09-28  8:17 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA, Mark Brown, Simon

On Thu, Sep 28, 2017 at 11:15 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
>
> Hi Daniel
>
>> >> > +       component = kzalloc(sizeof(*component), GFP_KERNEL);
>> >> > +       if (!component) {
>> >> > +               dev_err(dev, "ASoC: Failed to allocate memory\n");
>> >> > +               return -ENOMEM;
>> >>
>> >> No need to print an error message if kzalloc fails. The core will print it.
>> >
>> > Thanks. Yes I had noticed this warning from checkpatch.
>> > The main purpose of this patch is separate "register" function into
>> > "register" and "add".
>> > Thus, I keeped existing all code.
>> > I think "remove unneeded message" should be increment patch,
>> > but can you agree ?
>>
>> Makes sense. It's better to be sent as a separate patch.
>
> Thanks.
> If you have no objection, I will post it if this patch was accepted.
> Or do you do this ?

Lets have this patch reviewed & pushed and then will see. It's
not that important.

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

* Re: [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component()
  2017-09-28  8:17           ` Daniel Baluta
@ 2017-10-02  5:05             ` Kuninori Morimoto
  0 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-10-02  5:05 UTC (permalink / raw)
  To: Daniel Baluta; +Cc: Linux-ALSA, Mark Brown, Simon


Hi Mark

I will post v2 patch which includes this "remove unneeded message" patch set.

> >> >> > +       component = kzalloc(sizeof(*component), GFP_KERNEL);
> >> >> > +       if (!component) {
> >> >> > +               dev_err(dev, "ASoC: Failed to allocate memory\n");
> >> >> > +               return -ENOMEM;
> >> >>
> >> >> No need to print an error message if kzalloc fails. The core will print it.
> >> >
> >> > Thanks. Yes I had noticed this warning from checkpatch.
> >> > The main purpose of this patch is separate "register" function into
> >> > "register" and "add".
> >> > Thus, I keeped existing all code.
> >> > I think "remove unneeded message" should be increment patch,
> >> > but can you agree ?
> >>
> >> Makes sense. It's better to be sent as a separate patch.
> >
> > Thanks.
> > If you have no objection, I will post it if this patch was accepted.
> > Or do you do this ?
> 
> Lets have this patch reviewed & pushed and then will see. It's
> not that important.
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

end of thread, other threads:[~2017-10-02  5:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-27 23:57 [PATCH 0/2] ASoC: soc-core: add missing component functions Kuninori Morimoto
2017-09-27 23:58 ` [PATCH 1/2] ASoC: soc-core: add component lookup functions Kuninori Morimoto
2017-09-27 23:59 ` [PATCH 2/2] ASoC: soc-core: add snd_soc_add_component() Kuninori Morimoto
2017-09-28  7:37   ` Daniel Baluta
2017-09-28  8:10     ` Kuninori Morimoto
2017-09-28  8:12       ` Daniel Baluta
2017-09-28  8:15         ` Kuninori Morimoto
2017-09-28  8:17           ` Daniel Baluta
2017-10-02  5:05             ` Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.