From patchwork Wed Nov 2 00:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Potter X-Patchwork-Id: 13974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3301269wru; Tue, 1 Nov 2022 17:37:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HG53RU6lbLaqSNzrHsunlFIJqpD01B9TYEiya1JJEQIQkL3u1RVfJAG5/93QguwcWy9fP X-Received: by 2002:a05:6a00:1a47:b0:52e:6a8c:5430 with SMTP id h7-20020a056a001a4700b0052e6a8c5430mr21973111pfv.48.1667349434749; Tue, 01 Nov 2022 17:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667349434; cv=none; d=google.com; s=arc-20160816; b=ofr4bjJ+OtY4oKHwSa0oHAIg+NEh0JUb7Pf9CXgb8iDHhkGiGwLZEK9XMSY1wf4J+X kkXgjycL7dK0fThd6ZxLG1Ig4u6eqXbJoMl9jAe/H2MWplcfjbHtGbODZW9ZLNJ75pxv iqPujM8Ep2oc/2UxUKsF6oS2LQn71zdFmSV/8yisGzQMajGmeC8P1CIWoQcRDrhkhRtl OAa9nFitZzO0sLYcCSo1caW91MZkRw8nTG3fKln2OPHKxsAdpKLGpAOgHNzmWpDqo7Nn ptzesB4JBbtSl39xTpX5SlzCAtP/Iy4Y7L1taZofPYh+ZLLxWpQTIejZkNWfC02gxkds AVKQ== 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:dkim-signature; bh=tO0LAor4TdjnxnPqUvrC1prKZiIrkWSk8R0XYZ6tvt8=; b=YmXn3inS8uvznbPBz8cxYjxjcgt0Q1ofXMYfSGeMncyEqDht7UQsqLwpYdY/tKoKIk /uftHFNv8vgqq8NDd/clS7UoCIVDeOxUPAmD5/xTtmyi10OswABu8cuS/xpyjha1QvzJ iFvz9g3D64paqsP1s9US9jZ/EkGhrKora8gfDGHk4phaJHoQqPNB1Xjvq/WSlq2KxqOm R06Zp4GpnRIdx6hR+jIver/i5ypsX1+JmFvwXw1baqM3E82de2Fs7hSaNNyp/UZF8Dvh Z479yqU/npa5g4dvgoi1+QwAsdj0fScFCJ1C5kh7GR0lzw7Ppxdor0+2gLbWk8A1VLwr LXXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@philpotter-co-uk.20210112.gappssmtp.com header.s=20210112 header.b=tWfKavah; 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 nd10-20020a17090b4cca00b002141611a4bdsi389539pjb.37.2022.11.01.17.37.02; Tue, 01 Nov 2022 17:37:14 -0700 (PDT) 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; dkim=pass header.i=@philpotter-co-uk.20210112.gappssmtp.com header.s=20210112 header.b=tWfKavah; 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 S229826AbiKBAgd (ORCPT + 99 others); Tue, 1 Nov 2022 20:36:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229927AbiKBAg3 (ORCPT ); Tue, 1 Nov 2022 20:36:29 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0F28DECB for ; Tue, 1 Nov 2022 17:36:17 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id cl5so10706356wrb.9 for ; Tue, 01 Nov 2022 17:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tO0LAor4TdjnxnPqUvrC1prKZiIrkWSk8R0XYZ6tvt8=; b=tWfKavahahchekF5H2ZJeJjY4YDSYtrcnHRU8WIS0QwxKhLPQdlDbE+fAftYAAgp/F gt+hiEVITG4y8URcjz477i9kRCP5LwnfRlhryqiUTnTCkKYxvQsMO5wLm8g3znMfh3aO Nrco703cnoJvhWPhpY22TX/A99tkKhnCKcJRxeGmUL2voo0A6MlEOC6/PgKzK+IZJm06 Qbpy7F3KsWjJVNQ4AOk1hfpTVQvp7O/ooKS2RIYMajsGcNsIFHBOnrWdlNPT2+Zp4CWg B49cUOEf8j1a6hfW75PEpFEYfFGevfVO5SlaoXqlsViypk2LY5aY/mSJRikH1x+lRP0r Y4Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tO0LAor4TdjnxnPqUvrC1prKZiIrkWSk8R0XYZ6tvt8=; b=ylxcwOP7vIimJJeXn1hHitZnDY9jMCaVfoRpadMngI+YP+8FpKhAZC5t/9crstV9MA GlCCC5NIU0cIfxskexfRqHJIk6qqzyC8pjQ0GS8Z+HSQ9swufvLAg08yBskzMeuGH2YL yE5OeE1gA9URnfzZOn/mPjxtVJYX2NghPhaHV3hTx8KPa1yLJwyXMFiFsKP/iX/EmPlW dlH1Azp0tKvXEigFF0b6rPxIBMzsNm6oqKXxVgzc10/QIKapmwLueYB2tUa9f0Dw9P00 vliP5SKbGq6iQaecdh7Fq0NXvtWrPYzd7T+hdc3eu1lU4WIAA2FQwrFRIHR9s8iOWxdO fNrg== X-Gm-Message-State: ACrzQf28Px8PD0SLnPqX3gIAWbBP0K5276tZErtBqycIZrmFEJu+XC01 WqOT6rm61j6qcejmEOLI8FrPYg== X-Received: by 2002:a5d:63d1:0:b0:235:9aeb:e365 with SMTP id c17-20020a5d63d1000000b002359aebe365mr13612992wrw.77.1667349376421; Tue, 01 Nov 2022 17:36:16 -0700 (PDT) Received: from localhost.localdomain (d.f.5.e.6.6.b.1.e.6.2.7.e.5.c.8.0.a.1.e.e.d.f.d.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:dfde:e1a0:8c5e:726e:1b66:e5fd]) by smtp.gmail.com with ESMTPSA id p5-20020a5d68c5000000b00236e834f050sm2600149wrw.35.2022.11.01.17.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 17:36:15 -0700 (PDT) From: Phillip Potter To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, paskripkin@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, dan.carpenter@oracle.com Subject: [PATCH] staging: r8188eu: convert rtw_setdatarate_cmd to correct error semantics Date: Wed, 2 Nov 2022 00:36:13 +0000 Message-Id: <20221102003613.971-1-phil@philpotter.co.uk> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1748342601001108496?= X-GMAIL-MSGID: =?utf-8?q?1748342601001108496?= Convert rtw_setdatarate_cmd function to use proper error return codes rather than _SUCCESS and _FAIL, and a simpler 'return 0;' style. For now, wrap rtw_enqueue_cmd call and return -EPERM if it fails, as converting this function makes more sense later on due to its large number of callers. Also change rtw_wx_set_rate function to pass through the proper error code rather than just 0 or -1. Signed-off-by: Phillip Potter --- drivers/staging/r8188eu/core/rtw_cmd.c | 18 +++++++----------- drivers/staging/r8188eu/include/rtw_cmd.h | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 7 ++----- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index fdc0c71e28a4..19b2f73d481d 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -340,33 +340,29 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, return res; } -u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) +int rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) { struct cmd_obj *ph2c; struct setdatarate_parm *pbsetdataratepara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } + if (!ph2c) + return -ENOMEM; pbsetdataratepara = kzalloc(sizeof(*pbsetdataratepara), GFP_ATOMIC); if (!pbsetdataratepara) { kfree(ph2c); - res = _FAIL; - goto exit; + return -ENOMEM; } init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate)); pbsetdataratepara->mac_id = 5; memcpy(pbsetdataratepara->datarates, rateset, NumRates); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: + if (rtw_enqueue_cmd(pcmdpriv, ph2c) == _FAIL) + return -EPERM; - return res; + return 0; } void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h index a740a9a101d8..c330a4435b31 100644 --- a/drivers/staging/r8188eu/include/rtw_cmd.h +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -727,7 +727,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork); u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue); u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype); -u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset); +int rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset); u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode); u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset, u8 *pval); diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index f3b3d7468539..dda48a2a6d0c 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1340,7 +1340,7 @@ static int rtw_wx_set_rate(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - int i, ret = 0; + int i; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); u8 datarates[NumRates]; u32 target_rate = wrqu->bitrate.value; @@ -1408,10 +1408,7 @@ static int rtw_wx_set_rate(struct net_device *dev, } } - if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) - ret = -1; - - return ret; + return rtw_setdatarate_cmd(padapter, datarates); } static int rtw_wx_get_rate(struct net_device *dev,