]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/host/r8a66597-hcd.c
USB: use DIV_ROUND_UP
[linux-2.6-omap-h63xx.git] / drivers / usb / host / r8a66597-hcd.c
index fd00f1e33fb53a77647c37e8646218313388e6c9..afd4fbe7713cf71c2631c76469e35f697d3a9575 100644 (file)
@@ -44,6 +44,7 @@
 MODULE_DESCRIPTION("R8A66597 USB Host Controller Driver");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Yoshihiro Shimoda");
+MODULE_ALIAS("platform:r8a66597_hcd");
 
 #define DRIVER_VERSION "29 May 2007"
 
@@ -834,7 +835,7 @@ static void init_pipe_info(struct r8a66597 *r8a66597, struct urb *urb,
        info.pipenum = get_empty_pipenum(r8a66597, ep);
        info.address = get_urb_to_r8a66597_addr(r8a66597, urb);
        info.epnum = ep->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
-       info.maxpacket = ep->wMaxPacketSize;
+       info.maxpacket = le16_to_cpu(ep->wMaxPacketSize);
        info.type = get_r8a66597_type(ep->bmAttributes
                                      & USB_ENDPOINT_XFERTYPE_MASK);
        info.bufnum = get_bufnum(info.pipenum);
@@ -925,7 +926,7 @@ static void prepare_setup_packet(struct r8a66597 *r8a66597,
        r8a66597_write(r8a66597, ~(SIGN | SACK), INTSTS1);
 
        for (i = 0; i < 4; i++) {
-               r8a66597_write(r8a66597, p[i], setup_addr);
+               r8a66597_write(r8a66597, cpu_to_le16(p[i]), setup_addr);
                setup_addr += 2;
        }
        r8a66597_write(r8a66597, SUREQ, DCPCTR);
@@ -959,9 +960,9 @@ static void prepare_packet_read(struct r8a66597 *r8a66597,
                                r8a66597_write(r8a66597, TRCLR,
                                                td->pipe->pipetre);
                                r8a66597_write(r8a66597,
-                                               (urb->transfer_buffer_length
-                                               + td->maxpacket - 1)
-                                               / td->maxpacket,
+                                               DIV_ROUND_UP
+                                                 (urb->transfer_buffer_length,
+                                                  td->maxpacket),
                                                td->pipe->pipetrn);
                                r8a66597_bset(r8a66597, TRENB,
                                                td->pipe->pipetre);
@@ -1034,6 +1035,15 @@ static void prepare_status_packet(struct r8a66597 *r8a66597,
        pipe_start(r8a66597, td->pipe);
 }
 
+static int is_set_address(unsigned char *setup_packet)
+{
+       if (((setup_packet[0] & USB_TYPE_MASK) == USB_TYPE_STANDARD) &&
+                       setup_packet[1] == USB_REQ_SET_ADDRESS)
+               return 1;
+       else
+               return 0;
+}
+
 /* this function must be called with interrupt disabled */
 static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
 {
@@ -1041,7 +1051,7 @@ static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
 
        switch (td->type) {
        case USB_PID_SETUP:
-               if (td->urb->setup_packet[1] == USB_REQ_SET_ADDRESS) {
+               if (is_set_address(td->urb->setup_packet)) {
                        td->set_address = 1;
                        td->urb->setup_packet[2] = alloc_usb_address(r8a66597,
                                                                     td->urb);
@@ -2018,7 +2028,7 @@ static int r8a66597_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
        case GetPortStatus:
                if (wIndex > R8A66597_MAX_ROOT_HUB)
                        goto error;
-               *(u32 *)buf = rh->port;
+               *(u32 *)buf = cpu_to_le32(rh->port);
                break;
        case SetPortFeature:
                if (wIndex > R8A66597_MAX_ROOT_HUB)
@@ -2117,8 +2127,8 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
        struct usb_hcd          *hcd = r8a66597_to_hcd(r8a66597);
 
        del_timer_sync(&r8a66597->rh_timer);
-       iounmap((void *)r8a66597->reg);
        usb_remove_hcd(hcd);
+       iounmap((void *)r8a66597->reg);
        usb_put_hcd(hcd);
        return 0;
 }
@@ -2188,7 +2198,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&r8a66597->child_device);
 
        hcd->rsrc_start = res->start;
-       ret = usb_add_hcd(hcd, irq, 0);
+       ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
        if (ret != 0) {
                err("Failed to add hcd");
                goto clean_up;
@@ -2210,6 +2220,7 @@ static struct platform_driver r8a66597_driver = {
        .resume =       r8a66597_resume,
        .driver         = {
                .name = (char *) hcd_name,
+               .owner  = THIS_MODULE,
        },
 };