mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Check if usb device is suspended
@ 2014-03-13 11:43 Jagdish Gedia
  2014-03-13 13:05 ` Oliver Neukum
  2014-03-13 14:20 ` Alan Stern
  0 siblings, 2 replies; 5+ messages in thread
From: Jagdish Gedia @ 2014-03-13 11:43 UTC (permalink / raw)
  To: linux-usb; +Cc: linux-kernel

Hi,
I want to check in my driver if usb device is suspended or not?
currently i am doing it like

if(udev->state==USB_STATE_SUSPENDED)

Is this the proper way? Is this enough?










Thanks,
Jagdish Gediya

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

* Re: Check if usb device is suspended
  2014-03-13 11:43 Check if usb device is suspended Jagdish Gedia
@ 2014-03-13 13:05 ` Oliver Neukum
  2014-03-13 14:20 ` Alan Stern
  1 sibling, 0 replies; 5+ messages in thread
From: Oliver Neukum @ 2014-03-13 13:05 UTC (permalink / raw)
  To: Jagdish Gedia; +Cc: linux-usb, linux-kernel

On Thu, 2014-03-13 at 17:13 +0530, Jagdish Gedia wrote:
> Hi,
> I want to check in my driver if usb device is suspended or not?
> currently i am doing it like
> 
> if(udev->state==USB_STATE_SUSPENDED)
> 
> Is this the proper way? Is this enough?

This question is near meaningless. Assuming that you
don't check for fun, but want to act on the state,
the meaningful question would be how you know that
a device is still suspended (or not) while you perform
the actions you base on that information.

	Regards
		Oliver



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

* Re: Check if usb device is suspended
  2014-03-13 11:43 Check if usb device is suspended Jagdish Gedia
  2014-03-13 13:05 ` Oliver Neukum
@ 2014-03-13 14:20 ` Alan Stern
  2014-03-21 11:47   ` Jagdish Gedia
  1 sibling, 1 reply; 5+ messages in thread
From: Alan Stern @ 2014-03-13 14:20 UTC (permalink / raw)
  To: Jagdish Gedia; +Cc: linux-usb, linux-kernel

On Thu, 13 Mar 2014, Jagdish Gedia wrote:

> Hi,
> I want to check in my driver if usb device is suspended or not?

Why do you need to check?  Your driver gets told every time the device 
suspends and every time it resumes.  Therefore it should already know 
the answer.

> currently i am doing it like
> 
> if(udev->state==USB_STATE_SUSPENDED)
> 
> Is this the proper way? Is this enough?

Aside from the fact that the device's state may change immediately 
after you make this test, as Oliver pointed out, you also should 
realize that this test might not give the correct answer if the device 
is in the middle of suspending or resuming when the test runs.

Alan Stern


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

* Re: Check if usb device is suspended
  2014-03-13 14:20 ` Alan Stern
@ 2014-03-21 11:47   ` Jagdish Gedia
  2014-03-21 13:22     ` Oliver Neukum
  0 siblings, 1 reply; 5+ messages in thread
From: Jagdish Gedia @ 2014-03-21 11:47 UTC (permalink / raw)
  To: Alan Stern, oneukum; +Cc: linux-usb, linux-kernel

I want to resume the usb device on some event, so i want to check if
it is suspended. I think by above method i can check if the device is
already suspended, but may be i will miss to resume the device if it
is suspending. Is there any way through which i can check if device is
suspending?

On Thu, Mar 13, 2014 at 7:50 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Thu, 13 Mar 2014, Jagdish Gedia wrote:
>
>> Hi,
>> I want to check in my driver if usb device is suspended or not?
>
> Why do you need to check?  Your driver gets told every time the device
> suspends and every time it resumes.  Therefore it should already know
> the answer.
>
>> currently i am doing it like
>>
>> if(udev->state==USB_STATE_SUSPENDED)
>>
>> Is this the proper way? Is this enough?
>
> Aside from the fact that the device's state may change immediately
> after you make this test, as Oliver pointed out, you also should
> realize that this test might not give the correct answer if the device
> is in the middle of suspending or resuming when the test runs.
>
> Alan Stern
>

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

* Re: Check if usb device is suspended
  2014-03-21 11:47   ` Jagdish Gedia
@ 2014-03-21 13:22     ` Oliver Neukum
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Neukum @ 2014-03-21 13:22 UTC (permalink / raw)
  To: Jagdish Gedia; +Cc: Alan Stern, linux-usb, linux-kernel

On Fri, 2014-03-21 at 17:17 +0530, Jagdish Gedia wrote:
> I want to resume the usb device on some event, so i want to check if
> it is suspended. I think by above method i can check if the device is
> already suspended, but may be i will miss to resume the device if it
> is suspending. Is there any way through which i can check if device is
> suspending?

Just don't do that. If a device needs to be awake for some operation,
call usb_autopm_get(). If the device is already awake, it is a nop
besides keeping the device awake.
Checking is not a sensible strategy.

	Regards
		Oliver



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

end of thread, other threads:[~2014-03-21 13:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-13 11:43 Check if usb device is suspended Jagdish Gedia
2014-03-13 13:05 ` Oliver Neukum
2014-03-13 14:20 ` Alan Stern
2014-03-21 11:47   ` Jagdish Gedia
2014-03-21 13:22     ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®