- /* Allocate output buffer memory for the opened device */
- fifo = objects_p[MINOR_NR]->fifo;
- fifo->buf_tx_entry=(struct canmsg_t *)kmalloc(MAX_BUF_LENGTH * sizeof(struct canmsg_t), GFP_KERNEL);
- if (fifo->buf_tx_entry == NULL)
- return -ENOMEM;
- else
- if ( add_mem_to_list(fifo->buf_tx_entry) )
- return -ENOMEM;
- /* Allocate input buffer memory for the opened device */
- fifo->buf_rx_entry=(struct canmsg_t *)kmalloc(MAX_BUF_LENGTH * sizeof(struct canmsg_t), GFP_KERNEL);
- if (fifo->buf_rx_entry == NULL)
- return -ENOMEM;
- else
- if ( add_mem_to_list(fifo->buf_rx_entry) )
- return -ENOMEM;
-
- /* In- and output buffer initialization */
- fifo->tx_readp = fifo->buf_tx_entry;
- fifo->tx_writep = fifo->buf_tx_entry;
- fifo->rx_readp = fifo->buf_rx_entry;
- fifo->rx_writep = fifo->buf_rx_entry;
- fifo->rx_size = MAX_BUF_LENGTH * sizeof(struct canmsg_t);
- fifo->tx_size = fifo->rx_size;
-
-#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,0))
- init_waitqueue(&fifo->readq);
- init_waitqueue(&fifo->writeq);
-#else
- init_waitqueue_head(&fifo->readq);
- init_waitqueue_head(&fifo->writeq);
-#endif
+ canuser = (struct canuser_t *)kmalloc(sizeof(struct canuser_t), GFP_KERNEL);
+ if(canuser == NULL) goto no_canuser;
+ canuser->file = file;
+ canuser->msgobj = obj;
+ canuser->magic = CAN_USER_MAGIC;
+ file->private_data = canuser;