[PATCH] staging: r8188eu: use native wireless IE codes from linux/ieee80211.h

2020-10-11 Thread Ivan Safonov
IE code definitions have been replaced with native ones
to avoid code duplication.

The unobvious substitutions are:
_SSN_IE_1_ -> WLAN_EID_VENDOR_SPECIFIC;
_WPA_IE_ID_ -> WLAN_EID_VENDOR_SPECIFIC;
_WPA2_IE_ID_ -> WLAN_EID_RSN.

Signed-off-by: Ivan Safonov 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c   |  54 
 drivers/staging/rtl8188eu/core/rtw_cmd.c  |   2 +-
 .../staging/rtl8188eu/core/rtw_ieee80211.c|  36 +++---
 .../staging/rtl8188eu/core/rtw_ioctl_set.c|   2 +-
 drivers/staging/rtl8188eu/core/rtw_mlme.c |  18 +--
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 122 +-
 drivers/staging/rtl8188eu/core/rtw_recv.c |   4 +-
 .../staging/rtl8188eu/core/rtw_wlan_util.c|  24 ++--
 drivers/staging/rtl8188eu/core/rtw_xmit.c |  10 +-
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c  |  10 +-
 .../staging/rtl8188eu/include/rtw_security.h  |   3 -
 drivers/staging/rtl8188eu/include/wifi.h  |  34 -
 .../staging/rtl8188eu/os_dep/ioctl_linux.c|  10 +-
 drivers/staging/rtl8188eu/os_dep/mlme_linux.c |   2 +-
 14 files changed, 147 insertions(+), 184 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 2078d87055bf..fa1e34a0d456 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -67,7 +67,7 @@ static void update_BCNTIM(struct adapter *padapter)
uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
 
/* update TIM IE */
-   p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen,
+   p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen,
   pnetwork_mlmeext->ie_length - _FIXED_IE_LENGTH_);
if (p && tim_ielen > 0) {
tim_ielen += 2;
@@ -85,7 +85,7 @@ static void update_BCNTIM(struct adapter *padapter)
offset += pnetwork_mlmeext->ssid.ssid_length + 2;
 
/*  get supported rates len */
-   p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_,
+   p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES,
   &tmp_len, (pnetwork_mlmeext->ie_length -
  _BEACON_IE_OFFSET_));
if (p)
@@ -109,7 +109,7 @@ static void update_BCNTIM(struct adapter *padapter)
memcpy(pbackup_remainder_ie, premainder_ie,
   remainder_ielen);
}
-   *dst_ie++ = _TIM_IE_;
+   *dst_ie++ = WLAN_EID_TIM;
 
if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 0x00fc))
tim_ielen = 5;
@@ -243,7 +243,7 @@ void expire_timeout_chk(struct adapter *padapter)
 * for this station
 */
pstapriv->tim_bitmap |= BIT(psta->aid);
-   update_beacon(padapter, _TIM_IE_, NULL,
+   update_beacon(padapter, WLAN_EID_TIM, 
NULL,
  false);
 
if (!pmlmeext->active_keep_alive_check)
@@ -671,7 +671,7 @@ static void start_bss_network(struct adapter *padapter, u8 
*pbuf)
}
/* set channel, bwmode */
p = rtw_get_ie(pnetwork->ies + sizeof(struct ndis_802_11_fixed_ie),
-  _HT_ADD_INFO_IE_, &ie_len,
+   WLAN_EID_HT_OPERATION, &ie_len,
   pnetwork->ie_length -
   sizeof(struct ndis_802_11_fixed_ie));
if (p && ie_len) {
@@ -717,7 +717,7 @@ static void start_bss_network(struct adapter *padapter, u8 
*pbuf)
memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length);
 
if (pmlmeext->bstart_bss) {
-   update_beacon(padapter, _TIM_IE_, NULL, false);
+   update_beacon(padapter, WLAN_EID_TIM, NULL, false);
 
/* issue beacon frame */
if (send_beacon(padapter) == _FAIL)
@@ -788,7 +788,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
cap = get_unaligned_le16(ie);
 
/* SSID */
-   p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len,
+   p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len,
   pbss_network->ie_length - _BEACON_IE_OFFSET_);
if (p && ie_len > 0) {
memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid));
@@ -799,7 +799,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 
*pbuf,  int len)
/* channel */
channel = 0;
pbss_network->Configuration.Length = 0;
-   p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len,
+   p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len,
   (pbss_network->ie_length - _BEACON_IE_OFFSET_));
   

[PATCH] staging: rtl8723bs: remove unnecessary type cast of rtw_netdev_priv() result

2020-10-11 Thread Ivan Safonov
The type cast
padapter = (struct adapter *)rtw_netdev_priv(dev);
do nothing because type of rtw_netdev_priv() result
is (struct adapter *).

Signed-off-by: Ivan Safonov 
---
 .../staging/rtl8723bs/core/rtw_wlan_util.c|   6 +-
 .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c |  50 
 .../staging/rtl8723bs/os_dep/ioctl_linux.c| 116 +-
 drivers/staging/rtl8723bs/os_dep/os_intfs.c   |  12 +-
 drivers/staging/rtl8723bs/os_dep/xmit_linux.c |   2 +-
 5 files changed, 93 insertions(+), 93 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 372ce17c3569..e3e8140eec9e 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -2010,7 +2010,7 @@ int rtw_get_gpio(struct net_device *netdev, int gpio_num)
 {
u8 value;
u8 direction;
-   struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
+   struct adapter *adapter = rtw_netdev_priv(netdev);
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(adapter);
 
rtw_ps_deny(adapter, PS_DENY_IOCTL);
@@ -2038,7 +2038,7 @@ int  rtw_set_gpio_output_value(struct net_device *netdev, 
int gpio_num, bool isH
 {
u8 direction = 0;
u8 res = -1;
-   struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
+   struct adapter *adapter = rtw_netdev_priv(netdev);
 
/* Check GPIO is 4~7 */
if (gpio_num > 7 || gpio_num < 4) {
@@ -2074,7 +2074,7 @@ EXPORT_SYMBOL(rtw_set_gpio_output_value);
 
 int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput)
 {
-   struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev);
+   struct adapter *adapter = rtw_netdev_priv(netdev);
 
if (gpio_num > 7 || gpio_num < 4) {
DBG_871X("%s The gpio number does not included 4~7.\n", 
__func__);
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index ea3ae3d38337..9bb97c39f1a2 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -561,7 +561,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device 
*dev, struct ieee_pa
int ret = 0;
u32 wep_key_idx, wep_key_len;
struct sta_info *psta = NULL, *pbcmc_sta = NULL;
-   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
+   struct adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv* psecuritypriv =  &(padapter->securitypriv);
struct sta_priv *pstapriv = &padapter->stapriv;
@@ -847,7 +847,7 @@ static int rtw_cfg80211_set_encryption(struct net_device 
*dev, struct ieee_param
 {
int ret = 0;
u32 wep_key_idx, wep_key_len;
-   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
+   struct adapter *padapter = rtw_netdev_priv(dev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
 
@@ -1039,7 +1039,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, 
struct net_device *ndev,
u32 param_len;
struct ieee_param *param = NULL;
int ret = 0;
-   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev);
+   struct adapter *padapter = rtw_netdev_priv(ndev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
DBG_871X(FUNC_NDEV_FMT" adding key for %pM\n", FUNC_NDEV_ARG(ndev), 
mac_addr);
@@ -1149,7 +1149,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, 
struct net_device *ndev,
 static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev,
u8 key_index, bool pairwise, const u8 *mac_addr)
 {
-   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev);
+   struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;
 
DBG_871X(FUNC_NDEV_FMT" key_index =%d\n", FUNC_NDEV_ARG(ndev), 
key_index);
@@ -1168,7 +1168,7 @@ static int cfg80211_rtw_set_default_key(struct wiphy 
*wiphy,
, bool unicast, bool multicast
)
 {
-   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev);
+   struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;
 
DBG_871X(FUNC_NDEV_FMT" key_index =%d, unicast =%d, multicast =%d\n",
@@ -1201,7 +1201,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
struct station_info *sinfo)
 {
int ret = 0;
-   struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev);
+   struct adapter *padapter = rtw_netdev_priv(ndev);
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct sta_info *

[PATCH] Fixed issues with alignment to open parenthesis.

2020-10-11 Thread Tabot Kevin
This patch fixes the following:
- Made sure alignment matched open parenthesis.

Signed-off-by: Tabot Kevin 
---
 drivers/staging/greybus/audio_module.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/greybus/audio_module.c 
b/drivers/staging/greybus/audio_module.c
index c52c4f3..a243d60 100644
--- a/drivers/staging/greybus/audio_module.c
+++ b/drivers/staging/greybus/audio_module.c
@@ -175,8 +175,8 @@ static int gbaudio_codec_request_handler(struct 
gb_operation *op)
 }
 
 static int gb_audio_add_mgmt_connection(struct gbaudio_module_info *gbmodule,
-   struct greybus_descriptor_cport *cport_desc,
-   struct gb_bundle *bundle)
+   struct greybus_descriptor_cport 
*cport_desc,
+   struct gb_bundle *bundle)
 {
struct gb_connection *connection;
 
@@ -199,8 +199,8 @@ static int gb_audio_add_mgmt_connection(struct 
gbaudio_module_info *gbmodule,
 }
 
 static int gb_audio_add_data_connection(struct gbaudio_module_info *gbmodule,
-   struct greybus_descriptor_cport *cport_desc,
-   struct gb_bundle *bundle)
+   struct greybus_descriptor_cport 
*cport_desc,
+   struct gb_bundle *bundle)
 {
struct gb_connection *connection;
struct gbaudio_data_connection *dai;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC PKS/PMEM 26/58] fs/zonefs: Utilize new kmap_thread()

2020-10-11 Thread Damien Le Moal
On 2020/10/10 4:52, ira.we...@intel.com wrote:
> From: Ira Weiny 
> 
> The kmap() calls in this FS are localized to a single thread.  To avoid
> the over head of global PKRS updates use the new kmap_thread() call.
> 
> Cc: Damien Le Moal 
> Cc: Naohiro Aota 
> Signed-off-by: Ira Weiny 
> ---
>  fs/zonefs/super.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 8ec7c8f109d7..2fd6c86beee1 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -1297,7 +1297,7 @@ static int zonefs_read_super(struct super_block *sb)
>   if (ret)
>   goto free_page;
>  
> - super = kmap(page);
> + super = kmap_thread(page);
>  
>   ret = -EINVAL;
>   if (le32_to_cpu(super->s_magic) != ZONEFS_MAGIC)
> @@ -1349,7 +1349,7 @@ static int zonefs_read_super(struct super_block *sb)
>   ret = 0;
>  
>  unmap:
> - kunmap(page);
> + kunmap_thread(page);
>  free_page:
>   __free_page(page);
>  
> 

acked-by: Damien Le Moal 

-- 
Damien Le Moal
Western Digital Research
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC PKS/PMEM 10/58] drivers/rdma: Utilize new kmap_thread()

2020-10-11 Thread Ira Weiny
On Sat, Oct 10, 2020 at 11:36:49AM +, Bernard Metzler wrote:
> -ira.we...@intel.com wrote: -
> 

[snip]

> >@@ -505,7 +505,7 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx,
> >struct socket *s)
> > page_array[seg] = p;
> > 
> > if (!c_tx->use_sendpage) {
> >-iov[seg].iov_base = kmap(p) + fp_off;
> >+iov[seg].iov_base = kmap_thread(p) + 
> >fp_off;
> 
> This misses a corresponding kunmap_thread() in siw_unmap_pages()
> (pls change line 403 in siw_qp_tx.c as well)

Thanks I missed that.

Done.

Ira

> 
> Thanks,
> Bernard.
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC PKS/PMEM 48/58] drivers/md: Utilize new kmap_thread()

2020-10-11 Thread Ira Weiny
On Sat, Oct 10, 2020 at 10:20:34AM +0800, Coly Li wrote:
> On 2020/10/10 03:50, ira.we...@intel.com wrote:
> > From: Ira Weiny 
> > 
> > These kmap() calls are localized to a single thread.  To avoid the over
> > head of global PKRS updates use the new kmap_thread() call.
> > 
> 
> Hi Ira,
> 
> There were a number of options considered.
> 
> 1) Attempt to change all the thread local kmap() calls to kmap_atomic()
> 2) Introduce a flags parameter to kmap() to indicate if the mapping
> should be global or not
> 3) Change ~20-30 call sites to 'kmap_global()' to indicate that they
> require a global mapping of the pages
> 4) Change ~209 call sites to 'kmap_thread()' to indicate that the
> mapping is to be used within that thread of execution only
> 
> 
> I copied the above information from patch 00/58 to this message. The
> idea behind kmap_thread() is fine to me, but as you said the new api is
> very easy to be missed in new code (even for me). I would like to be
> supportive to option 2) introduce a flag to kmap(), then we won't forget
> the new thread-localized kmap method, and people won't ask why a
> _thread() function is called but no kthread created.

Thanks for the feedback.

I'm going to hold off making any changes until others weigh in.  FWIW, I kind
of like option 2 as well.  But there is already kmap_atomic() so it seemed like
kmap_() was more in line with the current API.

Thanks,
Ira

> 
> Thanks.
> 
> 
> Coly Li
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC PKS/PMEM 57/58] nvdimm/pmem: Stray access protection for pmem->virt_addr

2020-10-11 Thread Ira Weiny
On Fri, Oct 09, 2020 at 07:53:07PM -0700, John Hubbard wrote:
> On 10/9/20 12:50 PM, ira.we...@intel.com wrote:
> > From: Ira Weiny 
> > 
> > The pmem driver uses a cached virtual address to access its memory
> > directly.  Because the nvdimm driver is well aware of the special
> > protections it has mapped memory with, we call dev_access_[en|dis]able()
> > around the direct pmem->virt_addr (pmem_addr) usage instead of the
> > unnecessary overhead of trying to get a page to kmap.
> > 
> > Signed-off-by: Ira Weiny 
> > ---
> >   drivers/nvdimm/pmem.c | 4 
> >   1 file changed, 4 insertions(+)
> > 
> > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> > index fab29b514372..e4dc1ae990fc 100644
> > --- a/drivers/nvdimm/pmem.c
> > +++ b/drivers/nvdimm/pmem.c
> > @@ -148,7 +148,9 @@ static blk_status_t pmem_do_read(struct pmem_device 
> > *pmem,
> > if (unlikely(is_bad_pmem(&pmem->bb, sector, len)))
> > return BLK_STS_IOERR;
> > +   dev_access_enable(false);
> > rc = read_pmem(page, page_off, pmem_addr, len);
> > +   dev_access_disable(false);
> 
> Hi Ira!
> 
> The APIs should be tweaked to use a symbol (GLOBAL, PER_THREAD), instead of
> true/false. Try reading the above and you'll see that it sounds like it's
> doing the opposite of what it is ("enable_this(false)" sounds like a clumsy
> API design to *disable*, right?). And there is no hint about the scope.

Sounds reasonable.

> 
> And it *could* be so much more readable like this:
> 
> dev_access_enable(DEV_ACCESS_THIS_THREAD);

I'll think about the flag name.  I'm not liking 'this thread'.

Maybe DEV_ACCESS_[GLOBAL|THREAD]

Ira

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH RFC PKS/PMEM 22/58] fs/f2fs: Utilize new kmap_thread()

2020-10-11 Thread Ira Weiny
On Fri, Oct 09, 2020 at 06:30:36PM -0700, Eric Biggers wrote:
> On Sat, Oct 10, 2020 at 01:39:54AM +0100, Matthew Wilcox wrote:
> > On Fri, Oct 09, 2020 at 02:34:34PM -0700, Eric Biggers wrote:
> > > On Fri, Oct 09, 2020 at 12:49:57PM -0700, ira.we...@intel.com wrote:
> > > > The kmap() calls in this FS are localized to a single thread.  To avoid
> > > > the over head of global PKRS updates use the new kmap_thread() call.
> > > >
> > > > @@ -2410,12 +2410,12 @@ static inline struct page 
> > > > *f2fs_pagecache_get_page(
> > > >  
> > > >  static inline void f2fs_copy_page(struct page *src, struct page *dst)
> > > >  {
> > > > -   char *src_kaddr = kmap(src);
> > > > -   char *dst_kaddr = kmap(dst);
> > > > +   char *src_kaddr = kmap_thread(src);
> > > > +   char *dst_kaddr = kmap_thread(dst);
> > > >  
> > > > memcpy(dst_kaddr, src_kaddr, PAGE_SIZE);
> > > > -   kunmap(dst);
> > > > -   kunmap(src);
> > > > +   kunmap_thread(dst);
> > > > +   kunmap_thread(src);
> > > >  }
> > > 
> > > Wouldn't it make more sense to switch cases like this to kmap_atomic()?
> > > The pages are only mapped to do a memcpy(), then they're immediately 
> > > unmapped.
> > 
> > Maybe you missed the earlier thread from Thomas trying to do something
> > similar for rather different reasons ...
> > 
> > https://lore.kernel.org/lkml/20200919091751.06...@linutronix.de/
> 
> I did miss it.  I'm not subscribed to any of the mailing lists it was sent to.
> 
> Anyway, it shouldn't matter.  Patchsets should be standalone, and not require
> reading random prior threads on linux-kernel to understand.

Sorry, but I did not think that the discussion above was directly related.  If
I'm not mistaken, Thomas' work was directed at relaxing kmap_atomic() into
kmap_thread() calls.  While interesting, it is not the point of this series.  I
want to restrict kmap() callers into kmap_thread().

For this series it was considered to change the kmap_thread() call sites to
kmap_atomic().  But like I said in the cover letter kmap_atomic() is not the
same semantic.  It is too strict.  Perhaps I should have expanded that
explanation.

> 
> And I still don't really understand.  After this patchset, there is still code
> nearly identical to the above (doing a temporary mapping just for a memcpy) 
> that
> would still be using kmap_atomic().

I don't understand.  You mean there would be other call sites calling:

kmap_atomic()
memcpy()
kunmap_atomic()

?

> Is the idea that later, such code will be
> converted to use kmap_thread() instead?  If not, why use one over the other?
 

The reason for the new call is that with PKS added behind kmap we have 3 levels
of mapping we want.

global kmap (can span threads and sleep)
'thread' kmap (can sleep but not span threads)
'atomic' kmap (can't sleep nor span threads [by definition])

As Matthew said perhaps 'global kmaps' may be best changed to vmaps?  I just
don't know the details of every call site.

And since I don't know the call site details if there are kmap_thread() calls
which are better off as kmap_atomic() calls I think it is worth converting
them.  But I made the assumption that kmap users would already be calling
kmap_atomic() if they could (because it is more efficient).

Ira
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel