Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / watchdog / pcwd_usb.c
index cdfe0db..3fdfda9 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/completion.h>
 #include <asm/uaccess.h>
 #include <linux/usb.h>
+#include <linux/mutex.h>
 
 
 #ifdef CONFIG_USB_DEBUG
@@ -56,8 +57,8 @@
 
 
 /* Module and Version Information */
-#define DRIVER_VERSION "1.00"
-#define DRIVER_DATE "12 Jun 2004"
+#define DRIVER_VERSION "1.01"
+#define DRIVER_DATE "15 Mar 2005"
 #define DRIVER_AUTHOR "Wim Van Sebroeck <wim@iguana.be>"
 #define DRIVER_DESC "Berkshire USB-PC Watchdog driver"
 #define DRIVER_LICENSE "GPL"
@@ -79,12 +80,7 @@ static int heartbeat = WATCHDOG_HEARTBEAT;
 module_param(heartbeat, int, 0);
 MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
 
-#ifdef CONFIG_WATCHDOG_NOWAYOUT
-static int nowayout = 1;
-#else
-static int nowayout = 0;
-#endif
-
+static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
 
@@ -148,7 +144,7 @@ struct usb_pcwd_private {
 static struct usb_pcwd_private *usb_pcwd_device;
 
 /* prevent races between open() and disconnect() */
-static DECLARE_MUTEX (disconnect_sem);
+static DEFINE_MUTEX(disconnect_mutex);
 
 /* local function prototypes */
 static int usb_pcwd_probe      (struct usb_interface *interface, const struct usb_device_id *id);
@@ -156,7 +152,6 @@ static void usb_pcwd_disconnect     (struct usb_interface *interface);
 
 /* usb specific object needed to register this driver with the usb subsystem */
 static struct usb_driver usb_pcwd_driver = {
-       .owner =        THIS_MODULE,
        .name =         DRIVER_NAME,
        .probe =        usb_pcwd_probe,
        .disconnect =   usb_pcwd_disconnect,
@@ -227,7 +222,7 @@ static int usb_pcwd_send_command(struct usb_pcwd_private *usb_pcwd, unsigned cha
        if (usb_control_msg(usb_pcwd->udev, usb_sndctrlpipe(usb_pcwd->udev, 0),
                        HID_REQ_SET_REPORT, HID_DT_REPORT,
                        0x0200, usb_pcwd->interface_number, buf, sizeof(buf),
-                       HZ) != sizeof(buf)) {
+                       USB_COMMAND_TIMEOUT) != sizeof(buf)) {
                dbg("usb_pcwd_send_command: error in usb_control_msg for cmd 0x%x 0x%x 0x%x\n", cmd, *msb, *lsb);
        }
        /* wait till the usb card processed the command,
@@ -571,12 +566,6 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
        char fw_ver_str[20];
        unsigned char option_switches, dummy;
 
-       /* See if the device offered us matches what we can accept */
-       if ((udev->descriptor.idVendor != USB_PCWD_VENDOR_ID) ||
-           (udev->descriptor.idProduct != USB_PCWD_PRODUCT_ID)) {
-               return -ENODEV;
-       }
-
        cards_found++;
        if (cards_found > 1) {
                printk(KERN_ERR PFX "This driver only supports 1 device\n");
@@ -621,7 +610,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
        usb_pcwd->udev = udev;
        usb_pcwd->interface = interface;
        usb_pcwd->interface_number = iface_desc->desc.bInterfaceNumber;
-       usb_pcwd->intr_size = (endpoint->wMaxPacketSize > 8 ? endpoint->wMaxPacketSize : 8);
+       usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8);
 
        /* set up the memory buffer's */
        if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, SLAB_ATOMIC, &usb_pcwd->intr_dma))) {
@@ -716,7 +705,8 @@ err_out_misc_deregister:
 err_out_unregister_reboot:
        unregister_reboot_notifier(&usb_pcwd_notifier);
 error:
-       usb_pcwd_delete (usb_pcwd);
+       if (usb_pcwd)
+               usb_pcwd_delete(usb_pcwd);
        usb_pcwd_device = NULL;
        return retval;
 }
@@ -735,7 +725,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
        struct usb_pcwd_private *usb_pcwd;
 
        /* prevent races with open() */
-       down (&disconnect_sem);
+       mutex_lock(&disconnect_mutex);
 
        usb_pcwd = usb_get_intfdata (interface);
        usb_set_intfdata (interface, NULL);
@@ -761,7 +751,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
 
        cards_found--;
 
-       up (&disconnect_sem);
+       mutex_unlock(&disconnect_mutex);
 
        printk(KERN_INFO PFX "USB PC Watchdog disconnected\n");
 }