Skip to contentSkip to conversation

mailbox: mediatek: Fix handling of platform_get_irq() error

PATCH In review Krzysztof Kozlowski 2 participants 3 messages Aug 27, 2020 – Oct 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mailbox: mediatek: Fix handling of platform_get_irq() error

platform_get_irq() returns -ERRNO on error. In such case casting to u32 and comparing to 0 would pass the check.

Fixes 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver")

---

Changes since v2:
1. Fix subject.

Changes since v1:
1. Correct u32->int,
2. Fix left-over '!'.

---
 drivers/mailbox/mtk-cmdq-mailbox.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mailbox/mtk-cmdq-mailbox.c +3 -5
index 484d4438cd83..5665b6ea8119 100644
@@ -69,7 +69,7 @@ struct cmdq_task {
 struct cmdq {
 	struct mbox_controller	mbox;
 	void __iomem		*base;
-	u32			irq;
+	int			irq;
 	u32			thread_nr;
 	u32			irq_mask;
 	struct cmdq_thread	*thread;
@@ -525,10 +525,8 @@ static int cmdq_probe(struct platform_device *pdev)
 	}
 
 	cmdq->irq = platform_get_irq(pdev, 0);
-	if (!cmdq->irq) {
-		dev_err(dev, "failed to get irq\n");
-		return -EINVAL;
-	}
+	if (cmdq->irq < 0)
+		return cmdq->irq;
 
 	plat_data = (struct gce_plat *)of_device_get_match_data(dev);
 	if (!plat_data) {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · Krzysztof Kozlowski

platform_get_irq() returns -ERRNO on error. In such case casting to u32 and comparing to 0 would pass the check.

Fixes 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver")

---

Changes since v2:
1. Fix subject.

Quoted 6 lines

Changes since v1:
1. Correct u32->int,
2. Fix left-over '!'.

---
 drivers/mailbox/mtk-cmdq-mailbox.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Any comments here? This is a bugfix.

Best regards,
Krzysztof

Reviewed-by on v3 1/1
#2 lore raw
In reply to Krzysztof Kozlowski

Krzysztof Kozlowski <[email protected]> 於 2020年8月28日 週五 上午2:25寫道:

Quoted 4 lines

platform_get_irq() returns -ERRNO on error. In such case casting to u32 and comparing to 0 would pass the check.

Quoted 49 lines
Fixes 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver")

---

Changes since v2:
1. Fix subject.

Changes since v1:
1. Correct u32->int,
2. Fix left-over '!'.

---
 drivers/mailbox/mtk-cmdq-mailbox.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/mailbox/mtk-cmdq-mailbox.c +3 -6
index 484d4438cd83..5665b6ea8119 100644
@@ -69,7 +69,7 @@ struct cmdq_task {
 struct cmdq {
        struct mbox_controller  mbox;
        void __iomem            *base;
-       u32                     irq;
+       int                     irq;
        u32                     thread_nr;
        u32                     irq_mask;
        struct cmdq_thread      *thread;
@@ -525,10 +525,8 @@ static int cmdq_probe(struct platform_device *pdev)
        }
 
        cmdq->irq = platform_get_irq(pdev, 0);
-       if (!cmdq->irq) {
-               dev_err(dev, "failed to get irq\n");
-               return -EINVAL;
-       }
+       if (cmdq->irq < 0)
+               return cmdq->irq;
 
        plat_data = (struct gce_plat *)of_device_get_match_data(dev);
        if (!plat_data) {
--

2.17.1

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek