Re: [RFC/PATCH 2/8] usb: gadget: introduce UDC Class

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

 



Hi,

(and sorry for the huge delay)

On Mon, Oct 04, 2010 at 12:18:53PM -0500, Alan Stern wrote:
> On Mon, 4 Oct 2010, Felipe Balbi wrote:
> 
> > this class will be used to abstract away
> > several of the duplicated operations scatered
> > among the USB gadget controller drivers.
> > 
> > Later, we can add an atomic notifer to tell
> > interested drivers about what's happening
> > with the controller. Notifications such as
> > suspend, resume, enumerated, etc will be
> > useful, at a minimum, for implementing
> > usb charger detection.
> 
> Why is this implemented in terms of a udc class device?  Why not just
> associate the attributes with the controller device itself?  Is this
> for the uevents?

The idea is that I want a core device which will do the talking to the
underlying Hardware, instead of duplicating the code all over as it is
done today.

> > +/**
> > + * usb_add_udc - adds a new udc to the udc class driver list
> > + * @parent: the parent device to this udc. Usually the controller
> > + * driver's device.
> > + * @udc: the udc to be added to the list
> > + *
> > + * Returns zero on success, negative errno otherwise.
> > + */
> > +int usb_add_udc(struct device *parent, struct usb_udc *udc)
> > +{
> > +	struct device		*dev;
> > +	unsigned long		flags;
> > +	int			ret;
> > +
> > +	if (!udc->gadget || !udc->gadget->ops ||
> > +			!udc->gadget->ops->start) {
> > +		dev_dbg(parent, "unitializaed gadget\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	dev_vdbg(parent, "registering UDC\n");
> > +
> > +	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> > +	if (!dev) {
> > +		ret = -ENOMEM;
> > +		goto err1;
> > +	}
> > +
> > +	spin_lock_irqsave(&udc_lock, flags);
> > +
> > +	device_initialize(dev);
> > +
> > +	dev->class = udc_class;
> > +	dev->type = &udc_device_type;
> > +	dev->parent = parent;
> > +	dev->release = usb_udc_release;
> > +	dev_set_drvdata(dev, udc);
> > +	udc->dev = dev;
> > +	udc->gadget->dev.parent = udc->dev;
> > +	udc->gadget->dev.release = usb_udc_nop_release;
> 
> This causes problems with dummy-hcd.  It actually needs to do something 
> when the gadget device is released.
> 
> Why not embed the gadget and the device node directly in the usb_udc 
> structure, instead of just putting pointers there?

I'll do that now. Thanks.

-- 
balbi
--
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