From 0b2800e8c7fd86744aecdb9db4096427ad9b8bf9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 22 Aug 2003 01:53:08 -0700 Subject: [PATCH] V4L: add video_device_remove_file() to match video_device_create_file() --- include/linux/videodev.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/linux/videodev.h b/include/linux/videodev.h index 9e7dacaff115..8abbd9e9e596 100644 --- a/include/linux/videodev.h +++ b/include/linux/videodev.h @@ -63,6 +63,12 @@ video_device_create_file(struct video_device *vfd, { class_device_create_file(&vfd->class_dev, attr); } +static inline void +video_device_remove_file(struct video_device *vfd, + struct class_device_attribute *attr) +{ + class_device_remove_file(&vfd->class_dev, attr); +} /* helper functions to alloc / release struct video_device, the later can be used for video_device->release() */ -- cgit v1.2.3 From 0d2cc6b71ce235992cba24def6be9c590798e3be Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 27 Aug 2003 01:02:13 -0700 Subject: [PATCH] USB: minor doc updates Small kerneldoc clarifications: - more endpoint halt clearing info: * some hardware can't do it; which causes problems with drivers that want to use multiple interfaces or altsettings. * it doesn't affect queuing of data (should help usb-storage gadget driver, plus it's more sensible this way); - disconnect() callback not guaranteed: some hardware can't tell Mostly this captures answers to questions I've been asked. --- include/linux/usb_gadget.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/linux/usb_gadget.h b/include/linux/usb_gadget.h index a603cbde201e..c98a95dbe250 100644 --- a/include/linux/usb_gadget.h +++ b/include/linux/usb_gadget.h @@ -313,8 +313,8 @@ usb_ep_free_buffer (struct usb_ep *ep, void *buf, dma_addr_t dma, unsigned len) * arranges to poll once per interval, and the gadget driver usually will * have queued some data to transfer at that time. * - * Returns zero, or a negative error code. Endpoints that are not enabled, - * or which are enabled but halted, report errors; errors will also be + * Returns zero, or a negative error code. Endpoints that are not enabled + * report errors; errors will also be * reported when the usb peripheral is disconnected. */ static inline int @@ -352,6 +352,11 @@ static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req) * clears this feature; drivers may need to empty the endpoint's request * queue first, to make sure no inappropriate transfers happen. * + * Note that while an endpoint CLEAR_FEATURE will be invisible to the + * gadget driver, a SET_INTERFACE will not be. To reset endpoints for the + * current altsetting, see usb_ep_clear_halt(). When switching altsettings, + * it's simplest to use usb_ep_enable() or usb_ep_disable() for the endpoints. + * * Returns zero, or a negative error code. On success, this call sets * underlying hardware state that blocks data transfers. */ @@ -365,12 +370,14 @@ usb_ep_set_halt (struct usb_ep *ep) * usb_ep_clear_halt - clears endpoint halt, and resets toggle * @ep:the bulk or interrupt endpoint being reset * - * use this when responding to the standard usb "set interface" request, + * Use this when responding to the standard usb "set interface" request, * for endpoints that aren't reconfigured, after clearing any other state * in the endpoint's i/o queue. * - * returns zero, or a negative error code. on success, this call clears + * Returns zero, or a negative error code. On success, this call clears * the underlying hardware state reflecting endpoint halt and data toggle. + * Note that some hardware can't support this request (like pxa2xx_udc), + * and accordingly can't correctly implement interface altsettings. */ static inline int usb_ep_clear_halt (struct usb_ep *ep) @@ -562,7 +569,8 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget) * queues a response to ep0, or returns negative to stall. * @disconnect: Invoked after all transfers have been stopped, * when the host is disconnected. May be called in_interrupt; this - * may not sleep. + * may not sleep. Some devices can't detect disconnect, so this might + * not be called except as part of controller shutdown. * @unbind: Invoked when the driver is unbound from a gadget, * usually from rmmod (after a disconnect is reported). * Called in a context that permits sleeping. @@ -603,7 +611,9 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget) * not provide those callbacks. However, some may need to change modes * when the host is not longer directing those activities. For example, * local controls (buttons, dials, etc) may need to be re-enabled since - * the (remote) host can't do that any longer. + * the (remote) host can't do that any longer; or an error state might + * be cleared, to make the device behave identically whether or not + * power is maintained. */ struct usb_gadget_driver { char *function; -- cgit v1.2.3 From 19784c754ca66ebe8f6c39615b6e8de672d3806b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 27 Aug 2003 03:04:48 -0700 Subject: [PATCH] USB: hook up the USB driver core to the power management calls of the driver model. Now it's up to the individual USB drivers to implement suspend() and resume() if they want to. --- drivers/usb/core/usb.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/usb.h | 5 +++++ 2 files changed, 40 insertions(+) (limited to 'include') diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index b6e2dae1a48c..266bcfaf9fd7 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -1417,11 +1417,46 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } +static int usb_device_suspend(struct device *dev, u32 state) +{ + struct usb_interface *intf; + struct usb_driver *driver; + + if ((dev->driver == &usb_generic_driver) || + (dev->driver_data == &usb_generic_driver_data)) + return 0; + + intf = to_usb_interface(dev); + driver = to_usb_driver(dev->driver); + + if (driver && driver->suspend) + return driver->suspend(intf, state); + return 0; +} + +static int usb_device_resume(struct device *dev) +{ + struct usb_interface *intf; + struct usb_driver *driver; + + if ((dev->driver == &usb_generic_driver) || + (dev->driver_data == &usb_generic_driver_data)) + return 0; + + intf = to_usb_interface(dev); + driver = to_usb_driver(dev->driver); + + if (driver && driver->resume) + return driver->resume(intf); + return 0; +} struct bus_type usb_bus_type = { .name = "usb", .match = usb_device_match, .hotplug = usb_hotplug, + .suspend = usb_device_suspend, + .resume = usb_device_resume, }; #ifndef MODULE diff --git a/include/linux/usb.h b/include/linux/usb.h index df3ba0f3b90e..471c37f5188b 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -410,6 +410,8 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size) * the "usbfs" filesystem. This lets devices provide ways to * expose information to user space regardless of where they * do (or don't) show up otherwise in the filesystem. + * @suspend: Called when the device is going to be suspended by the system. + * @resume: Called when the device is being resumed by the system. * @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. @@ -445,6 +447,9 @@ struct usb_driver { int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); + int (*suspend) (struct usb_interface *intf, u32 state); + int (*resume) (struct usb_interface *intf); + const struct usb_device_id *id_table; struct device_driver driver; -- cgit v1.2.3