All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
To: "Uwe Kleine-König"
	<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	"Rob Herring"
	<robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Grant Likely"
	<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>,
	Kevin Hilman
	<khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>,
	Santosh Shilimkar
	<ssantosh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Murali Karicheri <m-karicheri2-l0cyMroinI0@public.gmane.org>
Subject: Re: [1/5] i2c: i2c-davinci: switch to use platform_get_irq
Date: Fri, 21 Nov 2014 13:01:17 +0200	[thread overview]
Message-ID: <546F1B7D.1020209@ti.com> (raw)
In-Reply-To: <20141120214838.GA346-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

On 11/20/2014 11:48 PM, Uwe Kleine-König wrote:
> 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-l0cyMroinI0@public.gmane.org>
>> CC: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
>> CC: Santosh Shilimkar <ssantosh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>> CC: Murali Karicheri <m-karicheri2-l0cyMroinI0@public.gmane.org>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org>
>> ---
>>   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.

I think you are right and It seems like, the check for !irq should
be added/restored for OF case in platform_get_irq() too.

Also, I've simulated irq == 0 case - the .probe() failed with error -EINVAL
which is returned by request_threaded_irq() because of !irq_settings_can_request(desc).
 i2c_davinci 2530000.i2c: failure requesting irq 0
 i2c_davinci: probe of 2530000.i2c failed with error -22

I'm not sure that above will work for everyone because it depends on ARCH_IRQ_INIT_FLAGS
and ARCH_IRQ_INIT_FLAGS = (IRQ_NOREQUEST | IRQ_NOPROBE) for ARM.

> 
>> +	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.
ok.

regards,
-grygorii

WARNING: multiple messages have this Message-ID (diff)
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Rob Herring" <robherring2@gmail.com>,
	"Grant Likely" <grant.likely@linaro.org>
Cc: Wolfram Sang <wsa@the-dreams.de>, <linux-i2c@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Sekhar Nori <nsekhar@ti.com>,
	Kevin Hilman <khilman@deeprootsystems.com>,
	Santosh Shilimkar <ssantosh@kernel.org>,
	Murali Karicheri <m-karicheri2@ti.com>
Subject: Re: [1/5] i2c: i2c-davinci: switch to use platform_get_irq
Date: Fri, 21 Nov 2014 13:01:17 +0200	[thread overview]
Message-ID: <546F1B7D.1020209@ti.com> (raw)
In-Reply-To: <20141120214838.GA346@pengutronix.de>

On 11/20/2014 11:48 PM, Uwe Kleine-König wrote:
> 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@ti.com>
>> CC: Kevin Hilman <khilman@deeprootsystems.com>
>> CC: Santosh Shilimkar <ssantosh@kernel.org>
>> CC: Murali Karicheri <m-karicheri2@ti.com>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.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.

I think you are right and It seems like, the check for !irq should
be added/restored for OF case in platform_get_irq() too.

Also, I've simulated irq == 0 case - the .probe() failed with error -EINVAL
which is returned by request_threaded_irq() because of !irq_settings_can_request(desc).
 i2c_davinci 2530000.i2c: failure requesting irq 0
 i2c_davinci: probe of 2530000.i2c failed with error -22

I'm not sure that above will work for everyone because it depends on ARCH_IRQ_INIT_FLAGS
and ARCH_IRQ_INIT_FLAGS = (IRQ_NOREQUEST | IRQ_NOPROBE) for ARM.

> 
>> +	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.
ok.

regards,
-grygorii


  parent reply	other threads:[~2014-11-21 11:01 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 10:03 [PATCH 0/5] i2c: davinci improvements and fixes Grygorii Strashko
2014-11-20 10:03 ` Grygorii Strashko
2014-11-20 10:03 ` [PATCH 1/5] i2c: i2c-davinci: switch to use platform_get_irq Grygorii Strashko
2014-11-20 10:03   ` Grygorii Strashko
2014-11-20 21:48   ` [1/5] " Uwe Kleine-König
     [not found]     ` <20141120214838.GA346-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-11-21 11:01       ` Grygorii Strashko [this message]
2014-11-21 11:01         ` Grygorii Strashko
     [not found]         ` <546F1B7D.1020209-l0cyMroinI0@public.gmane.org>
2014-11-21 14:03           ` Rob Herring
2014-11-21 14:03             ` Rob Herring
2014-11-21 14:59             ` Grygorii Strashko
     [not found] ` <1416477788-5544-1-git-send-email-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2014-11-20 10:03   ` [PATCH 2/5] i2c: davinci: query STP always when NACK is received Grygorii Strashko
2014-11-20 10:03     ` Grygorii Strashko
     [not found]     ` <1416477788-5544-3-git-send-email-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2014-11-20 22:19       ` [2/5] " Uwe Kleine-König
2014-11-20 22:19         ` Uwe Kleine-König
     [not found]         ` <20141120221953.GI27002-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-11-21 12:48           ` Grygorii Strashko
2014-11-21 12:48             ` Grygorii Strashko
     [not found]             ` <546F34B9.1000206-l0cyMroinI0@public.gmane.org>
2014-11-21 13:10               ` Uwe Kleine-König
2014-11-21 13:10                 ` Uwe Kleine-König
2014-11-21 15:33                 ` Grygorii Strashko
2014-11-21 15:33                   ` Grygorii Strashko
     [not found]                   ` <546F5B51.1030006-l0cyMroinI0@public.gmane.org>
2014-11-23 20:33                     ` Uwe Kleine-König
2014-11-23 20:33                       ` Uwe Kleine-König
     [not found]                       ` <20141123203314.GF4431-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-11-24 13:34                         ` Grygorii Strashko
2014-11-24 13:34                           ` Grygorii Strashko
     [not found]                           ` <547333EB.5050403-l0cyMroinI0@public.gmane.org>
2014-11-24 20:02                             ` Uwe Kleine-König
2014-11-24 20:02                               ` Uwe Kleine-König
2014-11-20 10:03 ` [PATCH 3/5] i2c: recovery: change input parameter to i2c_adapter for prepare/unprepare_recovery Grygorii Strashko
2014-11-20 10:03   ` Grygorii Strashko
     [not found]   ` <1416477788-5544-4-git-send-email-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2014-11-21 18:49     ` [3/5] " Uwe Kleine-König
2014-11-21 18:49       ` Uwe Kleine-König
2014-11-20 10:03 ` [PATCH 4/5] i2c: davinci: use bus recovery infrastructure Grygorii Strashko
2014-11-20 10:03   ` Grygorii Strashko
     [not found]   ` <1416477788-5544-5-git-send-email-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2014-11-21 19:07     ` [4/5] " Uwe Kleine-König
2014-11-21 19:07       ` Uwe Kleine-König
     [not found]       ` <20141121190744.GB4431-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-11-21 19:33         ` Grygorii Strashko
2014-11-21 19:33           ` Grygorii Strashko
     [not found]           ` <546F9382.40102-l0cyMroinI0@public.gmane.org>
2014-11-23 20:36             ` Uwe Kleine-König
2014-11-23 20:36               ` Uwe Kleine-König
2014-11-24 13:26               ` Grygorii Strashko
2014-11-24 13:26                 ` Grygorii Strashko
     [not found]                 ` <547331F2.3000006-l0cyMroinI0@public.gmane.org>
2014-11-24 20:07                   ` Uwe Kleine-König
2014-11-24 20:07                     ` Uwe Kleine-König
2014-11-20 10:03 ` [PATCH 5/5] i2c: davinci: use ICPFUNC to toggle I2C as gpio for bus recovery Grygorii Strashko
2014-11-20 10:03   ` Grygorii Strashko
     [not found]   ` <1416477788-5544-6-git-send-email-grygorii.strashko-l0cyMroinI0@public.gmane.org>
2014-11-23 17:04     ` [5/5] " Uwe Kleine-König
2014-11-23 17:04       ` Uwe Kleine-König
     [not found]       ` <20141123170400.GC4431-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-11-24 13:15         ` Grygorii Strashko
2014-11-24 13:15           ` Grygorii Strashko
     [not found]           ` <54732F8E.4080105-l0cyMroinI0@public.gmane.org>
2014-11-24 18:13             ` Mike Looijmans
2014-11-24 18:13               ` Mike Looijmans
     [not found]               ` <54737532.1050808-KQxf8TFvCoAi8rCdYzckzA@public.gmane.org>
2014-11-24 19:22                 ` Grygorii Strashko
2014-11-24 19:22                   ` Grygorii Strashko
2014-11-24 19:45             ` Uwe Kleine-König
2014-11-24 19:45               ` Uwe Kleine-König
     [not found]               ` <20141124194533.GU4431-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2014-11-25 13:04                 ` Grygorii Strashko
2014-11-25 13:04                   ` Grygorii Strashko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=546F1B7D.1020209@ti.com \
    --to=grygorii.strashko-l0cymroini0@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=m-karicheri2-l0cyMroinI0@public.gmane.org \
    --cc=nsekhar-l0cyMroinI0@public.gmane.org \
    --cc=robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=ssantosh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.