Skip to content

Commit

Permalink
kfifo: rename kfifo_put... into kfifo_in... and kfifo_get... into kfi…
Browse files Browse the repository at this point in the history
…fo_out...

rename kfifo_put...  into kfifo_in...  to prevent miss use of old non in
kernel-tree drivers

ditto for kfifo_get...  -> kfifo_out...

Improve the prototypes of kfifo_in and kfifo_out to make the kerneldoc
annotations more readable.

Add mini "howto porting to the new API" in kfifo.h

Signed-off-by: Stefani Seibold <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Acked-by: Mauro Carvalho Chehab <[email protected]>
Acked-by: Andi Kleen <[email protected]>
Acked-by: Arnd Bergmann <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sstefani authored and torvalds committed Dec 22, 2009
1 parent e64c026 commit 7acd72e
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 81 deletions.
4 changes: 2 additions & 2 deletions drivers/char/nozomi.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ static int send_data(enum port_type index, struct nozomi *dc)
struct tty_struct *tty = tty_port_tty_get(&port->port);

/* Get data from tty and place in buf for now */
size = kfifo_get(&port->fifo_ul, dc->send_buf,
size = kfifo_out(&port->fifo_ul, dc->send_buf,
ul_size < SEND_BUF_MAX ? ul_size : SEND_BUF_MAX);

if (size == 0) {
Expand Down Expand Up @@ -1672,7 +1672,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer,
goto exit;
}

rval = kfifo_put(&port->fifo_ul, (unsigned char *)buffer, count);
rval = kfifo_in(&port->fifo_ul, (unsigned char *)buffer, count);

/* notify card */
if (unlikely(dc == NULL)) {
Expand Down
8 changes: 4 additions & 4 deletions drivers/char/sonypi.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static void input_keyrelease(struct work_struct *work)
{
struct sonypi_keypress kp;

while (kfifo_get_locked(&sonypi_device.input_fifo, (unsigned char *)&kp,
while (kfifo_out_locked(&sonypi_device.input_fifo, (unsigned char *)&kp,
sizeof(kp), &sonypi_device.input_fifo_lock)
== sizeof(kp)) {
msleep(10);
Expand Down Expand Up @@ -828,7 +828,7 @@ static void sonypi_report_input_event(u8 event)
if (kp.dev) {
input_report_key(kp.dev, kp.key, 1);
input_sync(kp.dev);
kfifo_put_locked(&sonypi_device.input_fifo,
kfifo_in_locked(&sonypi_device.input_fifo,
(unsigned char *)&kp, sizeof(kp),
&sonypi_device.input_fifo_lock);
schedule_work(&sonypi_device.input_work);
Expand Down Expand Up @@ -882,7 +882,7 @@ static irqreturn_t sonypi_irq(int irq, void *dev_id)
acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
#endif

kfifo_put_locked(&sonypi_device.fifo, (unsigned char *)&event,
kfifo_in_locked(&sonypi_device.fifo, (unsigned char *)&event,
sizeof(event), &sonypi_device.fifo_lock);
kill_fasync(&sonypi_device.fifo_async, SIGIO, POLL_IN);
wake_up_interruptible(&sonypi_device.fifo_proc_list);
Expand Down Expand Up @@ -932,7 +932,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
return ret;

while (ret < count &&
(kfifo_get_locked(&sonypi_device.fifo, &c, sizeof(c),
(kfifo_out_locked(&sonypi_device.fifo, &c, sizeof(c),
&sonypi_device.fifo_lock) == sizeof(c))) {
if (put_user(c, buf++))
return -EFAULT;
Expand Down
16 changes: 8 additions & 8 deletions drivers/infiniband/hw/cxgb3/cxio_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
return -ENOMEM;

for (i = 0; i < skip_low + skip_high; i++)
kfifo_put(fifo, (unsigned char *) &entry, sizeof(u32));
kfifo_in(fifo, (unsigned char *) &entry, sizeof(u32));
if (random) {
j = 0;
random_bytes = random32();
Expand All @@ -71,22 +71,22 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
random_bytes = random32();
}
idx = (random_bytes >> (j * 2)) & 0xF;
kfifo_put(fifo,
kfifo_in(fifo,
(unsigned char *) &rarray[idx],
sizeof(u32));
rarray[idx] = i;
j++;
}
for (i = 0; i < RANDOM_SIZE; i++)
kfifo_put(fifo,
kfifo_in(fifo,
(unsigned char *) &rarray[i],
sizeof(u32));
} else
for (i = skip_low; i < nr - skip_high; i++)
kfifo_put(fifo, (unsigned char *) &i, sizeof(u32));
kfifo_in(fifo, (unsigned char *) &i, sizeof(u32));

for (i = 0; i < skip_low + skip_high; i++)
kfifo_get_locked(fifo, (unsigned char *) &entry,
kfifo_out_locked(fifo, (unsigned char *) &entry,
sizeof(u32), fifo_lock);
return 0;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p)

for (i = 16; i < T3_MAX_NUM_QP; i++)
if (!(i & rdev_p->qpmask))
kfifo_put(&rdev_p->rscp->qpid_fifo,
kfifo_in(&rdev_p->rscp->qpid_fifo,
(unsigned char *) &i, sizeof(u32));
return 0;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ int cxio_hal_init_resource(struct cxio_rdev *rdev_p,
static u32 cxio_hal_get_resource(struct kfifo *fifo, spinlock_t * lock)
{
u32 entry;
if (kfifo_get_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock))
if (kfifo_out_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock))
return entry;
else
return 0; /* fifo emptry */
Expand All @@ -190,7 +190,7 @@ static void cxio_hal_put_resource(struct kfifo *fifo, spinlock_t * lock,
u32 entry)
{
BUG_ON(
kfifo_put_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock)
kfifo_in_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock)
== 0);
}

Expand Down
16 changes: 8 additions & 8 deletions drivers/media/video/meye.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ static irqreturn_t meye_irq(int irq, void *dev_id)
return IRQ_HANDLED;

if (meye.mchip_mode == MCHIP_HIC_MODE_CONT_OUT) {
if (kfifo_get_locked(&meye.grabq, (unsigned char *)&reqnr,
if (kfifo_out_locked(&meye.grabq, (unsigned char *)&reqnr,
sizeof(int), &meye.grabq_lock) != sizeof(int)) {
mchip_free_frame();
return IRQ_HANDLED;
Expand All @@ -811,7 +811,7 @@ static irqreturn_t meye_irq(int irq, void *dev_id)
meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
meye.grab_buffer[reqnr].sequence = sequence++;
kfifo_put_locked(&meye.doneq, (unsigned char *)&reqnr,
kfifo_in_locked(&meye.doneq, (unsigned char *)&reqnr,
sizeof(int), &meye.doneq_lock);
wake_up_interruptible(&meye.proc_list);
} else {
Expand All @@ -821,7 +821,7 @@ static irqreturn_t meye_irq(int irq, void *dev_id)
mchip_free_frame();
goto again;
}
if (kfifo_get_locked(&meye.grabq, (unsigned char *)&reqnr,
if (kfifo_out_locked(&meye.grabq, (unsigned char *)&reqnr,
sizeof(int), &meye.grabq_lock) != sizeof(int)) {
mchip_free_frame();
goto again;
Expand All @@ -832,7 +832,7 @@ static irqreturn_t meye_irq(int irq, void *dev_id)
meye.grab_buffer[reqnr].state = MEYE_BUF_DONE;
do_gettimeofday(&meye.grab_buffer[reqnr].timestamp);
meye.grab_buffer[reqnr].sequence = sequence++;
kfifo_put_locked(&meye.doneq, (unsigned char *)&reqnr,
kfifo_in_locked(&meye.doneq, (unsigned char *)&reqnr,
sizeof(int), &meye.doneq_lock);
wake_up_interruptible(&meye.proc_list);
}
Expand Down Expand Up @@ -935,7 +935,7 @@ static int meyeioc_qbuf_capt(int *nb)
mchip_cont_compression_start();

meye.grab_buffer[*nb].state = MEYE_BUF_USING;
kfifo_put_locked(&meye.grabq, (unsigned char *)nb, sizeof(int),
kfifo_in_locked(&meye.grabq, (unsigned char *)nb, sizeof(int),
&meye.grabq_lock);
mutex_unlock(&meye.lock);

Expand Down Expand Up @@ -968,7 +968,7 @@ static int meyeioc_sync(struct file *file, void *fh, int *i)
/* fall through */
case MEYE_BUF_DONE:
meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
kfifo_get_locked(&meye.doneq, (unsigned char *)&unused,
kfifo_out_locked(&meye.doneq, (unsigned char *)&unused,
sizeof(int), &meye.doneq_lock);
}
*i = meye.grab_buffer[*i].size;
Expand Down Expand Up @@ -1456,7 +1456,7 @@ static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
buf->flags |= V4L2_BUF_FLAG_QUEUED;
buf->flags &= ~V4L2_BUF_FLAG_DONE;
meye.grab_buffer[buf->index].state = MEYE_BUF_USING;
kfifo_put_locked(&meye.grabq, (unsigned char *)&buf->index,
kfifo_in_locked(&meye.grabq, (unsigned char *)&buf->index,
sizeof(int), &meye.grabq_lock);
mutex_unlock(&meye.lock);

Expand All @@ -1483,7 +1483,7 @@ static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
return -EINTR;
}

if (!kfifo_get_locked(&meye.doneq, (unsigned char *)&reqnr,
if (!kfifo_out_locked(&meye.doneq, (unsigned char *)&reqnr,
sizeof(int), &meye.doneq_lock)) {
mutex_unlock(&meye.lock);
return -EBUSY;
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/wireless/libertas/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ static int lbs_thread(void *data)
spin_lock_irq(&priv->driver_lock);
while (kfifo_len(&priv->event_fifo)) {
u32 event;
kfifo_get(&priv->event_fifo, (unsigned char *) &event,

kfifo_out(&priv->event_fifo, (unsigned char *) &event,
sizeof(event));
spin_unlock_irq(&priv->driver_lock);
lbs_process_event(priv, event);
Expand Down Expand Up @@ -1175,7 +1176,7 @@ void lbs_queue_event(struct lbs_private *priv, u32 event)
if (priv->psstate == PS_STATE_SLEEP)
priv->psstate = PS_STATE_AWAKE;

kfifo_put(&priv->event_fifo, (unsigned char *) &event, sizeof(u32));
kfifo_in(&priv->event_fifo, (unsigned char *) &event, sizeof(u32));

wake_up_interruptible(&priv->waitq);

Expand Down
4 changes: 2 additions & 2 deletions drivers/platform/x86/fujitsu-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
vdbg_printk(FUJLAPTOP_DBG_TRACE,
"Push keycode into ringbuffer [%d]\n",
keycode);
status = kfifo_put_locked(&fujitsu_hotkey->fifo,
status = kfifo_in_locked(&fujitsu_hotkey->fifo,
(unsigned char *)&keycode,
sizeof(keycode),
&fujitsu_hotkey->fifo_lock);
Expand All @@ -1020,7 +1020,7 @@ static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event)
}
} else if (keycode == 0) {
while ((status =
kfifo_get_locked(
kfifo_out_locked(
&fujitsu_hotkey->fifo,
(unsigned char *) &keycode_r,
sizeof(keycode_r),
Expand Down
8 changes: 4 additions & 4 deletions drivers/platform/x86/sony-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ static void do_sony_laptop_release_key(struct work_struct *work)
{
struct sony_laptop_keypress kp;

while (kfifo_get_locked(&sony_laptop_input.fifo, (unsigned char *)&kp,
while (kfifo_out_locked(&sony_laptop_input.fifo, (unsigned char *)&kp,
sizeof(kp), &sony_laptop_input.fifo_lock)
== sizeof(kp)) {
msleep(10);
Expand Down Expand Up @@ -363,7 +363,7 @@ static void sony_laptop_report_input_event(u8 event)
/* we emit the scancode so we can always remap the key */
input_event(kp.dev, EV_MSC, MSC_SCAN, event);
input_sync(kp.dev);
kfifo_put_locked(&sony_laptop_input.fifo,
kfifo_in_locked(&sony_laptop_input.fifo,
(unsigned char *)&kp, sizeof(kp),
&sony_laptop_input.fifo_lock);

Expand Down Expand Up @@ -2130,7 +2130,7 @@ static ssize_t sonypi_misc_read(struct file *file, char __user *buf,
return ret;

while (ret < count &&
(kfifo_get_locked(&sonypi_compat.fifo, &c, sizeof(c),
(kfifo_out_locked(&sonypi_compat.fifo, &c, sizeof(c),
&sonypi_compat.fifo_lock) == sizeof(c))) {
if (put_user(c, buf++))
return -EFAULT;
Expand Down Expand Up @@ -2310,7 +2310,7 @@ static struct miscdevice sonypi_misc_device = {

static void sonypi_compat_report_event(u8 event)
{
kfifo_put_locked(&sonypi_compat.fifo, (unsigned char *)&event,
kfifo_in_locked(&sonypi_compat.fifo, (unsigned char *)&event,
sizeof(event), &sonypi_compat.fifo_lock);
kill_fasync(&sonypi_compat.fifo_async, SIGIO, POLL_IN);
wake_up_interruptible(&sonypi_compat.fifo_proc_list);
Expand Down
14 changes: 7 additions & 7 deletions drivers/scsi/libiscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ static void iscsi_free_task(struct iscsi_task *task)
if (conn->login_task == task)
return;

kfifo_put(&session->cmdpool.queue, (void*)&task, sizeof(void*));
kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));

if (sc) {
task->sc = NULL;
Expand Down Expand Up @@ -737,7 +737,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);

if (!kfifo_get(&session->cmdpool.queue,
if (!kfifo_out(&session->cmdpool.queue,
(void*)&task, sizeof(void*)))
return NULL;
}
Expand Down Expand Up @@ -1567,7 +1567,7 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn,
{
struct iscsi_task *task;

if (!kfifo_get(&conn->session->cmdpool.queue,
if (!kfifo_out(&conn->session->cmdpool.queue,
(void *) &task, sizeof(void *)))
return NULL;

Expand Down Expand Up @@ -2469,7 +2469,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
q->max = i;
goto enomem;
}
kfifo_put(&q->queue, (void*)&q->pool[i], sizeof(void*));
kfifo_in(&q->queue, (void*)&q->pool[i], sizeof(void*));
}

if (items) {
Expand Down Expand Up @@ -2819,7 +2819,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,

/* allocate login_task used for the login/text sequences */
spin_lock_bh(&session->lock);
if (!kfifo_get(&session->cmdpool.queue,
if (!kfifo_out(&session->cmdpool.queue,
(void*)&conn->login_task,
sizeof(void*))) {
spin_unlock_bh(&session->lock);
Expand All @@ -2839,7 +2839,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
return cls_conn;

login_task_data_alloc_fail:
kfifo_put(&session->cmdpool.queue, (void*)&conn->login_task,
kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
sizeof(void*));
login_task_alloc_fail:
iscsi_destroy_conn(cls_conn);
Expand Down Expand Up @@ -2902,7 +2902,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
free_pages((unsigned long) conn->data,
get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
kfree(conn->persistent_address);
kfifo_put(&session->cmdpool.queue, (void*)&conn->login_task,
kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
sizeof(void*));
if (session->leadconn == conn)
session->leadconn = NULL;
Expand Down
18 changes: 9 additions & 9 deletions drivers/scsi/libiscsi_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
return;

/* flush task's r2t queues */
while (kfifo_get(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
while (kfifo_out(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
sizeof(void*));
ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n");
}

r2t = tcp_task->r2t;
if (r2t != NULL) {
kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
sizeof(void*));
tcp_task->r2t = NULL;
}
Expand Down Expand Up @@ -541,7 +541,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
return 0;
}

rc = kfifo_get(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
rc = kfifo_out(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
if (!rc) {
iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. "
"Target has sent more R2Ts than it "
Expand All @@ -554,7 +554,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
if (r2t->data_length == 0) {
iscsi_conn_printk(KERN_ERR, conn,
"invalid R2T with zero data len\n");
kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
sizeof(void*));
return ISCSI_ERR_DATALEN;
}
Expand All @@ -570,7 +570,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
"invalid R2T with data len %u at offset %u "
"and total length %d\n", r2t->data_length,
r2t->data_offset, scsi_out(task->sc)->length);
kfifo_put(&tcp_task->r2tpool.queue, (void*)&r2t,
kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
sizeof(void*));
return ISCSI_ERR_DATALEN;
}
Expand All @@ -580,7 +580,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
r2t->sent = 0;

tcp_task->exp_datasn = r2tsn + 1;
kfifo_put(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
kfifo_in(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
conn->r2t_pdus_cnt++;

iscsi_requeue_task(task);
Expand Down Expand Up @@ -982,15 +982,15 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
if (r2t->data_length <= r2t->sent) {
ISCSI_DBG_TCP(task->conn,
" done with r2t %p\n", r2t);
kfifo_put(&tcp_task->r2tpool.queue,
kfifo_in(&tcp_task->r2tpool.queue,
(void *)&tcp_task->r2t,
sizeof(void *));
tcp_task->r2t = r2t = NULL;
}
}

if (r2t == NULL) {
kfifo_get(&tcp_task->r2tqueue,
kfifo_out(&tcp_task->r2tqueue,
(void *)&tcp_task->r2t, sizeof(void *));
r2t = tcp_task->r2t;
}
Expand Down
Loading

0 comments on commit 7acd72e

Please sign in to comment.