From nobody Mon Sep 15 18:06:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69377C46467 for ; Tue, 10 Jan 2023 20:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234232AbjAJU5C (ORCPT ); Tue, 10 Jan 2023 15:57:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233891AbjAJU4r (ORCPT ); Tue, 10 Jan 2023 15:56:47 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A51CB12A94 for ; Tue, 10 Jan 2023 12:56:44 -0800 (PST) Received: from dslb-178-004-206-224.178.004.pools.vodafone-ip.de ([178.4.206.224] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1pFLfi-0001pw-NV; Tue, 10 Jan 2023 21:56:38 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 1/4] staging: r8188eu: refactor status handling in usb_write_port_complete Date: Tue, 10 Jan 2023 21:56:23 +0100 Message-Id: <20230110205626.183516-2-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230110205626.183516-1-martin@kaiser.cx> References: <20230110205626.183516-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Refactor the satus handling in usb_write_port_complete. Make it clearer what happens for each status and avoid all the goto statements. Signed-off-by: Martin Kaiser Tested-by: Philipp Hortmann # Edimax N150 --- .../staging/r8188eu/os_dep/usb_ops_linux.c | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/stagi= ng/r8188eu/os_dep/usb_ops_linux.c index 257bcf496012..8494b80a08e5 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -48,21 +48,20 @@ static void usb_write_port_complete(struct urb *purb, s= truct pt_regs *regs) padapter->bWritePortCancel) goto check_completion; =20 - if (purb->status) { - if (purb->status =3D=3D -EINPROGRESS) { - goto check_completion; - } else if (purb->status =3D=3D -ENOENT) { - goto check_completion; - } else if (purb->status =3D=3D -ECONNRESET) { - goto check_completion; - } else if (purb->status =3D=3D -ESHUTDOWN) { - padapter->bDriverStopped =3D true; - goto check_completion; - } else if ((purb->status !=3D -EPIPE) && (purb->status !=3D -EPROTO)) { - padapter->bSurpriseRemoved =3D true; - - goto check_completion; - } + switch (purb->status) { + case 0: + case -EINPROGRESS: + case -ENOENT: + case -ECONNRESET: + case -EPIPE: + case -EPROTO: + break; + case -ESHUTDOWN: + padapter->bDriverStopped =3D true; + break; + default: + padapter->bSurpriseRemoved =3D true; + break; } =20 check_completion: --=20 2.30.2 From nobody Mon Sep 15 18:06:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C8FAC54EBC for ; Tue, 10 Jan 2023 20:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234307AbjAJU5F (ORCPT ); Tue, 10 Jan 2023 15:57:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233426AbjAJU4r (ORCPT ); Tue, 10 Jan 2023 15:56:47 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8B275950D for ; Tue, 10 Jan 2023 12:56:46 -0800 (PST) Received: from dslb-178-004-206-224.178.004.pools.vodafone-ip.de ([178.4.206.224] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1pFLfj-0001pw-H5; Tue, 10 Jan 2023 21:56:39 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 2/4] staging: r8188eu: reformat usb_write_port_complete Date: Tue, 10 Jan 2023 21:56:24 +0100 Message-Id: <20230110205626.183516-3-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230110205626.183516-1-martin@kaiser.cx> References: <20230110205626.183516-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This trivial patch reformats the usb_write_port_complete function. Hopefully, this makes the code a bit easier to read. Signed-off-by: Martin Kaiser Tested-by: Philipp Hortmann # Edimax N150 --- drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/stagi= ng/r8188eu/os_dep/usb_ops_linux.c index 8494b80a08e5..7da13b87d726 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -38,14 +38,13 @@ void rtw_read_port_cancel(struct adapter *padapter) static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) { struct xmit_buf *pxmitbuf =3D (struct xmit_buf *)purb->context; - struct adapter *padapter =3D pxmitbuf->padapter; - struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; + struct adapter *padapter =3D pxmitbuf->padapter; + struct xmit_priv *pxmitpriv =3D &padapter->xmitpriv; =20 if (pxmitbuf->flags =3D=3D HIGH_QUEUE_INX) rtw_chk_hi_queue_cmd(padapter); =20 - if (padapter->bSurpriseRemoved || padapter->bDriverStopped || - padapter->bWritePortCancel) + if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->b= WritePortCancel) goto check_completion; =20 switch (purb->status) { @@ -66,13 +65,9 @@ static void usb_write_port_complete(struct urb *purb, st= ruct pt_regs *regs) =20 check_completion: rtw_sctx_done_err(&pxmitbuf->sctx, - purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : - RTW_SCTX_DONE_SUCCESS); - + purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); rtw_free_xmitbuf(pxmitpriv, pxmitbuf); - tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - } =20 u32 rtw_write_port(struct adapter *padapter, u32 addr, u32 cnt, u8 *wmem) --=20 2.30.2 From nobody Mon Sep 15 18:06:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 353BDC46467 for ; Tue, 10 Jan 2023 20:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbjAJU44 (ORCPT ); Tue, 10 Jan 2023 15:56:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233700AbjAJU4r (ORCPT ); Tue, 10 Jan 2023 15:56:47 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 231033C3AF for ; Tue, 10 Jan 2023 12:56:45 -0800 (PST) Received: from dslb-178-004-206-224.178.004.pools.vodafone-ip.de ([178.4.206.224] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1pFLfk-0001pw-9H; Tue, 10 Jan 2023 21:56:40 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 3/4] staging: r8188eu: remove unused function parameter Date: Tue, 10 Jan 2023 21:56:25 +0100 Message-Id: <20230110205626.183516-4-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230110205626.183516-1-martin@kaiser.cx> References: <20230110205626.183516-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The regs parameter of the usb_write_port_complete function is not used. We can remove it. We can also remove the macro to hide the regs parameter when usb_write_port_complete is used as callback function for an urb transfer. Signed-off-by: Martin Kaiser Tested-by: Philipp Hortmann # Edimax N150 --- drivers/staging/r8188eu/include/usb_ops_linux.h | 2 -- drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/r8188eu/include/usb_ops_linux.h b/drivers/stag= ing/r8188eu/include/usb_ops_linux.h index 966688eedf66..e406a1fccda7 100644 --- a/drivers/staging/r8188eu/include/usb_ops_linux.h +++ b/drivers/staging/r8188eu/include/usb_ops_linux.h @@ -19,8 +19,6 @@ usb_bulkout_zero_complete(purb) #define usb_write_mem_complete(purb, regs) \ usb_write_mem_complete(purb) -#define usb_write_port_complete(purb, regs) \ - usb_write_port_complete(purb) #define usb_read_port_complete(purb, regs) \ usb_read_port_complete(purb) #define usb_read_interrupt_complete(purb, regs) \ diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/stagi= ng/r8188eu/os_dep/usb_ops_linux.c index 7da13b87d726..3fd080091340 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -35,7 +35,7 @@ void rtw_read_port_cancel(struct adapter *padapter) } } =20 -static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) +static void usb_write_port_complete(struct urb *purb) { struct xmit_buf *pxmitbuf =3D (struct xmit_buf *)purb->context; struct adapter *padapter =3D pxmitbuf->padapter; --=20 2.30.2 From nobody Mon Sep 15 18:06:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B86D0C46467 for ; Tue, 10 Jan 2023 20:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233958AbjAJU47 (ORCPT ); Tue, 10 Jan 2023 15:56:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232392AbjAJU4r (ORCPT ); Tue, 10 Jan 2023 15:56:47 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CD8B5950E for ; Tue, 10 Jan 2023 12:56:47 -0800 (PST) Received: from dslb-178-004-206-224.178.004.pools.vodafone-ip.de ([178.4.206.224] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1pFLfl-0001pw-3j; Tue, 10 Jan 2023 21:56:41 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 4/4] staging: r8188eu: always process urb status Date: Tue, 10 Jan 2023 21:56:26 +0100 Message-Id: <20230110205626.183516-5-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230110205626.183516-1-martin@kaiser.cx> References: <20230110205626.183516-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the if clause in usb_write_port_complete and process the urb status regardless of bSurpriseRemoved, bDriverStopped and bWritePortCancel. The only possible results of urb status processing are updates to bSurpriseRemoved and bDriverStopped. All of the three status variable are set to true only if the whole USB processing has to be stopped (when the driver is unloaded or when the system goes to sleep). It's no problem if one of the "stop everything" variables is already set and the urb status processing sets another one. This patch removes the last goto in usb_write_port_complete. It's also part of the ongoing effort to limit the use of the "stop everything" variables. Signed-off-by: Martin Kaiser Tested-by: Philipp Hortmann # Edimax N150 --- drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/stagi= ng/r8188eu/os_dep/usb_ops_linux.c index 3fd080091340..62106d2f82ad 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -44,9 +44,6 @@ static void usb_write_port_complete(struct urb *purb) if (pxmitbuf->flags =3D=3D HIGH_QUEUE_INX) rtw_chk_hi_queue_cmd(padapter); =20 - if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->b= WritePortCancel) - goto check_completion; - switch (purb->status) { case 0: case -EINPROGRESS: @@ -63,7 +60,6 @@ static void usb_write_port_complete(struct urb *purb) break; } =20 -check_completion: rtw_sctx_done_err(&pxmitbuf->sctx, purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); rtw_free_xmitbuf(pxmitpriv, pxmitbuf); --=20 2.30.2