Skip to contentSkip to conversation

firmware: mediatek: Use dev_err_probe() to simplify code

PATCH In review Yuan Can 3 participants 3 messages Sep 24, 2022 – Sep 26, 2022 Arm MediaTek

lore
Share & tools
lore

Yuan Can

author
#0 lore raw

PATCH 1/1 firmware: mediatek: Use dev_err_probe() to simplify code

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/firmware/mtk-adsp-ipc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/mtk-adsp-ipc.c +3 -4
index 3c071f814455..c57880949521 100644
@@ -96,10 +96,9 @@ static int mtk_adsp_ipc_probe(struct platform_device *pdev)
 		adsp_chan->idx = i;
 		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 %s ret %d\n",
-					adsp_mbox_ch_names[i], ret);
+			ret = dev_err_probe(dev, PTR_ERR(adsp_chan->ch),
+					    "Failed to request mbox chan %s\n",
+					    adsp_mbox_ch_names[i]);
 
 			for (j = 0; j < i; j++) {
 				adsp_chan = &adsp_ipc->chans[j];
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#2 lore raw
In reply to Yuan Can

Hi Yuan,

The patches LGTM:

Thanks,
Allen

Quoted 34 lines · Yuan Can

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/firmware/mtk-adsp-ipc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/firmware/mtk- renamed from drivers/firmware/mtk-adsp-ipc.c +0 -0

adsp-ipc.c
index 3c071f814455..c57880949521 100644

drivers/firmware/mtk-adsp-ipc.c +1 -4
@@ -96,10 +96,9 @@ static int mtk_adsp_ipc_probe(struct
 platform_device *pdev)
 		adsp_chan->idx = i;
 		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 %s ret %d\n",
-					adsp_mbox_ch_names[i], ret);
+			ret = dev_err_probe(dev, PTR_ERR(adsp_chan-
Quoted 1 line

ch),

drivers/firmware/mtk-adsp-ipc.c +1 -0
+					    "Failed to request mbox

chan %s\n",

drivers/firmware/mtk-adsp-ipc.c +1 -0
+					    adsp_mbox_ch_names[i]);
 
 			for (j = 0; j < i; j++) {
 				adsp_chan = &adsp_ipc->chans[j];