Re: [PATCH 01/13] usb: gadget: introduce .connect gadget driver API

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

 



On Mon, Aug 18, 2014 at 10:27:36PM +0800, Alan Stern wrote:
> On Mon, 18 Aug 2014, Peter Chen wrote:
> 
> > We introduce the connect API at usb_gadget_driver, the udc driver
> > uses it to tell gadget driver that it is ready to CONNECT, and the
> > dp can be pulled up from now on.
> > 
> > Meanwhile, we introduce an API usb_udc_ready_to_connect to encapsulate
> > above operation.
> > 
> > Signed-off-by: Peter Chen <peter.chen@xxxxxxxxxxxxx>
> > ---
> >  include/linux/usb/gadget.h |   29 ++++++++++++++++++++++++++++-
> >  1 file changed, 28 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> > index c3a6185..385af59 100644
> > --- a/include/linux/usb/gadget.h
> > +++ b/include/linux/usb/gadget.h
> > @@ -873,12 +873,39 @@ struct usb_gadget_driver {
> >  	void			(*disconnect)(struct usb_gadget *);
> >  	void			(*suspend)(struct usb_gadget *);
> >  	void			(*resume)(struct usb_gadget *);
> > +	int			(*connect)(struct usb_gadget *, bool connect);
> >  
> >  	/* FIXME support safe rmmod */
> >  	struct device_driver	driver;
> >  };
> 
> This looks strange.  Why do you have the "bool connect" parameter?  

How can I tell the gadget driver to pull down dp after vbus is off?

> There's already a disconnect callback.

Maybe I need to use other name rather than connect, the .disconnect sometimes
is called at bus reset handler so I can't put dp control in it.
> Also, you forgot to update the kerneldoc.
> 

Will do.

> > -
> > +/**
> > + * usb_udc_ready_to_connect - The udc is ready to connect (physical pullup dp)
> > + * @driver: the gadget driver for this gadget
> > + * @gadget: the udc device
> > + * @connect: whether the udc is ready to connect or not
> > + *
> > + * The USB 2.0 spec 7.2.1 and 7.1.5 requires the dp should not be pulled up if
> > + * the vbus is not there, else it will fail Back-voltage Testing at below
> > + * USB-IF certification test.
> > + * www.usb.org/developers/docs/USB-IFTestProc1_3.pdf
> > + *
> > + * Some udcs have hardware logic that even the pullup bit is set by software,
> > + * it can still meet above Back-voltage Testing requirement, these kinds of
> > + * udcs only need to set connect as true at its .udc_start. But other udcs
> > + * may have no this capability, so they need the software pullup bit is not
> > + * set when the vbus is not there, otherwise it will break the spec, and can't
> > + * pass Back-voltage Testing. So they need to set connect as false when the
> > + * vbus is not there, and set connect as true when the vbus is there.
> > + */
> > +static inline int usb_udc_ready_to_connect(struct usb_gadget_driver *driver,
> > +		struct usb_gadget *gadget, bool connect)
> > +{
> > +	if (driver->connect)
> > +		return driver->connect(gadget, connect);
> > +	else
> > +		return -EOPNOTSUPP;
> > +}
> >  
> >  /*-------------------------------------------------------------------------*/
> 
> Again, the "connect" argument isn't needed.
> 


-- 
Best Regards,
Peter Chen
--
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