USB: refactor usb device matching and create usb_device_match
[deliverable/linux.git] / drivers / usb / core / usb.h
index 1d25ccac783276f47fe7b9b26dd3025f356d1b70..86692a23573ff4da1fce5860e5d75d674e073672 100644 (file)
@@ -1,10 +1,10 @@
 /* Functions local to drivers/usb/core/ */
 
-extern void usb_create_sysfs_dev_files (struct usb_device *dev);
+extern int usb_create_sysfs_dev_files (struct usb_device *dev);
 extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
-extern void usb_create_sysfs_intf_files (struct usb_interface *intf);
+extern int usb_create_sysfs_intf_files (struct usb_interface *intf);
 extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
-extern void usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
+extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
                                struct usb_device *udev);
 extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);
 
@@ -20,8 +20,9 @@ extern char *usb_cache_string(struct usb_device *udev, int index);
 extern int usb_set_configuration(struct usb_device *dev, int configuration);
 
 extern void usb_kick_khubd(struct usb_device *dev);
-extern void usb_suspend_root_hub(struct usb_device *hdev);
 extern void usb_resume_root_hub(struct usb_device *dev);
+extern int usb_match_device(struct usb_device *dev,
+                           const struct usb_device_id *id);
 
 extern int  usb_hub_init(void);
 extern void usb_hub_cleanup(void);
@@ -30,9 +31,55 @@ extern void usb_major_cleanup(void);
 extern int usb_host_init(void);
 extern void usb_host_cleanup(void);
 
+#ifdef CONFIG_PM
+
+extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg);
+extern int usb_resume_both(struct usb_device *udev);
 extern int usb_port_suspend(struct usb_device *dev);
 extern int usb_port_resume(struct usb_device *dev);
 
+static inline void usb_pm_lock(struct usb_device *udev)
+{
+       mutex_lock_nested(&udev->pm_mutex, udev->level);
+}
+
+static inline void usb_pm_unlock(struct usb_device *udev)
+{
+       mutex_unlock(&udev->pm_mutex);
+}
+
+#else
+
+#define usb_suspend_both(udev, msg)    0
+static inline int usb_resume_both(struct usb_device *udev)
+{
+       return 0;
+}
+#define usb_port_suspend(dev)          0
+#define usb_port_resume(dev)           0
+static inline void usb_pm_lock(struct usb_device *udev) {}
+static inline void usb_pm_unlock(struct usb_device *udev) {}
+
+#endif
+
+#ifdef CONFIG_USB_SUSPEND
+
+#define USB_AUTOSUSPEND_DELAY  (HZ*2)
+
+extern void usb_autosuspend_device(struct usb_device *udev);
+extern int usb_autoresume_device(struct usb_device *udev);
+
+#else
+
+#define usb_autosuspend_device(udev)   do {} while (0)
+static inline int usb_autoresume_device(struct usb_device *udev)
+{
+       return 0;
+}
+
+#endif
+
+extern struct workqueue_struct *ksuspend_usb_wq;
 extern struct bus_type usb_bus_type;
 extern struct usb_device_driver usb_generic_driver;
 
@@ -40,7 +87,7 @@ extern struct usb_device_driver usb_generic_driver;
  * no such thing as a platform USB device, so we can steal the use
  * of the platform_data field. */
 
-static inline int is_usb_device(struct device *dev)
+static inline int is_usb_device(const struct device *dev)
 {
        return dev->platform_data == &usb_generic_driver;
 }
@@ -57,17 +104,17 @@ static inline int is_usb_device_driver(struct device_driver *drv)
 
 static inline void mark_active(struct usb_interface *f)
 {
-       f->dev.power.power_state.event = PM_EVENT_ON;
+       f->is_active = 1;
 }
 
 static inline void mark_quiesced(struct usb_interface *f)
 {
-       f->dev.power.power_state.event = PM_EVENT_FREEZE;
+       f->is_active = 0;
 }
 
-static inline int is_active(struct usb_interface *f)
+static inline int is_active(const struct usb_interface *f)
 {
-       return f->dev.power.power_state.event == PM_EVENT_ON;
+       return f->is_active;
 }
 
 
@@ -77,8 +124,8 @@ extern const char *usbcore_name;
 /* usbfs stuff */
 extern struct mutex usbfs_mutex;
 extern struct usb_driver usbfs_driver;
-extern struct file_operations usbfs_devices_fops;
-extern struct file_operations usbfs_device_file_operations;
+extern const struct file_operations usbfs_devices_fops;
+extern const struct file_operations usbfs_device_file_operations;
 extern void usbfs_conn_disc_event(void);
 
 extern int usbdev_init(void);
@@ -93,7 +140,7 @@ struct dev_state {
        struct list_head async_completed;
        wait_queue_head_t wait;     /* wake up if a request completed */
        unsigned int discsignr;
-       pid_t disc_pid;
+       struct pid *disc_pid;
        uid_t disc_uid, disc_euid;
        void __user *disccontext;
        unsigned long ifclaimed;
This page took 0.025681 seconds and 5 git commands to generate.