Deleted Added
full compact
usb_template.c (246616) usb_template.c (250207)
1/* $FreeBSD: head/sys/dev/usb/template/usb_template.c 246616 2013-02-10 10:56:13Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/template/usb_template.c 250207 2013-05-03 11:10:04Z hselasky $ */
2/*-
3 * Copyright (c) 2007 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.

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

64#include <dev/usb/usb_process.h>
65#include <dev/usb/usb_device.h>
66
67#define USB_DEBUG_VAR usb_debug
68#include <dev/usb/usb_debug.h>
69
70#include <dev/usb/usb_controller.h>
71#include <dev/usb/usb_bus.h>
2/*-
3 * Copyright (c) 2007 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.

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

64#include <dev/usb/usb_process.h>
65#include <dev/usb/usb_device.h>
66
67#define USB_DEBUG_VAR usb_debug
68#include <dev/usb/usb_debug.h>
69
70#include <dev/usb/usb_controller.h>
71#include <dev/usb/usb_bus.h>
72#include <dev/usb/usb_request.h>
72#include <dev/usb/template/usb_template.h>
73#endif /* USB_GLOBAL_INCLUDE_FILE */
74
75MODULE_DEPEND(usb_template, usb, 1, 1, 1);
76MODULE_VERSION(usb_template, 1);
77
78/* function prototypes */
79

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

1262 goto done;
1263 }
1264 /* sanity check */
1265 if (uts->size == 0) {
1266 uts->err = USB_ERR_INVAL;
1267 goto done;
1268 }
1269 /* allocate zeroed memory */
73#include <dev/usb/template/usb_template.h>
74#endif /* USB_GLOBAL_INCLUDE_FILE */
75
76MODULE_DEPEND(usb_template, usb, 1, 1, 1);
77MODULE_VERSION(usb_template, 1);
78
79/* function prototypes */
80

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

1263 goto done;
1264 }
1265 /* sanity check */
1266 if (uts->size == 0) {
1267 uts->err = USB_ERR_INVAL;
1268 goto done;
1269 }
1270 /* allocate zeroed memory */
1270 uts->buf = malloc(uts->size, M_USB, M_WAITOK | M_ZERO);
1271 uts->buf = usbd_alloc_config_desc(udev, uts->size);
1271 /*
1272 * Allow malloc() to return NULL regardless of M_WAITOK flag.
1273 * This helps when porting the software to non-FreeBSD
1274 * systems.
1275 */
1276 if (uts->buf == NULL) {
1277 /* could not allocate memory */
1278 uts->err = USB_ERR_NOMEM;

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

1331 * usb_temp_unsetup
1332 *
1333 * This function frees any memory associated with the currently
1334 * setup template, if any.
1335 *------------------------------------------------------------------------*/
1336void
1337usb_temp_unsetup(struct usb_device *udev)
1338{
1272 /*
1273 * Allow malloc() to return NULL regardless of M_WAITOK flag.
1274 * This helps when porting the software to non-FreeBSD
1275 * systems.
1276 */
1277 if (uts->buf == NULL) {
1278 /* could not allocate memory */
1279 uts->err = USB_ERR_NOMEM;

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

1332 * usb_temp_unsetup
1333 *
1334 * This function frees any memory associated with the currently
1335 * setup template, if any.
1336 *------------------------------------------------------------------------*/
1337void
1338usb_temp_unsetup(struct usb_device *udev)
1339{
1339 if (udev->usb_template_ptr) {
1340
1341 free(udev->usb_template_ptr, M_USB);
1342
1343 udev->usb_template_ptr = NULL;
1344 }
1340 usbd_free_config_desc(udev, udev->usb_template_ptr);
1341 udev->usb_template_ptr = NULL;
1345}
1346
1347static usb_error_t
1348usb_temp_setup_by_index(struct usb_device *udev, uint16_t index)
1349{
1350 usb_error_t err;
1351
1352 switch (index) {

--- 39 unchanged lines hidden ---
1342}
1343
1344static usb_error_t
1345usb_temp_setup_by_index(struct usb_device *udev, uint16_t index)
1346{
1347 usb_error_t err;
1348
1349 switch (index) {

--- 39 unchanged lines hidden ---