usb_lookup.c (193074) | usb_lookup.c (194228) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_lookup.c 193074 2009-05-30 00:22:57Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_lookup.c 194228 2009-06-15 01:02:43Z thompsa $ */ |
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. --- 13 unchanged lines hidden (view full) --- 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <dev/usb/usb_core.h> 28#include <dev/usb/usb_lookup.h> 29 30/*------------------------------------------------------------------------* | 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. --- 13 unchanged lines hidden (view full) --- 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <dev/usb/usb_core.h> 28#include <dev/usb/usb_lookup.h> 29 30/*------------------------------------------------------------------------* |
31 * usb2_lookup_id_by_info | 31 * usbd_lookup_id_by_info |
32 * 33 * This functions takes an array of "struct usb_device_id" and tries | 32 * 33 * This functions takes an array of "struct usb_device_id" and tries |
34 * to match the entries with the information in "struct usb_lookup_info". | 34 * to match the entries with the information in "struct usbd_lookup_info". |
35 * 36 * NOTE: The "sizeof_id" parameter must be a multiple of the 37 * usb_device_id structure size. Else the behaviour of this function 38 * is undefined. 39 * 40 * Return values: 41 * NULL: No match found. 42 * Else: Pointer to matching entry. 43 *------------------------------------------------------------------------*/ 44const struct usb_device_id * | 35 * 36 * NOTE: The "sizeof_id" parameter must be a multiple of the 37 * usb_device_id structure size. Else the behaviour of this function 38 * is undefined. 39 * 40 * Return values: 41 * NULL: No match found. 42 * Else: Pointer to matching entry. 43 *------------------------------------------------------------------------*/ 44const struct usb_device_id * |
45usb2_lookup_id_by_info(const struct usb_device_id *id, usb_size_t sizeof_id, 46 const struct usb_lookup_info *info) | 45usbd_lookup_id_by_info(const struct usb_device_id *id, usb_size_t sizeof_id, 46 const struct usbd_lookup_info *info) |
47{ 48 const struct usb_device_id *id_end; 49 50 if (id == NULL) { 51 goto done; 52 } 53 id_end = (const void *)(((const uint8_t *)id) + sizeof_id); 54 --- 54 unchanged lines hidden (view full) --- 109 return (id); 110 } 111 112done: 113 return (NULL); 114} 115 116/*------------------------------------------------------------------------* | 47{ 48 const struct usb_device_id *id_end; 49 50 if (id == NULL) { 51 goto done; 52 } 53 id_end = (const void *)(((const uint8_t *)id) + sizeof_id); 54 --- 54 unchanged lines hidden (view full) --- 109 return (id); 110 } 111 112done: 113 return (NULL); 114} 115 116/*------------------------------------------------------------------------* |
117 * usb2_lookup_id_by_uaa - factored out code | 117 * usbd_lookup_id_by_uaa - factored out code |
118 * 119 * Return values: 120 * 0: Success 121 * Else: Failure 122 *------------------------------------------------------------------------*/ 123int | 118 * 119 * Return values: 120 * 0: Success 121 * Else: Failure 122 *------------------------------------------------------------------------*/ 123int |
124usb2_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, | 124usbd_lookup_id_by_uaa(const struct usb_device_id *id, usb_size_t sizeof_id, |
125 struct usb_attach_arg *uaa) 126{ | 125 struct usb_attach_arg *uaa) 126{ |
127 id = usb2_lookup_id_by_info(id, sizeof_id, &uaa->info); | 127 id = usbd_lookup_id_by_info(id, sizeof_id, &uaa->info); |
128 if (id) { 129 /* copy driver info */ 130 uaa->driver_info = id->driver_info; 131 return (0); 132 } 133 return (ENXIO); 134} | 128 if (id) { 129 /* copy driver info */ 130 uaa->driver_info = id->driver_info; 131 return (0); 132 } 133 return (ENXIO); 134} |