kernels/linux-2.4.0/drivers/ieee1394/ieee1394_core.c
/**
 * alloc_hpsb_packet - allocate new packet structure
 * @data_size: size of the data block to be allocated
 *
 * This function allocates, initializes and returns a new &struct hpsb_packet.
 * It can be used in interrupt context.  A header block is always included, its
 * size is big enough to contain all possible 1394 headers.  The data block is
 * only allocated when @data_size is not zero.
 *
 * For packets for which responses will be received the @data_size has to be big
 * enough to contain the response's data block since no further allocation
 * occurs at response matching time.
 *
 * The packet's generation value will be set to the current generation number
 * for ease of use.  Remember to overwrite it with your own recorded generation
 * number if you can not be sure that your code will not race with a bus reset.
 *
 * Return value: A pointer to a &struct hpsb_packet or NULL on allocation
 * failure.
 */
allocate new packet structure
@data_size: size of the data block to be allocated

This function allocates, initializes and returns a new &struct hpsb_packet.
It can be used in interrupt context.  A header block is always included, its
size is big enough to contain all possible 1394 headers.  The data block is
only allocated when @data_size is not zero.

For packets for which responses will be received the @data_size has to be big
enough to contain the response's data block since no further allocation
occurs at response matching time.

The packet's generation value will be set to the current generation number
for ease of use.  Remember to overwrite it with your own recorded generation
number if you can not be sure that your code will not race with a bus reset.

Return value: A pointer to a &struct hpsb_packet or NULL on allocation
failure.
allocate new packet structure @data_size : size of the data block to be allocated This function allocates initializes and returns a new &struct hpsb_packet . It can be used in interrupt context . A header block is always included its size is big enough to contain all possible 1394 headers . The data block is only allocated when @data_size is not zero . For packets for which responses will be received the @data_size has to be big enough to contain the response ' s data block since no further allocation occurs at response matching time . The packet ' s generation value will be set to the current generation number for ease of use . Remember to overwrite it with your own recorded generation number if you can not be sure that your code will not race with a bus reset . Return value : A pointer to a &struct hpsb_packet or NULL on allocation failure .
struct hpsb_packet *alloc_hpsb_packet(size_t data_size)
{
        struct hpsb_packet *packet = NULL;
        void *header = NULL, *data = NULL;
        int kmflags = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
        packet = kmalloc(sizeof(struct hpsb_packet), kmflags);
        header = kmalloc(5 * 4, kmflags);
        if (header == NULL || packet == NULL) {
                kfree(header);
                kfree(packet);
                return NULL;
        }
        memset(packet, 0, sizeof(struct hpsb_packet));
        packet->header = header;
        if (data_size) {
                data = kmalloc(data_size + 8, kmflags);
                if (data == NULL) {
                        kfree(header);
                        kfree(packet);
                        return NULL;
                }
                packet->data = data;
                packet->data_size = data_size;
        }
        INIT_LIST_HEAD(&packet->list);
        sema_init(&packet->state_change, 0);
        packet->state = unused;
        packet->generation = get_hpsb_generation();
        packet->data_be = 1;
        return packet;
}
struct hpsb_packet * alloc_hpsb_packet ( size_t data_size ) { struct hpsb_packet * packet = NULL ; void * header = NULL , * data = NULL ; int kmflags = in_interrupt ( ) ? GFP_ATOMIC : GFP_KERNEL ; packet = kmalloc ( sizeof ( struct hpsb_packet ) , kmflags ) ; header = kmalloc ( 5 * 4 , kmflags ) ; if ( header == NULL || packet == NULL ) { kfree ( header ) ; kfree ( packet ) ; return NULL ; } memset ( packet , 0 , sizeof ( struct hpsb_packet ) ) ; packet -> header = header ; if ( data_size ) { data = kmalloc ( data_size + 8 , kmflags ) ; if ( data == NULL ) { kfree ( header ) ; kfree ( packet ) ; return NULL ; } packet -> data = data ; packet -> data_size = data_size ; } INIT_LIST_HEAD ( & packet -> list ) ; sema_init ( & packet -> state_change , 0 ) ; packet -> state = unused ; packet -> generation = get_hpsb_generation ( ) ; packet -> data_be = 1 ; return packet ; }
alloc_hpsb_packet - allocate new packet structure
 @data_size: size of the data block to be allocated
alloc_hpsb_packet - allocate new packet structure @data_size : size of the data block to be allocated