libusb20.c (213852) | libusb20.c (219100) |
---|---|
1/* $FreeBSD: head/lib/libusb/libusb20.c 213852 2010-10-14 20:38:18Z hselasky $ */ | 1/* $FreeBSD: head/lib/libusb/libusb20.c 219100 2011-02-28 17:23:15Z hselasky $ */ |
2/*- 3 * Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 141 unchanged lines hidden (view full) --- 151 return (error); 152} 153 154int 155libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, 156 uint32_t MaxFrameCount, uint8_t ep_no) 157{ 158 uint32_t size; | 2/*- 3 * Copyright (c) 2008-2009 Hans Petter Selasky. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. --- 141 unchanged lines hidden (view full) --- 151 return (error); 152} 153 154int 155libusb20_tr_open(struct libusb20_transfer *xfer, uint32_t MaxBufSize, 156 uint32_t MaxFrameCount, uint8_t ep_no) 157{ 158 uint32_t size; |
159 uint8_t pre_scale; |
|
159 int error; 160 | 160 int error; 161 |
161 if (xfer->is_opened) { | 162 if (xfer->is_opened) |
162 return (LIBUSB20_ERROR_BUSY); | 163 return (LIBUSB20_ERROR_BUSY); |
164 if (MaxFrameCount & LIBUSB20_MAX_FRAME_PRE_SCALE) { 165 MaxFrameCount &= ~LIBUSB20_MAX_FRAME_PRE_SCALE; 166 pre_scale = 1; 167 } else { 168 pre_scale = 0; |
|
163 } | 169 } |
164 if (MaxFrameCount == 0) { | 170 if (MaxFrameCount == 0) |
165 return (LIBUSB20_ERROR_INVALID_PARAM); | 171 return (LIBUSB20_ERROR_INVALID_PARAM); |
166 } | 172 |
167 xfer->maxFrames = MaxFrameCount; 168 169 size = MaxFrameCount * sizeof(xfer->pLength[0]); 170 xfer->pLength = malloc(size); 171 if (xfer->pLength == NULL) { 172 return (LIBUSB20_ERROR_NO_MEM); 173 } 174 memset(xfer->pLength, 0, size); 175 176 size = MaxFrameCount * sizeof(xfer->ppBuffer[0]); 177 xfer->ppBuffer = malloc(size); 178 if (xfer->ppBuffer == NULL) { 179 free(xfer->pLength); 180 return (LIBUSB20_ERROR_NO_MEM); 181 } 182 memset(xfer->ppBuffer, 0, size); 183 184 error = xfer->pdev->methods->tr_open(xfer, MaxBufSize, | 173 xfer->maxFrames = MaxFrameCount; 174 175 size = MaxFrameCount * sizeof(xfer->pLength[0]); 176 xfer->pLength = malloc(size); 177 if (xfer->pLength == NULL) { 178 return (LIBUSB20_ERROR_NO_MEM); 179 } 180 memset(xfer->pLength, 0, size); 181 182 size = MaxFrameCount * sizeof(xfer->ppBuffer[0]); 183 xfer->ppBuffer = malloc(size); 184 if (xfer->ppBuffer == NULL) { 185 free(xfer->pLength); 186 return (LIBUSB20_ERROR_NO_MEM); 187 } 188 memset(xfer->ppBuffer, 0, size); 189 190 error = xfer->pdev->methods->tr_open(xfer, MaxBufSize, |
185 MaxFrameCount, ep_no); | 191 MaxFrameCount, ep_no, pre_scale); |
186 187 if (error) { 188 free(xfer->ppBuffer); 189 free(xfer->pLength); 190 } else { 191 xfer->is_opened = 1; 192 } 193 return (error); --- 1033 unchanged lines hidden --- | 192 193 if (error) { 194 free(xfer->ppBuffer); 195 free(xfer->pLength); 196 } else { 197 xfer->is_opened = 1; 198 } 199 return (error); --- 1033 unchanged lines hidden --- |