Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp33173imn; Tue, 2 Aug 2022 17:16:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR4TKEP5/8TQemKKg6mwJbud+07skCuBQWtWqd9D8INBakeYSSVLwvau4or9EQ7XkIkhzYVh X-Received: by 2002:a17:90b:17c8:b0:1f5:4724:981f with SMTP id me8-20020a17090b17c800b001f54724981fmr349898pjb.205.1659485783768; Tue, 02 Aug 2022 17:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659485783; cv=none; d=google.com; s=arc-20160816; b=JqKACYIEOxcIDAqizzM52vK36dlSUB/+Y9TwwwQy4w2S8giEDuug9G9xNCqtFp9OU+ /JipFTadObYV4+KVxTqUH1jOcg1mpNgJpzIZLjN7OisUcWqy4e9e8p/5Uj9X16cpc/uT E2i057UWyhygn7XDKVvxUjHkY+x1C5DqKv3os3CUKUVxE9TeLCmtYoT7iFU/A6Id2E/d mlIYubV2fyFYT1sbVwaA5lUwdiIydbfE8+xGcTLh+lJAOPc85LyJ1Osoj0rGBAOWBl/s DWFhYb/D91X/yGPiMEb806tfHTK/BmrzQ+JB+p9+xUAQ9i2RHbGPGs0V3inliMFtc4d2 G/lA== 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=LdDwNECNKOvsqe41unvtSWJtqFXY0vco7mkCCiO+5zA=; b=ID0G+JjYm/wIyLqfKE/jYLHdYg0Fj9oNzSuffR3dAWHy2Ci98qzhlozrP1ZNlCQ7Ni yEp6dGI8d95OyRPNQCSb/8tsSrtH1ghGPTZAbHxAMOgUDk/ZVhcSfALVpfPWfncMAmPo +T04YlldmnV4WggaHFYdXS6nvR7wr6MxtRJ8yPZYDoT3V1/z4qwBvaYosHK/QHcztdI6 17pod14QflNjUPokshJeC3uO+jJaK8nNRY0SKZpvVx+KMSgiY6yb98o9jYm2Iq3JDVH5 FNalYdsxjN2RJ59Vl1LQPJBWYEMGxgIK9Q9Q5JVPS5EL3RZF0djzYX7rZ+rXm4C5wOjk 9gZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@philpotter-co-uk.20210112.gappssmtp.com header.s=20210112 header.b=Me9ngPLM; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a170902bd9300b0016dc4217314si803952pls.150.2022.08.02.17.16.08; Tue, 02 Aug 2022 17:16:23 -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=Me9ngPLM; 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 S234951AbiHBXoS (ORCPT + 99 others); Tue, 2 Aug 2022 19:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiHBXoP (ORCPT ); Tue, 2 Aug 2022 19:44:15 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F1065465D for ; Tue, 2 Aug 2022 16:44:14 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id a18-20020a05600c349200b003a30de68697so1232564wmq.0 for ; Tue, 02 Aug 2022 16:44:14 -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:mime-version :content-transfer-encoding; bh=LdDwNECNKOvsqe41unvtSWJtqFXY0vco7mkCCiO+5zA=; b=Me9ngPLMG9NwxgPxLEPrV78K+02GbdHmULeqAhvxcSynw/dYDkSGOX3g9GQBQROOIE tS6jz+TsARqv0yzYh7E+lyp+bCaCcETeryRArofAmv9Jq7bZEqc/XTub+oy7Yb6Z4BU3 nQWklkOQcN6w4BrD0E0EFdYKkks+1NbTbvhjbOoQykXaOYari+Jf5NZViMaAAImRrysr +9eqIGN6NIr0qzummthstNjdy707nTFwmh1kd/9qTnM5dTywPMBP4aM060T3Q+I0tF2x Xyj8WVwBuPeqNVxtYOuWmKtC+jJHL+EEmEDPh0GSH7sF9y120lTasGs6ngAJsTKCR0v6 Vgdg== 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:mime-version :content-transfer-encoding; bh=LdDwNECNKOvsqe41unvtSWJtqFXY0vco7mkCCiO+5zA=; b=PRzmzQdgH+qq4um9xK+m6GsLQ6Z5e5oewFrUl9CNMuFq7gGWg12CVw/iOz7gs8kocN hw44kbdwb9xCknl3f+4fG9XZeWQNRIeu1VV7uc9fojOs8Ad7rPTVfR7ri9RvF4y9Xyce spwdLpQ7H7uLZv0U9/LDHXkdeSIhy7MEzG0sg+hXxVghTbf6rBvC8t61cYLlptyR/t54 7Cd+BkFAIpiykqcoS2aMCWpJdizGMFaYiPna6PAOajjzA7Cd8dh8BzoWT1q1CaDo7xgf Ud9KX383Bire8+qQecbx94PlQ0OpO9TufSYozY9aakpT8NONdoK3WJ0wV0bbPomJeoPI eWjQ== X-Gm-Message-State: ACgBeo0sT0J2PL5uyZWapVBcV9Y3BV9g97Vw5agFF9kejexhdjS3Y21X +/kgUsRU+5T0JAuLe/jOu6xy7mrxhS1LSA== X-Received: by 2002:a05:600c:384c:b0:3a3:744d:8dd2 with SMTP id s12-20020a05600c384c00b003a3744d8dd2mr994110wmr.117.1659483853048; Tue, 02 Aug 2022 16:44:13 -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 p19-20020a05600c359300b003a32297598csm220092wmq.43.2022.08.02.16.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 16:44:12 -0700 (PDT) From: Phillip Potter To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, paskripkin@gmail.com, straube.linux@gmail.com, martin@kaiser.cx, abdun.nihaal@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: r8188eu: convert rtw_p2p_enable to correct error code semantics Date: Wed, 3 Aug 2022 00:44:08 +0100 Message-Id: <20220802234408.930-1-phil@philpotter.co.uk> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Convert the rtw_p2p_enable function to use correct error code semantics rather than _SUCCESS/_FAIL, and also make sure we allow these to be passed through properly in the one caller where we actually check the code, rtw_wext_p2p_enable. This change moves these functions to a clearer 'return 0;' style at the end of the function, and in the case of errors now returns ret instead of jumping to the end of the function, so that these can still be passed through but without using a goto to jump to a single return statement at the end which is less clear. This change moves the driver slowly closer to using standard error code semantics everywhere. Signed-off-by: Phillip Potter --- drivers/staging/r8188eu/core/rtw_p2p.c | 19 ++++++++----------- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 12 +++++------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index bd654d4ff8b4..dc159e58f428 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1883,15 +1883,14 @@ void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) { - int ret = _SUCCESS; + int ret; struct wifidirect_info *pwdinfo = &padapter->wdinfo; if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) { /* leave IPS/Autosuspend */ - if (rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } + ret = rtw_pwr_wakeup(padapter); + if (ret) + return ret; /* Added by Albert 2011/03/22 */ /* In the P2P mode, the driver should not support the b mode. */ @@ -1902,10 +1901,9 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) init_wifidirect_info(padapter, role); } else if (role == P2P_ROLE_DISABLE) { - if (rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } + ret = rtw_pwr_wakeup(padapter); + if (ret) + return ret; /* Disable P2P function */ if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { @@ -1923,6 +1921,5 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); } -exit: - return ret; + return 0; } diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 7f91dac2e41b..e9802d42aa1b 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -2079,7 +2079,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret = 0; + int ret; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct wifidirect_info *pwdinfo = &padapter->wdinfo; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2094,10 +2094,9 @@ static int rtw_wext_p2p_enable(struct net_device *dev, else if (*extra == '3') init_role = P2P_ROLE_GO; - if (_FAIL == rtw_p2p_enable(padapter, init_role)) { - ret = -EFAULT; - goto exit; - } + ret = rtw_p2p_enable(padapter, init_role); + if (ret) + return ret; /* set channel/bandwidth */ if (init_role != P2P_ROLE_DISABLE) { @@ -2121,8 +2120,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev, set_channel_bwmode(padapter, channel, ch_offset, bwmode); } -exit: - return ret; + return 0; } static void rtw_p2p_set_go_nego_ssid(struct net_device *dev, -- 2.37.1