mbox series

[v2,0/5] Correctly handle plaform_get_irq()'s result in the i2C drivers

Message ID 3712e871-bf2f-32c5-f9c2-2968c42087f8@omp.ru
Headers show
Series Correctly handle plaform_get_irq()'s result in the i2C drivers | expand

Message

Sergey Shtylyov July 4, 2021, 2:32 p.m. UTC
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

Comments

Sergey Shtylyov Aug. 11, 2021, 8:12 p.m. UTC | #1
On 7/4/21 5:32 PM, Sergey Shtylyov wrote:

> 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
Sergey Shtylyov Aug. 11, 2021, 8:14 p.m. UTC | #2
On 8/11/21 11:12 PM, Sergey Shtylyov wrote:

>> 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")? 

   What's, of/c. :-)

MBR, Sergey
Wolfram Sang Aug. 17, 2021, 8:08 p.m. UTC | #3
On Sun, Jul 04, 2021 at 05:41:50PM +0300, Sergey Shtylyov wrote:
> The 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)...

> 

> Fixes: 1b144df1d7d6 ("i2c: New PMC MSP71xx TWI bus driver")

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>


The driver has been removed meanwhile.
Wolfram Sang Aug. 17, 2021, 8:10 p.m. UTC | #4
On Sun, Jul 04, 2021 at 05:35:54PM +0300, Sergey Shtylyov wrote:
> 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...

> 

> Fixes: 15ef27756b23 ("i2c: hix5hd2: add i2c controller driver")

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

> 


Applied to for-next, thanks!
Wolfram Sang Aug. 17, 2021, 8:13 p.m. UTC | #5
On Sun, Jul 04, 2021 at 05:47:54PM +0300, Sergey Shtylyov wrote:
> Iff 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...

> 

> Fixes: 2bbd681ba2b ("i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller")

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

> 


George, do you like this patch?

> ---

>  drivers/i2c/busses/i2c-xlp9xx.c |    2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> Index: linux/drivers/i2c/busses/i2c-xlp9xx.c

> ===================================================================

> --- linux.orig/drivers/i2c/busses/i2c-xlp9xx.c

> +++ linux/drivers/i2c/busses/i2c-xlp9xx.c

> @@ -517,7 +517,7 @@ static int xlp9xx_i2c_probe(struct platf

>  		return 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 Aug. 25, 2021, 9:05 p.m. UTC | #6
On Sun, Jul 04, 2021 at 05:47:54PM +0300, Sergey Shtylyov wrote:
> Iff 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...

> 

> Fixes: 2bbd681ba2b ("i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller")

> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

> 


Applied to for-next, thanks!