ep->pipenum = pipenum;
        ep->ep.maxpacket = usb_endpoint_maxp(desc);
        r8a66597->pipenum2ep[pipenum] = ep;
-       r8a66597->epaddr2ep[desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK]
+       r8a66597->epaddr2ep[usb_endpoint_num(desc)]
                = ep;
        INIT_LIST_HEAD(&ep->queue);
 }
        if (ep->pipenum)        /* already allocated pipe  */
                return 0;
 
-       switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
+       switch (usb_endpoint_type(desc)) {
        case USB_ENDPOINT_XFER_BULK:
                if (r8a66597->bulk >= R8A66597_MAX_NUM_BULK) {
                        if (r8a66597->isochronous >= R8A66597_MAX_NUM_ISOC) {
        }
        ep->type = info.type;
 
-       info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+       info.epnum = usb_endpoint_num(desc);
        info.maxpacket = usb_endpoint_maxp(desc);
        info.interval = desc->bInterval;
        if (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK)