summaryrefslogtreecommitdiffstats
path: root/fastboot/usb_linux.c
diff options
context:
space:
mode:
authorAnatol Pomazau <anatol@google.com>2012-02-28 07:21:08 -0800
committerAnatol Pomazau <anatol@google.com>2012-02-28 07:21:08 -0800
commit5ae3f93f3bafbeb1fc9a3324475c58c725749c5e (patch)
tree27d6d32eed4eddb3c37167bc6ab1f156389377ef /fastboot/usb_linux.c
parent9427df10e9858ca0c86441d918c262baa9902f2c (diff)
downloadsystem_core-5ae3f93f3bafbeb1fc9a3324475c58c725749c5e.zip
system_core-5ae3f93f3bafbeb1fc9a3324475c58c725749c5e.tar.gz
system_core-5ae3f93f3bafbeb1fc9a3324475c58c725749c5e.tar.bz2
Remove trailing whitespaces
Change-Id: I6f83333a6ee0fbc562a12bb9555c43a44c98768e
Diffstat (limited to 'fastboot/usb_linux.c')
-rw-r--r--fastboot/usb_linux.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/fastboot/usb_linux.c b/fastboot/usb_linux.c
index cbc64e4..85187de 100644
--- a/fastboot/usb_linux.c
+++ b/fastboot/usb_linux.c
@@ -9,7 +9,7 @@
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -19,7 +19,7 @@
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
@@ -66,7 +66,7 @@
*/
#define MAX_USBFS_BULK_SIZE (16 * 1024)
-struct usb_handle
+struct usb_handle
{
char fname[64];
int desc;
@@ -85,12 +85,12 @@ static inline int badname(const char *name)
static int check(void *_desc, int len, unsigned type, int size)
{
unsigned char *desc = _desc;
-
+
if(len < size) return -1;
if(desc[0] < size) return -1;
if(desc[0] > len) return -1;
if(desc[1] != type) return -1;
-
+
return 0;
}
@@ -103,30 +103,30 @@ static int filter_usb_device(int fd, char *ptr, int len, int writable,
struct usb_interface_descriptor *ifc;
struct usb_endpoint_descriptor *ept;
struct usb_ifc_info info;
-
+
int in, out;
unsigned i;
unsigned e;
-
+
if(check(ptr, len, USB_DT_DEVICE, USB_DT_DEVICE_SIZE))
return -1;
dev = (void*) ptr;
len -= dev->bLength;
ptr += dev->bLength;
-
+
if(check(ptr, len, USB_DT_CONFIG, USB_DT_CONFIG_SIZE))
return -1;
cfg = (void*) ptr;
len -= cfg->bLength;
ptr += cfg->bLength;
-
+
info.dev_vendor = dev->idVendor;
info.dev_product = dev->idProduct;
info.dev_class = dev->bDeviceClass;
info.dev_subclass = dev->bDeviceSubClass;
info.dev_protocol = dev->bDeviceProtocol;
info.writable = writable;
-
+
// read device serial number (if there is one)
info.serial_number[0] = 0;
if (dev->iSerialNumber) {
@@ -162,23 +162,23 @@ static int filter_usb_device(int fd, char *ptr, int len, int writable,
ifc = (void*) ptr;
len -= ifc->bLength;
ptr += ifc->bLength;
-
+
in = -1;
out = -1;
info.ifc_class = ifc->bInterfaceClass;
info.ifc_subclass = ifc->bInterfaceSubClass;
info.ifc_protocol = ifc->bInterfaceProtocol;
-
+
for(e = 0; e < ifc->bNumEndpoints; e++) {
if(check(ptr, len, USB_DT_ENDPOINT, USB_DT_ENDPOINT_SIZE))
return -1;
ept = (void*) ptr;
len -= ept->bLength;
ptr += ept->bLength;
-
+
if((ept->bmAttributes & 0x03) != 0x02)
continue;
-
+
if(ept->bEndpointAddress & 0x80) {
in = ept->bEndpointAddress;
} else {
@@ -188,7 +188,7 @@ static int filter_usb_device(int fd, char *ptr, int len, int writable,
info.has_bulk_in = (in != -1);
info.has_bulk_out = (out != -1);
-
+
if(callback(&info) == 0) {
*ept_in_id = in;
*ept_out_id = out;
@@ -206,25 +206,25 @@ static usb_handle *find_usb_device(const char *base, ifc_match_func callback)
char busname[64], devname[64];
char desc[1024];
int n, in, out, ifc;
-
+
DIR *busdir, *devdir;
struct dirent *de;
int fd;
int writable;
-
+
busdir = opendir(base);
if(busdir == 0) return 0;
while((de = readdir(busdir)) && (usb == 0)) {
if(badname(de->d_name)) continue;
-
+
sprintf(busname, "%s/%s", base, de->d_name);
devdir = opendir(busname);
if(devdir == 0) continue;
-
+
// DBG("[ scanning %s ]\n", busname);
while((de = readdir(devdir)) && (usb == 0)) {
-
+
if(badname(de->d_name)) continue;
sprintf(devname, "%s/%s", busname, de->d_name);
@@ -240,7 +240,7 @@ static usb_handle *find_usb_device(const char *base, ifc_match_func callback)
}
n = read(fd, desc, sizeof(desc));
-
+
if(filter_usb_device(fd, desc, n, writable, callback,
&in, &out, &ifc) == 0) {
usb = calloc(1, sizeof(usb_handle));
@@ -277,13 +277,13 @@ int usb_write(usb_handle *h, const void *_data, int len)
if(h->ep_out == 0) {
return -1;
}
-
+
if(len == 0) {
bulk.ep = h->ep_out;
bulk.len = 0;
bulk.data = data;
bulk.timeout = 0;
-
+
n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
if(n != 0) {
fprintf(stderr,"ERROR: n = %d, errno = %d (%s)\n",
@@ -292,16 +292,16 @@ int usb_write(usb_handle *h, const void *_data, int len)
}
return 0;
}
-
+
while(len > 0) {
int xfer;
xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
-
+
bulk.ep = h->ep_out;
bulk.len = xfer;
bulk.data = data;
bulk.timeout = 0;
-
+
n = ioctl(h->desc, USBDEVFS_BULK, &bulk);
if(n != xfer) {
DBG("ERROR: n = %d, errno = %d (%s)\n",
@@ -327,10 +327,10 @@ int usb_read(usb_handle *h, void *_data, int len)
if(h->ep_in == 0) {
return -1;
}
-
+
while(len > 0) {
int xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
-
+
bulk.ep = h->ep_in;
bulk.len = xfer;
bulk.data = data;
@@ -353,12 +353,12 @@ int usb_read(usb_handle *h, void *_data, int len)
count += n;
len -= n;
data += n;
-
+
if(n < xfer) {
break;
}
}
-
+
return count;
}
@@ -377,7 +377,7 @@ void usb_kick(usb_handle *h)
int usb_close(usb_handle *h)
{
int fd;
-
+
fd = h->desc;
h->desc = -1;
if(fd >= 0) {