usb_mbuf.c (190749) | usb_mbuf.c (192984) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_mbuf.c 190749 2009-04-05 21:24:15Z piso $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_mbuf.c 192984 2009-05-28 17:36:36Z 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. --- 20 unchanged lines hidden (view full) --- 30/*------------------------------------------------------------------------* 31 * usb2_alloc_mbufs - allocate mbufs to an usbd interface queue 32 * 33 * Returns: 34 * A pointer that should be passed to "free()" when the buffer(s) 35 * should be released. 36 *------------------------------------------------------------------------*/ 37void * | 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. --- 20 unchanged lines hidden (view full) --- 30/*------------------------------------------------------------------------* 31 * usb2_alloc_mbufs - allocate mbufs to an usbd interface queue 32 * 33 * Returns: 34 * A pointer that should be passed to "free()" when the buffer(s) 35 * should be released. 36 *------------------------------------------------------------------------*/ 37void * |
38usb2_alloc_mbufs(struct malloc_type *type, struct usb2_ifqueue *ifq, | 38usb2_alloc_mbufs(struct malloc_type *type, struct usb_ifqueue *ifq, |
39 usb2_size_t block_size, uint16_t nblocks) 40{ | 39 usb2_size_t block_size, uint16_t nblocks) 40{ |
41 struct usb2_mbuf *m_ptr; | 41 struct usb_mbuf *m_ptr; |
42 uint8_t *data_ptr; 43 void *free_ptr = NULL; 44 usb2_size_t alloc_size; 45 46 /* align data */ 47 block_size += ((-block_size) & (USB_HOST_ALIGN - 1)); 48 49 if (nblocks && block_size) { 50 | 42 uint8_t *data_ptr; 43 void *free_ptr = NULL; 44 usb2_size_t alloc_size; 45 46 /* align data */ 47 block_size += ((-block_size) & (USB_HOST_ALIGN - 1)); 48 49 if (nblocks && block_size) { 50 |
51 alloc_size = (block_size + sizeof(struct usb2_mbuf)) * nblocks; | 51 alloc_size = (block_size + sizeof(struct usb_mbuf)) * nblocks; |
52 53 free_ptr = malloc(alloc_size, type, M_WAITOK | M_ZERO); 54 55 if (free_ptr == NULL) { 56 goto done; 57 } 58 m_ptr = free_ptr; 59 data_ptr = (void *)(m_ptr + nblocks); --- 18 unchanged lines hidden --- | 52 53 free_ptr = malloc(alloc_size, type, M_WAITOK | M_ZERO); 54 55 if (free_ptr == NULL) { 56 goto done; 57 } 58 m_ptr = free_ptr; 59 data_ptr = (void *)(m_ptr + nblocks); --- 18 unchanged lines hidden --- |