Unverified Commit 74bbdd63 authored by Tinghan Shen's avatar Tinghan Shen Committed by Mark Brown
Browse files

firmware: mediatek: Use meaningful names for mbox



Rename mbox according to actions instead of 'mbox0' and 'mbox1'

Signed-off-by: default avatarTinghan Shen <tinghan.shen@mediatek.com>
Link: https://lore.kernel.org/r/20220622062245.21021-3-tinghan.shen@mediatek.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 009b21f3
Loading
Loading
Loading
Loading
+12 −24
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@
#include <linux/platform_device.h>
#include <linux/slab.h>

static const char * const adsp_mbox_ch_names[MTK_ADSP_MBOX_NUM] = { "rx", "tx" };

/*
 * mtk_adsp_ipc_send - send ipc cmd to MTK ADSP
 *
@@ -72,7 +74,6 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
	struct mtk_adsp_ipc *adsp_ipc;
	struct mtk_adsp_chan *adsp_chan;
	struct mbox_client *cl;
	char *chan_name;
	int ret;
	int i, j;

@@ -83,12 +84,6 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
		return -ENOMEM;

	for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) {
		chan_name = kasprintf(GFP_KERNEL, "mbox%d", i);
		if (!chan_name) {
			ret = -ENOMEM;
			goto out;
		}

		adsp_chan = &adsp_ipc->chans[i];
		cl = &adsp_chan->cl;
		cl->dev = dev->parent;
@@ -99,17 +94,20 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)

		adsp_chan->ipc = adsp_ipc;
		adsp_chan->idx = i;
		adsp_chan->ch = mbox_request_channel_byname(cl, chan_name);
		adsp_chan->ch = mbox_request_channel_byname(cl, adsp_mbox_ch_names[i]);
		if (IS_ERR(adsp_chan->ch)) {
			ret = PTR_ERR(adsp_chan->ch);
			if (ret != -EPROBE_DEFER)
				dev_err(dev, "Failed to request mbox chan %d ret %d\n",
					i, ret);
			goto out_free;
				dev_err(dev, "Failed to request mbox chan %s ret %d\n",
					adsp_mbox_ch_names[i], ret);

			for (j = 0; j < i; j++) {
				adsp_chan = &adsp_ipc->chans[j];
				mbox_free_channel(adsp_chan->ch);
			}

		dev_dbg(dev, "request mbox chan %s\n", chan_name);
		kfree(chan_name);
			return ret;
		}
	}

	adsp_ipc->dev = dev;
@@ -117,16 +115,6 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
	dev_dbg(dev, "MTK ADSP IPC initialized\n");

	return 0;

out_free:
	kfree(chan_name);
out:
	for (j = 0; j < i; j++) {
		adsp_chan = &adsp_ipc->chans[j];
		mbox_free_channel(adsp_chan->ch);
	}

	return ret;
}

static int mtk_adsp_ipc_remove(struct platform_device *pdev)