Loading drivers/usb/gadget/function/f_gsi.c +46 −43 Original line number Diff line number Diff line Loading @@ -269,21 +269,15 @@ static void gsi_rw_timer_func(unsigned long arg) static struct f_gsi *get_connected_gsi(void) { struct f_gsi *connected_gsi; bool gsi_connected = false; int i; for (i = 0; i < IPA_USB_MAX_TETH_PROT_SIZE; i++) { for (i = 0; i < USB_PROT_MAX; i++) { connected_gsi = __gsi[i]; if (connected_gsi && atomic_read(&connected_gsi->connected)) { gsi_connected = true; break; } if (connected_gsi && atomic_read(&connected_gsi->connected)) return connected_gsi; } if (!gsi_connected) connected_gsi = NULL; return connected_gsi; return NULL; } #define DEFAULT_RW_TIMER_INTERVAL 500 /* in ms */ Loading @@ -291,15 +285,12 @@ static ssize_t usb_gsi_rw_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct f_gsi *gsi; struct usb_function *func; struct usb_gadget *gadget; u8 input; int i; int ret; gsi = get_connected_gsi(); if (!gsi) { log_event_dbg("%s: gsi not connected\n", __func__); goto err; } if (ubuf == NULL) { log_event_dbg("%s: buffer is Null.\n", __func__); goto err; Loading @@ -311,25 +302,35 @@ static ssize_t usb_gsi_rw_write(struct file *file, goto err; } if (gsi->debugfs_rw_timer_enable == !!input) { if (!!input) log_event_dbg("%s: RW already enabled\n", __func__); else log_event_dbg("%s: RW already disabled\n", __func__); goto err; } for (i = 0; i < USB_PROT_MAX; i++) { gsi = __gsi[i]; if (gsi && atomic_read(&gsi->connected)) { func = &gsi->function; gadget = func->config->cdev->gadget; gsi->debugfs_rw_timer_enable = !!input; if (gadget->speed >= USB_SPEED_SUPER && !func->func_is_suspended) { gsi->debugfs_rw_timer_enable = 0; del_timer_sync(&gsi->gsi_rw_timer); continue; } if (gsi->debugfs_rw_timer_enable) { mod_timer(&gsi->gsi_rw_timer, jiffies + msecs_to_jiffies(gsi->gsi_rw_timer_interval)); log_event_dbg("%s: timer initialized\n", __func__); log_event_dbg("%s: timer initialized\n", __func__); } else { del_timer_sync(&gsi->gsi_rw_timer); log_event_dbg("%s: timer deleted\n", __func__); } if (gadget->speed < USB_SPEED_SUPER) break; } } err: return count; } Loading @@ -338,14 +339,16 @@ static int usb_gsi_rw_show(struct seq_file *s, void *unused) { struct f_gsi *gsi; int i; u8 enable = 0; gsi = get_connected_gsi(); if (!gsi) { log_event_dbg("%s: gsi not connected\n", __func__); return 0; for (i = 0; i < USB_PROT_MAX; i++) { gsi = __gsi[i]; if (gsi && atomic_read(&gsi->connected)) enable |= gsi->debugfs_rw_timer_enable; } seq_printf(s, "%d\n", gsi->debugfs_rw_timer_enable); seq_printf(s, "%d\n", enable); return 0; } Loading @@ -369,14 +372,9 @@ static ssize_t usb_gsi_rw_timer_write(struct file *file, { struct f_gsi *gsi; u16 timer_val; int i; int ret; gsi = get_connected_gsi(); if (!gsi) { log_event_dbg("%s: gsi not connected\n", __func__); goto err; } if (ubuf == NULL) { log_event_dbg("%s: buffer is NULL.\n", __func__); goto err; Loading @@ -393,7 +391,12 @@ static ssize_t usb_gsi_rw_timer_write(struct file *file, goto err; } for (i = 0; i < USB_PROT_MAX; i++) { gsi = __gsi[i]; if (gsi && atomic_read(&gsi->connected)) gsi->gsi_rw_timer_interval = timer_val; } err: return count; } Loading Loading
drivers/usb/gadget/function/f_gsi.c +46 −43 Original line number Diff line number Diff line Loading @@ -269,21 +269,15 @@ static void gsi_rw_timer_func(unsigned long arg) static struct f_gsi *get_connected_gsi(void) { struct f_gsi *connected_gsi; bool gsi_connected = false; int i; for (i = 0; i < IPA_USB_MAX_TETH_PROT_SIZE; i++) { for (i = 0; i < USB_PROT_MAX; i++) { connected_gsi = __gsi[i]; if (connected_gsi && atomic_read(&connected_gsi->connected)) { gsi_connected = true; break; } if (connected_gsi && atomic_read(&connected_gsi->connected)) return connected_gsi; } if (!gsi_connected) connected_gsi = NULL; return connected_gsi; return NULL; } #define DEFAULT_RW_TIMER_INTERVAL 500 /* in ms */ Loading @@ -291,15 +285,12 @@ static ssize_t usb_gsi_rw_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct f_gsi *gsi; struct usb_function *func; struct usb_gadget *gadget; u8 input; int i; int ret; gsi = get_connected_gsi(); if (!gsi) { log_event_dbg("%s: gsi not connected\n", __func__); goto err; } if (ubuf == NULL) { log_event_dbg("%s: buffer is Null.\n", __func__); goto err; Loading @@ -311,25 +302,35 @@ static ssize_t usb_gsi_rw_write(struct file *file, goto err; } if (gsi->debugfs_rw_timer_enable == !!input) { if (!!input) log_event_dbg("%s: RW already enabled\n", __func__); else log_event_dbg("%s: RW already disabled\n", __func__); goto err; } for (i = 0; i < USB_PROT_MAX; i++) { gsi = __gsi[i]; if (gsi && atomic_read(&gsi->connected)) { func = &gsi->function; gadget = func->config->cdev->gadget; gsi->debugfs_rw_timer_enable = !!input; if (gadget->speed >= USB_SPEED_SUPER && !func->func_is_suspended) { gsi->debugfs_rw_timer_enable = 0; del_timer_sync(&gsi->gsi_rw_timer); continue; } if (gsi->debugfs_rw_timer_enable) { mod_timer(&gsi->gsi_rw_timer, jiffies + msecs_to_jiffies(gsi->gsi_rw_timer_interval)); log_event_dbg("%s: timer initialized\n", __func__); log_event_dbg("%s: timer initialized\n", __func__); } else { del_timer_sync(&gsi->gsi_rw_timer); log_event_dbg("%s: timer deleted\n", __func__); } if (gadget->speed < USB_SPEED_SUPER) break; } } err: return count; } Loading @@ -338,14 +339,16 @@ static int usb_gsi_rw_show(struct seq_file *s, void *unused) { struct f_gsi *gsi; int i; u8 enable = 0; gsi = get_connected_gsi(); if (!gsi) { log_event_dbg("%s: gsi not connected\n", __func__); return 0; for (i = 0; i < USB_PROT_MAX; i++) { gsi = __gsi[i]; if (gsi && atomic_read(&gsi->connected)) enable |= gsi->debugfs_rw_timer_enable; } seq_printf(s, "%d\n", gsi->debugfs_rw_timer_enable); seq_printf(s, "%d\n", enable); return 0; } Loading @@ -369,14 +372,9 @@ static ssize_t usb_gsi_rw_timer_write(struct file *file, { struct f_gsi *gsi; u16 timer_val; int i; int ret; gsi = get_connected_gsi(); if (!gsi) { log_event_dbg("%s: gsi not connected\n", __func__); goto err; } if (ubuf == NULL) { log_event_dbg("%s: buffer is NULL.\n", __func__); goto err; Loading @@ -393,7 +391,12 @@ static ssize_t usb_gsi_rw_timer_write(struct file *file, goto err; } for (i = 0; i < USB_PROT_MAX; i++) { gsi = __gsi[i]; if (gsi && atomic_read(&gsi->connected)) gsi->gsi_rw_timer_interval = timer_val; } err: return count; } Loading