Re: [RFC/PATCH 1/2] usb: gadget: introduce gadget status tracking

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

 



On Wed, 21 Dec 2011, Peter Chen wrote:

> On Mon, Dec 19, 2011 at 10:35:22AM -0500, Alan Stern wrote:
> > On Mon, 19 Dec 2011, Felipe Balbi wrote:
> > 
> > > that's useful information to expose to userland.
> > > 
> > > NYET-Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> > 
> > > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> > > index 7d64f89..6aa9fc2 100644
> > > --- a/include/linux/usb/gadget.h
> > > +++ b/include/linux/usb/gadget.h
> > > @@ -478,6 +478,53 @@ struct usb_gadget_ops {
> > >  	int	(*stop)(struct usb_gadget_driver *);
> > >  };
> > >  
> > > +enum usb_device_status {
> > > +	USB_STATUS_IDLE,
> > 
> > IDLE is not the best name.  It suggests the gadget isn't doing
> > anything, whereas in fact it's supposed to mean the gadget isn't
> > getting any bus power.  How about USB_STATUS_NOTATTACHED instead?
> > 
> Yes, USB_STATUS_NOTATTACHED seems better. But how this usb_device_status
> live with enum usb_device_status at ch9.h? How about re-use the one
> at ch9.h, and at some status if necessaries?

The enumeration in ch9.h is usb_device_state, not usb_device_status.  
I imagine Felipe was very careful to choose a different name.

I'm not sure whether we should reuse the values.  The ones in ch9.h
refer to the host's view of the device's state, whereas the new ones
refer to the device's own view.  However, perhaps they will turn out to
be sufficiently similar that we can reuse them.

> > > +	USB_STATUS_CONNECTED,
> > > +	USB_STATUS_RESETTING,
> > > +
> > > +	USB_STATUS_DEFAULT,
> > > +	USB_STATUS_ADDRESSED,
> > > +	USB_STATUS_UNCONFIGURED,
> > > +	USB_STATUS_CONFIGURED,
> > 
> > As pointed out earlier, there is no difference between ADDRESSED and 
> > UNCONFIGURED.
> > 
> > Furthermore, UDC drivers don't know whether the gadget is configured or 
> > not.  This means gadget drivers would have to make the call to set the 
> > status to or from CONFIGURED, which is awkward.
> at udc driver, is it ok we use below to set CONFIGURED status.
> if (udc->driver->setup(&udc->gadget, setup_packet_buff) >= 0)
> 	if (setup->bRequest == USB_REQ_SET_CONFIGURATION)
> 		usb_gadget_set_status(&udc->gadget, USB_STATUS_CONFIGURED);

That's a reasonable approach.  But you also have to look inside the
setup packet, because if the new bConfigurationValue is 0 then the new
status should be USB_STATUS_ADDRESSED.

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