From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A3CF7A for ; Thu, 28 Jul 2022 23:12:02 +0000 (UTC) Received: by mail-wr1-f41.google.com with SMTP id k8so1868452wrd.5 for ; Thu, 28 Jul 2022 16:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=philpotter-co-uk.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iOMs7BLkqwBB1UyXezQZ04RHJK4IHCUkM0ubSij7BbY=; b=TvgWxQ1YU4CH0+n1gsKJEid55d9jKIcmFtMQOw0CZFaHfwluaTrU+wGzMpSwJo2fdO JpKRA8uvvt5OAJt/ocPjjpo19sfI3aFcSrN0SBWMLeR951R1yh67AzlzTC62HI3WtPlJ zWfGmw7s3Q+D4Y+fDQpO4mWBW4TCG80pXnF2Dqs2Xlg+0cGDedBUs5qC6oSwuV0ZGtrT dJqHSXbF+wOy3WDYisoHFmTipvNOrOxJACnGPfDSgjAZOQz5swY8NVyf7oXWEZSsth4n SqznWV5UJZBkf6EqyaSSLvbKBtSMEYlqbIeWoU93f7WAZe+ATFd2bu7+8IIRV9uefqCS wbcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iOMs7BLkqwBB1UyXezQZ04RHJK4IHCUkM0ubSij7BbY=; b=PDo0ckEuPKfJo6JUsSO6yK9keSHPH9LUbMFxEZ8Gd5qqXYTcPdl9QJr3tT9rO9z1XZ X3lRf+hErDsHDAQVyqTWVAntCrW+zvF9pmtqzr/SiWham/43YVXgSTNSCnRTA3vdO3yf yyQJy4D6plMzff1tXMfYFzOqUGmGkEJoMtImHPXJD2lKfz/9ChkZ2vRuSyVVo4H5aNex e2KaMzGrR3SgZlvL+/nTQbDWVOfWwXRv8Jtwhhx4z6qSS2BMxBL7MJlHwNvD+OqGVDn4 qjhCaGeHN27P4ziZ6eERA8He7EPrGQSJi9zcueLGpmDgu04Qf5lmrstIIOwB7ik5b8Mq Kd6A== X-Gm-Message-State: ACgBeo3jNDamWzi4FD+Ii7bc8i7HF/5U30VO9NeOQT1aqem0ODNxeqH2 diIbByM1eZhWatEb5z05DNbNZw== X-Google-Smtp-Source: AA6agR6BuhN5Yz1o0mDQQ2XeVvUQLLBpBJKf9VdtE9hzY5hN+7oicLyfoD+qYRPAxwy8Ry9O0rHoDw== X-Received: by 2002:a05:6000:80b:b0:21e:d62e:b282 with SMTP id bt11-20020a056000080b00b0021ed62eb282mr614545wrb.557.1659049920763; Thu, 28 Jul 2022 16:12:00 -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 m20-20020a056000181400b0021e571a99d5sm2089419wrh.17.2022.07.28.16.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 16:12:00 -0700 (PDT) From: Phillip Potter To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, dan.carpenter@oracle.com, paskripkin@gmail.com, martin@kaiser.cx, straube.linux@gmail.com, fmdefrancesco@gmail.com, abdun.nihaal@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] staging: r8188eu: convert rtw_set_802_11_add_wep error code semantics Date: Fri, 29 Jul 2022 00:11:50 +0100 Message-Id: <20220728231150.972-3-phil@philpotter.co.uk> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220728231150.972-1-phil@philpotter.co.uk> References: <20220728231150.972-1-phil@philpotter.co.uk> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Convert the rtw_set_802_11_add_wep function to use 0 on success and an appropriate error code on error. Also convert return type to int to allow negative return values. For the first failure block where keyid >= 4, use -EOPNOTSUPP as this is most appropriate, and for the second failure block where rtw_set_key is called, use -ENOMEM, as this is the cause of failure in that function anyway - in due course, rtw_set_key can be converted as well. Finally, convert both call-sites of rtw_set_802_11_add_wep to use the new semantics, passing through the error code where we can for one of them. This gets the driver closer to removal of the non-standard _SUCCESS and _FAIL definitions, which are inverted compared to the standard in-kernel error code mechanism. Signed-off-by: Phillip Potter --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 8 ++++---- drivers/staging/r8188eu/include/rtw_ioctl_set.h | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 17f6bcbeebf4..a5b5d7f6a864 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -390,16 +390,16 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 return ret; } -u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) +int rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) { int keyid, res; struct security_priv *psecuritypriv = &padapter->securitypriv; - u8 ret = _SUCCESS; + int ret = 0; keyid = wep->KeyIndex & 0x3fffffff; if (keyid >= 4) { - ret = false; + ret = -EOPNOTSUPP; goto exit; } @@ -424,7 +424,7 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) res = rtw_set_key(padapter, psecuritypriv, keyid, 1); if (res == _FAIL) - ret = false; + ret = -ENOMEM; exit: return ret; diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_set.h b/drivers/staging/r8188eu/include/rtw_ioctl_set.h index 7365079c704f..761b30bdb8ec 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl_set.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl_set.h @@ -11,7 +11,7 @@ typedef u8 NDIS_802_11_PMKID_VALUE[16]; u8 rtw_set_802_11_authentication_mode(struct adapter *adapt, enum ndis_802_11_auth_mode authmode); u8 rtw_set_802_11_bssid(struct adapter*adapter, u8 *bssid); -u8 rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep); +int rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep); u8 rtw_set_802_11_disassociate(struct adapter *adapter); u8 rtw_set_802_11_bssid_list_scan(struct adapter*adapter, struct ndis_802_11_ssid *pssid, diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 7f91dac2e41b..4d8dbc2a9ef2 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -422,8 +422,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, pwep->KeyIndex |= 0x80000000; memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); if (param->u.crypt.set_tx) { - if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) - ret = -EOPNOTSUPP; + ret = rtw_set_802_11_add_wep(padapter, pwep); } else { if (wep_key_idx >= WEP_KEYS) { ret = -EOPNOTSUPP; @@ -1613,7 +1612,7 @@ static int rtw_wx_set_enc(struct net_device *dev, memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); - if (!rtw_set_802_11_add_wep(padapter, &wep)) { + if (rtw_set_802_11_add_wep(padapter, &wep)) { if (rf_on == pwrpriv->rf_pwrstate) ret = -EOPNOTSUPP; goto exit; -- 2.36.1