From patchwork Sat Feb 11 16:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 55851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1575424wrn; Sat, 11 Feb 2023 09:00:59 -0800 (PST) X-Google-Smtp-Source: AK7set8cqfr9CMOec4+4xH5dRA5+yVcH1ad4XtT6hixzdL210D13Zb9x+86TKfSjqB3rN79+/44V X-Received: by 2002:a17:906:4e96:b0:88d:3c85:4ccf with SMTP id v22-20020a1709064e9600b0088d3c854ccfmr20047464eju.25.1676134859586; Sat, 11 Feb 2023 09:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676134859; cv=none; d=google.com; s=arc-20160816; b=jJeDSsfFSbbPMA06awUai+nVEJVqQq1HuvmqrkydXw0AzEqa+jiMUklFMjNu5F1DO8 4Zu0AW/drNvB19kjvH801PvdI6SlvYqxBu2hbYaN2qb62JNkDHnESCubTrbsWLWCxHmu xioTxCk8c7FSsENHKvmGB/Fae3looODEZ+TD0oSey3y8cFKCDP91vbPv09zDNzXDBrWp 7dE5Hp/YRMMMTTJ5KKhdIx6i4nEPOJSNlgUtWU6LyZI8IZtgAH0InE6+JaOFEr822Iwe 9AoOi/1qYIzv4leBpa50miosxxFuv8Qd0Y7XVD7Rit27vlYFBFfXBMz+xmieKnTmPjHf jLBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=5ycl0LtRHuaIhTH1ZmlnKGLNlKodBFUTfgy+uqD5eeM=; b=lmrfRDY7o2Yx1Bo9ijgcstWYYEn+G5s2gscMq6vNDUQsmePjjNRqNesv4YpLPtQsFn fiHC6QfUr0zwAau1Ieo11PxG1pDd2pW6cCndWujJosUdJixyw3xh6EflfFIuQH7Pltyv ZKo91Gg3Gwu7n2PcdjIqzRLuVPlCg3i3yv9LzfE5qdrAMTe4vFREuOFlPYeAO6IpTAF6 7EyN9a84TW1U9odRC8vygneZdCNy75ZIelooJ9smleKoiEbJQ2tVF+8xPPe6H3/hiwF1 4jRNfTHX9VrWs/YFTyaRfrp3XBiTKSutqk14g7VOi4smk2gKFcEe7n8tG9IFiiHzi8rC HISA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 11-20020a17090602cb00b008a99f26d242si9714643ejk.416.2023.02.11.09.00.36; Sat, 11 Feb 2023 09:00:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjBKQvL (ORCPT + 99 others); Sat, 11 Feb 2023 11:51:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjBKQvJ (ORCPT ); Sat, 11 Feb 2023 11:51:09 -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 3DD8E1BF1 for ; Sat, 11 Feb 2023 08:51:08 -0800 (PST) Received: from dslb-094-219-036-079.094.219.pools.vodafone-ip.de ([94.219.36.79] 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 1pQt5Y-0006wA-Mp; Sat, 11 Feb 2023 17:51:00 +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] staging: r8188eu: merge _rtw_enqueue_cmd into its caller Date: Sat, 11 Feb 2023 17:50:45 +0100 Message-Id: <20230211165045.414424-1-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757554786661102019?= X-GMAIL-MSGID: =?utf-8?q?1757554786661102019?= The _rtw_enqueue_cmd function is called only by rtw_enqueue_cmd. When _rtw_enqueue_cmd is called, the caller has already checked that the obj parameter is not NULL. _rtw_enqueue_cmd returns _SUCCESS in any case. We can merge the two functions and simplify the error handling. Signed-off-by: Martin Kaiser Tested-by: Philipp Hortmann # Edimax N150 --- drivers/staging/r8188eu/core/rtw_cmd.c | 47 +++++--------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index d57360a68fb3..ca9e3d4ee7f4 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -28,32 +28,6 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) } } -/* Calling Context: - * - * rtw_enqueue_cmd can only be called between kernel thread, - * since only spin_lock is used. - * - * ISR/Call-Back functions can't call this sub-function. - */ - -static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) -{ - unsigned long flags; - - if (!obj) - goto exit; - - spin_lock_irqsave(&queue->lock, flags); - - list_add_tail(&obj->list, &queue->queue); - - spin_unlock_irqrestore(&queue->lock, flags); - -exit: - - return _SUCCESS; -} - int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { init_completion(&pcmdpriv->enqueue_cmd); @@ -125,28 +99,25 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { - int res = _FAIL; + unsigned long flags; struct adapter *padapter = pcmdpriv->padapter; if (!cmd_obj) - goto exit; + return _FAIL; cmd_obj->padapter = padapter; - res = rtw_cmd_filter(pcmdpriv, cmd_obj); - if (res == _FAIL) { + if (rtw_cmd_filter(pcmdpriv, cmd_obj) == _FAIL) { rtw_free_cmd_obj(cmd_obj); - goto exit; + return _FAIL; } - res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); - - if (res == _SUCCESS) - complete(&pcmdpriv->enqueue_cmd); + spin_lock_irqsave(&pcmdpriv->cmd_queue.lock, flags); + list_add_tail(&cmd_obj->list, &pcmdpriv->cmd_queue.queue); + spin_unlock_irqrestore(&pcmdpriv->cmd_queue.lock, flags); -exit: - - return res; + complete(&pcmdpriv->enqueue_cmd); + return _SUCCESS; } struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv)