Commit 0c264c6f authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: es1: separate usb_log enable/disable logic into different functions

One function shouldn't do two different things depending on a parameter
passed to it, so split usb_log_enable() into usb_log_disable()
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent efdc4313
...@@ -101,7 +101,8 @@ static inline struct es1_ap_dev *hd_to_es1(struct greybus_host_device *hd) ...@@ -101,7 +101,8 @@ static inline struct es1_ap_dev *hd_to_es1(struct greybus_host_device *hd)
} }
static void cport_out_callback(struct urb *urb); static void cport_out_callback(struct urb *urb);
static void usb_log_enable(struct es1_ap_dev *es1, int enable); static void usb_log_enable(struct es1_ap_dev *es1);
static void usb_log_disable(struct es1_ap_dev *es1);
/* /*
* Buffer constraints for the host driver. * Buffer constraints for the host driver.
...@@ -337,7 +338,7 @@ static void ap_disconnect(struct usb_interface *interface) ...@@ -337,7 +338,7 @@ static void ap_disconnect(struct usb_interface *interface)
if (!es1) if (!es1)
return; return;
usb_log_enable(es1, 0); usb_log_disable(es1);
/* Tear down everything! */ /* Tear down everything! */
for (i = 0; i < NUM_CPORT_OUT_URB; ++i) { for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
...@@ -544,12 +545,11 @@ static const struct file_operations apb1_log_fops = { ...@@ -544,12 +545,11 @@ static const struct file_operations apb1_log_fops = {
.read = apb1_log_read, .read = apb1_log_read,
}; };
static void usb_log_enable(struct es1_ap_dev *es1, int enable) static void usb_log_enable(struct es1_ap_dev *es1)
{ {
if (enable && apb1_log_task != NULL) if (apb1_log_task != NULL)
return; return;
if (enable) {
/* get log from APB1 */ /* get log from APB1 */
apb1_log_task = kthread_run(apb1_log_poll, es1, "apb1_log"); apb1_log_task = kthread_run(apb1_log_poll, es1, "apb1_log");
if (apb1_log_task == ERR_PTR(-ENOMEM)) if (apb1_log_task == ERR_PTR(-ENOMEM))
...@@ -557,15 +557,18 @@ static void usb_log_enable(struct es1_ap_dev *es1, int enable) ...@@ -557,15 +557,18 @@ static void usb_log_enable(struct es1_ap_dev *es1, int enable)
apb1_log_dentry = debugfs_create_file("apb1_log", S_IRUGO, apb1_log_dentry = debugfs_create_file("apb1_log", S_IRUGO,
gb_debugfs_get(), NULL, gb_debugfs_get(), NULL,
&apb1_log_fops); &apb1_log_fops);
} else { }
static void usb_log_disable(struct es1_ap_dev *es1)
{
if (apb1_log_task == NULL)
return;
debugfs_remove(apb1_log_dentry); debugfs_remove(apb1_log_dentry);
apb1_log_dentry = NULL; apb1_log_dentry = NULL;
if (apb1_log_task) {
kthread_stop(apb1_log_task); kthread_stop(apb1_log_task);
apb1_log_task = NULL; apb1_log_task = NULL;
}
}
} }
static ssize_t apb1_log_enable_read(struct file *f, char __user *buf, static ssize_t apb1_log_enable_read(struct file *f, char __user *buf,
...@@ -590,7 +593,7 @@ static ssize_t apb1_log_enable_write(struct file *f, const char __user *buf, ...@@ -590,7 +593,7 @@ static ssize_t apb1_log_enable_write(struct file *f, const char __user *buf,
return retval; return retval;
if (enable) { if (enable) {
usb_log_enable(es1, enable); usb_log_enable(es1);
retval = count; retval = count;
} else { } else {
retval = -EINVAL; retval = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment