From 8995a39d6d030b48633c9a2ed85d3244907acff0 Mon Sep 17 00:00:00 2001 From: Alex Elder Date: Tue, 27 Oct 2015 22:18:39 -0500 Subject: [PATCH] greybus: es2: move logging fifo into es2 struct Continue moving the logging data structures into the es2 AP data structure rather than having it be a single global. This patch moves the fifo. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/es2.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index a4b54d3593a4..3de5ba192a90 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -31,7 +31,6 @@ MODULE_DEVICE_TABLE(usb, id_table); #define APB1_LOG_SIZE SZ_16K static struct dentry *apb1_log_dentry; static struct dentry *apb1_log_enable_dentry; -static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE); /* Number of bulk in and bulk out couple */ #define NUM_BULKS 7 @@ -98,6 +97,7 @@ struct es2_cport_out { * @cport_out_urb_lock: locks the @cport_out_urb_busy "list" * * @apb1_log_task: task pointer for logging thread + * @apb1_log_fifo: kernel FIFO to carry logged data */ struct es2_ap_dev { struct usb_device *usb_dev; @@ -114,6 +114,7 @@ struct es2_ap_dev { int *cport_to_ep; struct task_struct *apb1_log_task; + DECLARE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE); }; /** @@ -629,7 +630,7 @@ static void apb1_log_get(struct es2_ap_dev *es2, char *buf) APB1_LOG_MSG_SIZE, ES2_TIMEOUT); if (retval > 0) - kfifo_in(&apb1_log_fifo, buf, retval); + kfifo_in(&es2->apb1_log_fifo, buf, retval); } while (retval > 0); } @@ -655,6 +656,7 @@ static int apb1_log_poll(void *data) static ssize_t apb1_log_read(struct file *f, char __user *buf, size_t count, loff_t *ppos) { + struct es2_ap_dev *es2 = f->f_inode->i_private; ssize_t ret; size_t copied; char *tmp_buf; @@ -666,7 +668,7 @@ static ssize_t apb1_log_read(struct file *f, char __user *buf, if (!tmp_buf) return -ENOMEM; - copied = kfifo_out(&apb1_log_fifo, tmp_buf, count); + copied = kfifo_out(&es2->apb1_log_fifo, tmp_buf, count); ret = simple_read_from_buffer(buf, count, ppos, tmp_buf, copied); kfree(tmp_buf); @@ -815,6 +817,7 @@ static int ap_probe(struct usb_interface *interface, es2->usb_intf = interface; es2->usb_dev = udev; spin_lock_init(&es2->cport_out_urb_lock); + INIT_KFIFO(es2->apb1_log_fifo); usb_set_intfdata(interface, es2); es2->cport_to_ep = kcalloc(hd->num_cports, sizeof(*es2->cport_to_ep), -- 2.11.0