Correctly handle plaform_get_irq()'s result in the i2C drivers
Subsystems (5)
v2 cover Correctly handle plaform_get_irq()'s result in the i2C drivers
Here are 5 patches against the 'i2c/for-current' branch of Wolfram's 'linux.git' repo. The affected drivers call platform_get_irq() but mis-interprete its result -- they consider IRQ0 as error and (sometimes) the real error codes as valid IRQs... :-/
[1/5] i2c: hix5hd2: fix IRQ check
[2/5] i2c: mt65xx: fix IRQ check
[3/5] i2c: pmcmsp: fix IRQ check
[4/5] i2c: s3c2410: fix IRQ check
[5/5] i2c: xlp9xx: fix main IRQ check
PATCH v2 1/5 i2c: hix5hd2: fix IRQ check
Iff platform_get_irq() returns 0, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision...
--- drivers/i2c/busses/i2c-hix5hd2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-hix5hd2.c +1 -1
@@ -413,7 +413,7 @@ static int hix5hd2_i2c_probe(struct platreturn PTR_ERR (priv->regs); irq =platform_get_irq (pdev,0 ); -if (irq <=0 ) +if (irq <0 )return irq; priv->clk =devm_clk_get (&pdev->dev,NULL );
Wolfram Sang
AppliedRe: [PATCH v2 1/5] i2c: hix5hd2: fix IRQ check
Quoted 7 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes 15ef27756b23 ("i2c: hix5hd2: add i2c controller driver")Signed-off-by Sergey Shtylyov <[email protected]>
Applied to for-next, thanks!
PATCH v2 2/5 i2c: mt65xx: fix IRQ check
In reply to Sergey ShtylyovIff platform_get_irq() returns 0, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision...
--- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-mt65xx.c +1 -1
@@ -1211,7 +1211,7 @@ static int mtk_i2c_probe(struct platformreturn PTR_ERR (i2c->pdmabase); irq =platform_get_irq (pdev,0 ); -if (irq <=0 ) +if (irq <0 )return irq;init_completion (&i2c->msg_complete);
Re: [PATCH v2 2/5] i2c: mt65xx: fix IRQ check
Quoted 6 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes ce38815d39ea ("I2C: mediatek: Add driver for MediaTek I2C controller")Signed-off-by Sergey Shtylyov <[email protected]>
Qii Wang, do you like this patch?
Quoted 18 lines
--- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux/drivers/i2c/busses/i2c-mt65xx.c
===================================================================drivers/i2c/busses/i2c-mt65xx.c +1
-1@@ -1211,7 +1211,7 @@ static int mtk_i2c_probe(struct platformreturn PTR_ERR (i2c->pdmabase); irq =platform_get_irq (pdev,0 ); -if (irq <=0 ) +if (irq <0 )return irq;init_completion (&i2c->msg_complete);
Re: [PATCH v2 2/5] i2c: mt65xx: fix IRQ check
Quoted 10 lines · Wolfram Sang
Quoted 6 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes ce38815d39ea ("I2C: mediatek: Add driver for MediaTek I2C controller")Signed-off-by Sergey Shtylyov <[email protected]>Qii Wang, do you like this patch?
It is ok.
Thanks
Quoted 18 lines
Quoted 18 lines
--- drivers/i2c/busses/i2c-mt65xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux/drivers/i2c/busses/i2c-mt65xx.c
===================================================================drivers/i2c/busses/i2c-mt65xx.c +1
-1@@ -1211,7 +1211,7 @@ static int mtk_i2c_probe(struct platformreturn PTR_ERR (i2c->pdmabase); irq =platform_get_irq (pdev,0 ); -if (irq <=0 ) +if (irq <0 )return irq;init_completion (&i2c->msg_complete);
Wolfram Sang
AppliedRe: [PATCH v2 2/5] i2c: mt65xx: fix IRQ check
In reply to Sergey ShtylyovQuoted 7 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes ce38815d39ea ("I2C: mediatek: Add driver for MediaTek I2C controller")Signed-off-by Sergey Shtylyov <[email protected]>
Applied to for-next, thanks!
PATCH v2 3/5 i2c: pmcmsp: fix IRQ check
In reply to Sergey ShtylyovThe driver's probe() method is written as if platform_get_irq() returns 0 on error, while actually it returns a negative error code (with all the other values considered valid IRQs). Rewrite the driver's IRQ checking code to pass the positive IRQ #s to request_irq() and use polling mode when platform_get_irq() returns negative error code (or IRQ0)...
---
Changes in version 2:
- fixed the IRQ validity check, assigning the result of platform_get_irq() call to the 'rc' variable first;
- merging the code enforcing the polling mode on bad IRQ in one place (after calling request_irq() and handling its result);
- removed explicit check for the deferred probe, fixed up the patch description accordingly;
- removed the dashes in the patch subject;
- refreshed the patch.
drivers/i2c/busses/i2c-pmcmsp.c | 8 +++++---
drivers/i2c/busses/i2c-pmcmsp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-pmcmsp.c +9 -3
@@ -291,8 +291,9 @@ static int pmcmsptwi_probe(struct platfo }/* request the irq */ - pmcmsptwi_data.irq =platform_get_irq (pldev,0 ); -if (pmcmsptwi_data.irq) { + rc =platform_get_irq (pldev,0 ); + pmcmsptwi_data.irq = rc; +if (rc >0 ) { rc =request_irq (pmcmsptwi_data.irq, &pmcmsptwi_interrupt,IRQF_SHARED , pldev->name, &pmcmsptwi_data);if (rc ==0 ) {
@@ -312,9 +313,14 @@ static int pmcmsptwi_probe(struct platfo"Could not assign TWI IRQ handler " "to irq %d (continuing with poll)\n" , pmcmsptwi_data.irq); - pmcmsptwi_data.irq =0 ; } } +/* +* We only get here with a negative rc if either platform_get_irq() or +* request_irq() call has failed; we have to enforce the polling mode... +*/ +if (rc <0 ) + pmcmsptwi_data.irq =0 ;init_completion (&pmcmsptwi_data.wait);mutex_init (&pmcmsptwi_data.lock);
Re: [PATCH v2 3/5] i2c: pmcmsp: fix IRQ check
Quoted 8 lines · Sergey Shtylyov
The driver's
probe()method is written as ifplatform_get_irq()returns 0 on error, while actually it returns a negative error code (with all the other values considered valid IRQs). Rewrite the driver's IRQ checking code to pass the positive IRQ #s torequest_irq()and use polling mode whenplatform_get_irq()returns negative error code (or IRQ0)...Fixes 1b144df1d7d6 ("i2c: New PMC MSP71xx TWI bus driver")Signed-off-by Sergey Shtylyov <[email protected]>
The driver has been removed meanwhile.
PATCH v2 4/5 i2c: s3c2410: fix IRQ check
In reply to Sergey ShtylyovIff platform_get_irq() returns 0, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision...
--- drivers/i2c/busses/i2c-s3c2410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-s3c2410.c +1 -1
@@ -1137,7 +1137,7 @@ static int s3c24xx_i2c_probe(struct plat*/ if (!(i2c->quirks &QUIRK_POLL )) { i2c->irq = ret =platform_get_irq (pdev,0 ); -if (ret <=0 ) { +if (ret <0 ) {dev_err (&pdev->dev,"cannot find IRQ\n" );clk_unprepare (i2c->clk);return ret;
Re: [PATCH v2 4/5] i2c: s3c2410: fix IRQ check
Quoted 10 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes 2bbd681ba2b ("i2c-s3c2410: Change IRQ to be plain integer.")Signed-off-by Sergey Shtylyov <[email protected]>--- drivers/i2c/busses/i2c-s3c2410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Best regards,
Krzysztof
Wolfram Sang
AppliedRe: [PATCH v2 4/5] i2c: s3c2410: fix IRQ check
In reply to Sergey ShtylyovQuoted 7 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes 2bbd681ba2b ("i2c-s3c2410: Change IRQ to be plain integer.")Signed-off-by Sergey Shtylyov <[email protected]>
Applied to for-next, thanks!
PATCH v2 5/5 i2c: xlp9xx: fix main IRQ check
In reply to Sergey ShtylyovIff platform_get_irq() returns 0 for the main IRQ, the driver's probe() method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity -- devm_request_irq() can always override that decision...
--- drivers/i2c/busses/i2c-xlp9xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-xlp9xx.c +1 -1
@@ -517,7 +517,7 @@ static int xlp9xx_i2c_probe(struct platfreturn PTR_ERR (priv->base); priv->irq =platform_get_irq (pdev,0 ); -if (priv->irq <=0 ) +if (priv->irq <0 )return priv->irq;/* SMBAlert irq */ priv->alert_data.irq =platform_get_irq (pdev,1 );
Re: [PATCH v2 5/5] i2c: xlp9xx: fix main IRQ check
Quoted 8 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0 for the main IRQ, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes 2bbd681ba2b ("i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller")Signed-off-by Sergey Shtylyov <[email protected]>
George, do you like this patch?
Quoted 17 lines
--- drivers/i2c/busses/i2c-xlp9xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux/drivers/i2c/busses/i2c-xlp9xx.c
===================================================================drivers/i2c/busses/i2c-xlp9xx.c +1
-1@@ -517,7 +517,7 @@ static int xlp9xx_i2c_probe(struct platfreturn PTR_ERR (priv->base); priv->irq =platform_get_irq (pdev,0 ); -if (priv->irq <=0 ) +if (priv->irq <0 )return priv->irq;/* SMBAlert irq */ priv->alert_data.irq =platform_get_irq (pdev,1 );
Wolfram Sang
AppliedRe: [PATCH v2 5/5] i2c: xlp9xx: fix main IRQ check
In reply to Sergey ShtylyovQuoted 8 lines · Sergey Shtylyov
Iff
platform_get_irq()returns 0 for the main IRQ, the driver'sprobe()method will return 0 early (as if the method's call was successful). Let's consider IRQ0 valid for simplicity --devm_request_irq()can always override that decision...Fixes 2bbd681ba2b ("i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller")Signed-off-by Sergey Shtylyov <[email protected]>
Applied to for-next, thanks!
Quoted 9 lines · Sergey Shtylyov
Here are 5 patches against the 'i2c/for-current' branch of Wolfram's 'linux.git' repo. The affected drivers call
platform_get_irq()but mis-interprete its result -- they consider IRQ0 as error and (sometimes) the real error codes as valid IRQs... :-/[1/5] i2c: hix5hd2: fix IRQ check
[2/5] i2c: mt65xx: fix IRQ check
[3/5] i2c: pmcmsp: fix IRQ check
[4/5] i2c: s3c2410: fix IRQ check
[5/5] i2c: xlp9xx: fix main IRQ check
Wolfram, hat's up with this series (its status in the patchwork is still "new")?
MBR, Sergey
Quoted 11 lines · Sergey Shtylyov
Quoted 9 lines
Here are 5 patches against the 'i2c/for-current' branch of Wolfram's 'linux.git' repo. The affected drivers call
platform_get_irq()but mis-interprete its result -- they consider IRQ0 as error and (sometimes) the real error codes as valid IRQs... :-/[1/5] i2c: hix5hd2: fix IRQ check
[2/5] i2c: mt65xx: fix IRQ check
[3/5] i2c: pmcmsp: fix IRQ check
[4/5] i2c: s3c2410: fix IRQ check
[5/5] i2c: xlp9xx: fix main IRQ checkWolfram, hat's up with this series (its status in the patchwork is still "new")?
What's, of/c. :-)
MBR, Sergey