firmware: mediatek: Use meaningful names for mbox
authorTinghan Shen <tinghan.shen@mediatek.com>
Wed, 22 Jun 2022 06:22:43 +0000 (14:22 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 22 Jun 2022 12:39:30 +0000 (13:39 +0100)
Rename mbox according to actions instead of 'mbox0' and 'mbox1'

Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
Link: https://lore.kernel.org/r/20220622062245.21021-3-tinghan.shen@mediatek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/firmware/mtk-adsp-ipc.c

index cb255a99170c9e3829ed530cb0e5d099bf8c54e3..3c071f814455522dc0b27fabbdf6d27793dea4f4 100644 (file)
@@ -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)