[PATCH 1/3] i2c: pca-platform: Handle errors from optional IRQ lookup

[email protected]
Newsgroups gmane.linux.drivers.i2c,gmane.linux.ports.arm.kernel,gmane.linux.kernel
Message-ID <[email protected]>
From: bui duc phuc <[email protected]>

platform_get_irq_optional() returns a positive IRQ number on success or
a negative error code on failure. For an optional IRQ, -ENXIO indicates
that no optional IRQ is available. Other errors, such as -EPROBE_DEFER
and -EINVAL, should be propagated so that the caller can handle them
appropriately.

Propagate negative errors other than -ENXIO.

Signed-off-by: bui duc phuc <[email protected]>
---
 drivers/i2c/busses/i2c-pca-platform.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index c0f35ebbe37d..63c8ca1f1870 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -139,8 +139,11 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
 
 	irq = platform_get_irq_optional(pdev, 0);
 	/* If irq is 0, we do polling. */
-	if (irq < 0)
+	if (irq < 0) {
+		if (irq != -ENXIO)
+			return irq;
 		irq = 0;
+	}
 
 	i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.