Deleted Added
full compact
usb_parse.c (246122) usb_parse.c (250204)
1/* $FreeBSD: head/sys/dev/usb/usb_parse.c 246122 2013-01-30 15:26:04Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/usb_parse.c 250204 2013-05-03 09:23:06Z hselasky $ */
2/*-
3 * Copyright (c) 2008 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.

--- 34 unchanged lines hidden (view full) ---

44#include <sys/unistd.h>
45#include <sys/callout.h>
46#include <sys/malloc.h>
47#include <sys/priv.h>
48
49#include <dev/usb/usb.h>
50#include <dev/usb/usbdi.h>
51#include <dev/usb/usbdi_util.h>
2/*-
3 * Copyright (c) 2008 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.

--- 34 unchanged lines hidden (view full) ---

44#include <sys/unistd.h>
45#include <sys/callout.h>
46#include <sys/malloc.h>
47#include <sys/priv.h>
48
49#include <dev/usb/usb.h>
50#include <dev/usb/usbdi.h>
51#include <dev/usb/usbdi_util.h>
52
53#define USB_DEBUG_VAR usb_debug
54
55#include <dev/usb/usb_core.h>
56#include <dev/usb/usb_debug.h>
52#endif /* USB_GLOBAL_INCLUDE_FILE */
53
54/*------------------------------------------------------------------------*
55 * usb_desc_foreach
56 *
57 * This function is the safe way to iterate across the USB config
58 * descriptor. It contains several checks against invalid
59 * descriptors. If the "desc" argument passed to this function is

--- 77 unchanged lines hidden (view full) ---

137 if (ps->iface_no_last == id->bInterfaceNumber)
138 new_iface = 0;
139 ps->iface_no_last = id->bInterfaceNumber;
140 break;
141 }
142 }
143
144 if (ps->desc == NULL) {
57#endif /* USB_GLOBAL_INCLUDE_FILE */
58
59/*------------------------------------------------------------------------*
60 * usb_desc_foreach
61 *
62 * This function is the safe way to iterate across the USB config
63 * descriptor. It contains several checks against invalid
64 * descriptors. If the "desc" argument passed to this function is

--- 77 unchanged lines hidden (view full) ---

142 if (ps->iface_no_last == id->bInterfaceNumber)
143 new_iface = 0;
144 ps->iface_no_last = id->bInterfaceNumber;
145 break;
146 }
147 }
148
149 if (ps->desc == NULL) {
145 /* first time */
150 /* first time or zero descriptors */
146 } else if (new_iface) {
147 /* new interface */
148 ps->iface_index ++;
149 ps->iface_index_alt = 0;
150 } else {
151 /* new alternate interface */
152 ps->iface_index_alt ++;
153 }
151 } else if (new_iface) {
152 /* new interface */
153 ps->iface_index ++;
154 ps->iface_index_alt = 0;
155 } else {
156 /* new alternate interface */
157 ps->iface_index_alt ++;
158 }
159#if (USB_IFACE_MAX <= 0)
160#error "USB_IFACE_MAX must be defined greater than zero"
161#endif
162 /* check for too many interfaces */
163 if (ps->iface_index >= USB_IFACE_MAX) {
164 DPRINTF("Interface limit reached\n");
165 id = NULL;
166 }
154
155 /* store and return current descriptor */
156 ps->desc = (struct usb_descriptor *)id;
157 return (id);
158}
159
160/*------------------------------------------------------------------------*
161 * usb_edesc_foreach

--- 130 unchanged lines hidden ---
167
168 /* store and return current descriptor */
169 ps->desc = (struct usb_descriptor *)id;
170 return (id);
171}
172
173/*------------------------------------------------------------------------*
174 * usb_edesc_foreach

--- 130 unchanged lines hidden ---