Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: mediatek: Use meaningful names for mbox

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>

authored by

Tinghan Shen and committed by
Mark Brown
74bbdd63 009b21f3

+12 -24
+12 -24
drivers/firmware/mtk-adsp-ipc.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/slab.h> 14 14 15 + static const char * const adsp_mbox_ch_names[MTK_ADSP_MBOX_NUM] = { "rx", "tx" }; 16 + 15 17 /* 16 18 * mtk_adsp_ipc_send - send ipc cmd to MTK ADSP 17 19 * ··· 74 72 struct mtk_adsp_ipc *adsp_ipc; 75 73 struct mtk_adsp_chan *adsp_chan; 76 74 struct mbox_client *cl; 77 - char *chan_name; 78 75 int ret; 79 76 int i, j; 80 77 ··· 84 83 return -ENOMEM; 85 84 86 85 for (i = 0; i < MTK_ADSP_MBOX_NUM; i++) { 87 - chan_name = kasprintf(GFP_KERNEL, "mbox%d", i); 88 - if (!chan_name) { 89 - ret = -ENOMEM; 90 - goto out; 91 - } 92 - 93 86 adsp_chan = &adsp_ipc->chans[i]; 94 87 cl = &adsp_chan->cl; 95 88 cl->dev = dev->parent; ··· 94 99 95 100 adsp_chan->ipc = adsp_ipc; 96 101 adsp_chan->idx = i; 97 - adsp_chan->ch = mbox_request_channel_byname(cl, chan_name); 102 + adsp_chan->ch = mbox_request_channel_byname(cl, adsp_mbox_ch_names[i]); 98 103 if (IS_ERR(adsp_chan->ch)) { 99 104 ret = PTR_ERR(adsp_chan->ch); 100 105 if (ret != -EPROBE_DEFER) 101 - dev_err(dev, "Failed to request mbox chan %d ret %d\n", 102 - i, ret); 103 - goto out_free; 104 - } 106 + dev_err(dev, "Failed to request mbox chan %s ret %d\n", 107 + adsp_mbox_ch_names[i], ret); 105 108 106 - dev_dbg(dev, "request mbox chan %s\n", chan_name); 107 - kfree(chan_name); 109 + for (j = 0; j < i; j++) { 110 + adsp_chan = &adsp_ipc->chans[j]; 111 + mbox_free_channel(adsp_chan->ch); 112 + } 113 + 114 + return ret; 115 + } 108 116 } 109 117 110 118 adsp_ipc->dev = dev; ··· 115 117 dev_dbg(dev, "MTK ADSP IPC initialized\n"); 116 118 117 119 return 0; 118 - 119 - out_free: 120 - kfree(chan_name); 121 - out: 122 - for (j = 0; j < i; j++) { 123 - adsp_chan = &adsp_ipc->chans[j]; 124 - mbox_free_channel(adsp_chan->ch); 125 - } 126 - 127 - return ret; 128 120 } 129 121 130 122 static int mtk_adsp_ipc_remove(struct platform_device *pdev)