All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Potter <phil@philpotter.co.uk>
To: Joe Perches <joe@perches.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	gregkh@linuxfoundation.org, Larry.Finger@lwfinger.net,
	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: Re: [PATCH 2/2] staging: r8188eu: convert rtw_set_802_11_add_wep error code semantics
Date: Wed, 3 Aug 2022 00:26:50 +0100	[thread overview]
Message-ID: <YumyulRRT4gXNuNh@equinox> (raw)
In-Reply-To: <f93d3ea32ac04a5edd8159abcb0504f71fe7aee4.camel@perches.com>

On Sun, Jul 31, 2022 at 10:12:56AM -0700, Joe Perches wrote:
> Yes, you've got it right.
> 
> I think Dan is suggesting something like the below, but
> not necessarily in a single patch:
> ---
>  drivers/staging/r8188eu/core/rtw_ioctl_set.c | 38 ++++++++++++----------------
>  1 file changed, 16 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c
> index 17f6bcbeebf42..2736bbce83b5b 100644
> --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c
> +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c
> @@ -390,44 +390,38 @@ 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 keyid;
> +	struct security_priv *secpriv = &padapter->securitypriv;
>  
>  	keyid = wep->KeyIndex & 0x3fffffff;
> -
> -	if (keyid >= 4) {
> -		ret = false;
> -		goto exit;
> -	}
> +	if (keyid >= 4)
> +		return -EOPNOTSUPP;
>  
>  	switch (wep->KeyLength) {
>  	case 5:
> -		psecuritypriv->dot11PrivacyAlgrthm = _WEP40_;
> +		secpriv->dot11PrivacyAlgrthm = _WEP40_;
>  		break;
>  	case 13:
> -		psecuritypriv->dot11PrivacyAlgrthm = _WEP104_;
> +		secpriv->dot11PrivacyAlgrthm = _WEP104_;
>  		break;
>  	default:
> -		psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
> +		secpriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
>  		break;
>  	}
>  
> -	memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], &wep->KeyMaterial, wep->KeyLength);
> +	memcpy(secpriv->dot11DefKey[keyid].skey, &wep->KeyMaterial,
> +	       wep->KeyLength);
>  
> -	psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength;
> +	secpriv->dot11DefKeylen[keyid] = wep->KeyLength;
> +	secpriv->dot11PrivacyKeyIndex = keyid;
>  
> -	psecuritypriv->dot11PrivacyKeyIndex = keyid;
> +	if (rtw_set_key(padapter, secpriv, keyid, 1) == _FAIL)
> +		return -ENOMEM;
>  
> -	res = rtw_set_key(padapter, psecuritypriv, keyid, 1);
> -
> -	if (res == _FAIL)
> -		ret = false;
> -exit:
> -
> -	return ret;
> +	return 0;
>  }
>  
>  /*
> 

Hi Joe,

Thanks for the suggestion, this is pretty much what I'd interpreted from
Dan's advice in the meantime. I will prepare a V2 tomorrow.

Regards,
Phil

  parent reply	other threads:[~2022-08-02 23:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 23:11 [PATCH 0/2] staging: r8188eu: more error code cleanups Phillip Potter
2022-07-28 23:11 ` [PATCH 1/2] staging: r8188eu: remove initializer from ret in rtw_pwr_wakeup Phillip Potter
2022-07-28 23:11 ` [PATCH 2/2] staging: r8188eu: convert rtw_set_802_11_add_wep error code semantics Phillip Potter
2022-07-29  6:48   ` Dan Carpenter
2022-07-30 18:36     ` Phillip Potter
2022-07-31 17:12       ` Joe Perches
2022-08-01  9:17         ` Dan Carpenter
2022-08-02 23:26         ` Phillip Potter [this message]
2022-08-01  7:00       ` Dan Carpenter
2022-08-02 20:10   ` Pavel Skripkin
2022-08-02 22:15     ` Phillip Potter
2022-07-29  6:09 ` [PATCH 0/2] staging: r8188eu: more error code cleanups Philipp Hortmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YumyulRRT4gXNuNh@equinox \
    --to=phil@philpotter.co.uk \
    --cc=Larry.Finger@lwfinger.net \
    --cc=abdun.nihaal@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=martin@kaiser.cx \
    --cc=paskripkin@gmail.com \
    --cc=straube.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.