linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
@ 2014-01-30 12:15 xinhui.pan
  2014-01-31 20:50 ` David Cohen
  0 siblings, 1 reply; 15+ messages in thread
From: xinhui.pan @ 2014-01-30 12:15 UTC (permalink / raw)
  To: balbi, david.a.cohen
  Cc: yanmin_zhang, linux-kernel, linux-gpio, linus.walleij, gnurou,
	xinhuix.pan

On Wed, 29 Jan 2014 13:06, David Cohen wrote:
> On Wed, Jan 29, 2014 at 01:52:30PM -0600, Felipe Balbi wrote:
>> On Wed, Jan 29, 2014 at 11:12:32AM -0800, David Cohen wrote:
>>> On Wed, Jan 29, 2014 at 03:23:40PM +0800, xinhui.pan wrote:
>>>>
>>>> 于 2014年01月29日 08:13, David Cohen 写道:
>>>>> On Tue, Jan 28, 2014 at 12:12:06PM -0600, Felipe Balbi wrote:
>>>>>> On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
>>>>>>> On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
>>>>>>>> On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
>>>>>>>>> From: "xinhui.pan" <xinhuiX.pan@intel.com>
>>>>>>>>>
>>>>>>>>> intel_gpio_runtime_idle should return correct error code if it do fail.
>>>>>>>>> make it more correct even though -EBUSY is the most possible return value.
>>>>>>>>>
>>>>>>>>> Signed-off-by: bo.he <bo.he@intel.com>
>>>>>>>>> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
>>>>>>>>> ---
>>>>>>>>>  drivers/gpio/gpio-intel-mid.c |    4 +++-
>>>>>>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>>>>>>>
>>>>>>>>> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
>>>>>>>>> index d1b50ef..05749a3 100644
>>>>>>>>> --- a/drivers/gpio/gpio-intel-mid.c
>>>>>>>>> +++ b/drivers/gpio/gpio-intel-mid.c
>>>>>>>>> @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
>>>>>>>>>
>>>>>>>>>  static int intel_gpio_runtime_idle(struct device *dev)
>>>>>>>>>  {
>>>>>>>>> -	pm_schedule_suspend(dev, 500);
>>>>>>>>> +	int err = pm_schedule_suspend(dev, 500);
>>>>>>>>> +	if (err)
>>>>>>>>> +		return err;
>>>>>>>>>  	return -EBUSY;
>>>>>>>>
>>>>>>>> wait, is it only me or this would look a lot better as:
>>>>>>>>
>>>>>>>> static int intel_gpio_runtime_idle(struct device *dev)
>>>>>>>> {
>>>>>>>> 	return pm_schedule_suspend(dev, 500);
>>>>>>>> }
>>>>>>>
>>>>>>> The reply to your suggestion is probably in this commit :)
>>>>>>>
>>>>>>> ---
>>>>>>> commit 45f0a85c8258741d11bda25c0a5669c06267204a
>>>>>>> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>>>>> Date:   Mon Jun 3 21:49:52 2013 +0200
>>>>>>>
>>>>>>>     PM / Runtime: Rework the "runtime idle" helper routine
>>>>>>> ---
>>>>>>>
>>>>>>> We won't return 0 from here.
>>>>>>
>>>>>> so you never want to return 0, why don't you, then:
>>>>>>
>>>>>> static int intel_gpio_runtime_idle(struct device *dev)
>>>>>> {
>>>>>> 	pm_schedule_suspend(dev, 500);
>>>>>> 	return -EBUSY;
>>>>>> }
>>>>>
>>>>> That's how it is currently :)
>>>>>
>>>>> But this patch is making the function to return a different code in case
>>>>> of error. IMHO there is not much fuctional gain with it, but I see
>>>>> perhaps one extra info for tracing during development.
>>>>>
>>>>> Anyway, I'll let Xinhui to do further comment since he's the author.
>>>>>
>>>>> Br, David
>>>>>
>>>> hi ,David & Balbi
>>>>   I checked several drivers yesterday to see how they use pm_schedule_suspend 
>>>> then found one bug in i2c. Also I noticed  gpio. 
>>>> I think returning a correct error code is important.So I change -EBUSY 
>>>> to *err*. To be honest,current code works well.
>>>
>>> In my experience, when I'm using fancy things like lauterbach a proper
>>> error code may save couple of minutes in my life :)
>>>
>>> I keep my ack here.
>>
>> fair enough, sorry for the noise ;-) It could still be simplified a bit:
>>
>> 	return err ?: -EBUSY;
> 
> Agreed :)
> Xinhui, could we have this suggestion in your patch?
> 
> Br, David
> 

Hi all,
  I am xinhui pan. Thanks to the VPN problem, I can't access Intel's network. So I have to send you this email by personal email address.
I am on Spring Festival vacation until Feb 9th. Sorry for that.
  Your suggestion is very nice,thanks :) 
  I will  generate V2 patch ASAP when my vocation is over. Thanks for all your help.

>>
>> -- 
>> balbi
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-30 12:15 [PATCH] gpio-intel-mid: fix the incorrect return of idle callback xinhui.pan
@ 2014-01-31 20:50 ` David Cohen
  2014-01-31 21:08   ` [PATCH v2] " David Cohen
  0 siblings, 1 reply; 15+ messages in thread
From: David Cohen @ 2014-01-31 20:50 UTC (permalink / raw)
  To: xinhui.pan
  Cc: balbi, yanmin_zhang, linux-kernel, linux-gpio, linus.walleij,
	gnurou, xinhuix.pan

Hi Xinhui,

> Hi all,
>   I am xinhui pan. Thanks to the VPN problem, I can't access Intel's
>   network. So I have to send you this email by personal email address.
>   I am on Spring Festival vacation until Feb 9th. Sorry for that.
>   Your suggestion is very nice,thanks :) 
>   I will  generate V2 patch ASAP when my vocation is over. Thanks for
>   all your help.

Since I got your ack you agree with this change, I can resend on behalf
of you. Just enjoy your holidays :)

Br, David

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-31 20:50 ` David Cohen
@ 2014-01-31 21:08   ` David Cohen
  2014-01-31 21:26     ` Felipe Balbi
  2014-02-05  9:37     ` Linus Walleij
  0 siblings, 2 replies; 15+ messages in thread
From: David Cohen @ 2014-01-31 21:08 UTC (permalink / raw)
  To: linus.walleij, gnurou
  Cc: linux-gpio, linux-kernel, xinhui.pan, bo.he, David Cohen, Felibe Balbi

From: "xinhui.pan" <xinhuiX.pan@intel.com>

intel_gpio_runtime_idle should return correct error code if it do fail.
make it more correct even though -EBUSY is the most possible return value.

Signed-off-by: bo.he <bo.he@intel.com>
Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Cc: Felibe Balbi <balbi@ti.com>
---
 drivers/gpio/gpio-intel-mid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
index 41218e93b9fe..55688d0548e9 100644
--- a/drivers/gpio/gpio-intel-mid.c
+++ b/drivers/gpio/gpio-intel-mid.c
@@ -369,8 +369,8 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
 
 static int intel_gpio_runtime_idle(struct device *dev)
 {
-	pm_schedule_suspend(dev, 500);
-	return -EBUSY;
+	int err = pm_schedule_suspend(dev, 500);
+	return err ?: -EBUSY;
 }
 
 static const struct dev_pm_ops intel_gpio_pm_ops = {
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-31 21:08   ` [PATCH v2] " David Cohen
@ 2014-01-31 21:26     ` Felipe Balbi
  2014-02-05  9:37     ` Linus Walleij
  1 sibling, 0 replies; 15+ messages in thread
From: Felipe Balbi @ 2014-01-31 21:26 UTC (permalink / raw)
  To: David Cohen
  Cc: linus.walleij, gnurou, linux-gpio, linux-kernel, xinhui.pan,
	bo.he, Felibe Balbi

[-- Attachment #1: Type: text/plain, Size: 1196 bytes --]

On Fri, Jan 31, 2014 at 01:08:01PM -0800, David Cohen wrote:
> From: "xinhui.pan" <xinhuiX.pan@intel.com>
> 
> intel_gpio_runtime_idle should return correct error code if it do fail.
> make it more correct even though -EBUSY is the most possible return value.
> 
> Signed-off-by: bo.he <bo.he@intel.com>
> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
> Cc: Felibe Balbi <balbi@ti.com>

Reviewed-by: Felipe Balbi <balbi@ti.com>

> ---
>  drivers/gpio/gpio-intel-mid.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> index 41218e93b9fe..55688d0548e9 100644
> --- a/drivers/gpio/gpio-intel-mid.c
> +++ b/drivers/gpio/gpio-intel-mid.c
> @@ -369,8 +369,8 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
>  
>  static int intel_gpio_runtime_idle(struct device *dev)
>  {
> -	pm_schedule_suspend(dev, 500);
> -	return -EBUSY;
> +	int err = pm_schedule_suspend(dev, 500);
> +	return err ?: -EBUSY;
>  }
>  
>  static const struct dev_pm_ops intel_gpio_pm_ops = {
> -- 
> 1.8.4.2
> 

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-31 21:08   ` [PATCH v2] " David Cohen
  2014-01-31 21:26     ` Felipe Balbi
@ 2014-02-05  9:37     ` Linus Walleij
  1 sibling, 0 replies; 15+ messages in thread
From: Linus Walleij @ 2014-02-05  9:37 UTC (permalink / raw)
  To: David Cohen
  Cc: Alexandre Courbot, linux-gpio, linux-kernel, xinhui.pan, bo.he,
	Felibe Balbi

On Fri, Jan 31, 2014 at 10:08 PM, David Cohen
<david.a.cohen@linux.intel.com> wrote:

> From: "xinhui.pan" <xinhuiX.pan@intel.com>
>
> intel_gpio_runtime_idle should return correct error code if it do fail.
> make it more correct even though -EBUSY is the most possible return value.
>
> Signed-off-by: bo.he <bo.he@intel.com>
> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
> Cc: Felibe Balbi <balbi@ti.com>

Patch applied with Felipe's Reviewed-by tag.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-29 19:52             ` Felipe Balbi
@ 2014-01-29 21:06               ` David Cohen
  0 siblings, 0 replies; 15+ messages in thread
From: David Cohen @ 2014-01-29 21:06 UTC (permalink / raw)
  To: Felipe Balbi, xinhui.pan
  Cc: linux-kernel, linux-gpio, linus.walleij, gnurou, yanmin_zhang

On Wed, Jan 29, 2014 at 01:52:30PM -0600, Felipe Balbi wrote:
> On Wed, Jan 29, 2014 at 11:12:32AM -0800, David Cohen wrote:
> > On Wed, Jan 29, 2014 at 03:23:40PM +0800, xinhui.pan wrote:
> > > 
> > > 于 2014年01月29日 08:13, David Cohen 写道:
> > > > On Tue, Jan 28, 2014 at 12:12:06PM -0600, Felipe Balbi wrote:
> > > >> On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
> > > >>> On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
> > > >>>> On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> > > >>>>> From: "xinhui.pan" <xinhuiX.pan@intel.com>
> > > >>>>>
> > > >>>>> intel_gpio_runtime_idle should return correct error code if it do fail.
> > > >>>>> make it more correct even though -EBUSY is the most possible return value.
> > > >>>>>
> > > >>>>> Signed-off-by: bo.he <bo.he@intel.com>
> > > >>>>> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> > > >>>>> ---
> > > >>>>>  drivers/gpio/gpio-intel-mid.c |    4 +++-
> > > >>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
> > > >>>>>
> > > >>>>> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> > > >>>>> index d1b50ef..05749a3 100644
> > > >>>>> --- a/drivers/gpio/gpio-intel-mid.c
> > > >>>>> +++ b/drivers/gpio/gpio-intel-mid.c
> > > >>>>> @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
> > > >>>>>  
> > > >>>>>  static int intel_gpio_runtime_idle(struct device *dev)
> > > >>>>>  {
> > > >>>>> -	pm_schedule_suspend(dev, 500);
> > > >>>>> +	int err = pm_schedule_suspend(dev, 500);
> > > >>>>> +	if (err)
> > > >>>>> +		return err;
> > > >>>>>  	return -EBUSY;
> > > >>>>
> > > >>>> wait, is it only me or this would look a lot better as:
> > > >>>>
> > > >>>> static int intel_gpio_runtime_idle(struct device *dev)
> > > >>>> {
> > > >>>> 	return pm_schedule_suspend(dev, 500);
> > > >>>> }
> > > >>>
> > > >>> The reply to your suggestion is probably in this commit :)
> > > >>>
> > > >>> ---
> > > >>> commit 45f0a85c8258741d11bda25c0a5669c06267204a
> > > >>> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > > >>> Date:   Mon Jun 3 21:49:52 2013 +0200
> > > >>>
> > > >>>     PM / Runtime: Rework the "runtime idle" helper routine
> > > >>> ---
> > > >>>
> > > >>> We won't return 0 from here.
> > > >>
> > > >> so you never want to return 0, why don't you, then:
> > > >>
> > > >> static int intel_gpio_runtime_idle(struct device *dev)
> > > >> {
> > > >> 	pm_schedule_suspend(dev, 500);
> > > >> 	return -EBUSY;
> > > >> }
> > > > 
> > > > That's how it is currently :)
> > > > 
> > > > But this patch is making the function to return a different code in case
> > > > of error. IMHO there is not much fuctional gain with it, but I see
> > > > perhaps one extra info for tracing during development.
> > > > 
> > > > Anyway, I'll let Xinhui to do further comment since he's the author.
> > > > 
> > > > Br, David
> > > > 
> > > hi ,David & Balbi
> > >   I checked several drivers yesterday to see how they use pm_schedule_suspend 
> > > then found one bug in i2c. Also I noticed  gpio. 
> > > I think returning a correct error code is important.So I change -EBUSY 
> > > to *err*. To be honest,current code works well.
> > 
> > In my experience, when I'm using fancy things like lauterbach a proper
> > error code may save couple of minutes in my life :)
> > 
> > I keep my ack here.
> 
> fair enough, sorry for the noise ;-) It could still be simplified a bit:
> 
> 	return err ?: -EBUSY;

Agreed :)
Xinhui, could we have this suggestion in your patch?

Br, David

> 
> -- 
> balbi



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-29 19:12           ` David Cohen
@ 2014-01-29 19:52             ` Felipe Balbi
  2014-01-29 21:06               ` David Cohen
  0 siblings, 1 reply; 15+ messages in thread
From: Felipe Balbi @ 2014-01-29 19:52 UTC (permalink / raw)
  To: David Cohen
  Cc: xinhui.pan, Felipe Balbi, linux-kernel, linux-gpio,
	linus.walleij, gnurou, yanmin_zhang

[-- Attachment #1: Type: text/plain, Size: 3342 bytes --]

On Wed, Jan 29, 2014 at 11:12:32AM -0800, David Cohen wrote:
> On Wed, Jan 29, 2014 at 03:23:40PM +0800, xinhui.pan wrote:
> > 
> > 于 2014年01月29日 08:13, David Cohen 写道:
> > > On Tue, Jan 28, 2014 at 12:12:06PM -0600, Felipe Balbi wrote:
> > >> On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
> > >>> On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
> > >>>> On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> > >>>>> From: "xinhui.pan" <xinhuiX.pan@intel.com>
> > >>>>>
> > >>>>> intel_gpio_runtime_idle should return correct error code if it do fail.
> > >>>>> make it more correct even though -EBUSY is the most possible return value.
> > >>>>>
> > >>>>> Signed-off-by: bo.he <bo.he@intel.com>
> > >>>>> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> > >>>>> ---
> > >>>>>  drivers/gpio/gpio-intel-mid.c |    4 +++-
> > >>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
> > >>>>>
> > >>>>> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> > >>>>> index d1b50ef..05749a3 100644
> > >>>>> --- a/drivers/gpio/gpio-intel-mid.c
> > >>>>> +++ b/drivers/gpio/gpio-intel-mid.c
> > >>>>> @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
> > >>>>>  
> > >>>>>  static int intel_gpio_runtime_idle(struct device *dev)
> > >>>>>  {
> > >>>>> -	pm_schedule_suspend(dev, 500);
> > >>>>> +	int err = pm_schedule_suspend(dev, 500);
> > >>>>> +	if (err)
> > >>>>> +		return err;
> > >>>>>  	return -EBUSY;
> > >>>>
> > >>>> wait, is it only me or this would look a lot better as:
> > >>>>
> > >>>> static int intel_gpio_runtime_idle(struct device *dev)
> > >>>> {
> > >>>> 	return pm_schedule_suspend(dev, 500);
> > >>>> }
> > >>>
> > >>> The reply to your suggestion is probably in this commit :)
> > >>>
> > >>> ---
> > >>> commit 45f0a85c8258741d11bda25c0a5669c06267204a
> > >>> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > >>> Date:   Mon Jun 3 21:49:52 2013 +0200
> > >>>
> > >>>     PM / Runtime: Rework the "runtime idle" helper routine
> > >>> ---
> > >>>
> > >>> We won't return 0 from here.
> > >>
> > >> so you never want to return 0, why don't you, then:
> > >>
> > >> static int intel_gpio_runtime_idle(struct device *dev)
> > >> {
> > >> 	pm_schedule_suspend(dev, 500);
> > >> 	return -EBUSY;
> > >> }
> > > 
> > > That's how it is currently :)
> > > 
> > > But this patch is making the function to return a different code in case
> > > of error. IMHO there is not much fuctional gain with it, but I see
> > > perhaps one extra info for tracing during development.
> > > 
> > > Anyway, I'll let Xinhui to do further comment since he's the author.
> > > 
> > > Br, David
> > > 
> > hi ,David & Balbi
> >   I checked several drivers yesterday to see how they use pm_schedule_suspend 
> > then found one bug in i2c. Also I noticed  gpio. 
> > I think returning a correct error code is important.So I change -EBUSY 
> > to *err*. To be honest,current code works well.
> 
> In my experience, when I'm using fancy things like lauterbach a proper
> error code may save couple of minutes in my life :)
> 
> I keep my ack here.

fair enough, sorry for the noise ;-) It could still be simplified a bit:

	return err ?: -EBUSY;

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-29  7:23         ` xinhui.pan
@ 2014-01-29 19:12           ` David Cohen
  2014-01-29 19:52             ` Felipe Balbi
  0 siblings, 1 reply; 15+ messages in thread
From: David Cohen @ 2014-01-29 19:12 UTC (permalink / raw)
  To: xinhui.pan
  Cc: Felipe Balbi, linux-kernel, linux-gpio, linus.walleij, gnurou,
	yanmin_zhang

On Wed, Jan 29, 2014 at 03:23:40PM +0800, xinhui.pan wrote:
> 
> 于 2014年01月29日 08:13, David Cohen 写道:
> > On Tue, Jan 28, 2014 at 12:12:06PM -0600, Felipe Balbi wrote:
> >> On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
> >>> On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
> >>>> On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> >>>>> From: "xinhui.pan" <xinhuiX.pan@intel.com>
> >>>>>
> >>>>> intel_gpio_runtime_idle should return correct error code if it do fail.
> >>>>> make it more correct even though -EBUSY is the most possible return value.
> >>>>>
> >>>>> Signed-off-by: bo.he <bo.he@intel.com>
> >>>>> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> >>>>> ---
> >>>>>  drivers/gpio/gpio-intel-mid.c |    4 +++-
> >>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> >>>>> index d1b50ef..05749a3 100644
> >>>>> --- a/drivers/gpio/gpio-intel-mid.c
> >>>>> +++ b/drivers/gpio/gpio-intel-mid.c
> >>>>> @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
> >>>>>  
> >>>>>  static int intel_gpio_runtime_idle(struct device *dev)
> >>>>>  {
> >>>>> -	pm_schedule_suspend(dev, 500);
> >>>>> +	int err = pm_schedule_suspend(dev, 500);
> >>>>> +	if (err)
> >>>>> +		return err;
> >>>>>  	return -EBUSY;
> >>>>
> >>>> wait, is it only me or this would look a lot better as:
> >>>>
> >>>> static int intel_gpio_runtime_idle(struct device *dev)
> >>>> {
> >>>> 	return pm_schedule_suspend(dev, 500);
> >>>> }
> >>>
> >>> The reply to your suggestion is probably in this commit :)
> >>>
> >>> ---
> >>> commit 45f0a85c8258741d11bda25c0a5669c06267204a
> >>> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >>> Date:   Mon Jun 3 21:49:52 2013 +0200
> >>>
> >>>     PM / Runtime: Rework the "runtime idle" helper routine
> >>> ---
> >>>
> >>> We won't return 0 from here.
> >>
> >> so you never want to return 0, why don't you, then:
> >>
> >> static int intel_gpio_runtime_idle(struct device *dev)
> >> {
> >> 	pm_schedule_suspend(dev, 500);
> >> 	return -EBUSY;
> >> }
> > 
> > That's how it is currently :)
> > 
> > But this patch is making the function to return a different code in case
> > of error. IMHO there is not much fuctional gain with it, but I see
> > perhaps one extra info for tracing during development.
> > 
> > Anyway, I'll let Xinhui to do further comment since he's the author.
> > 
> > Br, David
> > 
> hi ,David & Balbi
>   I checked several drivers yesterday to see how they use pm_schedule_suspend 
> then found one bug in i2c. Also I noticed  gpio. 
> I think returning a correct error code is important.So I change -EBUSY 
> to *err*. To be honest,current code works well.

In my experience, when I'm using fancy things like lauterbach a proper
error code may save couple of minutes in my life :)

I keep my ack here.

Br, David

> >>
> >> just like drivers/tty/serial/mfd.c::serial_hsu_runtime_idle() is doing ?
> >>
> >> -- 
> >> balbi
> > 
> > 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-29  0:13       ` David Cohen
@ 2014-01-29  7:23         ` xinhui.pan
  2014-01-29 19:12           ` David Cohen
  0 siblings, 1 reply; 15+ messages in thread
From: xinhui.pan @ 2014-01-29  7:23 UTC (permalink / raw)
  To: David Cohen, Felipe Balbi
  Cc: linux-kernel, linux-gpio, linus.walleij, gnurou, yanmin_zhang


于 2014年01月29日 08:13, David Cohen 写道:
> On Tue, Jan 28, 2014 at 12:12:06PM -0600, Felipe Balbi wrote:
>> On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
>>> On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
>>>> On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
>>>>> From: "xinhui.pan" <xinhuiX.pan@intel.com>
>>>>>
>>>>> intel_gpio_runtime_idle should return correct error code if it do fail.
>>>>> make it more correct even though -EBUSY is the most possible return value.
>>>>>
>>>>> Signed-off-by: bo.he <bo.he@intel.com>
>>>>> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
>>>>> ---
>>>>>  drivers/gpio/gpio-intel-mid.c |    4 +++-
>>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
>>>>> index d1b50ef..05749a3 100644
>>>>> --- a/drivers/gpio/gpio-intel-mid.c
>>>>> +++ b/drivers/gpio/gpio-intel-mid.c
>>>>> @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
>>>>>  
>>>>>  static int intel_gpio_runtime_idle(struct device *dev)
>>>>>  {
>>>>> -	pm_schedule_suspend(dev, 500);
>>>>> +	int err = pm_schedule_suspend(dev, 500);
>>>>> +	if (err)
>>>>> +		return err;
>>>>>  	return -EBUSY;
>>>>
>>>> wait, is it only me or this would look a lot better as:
>>>>
>>>> static int intel_gpio_runtime_idle(struct device *dev)
>>>> {
>>>> 	return pm_schedule_suspend(dev, 500);
>>>> }
>>>
>>> The reply to your suggestion is probably in this commit :)
>>>
>>> ---
>>> commit 45f0a85c8258741d11bda25c0a5669c06267204a
>>> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>> Date:   Mon Jun 3 21:49:52 2013 +0200
>>>
>>>     PM / Runtime: Rework the "runtime idle" helper routine
>>> ---
>>>
>>> We won't return 0 from here.
>>
>> so you never want to return 0, why don't you, then:
>>
>> static int intel_gpio_runtime_idle(struct device *dev)
>> {
>> 	pm_schedule_suspend(dev, 500);
>> 	return -EBUSY;
>> }
> 
> That's how it is currently :)
> 
> But this patch is making the function to return a different code in case
> of error. IMHO there is not much fuctional gain with it, but I see
> perhaps one extra info for tracing during development.
> 
> Anyway, I'll let Xinhui to do further comment since he's the author.
> 
> Br, David
> 
hi ,David & Balbi
  I checked several drivers yesterday to see how they use pm_schedule_suspend 
then found one bug in i2c. Also I noticed  gpio. 
I think returning a correct error code is important.So I change -EBUSY 
to *err*. To be honest,current code works well. 
>>
>> just like drivers/tty/serial/mfd.c::serial_hsu_runtime_idle() is doing ?
>>
>> -- 
>> balbi
> 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-28 18:12     ` Felipe Balbi
@ 2014-01-29  0:13       ` David Cohen
  2014-01-29  7:23         ` xinhui.pan
  0 siblings, 1 reply; 15+ messages in thread
From: David Cohen @ 2014-01-29  0:13 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: xinhui.pan, linux-kernel, linux-gpio, linus.walleij, gnurou,
	yanmin_zhang

On Tue, Jan 28, 2014 at 12:12:06PM -0600, Felipe Balbi wrote:
> On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
> > On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
> > > On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> > > > From: "xinhui.pan" <xinhuiX.pan@intel.com>
> > > > 
> > > > intel_gpio_runtime_idle should return correct error code if it do fail.
> > > > make it more correct even though -EBUSY is the most possible return value.
> > > > 
> > > > Signed-off-by: bo.he <bo.he@intel.com>
> > > > Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> > > > ---
> > > >  drivers/gpio/gpio-intel-mid.c |    4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> > > > index d1b50ef..05749a3 100644
> > > > --- a/drivers/gpio/gpio-intel-mid.c
> > > > +++ b/drivers/gpio/gpio-intel-mid.c
> > > > @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
> > > >  
> > > >  static int intel_gpio_runtime_idle(struct device *dev)
> > > >  {
> > > > -	pm_schedule_suspend(dev, 500);
> > > > +	int err = pm_schedule_suspend(dev, 500);
> > > > +	if (err)
> > > > +		return err;
> > > >  	return -EBUSY;
> > > 
> > > wait, is it only me or this would look a lot better as:
> > > 
> > > static int intel_gpio_runtime_idle(struct device *dev)
> > > {
> > > 	return pm_schedule_suspend(dev, 500);
> > > }
> > 
> > The reply to your suggestion is probably in this commit :)
> > 
> > ---
> > commit 45f0a85c8258741d11bda25c0a5669c06267204a
> > Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Date:   Mon Jun 3 21:49:52 2013 +0200
> > 
> >     PM / Runtime: Rework the "runtime idle" helper routine
> > ---
> > 
> > We won't return 0 from here.
> 
> so you never want to return 0, why don't you, then:
> 
> static int intel_gpio_runtime_idle(struct device *dev)
> {
> 	pm_schedule_suspend(dev, 500);
> 	return -EBUSY;
> }

That's how it is currently :)

But this patch is making the function to return a different code in case
of error. IMHO there is not much fuctional gain with it, but I see
perhaps one extra info for tracing during development.

Anyway, I'll let Xinhui to do further comment since he's the author.

Br, David

> 
> just like drivers/tty/serial/mfd.c::serial_hsu_runtime_idle() is doing ?
> 
> -- 
> balbi



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-28 17:24   ` David Cohen
@ 2014-01-28 18:12     ` Felipe Balbi
  2014-01-29  0:13       ` David Cohen
  0 siblings, 1 reply; 15+ messages in thread
From: Felipe Balbi @ 2014-01-28 18:12 UTC (permalink / raw)
  To: David Cohen
  Cc: Felipe Balbi, xinhui.pan, linux-kernel, linux-gpio,
	linus.walleij, gnurou, yanmin_zhang

[-- Attachment #1: Type: text/plain, Size: 1958 bytes --]

On Tue, Jan 28, 2014 at 09:24:13AM -0800, David Cohen wrote:
> On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
> > On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> > > From: "xinhui.pan" <xinhuiX.pan@intel.com>
> > > 
> > > intel_gpio_runtime_idle should return correct error code if it do fail.
> > > make it more correct even though -EBUSY is the most possible return value.
> > > 
> > > Signed-off-by: bo.he <bo.he@intel.com>
> > > Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> > > ---
> > >  drivers/gpio/gpio-intel-mid.c |    4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> > > index d1b50ef..05749a3 100644
> > > --- a/drivers/gpio/gpio-intel-mid.c
> > > +++ b/drivers/gpio/gpio-intel-mid.c
> > > @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
> > >  
> > >  static int intel_gpio_runtime_idle(struct device *dev)
> > >  {
> > > -	pm_schedule_suspend(dev, 500);
> > > +	int err = pm_schedule_suspend(dev, 500);
> > > +	if (err)
> > > +		return err;
> > >  	return -EBUSY;
> > 
> > wait, is it only me or this would look a lot better as:
> > 
> > static int intel_gpio_runtime_idle(struct device *dev)
> > {
> > 	return pm_schedule_suspend(dev, 500);
> > }
> 
> The reply to your suggestion is probably in this commit :)
> 
> ---
> commit 45f0a85c8258741d11bda25c0a5669c06267204a
> Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Date:   Mon Jun 3 21:49:52 2013 +0200
> 
>     PM / Runtime: Rework the "runtime idle" helper routine
> ---
> 
> We won't return 0 from here.

so you never want to return 0, why don't you, then:

static int intel_gpio_runtime_idle(struct device *dev)
{
	pm_schedule_suspend(dev, 500);
	return -EBUSY;
}

just like drivers/tty/serial/mfd.c::serial_hsu_runtime_idle() is doing ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-28 16:49 ` Felipe Balbi
@ 2014-01-28 17:24   ` David Cohen
  2014-01-28 18:12     ` Felipe Balbi
  0 siblings, 1 reply; 15+ messages in thread
From: David Cohen @ 2014-01-28 17:24 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: xinhui.pan, linux-kernel, linux-gpio, linus.walleij, gnurou,
	yanmin_zhang

On Tue, Jan 28, 2014 at 10:49:37AM -0600, Felipe Balbi wrote:
> On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> > From: "xinhui.pan" <xinhuiX.pan@intel.com>
> > 
> > intel_gpio_runtime_idle should return correct error code if it do fail.
> > make it more correct even though -EBUSY is the most possible return value.
> > 
> > Signed-off-by: bo.he <bo.he@intel.com>
> > Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> > ---
> >  drivers/gpio/gpio-intel-mid.c |    4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> > index d1b50ef..05749a3 100644
> > --- a/drivers/gpio/gpio-intel-mid.c
> > +++ b/drivers/gpio/gpio-intel-mid.c
> > @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
> >  
> >  static int intel_gpio_runtime_idle(struct device *dev)
> >  {
> > -	pm_schedule_suspend(dev, 500);
> > +	int err = pm_schedule_suspend(dev, 500);
> > +	if (err)
> > +		return err;
> >  	return -EBUSY;
> 
> wait, is it only me or this would look a lot better as:
> 
> static int intel_gpio_runtime_idle(struct device *dev)
> {
> 	return pm_schedule_suspend(dev, 500);
> }

The reply to your suggestion is probably in this commit :)

---
commit 45f0a85c8258741d11bda25c0a5669c06267204a
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Mon Jun 3 21:49:52 2013 +0200

    PM / Runtime: Rework the "runtime idle" helper routine
---

We won't return 0 from here.

Br, David

> 
> cheers
> 
> -- 
> balbi



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-28  8:50 [PATCH] " xinhui.pan
  2014-01-28 16:48 ` David Cohen
@ 2014-01-28 16:49 ` Felipe Balbi
  2014-01-28 17:24   ` David Cohen
  1 sibling, 1 reply; 15+ messages in thread
From: Felipe Balbi @ 2014-01-28 16:49 UTC (permalink / raw)
  To: xinhui.pan
  Cc: linux-kernel, linux-gpio, david.a.cohen, linus.walleij, gnurou,
	yanmin_zhang

[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]

On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> From: "xinhui.pan" <xinhuiX.pan@intel.com>
> 
> intel_gpio_runtime_idle should return correct error code if it do fail.
> make it more correct even though -EBUSY is the most possible return value.
> 
> Signed-off-by: bo.he <bo.he@intel.com>
> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
> ---
>  drivers/gpio/gpio-intel-mid.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
> index d1b50ef..05749a3 100644
> --- a/drivers/gpio/gpio-intel-mid.c
> +++ b/drivers/gpio/gpio-intel-mid.c
> @@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
>  
>  static int intel_gpio_runtime_idle(struct device *dev)
>  {
> -	pm_schedule_suspend(dev, 500);
> +	int err = pm_schedule_suspend(dev, 500);
> +	if (err)
> +		return err;
>  	return -EBUSY;

wait, is it only me or this would look a lot better as:

static int intel_gpio_runtime_idle(struct device *dev)
{
	return pm_schedule_suspend(dev, 500);
}

cheers

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
  2014-01-28  8:50 [PATCH] " xinhui.pan
@ 2014-01-28 16:48 ` David Cohen
  2014-01-28 16:49 ` Felipe Balbi
  1 sibling, 0 replies; 15+ messages in thread
From: David Cohen @ 2014-01-28 16:48 UTC (permalink / raw)
  To: xinhui.pan; +Cc: linux-kernel, linux-gpio, linus.walleij, gnurou, yanmin_zhang

Hi,

Thanks for the patch :)

On Tue, Jan 28, 2014 at 04:50:57PM +0800, xinhui.pan wrote:
> From: "xinhui.pan" <xinhuiX.pan@intel.com>
> 
> intel_gpio_runtime_idle should return correct error code if it do fail.
> make it more correct even though -EBUSY is the most possible return value.
> 
> Signed-off-by: bo.he <bo.he@intel.com>
> Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>

Acked-by: David Cohen <david.a.cohen@linux.intel.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH] gpio-intel-mid: fix the incorrect return of idle callback
@ 2014-01-28  8:50 xinhui.pan
  2014-01-28 16:48 ` David Cohen
  2014-01-28 16:49 ` Felipe Balbi
  0 siblings, 2 replies; 15+ messages in thread
From: xinhui.pan @ 2014-01-28  8:50 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-gpio, david.a.cohen, linus.walleij, gnurou, yanmin_zhang

From: "xinhui.pan" <xinhuiX.pan@intel.com>

intel_gpio_runtime_idle should return correct error code if it do fail.
make it more correct even though -EBUSY is the most possible return value.

Signed-off-by: bo.he <bo.he@intel.com>
Signed-off-by: xinhui.pan <xinhuiX.pan@intel.com>
---
 drivers/gpio/gpio-intel-mid.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-intel-mid.c b/drivers/gpio/gpio-intel-mid.c
index d1b50ef..05749a3 100644
--- a/drivers/gpio/gpio-intel-mid.c
+++ b/drivers/gpio/gpio-intel-mid.c
@@ -394,7 +394,9 @@ static const struct irq_domain_ops intel_gpio_irq_ops = {
 
 static int intel_gpio_runtime_idle(struct device *dev)
 {
-	pm_schedule_suspend(dev, 500);
+	int err = pm_schedule_suspend(dev, 500);
+	if (err)
+		return err;
 	return -EBUSY;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-02-05  9:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-30 12:15 [PATCH] gpio-intel-mid: fix the incorrect return of idle callback xinhui.pan
2014-01-31 20:50 ` David Cohen
2014-01-31 21:08   ` [PATCH v2] " David Cohen
2014-01-31 21:26     ` Felipe Balbi
2014-02-05  9:37     ` Linus Walleij
  -- strict thread matches above, loose matches on Subject: below --
2014-01-28  8:50 [PATCH] " xinhui.pan
2014-01-28 16:48 ` David Cohen
2014-01-28 16:49 ` Felipe Balbi
2014-01-28 17:24   ` David Cohen
2014-01-28 18:12     ` Felipe Balbi
2014-01-29  0:13       ` David Cohen
2014-01-29  7:23         ` xinhui.pan
2014-01-29 19:12           ` David Cohen
2014-01-29 19:52             ` Felipe Balbi
2014-01-29 21:06               ` David Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).