linux_usb.c (217265) | linux_usb.c (227461) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_compat_linux.c 217265 2011-01-11 13:59:06Z jhb $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_compat_linux.c 227461 2011-11-12 08:16:45Z hselasky $ */ |
2/*- 3 * Copyright (c) 2007 Luigi Rizzo - Universita` di Pisa. All rights reserved. 4 * Copyright (c) 2007 Hans Petter Selasky. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 549 unchanged lines hidden (view full) --- 559 uint8_t addr; 560 561 if (uhe == NULL) 562 return (-EINVAL); 563 564 type = uhe->desc.bmAttributes & UE_XFERTYPE; 565 addr = uhe->desc.bEndpointAddress; 566 | 2/*- 3 * Copyright (c) 2007 Luigi Rizzo - Universita` di Pisa. All rights reserved. 4 * Copyright (c) 2007 Hans Petter Selasky. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright --- 549 unchanged lines hidden (view full) --- 559 uint8_t addr; 560 561 if (uhe == NULL) 562 return (-EINVAL); 563 564 type = uhe->desc.bmAttributes & UE_XFERTYPE; 565 addr = uhe->desc.bEndpointAddress; 566 |
567 bzero(cfg, sizeof(cfg)); | 567 memset(cfg, 0, sizeof(cfg)); |
568 569 cfg[0].type = type; 570 cfg[0].endpoint = addr & UE_ADDR; 571 cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN); 572 573 ep = usbd_get_endpoint(dev, uhe->bsd_iface_index, cfg); 574 if (ep == NULL) 575 return (-EINVAL); --- 128 unchanged lines hidden (view full) --- 704 */ 705 urb = usb_alloc_urb(0xFFFF, size); 706 if (urb == NULL) 707 return (-ENOMEM); 708 709 urb->dev = dev; 710 urb->endpoint = uhe; 711 | 568 569 cfg[0].type = type; 570 cfg[0].endpoint = addr & UE_ADDR; 571 cfg[0].direction = addr & (UE_DIR_OUT | UE_DIR_IN); 572 573 ep = usbd_get_endpoint(dev, uhe->bsd_iface_index, cfg); 574 if (ep == NULL) 575 return (-EINVAL); --- 128 unchanged lines hidden (view full) --- 704 */ 705 urb = usb_alloc_urb(0xFFFF, size); 706 if (urb == NULL) 707 return (-ENOMEM); 708 709 urb->dev = dev; 710 urb->endpoint = uhe; 711 |
712 bcopy(&req, urb->setup_packet, sizeof(req)); | 712 memcpy(urb->setup_packet, &req, sizeof(req)); |
713 714 if (size && (!(req.bmRequestType & UT_READ))) { 715 /* move the data to a real buffer */ | 713 714 if (size && (!(req.bmRequestType & UT_READ))) { 715 /* move the data to a real buffer */ |
716 bcopy(data, USB_ADD_BYTES(urb->setup_packet, 717 sizeof(req)), size); | 716 memcpy(USB_ADD_BYTES(urb->setup_packet, sizeof(req)), 717 data, size); |
718 } 719 err = usb_start_wait_urb(urb, timeout, &actlen); 720 721 if (req.bmRequestType & UT_READ) { 722 if (actlen) { 723 bcopy(USB_ADD_BYTES(urb->setup_packet, 724 sizeof(req)), data, actlen); 725 } --- 58 unchanged lines hidden (view full) --- 784 } 785 usbd_transfer_unsetup(uhe->bsd_xfer, 2); 786 787 uhe->fbsd_buf_size = bufsize; 788 789 if (bufsize == 0) { 790 return (0); 791 } | 718 } 719 err = usb_start_wait_urb(urb, timeout, &actlen); 720 721 if (req.bmRequestType & UT_READ) { 722 if (actlen) { 723 bcopy(USB_ADD_BYTES(urb->setup_packet, 724 sizeof(req)), data, actlen); 725 } --- 58 unchanged lines hidden (view full) --- 784 } 785 usbd_transfer_unsetup(uhe->bsd_xfer, 2); 786 787 uhe->fbsd_buf_size = bufsize; 788 789 if (bufsize == 0) { 790 return (0); 791 } |
792 bzero(cfg, sizeof(cfg)); | 792 memset(cfg, 0, sizeof(cfg)); |
793 794 if (type == UE_ISOCHRONOUS) { 795 796 /* 797 * Isochronous transfers are special in that they don't fit 798 * into the BULK/INTR/CONTROL transfer model. 799 */ 800 --- 445 unchanged lines hidden (view full) --- 1246 * instead. 1247 *------------------------------------------------------------------------*/ 1248void 1249usb_init_urb(struct urb *urb) 1250{ 1251 if (urb == NULL) { 1252 return; 1253 } | 793 794 if (type == UE_ISOCHRONOUS) { 795 796 /* 797 * Isochronous transfers are special in that they don't fit 798 * into the BULK/INTR/CONTROL transfer model. 799 */ 800 --- 445 unchanged lines hidden (view full) --- 1246 * instead. 1247 *------------------------------------------------------------------------*/ 1248void 1249usb_init_urb(struct urb *urb) 1250{ 1251 if (urb == NULL) { 1252 return; 1253 } |
1254 bzero(urb, sizeof(*urb)); | 1254 memset(urb, 0, sizeof(*urb)); |
1255} 1256 1257/*------------------------------------------------------------------------* 1258 * usb_kill_urb 1259 *------------------------------------------------------------------------*/ 1260void 1261usb_kill_urb(struct urb *urb) 1262{ --- 470 unchanged lines hidden --- | 1255} 1256 1257/*------------------------------------------------------------------------* 1258 * usb_kill_urb 1259 *------------------------------------------------------------------------*/ 1260void 1261usb_kill_urb(struct urb *urb) 1262{ --- 470 unchanged lines hidden --- |