lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141120214838.GA346@pengutronix.de>
Date:	Thu, 20 Nov 2014 22:48:38 +0100
From:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
To:	Grygorii Strashko <grygorii.strashko@...com>
Cc:	Wolfram Sang <wsa@...-dreams.de>, linux-i2c@...r.kernel.org,
	linux-kernel@...r.kernel.org, Sekhar Nori <nsekhar@...com>,
	Kevin Hilman <khilman@...prootsystems.com>,
	Santosh Shilimkar <ssantosh@...nel.org>,
	Murali Karicheri <m-karicheri2@...com>
Subject: Re: [1/5] i2c: i2c-davinci: switch to use platform_get_irq

Hello Grygorii,

On Thu, Nov 20, 2014 at 12:03:04PM +0200, Grygorii Strashko wrote:
> Switch Davinci I2C driver to use platform_get_irq(), because
> - it is not recommened to use
>   platform_get_resource(pdev, IORESOURCE_IRQ, ..) for requesting IRQ's
>   resources any more, as they can be not ready yet in case of DT-booting.
> - it makes code simpler
> 
> CC: Sekhar Nori <nsekhar@...com>
> CC: Kevin Hilman <khilman@...prootsystems.com>
> CC: Santosh Shilimkar <ssantosh@...nel.org>
> CC: Murali Karicheri <m-karicheri2@...com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@...com>
> ---
>  drivers/i2c/busses/i2c-davinci.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
> index 4d96147..9bbfb8f 100644
> --- a/drivers/i2c/busses/i2c-davinci.c
> +++ b/drivers/i2c/busses/i2c-davinci.c
> @@ -640,13 +640,13 @@ static int davinci_i2c_probe(struct platform_device *pdev)
>  {
>  	struct davinci_i2c_dev *dev;
>  	struct i2c_adapter *adap;
> -	struct resource *mem, *irq;
> -	int r;
> +	struct resource *mem;
> +	int r, irq;
>  
> -	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> -	if (!irq) {
> -		dev_err(&pdev->dev, "no irq resource?\n");
> -		return -ENODEV;
> +	irq = platform_get_irq(pdev, 0);
One bad thing about platform_get_irq is its unusual handling of irq=0.
I'm pretty sure you don't want to use this value, so adding something
like:

	if (!irq)
		irq = -ENXIO

would be welcome because the usual value for "invalid irq" is 0 and not
-ESOMETHING. platform_get_irq is one of the very few functions that
don't adhere to this convention. With handling <= 0 as error your code
is immune to changes in this area. Although I notice that
platform_get_irq got worse in this respect to handle -EPROBE_DEFER. hmm.

Apart from your change I wonder if platform_get_irq should handle
of_irq_get returning 0 as an error.

> +	if (irq < 0) {
> +		dev_err(&pdev->dev, "can't get irq resource ret=%d\n", irq);
Please don't print an error if irq=-EPROBE_DEFER.

> +		return irq;
>  	}

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ