Re: File-Storage Gadget Eject/"Safely Remove" Detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 9 Jul 2010, Patrick Gitchell wrote:

> Hello,
> 
> I'm looking into having events occur in an embedded device when A) It
> connects to a host using the File Storage gadget and B) It is ejected
> by that host.  Part A is pretty straightforward, however, I'm having
> issues with part B...
> 
> The problem is, Windows seems to treat the event differently than
> Linux, as Linux sends a SCSI STOP command to the device, whereas
> Windows sends a USB Suspend.

That doesn't sound right at all.  Are you sure you haven't confused 
"ejecting" a device and "removing" a device?  These are two distinct 
actions.

> From what I can tell, this USB Suspend isn't passed up to the gadget
> layer,

Yes it is.  The usb_gadget_driver structure has suspend and resume 
callbacks, which the device controller driver should invoke.  If this 
doesn't happen, it's a bug in the controller driver.

> making it a pain to see when the device has been 'stopped'.  My
> current plan is to have two places where this is monitored, both
> exposed as sysfs entries.  One in musb-core.c, and one in
> file-storage.c, which will both need to be checked to see if the
> device has been ejected.
> 
> As you can see, this solution is rather dissatisfying.  My question is
> this: does anyone have a better solution?  Is there already some way
> that the File-Storage gadget can know it's been suspended?

See the fsg_suspend() and fsg_resume() routines in file_storage.c.  At 
the moment they don't do much, but you can always change them.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux