diff mbox series

[02/19] ASoC: add soc-card.c

Message ID 87eer7337h.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ASoC: add soc-card | expand

Commit Message

Kuninori Morimoto May 26, 2020, 1:16 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Current ALSA SoC has some snd_soc_card_xxx() functions,
and card->xxx() callbacks.
But, it is implemented randomly at random place.

To collect all card related functions into one place,
this patch creats new soc-card.c.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-card.h | 11 +++++++++++
 include/sound/soc.h      |  1 +
 sound/soc/Makefile       |  2 +-
 sound/soc/soc-card.c     | 26 ++++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 include/sound/soc-card.h
 create mode 100644 sound/soc/soc-card.c

Comments

Ranjani Sridharan May 27, 2020, 12:26 a.m. UTC | #1
On Tue, 2020-05-26 at 10:16 +0900, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Current ALSA SoC has some snd_soc_card_xxx() functions,
> and card->xxx() callbacks.
> But, it is implemented randomly at random place.
> 
> To collect all card related functions into one place,
> this patch creats new soc-card.c.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-card.h | 11 +++++++++++
>  include/sound/soc.h      |  1 +
>  sound/soc/Makefile       |  2 +-
>  sound/soc/soc-card.c     | 26 ++++++++++++++++++++++++++
>  4 files changed, 39 insertions(+), 1 deletion(-)
>  create mode 100644 include/sound/soc-card.h
>  create mode 100644 sound/soc/soc-card.c
> 
> diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
> new file mode 100644
> index 000000000000..997809bb3afb
> --- /dev/null
> +++ b/include/sound/soc-card.h
> @@ -0,0 +1,11 @@
> +/* SPDX-License-Identifier: GPL-2.0
> + *
> + * soc-card.h
> + *
> + * Copyright (C) 2019 Renesas Electronics Corp.
> + * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> + */
> +#ifndef __SOC_CARD_H
> +#define __SOC_CARD_H
> +
> +#endif /* __SOC_CARD_H */
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index 11ee3ed87aa1..5b880e29d106 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -1450,5 +1450,6 @@ static inline void
> snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
>  }
>  
>  #include <sound/soc-component.h>
> +#include <sound/soc-card.h>
Morimoto-san,

soc-card.h should be added where it is needed. For example, in this
patch, it should be included in soc-card.c and in the following
patches, it should be included in soc-core.c, soc-dapm.c etc where it
is needed.

Thanks,
Ranjani
Kuninori Morimoto May 28, 2020, 12:03 a.m. UTC | #2
Hi Ranjani

> > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > 
> > Current ALSA SoC has some snd_soc_card_xxx() functions,
> > and card->xxx() callbacks.
> > But, it is implemented randomly at random place.
> > 
> > To collect all card related functions into one place,
> > this patch creats new soc-card.c.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > ---
(snip)
> >  #include <sound/soc-component.h>
> > +#include <sound/soc-card.h>
> Morimoto-san,
> 
> soc-card.h should be added where it is needed. For example, in this
> patch, it should be included in soc-card.c and in the following
> patches, it should be included in soc-core.c, soc-dapm.c etc where it
> is needed.

OK, will fixup in v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto
Kuninori Morimoto May 28, 2020, 12:35 a.m. UTC | #3
Hi Ranjani, again

> > > From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > > 
> > > Current ALSA SoC has some snd_soc_card_xxx() functions,
> > > and card->xxx() callbacks.
> > > But, it is implemented randomly at random place.
> > > 
> > > To collect all card related functions into one place,
> > > this patch creats new soc-card.c.
> > > 
> > > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> > > ---
> (snip)
> > >  #include <sound/soc-component.h>
> > > +#include <sound/soc-card.h>
> > Morimoto-san,
> > 
> > soc-card.h should be added where it is needed. For example, in this
> > patch, it should be included in soc-card.c and in the following
> > patches, it should be included in soc-core.c, soc-dapm.c etc where it
> > is needed.

Hmm.... it seesm too many drivers are using snd_soc_card_xxx().
This means, I / this patch-set need to add too many #included <sound/soc-card.h>
line at too many files...

soc-component already did, but keeping it at soc.h is
more simple for some of them.
So, I want to keep it in v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto
diff mbox series

Patch

diff --git a/include/sound/soc-card.h b/include/sound/soc-card.h
new file mode 100644
index 000000000000..997809bb3afb
--- /dev/null
+++ b/include/sound/soc-card.h
@@ -0,0 +1,11 @@ 
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * soc-card.h
+ *
+ * Copyright (C) 2019 Renesas Electronics Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ */
+#ifndef __SOC_CARD_H
+#define __SOC_CARD_H
+
+#endif /* __SOC_CARD_H */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 11ee3ed87aa1..5b880e29d106 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1450,5 +1450,6 @@  static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
 }
 
 #include <sound/soc-component.h>
+#include <sound/soc-card.h>
 
 #endif
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 70a5f19ea3a1..7f1747518e79 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,6 +1,6 @@ 
 # SPDX-License-Identifier: GPL-2.0
 snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-utils.o soc-dai.o soc-component.o
-snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o soc-link.o
+snd-soc-core-objs += soc-pcm.o soc-io.o soc-devres.o soc-ops.o soc-link.o soc-card.o
 snd-soc-core-$(CONFIG_SND_SOC_COMPRESS) += soc-compress.o
 
 ifneq ($(CONFIG_SND_SOC_TOPOLOGY),)
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c
new file mode 100644
index 000000000000..4bc6f26ea8cb
--- /dev/null
+++ b/sound/soc/soc-card.c
@@ -0,0 +1,26 @@ 
+// SPDX-License-Identifier: GPL-2.0
+//
+// soc-card.c
+//
+// Copyright (C) 2019 Renesas Electronics Corp.
+// Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+//
+#include <sound/soc.h>
+
+#define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret)
+static inline int _soc_card_ret(struct snd_soc_card *card,
+				const char *func, int ret)
+{
+	switch (ret) {
+	case -EPROBE_DEFER:
+	case -ENOTSUPP:
+	case 0:
+		break;
+	default:
+		dev_err(card->dev,
+			"ASoC: error at %s on %s: %d\n",
+			func, card->name, ret);
+	}
+
+	return ret;
+}