]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/hid/usbhid/hid-core.c
USB: remove warn macro from HID core
[linux-2.6-omap-h63xx.git] / drivers / hid / usbhid / hid-core.c
index e900d597bc2d6e82802732c1ef663d7da3b69135..705a43cdeea4251d89b8585f37b4c098cc4fe1b7 100644 (file)
@@ -44,8 +44,6 @@
 #define DRIVER_DESC "USB HID core driver"
 #define DRIVER_LICENSE "GPL"
 
-static char *hid_types[] = {"Device", "Pointer", "Mouse", "Device", "Joystick",
-                               "Gamepad", "Keyboard", "Keypad", "Multi-Axis Controller"};
 /*
  * Module parameters.
  */
@@ -215,7 +213,8 @@ static void hid_irq_in(struct urb *urb)
                hid_io_error(hid);
                return;
        default:                /* error */
-               warn("input irq status %d received", urb->status);
+               dev_warn(&urb->dev->dev, "input irq status %d  "
+                               "received\n", urb->status);
        }
 
        status = usb_submit_urb(urb, GFP_ATOMIC);
@@ -234,13 +233,16 @@ static void hid_irq_in(struct urb *urb)
 static int hid_submit_out(struct hid_device *hid)
 {
        struct hid_report *report;
+       char *raw_report;
        struct usbhid_device *usbhid = hid->driver_data;
 
-       report = usbhid->out[usbhid->outtail];
+       report = usbhid->out[usbhid->outtail].report;
+       raw_report = usbhid->out[usbhid->outtail].raw_report;
 
-       hid_output_report(report, usbhid->outbuf);
        usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0);
        usbhid->urbout->dev = hid_to_usb_dev(hid);
+       memcpy(usbhid->outbuf, raw_report, usbhid->urbout->transfer_buffer_length);
+       kfree(raw_report);
 
        dbg_hid("submitting out urb\n");
 
@@ -256,17 +258,20 @@ static int hid_submit_ctrl(struct hid_device *hid)
 {
        struct hid_report *report;
        unsigned char dir;
+       char *raw_report;
        int len;
        struct usbhid_device *usbhid = hid->driver_data;
 
        report = usbhid->ctrl[usbhid->ctrltail].report;
+       raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report;
        dir = usbhid->ctrl[usbhid->ctrltail].dir;
 
        len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
        if (dir == USB_DIR_OUT) {
-               hid_output_report(report, usbhid->ctrlbuf);
                usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0);
                usbhid->urbctrl->transfer_buffer_length = len;
+               memcpy(usbhid->ctrlbuf, raw_report, len);
+               kfree(raw_report);
        } else {
                int maxpacket, padlen;
 
@@ -323,7 +328,8 @@ static void hid_irq_out(struct urb *urb)
        case -ENOENT:
                break;
        default:                /* error */
-               warn("output irq status %d received", urb->status);
+               dev_warn(&urb->dev->dev, "output irq status %d "
+                               "received\n", urb->status);
        }
 
        spin_lock_irqsave(&usbhid->outlock, flags);
@@ -376,7 +382,8 @@ static void hid_ctrl(struct urb *urb)
        case -EPIPE:            /* report not available */
                break;
        default:                /* error */
-               warn("ctrl urb status %d received", urb->status);
+               dev_warn(&urb->dev->dev, "ctrl urb status %d "
+                               "received\n", urb->status);
        }
 
        if (unplug)
@@ -403,6 +410,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
        int head;
        unsigned long flags;
        struct usbhid_device *usbhid = hid->driver_data;
+       int len = ((report->size - 1) >> 3) + 1 + (report->id > 0);
 
        if ((hid->quirks & HID_QUIRK_NOGET) && dir == USB_DIR_IN)
                return;
@@ -413,11 +421,18 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
 
                if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) {
                        spin_unlock_irqrestore(&usbhid->outlock, flags);
-                       warn("output queue full");
+                       dev_warn(&hid->dev, "output queue full\n");
                        return;
                }
 
-               usbhid->out[usbhid->outhead] = report;
+               usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC);
+               if (!usbhid->out[usbhid->outhead].raw_report) {
+                       spin_unlock_irqrestore(&usbhid->outlock, flags);
+                       dev_warn(&hid->dev, "output queueing failed\n");
+                       return;
+               }
+               hid_output_report(report, usbhid->out[usbhid->outhead].raw_report);
+               usbhid->out[usbhid->outhead].report = report;
                usbhid->outhead = head;
 
                if (!test_and_set_bit(HID_OUT_RUNNING, &usbhid->iofl))
@@ -432,10 +447,19 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
 
        if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) {
                spin_unlock_irqrestore(&usbhid->ctrllock, flags);
-               warn("control queue full");
+               dev_warn(&hid->dev, "control queue full\n");
                return;
        }
 
+       if (dir == USB_DIR_OUT) {
+               usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC);
+               if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) {
+                       spin_unlock_irqrestore(&usbhid->ctrllock, flags);
+                       dev_warn(&hid->dev, "control queueing failed\n");
+                       return;
+               }
+               hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report);
+       }
        usbhid->ctrl[usbhid->ctrlhead].report = report;
        usbhid->ctrl[usbhid->ctrlhead].dir = dir;
        usbhid->ctrlhead = head;
@@ -446,6 +470,7 @@ void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, uns
 
        spin_unlock_irqrestore(&usbhid->ctrllock, flags);
 }
+EXPORT_SYMBOL_GPL(usbhid_submit_report);
 
 static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
 {
@@ -460,7 +485,7 @@ static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, un
                return -1;
 
        if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) {
-               warn("event field not found");
+               dev_warn(&dev->dev, "event field not found\n");
                return -1;
        }
 
@@ -563,7 +588,7 @@ void usbhid_init_reports(struct hid_device *hid)
        }
 
        if (err)
-               warn("timeout initializing reports");
+               dev_warn(&hid->dev, "timeout initializing reports\n");
 }
 
 /*
@@ -593,7 +618,7 @@ static int hid_find_field_early(struct hid_device *hid, unsigned int page,
        return -1;
 }
 
-static void usbhid_set_leds(struct hid_device *hid)
+void usbhid_set_leds(struct hid_device *hid)
 {
        struct hid_field *field;
        int offset;
@@ -603,6 +628,7 @@ static void usbhid_set_leds(struct hid_device *hid)
                usbhid_submit_report(hid, field->report, USB_DIR_OUT);
        }
 }
+EXPORT_SYMBOL_GPL(usbhid_set_leds);
 
 /*
  * Traverse the supplied list of reports and find the longest
@@ -670,100 +696,6 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
        usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
 }
 
-/*
- * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
- * to "operational".  Without this, the ps3 controller will not report any
- * events.
- */
-static void hid_fixup_sony_ps3_controller(struct usb_device *dev, int ifnum)
-{
-       int result;
-       char *buf = kmalloc(18, GFP_KERNEL);
-
-       if (!buf)
-               return;
-
-       result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
-                                HID_REQ_GET_REPORT,
-                                USB_DIR_IN | USB_TYPE_CLASS |
-                                USB_RECIP_INTERFACE,
-                                (3 << 8) | 0xf2, ifnum, buf, 17,
-                                USB_CTRL_GET_TIMEOUT);
-
-       if (result < 0)
-               err_hid("%s failed: %d\n", __func__, result);
-
-       kfree(buf);
-}
-
-static int usbhid_start_finish(struct hid_device *hid)
-{
-       struct usb_interface *intf = to_usb_interface(hid->dev.parent);
-       char path[64], *type;
-       unsigned int i;
-
-       usbhid_init_reports(hid);
-       hid_dump_device(hid);
-       if (hid->quirks & HID_QUIRK_RESET_LEDS)
-               usbhid_set_leds(hid);
-
-       if (!hidinput_connect(hid))
-               hid->claimed |= HID_CLAIMED_INPUT;
-       if (!hiddev_connect(hid))
-               hid->claimed |= HID_CLAIMED_HIDDEV;
-       if (!hidraw_connect(hid))
-               hid->claimed |= HID_CLAIMED_HIDRAW;
-
-       if (!hid->claimed) {
-               printk(KERN_ERR "HID device claimed by neither input, hiddev "
-                               "nor hidraw\n");
-               return -ENODEV;
-       }
-
-       if ((hid->claimed & HID_CLAIMED_INPUT))
-               hid_ff_init(hid);
-
-       if (hid->quirks & HID_QUIRK_SONY_PS3_CONTROLLER)
-               hid_fixup_sony_ps3_controller(interface_to_usbdev(intf),
-                       intf->cur_altsetting->desc.bInterfaceNumber);
-
-       printk(KERN_INFO);
-
-       if (hid->claimed & HID_CLAIMED_INPUT)
-               printk("input");
-       if ((hid->claimed & HID_CLAIMED_INPUT) &&
-                       ((hid->claimed & HID_CLAIMED_HIDDEV) ||
-                               hid->claimed & HID_CLAIMED_HIDRAW))
-               printk(",");
-       if (hid->claimed & HID_CLAIMED_HIDDEV)
-               printk("hiddev%d", hid->minor);
-       if ((hid->claimed & HID_CLAIMED_INPUT) &&
-                       (hid->claimed & HID_CLAIMED_HIDDEV) &&
-                       (hid->claimed & HID_CLAIMED_HIDRAW))
-               printk(",");
-       if (hid->claimed & HID_CLAIMED_HIDRAW)
-               printk("hidraw%d", ((struct hidraw *)hid->hidraw)->minor);
-
-       type = "Device";
-       for (i = 0; i < hid->maxcollection; i++) {
-               if (hid->collection[i].type == HID_COLLECTION_APPLICATION &&
-                   (hid->collection[i].usage & HID_USAGE_PAGE) ==
-                                               HID_UP_GENDESK &&
-                   (hid->collection[i].usage & 0xffff) <
-                                               ARRAY_SIZE(hid_types)) {
-                       type = hid_types[hid->collection[i].usage & 0xffff];
-                       break;
-               }
-       }
-
-       usb_make_path(interface_to_usbdev(intf), path, 63);
-
-       printk(": USB HID v%x.%02x %s [%s] on %s\n",
-               hid->version >> 8, hid->version & 0xff, type, hid->name, path);
-
-       return 0;
-}
-
 static int usbhid_parse(struct hid_device *hid)
 {
        struct usb_interface *intf = to_usb_interface(hid->dev.parent);
@@ -953,9 +885,8 @@ static int usbhid_start(struct hid_device *hid)
        usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
        usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
 
-       ret = usbhid_start_finish(hid);
-       if (ret)
-               goto fail;
+       usbhid_init_reports(hid);
+       hid_dump_device(hid);
 
        return 0;
 
@@ -1030,7 +961,9 @@ static int hid_probe(struct usb_interface *intf, const struct usb_device_id *id)
        usb_set_intfdata(intf, hid);
        hid->ll_driver = &usb_hid_driver;
        hid->hid_output_raw_report = usbhid_output_raw_report;
+       hid->ff_init = hid_pidff_init;
 #ifdef CONFIG_USB_HIDDEV
+       hid->hiddev_connect = hiddev_connect;
        hid->hiddev_hid_event = hiddev_hid_event;
        hid->hiddev_report_event = hiddev_report_event;
 #endif
@@ -1179,7 +1112,8 @@ static int __init hid_init(void)
        retval = usb_register(&hid_driver);
        if (retval)
                goto usb_register_fail;
-       info(DRIVER_VERSION ":" DRIVER_DESC);
+       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
+                       DRIVER_DESC "\n");
 
        return 0;
 usb_register_fail: