static int __init testfunc(void) { unsigned char buf[6]; unsigned char i, j; unsigned int ret; printk(KERN_INFO "[fifo]byte stream fifo test start\n"); /* put string into the fifo */ kfifo_in(&test, "hello", 5); /* put values into the fifo */ for (i = 0; i != 10; i++) kfifo_put(&test, &i); /* show the number of used elements */ printk(KERN_INFO "[fifo]fifo len: %u\n", kfifo_len(&test)); /* get max of 5 bytes from the fifo */ i = kfifo_out(&test, buf, 5); printk(KERN_INFO "[fifo]buf: %.*s\n", i, buf); /* get max of 2 elements from the fifo */ ret = kfifo_out(&test, buf, 2); printk(KERN_INFO "[fifo]ret: %d\n", ret); /* and put it back to the end of the fifo */ ret = kfifo_in(&test, buf, ret); printk(KERN_INFO "[fifo]ret: %d\n", ret); /* skip first element of the fifo */ printk(KERN_INFO "[fifo]skip 1st element\n"); kfifo_skip(&test); /* put values into the fifo until is full */ for (i = 20; kfifo_put(&test, &i); i++) ; printk(KERN_INFO "[fifo]queue len: %u\n", kfifo_len(&test)); /* show the first value without removing from the fifo */ if (kfifo_peek(&test, &i)) printk(KERN_INFO "[fifo]%d\n", i); /* check the correctness of all values in the fifo */ j = 0; while (kfifo_get(&test, &i)) { printk(KERN_INFO "item = %d\n", i); if (i != expected_result[j++]) { printk(KERN_WARNING "value mismatch: test failed\n"); return -EIO; } } if (j != ARRAY_SIZE(expected_result)) { printk(KERN_WARNING "size mismatch: test failed\n"); return -EIO; } printk(KERN_INFO "[fifo]test passed\n"); return 0; }
static ssize_t threadrw_write_onece( struct threadrw_write_task *task, struct file *file, struct stream_buf_s *stbuf, const char __user *buf, size_t count) { struct threadrw_buf *rwbuf = NULL; int ret = 0; int to_write; if (!kfifo_get(&task->freefifo, (void *)&rwbuf)) { if (task->errors) return task->errors; return -EAGAIN; } to_write = min_t(u32, rwbuf->buffer_size, count); if (copy_from_user(rwbuf->vbuffer, buf, to_write)) { kfifo_put(&task->freefifo, (const void *)buf); ret = -EFAULT; goto err; } rwbuf->data_size = to_write; rwbuf->write_off = 0; kfifo_put(&task->datafifo, (const void *)rwbuf); threadrw_schedule_delayed_work(task, 0); return to_write; err: return ret; }
static int __init testfunc(void) { int buf[6]; int i, j; unsigned int ret; printk(KERN_INFO "int fifo test start\n"); for (i = 0; i != 10; i++) kfifo_put(&test, &i); printk(KERN_INFO "fifo len: %u\n", kfifo_len(&test)); ret = kfifo_out(&test, buf, 2); printk(KERN_INFO "ret: %d\n", ret); ret = kfifo_in(&test, buf, ret); printk(KERN_INFO "ret: %d\n", ret); printk(KERN_INFO "skip 1st element\n"); kfifo_skip(&test); for (i = 20; kfifo_put(&test, &i); i++) ; printk(KERN_INFO "queue len: %u\n", kfifo_len(&test)); if (kfifo_peek(&test, &i)) printk(KERN_INFO "%d\n", i); j = 0; while (kfifo_get(&test, &i)) { printk(KERN_INFO "item = %d\n", i); if (i != expected_result[j++]) { printk(KERN_WARNING "value mismatch: test failed\n"); return -EIO; } } if (j != ARRAY_SIZE(expected_result)) { printk(KERN_WARNING "size mismatch: test failed\n"); return -EIO; } printk(KERN_INFO "test passed\n"); return 0; }
static void nc_handler(void *ctx, char *pkt, unsigned len) { struct nc_priv *priv = g_priv; unsigned char *packet = net_eth_to_udp_payload(pkt); kfifo_put(priv->fifo, packet, net_eth_to_udplen(pkt)); }
/** * usb_serial_generic_write - generic write function for serial USB devices * @tty: Pointer to &struct tty_struct for the device * @port: Pointer to the &usb_serial_port structure for the device * @buf: Pointer to the data to write * @count: Number of bytes to write * * Returns the number of characters actually written, which may be anything * from zero to @count. If an error occurs, it returns the negative errno * value. */ int usb_serial_generic_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; int result; dbg("%s - port %d", __func__, port->number); if (count == 0) { dbg("%s - write request of 0 bytes", __func__); return 0; } /* only do something if we have a bulk out endpoint */ if (!serial->num_bulk_out) return 0; if (serial->type->max_in_flight_urbs) return usb_serial_multi_urb_write(tty, port, buf, count); count = kfifo_put(port->write_fifo, buf, count); result = usb_serial_generic_write_start(port); if (result >= 0) result = count; return result; }
static s32 usart1_irq_send(u8* buff, u32 buff_len) { u8 BoxErr = 0; //邮箱接收错误标志 u8 tx_data = 0; if(buff_len == 0) { return 0; } kfifo_put(&tx_fifo,buff,buff_len); //有可能再次调用此函数的时候,发送fifo中有未发送完毕的数据 while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); //如果连续调用此函数,等待发送数据寄存器为空,也就是等待上一次发送的数据已经发送完毕 //while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET); //如果连续调用此函数,等待发送数据寄存器为空,也就是等待上一次发送的数据已经发送完毕 if( 0 == kfifo_getc( &tx_fifo,&tx_data ) ) { USART1_PUTCHAR(tx_data); USART_ITConfig(USART1, USART_IT_TXE, ENABLE); //开启发送中断 } SysMboxPend(tx_event,tx_timeout_ticks,&BoxErr); if(BoxErr != 0) { return 0; } return buff_len; }
/* stp_uart_tty_receive() * * Called by tty low level driver when receive data is * available. * * Arguments: tty pointer to tty isntance data * data pointer to received data * flags pointer to flags for data * count count of received data in bytes * * Return Value: None */ static void stp_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) { unsigned int written; //UART_LOUD_FUNC("URX:%d\n", count); if (unlikely(count > 2000)) { UART_WARN_FUNC("abnormal: buffer count = %d\n", count); } if (unlikely(!g_stp_uart_rx_fifo || !g_stp_uart_rx_work || !g_stp_uart_rx_wq)) { UART_ERR_FUNC("abnormal g_stp_uart_rx_fifo(0x%p),g_stp_uart_rx_work(0x%p),g_stp_uart_rx_wq(0x%p)\n", g_stp_uart_rx_fifo, g_stp_uart_rx_work, g_stp_uart_rx_wq); return; } /* need to check available buffer size? skip! */ /* need to lock fifo? skip for single writer single reader! */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) written = kfifo_put(g_stp_uart_rx_fifo, (unsigned char *) data, count); #else written = kfifo_in(g_stp_uart_rx_fifo, (unsigned char *) data, count); #endif //printk("uart_rx:%d,wr:%d\n\r",count,written); queue_work(g_stp_uart_rx_wq, g_stp_uart_rx_work); if (unlikely(written != count)) { UART_ERR_FUNC("c(%d),w(%d) bytes dropped\n", count, written); } return; }
/* * nfs_read_req - Read File on NFS Server */ static int nfs_read_req(struct file_priv *priv, int offset, int readlen) { uint32_t data[1024]; uint32_t *p; uint32_t *filedata; int len; int ret; int rlen; p = &(data[0]); p = rpc_add_credentials(p); memcpy (p, priv->filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(offset); *p++ = htonl(readlen); *p++ = 0; len = p - &(data[0]); ret = rpc_req(priv->npriv, PROG_NFS, NFS_READ, data, len); if (ret) return ret; filedata = (uint32_t *)(nfs_packet + sizeof(struct rpc_reply)); rlen = ntohl(net_read_uint32(filedata + 18)); kfifo_put(priv->fifo, (char *)(filedata + 19), rlen); return 0; }
static void printl(const char *fmt, ...) { va_list args; int len; struct timeval now; char tbuf[256]; va_start(args, fmt); do_gettimeofday(&now); now.tv_sec -= tcpw.tstart.tv_sec; now.tv_usec -= tcpw.tstart.tv_usec; if (now.tv_usec < 0) { --now.tv_sec; now.tv_usec += 1000000; } len = sprintf(tbuf, "%lu.%06lu ", (unsigned long) now.tv_sec, (unsigned long) now.tv_usec); len += vscnprintf(tbuf+len, sizeof(tbuf)-len, fmt, args); va_end(args); kfifo_put(tcpw.fifo, tbuf, len); wake_up(&tcpw.wait); }
void mt76x2_mac_poll_tx_status(struct mt76x2_dev *dev, bool irq) { struct mt76x2_tx_status stat = {}; unsigned long flags; u8 update = 1; bool ret; if (!test_bit(MT76_STATE_RUNNING, &dev->mt76.state)) return; trace_mac_txstat_poll(dev); while (!irq || !kfifo_is_full(&dev->txstatus_fifo)) { spin_lock_irqsave(&dev->irq_lock, flags); ret = mt76x2_mac_load_tx_status(dev, &stat); spin_unlock_irqrestore(&dev->irq_lock, flags); if (!ret) break; trace_mac_txstat_fetch(dev, &stat); if (!irq) { mt76x2_send_tx_status(dev, &stat, &update); continue; } kfifo_put(&dev->txstatus_fifo, stat); } }
UNS8 canSend_driver(CAN_HANDLE fd0, Message const *m) { int i; printk(KERN_INFO "%x->[ ", (CANPipe*)fd0 - &canpipes[0]); for(i=0; i < MAX_NB_CAN_PIPES; i++) { if(canpipes[i].used && &canpipes[i] != (CANPipe*)fd0) { printk("%x ",i); } } printk(" ]"); print_message(m); // send to all readers, except myself for(i=0; i < MAX_NB_CAN_PIPES; i++) { if(canpipes[i].used && &canpipes[i] != (CANPipe*)fd0) { unsigned int len; len = kfifo_put (canpipes[i].pipe, (unsigned char *)m, sizeof(Message)); if (len != sizeof(Message)) { printk(KERN_NOTICE "can_virtual: error sending data to kernel fifo.\n"); return 1; } // wake up canReceive_driver() wake_up_interruptible (&canpipes[i].w_queue); } } return 0; }
static int tftp_write(struct device_d *_dev, FILE *f, const void *inbuf, size_t insize) { struct file_priv *priv = f->inode; size_t size, now; int ret; debug("%s: %zu\n", __func__, insize); size = insize; while (size) { now = kfifo_put(priv->fifo, inbuf, size); while (kfifo_len(priv->fifo) >= priv->blocksize) { kfifo_get(priv->fifo, priv->buf, priv->blocksize); tftp_send_write(priv, priv->buf, priv->blocksize); tftp_timer_reset(priv); while (priv->state == STATE_WAITACK) { ret = tftp_poll(priv); if (ret == TFTP_ERR_RESEND) tftp_send_write(priv, priv->buf, priv->blocksize); if (ret < 0) return ret; } } size -= now; inbuf += now; } return insize; }
/* stp_uart_tty_receive() * * Called by tty low level driver when receive data is * available. * * Arguments: tty pointer to tty isntance data * data pointer to received data * flags pointer to flags for data * count count of received data in bytes * * Return Value: None */ static void stp_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) { unsigned int fifo_avail_len;/* = LDISC_RX_FIFO_SIZE - kfifo_len(g_stp_uart_rx_fifo);*/ unsigned int how_much_put = 0; #if 0 { struct timeval now; do_gettimeofday(&now); printk("[+STP][ ][R] %4d --> sec = %lu, --> usec --> %lu\n", count, now.tv_sec, now.tv_usec); } #endif #if LDISC_RX_TASKLET_RWLOCK write_lock(&g_stp_uart_rx_handling_lock); #endif if (count > 2000) { /*this is abnormal*/ UART_ERR_FUNC("abnormal: buffer count = %d\n", count); } /*How much empty seat?*/ fifo_avail_len = LDISC_RX_FIFO_SIZE - kfifo_len(g_stp_uart_rx_fifo); if (fifo_avail_len > 0) { //UART_INFO_FUNC ("fifo left(%d), count(%d)\n", fifo_avail_len, count); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) how_much_put = kfifo_put(g_stp_uart_rx_fifo,(unsigned char *) data, count); #else how_much_put = kfifo_in(g_stp_uart_rx_fifo,(unsigned char *) data, count); #endif #if LDISC_RX_TASKLET_RWLOCK /* George Test */ write_unlock(&g_stp_uart_rx_handling_lock); #endif /*schedule it!*/ tasklet_schedule(&g_stp_uart_rx_fifo_tasklet); } else { UART_ERR_FUNC("stp_uart_tty_receive rxfifo is full!!\n"); } #if 0 { struct timeval now; do_gettimeofday(&now); printk("[-STP][ ][R] %4d --> sec = %lu, --> usec --> %lu\n", count, now.tv_sec, now.tv_usec); } #endif #if LDISC_RX_TASKLET_RWLOCK /* George Test */ //write_unlock(&g_stp_uart_rx_handling_lock); #endif }
/* Must be called with dev->event_lock held */ void __armada_drm_queue_unref_work(struct drm_device *dev, struct drm_framebuffer *fb) { struct armada_private *priv = dev->dev_private; WARN_ON(!kfifo_put(&priv->fb_unref, fb)); schedule_work(&priv->fb_unref_work); }
void srp_iu_put(struct iu_entry *iue) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33) kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *)); #else kfifo_in_locked(&iue->target->iu_queue.queue, (void *) &iue, sizeof(void *), &iue->target->iu_queue.lock); #endif }
/** * drm_flip_work_queue - queue work * @work: the flip-work * @val: the value to queue * * Queues work, that will later be run (passed back to drm_flip_func_t * func) on a work queue after drm_flip_work_commit() is called. */ void drm_flip_work_queue(struct drm_flip_work *work, void *val) { if (kfifo_put(&work->fifo, val)) { atomic_inc(&work->pending); } else { DRM_ERROR("%s fifo full!\n", work->name); work->func(work, val); } }
/* Transmitter */ static int cx25840_ir_tx_write(struct v4l2_subdev *sd, u8 *buf, size_t count, ssize_t *num) { struct cx25840_ir_state *ir_state = to_ir_state(sd); struct i2c_client *c; if (ir_state == NULL) return -ENODEV; c = ir_state->c; #if 0 /* * FIXME - the code below is an incomplete and untested sketch of what * may need to be done. The critical part is to get 4 (or 8) pulses * from the tx_kfifo, or converted from ns to the proper units from the * input, and push them off to the hardware Tx FIFO right away, if the * HW TX fifo needs service. The rest can be pushed to the tx_kfifo in * a less critical timeframe. Also watch out for overruning the * tx_kfifo - don't let it happen and let the caller know not all his * pulses were written. */ u32 *ns_pulse = (u32 *) buf; unsigned int n; u32 fifo_pulse[FIFO_TX_DEPTH]; u32 mark; /* Compute how much we can fit in the tx kfifo */ n = CX25840_IR_TX_KFIFO_SIZE - kfifo_len(ir_state->tx_kfifo); n = min(n, (unsigned int) count); n /= sizeof(u32); /* FIXME - turn on Tx Fifo service interrupt * check hardware fifo level, and other stuff */ for (i = 0; i < n; ) { for (j = 0; j < FIFO_TX_DEPTH / 2 && i < n; j++) { mark = ns_pulse[i] & LEVEL_MASK; fifo_pulse[j] = ns_to_pulse_width_count( ns_pulse[i] & ~LEVEL_MASK, ir_state->txclk_divider); if (mark) fifo_pulse[j] &= FIFO_RXTX_LVL; i++; } kfifo_put(ir_state->tx_kfifo, (u8 *) fifo_pulse, j * sizeof(u32)); } *num = n * sizeof(u32); #else /* For now enable the Tx FIFO Service interrupt & pretend we did work */ irqenable_tx(sd, IRQEN_TSE); *num = count; #endif return 0; }
static void sun4i_drv_traverse_endpoints(struct endpoint_list *list, struct device_node *node, int port_id) { struct device_node *ep, *remote, *port; port = of_graph_get_port_by_id(node, port_id); if (!port) { DRM_DEBUG_DRIVER("No output to bind on port %d\n", port_id); return; } for_each_available_child_of_node(port, ep) { remote = of_graph_get_remote_port_parent(ep); if (!remote) { DRM_DEBUG_DRIVER("Error retrieving the output node\n"); continue; } if (sun4i_drv_node_is_tcon(node)) { /* * TCON TOP is always probed before TCON. However, TCON * points back to TCON TOP when it is source for HDMI. * We have to skip it here to prevent infinite looping * between TCON TOP and TCON. */ if (sun4i_drv_node_is_tcon_top(remote)) { DRM_DEBUG_DRIVER("TCON output endpoint is TCON TOP... skipping\n"); of_node_put(remote); continue; } /* * If the node is our TCON with channel 0, the first * port is used for panel or bridges, and will not be * part of the component framework. */ if (sun4i_drv_node_is_tcon_with_ch0(node)) { struct of_endpoint endpoint; if (of_graph_parse_endpoint(ep, &endpoint)) { DRM_DEBUG_DRIVER("Couldn't parse endpoint\n"); of_node_put(remote); continue; } if (!endpoint.id) { DRM_DEBUG_DRIVER("Endpoint is our panel... skipping\n"); of_node_put(remote); continue; } } } kfifo_put(&list->fifo, remote); }
static int __init testfunc(void) { unsigned char buf[6]; unsigned char i; unsigned int ret; printk(KERN_INFO "byte stream fifo test start\n"); /* put string into the fifo */ kfifo_in(&test, "hello", 5); /* put values into the fifo */ for (i = 0; i != 10; i++) kfifo_put(&test, &i); /* show the number of used elements */ printk(KERN_INFO "fifo len: %u\n", kfifo_len(&test)); /* get max of 5 bytes from the fifo */ i = kfifo_out(&test, buf, 5); printk(KERN_INFO "buf: %.*s\n", i, buf); /* get max of 2 elements from the fifo */ ret = kfifo_out(&test, buf, 2); printk(KERN_INFO "ret: %d\n", ret); /* and put it back to the end of the fifo */ ret = kfifo_in(&test, buf, ret); printk(KERN_INFO "ret: %d\n", ret); /* put values into the fifo until is full */ for (i = 20; kfifo_put(&test, &i); i++) ; printk(KERN_INFO "queue len: %u\n", kfifo_len(&test)); /* print out all values in the fifo */ while (kfifo_get(&test, &i)) printk("%d ", i); printk("\n"); return 0; }
static void inline add2kfifo(const unsigned char *pdata,const unsigned int len) { if(kfifo_len(g_kfifo) < MAX_BUF_SIZE) { kfifo_put(g_kfifo,pdata,len); } else { kfifo_reset(g_kfifo); } }
static size_t uart16550_write(struct file *filp, const char *user_buffer, size_t size, loff_t *offset) { struct task_struct **task_user_push_data = ftask_user_push_data(filp->private_data); struct kfifo* data_from_user = fdata_from_user(filp->private_data); int i; for(i = 0; i<size; i++){ wait_for_queue(task_user_push_data,can_write,data_from_user); kfifo_put(data_from_user,charToU8(user_buffer[i])); } return size; }
static int do_write_work_in(struct threadrw_write_task *task) { struct threadrw_buf *rwbuf = NULL; int ret; int need_re_write = 0; int write_len = 0; unsigned long flags; if (kfifo_is_empty(&task->datafifo)) return 0; if (!kfifo_peek(&task->datafifo, (void *)&rwbuf)) return 0; if (task->codec_mm_buffer && !rwbuf->write_off) codec_mm_dma_flush(rwbuf->vbuffer, rwbuf->data_size, DMA_TO_DEVICE); ret = task->write(task->file, task->sbuf, (const char __user *)rwbuf->dma_handle + rwbuf->write_off, rwbuf->data_size, 3); /* noblock,phy addr */ if (ret == -EAGAIN) { need_re_write = 0; /*do later retry. */ } else if (ret >= rwbuf->data_size) { write_len += rwbuf->data_size; if (kfifo_get(&task->datafifo, (void *)&rwbuf)) { rwbuf->data_size = 0; kfifo_put(&task->freefifo, (const void *)rwbuf); /*wakeup write thread. */ wake_up_interruptible(&task->wq); } else pr_err("write ok,but kfifo_get data failed.!!!\n"); need_re_write = 1; } else if (ret > 0) { rwbuf->data_size -= ret; /* half data write */ rwbuf->write_off += ret; write_len += ret; need_re_write = 1; } else { /*ret <=0 */ pr_err("get errors ret=%d size=%d\n", ret, rwbuf->data_size); task->errors = ret; } if (write_len > 0) { task->passed_data_len += write_len; spin_lock_irqsave(&task->lock, flags); task->buffered_data_size -= write_len; spin_unlock_irqrestore(&task->lock, flags); } return need_re_write; }
static int init_task_buffers(struct threadrw_write_task *task, int num, int block_size) { struct threadrw_buf *rwbuf; int i; int used_codec_mm = 1; int buffers_num = num; if (used_codec_mm && (block_size * buffers_num) >= 128 * 1024) { int total_mm = ALIGN(block_size * buffers_num, (1 << 17)); task->codec_mm_buffer = codec_mm_alloc_for_dma(BUF_NAME, total_mm / PAGE_SIZE, 0, CODEC_MM_FLAGS_DMA_CPU); task->buffer_size = total_mm; buffers_num = total_mm / block_size; } for (i = 0; i < buffers_num; i++) { rwbuf = &task->buf[i]; rwbuf->buffer_size = block_size > 0 ? block_size : DEFAULT_BLOCK_SIZE; if (task->codec_mm_buffer) { rwbuf->buffer_size = block_size; if (i == buffers_num - 1) rwbuf->buffer_size = task->buffer_size - block_size * i; rwbuf->dma_handle = (dma_addr_t) task->codec_mm_buffer + block_size * i; rwbuf->vbuffer = codec_mm_phys_to_virt( rwbuf->dma_handle); } else { rwbuf->vbuffer = dma_alloc_coherent( amports_get_dma_device(), rwbuf->buffer_size, &rwbuf->dma_handle, GFP_KERNEL); if (!rwbuf->vbuffer) { rwbuf->buffer_size = 0; rwbuf->dma_handle = 0; task->max_buf = i + 1; break; } task->buffer_size += rwbuf->buffer_size; } kfifo_put(&task->freefifo, (const void *)rwbuf); task->max_buf = i + 1; } if (task->max_buf >= 3 || task->max_buf == num) return 0; /*must >=3 for swap buffers. */ if (task->max_buf > 0) free_task_buffers(task); return -1; }
static void tmsi_enqueue_data(struct tmsi_data *dev, const char * buffer, size_t length) { if (length == 0) return; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35) kfifo_in_spinlocked(dev->packet_buffer, buffer, length, &dev->buffer_lock); #elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32) kfifo_in_locked(dev->packet_buffer, buffer, length, &dev->buffer_lock); #else kfifo_put(dev->packet_buffer, buffer, length); #endif up(dev->fifo_sem); }
static int __init fifo_init(void) { int i, val, ret; ret = kfifo_alloc(&fifo, size * sizeof(int), GFP_KERNEL); if (ret) return -ENOMEM; printk("%s: populating fifo\n", MODNAME); for (i = 0; i < size; i++) kfifo_put(&fifo, i + 1); #if 0 printk("%s: iterating over fifo\n", MODNAME); print_fifo(&fifo); #endif /* dequeue one item -- and discard it */ if (!kfifo_get(&fifo, &val)) /* use the result and silence the compiler */; /* enqueue one more item */ kfifo_put(&fifo, size + 1); #if 0 printk("%s: iterating over updated fifo\n", MODNAME); print_fifo(&fifo); #endif printk("printing -- draining the queue\n"); i = 1; while(kfifo_get(&fifo, &val)) { printk("item[%d] = %d\n", i++, val); } printk("%s: init complete\n", MODNAME); return 0; }
static void unpin(void *arg, struct drm_gem_object *bo) { struct drm_plane *plane = arg; struct omap_plane *omap_plane = to_omap_plane(plane); if (kfifo_put(&omap_plane->unpin_fifo, (const struct drm_gem_object **)&bo)) { /* also hold a ref so it isn't free'd while pinned */ drm_gem_object_reference(bo); } else { dev_err(plane->dev->dev, "unpin fifo full!\n"); omap_gem_put_paddr(bo); } }
/** * ir_raw_event_store() - pass a pulse/space duration to the raw ir decoders * @dev: the struct rc_dev device descriptor * @ev: the struct ir_raw_event descriptor of the pulse/space * * This routine (which may be called from an interrupt context) stores a * pulse/space duration for the raw ir decoding state machines. Pulses are * signalled as positive values and spaces as negative values. A zero value * will reset the decoding state machines. */ int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev) { if (!dev->raw) return -EINVAL; IR_dprintk(2, "sample: (%05dus %s)\n", TO_US(ev->duration), TO_STR(ev->pulse)); if (!kfifo_put(&dev->raw->kfifo, *ev)) { dev_err(&dev->dev, "IR event FIFO is full!\n"); return -ENOSPC; } return 0; }
static int gs_put_char(struct tty_struct *tty, unsigned char ch) { struct gs_port *port = tty->driver_data; unsigned long flags; int status; pr_vdebug("gs_put_char: (%d,%p) char=0x%x, called from %ps\n", port->port_num, tty, ch, __builtin_return_address(0)); spin_lock_irqsave(&port->port_lock, flags); status = kfifo_put(&port->port_write_buf, ch); spin_unlock_irqrestore(&port->port_lock, flags); return status; }
/* Must be called with dev->event_lock held */ void __armada_drm_queue_unref_work(struct drm_device *dev, struct drm_framebuffer *fb) { struct armada_private *priv = dev->dev_private; /* * Yes, we really must jump through these hoops just to store a * _pointer_ to something into the kfifo. This is utterly insane * and idiotic, because it kfifo requires the _data_ pointed to by * the pointer const, not the pointer itself. Not only that, but * you have to pass a pointer _to_ the pointer you want stored. */ const struct drm_framebuffer *silly_api_alert = fb; WARN_ON(!kfifo_put(&priv->fb_unref, &silly_api_alert)); schedule_work(&priv->fb_unref_work); }
void BSP_Ser_WrStr_To_Buffer( char *p_str ) { CPU_INT16U len; CPU_INT16U temp; len = strlen( p_str ); temp = kfifo_get_free_space( &DBG_UART_Send_kFIFO ); if( len > temp ) { len = temp ; debug_uart_fifo_oveflow_counter++ ; } kfifo_put( &DBG_UART_Send_kFIFO, (unsigned char *)p_str, len); }