diff mbox series

[v2,01/39] ASoC: soc-dai.h: merge DAI call back functions into ops

Message ID 87v8dpb0w6.wl-kuninori.morimoto.gx@renesas.com
State Accepted
Commit 3e8bcec0787d1a73703c915c31cb00a2fd18ccbf
Headers show
Series ASoC: merge DAI call back functions into ops | expand

Commit Message

Kuninori Morimoto Aug. 8, 2023, 10:54 p.m. UTC
snd_soc_dai_driver has .ops for call back functions (A), but it also
has other call back functions (B). It is duplicated and confusable.

	struct snd_soc_dai_driver {
		...
 ^		int (*probe)(...);
 |		int (*remove)(...);
(B)		int (*compress_new)(...);
 |		int (*pcm_new)(...);
 v		...
(A)		const struct snd_soc_dai_ops *ops;
		...
	}

This patch merges (B) into (A).

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h              | 13 ++++++++
 sound/soc/generic/audio-graph-card.c |  2 +-
 sound/soc/soc-core.c                 | 25 ++++++++++++++++
 sound/soc/soc-dai.c                  | 44 ++++++++++++++++------------
 4 files changed, 64 insertions(+), 20 deletions(-)

Comments

Mark Brown Aug. 14, 2023, 10:05 p.m. UTC | #1
On Tue, 08 Aug 2023 22:54:50 +0000, Kuninori Morimoto wrote:
> snd_soc_dai_driver has .ops for call back functions (A), but it also
> has other call back functions (B). It is duplicated and confusable.
> 
> 	struct snd_soc_dai_driver {
> 		...
>  ^		int (*probe)(...);
>  |		int (*remove)(...);
> (B)		int (*compress_new)(...);
>  |		int (*pcm_new)(...);
>  v		...
> (A)		const struct snd_soc_dai_ops *ops;
> 		...
> 	}
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[01/39] ASoC: soc-dai.h: merge DAI call back functions into ops
        commit: 3e8bcec0787d1a73703c915c31cb00a2fd18ccbf
[02/39] ASoC: ti: merge DAI call back functions into ops
        commit: c64f5bd3afa0bf7a3b550bb63b9a5644acb04404
[03/39] ASoC: adi: merge DAI call back functions into ops
        commit: db49eb7b3855cc9bd422663b1cd84a36f5bd8d1f
[04/39] ASoC: adi: merge DAI call back functions into ops
        commit: db49eb7b3855cc9bd422663b1cd84a36f5bd8d1f
[05/39] ASoC: amd: merge DAI call back functions into ops
        commit: d86eb53532362f738dd840d7b953b2a769ccdd4b
[06/39] ASoC: dwc: merge DAI call back functions into ops
        commit: 2c88ba731fec284af52ed19b6c6eaacffb0c50f0
[07/39] ASoC: pxa: merge DAI call back functions into ops
        commit: 208b8395f79e4ad9196849b744f6e4a7abd2b836
[08/39] ASoC: bcm: merge DAI call back functions into ops
        commit: 59cd0ba842771946e922291199ce8c7a662484d4
[09/39] ASoC: fsl: merge DAI call back functions into ops
        commit: 5e5f68ca836e740c1d788f04efa84b37ed185606
[10/39] ASoC: img: merge DAI call back functions into ops
        commit: a98bd9e1173872cdbfc3ca7a2c43382f1417ab7e
[11/39] ASoC: sof: merge DAI call back functions into ops
        commit: f522af4cbe0158de3f518ed76b328ea6297a52b2
[12/39] ASoC: sti: merge DAI call back functions into ops
        commit: f33b8df2233a8f7007a289e4cf1bfce403fa6bf0
[13/39] ASoC: stm: merge DAI call back functions into ops
        commit: 2fb00b84cdb7dd2a8fe0d584236990b2392c5a57
[14/39] ASoC: pxa: merge DAI call back functions into ops
        commit: 208b8395f79e4ad9196849b744f6e4a7abd2b836
[15/39] ASoC: rsnd: merge DAI call back functions into ops
        commit: 47ca9f546ef6806925077e5ea6e084af660ee41b
[16/39] ASoC: qcom: merge DAI call back functions into ops
        commit: 9174fd60e55d7ff1ad2c909c67de48ebe7008e5a
[17/39] ASoC: au1x: merge DAI call back functions into ops
        commit: 4fc3331cb5f93b5a5ed5ee153b442960d11e1049
[18/39] ASoC: ux500: merge DAI call back functions into ops
        commit: 2870ffb31c58a301417ee12151122b337b316d0a
[19/39] ASoC: sunxi: merge DAI call back functions into ops
        commit: 331cd4d326244d853eb2e9fd3dcf55969055187e
[20/39] ASoC: tegra: merge DAI call back functions into ops
        commit: b36e672b6b6fa4f68fc74c3b85ba9b4a615fc1d9
[21/39] ASoC: atmel: merge DAI call back functions into ops
        commit: 2e85e70608c5d7233244c19ec2253dd1acb01e17
[22/39] ASoC: intel: merge DAI call back functions into ops
        commit: 3a8b7fd088d74c43eeb14406b7a1f0666a8d8594
[23/39] ASoC: meson: merge DAI call back functions into ops
        commit: 17821c2f6c53009b4c00aa5fd051425e19d46616
[24/39] ASoC: jz4740: merge DAI call back functions into ops
        commit: b3a7e76d7f7afd259dea954e9247dcccd361ed3a
[25/39] ASoC: cirrus: merge DAI call back functions into ops
        commit: af8a0e0391308258b2338b3b72e8fad5fac2d5d7
[26/39] ASoC: drm/vc4: merge DAI call back functions into ops
        commit: 3964f1d944c9dba5444ed85a9fcdf69991f17e5c
[27/39] ASoC: samsung: merge DAI call back functions into ops
        commit: 69b33471a2986f655006a37b1ae7b6cccf812b53
[28/39] ASoC: mediatek: merge DAI call back functions into ops
        commit: df775a399e1a6eb6eeab3d23f7c200f1dd4dcce0
[29/39] ASoC: rockchip: merge DAI call back functions into ops
        commit: 7575bec582876d295b34488cd39854c9e840ef04
[30/39] ASoC: uniphier: merge DAI call back functions into ops
        commit: 7142b49f5742d4bf5706b44db931906a45061b68
[31/39] ASoC: loongson: merge DAI call back functions into ops
        commit: 69c4f41b9e3c18bac11ada4b31abea3eed60f610
[32/39] ASoC: starfive: merge DAI call back functions into ops
        commit: de046f2ddbf929a0af73dd295902ea9a55ebc741
[33/39] ASoC: hisilicon: merge DAI call back functions into ops
        commit: d1f1c345562d31b1b5e2aaf03bfcdf1835778f65
[34/39] ASoC: codecs/wm*: merge DAI call back functions into ops
        commit: a350c5562318f798ef7b3e1e72bf947f0816ca45
[35/39] ASoC: soc-topology: merge DAI call back functions into ops
        commit: 7fdd0672678245dddd008fb2aea3b6952a5da795
[36/39] ASoC: codecs/cs47lxx: merge DAI call back functions into ops
        commit: 6bbb65c39a8468f12784bfa01d06a800c81310c5
[37/39] ASoC: codecs/cx2072x: merge DAI call back functions into ops
        commit: 707844f66ee3a79e3c1256e1b1667c9c43f6021d
[38/39] ASoC: codecs/hdmi-codec: merge DAI call back functions into ops
        commit: acd3e6256edf6d81eb01ab9a6fcbc48bf038a9a6
[39/39] ASoC: soc-dai.h: remove unused call back functions
        commit: 8e1eb11cd4579decc8e928be2face7c43f2a9c67

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index a33d803fe548..85f897fea21a 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -274,6 +274,15 @@  int snd_soc_dai_compr_get_metadata(struct snd_soc_dai *dai,
 const char *snd_soc_dai_name_get(struct snd_soc_dai *dai);
 
 struct snd_soc_dai_ops {
+	/* DAI driver callbacks */
+	int (*probe)(struct snd_soc_dai *dai);
+	int (*remove)(struct snd_soc_dai *dai);
+	/* compress dai */
+	int (*compress_new)(struct snd_soc_pcm_runtime *rtd, int num);
+	/* Optional Callback used at pcm creation*/
+	int (*pcm_new)(struct snd_soc_pcm_runtime *rtd,
+		       struct snd_soc_dai *dai);
+
 	/*
 	 * DAI clocking configuration, all optional.
 	 * Called by soc_card drivers, normally in their hw_params.
@@ -355,6 +364,10 @@  struct snd_soc_dai_ops {
 	u64 *auto_selectable_formats;
 	int num_auto_selectable_formats;
 
+	/* probe ordering - for components with runtime dependencies */
+	int probe_order;
+	int remove_order;
+
 	/* bit field */
 	unsigned int no_capture_mute:1;
 };
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 0b8258b6bd8e..13693ef9c242 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -60,7 +60,7 @@  static bool soc_component_is_pcm(struct snd_soc_dai_link_component *dlc)
 	struct snd_soc_dai *dai = snd_soc_find_dai_with_mutex(dlc);
 
 	if (dai && (dai->component->driver->pcm_construct ||
-		    dai->driver->pcm_new))
+		    (dai->driver->ops && dai->driver->ops->pcm_new)))
 		return true;
 
 	return false;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index a5b96c17633a..7dbf37e0ba2f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2510,6 +2510,7 @@  struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 {
 	struct device *dev = component->dev;
 	struct snd_soc_dai *dai;
+	struct snd_soc_dai_ops *ops; /* REMOVE ME */
 
 	lockdep_assert_held(&client_mutex);
 
@@ -2538,6 +2539,30 @@  struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 	if (!dai->name)
 		return NULL;
 
+	/* REMOVE ME */
+	if (dai_drv->probe		||
+	    dai_drv->remove		||
+	    dai_drv->compress_new	||
+	    dai_drv->pcm_new		||
+	    dai_drv->probe_order	||
+	    dai_drv->remove_order) {
+
+		ops = devm_kzalloc(dev, sizeof(struct snd_soc_dai_ops), GFP_KERNEL);
+		if (!ops)
+			return NULL;
+		if (dai_drv->ops)
+			memcpy(ops, dai_drv->ops, sizeof(struct snd_soc_dai_ops));
+
+		ops->probe		= dai_drv->probe;
+		ops->remove		= dai_drv->remove;
+		ops->compress_new	= dai_drv->compress_new;
+		ops->pcm_new		= dai_drv->pcm_new;
+		ops->probe_order	= dai_drv->probe_order;
+		ops->remove_order	= dai_drv->remove_order;
+
+		dai_drv->ops = ops;
+	}
+
 	dai->component = component;
 	dai->dev = dev;
 	dai->driver = dai_drv;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 73a97ac6ccb8..3f33f0630ad8 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -460,8 +460,9 @@  int snd_soc_dai_compress_new(struct snd_soc_dai *dai,
 			     struct snd_soc_pcm_runtime *rtd, int num)
 {
 	int ret = -ENOTSUPP;
-	if (dai->driver->compress_new)
-		ret = dai->driver->compress_new(rtd, num);
+	if (dai->driver->ops &&
+	    dai->driver->ops->compress_new)
+		ret = dai->driver->ops->compress_new(rtd, num);
 	return soc_dai_ret(dai, ret);
 }
 
@@ -545,19 +546,20 @@  int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order)
 	int i;
 
 	for_each_rtd_dais(rtd, i, dai) {
-		if (dai->driver->probe_order != order)
-			continue;
-
 		if (dai->probed)
 			continue;
 
-		if (dai->driver->probe) {
-			int ret = dai->driver->probe(dai);
+		if (dai->driver->ops) {
+			if (dai->driver->ops->probe_order != order)
+				continue;
 
-			if (ret < 0)
-				return soc_dai_ret(dai, ret);
-		}
+			if (dai->driver->ops->probe) {
+				int ret = dai->driver->ops->probe(dai);
 
+				if (ret < 0)
+					return soc_dai_ret(dai, ret);
+			}
+		}
 		dai->probed = 1;
 	}
 
@@ -570,16 +572,19 @@  int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order)
 	int i, r, ret = 0;
 
 	for_each_rtd_dais(rtd, i, dai) {
-		if (dai->driver->remove_order != order)
+		if (!dai->probed)
 			continue;
 
-		if (dai->probed &&
-		    dai->driver->remove) {
-			r = dai->driver->remove(dai);
-			if (r < 0)
-				ret = r; /* use last error */
-		}
+		if (dai->driver->ops) {
+			if (dai->driver->ops->remove_order != order)
+				continue;
 
+			if (dai->driver->ops->remove) {
+				r = dai->driver->ops->remove(dai);
+				if (r < 0)
+					ret = r; /* use last error */
+			}
+		}
 		dai->probed = 0;
 	}
 
@@ -592,8 +597,9 @@  int snd_soc_pcm_dai_new(struct snd_soc_pcm_runtime *rtd)
 	int i;
 
 	for_each_rtd_dais(rtd, i, dai) {
-		if (dai->driver->pcm_new) {
-			int ret = dai->driver->pcm_new(rtd, dai);
+		if (dai->driver->ops &&
+		    dai->driver->ops->pcm_new) {
+			int ret = dai->driver->ops->pcm_new(rtd, dai);
 			if (ret < 0)
 				return soc_dai_ret(dai, ret);
 		}