Skip to contentSkip to conversation

i2c: stm32: fix the return value handle for platform_get_irq()

PATCH Applied Ruan Jinjie 4 participants 8 messages Jul 31, 2023 – Aug 14, 2023

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

PATCH 1/1 i2c: stm32: fix the return value handle for platform_get_irq()

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

---
 drivers/i2c/busses/i2c-stm32f7.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +4 -4
index e897d9101434..579b30581725 100644
@@ -2121,12 +2121,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	phy_addr = (dma_addr_t)res->start;
 
 	irq_event = platform_get_irq(pdev, 0);
-	if (irq_event <= 0)
-		return irq_event ? : -ENOENT;
+	if (irq_event < 0)
+		return irq_event;
 
 	irq_error = platform_get_irq(pdev, 1);
-	if (irq_error <= 0)
-		return irq_error ? : -ENOENT;
+	if (irq_error < 0)
+		return irq_error;
 
 	i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
 						    "wakeup-source");
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Ruan,

Quoted 17 lines · Ruan Jinjie

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

---
 drivers/i2c/busses/i2c-stm32f7.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +0 -0
index e897d9101434..579b30581725 100644
@@ -2121,12 +2121,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	phy_addr = (dma_addr_t)res->start;
 
 	irq_event = platform_get_irq(pdev, 0);

drivers/i2c/busses/i2c-stm32f7.c static int stm32f7_i2c_probe(struct platform_device *pdev) · line 2129

Quoted 10 lines
drivers/i2c/busses/i2c-stm32f7.c +4 -4
-	if (irq_event <= 0)
-		return irq_event ? : -ENOENT;
+	if (irq_event < 0)
+		return irq_event;
 
 	irq_error = platform_get_irq(pdev, 1);
-	if (irq_error <= 0)
-		return irq_error ? : -ENOENT;
+	if (irq_error < 0)
+		return irq_error;

Correct, from patch ce753ad1549cbe ("platform: finally disallow IRQ0 in platform_get_irq() and its ilk") this check is already done inside platform_get_irq();

Andi

Quoted 6 lines
drivers/i2c/busses/i2c-stm32f7.c +0 -0
 	i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
 						    "wakeup-source");
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Hi Ruan,

Just a nitpick here that does not affect my r-b...

Quoted 4 lines · Ruan Jinjie
Quoted 3 lines

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

can we rephrase the whole commit to:

i2c: stm32: Do not check for 0 return after calling platform_get_irq()

It is not possible for platform_get_irq() to return 0. Use the return value from platform_get_irq().

Two notes on the commit log:

- Use capital letter after "i2c: stm32: Fix..."
- This is not a fix, so that we shouldn't use the word "fix" in the title.

just little notes for future patches :)

Thanks,
Andi

Quoted 38 lines
Quoted 13 lines
---
 drivers/i2c/busses/i2c-stm32f7.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +0 -0
index e897d9101434..579b30581725 100644
@@ -2121,12 +2121,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	phy_addr = (dma_addr_t)res->start;
 
 	irq_event = platform_get_irq(pdev, 0);

drivers/i2c/busses/i2c-stm32f7.c static int stm32f7_i2c_probe(struct platform_device *pdev) · line 2129

Quoted 10 lines
drivers/i2c/busses/i2c-stm32f7.c +4 -4
-	if (irq_event <= 0)
-		return irq_event ? : -ENOENT;
+	if (irq_event < 0)
+		return irq_event;
 
 	irq_error = platform_get_irq(pdev, 1);
-	if (irq_error <= 0)
-		return irq_error ? : -ENOENT;
+	if (irq_error < 0)
+		return irq_error;

Correct, from patch ce753ad1549cbe ("platform: finally disallow IRQ0 in platform_get_irq() and its ilk") this check is already done inside platform_get_irq();

Andi

Quoted 6 lines
drivers/i2c/busses/i2c-stm32f7.c +0 -0
 	i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
 						    "wakeup-source");
Signature · 1 line
2.34.1
#3 lore raw
Quoted 16 lines · Andi Shyti

Hi Ruan,

Just a nitpick here that does not affect my r-b...

Quoted 4 lines · Ruan Jinjie
Quoted 3 lines

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

can we rephrase the whole commit to:

i2c: stm32: Do not check for 0 return after calling platform_get_irq()

It is not possible for platform_get_irq() to return 0. Use the return value from platform_get_irq().

Quoted 7 lines

Two notes on the commit log:

- Use capital letter after "i2c: stm32: Fix..."
- This is not a fix, so that we shouldn't use the word "fix" in the title.

just little notes for future patches :)

Thank you for your valuable advice! I will keep an eye out for these in future patches.

Quoted 42 lines

Thanks,
Andi

Quoted 38 lines
Quoted 13 lines
---
 drivers/i2c/busses/i2c-stm32f7.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +0 -0
index e897d9101434..579b30581725 100644
@@ -2121,12 +2121,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	phy_addr = (dma_addr_t)res->start;
 
 	irq_event = platform_get_irq(pdev, 0);

drivers/i2c/busses/i2c-stm32f7.c static int stm32f7_i2c_probe(struct platform_device *pdev) · line 2129

Quoted 10 lines
drivers/i2c/busses/i2c-stm32f7.c +4 -4
-	if (irq_event <= 0)
-		return irq_event ? : -ENOENT;
+	if (irq_event < 0)
+		return irq_event;
 
 	irq_error = platform_get_irq(pdev, 1);
-	if (irq_error <= 0)
-		return irq_error ? : -ENOENT;
+	if (irq_error < 0)
+		return irq_error;

Correct, from patch ce753ad1549cbe ("platform: finally disallow IRQ0 in platform_get_irq() and its ilk") this check is already done inside platform_get_irq();

Andi

Quoted 6 lines
drivers/i2c/busses/i2c-stm32f7.c +0 -0
 	i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
 						    "wakeup-source");
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Ruan Jinjie

Hi Ruan,

thanks for your patch.

Quoted 20 lines · Ruan Jinjie

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

---
 drivers/i2c/busses/i2c-stm32f7.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-stm32f7.c +1 -2
index e897d9101434..579b30581725 100644
@@ -2121,12 +2121,12 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 	phy_addr = (dma_addr_t)res->start;
 
 	irq_event = platform_get_irq(pdev, 0);
-	if (irq_event <= 0)
-		return irq_event ? : -ENOENT;
+	if (irq_event < 0)

drivers/i2c/busses/i2c-stm32f7.c static int stm32f7_i2c_probe(struct platform_device *pdev) · line 2132

Quoted 10 lines
drivers/i2c/busses/i2c-stm32f7.c +3 -2
+		return irq_event;
 
 	irq_error = platform_get_irq(pdev, 1);
-	if (irq_error <= 0)
-		return irq_error ? : -ENOENT;
+	if (irq_error < 0)
+		return irq_error;
 
 	i2c_dev->wakeup_src = of_property_read_bool(pdev->dev.of_node,
 						    "wakeup-source");

Regards
Alain

Quoted 3 lines
Signature · 1 line
2.34.1
maintainer
#5 lore raw
In reply to Ruan Jinjie

Hi

Quoted 5 lines · Ruan Jinjie

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

With the commit log fixed, applied to i2c/andi-for-next on

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Please note that this patch may still undergo further evaluation and the final decision will be made in collaboration with Wolfram.

Thank you,
Andi

Patches applied
===============
[1/1] i2c: stm32: fix the return value handle for platform_get_irq()

      commit: 603b3cf89d8a96cc0e51eb15853f28944eb78f31

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

#6 lore raw
Quoted 10 lines · Andi Shyti

Hi

Quoted 5 lines · Ruan Jinjie

There is no possible for platform_get_irq() to return 0, and the return value of platform_get_irq() is more sensible to show the error reason.

With the commit log fixed, applied to i2c/andi-for-next on

Thank you!

Quoted 15 lines

https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Please note that this patch may still undergo further evaluation and the final decision will be made in collaboration with Wolfram.

Thank you,
Andi

Patches applied
===============
[1/1] i2c: stm32: fix the return value handle for platform_get_irq()

      commit: 603b3cf89d8a96cc0e51eb15853f28944eb78f31