Loading drivers/usb/gadget/function/f_accessory.c +9 −6 Original line number Diff line number Diff line Loading @@ -567,8 +567,7 @@ static ssize_t acc_read(struct file *fp, char __user *buf, { struct acc_dev *dev = fp->private_data; struct usb_request *req; ssize_t r = count; unsigned xfer; ssize_t r = count, xfer, len; int ret = 0; pr_debug("acc_read(%zu)\n", count); Loading @@ -589,6 +588,8 @@ static ssize_t acc_read(struct file *fp, char __user *buf, goto done; } len = ALIGN(count, dev->ep_out->maxpacket); if (dev->rx_done) { // last req cancelled. try to get it. req = dev->rx_req[0]; Loading @@ -598,7 +599,7 @@ static ssize_t acc_read(struct file *fp, char __user *buf, requeue_req: /* queue a request */ req = dev->rx_req[0]; req->length = count; req->length = len; dev->rx_done = 0; ret = usb_ep_queue(dev->ep_out, req, GFP_KERNEL); if (ret < 0) { Loading Loading @@ -912,6 +913,8 @@ int acc_ctrlrequest(struct usb_composite_dev *cdev, memset(dev->serial, 0, sizeof(dev->serial)); dev->start_requested = 0; dev->audio_mode = 0; strlcpy(dev->manufacturer, "Android", ACC_STRING_SIZE); strlcpy(dev->model, "Android", ACC_STRING_SIZE); } } Loading Loading @@ -1214,13 +1217,13 @@ static int acc_setup(void) INIT_DELAYED_WORK(&dev->start_work, acc_start_work); INIT_WORK(&dev->hid_work, acc_hid_work); /* _acc_dev must be set before calling usb_gadget_register_driver */ _acc_dev = dev; ret = misc_register(&acc_device); if (ret) goto err; /* _acc_dev must be set before calling usb_gadget_register_driver */ _acc_dev = dev; return 0; err: Loading drivers/usb/gadget/function/f_cdev.c +57 −0 Original line number Diff line number Diff line Loading @@ -348,6 +348,23 @@ static inline struct f_cdev *cser_to_port(struct cserial *cser) return container_of(cser, struct f_cdev, port_usb); } static unsigned int convert_uart_sigs_to_acm(unsigned int uart_sig) { unsigned int acm_sig = 0; /* should this needs to be in calling functions ??? */ uart_sig &= (TIOCM_RI | TIOCM_CD | TIOCM_DSR); if (uart_sig & TIOCM_RI) acm_sig |= ACM_CTRL_RI; if (uart_sig & TIOCM_CD) acm_sig |= ACM_CTRL_DCD; if (uart_sig & TIOCM_DSR) acm_sig |= ACM_CTRL_DSR; return acm_sig; } static unsigned int convert_acm_sigs_to_uart(unsigned int acm_sig) { unsigned int uart_sig = 0; Loading Loading @@ -1357,6 +1374,12 @@ static int f_cdev_tiocmget(struct f_cdev *port) if (cser->serial_state & TIOCM_RI) result |= TIOCM_RI; if (cser->serial_state & TIOCM_DSR) result |= TIOCM_DSR; if (cser->serial_state & TIOCM_CTS) result |= TIOCM_CTS; return result; } Loading Loading @@ -1397,6 +1420,24 @@ static int f_cdev_tiocmset(struct f_cdev *port, } } if (set & TIOCM_DSR) cser->serial_state |= TIOCM_DSR; if (clear & TIOCM_DSR) cser->serial_state &= ~TIOCM_DSR; if (set & TIOCM_CTS) { if (cser->send_break) { cser->serial_state |= TIOCM_CTS; status = cser->send_break(cser, 0); } } if (clear & TIOCM_CTS) { if (cser->send_break) { cser->serial_state &= ~TIOCM_CTS; status = cser->send_break(cser, 1); } } return status; } Loading Loading @@ -1447,7 +1488,9 @@ static void usb_cser_notify_modem(void *fport, int ctrl_bits) { int temp; struct f_cdev *port = fport; struct cserial *cser; cser = &port->port_usb; if (!port) { pr_err("port is null\n"); return; Loading @@ -1463,6 +1506,17 @@ static void usb_cser_notify_modem(void *fport, int ctrl_bits) port->cbits_to_modem = temp; port->cbits_updated = true; /* if DTR is high, update latest modem info to laptop */ if (port->cbits_to_modem & TIOCM_DTR) { unsigned int result; unsigned int cbits_to_laptop; result = f_cdev_tiocmget(port); cbits_to_laptop = convert_uart_sigs_to_acm(result); if (cser->send_modem_ctrl_bits) cser->send_modem_ctrl_bits(cser, cbits_to_laptop); } wake_up(&port->read_wq); } Loading Loading @@ -1512,8 +1566,10 @@ int usb_cser_connect(struct f_cdev *port) void usb_cser_disconnect(struct f_cdev *port) { struct cserial *cser; unsigned long flags; cser = &port->port_usb; usb_cser_stop_io(port); /* lower DTR to modem */ Loading @@ -1521,6 +1577,7 @@ void usb_cser_disconnect(struct f_cdev *port) spin_lock_irqsave(&port->port_lock, flags); port->is_connected = false; cser->notify_modem = NULL; port->nbytes_from_host = port->nbytes_to_host = 0; port->nbytes_to_port_bridge = 0; spin_unlock_irqrestore(&port->port_lock, flags); Loading Loading
drivers/usb/gadget/function/f_accessory.c +9 −6 Original line number Diff line number Diff line Loading @@ -567,8 +567,7 @@ static ssize_t acc_read(struct file *fp, char __user *buf, { struct acc_dev *dev = fp->private_data; struct usb_request *req; ssize_t r = count; unsigned xfer; ssize_t r = count, xfer, len; int ret = 0; pr_debug("acc_read(%zu)\n", count); Loading @@ -589,6 +588,8 @@ static ssize_t acc_read(struct file *fp, char __user *buf, goto done; } len = ALIGN(count, dev->ep_out->maxpacket); if (dev->rx_done) { // last req cancelled. try to get it. req = dev->rx_req[0]; Loading @@ -598,7 +599,7 @@ static ssize_t acc_read(struct file *fp, char __user *buf, requeue_req: /* queue a request */ req = dev->rx_req[0]; req->length = count; req->length = len; dev->rx_done = 0; ret = usb_ep_queue(dev->ep_out, req, GFP_KERNEL); if (ret < 0) { Loading Loading @@ -912,6 +913,8 @@ int acc_ctrlrequest(struct usb_composite_dev *cdev, memset(dev->serial, 0, sizeof(dev->serial)); dev->start_requested = 0; dev->audio_mode = 0; strlcpy(dev->manufacturer, "Android", ACC_STRING_SIZE); strlcpy(dev->model, "Android", ACC_STRING_SIZE); } } Loading Loading @@ -1214,13 +1217,13 @@ static int acc_setup(void) INIT_DELAYED_WORK(&dev->start_work, acc_start_work); INIT_WORK(&dev->hid_work, acc_hid_work); /* _acc_dev must be set before calling usb_gadget_register_driver */ _acc_dev = dev; ret = misc_register(&acc_device); if (ret) goto err; /* _acc_dev must be set before calling usb_gadget_register_driver */ _acc_dev = dev; return 0; err: Loading
drivers/usb/gadget/function/f_cdev.c +57 −0 Original line number Diff line number Diff line Loading @@ -348,6 +348,23 @@ static inline struct f_cdev *cser_to_port(struct cserial *cser) return container_of(cser, struct f_cdev, port_usb); } static unsigned int convert_uart_sigs_to_acm(unsigned int uart_sig) { unsigned int acm_sig = 0; /* should this needs to be in calling functions ??? */ uart_sig &= (TIOCM_RI | TIOCM_CD | TIOCM_DSR); if (uart_sig & TIOCM_RI) acm_sig |= ACM_CTRL_RI; if (uart_sig & TIOCM_CD) acm_sig |= ACM_CTRL_DCD; if (uart_sig & TIOCM_DSR) acm_sig |= ACM_CTRL_DSR; return acm_sig; } static unsigned int convert_acm_sigs_to_uart(unsigned int acm_sig) { unsigned int uart_sig = 0; Loading Loading @@ -1357,6 +1374,12 @@ static int f_cdev_tiocmget(struct f_cdev *port) if (cser->serial_state & TIOCM_RI) result |= TIOCM_RI; if (cser->serial_state & TIOCM_DSR) result |= TIOCM_DSR; if (cser->serial_state & TIOCM_CTS) result |= TIOCM_CTS; return result; } Loading Loading @@ -1397,6 +1420,24 @@ static int f_cdev_tiocmset(struct f_cdev *port, } } if (set & TIOCM_DSR) cser->serial_state |= TIOCM_DSR; if (clear & TIOCM_DSR) cser->serial_state &= ~TIOCM_DSR; if (set & TIOCM_CTS) { if (cser->send_break) { cser->serial_state |= TIOCM_CTS; status = cser->send_break(cser, 0); } } if (clear & TIOCM_CTS) { if (cser->send_break) { cser->serial_state &= ~TIOCM_CTS; status = cser->send_break(cser, 1); } } return status; } Loading Loading @@ -1447,7 +1488,9 @@ static void usb_cser_notify_modem(void *fport, int ctrl_bits) { int temp; struct f_cdev *port = fport; struct cserial *cser; cser = &port->port_usb; if (!port) { pr_err("port is null\n"); return; Loading @@ -1463,6 +1506,17 @@ static void usb_cser_notify_modem(void *fport, int ctrl_bits) port->cbits_to_modem = temp; port->cbits_updated = true; /* if DTR is high, update latest modem info to laptop */ if (port->cbits_to_modem & TIOCM_DTR) { unsigned int result; unsigned int cbits_to_laptop; result = f_cdev_tiocmget(port); cbits_to_laptop = convert_uart_sigs_to_acm(result); if (cser->send_modem_ctrl_bits) cser->send_modem_ctrl_bits(cser, cbits_to_laptop); } wake_up(&port->read_wq); } Loading Loading @@ -1512,8 +1566,10 @@ int usb_cser_connect(struct f_cdev *port) void usb_cser_disconnect(struct f_cdev *port) { struct cserial *cser; unsigned long flags; cser = &port->port_usb; usb_cser_stop_io(port); /* lower DTR to modem */ Loading @@ -1521,6 +1577,7 @@ void usb_cser_disconnect(struct f_cdev *port) spin_lock_irqsave(&port->port_lock, flags); port->is_connected = false; cser->notify_modem = NULL; port->nbytes_from_host = port->nbytes_to_host = 0; port->nbytes_to_port_bridge = 0; spin_unlock_irqrestore(&port->port_lock, flags); Loading