From patchwork Tue Apr 21 12:32:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 11501205 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61A2E6CA for ; Tue, 21 Apr 2020 12:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 499A92075E for ; Tue, 21 Apr 2020 12:33:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="b3QneW5N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728854AbgDUMdV (ORCPT ); Tue, 21 Apr 2020 08:33:21 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:34824 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728841AbgDUMdU (ORCPT ); Tue, 21 Apr 2020 08:33:20 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03LCMRxo023343; Tue, 21 Apr 2020 14:33:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=0hET9m9U8HNjSCYqn7p/h2ZCXaeqDDYalebZRnWlOT0=; b=b3QneW5N9a4sAQW94ax4zdlhJBaO/Co186+VagX9ucAasAeOpCXA2Ly1LV/BsNvxrXuU G5V0VbiInVKGmMVmIpPGg/HewSZsO2r2D8LBxYEjocKoT2wVU4jHe+POWOyHZfPgSD5K fX05RU6ehCvcGv/czJEZKD9UK580QVbdAurFPHlOFrh4lJb3eKeaAPwke31b5Te07i8H CfF7dm2m9UrN2cR8z7I/aaxae15WCmkeZbs3RgJy9oGCV5SK/BPOVd+99YSLbjK/sxfH 77la8hWrIglCRBm0+6YN0BGD6Od0kX+uHIqDnpyvurW0GTq3doaulTQuWfLUQKxH02GX tw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fregfxse-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Apr 2020 14:33:11 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5970B100034; Tue, 21 Apr 2020 14:33:11 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4CB152B0FCB; Tue, 21 Apr 2020 14:33:11 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 21 Apr 2020 14:33:10 +0200 From: Fabrice Gasnier To: , CC: , , , , Subject: [PATCH 1/4] usb: dwc2: gadget: move gadget resume after the core is in L0 state Date: Tue, 21 Apr 2020 14:32:18 +0200 Message-ID: <1587472341-17935-2-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> References: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG7NODE1.st.com (10.75.127.19) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-21_05:2020-04-20,2020-04-21 signatures=0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When the remote wakeup interrupt is triggered, lx_state is resumed from L2 to L0 state. But when the gadget resume is called, lx_state is still L2. This prevents the resume callback to queue any request. Any attempt to queue a request from resume callback will result in: - "submit request only in active state" debug message to be issued - dwc2_hsotg_ep_queue() returns -EAGAIN Move the call to resume gadget after the core is put in DWC2_L0 state. Signed-off-by: Fabrice Gasnier --- drivers/usb/dwc2/core_intr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 876ff31..b8ebda5 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -404,9 +404,11 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) } if (dwc2_is_device_mode(hsotg)) { + enum dwc2_lx_state lx_state = hsotg->lx_state; + dev_dbg(hsotg->dev, "DSTS=0x%0x\n", dwc2_readl(hsotg, DSTS)); - if (hsotg->lx_state == DWC2_L2) { + if (lx_state == DWC2_L2) { u32 dctl = dwc2_readl(hsotg, DCTL); /* Clear Remote Wakeup Signaling */ @@ -415,11 +417,13 @@ static void dwc2_handle_wakeup_detected_intr(struct dwc2_hsotg *hsotg) ret = dwc2_exit_partial_power_down(hsotg, true); if (ret && (ret != -ENOTSUPP)) dev_err(hsotg->dev, "exit power_down failed\n"); - - call_gadget(hsotg, resume); } /* Change to L0 state */ hsotg->lx_state = DWC2_L0; + + /* Gadget may queue new requests upon resume to L0 state */ + if (lx_state == DWC2_L2) + call_gadget(hsotg, resume); } else { if (hsotg->params.power_down) return; From patchwork Tue Apr 21 12:32:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 11501203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D8456CA for ; Tue, 21 Apr 2020 12:33:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 042252075E for ; Tue, 21 Apr 2020 12:33:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="DLOOB3q1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728861AbgDUMdV (ORCPT ); Tue, 21 Apr 2020 08:33:21 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:5350 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728839AbgDUMdU (ORCPT ); Tue, 21 Apr 2020 08:33:20 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03LCO4wA004143; Tue, 21 Apr 2020 14:33:13 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=BCdNw/6bNXDgvzYMM/yuCjYQaZbw1vGHMQ1wGH6OfQw=; b=DLOOB3q1xzpkHuWVQE1W3GjjNP5r0gaRi3HZdwgCBZe9UN3Y+2ePKe8zkp1dLYzqxDFF VlNpr1z/paTkNWP1sXYtEyg8WCLDaat6YLCohITc6Dt5L0WFNDO4hthfMgNAf7SpRKW8 qBWXOLNdGZ4fPFLN0tCqQvfYbQiN3MqTflVX9S3fYkIJIvOoVC+3hCOi7rCNF8uNjdy9 TEYRETf/9kMBpfcq2Q7yHRUCSKZbEmBMvjoGC7VjseTN39E2EtFdHiNckZQYOCjFZgCe eM+XbkYTWhsOIZrJ2h0+PWOjxRZW60Zmx/9vppT/jTb2hEiuxxrSr9uE2ajiNX/HDxnd yg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fpp8rapj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Apr 2020 14:33:13 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AD49A100034; Tue, 21 Apr 2020 14:33:12 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 9FB322B0FCB; Tue, 21 Apr 2020 14:33:12 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 21 Apr 2020 14:33:11 +0200 From: Fabrice Gasnier To: , CC: , , , , Subject: [PATCH 2/4] usb: gadget: u_serial: add suspend resume callbacks Date: Tue, 21 Apr 2020 14:32:19 +0200 Message-ID: <1587472341-17935-3-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> References: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG7NODE1.st.com (10.75.127.19) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-21_05:2020-04-20,2020-04-21 signatures=0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add suspend resume callbacks to handle the case seen when the bus is suspended by the HOST, and the device opens the port (cat /dev/ttyGS0). Gadget controller (like DWC2) doesn't accept usb requests to be queued in this case (when in L2 state), from the gs_open() call. Error log is printed - configfs-gadget gadget: acm ttyGS0 can't notify serial state, -11 If the HOST resumes (opens) the bus, the port still isn't functional. Use suspend/resume callbacks to monitor the gadget suspended state by using 'suspended' flag. In case the port gets opened (cat /dev/ttyGS0), the I/O stream will be delayed until the bus gets resumed by the HOST. Signed-off-by: Fabrice Gasnier --- drivers/usb/gadget/function/u_serial.c | 57 +++++++++++++++++++++++++++++----- drivers/usb/gadget/function/u_serial.h | 2 ++ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 8167d37..3cfc6e2 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -120,6 +120,8 @@ struct gs_port { wait_queue_head_t drain_wait; /* wait while writes drain */ bool write_busy; wait_queue_head_t close_wait; + bool suspended; /* port suspended */ + bool start_delayed; /* delay start when suspended */ /* REVISIT this state ... */ struct usb_cdc_line_coding port_line_coding; /* 8-N-1 etc */ @@ -630,13 +632,19 @@ static int gs_open(struct tty_struct *tty, struct file *file) /* if connected, start the I/O stream */ if (port->port_usb) { - struct gserial *gser = port->port_usb; - - pr_debug("gs_open: start ttyGS%d\n", port->port_num); - gs_start_io(port); - - if (gser->connect) - gser->connect(gser); + /* if port is suspended, wait resume to start I/0 stream */ + if (!port->suspended) { + struct gserial *gser = port->port_usb; + + pr_debug("gs_open: start ttyGS%d\n", port->port_num); + gs_start_io(port); + + if (gser->connect) + gser->connect(gser); + } else { + pr_debug("delay start of ttyGS%d\n", port->port_num); + port->start_delayed = true; + } } pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); @@ -680,7 +688,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); gser = port->port_usb; - if (gser && gser->disconnect) + if (gser && !port->suspended && gser->disconnect) gser->disconnect(gser); /* wait for circular write buffer to drain, disconnect, or at @@ -708,6 +716,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) else kfifo_reset(&port->port_write_buf); + port->start_delayed = false; port->port.count = 0; port->port.tty = NULL; @@ -1403,6 +1412,38 @@ void gserial_disconnect(struct gserial *gser) } EXPORT_SYMBOL_GPL(gserial_disconnect); +void gserial_suspend(struct gserial *gser) +{ + struct gs_port *port = gser->ioport; + unsigned long flags; + + spin_lock_irqsave(&port->port_lock, flags); + port->suspended = true; + spin_unlock_irqrestore(&port->port_lock, flags); +} +EXPORT_SYMBOL_GPL(gserial_suspend); + +void gserial_resume(struct gserial *gser) +{ + struct gs_port *port = gser->ioport; + unsigned long flags; + + spin_lock_irqsave(&port->port_lock, flags); + port->suspended = false; + if (!port->start_delayed) { + spin_unlock_irqrestore(&port->port_lock, flags); + return; + } + + pr_debug("delayed start ttyGS%d\n", port->port_num); + gs_start_io(port); + if (gser->connect) + gser->connect(gser); + port->start_delayed = false; + spin_unlock_irqrestore(&port->port_lock, flags); +} +EXPORT_SYMBOL_GPL(gserial_resume); + static int userial_init(void) { unsigned i; diff --git a/drivers/usb/gadget/function/u_serial.h b/drivers/usb/gadget/function/u_serial.h index e5b08ab..009a959 100644 --- a/drivers/usb/gadget/function/u_serial.h +++ b/drivers/usb/gadget/function/u_serial.h @@ -68,6 +68,8 @@ ssize_t gserial_get_console(unsigned char port_num, char *page); /* connect/disconnect is handled by individual functions */ int gserial_connect(struct gserial *, u8 port_num); void gserial_disconnect(struct gserial *); +void gserial_suspend(struct gserial *p); +void gserial_resume(struct gserial *p); /* functions are bound to configurations by a config or gadget driver */ int gser_bind_config(struct usb_configuration *c, u8 port_num); From patchwork Tue Apr 21 12:32:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 11501199 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4ECC66CA for ; Tue, 21 Apr 2020 12:33:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35E9D2084D for ; Tue, 21 Apr 2020 12:33:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="sB7xK0lE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728888AbgDUMdY (ORCPT ); Tue, 21 Apr 2020 08:33:24 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:13408 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728853AbgDUMdW (ORCPT ); Tue, 21 Apr 2020 08:33:22 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03LCOCbE002725; Tue, 21 Apr 2020 14:33:14 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=kO+cRwxzp6MTRP0BhgQn00h4Jvgtw6HO9Mccuab6nNs=; b=sB7xK0lERq51IXDlyGZOCu7iKpv0O3+r/L6Of+Ft7xWKxsTYBJtHDVCg0RzjNGcifOSW /87ylOnSdy6jU73BfCEow0nSHEWwgkcTYM536JV5IZtI8NwzmaYoJR/mvZmhE+tJUojp OcNKZHoMH8vCiPsDbydk8fhyBFP0Z5fCmcIJROIFO5TK3K8AFgsLrKsT8/9r+EGYmlY7 zYDe9xyyV0urvnIqqCVxZK6ljvayDM9VWt0bCOK3VbL3VpxbHGSllCFxXzwUu+SBCsV3 0U0leklll+y57LyfIYtZQZ9KRI54987O0USnFpOa2h6GkKfupUm8pywcA59RV4m6z/iF ZQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fq11g3ek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Apr 2020 14:33:14 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 158EB10002A; Tue, 21 Apr 2020 14:33:14 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0ACC42B0FCB; Tue, 21 Apr 2020 14:33:14 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 21 Apr 2020 14:33:13 +0200 From: Fabrice Gasnier To: , CC: , , , , Subject: [PATCH 3/4] usb: gadget: f_serial: add suspend resume callbacks Date: Tue, 21 Apr 2020 14:32:20 +0200 Message-ID: <1587472341-17935-4-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> References: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-21_05:2020-04-20,2020-04-21 signatures=0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add suspend resume callbacks to notify u_serial of the bus suspend/resume state. Signed-off-by: Fabrice Gasnier --- drivers/usb/gadget/function/f_serial.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c index 1406255..e627138 100644 --- a/drivers/usb/gadget/function/f_serial.c +++ b/drivers/usb/gadget/function/f_serial.c @@ -348,6 +348,20 @@ static void gser_unbind(struct usb_configuration *c, struct usb_function *f) usb_free_all_descriptors(f); } +static void gser_resume(struct usb_function *f) +{ + struct f_gser *gser = func_to_gser(f); + + gserial_resume(&gser->port); +} + +static void gser_suspend(struct usb_function *f) +{ + struct f_gser *gser = func_to_gser(f); + + gserial_suspend(&gser->port); +} + static struct usb_function *gser_alloc(struct usb_function_instance *fi) { struct f_gser *gser; @@ -369,6 +383,8 @@ static struct usb_function *gser_alloc(struct usb_function_instance *fi) gser->port.func.set_alt = gser_set_alt; gser->port.func.disable = gser_disable; gser->port.func.free_func = gser_free; + gser->port.func.resume = gser_resume; + gser->port.func.suspend = gser_suspend; return &gser->port.func; } From patchwork Tue Apr 21 12:32:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 11501201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2B3E81 for ; Tue, 21 Apr 2020 12:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9D4C2071C for ; Tue, 21 Apr 2020 12:33:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="hnFbBrbh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgDUMd2 (ORCPT ); Tue, 21 Apr 2020 08:33:28 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:45503 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbgDUMdY (ORCPT ); Tue, 21 Apr 2020 08:33:24 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03LCN1G0021757; Tue, 21 Apr 2020 14:33:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=XOcOfmk0mzp2LNDxp8A7DBUhCmQQA1WzS4pxBJFuT4I=; b=hnFbBrbhUH6PNx/IwwA4OIARvamZ1ny/0XqEk4W050Jhw7AfGf0n2pb/zLKP5H6Py5zr 6W0bDRVOZzmQxdERo0OJGVAJ7qpOM/h7mw61EQq6sykm90H/bNuyUPeXn2FC6x4Otpry nW/p/ec/MOwE8dF+Lzpas1nARb5JEJCZvSkKTiyjKfxILl0H7g9ph3gVehSE0D3YxmPu uAfHdGcVhORGKEJ+WTICmorgngUOnWFKpUKSR3VVQejYeBozTUefsfu/fnxjJkYLcp44 vG9fvRYULcXgnv0WLuTsxdWMEJSJ4zkWCQqQvMMmKIgQvm9i009923ZZg7o/UxCAzIIf hA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30fqaw81au-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Apr 2020 14:33:15 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4BE9A10002A; Tue, 21 Apr 2020 14:33:15 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 429112B0FCB; Tue, 21 Apr 2020 14:33:15 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 21 Apr 2020 14:33:14 +0200 From: Fabrice Gasnier To: , CC: , , , , Subject: [PATCH 4/4] usb: gadget: f_acm: add suspend resume callbacks Date: Tue, 21 Apr 2020 14:32:21 +0200 Message-ID: <1587472341-17935-5-git-send-email-fabrice.gasnier@st.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> References: <1587472341-17935-1-git-send-email-fabrice.gasnier@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-21_05:2020-04-20,2020-04-21 signatures=0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add suspend resume callbacks to notify u_serial of the bus suspend/resume state. Signed-off-by: Fabrice Gasnier --- drivers/usb/gadget/function/f_acm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index 7c152c2..200596e 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c @@ -723,6 +723,20 @@ static void acm_free_func(struct usb_function *f) kfree(acm); } +static void acm_resume(struct usb_function *f) +{ + struct f_acm *acm = func_to_acm(f); + + gserial_resume(&acm->port); +} + +static void acm_suspend(struct usb_function *f) +{ + struct f_acm *acm = func_to_acm(f); + + gserial_suspend(&acm->port); +} + static struct usb_function *acm_alloc_func(struct usb_function_instance *fi) { struct f_serial_opts *opts; @@ -750,6 +764,8 @@ static struct usb_function *acm_alloc_func(struct usb_function_instance *fi) acm->port_num = opts->port_num; acm->port.func.unbind = acm_unbind; acm->port.func.free_func = acm_free_func; + acm->port.func.resume = acm_resume; + acm->port.func.suspend = acm_suspend; return &acm->port.func; }