Re: [PATCH v3 1/3] usb: udc: add usb_gadget_find_udc

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

 



On Mon, Jan 19, 2015 at 11:29:22AM -0500, Alan Stern wrote:
> On Mon, 19 Jan 2015, Peter Chen wrote:
> 
> > > > An idea just struck me...  Instead of looping through all the udc's to
> > > > find the right one, why not simply store a pointer to the udc in struct
> > > > usb_gadget?
> > > > 
> > 
> > We still have code to find usb_gadget_driver to iterate udc_list, it
> > is better to change all, we need to have solution to consolidate
> > struct usb_udc, struct usb_gadget, and struct usb_gadget_drver.
> > I have no good solution now.
> 
> I think it's okay to iterate through the list to find a 
> usb_gadget_driver.  But it's silly to iterate to find the usb_udc 
> corresponding to a usb_gadget.

Felipe, what's your opinion?

> 
> > > > Also, it looks like there's a bug in usb_add_gadget_udc_release() in 
> > > > udc-core.c.  The error pathway (between err3 and err2) does not undo 
> > > > the
> > > > 
> > > > 	ret = device_register(&gadget->dev);
> > > > 
> > > > call.  There's a put_device() call but no device_del().
> > > 
> > > good point :-) Do you want to send a patch for that ?
> > > 
> > 
> > It looks like there is another issue in error pathway, the
> > put_device(&udc->dev) at err3 should be moved to err4 since
> > the get_device is called at device_add.
> 
> No, the get_device is done by device_initialize, so the code is correct 
> as it stands.  See the kerneldoc for device_initialize() in 
> drivers/base/core.c.
> 
> Alan Stern
> 

Yes, you are right, just device_initialize calls kobject_init to
set refcount as 1, not call get_device directly.
-- 

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