From 42776c14c69224a75c781852ae4ca9a4811fd075 Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Mon, 2 Sep 2019 16:08:30 +0300 Subject: staging: iio: adc: ad7192: Add system calibration support This patch will add a system calibration attribute for each channel. Using this option the user will have the ability to calibrate each channel for zero scale and full scale. It uses the iio_chan_spec_ext_info and IIO_ENUM to implement the functionality. Signed-off-by: Mircea Caprioru Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7192.c | 79 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index e6b660489165..bf3e2a9cc07f 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -155,6 +155,11 @@ * The DOUT/RDY output must also be wired to an interrupt capable GPIO. */ +enum { + AD7192_SYSCALIB_ZERO_SCALE, + AD7192_SYSCALIB_FULL_SCALE, +}; + struct ad7192_state { struct regulator *avdd; struct regulator *dvdd; @@ -169,10 +174,80 @@ struct ad7192_state { u8 devid; u8 clock_sel; struct mutex lock; /* protect sensor state */ + u8 syscalib_mode[8]; struct ad_sigma_delta sd; }; +static const char * const ad7192_syscalib_modes[] = { + [AD7192_SYSCALIB_ZERO_SCALE] = "zero_scale", + [AD7192_SYSCALIB_FULL_SCALE] = "full_scale", +}; + +static int ad7192_set_syscalib_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int mode) +{ + struct ad7192_state *st = iio_priv(indio_dev); + + st->syscalib_mode[chan->channel] = mode; + + return 0; +} + +static int ad7192_get_syscalib_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct ad7192_state *st = iio_priv(indio_dev); + + return st->syscalib_mode[chan->channel]; +} + +static ssize_t ad7192_write_syscalib(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + const char *buf, size_t len) +{ + struct ad7192_state *st = iio_priv(indio_dev); + bool sys_calib; + int ret, temp; + + ret = strtobool(buf, &sys_calib); + if (ret) + return ret; + + temp = st->syscalib_mode[chan->channel]; + if (sys_calib) { + if (temp == AD7192_SYSCALIB_ZERO_SCALE) + ret = ad_sd_calibrate(&st->sd, AD7192_MODE_CAL_SYS_ZERO, + chan->address); + else + ret = ad_sd_calibrate(&st->sd, AD7192_MODE_CAL_SYS_FULL, + chan->address); + } + + return ret ? ret : len; +} + +static const struct iio_enum ad7192_syscalib_mode_enum = { + .items = ad7192_syscalib_modes, + .num_items = ARRAY_SIZE(ad7192_syscalib_modes), + .set = ad7192_set_syscalib_mode, + .get = ad7192_get_syscalib_mode +}; + +static const struct iio_chan_spec_ext_info ad7192_calibsys_ext_info[] = { + { + .name = "sys_calibration", + .write = ad7192_write_syscalib, + .shared = IIO_SEPARATE, + }, + IIO_ENUM("sys_calibration_mode", IIO_SEPARATE, + &ad7192_syscalib_mode_enum), + IIO_ENUM_AVAILABLE("sys_calibration_mode", &ad7192_syscalib_mode_enum), + {} +}; + static struct ad7192_state *ad_sigma_delta_to_ad7192(struct ad_sigma_delta *sd) { return container_of(sd, struct ad7192_state, sd); @@ -770,9 +845,11 @@ static int ad7192_channels_config(struct iio_dev *indio_dev) *chan = channels[i]; chan->info_mask_shared_by_all |= BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY); - if (chan->type != IIO_TEMP) + if (chan->type != IIO_TEMP) { chan->info_mask_shared_by_type_available |= BIT(IIO_CHAN_INFO_SCALE); + chan->ext_info = ad7192_calibsys_ext_info; + } chan++; } -- cgit v1.2.3-59-g8ed1b From 5a56c518c4d22c2b909eff6b18c7e40e1642c53d Mon Sep 17 00:00:00 2001 From: Rohit Sarkar Date: Sat, 14 Sep 2019 02:06:27 +0530 Subject: staging: iio: ADIS16240: Remove unused include '#include' isn't being used anywhere. Remove it. Signed-off-by: Rohit Sarkar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16240.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index 82099db4bf0c..a480409090c0 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -7,7 +7,6 @@ #include #include -#include #include #include #include -- cgit v1.2.3-59-g8ed1b From 55ecd411c31dcbe54b5ac3af4038942cd056a63f Mon Sep 17 00:00:00 2001 From: Aliasgar Surti Date: Wed, 18 Sep 2019 14:55:49 +0530 Subject: staging: rtl8723bs: Removed unneeded variables coccicheck reported warning for unneeded variable used. This patch removes the unneeded variables. Signed-off-by: Aliasgar Surti Link: https://lore.kernel.org/r/1568798749-9855-1-git-send-email-aliasgar.surti500@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 54 +++----------------------- 1 file changed, 5 insertions(+), 49 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index d1b199e3e5bd..55c6e4546b50 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2425,13 +2425,6 @@ static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, return 0; } -static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - return ret; -} - static int rtw_get_ap_info(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -4458,43 +4451,6 @@ static int rtw_pm_set(struct net_device *dev, return ret; } -static int rtw_mp_efuse_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - int err = 0; - return err; -} - -static int rtw_mp_efuse_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - int err = 0; - return err; -} - -static int rtw_tdls(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - return ret; -} - - -static int rtw_tdls_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - return ret; -} - - - - - static int rtw_test( struct net_device *dev, struct iw_request_info *info, @@ -4744,7 +4700,7 @@ static iw_handler rtw_private_handler[] = { rtw_wx_write32, /* 0x00 */ rtw_wx_read32, /* 0x01 */ rtw_drvext_hdl, /* 0x02 */ - rtw_mp_ioctl_hdl, /* 0x03 */ + NULL, /* 0x03 */ /* for MM DTV platform */ rtw_get_ap_info, /* 0x04 */ @@ -4771,15 +4727,15 @@ static iw_handler rtw_private_handler[] = { NULL, /* 0x12 */ rtw_p2p_get2, /* 0x13 */ - rtw_tdls, /* 0x14 */ - rtw_tdls_get, /* 0x15 */ + NULL, /* 0x14 */ + NULL, /* 0x15 */ rtw_pm_set, /* 0x16 */ rtw_wx_priv_null, /* 0x17 */ rtw_rereg_nd_name, /* 0x18 */ rtw_wx_priv_null, /* 0x19 */ - rtw_mp_efuse_set, /* 0x1A */ - rtw_mp_efuse_get, /* 0x1B */ + NULL, /* 0x1A */ + NULL, /* 0x1B */ NULL, /* 0x1C is reserved for hostapd */ rtw_test, /* 0x1D */ }; -- cgit v1.2.3-59-g8ed1b From 6f406c73037f0ce2b9e30ffcb9d44661da7b7006 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 16 Sep 2019 10:22:11 +0100 Subject: staging: rtl8723bs: os_dep: fix spelling mistake "offet" -> "offset" There is a spelling mistake in a DBG_871X error message. Fix it. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20190916092211.32646-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 55c6e4546b50..8e58763c8a8d 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2786,7 +2786,7 @@ static int rtw_dbg_port(struct net_device *dev, DBG_871X("oper_ch =%d\n", rtw_get_oper_ch(padapter)); DBG_871X("oper_bw =%d\n", rtw_get_oper_bw(padapter)); - DBG_871X("oper_ch_offet =%d\n", rtw_get_oper_choffset(padapter)); + DBG_871X("oper_ch_offset =%d\n", rtw_get_oper_choffset(padapter)); break; case 0x05: -- cgit v1.2.3-59-g8ed1b From 53e3a7e1d7af57f4597e6d6329f0f3d911f21e60 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 6 Sep 2019 18:50:21 +0100 Subject: staging: rtl8723bs: core: make array op_class static const, makes object smaller Don't populate the array op_class on the stack but instead make it static const. Makes the object code smaller by 64 bytes. Before: text data bss dec hex filename 93553 7944 5056 106553 1a039 rtl8723bs/core/rtw_mlme_ext.o After: text data bss dec hex filename 93425 8008 5056 106489 19ff9 rtl8723bs/core/rtw_mlme_ext.o (gcc version 9.2.1, amd64) Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20190906175021.25103-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 2128886c9924..814b7a6bf4ea 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -344,7 +344,7 @@ static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel struct p2p_channels *channel_list) { - struct p2p_oper_class_map op_class[] = { + static const struct p2p_oper_class_map op_class[] = { { IEEE80211G, 81, 1, 13, 1, BW20 }, { IEEE80211G, 82, 14, 14, 1, BW20 }, { IEEE80211A, 115, 36, 48, 4, BW20 }, @@ -363,7 +363,7 @@ static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel for (op = 0; op_class[op].op_class; op++) { u8 ch; - struct p2p_oper_class_map *o = &op_class[op]; + const struct p2p_oper_class_map *o = &op_class[op]; struct p2p_reg_class *reg = NULL; for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { -- cgit v1.2.3-59-g8ed1b From 9cdb1928683dc4efbd69db1cac9935238ca8864d Mon Sep 17 00:00:00 2001 From: Saiyam Doshi Date: Thu, 12 Sep 2019 20:23:46 +0530 Subject: staging: rtl8723bs: remove unneeded conversion to bool Relational and logical operators evaluate to bool, explicit conversion is overly verbose and unneeded. This issue found using - Coccinelle (http://coccinelle.lip6.fr) Signed-off-by: Saiyam Doshi Link: https://lore.kernel.org/r/20190912145346.GA9013@SD.eic.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 814b7a6bf4ea..c7170a20a90c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -2922,7 +2922,8 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int i = 0; do { - ret = _issue_probereq(padapter, pssid, da, ch, append_wps, wait_ms > 0?true:false); + ret = _issue_probereq(padapter, pssid, da, ch, append_wps, + wait_ms > 0); i++; @@ -3513,7 +3514,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow } do { - ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0?true:false); + ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0); i++; @@ -3661,7 +3662,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int da = get_my_bssid(&(pmlmeinfo->network)); do { - ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0?true:false); + ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0); i++; @@ -3769,7 +3770,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int int i = 0; do { - ret = _issue_deauth(padapter, da, reason, wait_ms > 0?true:false); + ret = _issue_deauth(padapter, da, reason, wait_ms > 0); i++; -- cgit v1.2.3-59-g8ed1b From 87a966d8ca34436ee91ea7a5de229c6e2b08bb90 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Sep 2019 13:56:34 +0200 Subject: staging: rtl8723bs: remove return statements from void functions Remove unnecessary return statements from void functions reported by checkpatch. WARNING: void function return statements are not generally useful Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20190914115634.67874-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 ---------- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 1 - drivers/staging/rtl8723bs/core/rtw_security.c | 1 - drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 -- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 2 -- drivers/staging/rtl8723bs/hal/odm_DIG.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 2 -- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 1 - drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 1 - 11 files changed, 27 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 34adf5789c98..4000125054c3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -329,7 +329,6 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[3] = (u8)(curtime & 0xff) ;/* p[0]; */ pibss[4] = (u8)((curtime>>8) & 0xff) ;/* p[1]; */ pibss[5] = (u8)((curtime>>16) & 0xff) ;/* p[2]; */ - return; } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -832,8 +831,6 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) exit: spin_unlock_bh(&pmlmepriv->lock); - - return; } @@ -1840,8 +1837,6 @@ void rtw_mlme_reset_auto_scan_int(struct adapter *adapter) mlme->auto_scan_int_ms = mlme->roam_scan_int_ms; } else mlme->auto_scan_int_ms = 0; /* disabled */ - - return; } static void rtw_auto_scan_handler(struct adapter *padapter) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index c7170a20a90c..5e687f6d2c3e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3087,8 +3087,6 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short rtw_wep_encrypt(padapter, (u8 *)pmgntframe); DBG_871X("%s\n", __func__); dump_mgntframe(padapter, pmgntframe); - - return; } @@ -3406,8 +3404,6 @@ exit: rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); else rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); - - return; } /* when wait_ack is ture, this function shoule be called at process context */ @@ -5261,8 +5257,6 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi DBG_871X("report_del_sta_event: delete STA, mac_id =%d\n", mac_id); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) @@ -5307,8 +5301,6 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int DBG_871X("report_add_sta_event: add STA\n"); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } /**************************************************************************** @@ -5870,8 +5862,6 @@ void link_timer_hdl(struct timer_list *t) issue_assocreq(padapter); set_link_timer(pmlmeext, REASSOC_TO); } - - return; } void addba_timer_hdl(struct timer_list *t) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 4075de07e0a9..30137f0bd984 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -190,7 +190,6 @@ void rtw_ps_processor(struct adapter *padapter) } exit: pwrpriv->ps_processing = false; - return; } static void pwr_state_check_handler(struct timer_list *t) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 57cfe06d7d73..5ffaf9bfa6e8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -309,7 +309,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) WEP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); } - return; } /* 3 =====TKIP related ===== */ diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index ea3ea2a6b314..5ab98f3e722e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1170,8 +1170,6 @@ void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) pmlmeinfo->HT_info_enable = 1; memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); - - return; } void HTOnAssocRsp(struct adapter *padapter) diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index 3239d37087c8..1ca9063a269f 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -402,8 +402,6 @@ static void GetDeltaSwingTable_8723B( *TemperatureUP_B = (u8 *)DeltaSwingTableIdx_2GA_P_8188E; *TemperatureDOWN_B = (u8 *)DeltaSwingTableIdx_2GA_N_8188E; } - - return; } diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index 70d98c58ca97..40fe43c62c45 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -1074,7 +1074,6 @@ void odm_FAThresholdCheck( dm_FA_thres[1] = 4000; dm_FA_thres[2] = 5000; } - return; } u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index faeaf24fa833..87535a4c2e14 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -3773,7 +3773,6 @@ void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length) process_c2h_event(padapter, &C2hEvent, tmpBuf); /* c2h_handler_8723b(padapter,&C2hEvent); */ - return; } void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index 0f3301091258..e8577c084bbd 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -179,8 +179,6 @@ static void rtl8723bs_c2h_packet_handler(struct adapter *padapter, kfree(tmp); /* DBG_871X("-%s res(%d)\n", __func__, res); */ - - return; } static inline union recv_frame *try_alloc_recvframe(struct recv_priv *precvpriv, diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index f819abb756dc..67d56f3c0717 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1422,7 +1422,6 @@ void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnet DBG_8192C("%s(): cfg80211_unlink %s!! () ", __func__, select_network.Ssid.Ssid); cfg80211_put_bss(padapter->rtw_wdev->wiphy, bss); } - return; } void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index d3784c44f6d0..12f683e2e0e2 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -281,7 +281,6 @@ static void sdio_dvobj_deinit(struct sdio_func *func) sdio_deinit(dvobj); devobj_deinit(dvobj); } - return; } void rtw_set_hal_ops(struct adapter *padapter) -- cgit v1.2.3-59-g8ed1b From 8635b4c480b0d17f65bfd2d3c9522048662f7c32 Mon Sep 17 00:00:00 2001 From: Ido Tamir Date: Fri, 6 Sep 2019 14:22:41 +0300 Subject: staging: sm750fb: CHECK: Avoid CamelCase This patch fixes the checkpatch.pl warning: CHECK: Avoid CamelCase for the following files: drivers/staging/sm750fb/ddk750_chip.c drivers/staging/sm750fb/ddk750_chip.h drivers/staging/sm750fb/ddk750_mode.c Signed-off-by: Ido Tamir Link: https://lore.kernel.org/r/20190906112241.GA2144@ubuntu-kernel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_chip.c | 38 +++++++++++++++++------------------ drivers/staging/sm750fb/ddk750_chip.h | 18 ++++++++--------- drivers/staging/sm750fb/ddk750_mode.c | 8 ++++---- 3 files changed, 32 insertions(+), 32 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c index 5a317cc98a4b..e598881308d7 100644 --- a/drivers/staging/sm750fb/ddk750_chip.c +++ b/drivers/staging/sm750fb/ddk750_chip.c @@ -66,8 +66,8 @@ static void set_chip_clock(unsigned int frequency) /* * Set up PLL structure to hold the value to be set in clocks. */ - pll.inputFreq = DEFAULT_INPUT_CLOCK; /* Defined in CLOCK.H */ - pll.clockType = MXCLK_PLL; + pll.input_freq = DEFAULT_INPUT_CLOCK; /* Defined in CLOCK.H */ + pll.clock_type = MXCLK_PLL; /* * Call sm750_calc_pll_value() to fill the other fields @@ -211,13 +211,13 @@ unsigned int ddk750_get_vm_size(void) return data; } -int ddk750_init_hw(struct initchip_param *pInitParam) +int ddk750_init_hw(struct initchip_param *p_init_param) { unsigned int reg; - if (pInitParam->powerMode != 0) - pInitParam->powerMode = 0; - sm750_set_power_mode(pInitParam->powerMode); + if (p_init_param->power_mode != 0) + p_init_param->power_mode = 0; + sm750_set_power_mode(p_init_param->power_mode); /* Enable display power gate & LOCALMEM power gate*/ reg = peek32(CURRENT_GATE); @@ -238,13 +238,13 @@ int ddk750_init_hw(struct initchip_param *pInitParam) } /* Set the Main Chip Clock */ - set_chip_clock(MHz((unsigned int)pInitParam->chipClock)); + set_chip_clock(MHz((unsigned int)p_init_param->chip_clock)); /* Set up memory clock. */ - set_memory_clock(MHz(pInitParam->memClock)); + set_memory_clock(MHz(p_init_param->mem_clock)); /* Set up master clock */ - set_master_clock(MHz(pInitParam->masterClock)); + set_master_clock(MHz(p_init_param->master_clock)); /* * Reset the memory controller. @@ -252,7 +252,7 @@ int ddk750_init_hw(struct initchip_param *pInitParam) * the system might hang when sw accesses the memory. * The memory should be resetted after changing the MXCLK. */ - if (pInitParam->resetMemory == 1) { + if (p_init_param->reset_memory == 1) { reg = peek32(MISC_CTRL); reg &= ~MISC_CTRL_LOCALMEM_RESET; poke32(MISC_CTRL, reg); @@ -261,7 +261,7 @@ int ddk750_init_hw(struct initchip_param *pInitParam) poke32(MISC_CTRL, reg); } - if (pInitParam->setAllEngOff == 1) { + if (p_init_param->set_all_eng_off == 1) { sm750_enable_2d_engine(0); /* Disable Overlay, if a former application left it on */ @@ -337,13 +337,13 @@ unsigned int sm750_calc_pll_value(unsigned int request_orig, ret = 0; mini_diff = ~0; request = request_orig / 1000; - input = pll->inputFreq / 1000; + input = pll->input_freq / 1000; /* * for MXCLK register, * no POD provided, so need be treated differently */ - if (pll->clockType == MXCLK_PLL) + if (pll->clock_type == MXCLK_PLL) max_d = 3; for (N = 15; N > 1; N--) { @@ -365,7 +365,7 @@ unsigned int sm750_calc_pll_value(unsigned int request_orig, if (M < 256 && M > 0) { unsigned int diff; - tmp_clock = pll->inputFreq * M / N / X; + tmp_clock = pll->input_freq * M / N / X; diff = abs(tmp_clock - request_orig); if (diff < mini_diff) { pll->M = M; @@ -383,14 +383,14 @@ unsigned int sm750_calc_pll_value(unsigned int request_orig, return ret; } -unsigned int sm750_format_pll_reg(struct pll_value *pPLL) +unsigned int sm750_format_pll_reg(struct pll_value *p_PLL) { #ifndef VALIDATION_CHIP - unsigned int POD = pPLL->POD; + unsigned int POD = p_PLL->POD; #endif - unsigned int OD = pPLL->OD; - unsigned int M = pPLL->M; - unsigned int N = pPLL->N; + unsigned int OD = p_PLL->OD; + unsigned int M = p_PLL->M; + unsigned int N = p_PLL->N; /* * Note that all PLL's have the same format. Here, we just use diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h index 3e92b3297160..ee2e9d90f7dd 100644 --- a/drivers/staging/sm750fb/ddk750_chip.h +++ b/drivers/staging/sm750fb/ddk750_chip.h @@ -40,8 +40,8 @@ enum clock_type { }; struct pll_value { - enum clock_type clockType; - unsigned long inputFreq; /* Input clock frequency to the PLL */ + enum clock_type clock_type; + unsigned long input_freq; /* Input clock frequency to the PLL */ /* Use this when clockType = PANEL_PLL */ unsigned long M; @@ -53,41 +53,41 @@ struct pll_value { /* input struct to initChipParam() function */ struct initchip_param { /* Use power mode 0 or 1 */ - unsigned short powerMode; + unsigned short power_mode; /* * Speed of main chip clock in MHz unit * 0 = keep the current clock setting * Others = the new main chip clock */ - unsigned short chipClock; + unsigned short chip_clock; /* * Speed of memory clock in MHz unit * 0 = keep the current clock setting * Others = the new memory clock */ - unsigned short memClock; + unsigned short mem_clock; /* * Speed of master clock in MHz unit * 0 = keep the current clock setting * Others = the new master clock */ - unsigned short masterClock; + unsigned short master_clock; /* * 0 = leave all engine state untouched. * 1 = make sure they are off: 2D, Overlay, * video alpha, alpha, hardware cursors */ - unsigned short setAllEngOff; + unsigned short set_all_eng_off; /* * 0 = Do not reset the memory controller * 1 = Reset the memory controller */ - unsigned char resetMemory; + unsigned char reset_memory; /* More initialization parameter can be added if needed */ }; @@ -95,7 +95,7 @@ struct initchip_param { enum logical_chip_type sm750_get_chip_type(void); void sm750_set_chip_type(unsigned short dev_id, u8 rev_id); unsigned int sm750_calc_pll_value(unsigned int request, struct pll_value *pll); -unsigned int sm750_format_pll_reg(struct pll_value *pPLL); +unsigned int sm750_format_pll_reg(struct pll_value *p_PLL); unsigned int ddk750_get_vm_size(void); int ddk750_init_hw(struct initchip_param *pinit_param); diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 4dac691ad1b1..9722692125d7 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -81,7 +81,7 @@ static int programModeRegisters(struct mode_parameter *pModeParam, int cnt = 0; unsigned int tmp, reg; - if (pll->clockType == SECONDARY_PLL) { + if (pll->clock_type == SECONDARY_PLL) { /* programe secondary pixel clock */ poke32(CRT_PLL_CTRL, sm750_format_pll_reg(pll)); @@ -134,7 +134,7 @@ static int programModeRegisters(struct mode_parameter *pModeParam, poke32(CRT_DISPLAY_CTRL, tmp | reg); } - } else if (pll->clockType == PRIMARY_PLL) { + } else if (pll->clock_type == PRIMARY_PLL) { unsigned int reserved; poke32(PANEL_PLL_CTRL, sm750_format_pll_reg(pll)); @@ -211,8 +211,8 @@ int ddk750_setModeTiming(struct mode_parameter *parm, enum clock_type clock) struct pll_value pll; unsigned int uiActualPixelClk; - pll.inputFreq = DEFAULT_INPUT_CLOCK; - pll.clockType = clock; + pll.input_freq = DEFAULT_INPUT_CLOCK; + pll.clock_type = clock; uiActualPixelClk = sm750_calc_pll_value(parm->pixel_clock, &pll); if (sm750_get_chip_type() == SM750LE) { -- cgit v1.2.3-59-g8ed1b From 97a0ea779560fba2053b732be1beab1085a7959e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Sep 2019 13:42:57 +0200 Subject: staging: rtl8188eu: cleanup long line in rtw_mlme_ext.c Remove comparsion to NULL and unnecessary parentheses to avoid line length over 80 characters and follow kernel coding style. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20190912114257.17529-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 18dc9fc1c04a..e984b4605e91 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -507,7 +507,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) pwps_ie = rtw_get_wps_ie(cur_network->ies+_FIXED_IE_LENGTH_, cur_network->ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen); /* inerset & update wps_probe_resp_ie */ - if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) { uint wps_offset, remainder_ielen; u8 *premainder_ie; -- cgit v1.2.3-59-g8ed1b From fe11afc326f1c9450d43acc72bb84f6902262b08 Mon Sep 17 00:00:00 2001 From: Connor Kuehl Date: Fri, 20 Sep 2019 11:48:07 +0200 Subject: staging: rtl8188eu: remove unnecessary self-assignment This is a self-assignment which is redundant. Fix this by removing the self-assignment. Addresses-Coverity: ("Self assignment") Signed-off-by: Connor Kuehl Link: https://lore.kernel.org/r/20190920094807.9217-1-connor.kuehl@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 086f98d38cba..57ae0e83dd3e 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -552,7 +552,6 @@ void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */ } else { pHalData->AntDivCfg = 0; - pHalData->TRxAntDivType = pHalData->TRxAntDivType; /* The value in the driver setting of device manager. */ } DBG_88E("EEPROM : AntDivCfg = %x, TRxAntDivType = %x\n", pHalData->AntDivCfg, pHalData->TRxAntDivType); } -- cgit v1.2.3-59-g8ed1b From 1c0c5e9b23128eb5bf37d7cbf17051571420c0a6 Mon Sep 17 00:00:00 2001 From: Aurabindo Jayamohanan Date: Thu, 19 Sep 2019 11:39:50 +0000 Subject: staging: board: use appropriate macro to initialize struct Make code more readable by using macros defined for initializing struct resource Signed-off-by: Aurabindo Jayamohanan Link: https://lore.kernel.org/r/20190919113945.13700-1-mail@aurabindo.in Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/armadillo800eva.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c index 962cc0c79988..0225234dd7aa 100644 --- a/drivers/staging/board/armadillo800eva.c +++ b/drivers/staging/board/armadillo800eva.c @@ -50,16 +50,8 @@ static struct sh_mobile_lcdc_info lcdc0_info = { }; static struct resource lcdc0_resources[] = { - [0] = { - .name = "LCD0", - .start = 0xfe940000, - .end = 0xfe943fff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = 177 + 32, - .flags = IORESOURCE_IRQ, - }, + DEFINE_RES_MEM_NAMED(0xfe940000, 0x4000, "LCD0"), + DEFINE_RES_IRQ(177 + 32), }; static struct platform_device lcdc0_device = { -- cgit v1.2.3-59-g8ed1b From 88b3673ec0d6403c25d52e0a46797485e9d01150 Mon Sep 17 00:00:00 2001 From: Rohit Sarkar Date: Tue, 10 Sep 2019 23:54:15 +0530 Subject: staging: rtl8192u: ieee80211: Replace snprintf with scnprintf When the number of bytes to be printed exceeds the limit snprintf returns the number of bytes that would have been printed (if there was no truncation). This might cause issues, hence use scnprintf which returns the actual number of bytes printed to buffer always. Signed-off-by: Rohit Sarkar Link: https://lore.kernel.org/r/20190910182415.GA5768@SARKAR Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 5c33bcb0db2e..00fea127bdc3 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1620,7 +1620,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, for (i = 0; i < network->rates_len; i++) { network->rates[i] = info_element->data[i]; #ifdef CONFIG_IEEE80211_DEBUG - p += snprintf(p, sizeof(rates_str) - + p += scnprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]); #endif @@ -1647,7 +1647,7 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, for (i = 0; i < network->rates_ex_len; i++) { network->rates_ex[i] = info_element->data[i]; #ifdef CONFIG_IEEE80211_DEBUG - p += snprintf(p, sizeof(rates_str) - + p += scnprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates_ex[i]); #endif diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 9dd5c04181ea..33c596f9ec96 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -109,7 +109,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, /* Add basic and extended rates */ max_rate = 0; p = custom; - p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); + p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); for (i = 0, j = 0; i < network->rates_len; ) { if (j < network->rates_ex_len && ((network->rates_ex[j] & 0x7F) < @@ -119,12 +119,12 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, rate = network->rates[i++] & 0x7F; if (rate > max_rate) max_rate = rate; - p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), + p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); } for (; j < network->rates_ex_len; j++) { rate = network->rates_ex[j] & 0x7F; - p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), + p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); if (rate > max_rate) max_rate = rate; @@ -214,7 +214,7 @@ static inline char *rtl819x_translate_scan(struct ieee80211_device *ieee, * for given network. */ iwe.cmd = IWEVCUSTOM; p = custom; - p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), + p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) -- cgit v1.2.3-59-g8ed1b From 78f7aac11e0d6270b347223f1677cc0183730f86 Mon Sep 17 00:00:00 2001 From: Sumera Priyadarsini Date: Wed, 18 Sep 2019 19:27:42 +0530 Subject: staging: rtl8192u: Remove unnecessary blank lines This patch fixes the file r8192U_core.c to avoid the chechpatch.pl warnings: CHECK: Please don't use multiple blank lines CHECK: Blank lines aren't necessary before a close brace '}' Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/95ce1564a34ff65e51fd63a241713e23e12dac91.1568814125.git.sylphrenadin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 70 ---------------------------------- 1 file changed, 70 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 2821411878ce..ecdd4b1e95c5 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -98,8 +98,6 @@ static char *ifname = "wlan%d"; static int hwwep = 1; /* default use hw. set 0 to use software security */ static int channels = 0x3fff; - - module_param(ifname, charp, 0644); module_param(hwwep, int, 0644); module_param(channels, int, 0644); @@ -112,7 +110,6 @@ static int rtl8192_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); static void rtl8192_usb_disconnect(struct usb_interface *intf); - static struct usb_driver rtl8192_usb_driver = { .name = RTL819XU_MODULE_NAME, /* Driver name */ .id_table = rtl8192_usb_id_tbl, /* PCI_ID table */ @@ -122,7 +119,6 @@ static struct usb_driver rtl8192_usb_driver = { .resume = NULL, /* PM resume fn */ }; - struct CHANNEL_LIST { u8 Channel[32]; u8 Len; @@ -207,9 +203,6 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv) } } - - - static void CamResetAllEntry(struct net_device *dev) { u32 ulcommand = 0; @@ -297,7 +290,6 @@ int write_nic_byte(struct net_device *dev, int indx, u8 data) return 0; } - int write_nic_word(struct net_device *dev, int indx, u16 data) { int status; @@ -324,7 +316,6 @@ int write_nic_word(struct net_device *dev, int indx, u16 data) return 0; } - int write_nic_dword(struct net_device *dev, int indx, u32 data) { int status; @@ -343,7 +334,6 @@ int write_nic_dword(struct net_device *dev, int indx, u32 data) usbdata, 4, HZ / 2); kfree(usbdata); - if (status < 0) { netdev_err(dev, "%s TimeOut! status: %d\n", __func__, status); return status; @@ -352,8 +342,6 @@ int write_nic_dword(struct net_device *dev, int indx, u32 data) return 0; } - - int read_nic_byte(struct net_device *dev, int indx, u8 *data) { int status; @@ -379,8 +367,6 @@ int read_nic_byte(struct net_device *dev, int indx, u8 *data) return 0; } - - int read_nic_word(struct net_device *dev, int indx, u16 *data) { int status; @@ -788,7 +774,6 @@ void rtl8192_set_rxconf(struct net_device *dev) rxconf = rxconf | RCR_CBSSID; } - if (priv->ieee80211->iw_mode == IW_MODE_MONITOR) { rxconf = rxconf | RCR_AICV; rxconf = rxconf | RCR_APWRMGT; @@ -797,7 +782,6 @@ void rtl8192_set_rxconf(struct net_device *dev) if (priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR) rxconf = rxconf | RCR_ACRC32; - rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK; rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE << RX_FIFO_THRESHOLD_SHIFT); rxconf = rxconf & ~MAX_RX_DMA_MASK; @@ -901,13 +885,11 @@ static u32 rtl819xusb_rx_command_packet(struct net_device *dev, return status; } - static void rtl8192_data_hard_stop(struct net_device *dev) { /* FIXME !! */ } - static void rtl8192_data_hard_resume(struct net_device *dev) { /* FIXME !! */ @@ -951,7 +933,6 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 queue_index = tcb_desc->queue_index; - spin_lock_irqsave(&priv->tx_lock, flags); memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); @@ -1123,7 +1104,6 @@ static void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) } } - #define SHORT_SLOT_TIME 9 #define NON_SHORT_SLOT_TIME 20 @@ -1188,7 +1168,6 @@ static void rtl8192_net_update(struct net_device *dev) */ void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate) { - } short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) @@ -1389,7 +1368,6 @@ static u8 MRateToHwRate8190Pci(u8 rate) return ret; } - static u8 QueryIsShort(u8 TxHT, u8 TxRate, struct cb_desc *tcb_desc) { u8 tmp_Short; @@ -1742,7 +1720,6 @@ static const struct ieee80211_qos_parameters def_qos_parameters = { {0, 0, 0, 0} /* tx_op_limit */ }; - static void rtl8192_update_beacon(struct work_struct *work) { struct r8192_priv *priv = container_of(work, struct r8192_priv, @@ -1913,11 +1890,9 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, if (set_qos_param == 1) schedule_work(&priv->qos_activate); - return 0; } - static int rtl8192_handle_assoc_response( struct net_device *dev, struct ieee80211_assoc_response_frame *resp, @@ -1929,7 +1904,6 @@ static int rtl8192_handle_assoc_response( return 0; } - static void rtl8192_update_ratr_table(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -2218,7 +2192,6 @@ static void rtl8192_init_priv_task(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - INIT_WORK(&priv->reset_wq, rtl8192_restart); INIT_DELAYED_WORK(&priv->watch_dog_wq, @@ -2515,7 +2488,6 @@ static int rtl8192_read_eeprom_info(struct net_device *dev) break; } - if (priv->rf_type == RF_1T2R) RT_TRACE(COMP_EPROM, "\n1T2R config\n"); else @@ -2668,7 +2640,6 @@ static void rtl8192_hwconfig(struct net_device *dev) /* Set Auto Rate fallback control */ } - /* InitializeAdapter and PhyCfg */ static bool rtl8192_adapter_start(struct net_device *dev) { @@ -2803,14 +2774,12 @@ static bool rtl8192_adapter_start(struct net_device *dev) RT_TRACE(COMP_INIT, "%s():after phy RF config\n", __func__); } - if (priv->ieee80211->FwRWRF) /* We can force firmware to do RF-R/W */ priv->Rf_Mode = RF_OP_By_FW; else priv->Rf_Mode = RF_OP_By_SW_3wire; - rtl8192_phy_updateInitGain(dev); /*--set CCK and OFDM Block "ON"--*/ rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1); @@ -2865,7 +2834,6 @@ static bool rtl8192_adapter_start(struct net_device *dev) } write_nic_byte(dev, 0x87, 0x0); - return init_status; } @@ -2996,7 +2964,6 @@ static RESET_TYPE RxCheckStuck(struct net_device *dev) return RESET_TYPE_NORESET; } - /** * This function is called by Checkforhang to check whether we should * ask OS to reset driver @@ -3052,8 +3019,6 @@ static void rtl8192_cancel_deferred_work(struct r8192_priv *priv); static int _rtl8192_up(struct net_device *dev); static int rtl8192_close(struct net_device *dev); - - static void CamRestoreAllEntry(struct net_device *dev) { u8 EntryId = 0; @@ -3070,7 +3035,6 @@ static void CamRestoreAllEntry(struct net_device *dev) RT_TRACE(COMP_SEC, "%s:\n", __func__); - if ((priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP40) || (priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP104)) { for (EntryId = 0; EntryId < 4; EntryId++) { @@ -3096,8 +3060,6 @@ static void CamRestoreAllEntry(struct net_device *dev) MacAddr, 0, NULL); } - - if (priv->ieee80211->group_key_type == KEY_TYPE_TKIP) { MacAddr = CAM_CONST_BROAD; for (EntryId = 1; EntryId < 4; EntryId++) { @@ -3134,7 +3096,6 @@ static void rtl819x_ifsilentreset(struct net_device *dev) int reset_status = 0; struct ieee80211_device *ieee = priv->ieee80211; - /* If we need to check CCK stop, please uncomment this line. */ /* bStuck = Adapter->HalFunc.CheckHWStopHandler(Adapter); */ @@ -3258,7 +3219,6 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, } } - static void rtl819x_watchdog_wqcallback(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); @@ -3369,7 +3329,6 @@ static int _rtl8192_up(struct net_device *dev) return 0; } - static int rtl8192_open(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3381,7 +3340,6 @@ static int rtl8192_open(struct net_device *dev) return ret; } - int rtl8192_up(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3392,7 +3350,6 @@ int rtl8192_up(struct net_device *dev) return _rtl8192_up(dev); } - static int rtl8192_close(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3440,7 +3397,6 @@ int rtl8192_down(struct net_device *dev) deinit_hal_dm(dev); del_timer_sync(&priv->watch_dog_timer); - ieee80211_softmac_stop_protocol(priv->ieee80211); memset(&priv->ieee80211->current_network, 0, offsetof(struct ieee80211_network, list)); @@ -3449,7 +3405,6 @@ int rtl8192_down(struct net_device *dev) return 0; } - void rtl8192_commit(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3495,7 +3450,6 @@ static void r8192_set_multicast(struct net_device *dev) priv->promisc = promisc; } - static int r8192_set_mac_adr(struct net_device *dev, void *mac) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3525,7 +3479,6 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) mutex_lock(&priv->wx_mutex); - if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; goto out; @@ -3778,7 +3731,6 @@ static long rtl819x_translate_todbm(u8 signal_strength_index) return signal_power; } - /* We can not declare RSSI/EVM total value of sliding window to * be a local static. Otherwise, it may increase when we return from S3/S4. The * value will be kept in memory or disk. Declare the value in the adaptor @@ -3841,7 +3793,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, if (!bcheck) return; - /* only rtl8190 supported * rtl8190_process_cck_rxpathsel(priv,pprevious_stats); */ @@ -3851,7 +3802,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, /* record the general signal strength to the sliding window. */ - /* <2> Showed on UI for engineering * hardware does not provide rssi information for each rf path in CCK */ @@ -3881,7 +3831,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, } } - /* Check PWDB. */ RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", pprevious_stats->bIsCCK ? "CCK" : "OFDM", @@ -3908,7 +3857,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, pprevious_stats->bIsCCK ? "CCK" : "OFDM", pprevious_stats->RxPWDBAll); - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) { @@ -4083,7 +4031,6 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, u8 rf_rx_num = 0; u8 sq; - priv->stats.numqry_phystatus++; is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); @@ -4214,7 +4161,6 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, precord_stats->RxMIMOSignalStrength[i] = (u8)RSSI; } - /* (2)PWDB, Average PWDB calculated by hardware * (for rate adaptive) */ @@ -4259,7 +4205,6 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, evm & 0xff; } - /* record rx statistics for debug */ rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *) @@ -4297,7 +4242,6 @@ static void rtl8192_record_rxdesc_forlateruse( ptarget_stats->Seq_Num = psrc_stats->Seq_Num; } - static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, struct ieee80211_rx_stats *pstats, struct rx_drvinfo_819x_usb *pdrvinfo) @@ -4341,8 +4285,6 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, bToSelfBA = true; } - - if (bpacket_match_bssid) priv->stats.numpacket_matchbssid++; if (bpacket_toself) @@ -4383,7 +4325,6 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev, /* 1: short preamble/GI, 0: long preamble/GI */ u32 preamble_guardinterval; - if (stats->bCRC) rcvType = 2; else if (stats->bICV) @@ -4491,7 +4432,6 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev, priv->stats.received_rate_histogram[rcvType][rateIndex]++; } - static void query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe) @@ -4556,7 +4496,6 @@ static void query_rxdesc_status(struct sk_buff *skb, stats->bShortPreamble = driver_info->SPLCP; - UpdateReceivedRateHistogramStatistics8190(dev, stats); stats->bIsAMPDU = (driver_info->PartAggr == 1); @@ -4671,8 +4610,6 @@ static void rtl819xusb_process_received_packet( #ifdef SW_CRC_CHECK SwCrcCheck(); #endif - - } static void query_rx_cmdpkt_desc_status(struct sk_buff *skb, @@ -4691,7 +4628,6 @@ static void query_rx_cmdpkt_desc_status(struct sk_buff *skb, stats->ntotalfrag = 1; } - static void rtl8192_rx_cmd(struct sk_buff *skb) { struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; @@ -4759,7 +4695,6 @@ static const struct net_device_ops rtl8192_netdev_ops = { .ndo_start_xmit = ieee80211_xmit, }; - /**************************************************************************** * ---------------------------- USB_STUFF--------------------------- *****************************************************************************/ @@ -4815,7 +4750,6 @@ static int rtl8192_usb_probe(struct usb_interface *intf, RT_TRACE(COMP_INIT, "dev name=======> %s\n", dev->name); rtl8192_proc_init_one(dev); - RT_TRACE(COMP_INIT, "Driver probe completed\n"); return 0; @@ -4843,7 +4777,6 @@ static void rtl8192_cancel_deferred_work(struct r8192_priv *priv) cancel_work_sync(&priv->qos_activate); } - static void rtl8192_usb_disconnect(struct usb_interface *intf) { struct net_device *dev = usb_get_intfdata(intf); @@ -4907,7 +4840,6 @@ static int __init rtl8192_usb_module_init(void) return usb_register(&rtl8192_usb_driver); } - static void __exit rtl8192_usb_module_exit(void) { usb_deregister(&rtl8192_usb_driver); @@ -4949,7 +4881,6 @@ void EnableHWSecurityConfig8192(struct net_device *dev) write_nic_byte(dev, SECR, SECR_value); } - void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent) { @@ -4970,7 +4901,6 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, else usConfig |= BIT(15) | (KeyType << 2) | KeyIndex; - for (i = 0; i < CAM_CONTENT_COUNT; i++) { TargetCommand = i + CAM_CONTENT_COUNT * EntryNo; TargetCommand |= BIT(31) | BIT(16); -- cgit v1.2.3-59-g8ed1b From 3278ef5961e0e28a57b774cf506e141facc9af4d Mon Sep 17 00:00:00 2001 From: Sumera Priyadarsini Date: Wed, 18 Sep 2019 19:27:43 +0530 Subject: staging: rtl8192u: Fix alignment to match open parenthesis This patch fixes the file r8192U_core.c to avoid the checkpatch.pl warning: CHECK: Alignment should match open parenthesis Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/07a4311b70ed22833a01a9067418639905041cb7.1568814125.git.sylphrenadin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index ecdd4b1e95c5..f361cae78106 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -614,13 +614,13 @@ static void rtl8192_proc_init_one(struct net_device *dev) return; proc_create_single("stats-rx", S_IFREG | S_IRUGO, dir, - proc_get_stats_rx); + proc_get_stats_rx); proc_create_single("stats-tx", S_IFREG | S_IRUGO, dir, - proc_get_stats_tx); + proc_get_stats_tx); proc_create_single("stats-ap", S_IFREG | S_IRUGO, dir, - proc_get_stats_ap); + proc_get_stats_ap); proc_create_single("registers", S_IFREG | S_IRUGO, dir, - proc_get_registers); + proc_get_registers); } static void rtl8192_proc_remove_one(struct net_device *dev) @@ -4508,7 +4508,7 @@ static void query_rxdesc_status(struct sk_buff *skb, /* Rx A-MPDU */ if (driver_info->FirstAGGR == 1 || driver_info->PartAggr == 1) RT_TRACE(COMP_RXDESC, - "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n", + "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n", driver_info->FirstAGGR, driver_info->PartAggr); } -- cgit v1.2.3-59-g8ed1b From c2e323290f9f7cd0d8115a7e7ad4d3311e5a2aa9 Mon Sep 17 00:00:00 2001 From: Sumera Priyadarsini Date: Wed, 18 Sep 2019 19:27:44 +0530 Subject: staging: rtl8192u: Remove unnecessary line-breaks in function signatures This patch fixes the function signatures for rtl8192_handle_assoc_response, rtl8192_record_rxdesc_forlateruse, rtl819xusb_process_received_packet and other relevant code blocks to avoid the checkpatch.pl warning: CHECK: Lines should not end with a '(' Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/ed06fc34eecd883f02bb9a037522b65c63a5eec4.1568814125.git.sylphrenadin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index f361cae78106..f0f755f8d8a1 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1893,10 +1893,9 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, return 0; } -static int rtl8192_handle_assoc_response( - struct net_device *dev, - struct ieee80211_assoc_response_frame *resp, - struct ieee80211_network *network) +static int rtl8192_handle_assoc_response(struct net_device *dev, + struct ieee80211_assoc_response_frame *resp, + struct ieee80211_network *network) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3808,10 +3807,9 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, if (!pprevious_stats->bIsCCK && (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) { for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) { - if (!rtl8192_phy_CheckIsLegalRFPath( - priv->ieee80211->dev, rfpath)) + if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, + rfpath)) continue; - if (priv->stats.rx_rssi_percentage[rfpath] == 0) priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; @@ -4139,8 +4137,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, else continue; - if (!rtl8192_phy_CheckIsLegalRFPath( - priv->ieee80211->dev, i)) + if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i)) continue; rx_pwr[i] = @@ -4233,9 +4230,8 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, } } /* QueryRxPhyStatus8190Pci */ -static void rtl8192_record_rxdesc_forlateruse( - struct ieee80211_rx_stats *psrc_stats, - struct ieee80211_rx_stats *ptarget_stats) +static void rtl8192_record_rxdesc_forlateruse(struct ieee80211_rx_stats *psrc_stats, + struct ieee80211_rx_stats *ptarget_stats) { ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; @@ -4466,8 +4462,7 @@ static void query_rxdesc_status(struct sk_buff *skb, * Driver info are written to the RxBuffer following rx desc */ if (stats->RxDrvInfoSize != 0) { - driver_info = (struct rx_drvinfo_819x_usb *)( - skb->data + driver_info = (struct rx_drvinfo_819x_usb *)(skb->data + sizeof(struct rx_desc_819x_usb) + stats->RxBufShift ); @@ -4575,9 +4570,8 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) } } -static void rtl819xusb_process_received_packet( - struct net_device *dev, - struct ieee80211_rx_stats *pstats) +static void rtl819xusb_process_received_packet(struct net_device *dev, + struct ieee80211_rx_stats *pstats) { struct r8192_priv *priv = ieee80211_priv(dev); -- cgit v1.2.3-59-g8ed1b From e40219d5e4b2177bfd4d885e7b64e3b236af40ac Mon Sep 17 00:00:00 2001 From: Jerry Lin Date: Fri, 6 Sep 2019 09:06:14 +0800 Subject: staging: olpc_dcon: allow simultaneous XO-1 and XO-1.5 support This patch remove model related configuration. Since the module can decide which platform data to use itself base on current running olpc board. Also change module dependency from (GPIO_CS5535 || GPIO_CS5535=n) to (GPIO_CS5535 || ACPI) because original one does not make any sense and module only doing real work when GPIO_CS5535 or ACPI is setted. Remove kernel configurations: - FB_OLPC_DCON_1 - FB_OLPC_DCON_1_5 Signed-off-by: Jerry Lin Link: https://lore.kernel.org/r/20190906010613.GA562@compute1 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/Kconfig | 21 +-------------------- drivers/staging/olpc_dcon/Makefile | 4 +--- drivers/staging/olpc_dcon/TODO | 1 - drivers/staging/olpc_dcon/olpc_dcon.c | 6 +----- drivers/staging/olpc_dcon/olpc_dcon.h | 5 ----- 5 files changed, 3 insertions(+), 34 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig index f5c716bb3413..4ae271ff2baf 100644 --- a/drivers/staging/olpc_dcon/Kconfig +++ b/drivers/staging/olpc_dcon/Kconfig @@ -3,7 +3,7 @@ config FB_OLPC_DCON tristate "One Laptop Per Child Display CONtroller support" depends on OLPC && FB depends on I2C - depends on (GPIO_CS5535 || GPIO_CS5535=n) + depends on (GPIO_CS5535 || ACPI) select BACKLIGHT_CLASS_DEVICE help In order to support very low power operation, the XO laptop uses a @@ -15,22 +15,3 @@ config FB_OLPC_DCON This controller is only available on OLPC platforms. Unless you have one of these platforms, you will want to say 'N'. -config FB_OLPC_DCON_1 - bool "OLPC XO-1 DCON support" - depends on FB_OLPC_DCON && GPIO_CS5535 - default y - help - Enable support for the DCON in XO-1 model laptops. The kernel - communicates with the DCON using model-specific code. If you - have an XO-1 (or if you're unsure what model you have), you should - say 'Y'. - -config FB_OLPC_DCON_1_5 - bool "OLPC XO-1.5 DCON support" - depends on FB_OLPC_DCON && ACPI - default y - help - Enable support for the DCON in XO-1.5 model laptops. The kernel - communicates with the DCON using model-specific code. If you - have an XO-1.5 (or if you're unsure what model you have), you - should say 'Y'. diff --git a/drivers/staging/olpc_dcon/Makefile b/drivers/staging/olpc_dcon/Makefile index cb1248c5c162..734b2ce26066 100644 --- a/drivers/staging/olpc_dcon/Makefile +++ b/drivers/staging/olpc_dcon/Makefile @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -olpc-dcon-objs += olpc_dcon.o -olpc-dcon-$(CONFIG_FB_OLPC_DCON_1) += olpc_dcon_xo_1.o -olpc-dcon-$(CONFIG_FB_OLPC_DCON_1_5) += olpc_dcon_xo_1_5.o +olpc-dcon-objs += olpc_dcon.o olpc_dcon_xo_1.o olpc_dcon_xo_1_5.o obj-$(CONFIG_FB_OLPC_DCON) += olpc-dcon.o diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO index d8296f2ae872..7c263358b44a 100644 --- a/drivers/staging/olpc_dcon/TODO +++ b/drivers/staging/olpc_dcon/TODO @@ -8,7 +8,6 @@ TODO: internals, but isn't properly integrated, is not the correct solution. - see if vx855 gpio API can be made similar enough to cs5535 so we can share more code - - allow simultaneous XO-1 and XO-1.5 support Please send patches to Greg Kroah-Hartman and copy: diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index a254238be181..a0d6d90f4cc8 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -790,15 +790,11 @@ static struct i2c_driver dcon_driver = { static int __init olpc_dcon_init(void) { -#ifdef CONFIG_FB_OLPC_DCON_1_5 /* XO-1.5 */ if (olpc_board_at_least(olpc_board(0xd0))) pdata = &dcon_pdata_xo_1_5; -#endif -#ifdef CONFIG_FB_OLPC_DCON_1 - if (!pdata) + else pdata = &dcon_pdata_xo_1; -#endif return i2c_add_driver(&dcon_driver); } diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index 22d976a09785..41bd1360b56e 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h @@ -106,12 +106,7 @@ struct dcon_gpio { irqreturn_t dcon_interrupt(int irq, void *id); -#ifdef CONFIG_FB_OLPC_DCON_1 extern struct dcon_platform_data dcon_pdata_xo_1; -#endif - -#ifdef CONFIG_FB_OLPC_DCON_1_5 extern struct dcon_platform_data dcon_pdata_xo_1_5; -#endif #endif -- cgit v1.2.3-59-g8ed1b From d9dc93128d13ba26d2764dc339f3a34c92da229a Mon Sep 17 00:00:00 2001 From: Rohit Sarkar Date: Wed, 11 Sep 2019 00:19:31 +0530 Subject: staging: rtl8712: Replace snprintf with scnprintf When the number of bytes to be printed exceeds the limit snprintf returns the number of bytes that would have been printed (if there was no truncation). This might cause issues, hence use scnprintf which returns the actual number of bytes printed to buffer always. Signed-off-by: Rohit Sarkar Link: https://lore.kernel.org/r/20190910184931.GA8228@SARKAR Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 944336e0d2e2..b3263e953f05 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -142,7 +142,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info, memset(buf, 0, MAX_WPA_IE_LEN); n = sprintf(buf, "wpa_ie="); for (i = 0; i < wpa_len; i++) { - n += snprintf(buf + n, MAX_WPA_IE_LEN - n, + n += scnprintf(buf + n, MAX_WPA_IE_LEN - n, "%02x", wpa_ie[i]); if (n >= MAX_WPA_IE_LEN) break; @@ -162,7 +162,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info, memset(buf, 0, MAX_WPA_IE_LEN); n = sprintf(buf, "rsn_ie="); for (i = 0; i < rsn_len; i++) { - n += snprintf(buf + n, MAX_WPA_IE_LEN - n, + n += scnprintf(buf + n, MAX_WPA_IE_LEN - n, "%02x", rsn_ie[i]); if (n >= MAX_WPA_IE_LEN) break; -- cgit v1.2.3-59-g8ed1b From 0605bed9ba62e2e284be791da7ad6ee37d2f29cf Mon Sep 17 00:00:00 2001 From: Aliasgar Surti Date: Wed, 18 Sep 2019 18:46:36 +0530 Subject: staging: qlge: Removed unnecessary variable coccicheck reported warning for unnecessary variable used. This patch fixes the same by removing the variable and returning value directly. Signed-off-by: Aliasgar Surti Link: https://lore.kernel.org/r/1568812596-25926-1-git-send-email-aliasgar.surti500@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 31389ab8bdf7..5599525a19d5 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -389,7 +389,6 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 *buf, static int ql_get_ets_regs(struct ql_adapter *qdev, u32 *buf) { - int status = 0; int i; for (i = 0; i < 8; i++, buf++) { @@ -402,7 +401,7 @@ static int ql_get_ets_regs(struct ql_adapter *qdev, u32 *buf) *buf = ql_read32(qdev, CNA_ETS); } - return status; + return 0; } static void ql_get_intr_states(struct ql_adapter *qdev, u32 *buf) -- cgit v1.2.3-59-g8ed1b From 0911224b6bf4c86c486746f1f993cddb006901e1 Mon Sep 17 00:00:00 2001 From: Navid Emamdoost Date: Thu, 19 Sep 2019 20:42:54 -0500 Subject: staging: rtl8192u: release memory on error path In rtl819xU_tx_cmd if usb_submit_urb fails the allocated memories should be released. Signed-off-by: Navid Emamdoost Link: https://lore.kernel.org/r/20190920014303.31410-1-navid.emamdoost@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index f0f755f8d8a1..d4510920b0e6 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1211,6 +1211,8 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) return 0; DMESGE("Error TX CMD URB, error %d", status); + dev_kfree_skb(skb); + usb_free_urb(tx_urb); return -1; } -- cgit v1.2.3-59-g8ed1b From ca312438cf176a16d4b89350cade8789ba8d7133 Mon Sep 17 00:00:00 2001 From: Navid Emamdoost Date: Thu, 19 Sep 2019 21:51:33 -0500 Subject: staging: rtl8192u: fix multiple memory leaks on error path In rtl8192_tx on error handling path allocated urbs and also skb should be released. Signed-off-by: Navid Emamdoost Link: https://lore.kernel.org/r/20190920025137.29407-1-navid.emamdoost@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index d4510920b0e6..48f1591ed5b4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1402,7 +1402,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) (struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); struct usb_device *udev = priv->udev; int pend; - int status; + int status, rt = -1; struct urb *tx_urb = NULL, *tx_urb_zero = NULL; unsigned int idx_pipe; @@ -1546,8 +1546,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) } if (bSend0Byte) { tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC); - if (!tx_urb_zero) - return -ENOMEM; + if (!tx_urb_zero) { + rt = -ENOMEM; + goto error; + } usb_fill_bulk_urb(tx_urb_zero, udev, usb_sndbulkpipe(udev, idx_pipe), &zero, 0, tx_zero_isr, dev); @@ -1557,7 +1559,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status); - return -1; + goto error; } } netif_trans_update(dev); @@ -1568,7 +1570,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status); - return -1; + +error: + dev_kfree_skb_any(skb); + usb_free_urb(tx_urb); + usb_free_urb(tx_urb_zero); + return rt; } static short rtl8192_usb_initendpoints(struct net_device *dev) -- cgit v1.2.3-59-g8ed1b From af42abb680e33f3428a38080decd205f6b2e4770 Mon Sep 17 00:00:00 2001 From: Kefeng Wang Date: Fri, 20 Sep 2019 14:25:33 +0800 Subject: staging: Use pr_warn instead of pr_warning As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of pr_warning"), removing pr_warning so all logging messages use a consistent _warn style. Let's do it. Cc: Karsten Keil Signed-off-by: Kefeng Wang Link: https://lore.kernel.org/r/20190920062544.180997-22-wangkefeng.wang@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/isdn/gigaset/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/isdn/gigaset/interface.c b/drivers/staging/isdn/gigaset/interface.c index 17fa615a8c68..9ddadd07e707 100644 --- a/drivers/staging/isdn/gigaset/interface.c +++ b/drivers/staging/isdn/gigaset/interface.c @@ -518,7 +518,7 @@ void gigaset_if_init(struct cardstate *cs) if (!IS_ERR(cs->tty_dev)) dev_set_drvdata(cs->tty_dev, cs); else { - pr_warning("could not register device to the tty subsystem\n"); + pr_warn("could not register device to the tty subsystem\n"); cs->tty_dev = NULL; } mutex_unlock(&cs->mutex); -- cgit v1.2.3-59-g8ed1b From 01b16aed578a0302672e7a4c2a778fef2472b29e Mon Sep 17 00:00:00 2001 From: Jerry Lin Date: Wed, 25 Sep 2019 15:42:43 +0800 Subject: staging: olpc_dcon: fix wrong dependencies in Kconfig file To allow simultaneous support for XO-1 and XO-1.5. This module require GPIO_CS5535 (for 1.0) and ACPI (for 1.5) now. Reported-by: kbuild test robot Signed-off-by: Jerry Lin Link: https://lore.kernel.org/r/20190925074243.GA24947@compute1 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig index 4ae271ff2baf..d1a0dea09ef0 100644 --- a/drivers/staging/olpc_dcon/Kconfig +++ b/drivers/staging/olpc_dcon/Kconfig @@ -3,7 +3,7 @@ config FB_OLPC_DCON tristate "One Laptop Per Child Display CONtroller support" depends on OLPC && FB depends on I2C - depends on (GPIO_CS5535 || ACPI) + depends on GPIO_CS5535 && ACPI select BACKLIGHT_CLASS_DEVICE help In order to support very low power operation, the XO laptop uses a -- cgit v1.2.3-59-g8ed1b From 43821e36e5fcbc5ded28ce80290aff20445bd166 Mon Sep 17 00:00:00 2001 From: Connor Kuehl Date: Tue, 24 Sep 2019 07:28:19 -0700 Subject: staging: rtl8188eu: remove dead code/vestigial do..while loop The local variable 'bcmd_down' is always set to true almost immediately before the do-while's condition is checked. As a result, !bcmd_down evaluates to false which short circuits the logical AND operator meaning that the second operand is never reached and is therefore dead code. Furthermore, the do..while loop may be removed since it will always only execute once because 'bcmd_down' is always set to true, so the !bcmd_down evaluates to false and the loop exits immediately after the first pass. Fix this by removing the loop and its condition variables 'bcmd_down' and 'retry_cnts' While we're in there, also fix some checkpatch.pl suggestions regarding spaces around arithmetic operators like '+' Addresses-Coverity: ("Logically dead code") Signed-off-by: Connor Kuehl Link: https://lore.kernel.org/r/20190924142819.5243-1-connor.kuehl@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 55 ++++++++++++---------------- 1 file changed, 24 insertions(+), 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index 47352f210c0b..7646167a0b36 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -47,8 +47,6 @@ static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num) ******************************************/ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) { - u8 bcmd_down = false; - s32 retry_cnts = 100; u8 h2c_box_num; u32 msgbox_addr; u32 msgbox_ex_addr; @@ -71,39 +69,34 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p goto exit; /* pay attention to if race condition happened in H2C cmd setting. */ - do { - h2c_box_num = adapt->HalData->LastHMEBoxNum; - - if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) { - DBG_88E(" fw read cmd failed...\n"); - goto exit; - } - - *(u8 *)(&h2c_cmd) = ElementID; - - if (CmdLen <= 3) { - memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen); - } else { - memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, 3); - ext_cmd_len = CmdLen-3; - memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer+3, ext_cmd_len); + h2c_box_num = adapt->HalData->LastHMEBoxNum; - /* Write Ext command */ - msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); - for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) - usb_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); - } - /* Write command */ - msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); - for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) - usb_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); + if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) { + DBG_88E(" fw read cmd failed...\n"); + goto exit; + } - bcmd_down = true; + *(u8 *)(&h2c_cmd) = ElementID; - adapt->HalData->LastHMEBoxNum = - (h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS; + if (CmdLen <= 3) { + memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, CmdLen); + } else { + memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, 3); + ext_cmd_len = CmdLen - 3; + memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer + 3, ext_cmd_len); + + /* Write Ext command */ + msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); + for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) + usb_write8(adapt, msgbox_ex_addr + cmd_idx, *((u8 *)(&h2c_cmd_ex) + cmd_idx)); + } + /* Write command */ + msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); + for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) + usb_write8(adapt, msgbox_addr + cmd_idx, *((u8 *)(&h2c_cmd) + cmd_idx)); - } while ((!bcmd_down) && (retry_cnts--)); + adapt->HalData->LastHMEBoxNum = + (h2c_box_num + 1) % RTL88E_MAX_H2C_BOX_NUMS; ret = _SUCCESS; -- cgit v1.2.3-59-g8ed1b From 5dec9a28778e0b857eed9817d957460a23c9053b Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 26 Sep 2019 13:50:57 +0100 Subject: staging: rtl8192e: clean up indentation issue The RT_TRACE is indented incorrectly, add in the missing tabs. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20190926125057.16158-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index f932cb15e4e5..b08712a9c029 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -715,8 +715,8 @@ void rtl92e_set_wireless_mode(struct net_device *dev, u8 wireless_mode) if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) { priv->rtllib->pHTInfo->bEnableHT = 1; - RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", - __func__, wireless_mode); + RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 1\n", + __func__, wireless_mode); } else { priv->rtllib->pHTInfo->bEnableHT = 0; RT_TRACE(COMP_DBG, "%s(), wireless_mode:%x, bEnableHT = 0\n", -- cgit v1.2.3-59-g8ed1b From 17e325285dfb50a9d729c7426d125cc8d05b2e8b Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 27 Sep 2019 10:24:00 +0100 Subject: staging: vt6656: clean up an indentation issue There is a block of code that is indented incorrectly, add in the missing tabs. Signed-off-by: Colin Ian King Reviewed-by: Quentin Deslandes Link: https://lore.kernel.org/r/20190927092400.20213-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 856ba97aec4f..3478a10f8025 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -249,10 +249,10 @@ static int vnt_init_registers(struct vnt_private *priv) } else { priv->tx_antenna_mode = ANT_B; - if (priv->tx_rx_ant_inv) - priv->rx_antenna_mode = ANT_A; - else - priv->rx_antenna_mode = ANT_B; + if (priv->tx_rx_ant_inv) + priv->rx_antenna_mode = ANT_A; + else + priv->rx_antenna_mode = ANT_B; } } -- cgit v1.2.3-59-g8ed1b From c47be36db3283bdcc071b55ccbb366fba1f57b2f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 26 Sep 2019 19:59:33 +0200 Subject: staging: rtl8723bs: remove unused function write_cam_from_cache Function write_cam_from_cache in rtw_wlan_util.c is never used, so remove it. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20190926175933.44967-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 13 ------------- drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 1 - 2 files changed, 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 5ab98f3e722e..3933e8637e57 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -606,19 +606,6 @@ inline void clear_cam_entry(struct adapter *adapter, u8 id) clear_cam_cache(adapter, id); } -inline void write_cam_from_cache(struct adapter *adapter, u8 id) -{ - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl; - struct cam_entry_cache cache; - - spin_lock_bh(&cam_ctl->lock); - memcpy(&cache, &dvobj->cam_cache[id], sizeof(struct cam_entry_cache)); - spin_unlock_bh(&cam_ctl->lock); - - _write_cam(adapter, id, cache.ctrl, cache.mac, cache.key); -} - void write_cam_cache(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key) { struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h index fd3cf955c9f8..73e8ec09b6e1 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -576,7 +576,6 @@ void read_cam(struct adapter *padapter , u8 entry, u8 *get_key); /* modify HW only */ void _write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); void _clear_cam_entry(struct adapter *padapter, u8 entry); -void write_cam_from_cache(struct adapter *adapter, u8 id); /* modify both HW and cache */ void write_cam(struct adapter *padapter, u8 id, u16 ctrl, u8 *mac, u8 *key); -- cgit v1.2.3-59-g8ed1b From 228241944a48113470d3c3b46c88ba7fbe0a274b Mon Sep 17 00:00:00 2001 From: Connor Kuehl Date: Thu, 26 Sep 2019 08:03:17 -0700 Subject: staging: rtl8188eu: fix possible null dereference Inside a nested 'else' block at the beginning of this function is a call that assigns 'psta' to the return value of 'rtw_get_stainfo()'. If 'rtw_get_stainfo()' returns NULL and the flow of control reaches the 'else if' where 'psta' is dereferenced, then we will dereference a NULL pointer. Fix this by checking if 'psta' is not NULL before reading its 'psta->qos_option' data member. Addresses-Coverity: ("Dereference null return value") Signed-off-by: Connor Kuehl Acked-by: Larry Finger Link: https://lore.kernel.org/r/20190926150317.5894-1-connor.kuehl@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 952f2ab51347..c37591657bac 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -776,7 +776,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); - if (psta->qos_option) + if (psta && psta->qos_option) qos_option = true; } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { @@ -784,7 +784,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - if (psta->qos_option) + if (psta && psta->qos_option) qos_option = true; } else { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv))); -- cgit v1.2.3-59-g8ed1b From 82e465642f93e3134227a4e5bd3418238695ad54 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 26 Sep 2019 15:14:54 +0000 Subject: staging: wilc1000: remove unnecessary netdev validation check in del_key() Removed unnecessary check to compare vif interface with zeroth index element in vif array. Already the caller takes care of passing the appropriate netdev handler during the del key operation. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20190926151436.27819-1-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 33 +++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 22f21831649b..a1ca700e045a 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -620,29 +620,26 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev, bool pairwise, const u8 *mac_addr) { - struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(netdev); struct wilc_priv *priv = &vif->priv; - if (netdev == wl->vif[0]->ndev) { - if (priv->wilc_gtk[key_index]) { - kfree(priv->wilc_gtk[key_index]->key); - priv->wilc_gtk[key_index]->key = NULL; - kfree(priv->wilc_gtk[key_index]->seq); - priv->wilc_gtk[key_index]->seq = NULL; + if (priv->wilc_gtk[key_index]) { + kfree(priv->wilc_gtk[key_index]->key); + priv->wilc_gtk[key_index]->key = NULL; + kfree(priv->wilc_gtk[key_index]->seq); + priv->wilc_gtk[key_index]->seq = NULL; - kfree(priv->wilc_gtk[key_index]); - priv->wilc_gtk[key_index] = NULL; - } + kfree(priv->wilc_gtk[key_index]); + priv->wilc_gtk[key_index] = NULL; + } - if (priv->wilc_ptk[key_index]) { - kfree(priv->wilc_ptk[key_index]->key); - priv->wilc_ptk[key_index]->key = NULL; - kfree(priv->wilc_ptk[key_index]->seq); - priv->wilc_ptk[key_index]->seq = NULL; - kfree(priv->wilc_ptk[key_index]); - priv->wilc_ptk[key_index] = NULL; - } + if (priv->wilc_ptk[key_index]) { + kfree(priv->wilc_ptk[key_index]->key); + priv->wilc_ptk[key_index]->key = NULL; + kfree(priv->wilc_ptk[key_index]->seq); + priv->wilc_ptk[key_index]->seq = NULL; + kfree(priv->wilc_ptk[key_index]); + priv->wilc_ptk[key_index] = NULL; } if (key_index <= 3 && priv->wep_key_len[key_index]) { -- cgit v1.2.3-59-g8ed1b From fb2d74342fedca6074dd3c4ae9339f76d35caac3 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 26 Sep 2019 15:14:56 +0000 Subject: staging: wilc1000: move wlan_deinit_locks() in wilc_netdev_cleanup() Move deinitialization of lock during the module remove and the initialization of lock wilc_cfg80211_init(). This to ensure locks are available during module load and gets free during unload. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20190926151436.27819-2-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_netdev.c | 14 +------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 14 ++++++++++++-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.h | 1 + 3 files changed, 14 insertions(+), 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index 508acb8bb089..d931fb2b2745 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -424,18 +424,6 @@ fail: return -1; } -static void wlan_deinit_locks(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - mutex_destroy(&wilc->hif_cs); - mutex_destroy(&wilc->rxq_cs); - mutex_destroy(&wilc->cfg_cmd_lock); - mutex_destroy(&wilc->txq_add_to_head_cs); - mutex_destroy(&wilc->vif_mutex); -} - static void wlan_deinitialize_threads(struct net_device *dev) { struct wilc_vif *vif = netdev_priv(dev); @@ -477,7 +465,6 @@ static void wilc_wlan_deinitialize(struct net_device *dev) wilc_wlan_stop(wl, vif); wilc_wlan_cleanup(dev); - wlan_deinit_locks(dev); wl->initialized = false; @@ -875,6 +862,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) flush_workqueue(wilc->hif_workqueue); destroy_workqueue(wilc->hif_workqueue); wilc_wlan_cfg_deinit(wilc); + wlan_deinit_locks(wilc); kfree(wilc->bus_data); wiphy_unregister(wilc->wiphy); wiphy_free(wilc->wiphy); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index a1ca700e045a..549b1d078198 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1802,6 +1802,15 @@ static void wlan_init_locks(struct wilc *wl) init_completion(&wl->txq_thread_started); } +void wlan_deinit_locks(struct wilc *wilc) +{ + mutex_destroy(&wilc->hif_cs); + mutex_destroy(&wilc->rxq_cs); + mutex_destroy(&wilc->cfg_cmd_lock); + mutex_destroy(&wilc->txq_add_to_head_cs); + mutex_destroy(&wilc->vif_mutex); +} + int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, const struct wilc_hif_func *ops) { @@ -1813,6 +1822,8 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, if (!wl) return -EINVAL; + wlan_init_locks(wl); + ret = wilc_wlan_cfg_init(wl); if (ret) goto free_wl; @@ -1836,8 +1847,6 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, goto free_hq; } - wlan_init_locks(wl); - return 0; free_hq: @@ -1847,6 +1856,7 @@ free_cfg: wilc_wlan_cfg_deinit(wl); free_wl: + wlan_deinit_locks(wl); wiphy_unregister(wl->wiphy); wiphy_free(wl->wiphy); return ret; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index 234faaabdb82..d802f884e525 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -24,4 +24,5 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg); struct wilc_vif *wilc_get_interface(struct wilc *wl); +void wlan_deinit_locks(struct wilc *wilc); #endif -- cgit v1.2.3-59-g8ed1b From 8399918f3056e1033f0f4c08eab437fb38d6f22d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 26 Sep 2019 15:14:59 +0000 Subject: staging: wilc1000: use RCU list to maintain vif interfaces list Make use of RCU list to maintain virtual interfaces instead of an array. The update operation on 'vif' list is less compare to the read operations. Mostly the 'vif' list elements are accessed for the read operation, so RCU list is more suited for this requirement. The shifting of interface index id's during the delete interface is not required. As the firmware only supports 2 interfaces so make use of available free slot index id during add interface. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20190926151436.27819-3-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_hif.c | 8 +- drivers/staging/wilc1000/wilc_netdev.c | 117 ++++++++++++------ drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 141 +++++++++------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.h | 1 + drivers/staging/wilc1000/wilc_wfi_netdevice.h | 4 +- 5 files changed, 148 insertions(+), 123 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_hif.c b/drivers/staging/wilc1000/wilc_hif.c index f2b7d5a1be17..0ac2b6ac50b0 100644 --- a/drivers/staging/wilc1000/wilc_hif.c +++ b/drivers/staging/wilc1000/wilc_hif.c @@ -183,11 +183,17 @@ int wilc_get_vif_idx(struct wilc_vif *vif) static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) { int index = idx - 1; + struct wilc_vif *vif; if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC) return NULL; - return wilc->vif[index]; + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->idx == index) + return vif; + } + + return NULL; } static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index d931fb2b2745..93c0d6e78813 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -97,29 +97,25 @@ void wilc_mac_indicate(struct wilc *wilc) static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) { u8 *bssid, *bssid1; - int i = 0; struct net_device *ndev = NULL; + struct wilc_vif *vif; bssid = mac_header + 10; bssid1 = mac_header + 4; - mutex_lock(&wilc->vif_mutex); - for (i = 0; i < wilc->vif_num; i++) { - if (wilc->vif[i]->mode == WILC_STATION_MODE) - if (ether_addr_equal_unaligned(bssid, - wilc->vif[i]->bssid)) { - ndev = wilc->vif[i]->ndev; + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->mode == WILC_STATION_MODE) + if (ether_addr_equal_unaligned(bssid, vif->bssid)) { + ndev = vif->ndev; goto out; } - if (wilc->vif[i]->mode == WILC_AP_MODE) - if (ether_addr_equal_unaligned(bssid1, - wilc->vif[i]->bssid)) { - ndev = wilc->vif[i]->ndev; + if (vif->mode == WILC_AP_MODE) + if (ether_addr_equal_unaligned(bssid1, vif->bssid)) { + ndev = vif->ndev; goto out; } } out: - mutex_unlock(&wilc->vif_mutex); return ndev; } @@ -137,13 +133,16 @@ void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) { - u8 i = 0; + int srcu_idx; u8 ret_val = 0; + struct wilc_vif *vif; - for (i = 0; i < wilc->vif_num; i++) - if (!is_zero_ether_addr(wilc->vif[i]->bssid)) + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (!is_zero_ether_addr(vif->bssid)) ret_val++; - + } + srcu_read_unlock(&wilc->srcu, srcu_idx); return ret_val; } @@ -167,16 +166,16 @@ static int wilc_txq_task(void *vp) do { ret = wilc_wlan_handle_txq(wl, &txq_count); if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) { - int i; + int srcu_idx; struct wilc_vif *ifc; - mutex_lock(&wl->vif_mutex); - for (i = 0; i < wl->vif_num; i++) { - ifc = wl->vif[i]; + srcu_idx = srcu_read_lock(&wl->srcu); + list_for_each_entry_rcu(ifc, &wl->vif_list, + list) { if (ifc->mac_opened && ifc->ndev) netif_wake_queue(ifc->ndev); } - mutex_unlock(&wl->vif_mutex); + srcu_read_unlock(&wl->srcu, srcu_idx); } } while (ret == -ENOBUFS && !wl->close); } @@ -725,14 +724,15 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) wilc_tx_complete); if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { - int i; + int srcu_idx; + struct wilc_vif *vif; - mutex_lock(&wilc->vif_mutex); - for (i = 0; i < wilc->vif_num; i++) { - if (wilc->vif[i]->mac_opened) - netif_stop_queue(wilc->vif[i]->ndev); + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->mac_opened) + netif_stop_queue(vif->ndev); } - mutex_unlock(&wilc->vif_mutex); + srcu_read_unlock(&wilc->srcu, srcu_idx); } return 0; @@ -810,14 +810,13 @@ void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) { - int i = 0; + int srcu_idx; struct wilc_vif *vif; - mutex_lock(&wilc->vif_mutex); - for (i = 0; i < wilc->vif_num; i++) { + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { u16 type = le16_to_cpup((__le16 *)buff); - vif = netdev_priv(wilc->vif[i]->ndev); if ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) || (type == vif->frame_reg[1].type && vif->frame_reg[1].reg)) { wilc_wfi_p2p_rx(vif, buff, size); @@ -829,7 +828,7 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) break; } } - mutex_unlock(&wilc->vif_mutex); + srcu_read_unlock(&wilc->srcu, srcu_idx); } static const struct net_device_ops wilc_netdev_ops = { @@ -843,7 +842,8 @@ static const struct net_device_ops wilc_netdev_ops = { void wilc_netdev_cleanup(struct wilc *wilc) { - int i; + struct wilc_vif *vif; + int srcu_idx; if (!wilc) return; @@ -853,14 +853,32 @@ void wilc_netdev_cleanup(struct wilc *wilc) wilc->firmware = NULL; } - for (i = 0; i < wilc->vif_num; i++) { - if (wilc->vif[i] && wilc->vif[i]->ndev) - unregister_netdev(wilc->vif[i]->ndev); + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->ndev) + unregister_netdev(vif->ndev); } + srcu_read_unlock(&wilc->srcu, srcu_idx); wilc_wfi_deinit_mon_interface(wilc, false); flush_workqueue(wilc->hif_workqueue); destroy_workqueue(wilc->hif_workqueue); + + do { + mutex_lock(&wilc->vif_mutex); + if (wilc->vif_num <= 0) { + mutex_unlock(&wilc->vif_mutex); + break; + } + vif = wilc_get_wl_to_vif(wilc); + if (!IS_ERR(vif)) + list_del_rcu(&vif->list); + + wilc->vif_num--; + mutex_unlock(&wilc->vif_mutex); + synchronize_srcu(&wilc->srcu); + } while (1); + wilc_wlan_cfg_deinit(wilc); wlan_deinit_locks(wilc); kfree(wilc->bus_data); @@ -869,6 +887,23 @@ void wilc_netdev_cleanup(struct wilc *wilc) } EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); +static u8 wilc_get_available_idx(struct wilc *wl) +{ + int idx = 0; + struct wilc_vif *vif; + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + list_for_each_entry_rcu(vif, &wl->vif_list, list) { + if (vif->idx == 0) + idx = 1; + else + idx = 0; + } + srcu_read_unlock(&wl->srcu, srcu_idx); + return idx; +} + struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, int vif_type, enum nl80211_iftype type, bool rtnl_locked) @@ -909,10 +944,14 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, ndev->needs_free_netdev = true; vif->iftype = vif_type; - vif->wilc->vif[wl->vif_num] = vif; - vif->idx = wl->vif_num; - wl->vif_num += 1; + vif->idx = wilc_get_available_idx(wl); vif->mac_opened = 0; + mutex_lock(&wl->vif_mutex); + list_add_tail_rcu(&vif->list, &wl->vif_list); + wl->vif_num += 1; + mutex_unlock(&wl->vif_mutex); + synchronize_srcu(&wl->srcu); + return vif; } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 549b1d078198..3882c90dc3fb 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -186,15 +186,15 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status, } } -static struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl) +struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl) { - int i; + struct wilc_vif *vif; - for (i = 0; i < wl->vif_num; i++) - if (wl->vif[i]) - return wl->vif[i]; + vif = list_first_or_null_rcu(&wl->vif_list, typeof(*vif), list); + if (!vif) + return ERR_PTR(-EINVAL); - return ERR_PTR(-EINVAL); + return vif; } static int set_channel(struct wiphy *wiphy, @@ -204,11 +204,12 @@ static int set_channel(struct wiphy *wiphy, struct wilc_vif *vif; u32 channelnum; int result; + int srcu_idx; - mutex_lock(&wl->vif_mutex); + srcu_idx = srcu_read_lock(&wl->srcu); vif = wilc_get_wl_to_vif(wl); if (IS_ERR(vif)) { - mutex_unlock(&wl->vif_mutex); + srcu_read_unlock(&wl->srcu, srcu_idx); return PTR_ERR(vif); } @@ -219,7 +220,7 @@ static int set_channel(struct wiphy *wiphy, if (result) netdev_err(vif->ndev, "Error in setting channel\n"); - mutex_unlock(&wl->vif_mutex); + srcu_read_unlock(&wl->srcu, srcu_idx); return result; } @@ -749,33 +750,19 @@ static int change_bss(struct wiphy *wiphy, struct net_device *dev, return 0; } -struct wilc_vif *wilc_get_interface(struct wilc *wl) -{ - int i; - struct wilc_vif *vif = NULL; - - mutex_lock(&wl->vif_mutex); - for (i = 0; i < wl->vif_num; i++) { - if (wl->vif[i]) { - vif = wl->vif[i]; - break; - } - } - mutex_unlock(&wl->vif_mutex); - return vif; -} - static int set_wiphy_params(struct wiphy *wiphy, u32 changed) { - int ret; + int ret = -EINVAL; struct cfg_param_attr cfg_param_val; struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif; struct wilc_priv *priv; + int srcu_idx; - vif = wilc_get_interface(wl); - if (!vif) - return -EINVAL; + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) + goto out; priv = &vif->priv; cfg_param_val.flag = 0; @@ -805,7 +792,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) } else { netdev_err(vif->ndev, "Fragmentation threshold out of range\n"); - return -EINVAL; + goto out; } } @@ -818,7 +805,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) cfg_param_val.rts_threshold = wiphy->rts_threshold; } else { netdev_err(vif->ndev, "RTS threshold out of range\n"); - return -EINVAL; + goto out; } } @@ -826,6 +813,8 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) if (ret) netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n"); +out: + srcu_read_unlock(&wl->srcu, srcu_idx); return ret; } @@ -1554,20 +1543,16 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, return ret; } -static int wilc_get_vif_from_type(struct wilc *wl, int type) +static struct wilc_vif *wilc_get_vif_from_type(struct wilc *wl, int type) { - int i; + struct wilc_vif *vif; - mutex_lock(&wl->vif_mutex); - for (i = 0; i < wl->vif_num; i++) { - if (wl->vif[i]->iftype == type) { - mutex_unlock(&wl->vif_mutex); - return i; - } + list_for_each_entry_rcu(vif, &wl->vif_list, list) { + if (vif->iftype == type) + return vif; } - mutex_unlock(&wl->vif_mutex); - return -EINVAL; + return NULL; } static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, @@ -1580,29 +1565,36 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, struct wilc_vif *vif; struct wireless_dev *wdev; int iftype; - int ret; if (type == NL80211_IFTYPE_MONITOR) { struct net_device *ndev; - int ap_index = wilc_get_vif_from_type(wl, WILC_AP_MODE); - - if (ap_index < 0) { - ap_index = wilc_get_vif_from_type(wl, WILC_GO_MODE); - if (ap_index < 0) + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_vif_from_type(wl, WILC_AP_MODE); + if (!vif) { + vif = wilc_get_vif_from_type(wl, WILC_GO_MODE); + if (!vif) { + srcu_read_unlock(&wl->srcu, srcu_idx); goto validate_interface; + } } - vif = wl->vif[ap_index]; - if (vif->monitor_flag) + if (vif->monitor_flag) { + srcu_read_unlock(&wl->srcu, srcu_idx); goto validate_interface; + } ndev = wilc_wfi_init_mon_interface(wl, name, vif->ndev); - if (ndev) + if (ndev) { vif->monitor_flag = 1; - else + } else { + srcu_read_unlock(&wl->srcu, srcu_idx); return ERR_PTR(-EINVAL); + } wdev = &vif->priv.wdev; + srcu_read_unlock(&wl->srcu, srcu_idx); return wdev; } @@ -1610,9 +1602,10 @@ validate_interface: mutex_lock(&wl->vif_mutex); if (wl->vif_num == WILC_NUM_CONCURRENT_IFC) { pr_err("Reached maximum number of interface\n"); - ret = -EINVAL; - goto out_err; + mutex_unlock(&wl->vif_mutex); + return ERR_PTR(-EINVAL); } + mutex_unlock(&wl->vif_mutex); switch (type) { case NL80211_IFTYPE_STATION: @@ -1622,30 +1615,20 @@ validate_interface: iftype = WILC_AP_MODE; break; default: - ret = -EOPNOTSUPP; - goto out_err; + return ERR_PTR(-EOPNOTSUPP); } vif = wilc_netdev_ifc_init(wl, name, iftype, type, true); - if (IS_ERR(vif)) { - ret = PTR_ERR(vif); - goto out_err; - } - - mutex_unlock(&wl->vif_mutex); + if (IS_ERR(vif)) + return ERR_CAST(vif); return &vif->priv.wdev; - -out_err: - mutex_unlock(&wl->vif_mutex); - return ERR_PTR(ret); } static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) { struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif; - int i; if (wdev->iftype == NL80211_IFTYPE_AP || wdev->iftype == NL80211_IFTYPE_P2P_GO) @@ -1655,22 +1638,12 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) unregister_netdevice(vif->ndev); vif->monitor_flag = 0; - mutex_lock(&wl->vif_mutex); wilc_set_operation_mode(vif, 0, 0, 0); - for (i = vif->idx; i < wl->vif_num; i++) { - if ((i + 1) >= wl->vif_num) { - wl->vif[i] = NULL; - } else { - vif = wl->vif[i + 1]; - vif->idx = i; - wl->vif[i] = vif; - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - vif->iftype, vif->idx); - } - } + mutex_lock(&wl->vif_mutex); + list_del_rcu(&vif->list); wl->vif_num--; mutex_unlock(&wl->vif_mutex); - + synchronize_srcu(&wl->srcu); return 0; } @@ -1695,16 +1668,17 @@ static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) { struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif; + int srcu_idx; - mutex_lock(&wl->vif_mutex); + srcu_idx = srcu_read_lock(&wl->srcu); vif = wilc_get_wl_to_vif(wl); if (IS_ERR(vif)) { - mutex_unlock(&wl->vif_mutex); + srcu_read_unlock(&wl->srcu, srcu_idx); return; } netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled); - mutex_unlock(&wl->vif_mutex); + srcu_read_unlock(&wl->srcu, srcu_idx); } static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, @@ -1800,6 +1774,7 @@ static void wlan_init_locks(struct wilc *wl) init_completion(&wl->cfg_event); init_completion(&wl->sync_event); init_completion(&wl->txq_thread_started); + init_srcu_struct(&wl->srcu); } void wlan_deinit_locks(struct wilc *wilc) @@ -1809,6 +1784,7 @@ void wlan_deinit_locks(struct wilc *wilc) mutex_destroy(&wilc->cfg_cmd_lock); mutex_destroy(&wilc->txq_add_to_head_cs); mutex_destroy(&wilc->vif_mutex); + cleanup_srcu_struct(&wilc->srcu); } int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, @@ -1834,6 +1810,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, wl->chip_ps_state = WILC_CHIP_WAKEDUP; INIT_LIST_HEAD(&wl->txq_head.list); INIT_LIST_HEAD(&wl->rxq_head.list); + INIT_LIST_HEAD(&wl->vif_list); wl->hif_workqueue = create_singlethread_workqueue("WILC_wq"); if (!wl->hif_workqueue) { diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index d802f884e525..7206b6162a8c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -24,5 +24,6 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg); struct wilc_vif *wilc_get_interface(struct wilc *wl); +struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl); void wlan_deinit_locks(struct wilc *wilc); #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 978a8bdbfc40..fa41b46eb245 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -208,6 +208,7 @@ struct wilc_vif { struct tcp_ack_filter ack_filter; bool connecting; struct wilc_priv priv; + struct list_head list; }; struct wilc { @@ -221,9 +222,10 @@ struct wilc { int dev_irq_num; int close; u8 vif_num; - struct wilc_vif *vif[WILC_NUM_CONCURRENT_IFC]; + struct list_head vif_list; /*protect vif list*/ struct mutex vif_mutex; + struct srcu_struct srcu; u8 open_ifcs; /*protect head of transmit queue*/ struct mutex txq_add_to_head_cs; -- cgit v1.2.3-59-g8ed1b From 854d66df74aed25cabb25e8224179374b5d5ecbe Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Mon, 16 Sep 2019 19:37:08 +0000 Subject: staging: wilc1000: look for rtc_clk clock in spi mode If rtc_clk is provided from DT, use it and enable it. This is optional. The signal may be hardcoded and no need to be requested, but if DT provides it, use it. Signed-off-by: Adham Abozaeid Link: https://lore.kernel.org/r/20190916193701.20755-1-adham.abozaeid@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_spi.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 3c1ae9e9f9aa..166455a969bf 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -4,6 +4,7 @@ * All rights reserved. */ +#include #include #include "wilc_wfi_netdevice.h" @@ -132,6 +133,12 @@ static int wilc_bus_probe(struct spi_device *spi) wilc->bus_data = spi_priv; wilc->gpio_irq = gpio; + wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk"); + if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + else if (!IS_ERR(wilc->rtc_clk)) + clk_prepare_enable(wilc->rtc_clk); + return 0; } @@ -142,6 +149,10 @@ static int wilc_bus_remove(struct spi_device *spi) /* free the GPIO in module remove */ if (wilc->gpio_irq) gpiod_put(wilc->gpio_irq); + + if (!IS_ERR(wilc->rtc_clk)) + clk_disable_unprepare(wilc->rtc_clk); + wilc_netdev_cleanup(wilc); return 0; } -- cgit v1.2.3-59-g8ed1b From 7c1a38e1fe05b7740b5e36ec0f7675f241a1e225 Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Wed, 18 Sep 2019 14:35:48 -0400 Subject: staging: fieldbus core: remove unused strings Remove two unused static const strings - a leftover from a previous stage. Interestingly, neither gcc nor sparse warned about their presence. Signed-off-by: Sven Van Asbroeck Link: https://lore.kernel.org/r/20190918183552.28959-2-TheSven73@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/dev_core.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c index f6f5b92ba914..1ba0234cc60d 100644 --- a/drivers/staging/fieldbus/dev_core.c +++ b/drivers/staging/fieldbus/dev_core.c @@ -23,9 +23,6 @@ static dev_t fieldbus_devt; static DEFINE_IDA(fieldbus_ida); static DEFINE_MUTEX(fieldbus_mtx); -static const char ctrl_enabled[] = "enabled"; -static const char ctrl_disabled[] = "disabled"; - static ssize_t online_show(struct device *dev, struct device_attribute *attr, char *buf) { -- cgit v1.2.3-59-g8ed1b From 9cc05ed4df03a60c8119b49e66f8b47436d89c27 Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Wed, 18 Sep 2019 14:35:49 -0400 Subject: staging: fieldbus: move "offline mode" definition to fieldbus core anybus-s cards use the "offline mode" property to determine if process memory should be clear, set, or frozen when the card is offline. Move this property to the fieldbus core, so that it can become part of the future fieldbus config interface. Signed-off-by: Sven Van Asbroeck Link: https://lore.kernel.org/r/20190918183552.28959-3-TheSven73@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/anybuss/anybuss-client.h | 11 ++++------- drivers/staging/fieldbus/anybuss/hms-profinet.c | 2 +- drivers/staging/fieldbus/anybuss/host.c | 6 +++--- drivers/staging/fieldbus/fieldbus_dev.h | 6 ++++++ 4 files changed, 14 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fieldbus/anybuss/anybuss-client.h b/drivers/staging/fieldbus/anybuss/anybuss-client.h index 0c4b6a1ffe10..8ee1f1baccf1 100644 --- a/drivers/staging/fieldbus/anybuss/anybuss-client.h +++ b/drivers/staging/fieldbus/anybuss/anybuss-client.h @@ -12,6 +12,9 @@ #include #include +/* move to when taking this out of staging */ +#include "../fieldbus_dev.h" + struct anybuss_host; struct anybuss_client { @@ -61,12 +64,6 @@ anybuss_set_drvdata(struct anybuss_client *client, void *data) int anybuss_set_power(struct anybuss_client *client, bool power_on); -enum anybuss_offl_mode { - AB_OFFL_MODE_CLEAR = 0, - AB_OFFL_MODE_FREEZE, - AB_OFFL_MODE_SET -}; - struct anybuss_memcfg { u16 input_io; u16 input_dpram; @@ -76,7 +73,7 @@ struct anybuss_memcfg { u16 output_dpram; u16 output_total; - enum anybuss_offl_mode offl_mode; + enum fieldbus_dev_offl_mode offl_mode; }; int anybuss_start_init(struct anybuss_client *client, diff --git a/drivers/staging/fieldbus/anybuss/hms-profinet.c b/drivers/staging/fieldbus/anybuss/hms-profinet.c index 5446843e35f4..31c43a0a5776 100644 --- a/drivers/staging/fieldbus/anybuss/hms-profinet.c +++ b/drivers/staging/fieldbus/anybuss/hms-profinet.c @@ -96,7 +96,7 @@ static int __profi_enable(struct profi_priv *priv) .output_io = 220, .output_dpram = PROFI_DPRAM_SIZE, .output_total = PROFI_DPRAM_SIZE, - .offl_mode = AB_OFFL_MODE_CLEAR, + .offl_mode = FIELDBUS_DEV_OFFL_MODE_CLEAR, }; /* diff --git a/drivers/staging/fieldbus/anybuss/host.c b/drivers/staging/fieldbus/anybuss/host.c index f69dc4930457..549cb7d51af8 100644 --- a/drivers/staging/fieldbus/anybuss/host.c +++ b/drivers/staging/fieldbus/anybuss/host.c @@ -1022,13 +1022,13 @@ int anybuss_start_init(struct anybuss_client *client, }; switch (cfg->offl_mode) { - case AB_OFFL_MODE_CLEAR: + case FIELDBUS_DEV_OFFL_MODE_CLEAR: op_mode = 0; break; - case AB_OFFL_MODE_FREEZE: + case FIELDBUS_DEV_OFFL_MODE_FREEZE: op_mode = OP_MODE_FBFC; break; - case AB_OFFL_MODE_SET: + case FIELDBUS_DEV_OFFL_MODE_SET: op_mode = OP_MODE_FBS; break; default: diff --git a/drivers/staging/fieldbus/fieldbus_dev.h b/drivers/staging/fieldbus/fieldbus_dev.h index a10fc3b446dc..301dca3b8d71 100644 --- a/drivers/staging/fieldbus/fieldbus_dev.h +++ b/drivers/staging/fieldbus/fieldbus_dev.h @@ -15,6 +15,12 @@ enum fieldbus_dev_type { FIELDBUS_DEV_TYPE_PROFINET, }; +enum fieldbus_dev_offl_mode { + FIELDBUS_DEV_OFFL_MODE_CLEAR = 0, + FIELDBUS_DEV_OFFL_MODE_FREEZE, + FIELDBUS_DEV_OFFL_MODE_SET +}; + /** * struct fieldbus_dev - Fieldbus device * @read_area: [DRIVER] function to read the process data area of the -- cgit v1.2.3-59-g8ed1b From f8fcbb6ba89c8144d3cc4ce72999672c23b82ed2 Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Thu, 3 Oct 2019 11:03:17 -0700 Subject: staging: vc04_services: Avoid typedef Avoid typedefs to maintain kernel coding style. Issue found by checkpatch.pl Replace the enum typedef VCHIQ_REASON_T with vchiq_reason. Signed-off-by: Nachammai Karuppiah Link: https://lore.kernel.org/r/1570125797-24410-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++---- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 4 ++-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index b1595b13dea8..280e237e3b42 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -516,7 +516,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, ***************************************************************************/ static VCHIQ_STATUS_T -add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, +add_completion(VCHIQ_INSTANCE_T instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, void *bulk_userdata) { @@ -583,7 +583,7 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, ***************************************************************************/ static VCHIQ_STATUS_T -service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, +service_callback(enum vchiq_reason reason, struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) { /* How do we ensure the callback goes to the right client? @@ -1666,7 +1666,7 @@ vchiq_compat_ioctl_queue_bulk(struct file *file, } struct vchiq_completion_data32 { - VCHIQ_REASON_T reason; + enum vchiq_reason reason; compat_uptr_t header; compat_uptr_t service_userdata; compat_uptr_t bulk_userdata; @@ -2271,7 +2271,7 @@ vchiq_videocore_wanted(struct vchiq_state *state) } static VCHIQ_STATUS_T -vchiq_keepalive_vchiq_callback(VCHIQ_REASON_T reason, +vchiq_keepalive_vchiq_callback(enum vchiq_reason reason, struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T service_user, void *bulk_user) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 56a23a297fa4..b0e0653ffc23 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -355,7 +355,7 @@ mark_service_closing(struct vchiq_service *service) } static inline VCHIQ_STATUS_T -make_service_callback(struct vchiq_service *service, VCHIQ_REASON_T reason, +make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, struct vchiq_header *header, void *bulk_userdata) { VCHIQ_STATUS_T status; @@ -1230,7 +1230,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, spin_unlock(&bulk_waiter_spinlock); } else if (bulk->mode == VCHIQ_BULK_MODE_CALLBACK) { - VCHIQ_REASON_T reason = (bulk->dir == + enum vchiq_reason reason = (bulk->dir == VCHIQ_BULK_TRANSMIT) ? ((bulk->actual == VCHIQ_BULK_ACTUAL_ABORTED) ? diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index c23bd105c40f..f911612a6a54 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -15,7 +15,7 @@ #define VCHIQ_GET_SERVICE_USERDATA(service) vchiq_get_service_userdata(service) #define VCHIQ_GET_SERVICE_FOURCC(service) vchiq_get_service_fourcc(service) -typedef enum { +enum vchiq_reason { VCHIQ_SERVICE_OPENED, /* service, -, - */ VCHIQ_SERVICE_CLOSED, /* service, -, - */ VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ @@ -23,7 +23,7 @@ typedef enum { VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ -} VCHIQ_REASON_T; +}; typedef enum { VCHIQ_ERROR = -1, @@ -63,7 +63,7 @@ struct vchiq_element { typedef unsigned int VCHIQ_SERVICE_HANDLE_T; -typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(VCHIQ_REASON_T, +typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(enum vchiq_reason, struct vchiq_header *, VCHIQ_SERVICE_HANDLE_T, void *); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 460ccea088bf..c2343a1a3a6a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -32,7 +32,7 @@ struct vchiq_queue_bulk_transfer { }; struct vchiq_completion_data { - VCHIQ_REASON_T reason; + enum vchiq_reason reason; struct vchiq_header *header; void *service_userdata; void *bulk_userdata; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 17a4f2c8d8b1..575e2daedc89 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -509,7 +509,7 @@ EXPORT_SYMBOL(vchi_disconnect); * ***********************************************************/ -static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason, +static VCHIQ_STATUS_T shim_callback(enum vchiq_reason reason, struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_user) -- cgit v1.2.3-59-g8ed1b From b664312285eb6bb9378159f2fea02e39886a7012 Mon Sep 17 00:00:00 2001 From: Rohit Sarkar Date: Wed, 2 Oct 2019 22:35:19 +0530 Subject: staging: rtl8712: fix boundary condition for n Now that snprintf is replaced by scnprintf n >= MAX_WPA_IE_LEN doesn't make sense as the maximum value n can take is MAX_WPA_IE_LEN. Signed-off-by: Rohit Sarkar Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20191002170518.GA1688@SARKAR Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index b3263e953f05..363b82e3e7c6 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -144,7 +144,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info, for (i = 0; i < wpa_len; i++) { n += scnprintf(buf + n, MAX_WPA_IE_LEN - n, "%02x", wpa_ie[i]); - if (n >= MAX_WPA_IE_LEN) + if (n == MAX_WPA_IE_LEN-1) break; } memset(iwe, 0, sizeof(*iwe)); @@ -164,7 +164,7 @@ static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info, for (i = 0; i < rsn_len; i++) { n += scnprintf(buf + n, MAX_WPA_IE_LEN - n, "%02x", rsn_ie[i]); - if (n >= MAX_WPA_IE_LEN) + if (n == MAX_WPA_IE_LEN-1) break; } memset(iwe, 0, sizeof(*iwe)); -- cgit v1.2.3-59-g8ed1b From b74e124e10484dae41581cb4838ab3e2467996a4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 3 Oct 2019 14:25:11 +0200 Subject: staging: rtl8188eu: convert variables from unsigned char to u8 Convert the local variables max_AMPDU_len and min_MPDU_spacing from unsigned char to u8 and remove unnecessary castings to u8 pointer. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191003122514.1760-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 51a5b71f8c25..1e4461a74474 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -560,8 +560,8 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) static void update_hw_ht_param(struct adapter *padapter) { - unsigned char max_AMPDU_len; - unsigned char min_MPDU_spacing; + u8 max_AMPDU_len; + u8 min_MPDU_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -576,9 +576,9 @@ static void update_hw_ht_param(struct adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_MPDU_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_AMPDU_len); /* */ /* Config SM Power Save setting */ -- cgit v1.2.3-59-g8ed1b From 7e3303fc8c45a7164d3af67791cea615bb4b9fd0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 3 Oct 2019 14:25:12 +0200 Subject: staging: rtl8188eu: rename variables to avoid mixed case Rename the local varibles max_AMPDU_len and min_MPDU_spacing to avoid mixed case. max_AMPDU_len -> max_ampdu_len min_MPDU_spacing -> min_mpdu_spacing Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191003122514.1760-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 1e4461a74474..75c34e8f2335 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -560,8 +560,8 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) static void update_hw_ht_param(struct adapter *padapter) { - u8 max_AMPDU_len; - u8 min_MPDU_spacing; + u8 max_ampdu_len; + u8 min_mpdu_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -572,13 +572,13 @@ static void update_hw_ht_param(struct adapter *padapter) ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k ampdu_params_info [4:2]:Min MPDU Start Spacing */ - max_AMPDU_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; + max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; - min_MPDU_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; + min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_MPDU_spacing); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_AMPDU_len); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); /* */ /* Config SM Power Save setting */ -- cgit v1.2.3-59-g8ed1b From 5f6bca795f6d27b04aa846805a1b396addde9100 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 3 Oct 2019 14:25:13 +0200 Subject: staging: rtl8188eu: cleanup whitespace in update_hw_ht_param Replace tabs with spaces in declarations and reomve two blank lines in update_hw_ht_param to cleanup whitespace and improve readability. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191003122514.1760-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 75c34e8f2335..97cab71cef23 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -562,8 +562,8 @@ static void update_hw_ht_param(struct adapter *padapter) { u8 max_ampdu_len; u8 min_mpdu_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_88E("%s\n", __func__); @@ -573,11 +573,9 @@ static void update_hw_ht_param(struct adapter *padapter) ampdu_params_info [4:2]:Min MPDU Start Spacing */ max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; - min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); /* */ -- cgit v1.2.3-59-g8ed1b From 7e6af677d82719ce5972b94bc7d9a4b5c8eddae0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 3 Oct 2019 14:25:14 +0200 Subject: staging: rtl8188eu: cleanup comments in update_hw_ht_param Cleanup comments in update_hw_ht_param to follow kernel coding style and avoid line length over 80 characters. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191003122514.1760-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 97cab71cef23..9aa44c921aca 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -567,20 +567,17 @@ static void update_hw_ht_param(struct adapter *padapter) DBG_88E("%s\n", __func__); - /* handle A-MPDU parameter field */ - /* - ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k - ampdu_params_info [4:2]:Min MPDU Start Spacing - */ + /* handle A-MPDU parameter field + * ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + * ampdu_params_info [4:2]:Min MPDU Start Spacing + */ max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); - /* */ - /* Config SM Power Save setting */ - /* */ + /* Config SM Power Save setting */ pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & 0x0C) >> 2; if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) DBG_88E("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); -- cgit v1.2.3-59-g8ed1b From 8789f13ddc77723e9451548b984382605340899c Mon Sep 17 00:00:00 2001 From: Valdis Klētnieks Date: Wed, 2 Oct 2019 15:16:24 -0400 Subject: staging: exfat: fix fs_sync() calls. The majority of them were totally backwards. Change the logic so that if DELAYED_SYNC *isn't* in the config, we actually flush to disk before flagging the file system as clean. That leaves two calls in the DELAYED_SYNC case. More detailed analysis is needed to make sure that's what's really needed, or if other call sites also need a fs_sync() call. This patch is at least "less wrong" than the code was, but further changes should be another patch. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/11092.1570043784@turing-police Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 5f6caee819a6..2526044569ee 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -458,7 +458,7 @@ static int ffsUmountVol(struct super_block *sb) /* acquire the lock for file system critical section */ down(&p_fs->v_sem); - fs_sync(sb, false); + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); if (p_fs->vol_type == EXFAT) { @@ -666,8 +666,8 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, /* create a new file */ ret = create_file(inode, &dir, &uni_name, mode, fid); -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -1039,8 +1039,8 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, release_entry_set(es); } -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -1179,8 +1179,8 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) if (fid->rwoffset > fid->size) fid->rwoffset = fid->size; -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -1327,8 +1327,8 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, num_entries + 1); } out: -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -1389,8 +1389,8 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) fid->start_clu = CLUSTER_32(~0); fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -1478,8 +1478,8 @@ static int ffsSetAttr(struct inode *inode, u32 attr) release_entry_set(es); } -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -1916,8 +1916,8 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) ret = create_dir(inode, &dir, &uni_name, fid); -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif @@ -2177,8 +2177,8 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) fid->start_clu = CLUSTER_32(~0); fid->flags = (p_fs->vol_type == EXFAT) ? 0x03 : 0x01; -#ifdef CONFIG_EXFAT_DELAYED_SYNC - fs_sync(sb, false); +#ifndef CONFIG_EXFAT_DELAYED_SYNC + fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); #endif -- cgit v1.2.3-59-g8ed1b From d98bb9c2fec01254d2e04e1eed51dde9ae611314 Mon Sep 17 00:00:00 2001 From: Valdis Klētnieks Date: Wed, 2 Oct 2019 15:01:35 -0400 Subject: staging: exfat: explain the fs_sync() issue in TODO We've seen several incorrect patches for fs_sync() calls in the exfat driver. Add code to the TODO that explains this isn't just a delete code and refactor, but that actual analysis of when the filesystem should be flushed to disk needs to be done. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/9837.1570042895@turing-police Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/TODO | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/TODO b/drivers/staging/exfat/TODO index a3eb282f9efc..b60e50b9cf4e 100644 --- a/drivers/staging/exfat/TODO +++ b/drivers/staging/exfat/TODO @@ -3,6 +3,15 @@ same for ffsWriteFile. exfat_core.c - fs_sync(sb,0) all over the place looks fishy as hell. There's only one place that calls it with a non-zero argument. +Randomly removing fs_sync() calls is *not* the right answer, especially +if the removal then leaves a call to fs_set_vol_flags(VOL_CLEAN), as that +says the file system is clean and synced when we *know* it isn't. +The proper fix here is to go through and actually analyze how DELAYED_SYNC +should work, and any time we're setting VOL_CLEAN, ensure the file system +has in fact been synced to disk. In other words, changing the 'false' to +'true' is probably more correct. Also, it's likely that the one current +place where it actually does an bdev_sync isn't sufficient in the DELAYED_SYNC +case. ffsTruncateFile - if (old_size <= new_size) { That doesn't look right. How did it ever work? Are they relying on lazy -- cgit v1.2.3-59-g8ed1b From a7a91ca5a23dbcc68f04d18ef7e765b1e4f64c7f Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:36 +0000 Subject: staging: wfx: add infrastructure for new driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instantiate build infrastructure WFx driver. This driver provides support for Wifi chipset Silicon Labs WF200 and further: https://www.silabs.com/documents/public/data-sheets/wf200-datasheet.pdf This chip support SPI and SDIO bus. SDIO interface has two particularities: 1. Some parameters may be useful for end user (I will talk about gpio_wakeup later). 2. The SDIO VID and PID of WF200 are 0000:0001 which are too much generic to rely on. So, current code checks VID/PID and looks for a node in DT (since WF200 targets embedded platforms, I don't think it is a problem to rely on DT). DT can also be used to define to parameters for driver. Currently, if no node is found, a warning is emitted, but it could be changed in error. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-2-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 5 ++ drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + .../bindings/net/wireless/siliabs,wfx.txt | 97 ++++++++++++++++++++++ drivers/staging/wfx/Kconfig | 7 ++ drivers/staging/wfx/Makefile | 8 ++ drivers/staging/wfx/TODO | 20 +++++ drivers/staging/wfx/bus.h | 17 ++++ drivers/staging/wfx/bus_sdio.c | 70 ++++++++++++++++ drivers/staging/wfx/bus_spi.c | 53 ++++++++++++ drivers/staging/wfx/main.c | 47 +++++++++++ drivers/staging/wfx/wfx_version.h | 3 + 12 files changed, 330 insertions(+) create mode 100644 drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt create mode 100644 drivers/staging/wfx/Kconfig create mode 100644 drivers/staging/wfx/Makefile create mode 100644 drivers/staging/wfx/TODO create mode 100644 drivers/staging/wfx/bus.h create mode 100644 drivers/staging/wfx/bus_sdio.c create mode 100644 drivers/staging/wfx/bus_spi.c create mode 100644 drivers/staging/wfx/main.c create mode 100644 drivers/staging/wfx/wfx_version.h (limited to 'drivers/staging') diff --git a/MAINTAINERS b/MAINTAINERS index 296de2b51c83..8f5b4847a9e8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14802,6 +14802,11 @@ S: Maintained F: drivers/input/touchscreen/silead.c F: drivers/platform/x86/touchscreen_dmi.c +SILICON LABS WIRELESS DRIVERS (for WFxxx series) +M: Jérôme Pouiller +S: Supported +F: drivers/staging/wfx/ + SILICON MOTION SM712 FRAME BUFFER DRIVER M: Sudip Mukherjee M: Teddy Wang diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 6f1fa4c849a1..a490141a0e88 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -125,4 +125,6 @@ source "drivers/staging/exfat/Kconfig" source "drivers/staging/qlge/Kconfig" +source "drivers/staging/wfx/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index a90f9b308c8d..4cb548a0ff87 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -53,3 +53,4 @@ obj-$(CONFIG_UWB) += uwb/ obj-$(CONFIG_USB_WUSB) += wusbcore/ obj-$(CONFIG_EXFAT_FS) += exfat/ obj-$(CONFIG_QLGE) += qlge/ +obj-$(CONFIG_WFX) += wfx/ diff --git a/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt b/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt new file mode 100644 index 000000000000..15965c9b4180 --- /dev/null +++ b/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt @@ -0,0 +1,97 @@ +The WFxxx chip series can be connected via SPI or via SDIO. + +SPI +--- + +You have to declare the WFxxx chip in your device tree. + +Required properties: + - compatible: Should be "silabs,wfx-spi" + - reg: Chip select address of device + - spi-max-frequency: Maximum SPI clocking speed of device in Hz + - interrupts-extended: Should contain interrupt line (interrupt-parent + + interrupt can also been used). Trigger should be `IRQ_TYPE_EDGE_RISING`. + +Optional properties: + - reset-gpios: phandle of gpio that will be used to reset chip during probe. + Without this property, you may encounter issues with warm boot. + +Please consult Documentation/devicetree/bindings/spi/spi-bus.txt for optional +SPI connection related properties, + +Example: + +&spi1 { + wfx { + compatible = "silabs,wfx-spi"; + pinctrl-names = "default"; + pinctrl-0 = <&wfx_irq &wfx_gpios>; + interrupts-extended = <&gpio 16 IRQ_TYPE_EDGE_RISING>; + wakeup-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + reg = <0>; + spi-max-frequency = <42000000>; + }; +}; + + +SDIO +---- + +The driver is able to detect a WFxxx chip on SDIO bus by matching its Vendor ID +and Product ID. However, driver will only provide limited features in this +case. Thus declaring WFxxx chip in device tree is strongly recommended (and may +become mandatory in the future). + +Required properties: + - compatible: Should be "silabs,wfx-sdio" + - reg: Should be 1 + +In addition, it is recommended to declare a mmc-pwrseq on SDIO host above WFx. +Without it, you may encounter issues with warm boot. mmc-pwrseq should be +compatible with mmc-pwrseq-simple. Please consult +Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt for more +information. + +Example: + +/ { + wfx_pwrseq: wfx_pwrseq { + compatible = "mmc-pwrseq-simple"; + pinctrl-names = "default"; + pinctrl-0 = <&wfx_reset>; + reset-gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; +}; + +&mmc1 { + mmc-pwrseq = <&wfx_pwrseq>; + #address-size = <1>; + #size = <0>; + + mmc@1 { + compatible = "silabs,wfx-sdio"; + reg = <1>; + pinctrl-names = "default"; + pinctrl-0 = <&wfx_wakeup>; + wakeup-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + }; +}; + +Note that #address-size and #size shoud already be defined in node mmc1, but it +is rarely the case. + +Common properties +----------------- + +Some properties are recognized either by SPI and SDIO versions: + - wakeup-gpios: phandle of gpio that will be used to wake-up chip. Without + this property, driver will disable most of power saving features. + - config-file: Use an alternative file as PDS. Default is `wf200.pds`. Only + necessary for development/debug purpose. + - slk_key: String representing hexdecimal value of secure link key to use. + Must contains 64 hexadecimal digits. Not supported in current version. + +WFx driver also supports `mac-address` and `local-mac-address` as described in +Documentation/devicetree/binding/net/ethernet.txt + diff --git a/drivers/staging/wfx/Kconfig b/drivers/staging/wfx/Kconfig new file mode 100644 index 000000000000..9b8a1c7a9e90 --- /dev/null +++ b/drivers/staging/wfx/Kconfig @@ -0,0 +1,7 @@ +config WFX + tristate "Silicon Labs wireless chips WF200 and further" + depends on MAC80211 + depends on (SPI || MMC) + help + This is a driver for Silicons Labs WFxxx series (WF200 and further) + chipsets. This chip can be found on SPI or SDIO buses. diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile new file mode 100644 index 000000000000..74939a5a0a1c --- /dev/null +++ b/drivers/staging/wfx/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 + +wfx-y := \ + main.o +wfx-$(CONFIG_SPI) += bus_spi.o +wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o + +obj-$(CONFIG_WFX) += wfx.o diff --git a/drivers/staging/wfx/TODO b/drivers/staging/wfx/TODO new file mode 100644 index 000000000000..be990e8f18b1 --- /dev/null +++ b/drivers/staging/wfx/TODO @@ -0,0 +1,20 @@ +This is a list of things that need to be done to get this driver out of the +staging directory. + + - wfx_version.h is still there in order to ensure synchronization with github. + It can be dropped as soon as development is entirely in kernel + + - I have to take a decision about secure link support. I can: + - drop completely + - keep it in an external patch (my preferred option) + - replace call to mbedtls with kernel crypto API (necessitate a + bunch of work) + - pull mbedtls in kernel (non-realistic) + + - mac80211 interface does not (yet) have expected quality to be placed + outside of staging: + - Some processings are redundant with mac80211 ones + - Many members from wfx_dev/wfx_vif can be retrieved from mac80211 + structures + - Some functions are too complex + - ... diff --git a/drivers/staging/wfx/bus.h b/drivers/staging/wfx/bus.h new file mode 100644 index 000000000000..8ce871a8a9ff --- /dev/null +++ b/drivers/staging/wfx/bus.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Common bus abstraction layer. + * + * Copyright (c) 2017-2018, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_BUS_H +#define WFX_BUS_H + +#include +#include + +extern struct sdio_driver wfx_sdio_driver; +extern struct spi_driver wfx_spi_driver; + +#endif diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c new file mode 100644 index 000000000000..4b26c994f43c --- /dev/null +++ b/drivers/staging/wfx/bus_sdio.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * SDIO interface. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include +#include +#include + +#include "bus.h" + +static const struct of_device_id wfx_sdio_of_match[]; +static int wfx_sdio_probe(struct sdio_func *func, + const struct sdio_device_id *id) +{ + struct device_node *np = func->dev.of_node; + + if (func->num != 1) { + dev_err(&func->dev, "SDIO function number is %d while it should always be 1 (unsupported chip?)\n", func->num); + return -ENODEV; + } + + if (np) { + if (!of_match_node(wfx_sdio_of_match, np)) { + dev_warn(&func->dev, "no compatible device found in DT\n"); + return -ENODEV; + } + } else { + dev_warn(&func->dev, "device is not declared in DT, features will be limited\n"); + // FIXME: ignore VID/PID and only rely on device tree + // return -ENODEV; + } + return -EIO; // FIXME: not yet supported +} + +static void wfx_sdio_remove(struct sdio_func *func) +{ +} + +#define SDIO_VENDOR_ID_SILABS 0x0000 +#define SDIO_DEVICE_ID_SILABS_WF200 0x1000 +static const struct sdio_device_id wfx_sdio_ids[] = { + { SDIO_DEVICE(SDIO_VENDOR_ID_SILABS, SDIO_DEVICE_ID_SILABS_WF200) }, + // FIXME: ignore VID/PID and only rely on device tree + // { SDIO_DEVICE(SDIO_ANY_ID, SDIO_ANY_ID) }, + { }, +}; +MODULE_DEVICE_TABLE(sdio, wfx_sdio_ids); + +#ifdef CONFIG_OF +static const struct of_device_id wfx_sdio_of_match[] = { + { .compatible = "silabs,wfx-sdio" }, + { }, +}; +MODULE_DEVICE_TABLE(of, wfx_sdio_of_match); +#endif + +struct sdio_driver wfx_sdio_driver = { + .name = "wfx-sdio", + .id_table = wfx_sdio_ids, + .probe = wfx_sdio_probe, + .remove = wfx_sdio_remove, + .drv = { + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(wfx_sdio_of_match), + } +}; diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c new file mode 100644 index 000000000000..574b60f513e9 --- /dev/null +++ b/drivers/staging/wfx/bus_spi.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * SPI interface. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2011, Sagrad Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include +#include + +#include "bus.h" + +static int wfx_spi_probe(struct spi_device *func) +{ + return -EIO; +} + +/* Disconnect Function to be called by SPI stack when device is disconnected */ +static int wfx_spi_disconnect(struct spi_device *func) +{ + return 0; +} + +/* + * For dynamic driver binding, kernel does not use OF to match driver. It only + * use modalias and modalias is a copy of 'compatible' DT node with vendor + * stripped. + */ +static const struct spi_device_id wfx_spi_id[] = { + { "wfx-spi", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(spi, wfx_spi_id); + +#ifdef CONFIG_OF +static const struct of_device_id wfx_spi_of_match[] = { + { .compatible = "silabs,wfx-spi" }, + { }, +}; +MODULE_DEVICE_TABLE(of, wfx_spi_of_match); +#endif + +struct spi_driver wfx_spi_driver = { + .driver = { + .name = "wfx-spi", + .of_match_table = of_match_ptr(wfx_spi_of_match), + }, + .id_table = wfx_spi_id, + .probe = wfx_spi_probe, + .remove = wfx_spi_disconnect, +}; diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c new file mode 100644 index 000000000000..cd69f955f531 --- /dev/null +++ b/drivers/staging/wfx/main.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Device probe and register. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (c) 2008, Johannes Berg + * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2007-2009, Christian Lamparter + * Copyright (c) 2006, Michael Wu + * Copyright (c) 2004-2006 Jean-Baptiste Note , et al. + */ +#include +#include +#include +#include + +#include "bus.h" +#include "wfx_version.h" + +MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); +MODULE_AUTHOR("Jérôme Pouiller "); +MODULE_LICENSE("GPL"); +MODULE_VERSION(WFX_LABEL); + +static int __init wfx_core_init(void) +{ + int ret = 0; + + pr_info("wfx: Silicon Labs " WFX_LABEL "\n"); + + if (IS_ENABLED(CONFIG_SPI)) + ret = spi_register_driver(&wfx_spi_driver); + if (IS_ENABLED(CONFIG_MMC) && !ret) + ret = sdio_register_driver(&wfx_sdio_driver); + return ret; +} +module_init(wfx_core_init); + +static void __exit wfx_core_exit(void) +{ + if (IS_ENABLED(CONFIG_MMC)) + sdio_unregister_driver(&wfx_sdio_driver); + if (IS_ENABLED(CONFIG_SPI)) + spi_unregister_driver(&wfx_spi_driver); +} +module_exit(wfx_core_exit); diff --git a/drivers/staging/wfx/wfx_version.h b/drivers/staging/wfx/wfx_version.h new file mode 100644 index 000000000000..6e7f30207c73 --- /dev/null +++ b/drivers/staging/wfx/wfx_version.h @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! */ +#define WFX_LABEL "2.3.1" -- cgit v1.2.3-59-g8ed1b From 0096214a59a72b3c3c943e27bd03307324d3ce0f Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:37 +0000 Subject: staging: wfx: add support for I/O access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce bus level communication layer. At this level, 7 registers can be addressed. Notice that SPI driver is able to manage chip reset. SDIO mode relies on an external driver (`mmc-pwrseq`) to reset chip. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-3-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bus.h | 17 ++++ drivers/staging/wfx/bus_sdio.c | 189 +++++++++++++++++++++++++++++++++++++- drivers/staging/wfx/bus_spi.c | 200 ++++++++++++++++++++++++++++++++++++++++- drivers/staging/wfx/hwio.h | 48 ++++++++++ drivers/staging/wfx/main.c | 53 +++++++++++ drivers/staging/wfx/main.h | 32 +++++++ drivers/staging/wfx/wfx.h | 24 +++++ 7 files changed, 561 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/wfx/hwio.h create mode 100644 drivers/staging/wfx/main.h create mode 100644 drivers/staging/wfx/wfx.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bus.h b/drivers/staging/wfx/bus.h index 8ce871a8a9ff..eb77abc09ec2 100644 --- a/drivers/staging/wfx/bus.h +++ b/drivers/staging/wfx/bus.h @@ -11,6 +11,23 @@ #include #include +#define WFX_REG_CONFIG 0x0 +#define WFX_REG_CONTROL 0x1 +#define WFX_REG_IN_OUT_QUEUE 0x2 +#define WFX_REG_AHB_DPORT 0x3 +#define WFX_REG_BASE_ADDR 0x4 +#define WFX_REG_SRAM_DPORT 0x5 +#define WFX_REG_SET_GEN_R_W 0x6 +#define WFX_REG_FRAME_OUT 0x7 + +struct hwbus_ops { + int (*copy_from_io)(void *bus_priv, unsigned int addr, void *dst, size_t count); + int (*copy_to_io)(void *bus_priv, unsigned int addr, const void *src, size_t count); + void (*lock)(void *bus_priv); + void (*unlock)(void *bus_priv); + size_t (*align_size)(void *bus_priv, size_t size); +}; + extern struct sdio_driver wfx_sdio_driver; extern struct spi_driver wfx_spi_driver; diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 4b26c994f43c..35bcca7ec5dc 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -8,36 +8,223 @@ #include #include #include +#include #include #include "bus.h" +#include "wfx.h" +#include "hwio.h" +#include "main.h" + +static const struct wfx_platform_data wfx_sdio_pdata = { +}; + +struct wfx_sdio_priv { + struct sdio_func *func; + struct wfx_dev *core; + u8 buf_id_tx; + u8 buf_id_rx; + int of_irq; +}; + +static int wfx_sdio_copy_from_io(void *priv, unsigned int reg_id, + void *dst, size_t count) +{ + struct wfx_sdio_priv *bus = priv; + unsigned int sdio_addr = reg_id << 2; + int ret; + + BUG_ON(reg_id > 7); + WARN(((uintptr_t) dst) & 3, "unaligned buffer size"); + WARN(count & 3, "unaligned buffer address"); + + /* Use queue mode buffers */ + if (reg_id == WFX_REG_IN_OUT_QUEUE) + sdio_addr |= (bus->buf_id_rx + 1) << 7; + ret = sdio_memcpy_fromio(bus->func, dst, sdio_addr, count); + if (!ret && reg_id == WFX_REG_IN_OUT_QUEUE) + bus->buf_id_rx = (bus->buf_id_rx + 1) % 4; + + return ret; +} + +static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id, + const void *src, size_t count) +{ + struct wfx_sdio_priv *bus = priv; + unsigned int sdio_addr = reg_id << 2; + int ret; + + BUG_ON(reg_id > 7); + WARN(((uintptr_t) src) & 3, "unaligned buffer size"); + WARN(count & 3, "unaligned buffer address"); + + /* Use queue mode buffers */ + if (reg_id == WFX_REG_IN_OUT_QUEUE) + sdio_addr |= bus->buf_id_tx << 7; + // FIXME: discards 'const' qualifier for src + ret = sdio_memcpy_toio(bus->func, sdio_addr, (void *) src, count); + if (!ret && reg_id == WFX_REG_IN_OUT_QUEUE) + bus->buf_id_tx = (bus->buf_id_tx + 1) % 32; + + return ret; +} + +static void wfx_sdio_lock(void *priv) +{ + struct wfx_sdio_priv *bus = priv; + + sdio_claim_host(bus->func); +} + +static void wfx_sdio_unlock(void *priv) +{ + struct wfx_sdio_priv *bus = priv; + + sdio_release_host(bus->func); +} + +static void wfx_sdio_irq_handler(struct sdio_func *func) +{ + struct wfx_sdio_priv *bus = sdio_get_drvdata(func); + + if (bus->core) + /* empty */; + else + WARN(!bus->core, "race condition in driver init/deinit"); +} + +static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void *priv) +{ + struct wfx_sdio_priv *bus = priv; + + if (!bus->core) { + WARN(!bus->core, "race condition in driver init/deinit"); + return IRQ_NONE; + } + sdio_claim_host(bus->func); + sdio_release_host(bus->func); + return IRQ_HANDLED; +} + +static int wfx_sdio_irq_subscribe(struct wfx_sdio_priv *bus) +{ + int ret; + + if (bus->of_irq) { + ret = request_irq(bus->of_irq, wfx_sdio_irq_handler_ext, + IRQF_TRIGGER_RISING, "wfx", bus); + } else { + sdio_claim_host(bus->func); + ret = sdio_claim_irq(bus->func, wfx_sdio_irq_handler); + sdio_release_host(bus->func); + } + return ret; +} + +static int wfx_sdio_irq_unsubscribe(struct wfx_sdio_priv *bus) +{ + int ret; + + if (bus->of_irq) { + free_irq(bus->of_irq, bus); + ret = 0; + } else { + sdio_claim_host(bus->func); + ret = sdio_release_irq(bus->func); + sdio_release_host(bus->func); + } + return ret; +} + +static size_t wfx_sdio_align_size(void *priv, size_t size) +{ + struct wfx_sdio_priv *bus = priv; + + return sdio_align_size(bus->func, size); +} + +static const struct hwbus_ops wfx_sdio_hwbus_ops = { + .copy_from_io = wfx_sdio_copy_from_io, + .copy_to_io = wfx_sdio_copy_to_io, + .lock = wfx_sdio_lock, + .unlock = wfx_sdio_unlock, + .align_size = wfx_sdio_align_size, +}; static const struct of_device_id wfx_sdio_of_match[]; static int wfx_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) { struct device_node *np = func->dev.of_node; + struct wfx_sdio_priv *bus; + int ret; if (func->num != 1) { dev_err(&func->dev, "SDIO function number is %d while it should always be 1 (unsupported chip?)\n", func->num); return -ENODEV; } + bus = devm_kzalloc(&func->dev, sizeof(*bus), GFP_KERNEL); + if (!bus) + return -ENOMEM; + if (np) { if (!of_match_node(wfx_sdio_of_match, np)) { dev_warn(&func->dev, "no compatible device found in DT\n"); return -ENODEV; } + bus->of_irq = irq_of_parse_and_map(np, 0); } else { dev_warn(&func->dev, "device is not declared in DT, features will be limited\n"); // FIXME: ignore VID/PID and only rely on device tree // return -ENODEV; } - return -EIO; // FIXME: not yet supported + + bus->func = func; + sdio_set_drvdata(func, bus); + func->card->quirks |= MMC_QUIRK_LENIENT_FN0 | MMC_QUIRK_BLKSZ_FOR_BYTE_MODE | MMC_QUIRK_BROKEN_BYTE_MODE_512; + + sdio_claim_host(func); + ret = sdio_enable_func(func); + // Block of 64 bytes is more efficient than 512B for frame sizes < 4k + sdio_set_block_size(func, 64); + sdio_release_host(func); + if (ret) + goto err0; + + ret = wfx_sdio_irq_subscribe(bus); + if (ret) + goto err1; + + bus->core = wfx_init_common(&func->dev, &wfx_sdio_pdata, + &wfx_sdio_hwbus_ops, bus); + if (!bus->core) { + ret = -EIO; + goto err2; + } + + return 0; + +err2: + wfx_sdio_irq_unsubscribe(bus); +err1: + sdio_claim_host(func); + sdio_disable_func(func); + sdio_release_host(func); +err0: + return ret; } static void wfx_sdio_remove(struct sdio_func *func) { + struct wfx_sdio_priv *bus = sdio_get_drvdata(func); + + wfx_free_common(bus->core); + wfx_sdio_irq_unsubscribe(bus); + sdio_claim_host(func); + sdio_disable_func(func); + sdio_release_host(func); } #define SDIO_VENDOR_ID_SILABS 0x0000 diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index 574b60f513e9..5e8f84baf2ca 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -7,19 +7,217 @@ * Copyright (c) 2010, ST-Ericsson */ #include +#include +#include +#include #include +#include #include #include "bus.h" +#include "wfx.h" +#include "hwio.h" +#include "main.h" + +static int gpio_reset = -2; +module_param(gpio_reset, int, 0644); +MODULE_PARM_DESC(gpio_reset, "gpio number for reset. -1 for none."); + +#define SET_WRITE 0x7FFF /* usage: and operation */ +#define SET_READ 0x8000 /* usage: or operation */ + +static const struct wfx_platform_data wfx_spi_pdata = { +}; + +struct wfx_spi_priv { + struct spi_device *func; + struct wfx_dev *core; + struct gpio_desc *gpio_reset; + struct work_struct request_rx; + bool need_swab; +}; + +/* + * WFx chip read data 16bits at time and place them directly into (little + * endian) CPU register. So, chip expect byte order like "B1 B0 B3 B2" (while + * LE is "B0 B1 B2 B3" and BE is "B3 B2 B1 B0") + * + * A little endian host with bits_per_word == 16 should do the right job + * natively. The code below to support big endian host and commonly used SPI + * 8bits. + */ +static int wfx_spi_copy_from_io(void *priv, unsigned int addr, + void *dst, size_t count) +{ + struct wfx_spi_priv *bus = priv; + u16 regaddr = (addr << 12) | (count / 2) | SET_READ; + struct spi_message m; + struct spi_transfer t_addr = { + .tx_buf = ®addr, + .len = sizeof(regaddr), + }; + struct spi_transfer t_msg = { + .rx_buf = dst, + .len = count, + }; + u16 *dst16 = dst; + int ret, i; + + WARN(count % 2, "buffer size must be a multiple of 2"); + + cpu_to_le16s(®addr); + if (bus->need_swab) + swab16s(®addr); + + spi_message_init(&m); + spi_message_add_tail(&t_addr, &m); + spi_message_add_tail(&t_msg, &m); + ret = spi_sync(bus->func, &m); + + if (bus->need_swab && addr == WFX_REG_CONFIG) + for (i = 0; i < count / 2; i++) + swab16s(&dst16[i]); + return ret; +} + +static int wfx_spi_copy_to_io(void *priv, unsigned int addr, + const void *src, size_t count) +{ + struct wfx_spi_priv *bus = priv; + u16 regaddr = (addr << 12) | (count / 2); + // FIXME: use a bounce buffer + u16 *src16 = (void *) src; + int ret, i; + struct spi_message m; + struct spi_transfer t_addr = { + .tx_buf = ®addr, + .len = sizeof(regaddr), + }; + struct spi_transfer t_msg = { + .tx_buf = src, + .len = count, + }; + + WARN(count % 2, "buffer size must be a multiple of 2"); + WARN(regaddr & SET_READ, "bad addr or size overflow"); + + cpu_to_le16s(®addr); + + if (bus->need_swab) + swab16s(®addr); + if (bus->need_swab && addr == WFX_REG_CONFIG) + for (i = 0; i < count / 2; i++) + swab16s(&src16[i]); + + spi_message_init(&m); + spi_message_add_tail(&t_addr, &m); + spi_message_add_tail(&t_msg, &m); + ret = spi_sync(bus->func, &m); + + if (bus->need_swab && addr == WFX_REG_CONFIG) + for (i = 0; i < count / 2; i++) + swab16s(&src16[i]); + return ret; +} + +static void wfx_spi_lock(void *priv) +{ +} + +static void wfx_spi_unlock(void *priv) +{ +} + +static irqreturn_t wfx_spi_irq_handler(int irq, void *priv) +{ + struct wfx_spi_priv *bus = priv; + + if (!bus->core) { + WARN(!bus->core, "race condition in driver init/deinit"); + return IRQ_NONE; + } + queue_work(system_highpri_wq, &bus->request_rx); + return IRQ_HANDLED; +} + +static void wfx_spi_request_rx(struct work_struct *work) +{ +} + +static size_t wfx_spi_align_size(void *priv, size_t size) +{ + // Most of SPI controllers avoid DMA if buffer size is not 32bit aligned + return ALIGN(size, 4); +} + +static const struct hwbus_ops wfx_spi_hwbus_ops = { + .copy_from_io = wfx_spi_copy_from_io, + .copy_to_io = wfx_spi_copy_to_io, + .lock = wfx_spi_lock, + .unlock = wfx_spi_unlock, + .align_size = wfx_spi_align_size, +}; static int wfx_spi_probe(struct spi_device *func) { - return -EIO; + struct wfx_spi_priv *bus; + int ret; + + if (!func->bits_per_word) + func->bits_per_word = 16; + ret = spi_setup(func); + if (ret) + return ret; + // Trace below is also displayed by spi_setup() if compiled with DEBUG + dev_dbg(&func->dev, "SPI params: CS=%d, mode=%d bits/word=%d speed=%d\n", + func->chip_select, func->mode, func->bits_per_word, func->max_speed_hz); + if (func->bits_per_word != 16 && func->bits_per_word != 8) + dev_warn(&func->dev, "unusual bits/word value: %d\n", func->bits_per_word); + if (func->max_speed_hz > 49000000) + dev_warn(&func->dev, "%dHz is a very high speed\n", func->max_speed_hz); + + bus = devm_kzalloc(&func->dev, sizeof(*bus), GFP_KERNEL); + if (!bus) + return -ENOMEM; + bus->func = func; + if (func->bits_per_word == 8 || IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) + bus->need_swab = true; + spi_set_drvdata(func, bus); + + bus->gpio_reset = wfx_get_gpio(&func->dev, gpio_reset, "reset"); + if (!bus->gpio_reset) { + dev_warn(&func->dev, "try to load firmware anyway\n"); + } else { + gpiod_set_value(bus->gpio_reset, 0); + udelay(100); + gpiod_set_value(bus->gpio_reset, 1); + udelay(2000); + } + + ret = devm_request_irq(&func->dev, func->irq, wfx_spi_irq_handler, + IRQF_TRIGGER_RISING, "wfx", bus); + if (ret) + return ret; + + INIT_WORK(&bus->request_rx, wfx_spi_request_rx); + bus->core = wfx_init_common(&func->dev, &wfx_spi_pdata, + &wfx_spi_hwbus_ops, bus); + if (!bus->core) + return -EIO; + + return ret; } /* Disconnect Function to be called by SPI stack when device is disconnected */ static int wfx_spi_disconnect(struct spi_device *func) { + struct wfx_spi_priv *bus = spi_get_drvdata(func); + + wfx_free_common(bus->core); + // A few IRQ will be sent during device release. Hopefully, no IRQ + // should happen after wdev/wvif are released. + devm_free_irq(&func->dev, func->irq, bus); + flush_work(&bus->request_rx); return 0; } diff --git a/drivers/staging/wfx/hwio.h b/drivers/staging/wfx/hwio.h new file mode 100644 index 000000000000..c490014c1df8 --- /dev/null +++ b/drivers/staging/wfx/hwio.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Low-level API. + * + * Copyright (c) 2017-2018, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_HWIO_H +#define WFX_HWIO_H + +#define CFG_ERR_SPI_FRAME 0x00000001 // only with SPI +#define CFG_ERR_SDIO_BUF_MISMATCH 0x00000001 // only with SDIO +#define CFG_ERR_BUF_UNDERRUN 0x00000002 +#define CFG_ERR_DATA_IN_TOO_LARGE 0x00000004 +#define CFG_ERR_HOST_NO_OUT_QUEUE 0x00000008 +#define CFG_ERR_BUF_OVERRUN 0x00000010 +#define CFG_ERR_DATA_OUT_TOO_LARGE 0x00000020 +#define CFG_ERR_HOST_NO_IN_QUEUE 0x00000040 +#define CFG_ERR_HOST_CRC_MISS 0x00000080 // only with SDIO +#define CFG_SPI_IGNORE_CS 0x00000080 // only with SPI +#define CFG_WORD_MODE_MASK 0x00000300 // Bytes ordering (only writable in SPI): +#define CFG_WORD_MODE0 0x00000000 // B1,B0,B3,B2 (In SPI, register address and CONFIG data always use this mode) +#define CFG_WORD_MODE1 0x00000100 // B3,B2,B1,B0 +#define CFG_WORD_MODE2 0x00000200 // B0,B1,B2,B3 (SDIO) +#define CFG_DIRECT_ACCESS_MODE 0x00000400 // Direct or queue access mode +#define CFG_PREFETCH_AHB 0x00000800 +#define CFG_DISABLE_CPU_CLK 0x00001000 +#define CFG_PREFETCH_SRAM 0x00002000 +#define CFG_CPU_RESET 0x00004000 +#define CFG_SDIO_DISABLE_IRQ 0x00008000 // only with SDIO +#define CFG_IRQ_ENABLE_DATA 0x00010000 +#define CFG_IRQ_ENABLE_WRDY 0x00020000 +#define CFG_CLK_RISE_EDGE 0x00040000 +#define CFG_SDIO_DISABLE_CRC_CHK 0x00080000 // only with SDIO +#define CFG_RESERVED 0x00F00000 +#define CFG_DEVICE_ID_MAJOR 0x07000000 +#define CFG_DEVICE_ID_RESERVED 0x78000000 +#define CFG_DEVICE_ID_TYPE 0x80000000 + +#define CTRL_NEXT_LEN_MASK 0x00000FFF +#define CTRL_WLAN_WAKEUP 0x00001000 +#define CTRL_WLAN_READY 0x00002000 + +#define IGPR_RW 0x80000000 +#define IGPR_INDEX 0x7F000000 +#define IGPR_VALUE 0x00FFFFFF + +#endif /* WFX_HWIO_H */ diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index cd69f955f531..744445ef597c 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -11,10 +11,15 @@ * Copyright (c) 2004-2006 Jean-Baptiste Note , et al. */ #include +#include +#include +#include #include #include #include +#include "main.h" +#include "wfx.h" #include "bus.h" #include "wfx_version.h" @@ -23,6 +28,54 @@ MODULE_AUTHOR("Jérôme Pouiller "); MODULE_LICENSE("GPL"); MODULE_VERSION(WFX_LABEL); +struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label) +{ + struct gpio_desc *ret; + char label_buf[256]; + + if (override >= 0) { + snprintf(label_buf, sizeof(label_buf), "wfx_%s", label); + ret = ERR_PTR(devm_gpio_request_one(dev, override, GPIOF_OUT_INIT_LOW, label_buf)); + if (!ret) + ret = gpio_to_desc(override); + } else if (override == -1) { + ret = NULL; + } else { + ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW); + } + if (IS_ERR(ret) || !ret) { + if (!ret || PTR_ERR(ret) == -ENOENT) + dev_warn(dev, "gpio %s is not defined\n", label); + else + dev_warn(dev, "error while requesting gpio %s\n", label); + ret = NULL; + } else { + dev_dbg(dev, "using gpio %d for %s\n", desc_to_gpio(ret), label); + } + return ret; +} + +struct wfx_dev *wfx_init_common(struct device *dev, + const struct wfx_platform_data *pdata, + const struct hwbus_ops *hwbus_ops, + void *hwbus_priv) +{ + struct wfx_dev *wdev; + + wdev = devm_kmalloc(dev, sizeof(*wdev), GFP_KERNEL); + if (!wdev) + return NULL; + wdev->dev = dev; + wdev->hwbus_ops = hwbus_ops; + wdev->hwbus_priv = hwbus_priv; + memcpy(&wdev->pdata, pdata, sizeof(*pdata)); + return wdev; +} + +void wfx_free_common(struct wfx_dev *wdev) +{ +} + static int __init wfx_core_init(void) { int ret = 0; diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h new file mode 100644 index 000000000000..82222edf998b --- /dev/null +++ b/drivers/staging/wfx/main.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Device probe and register. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (c) 2006, Michael Wu + * Copyright 2004-2006 Jean-Baptiste Note , et al. + */ +#ifndef WFX_MAIN_H +#define WFX_MAIN_H + +#include +#include + +#include "bus.h" + +struct wfx_dev; + +struct wfx_platform_data { +}; + +struct wfx_dev *wfx_init_common(struct device *dev, + const struct wfx_platform_data *pdata, + const struct hwbus_ops *hwbus_ops, + void *hwbus_priv); +void wfx_free_common(struct wfx_dev *wdev); + +struct gpio_desc *wfx_get_gpio(struct device *dev, int override, + const char *label); + +#endif diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h new file mode 100644 index 000000000000..9716acc981df --- /dev/null +++ b/drivers/staging/wfx/wfx.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Common private data for Silicon Labs WFx chips. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (c) 2006, Michael Wu + * Copyright 2004-2006 Jean-Baptiste Note , et al. + */ +#ifndef WFX_H +#define WFX_H + +#include "main.h" + +struct hwbus_ops; + +struct wfx_dev { + struct wfx_platform_data pdata; + struct device *dev; + const struct hwbus_ops *hwbus_ops; + void *hwbus_priv; +}; + +#endif /* WFX_H */ -- cgit v1.2.3-59-g8ed1b From a794e8b6fafe0dc82b2a2af32e85a859ad68a3a1 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:37 +0000 Subject: staging: wfx: add I/O API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hwio.c provides an abstraction to access different types of register of the chip. Note that only data register (aka FRAME_OUT) and control register are used normal communication. Other registers are only used during chip start up. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-4-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/hwio.c | 327 +++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/hwio.h | 27 ++++ 3 files changed, 355 insertions(+) create mode 100644 drivers/staging/wfx/hwio.c (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 74939a5a0a1c..e860845186cf 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 wfx-y := \ + hwio.o \ main.o wfx-$(CONFIG_SPI) += bus_spi.o wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o diff --git a/drivers/staging/wfx/hwio.c b/drivers/staging/wfx/hwio.c new file mode 100644 index 000000000000..fa626a49dd8a --- /dev/null +++ b/drivers/staging/wfx/hwio.c @@ -0,0 +1,327 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Low-level I/O functions. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include +#include + +#include "hwio.h" +#include "wfx.h" +#include "bus.h" + +/* + * Internal helpers. + * + * About CONFIG_VMAP_STACK: + * When CONFIG_VMAP_STACK is enabled, it is not possible to run DMA on stack + * allocated data. Functions below that work with registers (aka functions + * ending with "32") automatically reallocate buffers with kmalloc. However, + * functions that work with arbitrary length buffers let's caller to handle + * memory location. In doubt, enable CONFIG_DEBUG_SG to detect badly located + * buffer. + */ + +static int read32(struct wfx_dev *wdev, int reg, u32 *val) +{ + int ret; + __le32 *tmp = kmalloc(sizeof(u32), GFP_KERNEL); + + *val = ~0; // Never return undefined value + if (!tmp) + return -ENOMEM; + ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, tmp, sizeof(u32)); + if (ret >= 0) + *val = le32_to_cpu(*tmp); + kfree(tmp); + if (ret) + dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + return ret; +} + +static int write32(struct wfx_dev *wdev, int reg, u32 val) +{ + int ret; + __le32 *tmp = kmalloc(sizeof(u32), GFP_KERNEL); + + if (!tmp) + return -ENOMEM; + *tmp = cpu_to_le32(val); + ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, tmp, sizeof(u32)); + kfree(tmp); + if (ret) + dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + return ret; +} + +static int read32_locked(struct wfx_dev *wdev, int reg, u32 *val) +{ + int ret; + + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = read32(wdev, reg, val); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + return ret; +} + +static int write32_locked(struct wfx_dev *wdev, int reg, u32 val) +{ + int ret; + + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = write32(wdev, reg, val); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + return ret; +} + +static int write32_bits_locked(struct wfx_dev *wdev, int reg, u32 mask, u32 val) +{ + int ret; + u32 val_r, val_w; + + WARN_ON(~mask & val); + val &= mask; + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = read32(wdev, reg, &val_r); + if (ret < 0) + goto err; + val_w = (val_r & ~mask) | val; + if (val_w != val_r) { + ret = write32(wdev, reg, val_w); + } +err: + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + return ret; +} + +static int indirect_read(struct wfx_dev *wdev, int reg, u32 addr, void *buf, size_t len) +{ + int ret; + int i; + u32 cfg; + u32 prefetch; + + WARN_ON(len >= 0x2000); + WARN_ON(reg != WFX_REG_AHB_DPORT && reg != WFX_REG_SRAM_DPORT); + + if (reg == WFX_REG_AHB_DPORT) + prefetch = CFG_PREFETCH_AHB; + else if (reg == WFX_REG_SRAM_DPORT) + prefetch = CFG_PREFETCH_SRAM; + else + return -ENODEV; + + ret = write32(wdev, WFX_REG_BASE_ADDR, addr); + if (ret < 0) + goto err; + + ret = read32(wdev, WFX_REG_CONFIG, &cfg); + if (ret < 0) + goto err; + + ret = write32(wdev, WFX_REG_CONFIG, cfg | prefetch); + if (ret < 0) + goto err; + + for (i = 0; i < 20; i++) { + ret = read32(wdev, WFX_REG_CONFIG, &cfg); + if (ret < 0) + goto err; + if (!(cfg & prefetch)) + break; + udelay(200); + } + if (i == 20) { + ret = -ETIMEDOUT; + goto err; + } + + ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, buf, len); + +err: + if (ret < 0) + memset(buf, 0xFF, len); // Never return undefined value + return ret; +} + +static int indirect_write(struct wfx_dev *wdev, int reg, u32 addr, const void *buf, size_t len) +{ + int ret; + + WARN_ON(len >= 0x2000); + WARN_ON(reg != WFX_REG_AHB_DPORT && reg != WFX_REG_SRAM_DPORT); + ret = write32(wdev, WFX_REG_BASE_ADDR, addr); + if (ret < 0) + return ret; + + return wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, buf, len); +} + +static int indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr, void *buf, size_t len) +{ + int ret; + + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = indirect_read(wdev, reg, addr, buf, len); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + return ret; +} + +static int indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr, const void *buf, size_t len) +{ + int ret; + + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = indirect_write(wdev, reg, addr, buf, len); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + return ret; +} + +static int indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 *val) +{ + int ret; + __le32 *tmp = kmalloc(sizeof(u32), GFP_KERNEL); + + if (!tmp) + return -ENOMEM; + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = indirect_read(wdev, reg, addr, tmp, sizeof(u32)); + *val = cpu_to_le32(*tmp); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + kfree(tmp); + return ret; +} + +static int indirect_write32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 val) +{ + int ret; + __le32 *tmp = kmalloc(sizeof(u32), GFP_KERNEL); + + if (!tmp) + return -ENOMEM; + *tmp = cpu_to_le32(val); + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = indirect_write(wdev, reg, addr, tmp, sizeof(u32)); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + kfree(tmp); + return ret; +} + +int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t len) +{ + int ret; + + WARN((long) buf & 3, "%s: unaligned buffer", __func__); + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + if (ret) + dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + return ret; +} + +int wfx_data_write(struct wfx_dev *wdev, const void *buf, size_t len) +{ + int ret; + + WARN((long) buf & 3, "%s: unaligned buffer", __func__); + wdev->hwbus_ops->lock(wdev->hwbus_priv); + ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); + wdev->hwbus_ops->unlock(wdev->hwbus_priv); + if (ret) + dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + return ret; +} + +int sram_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len) +{ + return indirect_read_locked(wdev, WFX_REG_SRAM_DPORT, addr, buf, len); +} + +int ahb_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len) +{ + return indirect_read_locked(wdev, WFX_REG_AHB_DPORT, addr, buf, len); +} + +int sram_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len) +{ + return indirect_write_locked(wdev, WFX_REG_SRAM_DPORT, addr, buf, len); +} + +int ahb_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len) +{ + return indirect_write_locked(wdev, WFX_REG_AHB_DPORT, addr, buf, len); +} + +int sram_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val) +{ + return indirect_read32_locked(wdev, WFX_REG_SRAM_DPORT, addr, val); +} + +int ahb_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val) +{ + return indirect_read32_locked(wdev, WFX_REG_AHB_DPORT, addr, val); +} + +int sram_reg_write(struct wfx_dev *wdev, u32 addr, u32 val) +{ + return indirect_write32_locked(wdev, WFX_REG_SRAM_DPORT, addr, val); +} + +int ahb_reg_write(struct wfx_dev *wdev, u32 addr, u32 val) +{ + return indirect_write32_locked(wdev, WFX_REG_AHB_DPORT, addr, val); +} + +int config_reg_read(struct wfx_dev *wdev, u32 *val) +{ + return read32_locked(wdev, WFX_REG_CONFIG, val); +} + +int config_reg_write(struct wfx_dev *wdev, u32 val) +{ + return write32_locked(wdev, WFX_REG_CONFIG, val); +} + +int config_reg_write_bits(struct wfx_dev *wdev, u32 mask, u32 val) +{ + return write32_bits_locked(wdev, WFX_REG_CONFIG, mask, val); +} + +int control_reg_read(struct wfx_dev *wdev, u32 *val) +{ + return read32_locked(wdev, WFX_REG_CONTROL, val); +} + +int control_reg_write(struct wfx_dev *wdev, u32 val) +{ + return write32_locked(wdev, WFX_REG_CONTROL, val); +} + +int control_reg_write_bits(struct wfx_dev *wdev, u32 mask, u32 val) +{ + return write32_bits_locked(wdev, WFX_REG_CONTROL, mask, val); +} + +int igpr_reg_read(struct wfx_dev *wdev, int index, u32 *val) +{ + int ret; + + *val = ~0; // Never return undefined value + ret = write32_locked(wdev, WFX_REG_SET_GEN_R_W, IGPR_RW | index << 24); + if (ret) + return ret; + ret = read32_locked(wdev, WFX_REG_SET_GEN_R_W, val); + if (ret) + return ret; + *val &= IGPR_VALUE; + return ret; +} + +int igpr_reg_write(struct wfx_dev *wdev, int index, u32 val) +{ + return write32_locked(wdev, WFX_REG_SET_GEN_R_W, index << 24 | val); +} diff --git a/drivers/staging/wfx/hwio.h b/drivers/staging/wfx/hwio.h index c490014c1df8..906524f71fd1 100644 --- a/drivers/staging/wfx/hwio.h +++ b/drivers/staging/wfx/hwio.h @@ -8,6 +8,25 @@ #ifndef WFX_HWIO_H #define WFX_HWIO_H +#include + +struct wfx_dev; + +int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t buf_len); +int wfx_data_write(struct wfx_dev *wdev, const void *buf, size_t buf_len); + +int sram_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len); +int sram_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len); + +int ahb_buf_read(struct wfx_dev *wdev, u32 addr, void *buf, size_t len); +int ahb_buf_write(struct wfx_dev *wdev, u32 addr, const void *buf, size_t len); + +int sram_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val); +int sram_reg_write(struct wfx_dev *wdev, u32 addr, u32 val); + +int ahb_reg_read(struct wfx_dev *wdev, u32 addr, u32 *val); +int ahb_reg_write(struct wfx_dev *wdev, u32 addr, u32 val); + #define CFG_ERR_SPI_FRAME 0x00000001 // only with SPI #define CFG_ERR_SDIO_BUF_MISMATCH 0x00000001 // only with SDIO #define CFG_ERR_BUF_UNDERRUN 0x00000002 @@ -36,13 +55,21 @@ #define CFG_DEVICE_ID_MAJOR 0x07000000 #define CFG_DEVICE_ID_RESERVED 0x78000000 #define CFG_DEVICE_ID_TYPE 0x80000000 +int config_reg_read(struct wfx_dev *wdev, u32 *val); +int config_reg_write(struct wfx_dev *wdev, u32 val); +int config_reg_write_bits(struct wfx_dev *wdev, u32 mask, u32 val); #define CTRL_NEXT_LEN_MASK 0x00000FFF #define CTRL_WLAN_WAKEUP 0x00001000 #define CTRL_WLAN_READY 0x00002000 +int control_reg_read(struct wfx_dev *wdev, u32 *val); +int control_reg_write(struct wfx_dev *wdev, u32 val); +int control_reg_write_bits(struct wfx_dev *wdev, u32 mask, u32 val); #define IGPR_RW 0x80000000 #define IGPR_INDEX 0x7F000000 #define IGPR_VALUE 0x00FFFFFF +int igpr_reg_read(struct wfx_dev *wdev, int index, u32 *val); +int igpr_reg_write(struct wfx_dev *wdev, int index, u32 val); #endif /* WFX_HWIO_H */ -- cgit v1.2.3-59-g8ed1b From fee695e3e30f72a18d4631b8d7589cf413282c7c Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:38 +0000 Subject: staging: wfx: add tracepoints for I/O access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tracepoints are useful for debugging. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-5-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 6 +- drivers/staging/wfx/debug.c | 10 +++ drivers/staging/wfx/hwio.c | 11 ++++ drivers/staging/wfx/traces.h | 149 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/wfx/debug.c create mode 100644 drivers/staging/wfx/traces.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index e860845186cf..330b7288ebb5 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -1,8 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 +# Necessary for CREATE_TRACE_POINTS +CFLAGS_debug.o = -I$(src) + wfx-y := \ hwio.o \ - main.o + main.o \ + debug.o wfx-$(CONFIG_SPI) += bus_spi.o wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c new file mode 100644 index 000000000000..bf44c944640d --- /dev/null +++ b/drivers/staging/wfx/debug.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Debugfs interface. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ + +#define CREATE_TRACE_POINTS +#include "traces.h" diff --git a/drivers/staging/wfx/hwio.c b/drivers/staging/wfx/hwio.c index fa626a49dd8a..0cf52aee10e7 100644 --- a/drivers/staging/wfx/hwio.c +++ b/drivers/staging/wfx/hwio.c @@ -12,6 +12,7 @@ #include "hwio.h" #include "wfx.h" #include "bus.h" +#include "traces.h" /* * Internal helpers. @@ -63,6 +64,7 @@ static int read32_locked(struct wfx_dev *wdev, int reg, u32 *val) wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = read32(wdev, reg, val); + _trace_io_read32(reg, *val); wdev->hwbus_ops->unlock(wdev->hwbus_priv); return ret; } @@ -73,6 +75,7 @@ static int write32_locked(struct wfx_dev *wdev, int reg, u32 val) wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = write32(wdev, reg, val); + _trace_io_write32(reg, val); wdev->hwbus_ops->unlock(wdev->hwbus_priv); return ret; } @@ -86,11 +89,13 @@ static int write32_bits_locked(struct wfx_dev *wdev, int reg, u32 mask, u32 val) val &= mask; wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = read32(wdev, reg, &val_r); + _trace_io_read32(reg, val_r); if (ret < 0) goto err; val_w = (val_r & ~mask) | val; if (val_w != val_r) { ret = write32(wdev, reg, val_w); + _trace_io_write32(reg, val_w); } err: wdev->hwbus_ops->unlock(wdev->hwbus_priv); @@ -166,6 +171,7 @@ static int indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr, void *b wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = indirect_read(wdev, reg, addr, buf, len); + _trace_io_ind_read(reg, addr, buf, len); wdev->hwbus_ops->unlock(wdev->hwbus_priv); return ret; } @@ -176,6 +182,7 @@ static int indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr, const wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = indirect_write(wdev, reg, addr, buf, len); + _trace_io_ind_write(reg, addr, buf, len); wdev->hwbus_ops->unlock(wdev->hwbus_priv); return ret; } @@ -190,6 +197,7 @@ static int indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 * wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = indirect_read(wdev, reg, addr, tmp, sizeof(u32)); *val = cpu_to_le32(*tmp); + _trace_io_ind_read32(reg, addr, *val); wdev->hwbus_ops->unlock(wdev->hwbus_priv); kfree(tmp); return ret; @@ -205,6 +213,7 @@ static int indirect_write32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 *tmp = cpu_to_le32(val); wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = indirect_write(wdev, reg, addr, tmp, sizeof(u32)); + _trace_io_ind_write32(reg, addr, val); wdev->hwbus_ops->unlock(wdev->hwbus_priv); kfree(tmp); return ret; @@ -217,6 +226,7 @@ int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t len) WARN((long) buf & 3, "%s: unaligned buffer", __func__); wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); + _trace_io_read(WFX_REG_IN_OUT_QUEUE, buf, len); wdev->hwbus_ops->unlock(wdev->hwbus_priv); if (ret) dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); @@ -230,6 +240,7 @@ int wfx_data_write(struct wfx_dev *wdev, const void *buf, size_t len) WARN((long) buf & 3, "%s: unaligned buffer", __func__); wdev->hwbus_ops->lock(wdev->hwbus_priv); ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); + _trace_io_write(WFX_REG_IN_OUT_QUEUE, buf, len); wdev->hwbus_ops->unlock(wdev->hwbus_priv); if (ret) dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); diff --git a/drivers/staging/wfx/traces.h b/drivers/staging/wfx/traces.h new file mode 100644 index 000000000000..34642f3451b5 --- /dev/null +++ b/drivers/staging/wfx/traces.h @@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Tracepoints definitions. + * + * Copyright (c) 2018-2019, Silicon Laboratories, Inc. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM wfx + +#if !defined(_WFX_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) +#define _WFX_TRACE_H + +#include + +#include "bus.h" + +/* The hell below need some explanations. For each symbolic number, we need to + * define it with TRACE_DEFINE_ENUM() and in a list for __print_symbolic. + * + * 1. Define a new macro that call TRACE_DEFINE_ENUM(): + * + * #define xxx_name(sym) TRACE_DEFINE_ENUM(sym); + * + * 2. Define list of all symbols: + * + * #define list_names \ + * ... \ + * xxx_name(XXX) \ + * ... + * + * 3. Instanciate that list_names: + * + * list_names + * + * 4. Redefine xxx_name() as a entry of array for __print_symbolic() + * + * #undef xxx_name + * #define xxx_name(msg) { msg, #msg }, + * + * 5. list_name can now nearlu be used with __print_symbolic() but, + * __print_symbolic() dislike last comma of list. So we define a new list + * with a dummy element: + * + * #define list_for_print_symbolic list_names { -1, NULL } + */ + +#define wfx_reg_list_enum \ + wfx_reg_name(WFX_REG_CONFIG, "CONFIG") \ + wfx_reg_name(WFX_REG_CONTROL, "CONTROL") \ + wfx_reg_name(WFX_REG_IN_OUT_QUEUE, "QUEUE") \ + wfx_reg_name(WFX_REG_AHB_DPORT, "AHB") \ + wfx_reg_name(WFX_REG_BASE_ADDR, "BASE_ADDR") \ + wfx_reg_name(WFX_REG_SRAM_DPORT, "SRAM") \ + wfx_reg_name(WFX_REG_SET_GEN_R_W, "SET_GEN_R_W") \ + wfx_reg_name(WFX_REG_FRAME_OUT, "FRAME_OUT") + +#undef wfx_reg_name +#define wfx_reg_name(sym, name) TRACE_DEFINE_ENUM(sym); +wfx_reg_list_enum +#undef wfx_reg_name +#define wfx_reg_name(sym, name) { sym, name }, +#define wfx_reg_list wfx_reg_list_enum { -1, NULL } + +DECLARE_EVENT_CLASS(io_data, + TP_PROTO(int reg, int addr, const void *io_buf, size_t len), + TP_ARGS(reg, addr, io_buf, len), + TP_STRUCT__entry( + __field(int, reg) + __field(int, addr) + __field(int, msg_len) + __field(int, buf_len) + __array(u8, buf, 32) + __array(u8, addr_str, 10) + ), + TP_fast_assign( + __entry->reg = reg; + __entry->addr = addr; + __entry->msg_len = len; + __entry->buf_len = min_t(int, sizeof(__entry->buf), __entry->msg_len); + memcpy(__entry->buf, io_buf, __entry->buf_len); + if (addr >= 0) + snprintf(__entry->addr_str, 10, "/%08x", addr); + else + __entry->addr_str[0] = 0; + ), + TP_printk("%s%s: %s%s (%d bytes)", + __print_symbolic(__entry->reg, wfx_reg_list), + __entry->addr_str, + __print_hex(__entry->buf, __entry->buf_len), + __entry->msg_len > sizeof(__entry->buf) ? " ..." : "", + __entry->msg_len + ) +); +DEFINE_EVENT(io_data, io_write, + TP_PROTO(int reg, int addr, const void *io_buf, size_t len), + TP_ARGS(reg, addr, io_buf, len)); +#define _trace_io_ind_write(reg, addr, io_buf, len) trace_io_write(reg, addr, io_buf, len) +#define _trace_io_write(reg, io_buf, len) trace_io_write(reg, -1, io_buf, len) +DEFINE_EVENT(io_data, io_read, + TP_PROTO(int reg, int addr, const void *io_buf, size_t len), + TP_ARGS(reg, addr, io_buf, len)); +#define _trace_io_ind_read(reg, addr, io_buf, len) trace_io_read(reg, addr, io_buf, len) +#define _trace_io_read(reg, io_buf, len) trace_io_read(reg, -1, io_buf, len) + +DECLARE_EVENT_CLASS(io_data32, + TP_PROTO(int reg, int addr, u32 val), + TP_ARGS(reg, addr, val), + TP_STRUCT__entry( + __field(int, reg) + __field(int, addr) + __field(int, val) + __array(u8, addr_str, 10) + ), + TP_fast_assign( + __entry->reg = reg; + __entry->addr = addr; + __entry->val = val; + if (addr >= 0) + snprintf(__entry->addr_str, 10, "/%08x", addr); + else + __entry->addr_str[0] = 0; + ), + TP_printk("%s%s: %08x", + __print_symbolic(__entry->reg, wfx_reg_list), + __entry->addr_str, + __entry->val + ) +); +DEFINE_EVENT(io_data32, io_write32, + TP_PROTO(int reg, int addr, u32 val), + TP_ARGS(reg, addr, val)); +#define _trace_io_ind_write32(reg, addr, val) trace_io_write32(reg, addr, val) +#define _trace_io_write32(reg, val) trace_io_write32(reg, -1, val) +DEFINE_EVENT(io_data32, io_read32, + TP_PROTO(int reg, int addr, u32 val), + TP_ARGS(reg, addr, val)); +#define _trace_io_ind_read32(reg, addr, val) trace_io_read32(reg, addr, val) +#define _trace_io_read32(reg, val) trace_io_read32(reg, -1, val) + +#endif + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH . +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE traces + +#include -- cgit v1.2.3-59-g8ed1b From 652b4afb240e5dc196995597942309e89e89c767 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:38 +0000 Subject: staging: wfx: load firmware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A firmware is necessary to run the chip. wfx_init_device() is in charge of loading firmware on chip and doing low level initialization. Firmwares for WF200 are available here: https://github.com/SiliconLabs/wfx-firmware/ Note that firmware are encrypted. Driver checks that key used to encrypt firmware match with key burned into chip. Currently, "C0" key is used for production chips. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/bus_sdio.c | 8 + drivers/staging/wfx/bus_spi.c | 7 + drivers/staging/wfx/fwio.c | 387 +++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/fwio.h | 15 ++ drivers/staging/wfx/main.c | 20 +++ drivers/staging/wfx/main.h | 10 ++ drivers/staging/wfx/wfx.h | 2 + 8 files changed, 450 insertions(+) create mode 100644 drivers/staging/wfx/fwio.c create mode 100644 drivers/staging/wfx/fwio.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 330b7288ebb5..e568d7a6fb06 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -5,6 +5,7 @@ CFLAGS_debug.o = -I$(src) wfx-y := \ hwio.o \ + fwio.o \ main.o \ debug.o wfx-$(CONFIG_SPI) += bus_spi.o diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 35bcca7ec5dc..25c587fe2141 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -17,6 +17,7 @@ #include "main.h" static const struct wfx_platform_data wfx_sdio_pdata = { + .file_fw = "wfm_wf200", }; struct wfx_sdio_priv { @@ -204,8 +205,14 @@ static int wfx_sdio_probe(struct sdio_func *func, goto err2; } + ret = wfx_probe(bus->core); + if (ret) + goto err3; + return 0; +err3: + wfx_free_common(bus->core); err2: wfx_sdio_irq_unsubscribe(bus); err1: @@ -220,6 +227,7 @@ static void wfx_sdio_remove(struct sdio_func *func) { struct wfx_sdio_priv *bus = sdio_get_drvdata(func); + wfx_release(bus->core); wfx_free_common(bus->core); wfx_sdio_irq_unsubscribe(bus); sdio_claim_host(func); diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index 5e8f84baf2ca..b73b9416273f 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -27,6 +27,8 @@ MODULE_PARM_DESC(gpio_reset, "gpio number for reset. -1 for none."); #define SET_READ 0x8000 /* usage: or operation */ static const struct wfx_platform_data wfx_spi_pdata = { + .file_fw = "wfm_wf200", + .use_rising_clk = true, }; struct wfx_spi_priv { @@ -205,6 +207,10 @@ static int wfx_spi_probe(struct spi_device *func) if (!bus->core) return -EIO; + ret = wfx_probe(bus->core); + if (ret) + wfx_free_common(bus->core); + return ret; } @@ -213,6 +219,7 @@ static int wfx_spi_disconnect(struct spi_device *func) { struct wfx_spi_priv *bus = spi_get_drvdata(func); + wfx_release(bus->core); wfx_free_common(bus->core); // A few IRQ will be sent during device release. Hopefully, no IRQ // should happen after wdev/wvif are released. diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c new file mode 100644 index 000000000000..8fb4a9f6d1a6 --- /dev/null +++ b/drivers/staging/wfx/fwio.c @@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Firmware loading. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include +#include +#include + +#include "fwio.h" +#include "wfx.h" +#include "hwio.h" + +// Addresses below are in SRAM area +#define WFX_DNLD_FIFO 0x09004000 +#define DNLD_BLOCK_SIZE 0x0400 +#define DNLD_FIFO_SIZE 0x8000 // (32 * DNLD_BLOCK_SIZE) +// Download Control Area (DCA) +#define WFX_DCA_IMAGE_SIZE 0x0900C000 +#define WFX_DCA_PUT 0x0900C004 +#define WFX_DCA_GET 0x0900C008 +#define WFX_DCA_HOST_STATUS 0x0900C00C +#define HOST_READY 0x87654321 +#define HOST_INFO_READ 0xA753BD99 +#define HOST_UPLOAD_PENDING 0xABCDDCBA +#define HOST_UPLOAD_COMPLETE 0xD4C64A99 +#define HOST_OK_TO_JUMP 0x174FC882 +#define WFX_DCA_NCP_STATUS 0x0900C010 +#define NCP_NOT_READY 0x12345678 +#define NCP_READY 0x87654321 +#define NCP_INFO_READY 0xBD53EF99 +#define NCP_DOWNLOAD_PENDING 0xABCDDCBA +#define NCP_DOWNLOAD_COMPLETE 0xCAFEFECA +#define NCP_AUTH_OK 0xD4C64A99 +#define NCP_AUTH_FAIL 0x174FC882 +#define NCP_PUB_KEY_RDY 0x7AB41D19 +#define WFX_DCA_FW_SIGNATURE 0x0900C014 +#define FW_SIGNATURE_SIZE 0x40 +#define WFX_DCA_FW_HASH 0x0900C054 +#define FW_HASH_SIZE 0x08 +#define WFX_DCA_FW_VERSION 0x0900C05C +#define FW_VERSION_SIZE 0x04 +#define WFX_DCA_RESERVED 0x0900C060 +#define DCA_RESERVED_SIZE 0x20 +#define WFX_STATUS_INFO 0x0900C080 +#define WFX_BOOTLOADER_LABEL 0x0900C084 +#define BOOTLOADER_LABEL_SIZE 0x3C +#define WFX_PTE_INFO 0x0900C0C0 +#define PTE_INFO_KEYSET_IDX 0x0D +#define PTE_INFO_SIZE 0x10 +#define WFX_ERR_INFO 0x0900C0D0 +#define ERR_INVALID_SEC_TYPE 0x05 +#define ERR_SIG_VERIF_FAILED 0x0F +#define ERR_AES_CTRL_KEY 0x10 +#define ERR_ECC_PUB_KEY 0x11 +#define ERR_MAC_KEY 0x18 + +#define DCA_TIMEOUT 50 // milliseconds +#define WAKEUP_TIMEOUT 200 // milliseconds + +static const char * const fwio_error_strings[] = { + [ERR_INVALID_SEC_TYPE] = "Invalid section type or wrong encryption", + [ERR_SIG_VERIF_FAILED] = "Signature verification failed", + [ERR_AES_CTRL_KEY] = "AES control key not initialized", + [ERR_ECC_PUB_KEY] = "ECC public key not initialized", + [ERR_MAC_KEY] = "MAC key not initialized", +}; + +/* + * request_firmware() allocate data using vmalloc(). It is not compatible with + * underlying hardware that use DMA. Function below detect this case and + * allocate a bounce buffer if necessary. + * + * Notice that, in doubt, you can enable CONFIG_DEBUG_SG to ask kernel to + * detect this problem at runtime (else, kernel silently fail). + * + * NOTE: it may also be possible to use 'pages' from struct firmware and avoid + * bounce buffer + */ +int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t len) +{ + int ret; + const u8 *tmp; + + if (!virt_addr_valid(buf)) { + tmp = kmemdup(buf, len, GFP_KERNEL); + if (!tmp) + return -ENOMEM; + } else { + tmp = buf; + } + ret = sram_buf_write(wdev, addr, tmp, len); + if (!virt_addr_valid(buf)) + kfree(tmp); + return ret; +} + +int get_firmware(struct wfx_dev *wdev, u32 keyset_chip, + const struct firmware **fw, int *file_offset) +{ + int keyset_file; + char filename[256]; + const char *data; + int ret; + + snprintf(filename, sizeof(filename), "%s_%02X.sec", wdev->pdata.file_fw, keyset_chip); + ret = firmware_request_nowarn(fw, filename, wdev->dev); + if (ret) { + dev_info(wdev->dev, "can't load %s, falling back to %s.sec\n", filename, wdev->pdata.file_fw); + snprintf(filename, sizeof(filename), "%s.sec", wdev->pdata.file_fw); + ret = request_firmware(fw, filename, wdev->dev); + if (ret) { + dev_err(wdev->dev, "can't load %s\n", filename); + *fw = NULL; + return ret; + } + } + + data = (*fw)->data; + if (memcmp(data, "KEYSET", 6) != 0) { + // Legacy firmware format + *file_offset = 0; + keyset_file = 0x90; + } else { + *file_offset = 8; + keyset_file = (hex_to_bin(data[6]) * 16) | hex_to_bin(data[7]); + if (keyset_file < 0) { + dev_err(wdev->dev, "%s corrupted\n", filename); + release_firmware(*fw); + *fw = NULL; + return -EINVAL; + } + } + if (keyset_file != keyset_chip) { + dev_err(wdev->dev, "firmware keyset is incompatible with chip (file: 0x%02X, chip: 0x%02X)\n", + keyset_file, keyset_chip); + release_firmware(*fw); + *fw = NULL; + return -ENODEV; + } + wdev->keyset = keyset_file; + return 0; +} + +static int wait_ncp_status(struct wfx_dev *wdev, u32 status) +{ + ktime_t now, start; + u32 reg; + int ret; + + start = ktime_get(); + for (;;) { + ret = sram_reg_read(wdev, WFX_DCA_NCP_STATUS, ®); + if (ret < 0) + return -EIO; + now = ktime_get(); + if (reg == status) + break; + if (ktime_after(now, ktime_add_ms(start, DCA_TIMEOUT))) + return -ETIMEDOUT; + } + if (ktime_compare(now, start)) + dev_dbg(wdev->dev, "chip answer after %lldus\n", ktime_us_delta(now, start)); + else + dev_dbg(wdev->dev, "chip answer immediately\n"); + return 0; +} + +static int upload_firmware(struct wfx_dev *wdev, const u8 *data, size_t len) +{ + int ret; + u32 offs, bytes_done; + ktime_t now, start; + + if (len % DNLD_BLOCK_SIZE) { + dev_err(wdev->dev, "firmware size is not aligned. Buffer overrun will occur\n"); + return -EIO; + } + offs = 0; + while (offs < len) { + start = ktime_get(); + for (;;) { + ret = sram_reg_read(wdev, WFX_DCA_GET, &bytes_done); + if (ret < 0) + return ret; + now = ktime_get(); + if (offs + DNLD_BLOCK_SIZE - bytes_done < DNLD_FIFO_SIZE) + break; + if (ktime_after(now, ktime_add_ms(start, DCA_TIMEOUT))) + return -ETIMEDOUT; + } + if (ktime_compare(now, start)) + dev_dbg(wdev->dev, "answer after %lldus\n", ktime_us_delta(now, start)); + + ret = sram_write_dma_safe(wdev, WFX_DNLD_FIFO + (offs % DNLD_FIFO_SIZE), + data + offs, DNLD_BLOCK_SIZE); + if (ret < 0) + return ret; + + // WFx seems to not support writing 0 in this register during + // first loop + offs += DNLD_BLOCK_SIZE; + ret = sram_reg_write(wdev, WFX_DCA_PUT, offs); + if (ret < 0) + return ret; + } + return 0; +} + +static void print_boot_status(struct wfx_dev *wdev) +{ + u32 val32; + + sram_reg_read(wdev, WFX_STATUS_INFO, &val32); + if (val32 == 0x12345678) { + dev_info(wdev->dev, "no error reported by secure boot\n"); + } else { + sram_reg_read(wdev, WFX_ERR_INFO, &val32); + if (val32 < ARRAY_SIZE(fwio_error_strings) && fwio_error_strings[val32]) + dev_info(wdev->dev, "secure boot error: %s\n", fwio_error_strings[val32]); + else + dev_info(wdev->dev, "secure boot error: Unknown (0x%02x)\n", val32); + } +} + +int load_firmware_secure(struct wfx_dev *wdev) +{ + const struct firmware *fw = NULL; + int header_size; + int fw_offset; + ktime_t start; + u8 *buf; + int ret; + + BUILD_BUG_ON(PTE_INFO_SIZE > BOOTLOADER_LABEL_SIZE); + buf = kmalloc(BOOTLOADER_LABEL_SIZE + 1, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_READY); + ret = wait_ncp_status(wdev, NCP_INFO_READY); + if (ret) + goto error; + + sram_buf_read(wdev, WFX_BOOTLOADER_LABEL, buf, BOOTLOADER_LABEL_SIZE); + buf[BOOTLOADER_LABEL_SIZE] = 0; + dev_dbg(wdev->dev, "bootloader: \"%s\"\n", buf); + + sram_buf_read(wdev, WFX_PTE_INFO, buf, PTE_INFO_SIZE); + ret = get_firmware(wdev, buf[PTE_INFO_KEYSET_IDX], &fw, &fw_offset); + if (ret) + goto error; + header_size = fw_offset + FW_SIGNATURE_SIZE + FW_HASH_SIZE; + + sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_INFO_READ); + ret = wait_ncp_status(wdev, NCP_READY); + if (ret) + goto error; + + sram_reg_write(wdev, WFX_DNLD_FIFO, 0xFFFFFFFF); // Fifo init + sram_write_dma_safe(wdev, WFX_DCA_FW_VERSION, "\x01\x00\x00\x00", FW_VERSION_SIZE); + sram_write_dma_safe(wdev, WFX_DCA_FW_SIGNATURE, fw->data + fw_offset, FW_SIGNATURE_SIZE); + sram_write_dma_safe(wdev, WFX_DCA_FW_HASH, fw->data + fw_offset + FW_SIGNATURE_SIZE, FW_HASH_SIZE); + sram_reg_write(wdev, WFX_DCA_IMAGE_SIZE, fw->size - header_size); + sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_UPLOAD_PENDING); + ret = wait_ncp_status(wdev, NCP_DOWNLOAD_PENDING); + if (ret) + goto error; + + start = ktime_get(); + ret = upload_firmware(wdev, fw->data + header_size, fw->size - header_size); + if (ret) + goto error; + dev_dbg(wdev->dev, "firmware load after %lldus\n", ktime_us_delta(ktime_get(), start)); + + sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_UPLOAD_COMPLETE); + ret = wait_ncp_status(wdev, NCP_AUTH_OK); + // Legacy ROM support + if (ret < 0) + ret = wait_ncp_status(wdev, NCP_PUB_KEY_RDY); + if (ret < 0) + goto error; + sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_OK_TO_JUMP); + +error: + kfree(buf); + if (fw) + release_firmware(fw); + if (ret) + print_boot_status(wdev); + return ret; +} + +static int init_gpr(struct wfx_dev *wdev) +{ + int ret, i; + static const struct { + int index; + u32 value; + } gpr_init[] = { + { 0x07, 0x208775 }, + { 0x08, 0x2EC020 }, + { 0x09, 0x3C3C3C }, + { 0x0B, 0x322C44 }, + { 0x0C, 0xA06497 }, + }; + + for (i = 0; i < ARRAY_SIZE(gpr_init); i++) { + ret = igpr_reg_write(wdev, gpr_init[i].index, gpr_init[i].value); + if (ret < 0) + return ret; + dev_dbg(wdev->dev, " index %02x: %08x\n", gpr_init[i].index, gpr_init[i].value); + } + return 0; +} + +int wfx_init_device(struct wfx_dev *wdev) +{ + int ret; + int hw_revision, hw_type; + int wakeup_timeout = 50; // ms + ktime_t now, start; + u32 reg; + + reg = CFG_DIRECT_ACCESS_MODE | CFG_CPU_RESET | CFG_WORD_MODE2; + if (wdev->pdata.use_rising_clk) + reg |= CFG_CLK_RISE_EDGE; + ret = config_reg_write(wdev, reg); + if (ret < 0) { + dev_err(wdev->dev, "bus returned an error during first write access. Host configuration error?\n"); + return -EIO; + } + + ret = config_reg_read(wdev, ®); + if (ret < 0) { + dev_err(wdev->dev, "bus returned an error during first read access. Bus configuration error?\n"); + return -EIO; + } + if (reg == 0 || reg == ~0) { + dev_err(wdev->dev, "chip mute. Bus configuration error or chip wasn't reset?\n"); + return -EIO; + } + dev_dbg(wdev->dev, "initial config register value: %08x\n", reg); + + hw_revision = FIELD_GET(CFG_DEVICE_ID_MAJOR, reg); + if (hw_revision == 0 || hw_revision > 2) { + dev_err(wdev->dev, "bad hardware revision number: %d\n", hw_revision); + return -ENODEV; + } + hw_type = FIELD_GET(CFG_DEVICE_ID_TYPE, reg); + if (hw_type == 1) { + dev_notice(wdev->dev, "development hardware detected\n"); + wakeup_timeout = 2000; + } + + ret = init_gpr(wdev); + if (ret < 0) + return ret; + + ret = control_reg_write(wdev, CTRL_WLAN_WAKEUP); + if (ret < 0) + return -EIO; + start = ktime_get(); + for (;;) { + ret = control_reg_read(wdev, ®); + now = ktime_get(); + if (reg & CTRL_WLAN_READY) + break; + if (ktime_after(now, ktime_add_ms(start, wakeup_timeout))) { + dev_err(wdev->dev, "chip didn't wake up. Chip wasn't reset?\n"); + return -ETIMEDOUT; + } + } + dev_dbg(wdev->dev, "chip wake up after %lldus\n", ktime_us_delta(now, start)); + + ret = config_reg_write_bits(wdev, CFG_CPU_RESET, 0); + if (ret < 0) + return ret; + ret = load_firmware_secure(wdev); + if (ret < 0) + return ret; + ret = config_reg_write_bits(wdev, CFG_DIRECT_ACCESS_MODE | CFG_IRQ_ENABLE_DATA | CFG_IRQ_ENABLE_WRDY, CFG_IRQ_ENABLE_DATA); + return ret; +} diff --git a/drivers/staging/wfx/fwio.h b/drivers/staging/wfx/fwio.h new file mode 100644 index 000000000000..6028f92503fe --- /dev/null +++ b/drivers/staging/wfx/fwio.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Firmware loading. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_FWIO_H +#define WFX_FWIO_H + +struct wfx_dev; + +int wfx_init_device(struct wfx_dev *wdev); + +#endif /* WFX_FWIO_H */ diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 744445ef597c..a8ef29174232 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -20,6 +20,8 @@ #include "main.h" #include "wfx.h" +#include "fwio.h" +#include "hwio.h" #include "bus.h" #include "wfx_version.h" @@ -76,6 +78,24 @@ void wfx_free_common(struct wfx_dev *wdev) { } +int wfx_probe(struct wfx_dev *wdev) +{ + int err; + + err = wfx_init_device(wdev); + if (err) + goto err1; + + return 0; + +err1: + return err; +} + +void wfx_release(struct wfx_dev *wdev) +{ +} + static int __init wfx_core_init(void) { int ret = 0; diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index 82222edf998b..8b2526d81984 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -18,6 +18,13 @@ struct wfx_dev; struct wfx_platform_data { + /* Keyset and ".sec" extention will appended to this string */ + const char *file_fw; + /* + * if true HIF D_out is sampled on the rising edge of the clock + * (intended to be used in 50Mhz SDIO) + */ + bool use_rising_clk; }; struct wfx_dev *wfx_init_common(struct device *dev, @@ -26,6 +33,9 @@ struct wfx_dev *wfx_init_common(struct device *dev, void *hwbus_priv); void wfx_free_common(struct wfx_dev *wdev); +int wfx_probe(struct wfx_dev *wdev); +void wfx_release(struct wfx_dev *wdev); + struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 9716acc981df..56aed33291ae 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -19,6 +19,8 @@ struct wfx_dev { struct device *dev; const struct hwbus_ops *hwbus_ops; void *hwbus_priv; + + u8 keyset; }; #endif /* WFX_H */ -- cgit v1.2.3-59-g8ed1b From e4ee3cb3efc67893ad7d8e27176e5cfee6f3c7dc Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:39 +0000 Subject: staging: wfx: import HIF API headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These files are shared with firmware sources. Only a subset of these definitions are used by driver but, for now, it is easier to import all. API defines 3 kinds of messages: - Requests (req) are sent from host to chip - Confirmations (cnf) are sent by chip and are always in reply to a request - Indications (ind) are spontaneous message from chip to host One request normally generate one confirmation. There are a few exceptions to this rule: - "shutdown" request is not acknowledged - multiple tx request can be acknowledged a unique "multi-tx" confirmation In add, API defines MIB. They are sub-structures for write_mib and read_mib API. Note that all numbers in API have to be little endian when sent/received from/to chip (I didn't declared them with __le32 because driver also use them internally). Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-7-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_api_cmd.h | 681 ++++++++++++++++++++++++++++++++++ drivers/staging/wfx/hif_api_general.h | 437 ++++++++++++++++++++++ drivers/staging/wfx/hif_api_mib.h | 558 ++++++++++++++++++++++++++++ 3 files changed, 1676 insertions(+) create mode 100644 drivers/staging/wfx/hif_api_cmd.h create mode 100644 drivers/staging/wfx/hif_api_general.h create mode 100644 drivers/staging/wfx/hif_api_mib.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_api_cmd.h b/drivers/staging/wfx/hif_api_cmd.h new file mode 100644 index 000000000000..7c5d1ea6098d --- /dev/null +++ b/drivers/staging/wfx/hif_api_cmd.h @@ -0,0 +1,681 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * WFx hardware interface definitions + * + * Copyright (c) 2018-2019, Silicon Laboratories Inc. + */ + +#ifndef WFX_HIF_API_CMD_H +#define WFX_HIF_API_CMD_H + +#include "hif_api_general.h" + +#define HIF_NUM_AC 4 + +#define HIF_API_SSID_SIZE API_SSID_SIZE + +enum hif_requests_ids { + HIF_REQ_ID_RESET = 0x0a, + HIF_REQ_ID_READ_MIB = 0x05, + HIF_REQ_ID_WRITE_MIB = 0x06, + HIF_REQ_ID_START_SCAN = 0x07, + HIF_REQ_ID_STOP_SCAN = 0x08, + HIF_REQ_ID_TX = 0x04, + HIF_REQ_ID_JOIN = 0x0b, + HIF_REQ_ID_SET_PM_MODE = 0x10, + HIF_REQ_ID_SET_BSS_PARAMS = 0x11, + HIF_REQ_ID_ADD_KEY = 0x0c, + HIF_REQ_ID_REMOVE_KEY = 0x0d, + HIF_REQ_ID_EDCA_QUEUE_PARAMS = 0x13, + HIF_REQ_ID_START = 0x17, + HIF_REQ_ID_BEACON_TRANSMIT = 0x18, + HIF_REQ_ID_UPDATE_IE = 0x1b, + HIF_REQ_ID_MAP_LINK = 0x1c, +}; + +enum hif_confirmations_ids { + HIF_CNF_ID_RESET = 0x0a, + HIF_CNF_ID_READ_MIB = 0x05, + HIF_CNF_ID_WRITE_MIB = 0x06, + HIF_CNF_ID_START_SCAN = 0x07, + HIF_CNF_ID_STOP_SCAN = 0x08, + HIF_CNF_ID_TX = 0x04, + HIF_CNF_ID_MULTI_TRANSMIT = 0x1e, + HIF_CNF_ID_JOIN = 0x0b, + HIF_CNF_ID_SET_PM_MODE = 0x10, + HIF_CNF_ID_SET_BSS_PARAMS = 0x11, + HIF_CNF_ID_ADD_KEY = 0x0c, + HIF_CNF_ID_REMOVE_KEY = 0x0d, + HIF_CNF_ID_EDCA_QUEUE_PARAMS = 0x13, + HIF_CNF_ID_START = 0x17, + HIF_CNF_ID_BEACON_TRANSMIT = 0x18, + HIF_CNF_ID_UPDATE_IE = 0x1b, + HIF_CNF_ID_MAP_LINK = 0x1c, +}; + +enum hif_indications_ids { + HIF_IND_ID_RX = 0x84, + HIF_IND_ID_SCAN_CMPL = 0x86, + HIF_IND_ID_JOIN_COMPLETE = 0x8f, + HIF_IND_ID_SET_PM_MODE_CMPL = 0x89, + HIF_IND_ID_SUSPEND_RESUME_TX = 0x8c, + HIF_IND_ID_EVENT = 0x85 +}; + +union hif_commands_ids { + enum hif_requests_ids request; + enum hif_confirmations_ids confirmation; + enum hif_indications_ids indication; +}; + +enum hif_status { + HIF_STATUS_SUCCESS = 0x0, + HIF_STATUS_FAILURE = 0x1, + HIF_INVALID_PARAMETER = 0x2, + HIF_STATUS_WARNING = 0x3, + HIF_ERROR_UNSUPPORTED_MSG_ID = 0x4, + HIF_STATUS_DECRYPTFAILURE = 0x10, + HIF_STATUS_MICFAILURE = 0x11, + HIF_STATUS_NO_KEY_FOUND = 0x12, + HIF_STATUS_RETRY_EXCEEDED = 0x13, + HIF_STATUS_TX_LIFETIME_EXCEEDED = 0x14, + HIF_REQUEUE = 0x15, + HIF_STATUS_REFUSED = 0x16, + HIF_STATUS_BUSY = 0x17 +}; + +struct hif_reset_flags { + uint8_t reset_stat:1; + uint8_t reset_all_int:1; + uint8_t reserved1:6; + uint8_t reserved2[3]; +} __packed; + +struct hif_req_reset { + struct hif_reset_flags reset_flags; +} __packed; + +struct hif_cnf_reset { + uint32_t status; +} __packed; + +struct hif_req_read_mib { + uint16_t mib_id; + uint16_t reserved; +} __packed; + +struct hif_cnf_read_mib { + uint32_t status; + uint16_t mib_id; + uint16_t length; + uint8_t mib_data[]; +} __packed; + +struct hif_req_write_mib { + uint16_t mib_id; + uint16_t length; + uint8_t mib_data[]; +} __packed; + +struct hif_cnf_write_mib { + uint32_t status; +} __packed; + +struct hif_ie_flags { + uint8_t beacon:1; + uint8_t probe_resp:1; + uint8_t probe_req:1; + uint8_t reserved1:5; + uint8_t reserved2; +} __packed; + +struct hif_ie_tlv { + uint8_t type; + uint8_t length; + uint8_t data[]; +} __packed; + +struct hif_req_update_ie { + struct hif_ie_flags ie_flags; + uint16_t num_i_es; + struct hif_ie_tlv ie[]; +} __packed; + +struct hif_cnf_update_ie { + uint32_t status; +} __packed; + +struct hif_scan_type { + uint8_t type:1; + uint8_t mode:1; + uint8_t reserved:6; +} __packed; + +struct hif_scan_flags { + uint8_t fbg:1; + uint8_t reserved1:1; + uint8_t pre:1; + uint8_t reserved2:5; +} __packed; + +struct hif_auto_scan_param { + uint16_t interval; + uint8_t reserved; + int8_t rssi_thr; +} __packed; + +struct hif_ssid_def { + uint32_t ssid_length; + uint8_t ssid[HIF_API_SSID_SIZE]; +} __packed; + +#define HIF_API_MAX_NB_SSIDS 2 +#define HIF_API_MAX_NB_CHANNELS 14 + +struct hif_req_start_scan { + uint8_t band; + struct hif_scan_type scan_type; + struct hif_scan_flags scan_flags; + uint8_t max_transmit_rate; + struct hif_auto_scan_param auto_scan_param; + uint8_t num_of_probe_requests; + uint8_t probe_delay; + uint8_t num_of_ssi_ds; + uint8_t num_of_channels; + uint32_t min_channel_time; + uint32_t max_channel_time; + int32_t tx_power_level; + uint8_t ssid_and_channel_lists[]; +} __packed; + +struct hif_start_scan_req_cstnbssid_body { + uint8_t band; + struct hif_scan_type scan_type; + struct hif_scan_flags scan_flags; + uint8_t max_transmit_rate; + struct hif_auto_scan_param auto_scan_param; + uint8_t num_of_probe_requests; + uint8_t probe_delay; + uint8_t num_of_ssi_ds; + uint8_t num_of_channels; + uint32_t min_channel_time; + uint32_t max_channel_time; + int32_t tx_power_level; + struct hif_ssid_def ssid_def[HIF_API_MAX_NB_SSIDS]; + uint8_t channel_list[]; +} __packed; + +struct hif_cnf_start_scan { + uint32_t status; +} __packed; + +struct hif_cnf_stop_scan { + uint32_t status; +} __packed; + +enum hif_pm_mode_status { + HIF_PM_MODE_ACTIVE = 0x0, + HIF_PM_MODE_PS = 0x1, + HIF_PM_MODE_UNDETERMINED = 0x2 +}; + +struct hif_ind_scan_cmpl { + uint32_t status; + uint8_t pm_mode; + uint8_t num_channels_completed; + uint16_t reserved; +} __packed; + +enum hif_queue_id { + HIF_QUEUE_ID_BACKGROUND = 0x0, + HIF_QUEUE_ID_BESTEFFORT = 0x1, + HIF_QUEUE_ID_VIDEO = 0x2, + HIF_QUEUE_ID_VOICE = 0x3 +}; + +enum hif_frame_format { + HIF_FRAME_FORMAT_NON_HT = 0x0, + HIF_FRAME_FORMAT_MIXED_FORMAT_HT = 0x1, + HIF_FRAME_FORMAT_GF_HT_11N = 0x2 +}; + +enum hif_stbc { + HIF_STBC_NOT_ALLOWED = 0x0, + HIF_STBC_ALLOWED = 0x1 +}; + +struct hif_queue { + uint8_t queue_id:2; + uint8_t peer_sta_id:4; + uint8_t reserved:2; +} __packed; + +struct hif_data_flags { + uint8_t more:1; + uint8_t fc_offset:3; + uint8_t reserved:4; +} __packed; + +struct hif_tx_flags { + uint8_t start_exp:1; + uint8_t reserved:3; + uint8_t retry_policy_index:4; +} __packed; + +struct hif_ht_tx_parameters { + uint8_t frame_format:4; + uint8_t fec_coding:1; + uint8_t short_gi:1; + uint8_t reserved1:1; + uint8_t stbc:1; + uint8_t reserved2; + uint8_t aggregation:1; + uint8_t reserved3:7; + uint8_t reserved4; +} __packed; + +struct hif_req_tx { + uint32_t packet_id; + uint8_t max_tx_rate; + struct hif_queue queue_id; + struct hif_data_flags data_flags; + struct hif_tx_flags tx_flags; + uint32_t reserved; + uint32_t expire_time; + struct hif_ht_tx_parameters ht_tx_parameters; + uint8_t frame[]; +} __packed; + +enum hif_qos_ackplcy { + HIF_QOS_ACKPLCY_NORMAL = 0x0, + HIF_QOS_ACKPLCY_TXNOACK = 0x1, + HIF_QOS_ACKPLCY_NOEXPACK = 0x2, + HIF_QOS_ACKPLCY_BLCKACK = 0x3 +}; + +struct hif_tx_result_flags { + uint8_t aggr:1; + uint8_t requeue:1; + uint8_t ack_policy:2; + uint8_t txop_limit:1; + uint8_t reserved1:3; + uint8_t reserved2; +} __packed; + +struct hif_cnf_tx { + uint32_t status; + uint32_t packet_id; + uint8_t txed_rate; + uint8_t ack_failures; + struct hif_tx_result_flags tx_result_flags; + uint32_t media_delay; + uint32_t tx_queue_delay; +} __packed; + +struct hif_cnf_multi_transmit { + uint32_t num_tx_confs; + struct hif_cnf_tx tx_conf_payload[]; +} __packed; + +enum hif_ri_flags_encrypt { + HIF_RI_FLAGS_UNENCRYPTED = 0x0, + HIF_RI_FLAGS_WEP_ENCRYPTED = 0x1, + HIF_RI_FLAGS_TKIP_ENCRYPTED = 0x2, + HIF_RI_FLAGS_AES_ENCRYPTED = 0x3, + HIF_RI_FLAGS_WAPI_ENCRYPTED = 0x4 +}; + +struct hif_rx_flags { + uint8_t encryp:3; + uint8_t in_aggr:1; + uint8_t first_aggr:1; + uint8_t last_aggr:1; + uint8_t defrag:1; + uint8_t beacon:1; + uint8_t tim:1; + uint8_t bitmap:1; + uint8_t match_ssid:1; + uint8_t match_bssid:1; + uint8_t more:1; + uint8_t reserved1:1; + uint8_t ht:1; + uint8_t stbc:1; + uint8_t match_uc_addr:1; + uint8_t match_mc_addr:1; + uint8_t match_bc_addr:1; + uint8_t key_type:1; + uint8_t key_index:4; + uint8_t reserved2:1; + uint8_t peer_sta_id:4; + uint8_t reserved3:2; + uint8_t reserved4:1; +} __packed; + +struct hif_ind_rx { + uint32_t status; + uint16_t channel_number; + uint8_t rxed_rate; + uint8_t rcpi_rssi; + struct hif_rx_flags rx_flags; + uint8_t frame[]; +} __packed; + + +struct hif_req_edca_queue_params { + uint8_t queue_id; + uint8_t reserved1; + uint8_t aifsn; + uint8_t reserved2; + uint16_t cw_min; + uint16_t cw_max; + uint16_t tx_op_limit; + uint16_t allowed_medium_time; + uint32_t reserved3; +} __packed; + +struct hif_cnf_edca_queue_params { + uint32_t status; +} __packed; + +enum hif_ap_mode { + HIF_MODE_IBSS = 0x0, + HIF_MODE_BSS = 0x1 +}; + +enum hif_preamble { + HIF_PREAMBLE_LONG = 0x0, + HIF_PREAMBLE_SHORT = 0x1, + HIF_PREAMBLE_SHORT_LONG12 = 0x2 +}; + +struct hif_join_flags { + uint8_t reserved1:2; + uint8_t force_no_beacon:1; + uint8_t force_with_ind:1; + uint8_t reserved2:4; +} __packed; + +struct hif_req_join { + uint8_t mode; + uint8_t band; + uint16_t channel_number; + uint8_t bssid[ETH_ALEN]; + uint16_t atim_window; + uint8_t preamble_type; + uint8_t probe_for_join; + uint8_t reserved; + struct hif_join_flags join_flags; + uint32_t ssid_length; + uint8_t ssid[HIF_API_SSID_SIZE]; + uint32_t beacon_interval; + uint32_t basic_rate_set; +} __packed; + +struct hif_cnf_join { + uint32_t status; +} __packed; + +struct hif_ind_join_complete { + uint32_t status; +} __packed; + +struct hif_bss_flags { + uint8_t lost_count_only:1; + uint8_t reserved:7; +} __packed; + +struct hif_req_set_bss_params { + struct hif_bss_flags bss_flags; + uint8_t beacon_lost_count; + uint16_t aid; + uint32_t operational_rate_set; +} __packed; + +struct hif_cnf_set_bss_params { + uint32_t status; +} __packed; + +struct hif_pm_mode { + uint8_t enter_psm:1; + uint8_t reserved:6; + uint8_t fast_psm:1; +} __packed; + +struct hif_req_set_pm_mode { + struct hif_pm_mode pm_mode; + uint8_t fast_psm_idle_period; + uint8_t ap_psm_change_period; + uint8_t min_auto_ps_poll_period; +} __packed; + +struct hif_cnf_set_pm_mode { + uint32_t status; +} __packed; + +struct hif_ind_set_pm_mode_cmpl { + uint32_t status; + uint8_t pm_mode; + uint8_t reserved[3]; +} __packed; + + +struct hif_req_start { + uint8_t mode; + uint8_t band; + uint16_t channel_number; + uint32_t reserved1; + uint32_t beacon_interval; + uint8_t dtim_period; + uint8_t preamble_type; + uint8_t reserved2; + uint8_t ssid_length; + uint8_t ssid[HIF_API_SSID_SIZE]; + uint32_t basic_rate_set; +} __packed; + +struct hif_cnf_start { + uint32_t status; +} __packed; + +enum hif_beacon { + HIF_BEACON_STOP = 0x0, + HIF_BEACON_START = 0x1 +}; + +struct hif_req_beacon_transmit { + uint8_t enable_beaconing; + uint8_t reserved[3]; +} __packed; + +struct hif_cnf_beacon_transmit { + uint32_t status; +} __packed; + +enum hif_sta_map_direction { + HIF_STA_MAP = 0x0, + HIF_STA_UNMAP = 0x1 +}; + +struct hif_map_link_flags { + uint8_t map_direction:1; + uint8_t mfpc:1; + uint8_t reserved:6; +} __packed; + +struct hif_req_map_link { + uint8_t mac_addr[ETH_ALEN]; + struct hif_map_link_flags map_link_flags; + uint8_t peer_sta_id; +} __packed; + +struct hif_cnf_map_link { + uint32_t status; +} __packed; + +struct hif_suspend_resume_flags { + uint8_t resume:1; + uint8_t reserved1:2; + uint8_t bc_mc_only:1; + uint8_t reserved2:4; + uint8_t reserved3; +} __packed; + +struct hif_ind_suspend_resume_tx { + struct hif_suspend_resume_flags suspend_resume_flags; + uint16_t peer_sta_set; +} __packed; + + +#define MAX_KEY_ENTRIES 24 +#define HIF_API_WEP_KEY_DATA_SIZE 16 +#define HIF_API_TKIP_KEY_DATA_SIZE 16 +#define HIF_API_RX_MIC_KEY_SIZE 8 +#define HIF_API_TX_MIC_KEY_SIZE 8 +#define HIF_API_AES_KEY_DATA_SIZE 16 +#define HIF_API_WAPI_KEY_DATA_SIZE 16 +#define HIF_API_MIC_KEY_DATA_SIZE 16 +#define HIF_API_IGTK_KEY_DATA_SIZE 16 +#define HIF_API_RX_SEQUENCE_COUNTER_SIZE 8 +#define HIF_API_IPN_SIZE 8 + +enum hif_key_type { + HIF_KEY_TYPE_WEP_DEFAULT = 0x0, + HIF_KEY_TYPE_WEP_PAIRWISE = 0x1, + HIF_KEY_TYPE_TKIP_GROUP = 0x2, + HIF_KEY_TYPE_TKIP_PAIRWISE = 0x3, + HIF_KEY_TYPE_AES_GROUP = 0x4, + HIF_KEY_TYPE_AES_PAIRWISE = 0x5, + HIF_KEY_TYPE_WAPI_GROUP = 0x6, + HIF_KEY_TYPE_WAPI_PAIRWISE = 0x7, + HIF_KEY_TYPE_IGTK_GROUP = 0x8, + HIF_KEY_TYPE_NONE = 0x9 +}; + +struct hif_wep_pairwise_key { + uint8_t peer_address[ETH_ALEN]; + uint8_t reserved; + uint8_t key_length; + uint8_t key_data[HIF_API_WEP_KEY_DATA_SIZE]; +} __packed; + +struct hif_wep_group_key { + uint8_t key_id; + uint8_t key_length; + uint8_t reserved[2]; + uint8_t key_data[HIF_API_WEP_KEY_DATA_SIZE]; +} __packed; + +struct hif_tkip_pairwise_key { + uint8_t peer_address[ETH_ALEN]; + uint8_t reserved[2]; + uint8_t tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE]; + uint8_t rx_mic_key[HIF_API_RX_MIC_KEY_SIZE]; + uint8_t tx_mic_key[HIF_API_TX_MIC_KEY_SIZE]; +} __packed; + +struct hif_tkip_group_key { + uint8_t tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE]; + uint8_t rx_mic_key[HIF_API_RX_MIC_KEY_SIZE]; + uint8_t key_id; + uint8_t reserved[3]; + uint8_t rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE]; +} __packed; + +struct hif_aes_pairwise_key { + uint8_t peer_address[ETH_ALEN]; + uint8_t reserved[2]; + uint8_t aes_key_data[HIF_API_AES_KEY_DATA_SIZE]; +} __packed; + +struct hif_aes_group_key { + uint8_t aes_key_data[HIF_API_AES_KEY_DATA_SIZE]; + uint8_t key_id; + uint8_t reserved[3]; + uint8_t rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE]; +} __packed; + +struct hif_wapi_pairwise_key { + uint8_t peer_address[ETH_ALEN]; + uint8_t key_id; + uint8_t reserved; + uint8_t wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE]; + uint8_t mic_key_data[HIF_API_MIC_KEY_DATA_SIZE]; +} __packed; + +struct hif_wapi_group_key { + uint8_t wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE]; + uint8_t mic_key_data[HIF_API_MIC_KEY_DATA_SIZE]; + uint8_t key_id; + uint8_t reserved[3]; +} __packed; + +struct hif_igtk_group_key { + uint8_t igtk_key_data[HIF_API_IGTK_KEY_DATA_SIZE]; + uint8_t key_id; + uint8_t reserved[3]; + uint8_t ipn[HIF_API_IPN_SIZE]; +} __packed; + +union hif_privacy_key_data { + struct hif_wep_pairwise_key wep_pairwise_key; + struct hif_wep_group_key wep_group_key; + struct hif_tkip_pairwise_key tkip_pairwise_key; + struct hif_tkip_group_key tkip_group_key; + struct hif_aes_pairwise_key aes_pairwise_key; + struct hif_aes_group_key aes_group_key; + struct hif_wapi_pairwise_key wapi_pairwise_key; + struct hif_wapi_group_key wapi_group_key; + struct hif_igtk_group_key igtk_group_key; +}; + +struct hif_req_add_key { + uint8_t type; + uint8_t entry_index; + uint8_t int_id:2; + uint8_t reserved1:6; + uint8_t reserved2; + union hif_privacy_key_data key; +} __packed; + +struct hif_cnf_add_key { + uint32_t status; +} __packed; + +struct hif_req_remove_key { + uint8_t entry_index; + uint8_t reserved[3]; +} __packed; + +struct hif_cnf_remove_key { + uint32_t status; +} __packed; + +enum hif_event_ind { + HIF_EVENT_IND_BSSLOST = 0x1, + HIF_EVENT_IND_BSSREGAINED = 0x2, + HIF_EVENT_IND_RCPI_RSSI = 0x3, + HIF_EVENT_IND_PS_MODE_ERROR = 0x4, + HIF_EVENT_IND_INACTIVITY = 0x5 +}; + +enum hif_ps_mode_error { + HIF_PS_ERROR_NO_ERROR = 0, + HIF_PS_ERROR_AP_NOT_RESP_TO_POLL = 1, + HIF_PS_ERROR_AP_NOT_RESP_TO_UAPSD_TRIGGER = 2, + HIF_PS_ERROR_AP_SENT_UNICAST_IN_DOZE = 3, + HIF_PS_ERROR_AP_NO_DATA_AFTER_TIM = 4 +}; + +union hif_event_data { + uint8_t rcpi_rssi; + uint32_t ps_mode_error; + uint32_t peer_sta_set; +}; + +struct hif_ind_event { + uint32_t event_id; + union hif_event_data event_data; +} __packed; + + +#endif diff --git a/drivers/staging/wfx/hif_api_general.h b/drivers/staging/wfx/hif_api_general.h new file mode 100644 index 000000000000..d885b55d2882 --- /dev/null +++ b/drivers/staging/wfx/hif_api_general.h @@ -0,0 +1,437 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * WFx hardware interface definitions + * + * Copyright (c) 2018-2019, Silicon Laboratories Inc. + */ + +#ifndef WFX_HIF_API_GENERAL_H +#define WFX_HIF_API_GENERAL_H + +#ifdef __KERNEL__ +#include +#include +#else +#include +#include +#define __packed __attribute__((__packed__)) +#endif + +#define API_SSID_SIZE 32 + +#define HIF_ID_IS_INDICATION 0x80 +#define HIF_COUNTER_MAX 7 + +struct hif_msg { + uint16_t len; + uint8_t id; + uint8_t reserved:1; + uint8_t interface:2; + uint8_t seqnum:3; + uint8_t encrypted:2; + uint8_t body[]; +} __packed; + +enum hif_general_requests_ids { + HIF_REQ_ID_CONFIGURATION = 0x09, + HIF_REQ_ID_CONTROL_GPIO = 0x26, + HIF_REQ_ID_SET_SL_MAC_KEY = 0x27, + HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS = 0x28, + HIF_REQ_ID_SL_CONFIGURE = 0x29, + HIF_REQ_ID_PREVENT_ROLLBACK = 0x2a, + HIF_REQ_ID_PTA_SETTINGS = 0x2b, + HIF_REQ_ID_PTA_PRIORITY = 0x2c, + HIF_REQ_ID_PTA_STATE = 0x2d, + HIF_REQ_ID_SHUT_DOWN = 0x32, +}; + +enum hif_general_confirmations_ids { + HIF_CNF_ID_CONFIGURATION = 0x09, + HIF_CNF_ID_CONTROL_GPIO = 0x26, + HIF_CNF_ID_SET_SL_MAC_KEY = 0x27, + HIF_CNF_ID_SL_EXCHANGE_PUB_KEYS = 0x28, + HIF_CNF_ID_SL_CONFIGURE = 0x29, + HIF_CNF_ID_PREVENT_ROLLBACK = 0x2a, + HIF_CNF_ID_PTA_SETTINGS = 0x2b, + HIF_CNF_ID_PTA_PRIORITY = 0x2c, + HIF_CNF_ID_PTA_STATE = 0x2d, + HIF_CNF_ID_SHUT_DOWN = 0x32, +}; + +enum hif_general_indications_ids { + HIF_IND_ID_EXCEPTION = 0xe0, + HIF_IND_ID_STARTUP = 0xe1, + HIF_IND_ID_WAKEUP = 0xe2, + HIF_IND_ID_GENERIC = 0xe3, + HIF_IND_ID_ERROR = 0xe4, + HIF_IND_ID_SL_EXCHANGE_PUB_KEYS = 0xe5 +}; + +enum hif_hi_status { + HI_STATUS_SUCCESS = 0x0000, + HI_STATUS_FAILURE = 0x0001, + HI_INVALID_PARAMETER = 0x0002, + HI_STATUS_GPIO_WARNING = 0x0003, + HI_ERROR_UNSUPPORTED_MSG_ID = 0x0004, + SL_MAC_KEY_STATUS_SUCCESS = 0x005A, + SL_MAC_KEY_STATUS_FAILED_KEY_ALREADY_BURNED = 0x006B, + SL_MAC_KEY_STATUS_FAILED_RAM_MODE_NOT_ALLOWED = 0x007C, + SL_MAC_KEY_STATUS_FAILED_UNKNOWN_MODE = 0x008D, + SL_PUB_KEY_EXCHANGE_STATUS_SUCCESS = 0x009E, + SL_PUB_KEY_EXCHANGE_STATUS_FAILED = 0x00AF, + PREVENT_ROLLBACK_CNF_SUCCESS = 0x1234, + PREVENT_ROLLBACK_CNF_WRONG_MAGIC_WORD = 0x1256 +}; + +enum hif_api_rate_index { + API_RATE_INDEX_B_1MBPS = 0, + API_RATE_INDEX_B_2MBPS = 1, + API_RATE_INDEX_B_5P5MBPS = 2, + API_RATE_INDEX_B_11MBPS = 3, + API_RATE_INDEX_PBCC_22MBPS = 4, + API_RATE_INDEX_PBCC_33MBPS = 5, + API_RATE_INDEX_G_6MBPS = 6, + API_RATE_INDEX_G_9MBPS = 7, + API_RATE_INDEX_G_12MBPS = 8, + API_RATE_INDEX_G_18MBPS = 9, + API_RATE_INDEX_G_24MBPS = 10, + API_RATE_INDEX_G_36MBPS = 11, + API_RATE_INDEX_G_48MBPS = 12, + API_RATE_INDEX_G_54MBPS = 13, + API_RATE_INDEX_N_6P5MBPS = 14, + API_RATE_INDEX_N_13MBPS = 15, + API_RATE_INDEX_N_19P5MBPS = 16, + API_RATE_INDEX_N_26MBPS = 17, + API_RATE_INDEX_N_39MBPS = 18, + API_RATE_INDEX_N_52MBPS = 19, + API_RATE_INDEX_N_58P5MBPS = 20, + API_RATE_INDEX_N_65MBPS = 21, + API_RATE_NUM_ENTRIES = 22 +}; + + +enum hif_fw_type { + HIF_FW_TYPE_ETF = 0x0, + HIF_FW_TYPE_WFM = 0x1, + HIF_FW_TYPE_WSM = 0x2 +}; + +struct hif_capabilities { + uint8_t link_mode:2; + uint8_t reserved1:6; + uint8_t reserved2; + uint8_t reserved3; + uint8_t reserved4; +} __packed; + +struct hif_otp_regul_sel_mode_info { + uint8_t region_sel_mode:4; + uint8_t reserved:4; +} __packed; + +struct hif_otp_phy_info { + uint8_t phy1_region:3; + uint8_t phy0_region:3; + uint8_t otp_phy_ver:2; +} __packed; + +#define API_OPN_SIZE 14 +#define API_UID_SIZE 8 +#define API_DISABLED_CHANNEL_LIST_SIZE 2 +#define API_FIRMWARE_LABEL_SIZE 128 + +struct hif_ind_startup { + uint32_t status; + uint16_t hardware_id; + uint8_t opn[API_OPN_SIZE]; + uint8_t uid[API_UID_SIZE]; + uint16_t num_inp_ch_bufs; + uint16_t size_inp_ch_buf; + uint8_t num_links_ap; + uint8_t num_interfaces; + uint8_t mac_addr[2][ETH_ALEN]; + uint8_t api_version_minor; + uint8_t api_version_major; + struct hif_capabilities capabilities; + uint8_t firmware_build; + uint8_t firmware_minor; + uint8_t firmware_major; + uint8_t firmware_type; + uint8_t disabled_channel_list[API_DISABLED_CHANNEL_LIST_SIZE]; + struct hif_otp_regul_sel_mode_info regul_sel_mode_info; + struct hif_otp_phy_info otp_phy_info; + uint32_t supported_rate_mask; + uint8_t firmware_label[API_FIRMWARE_LABEL_SIZE]; +} __packed; + +struct hif_ind_wakeup { +} __packed; + +struct hif_req_configuration { + uint16_t length; + uint8_t pds_data[]; +} __packed; + +struct hif_cnf_configuration { + uint32_t status; +} __packed; + +enum hif_gpio_mode { + HIF_GPIO_MODE_D0 = 0x0, + HIF_GPIO_MODE_D1 = 0x1, + HIF_GPIO_MODE_OD0 = 0x2, + HIF_GPIO_MODE_OD1 = 0x3, + HIF_GPIO_MODE_TRISTATE = 0x4, + HIF_GPIO_MODE_TOGGLE = 0x5, + HIF_GPIO_MODE_READ = 0x6 +}; + +struct hif_req_control_gpio { + uint8_t gpio_label; + uint8_t gpio_mode; +} __packed; + +enum hif_gpio_error { + HIF_GPIO_ERROR_0 = 0x0, + HIF_GPIO_ERROR_1 = 0x1, + HIF_GPIO_ERROR_2 = 0x2 +}; + +struct hif_cnf_control_gpio { + uint32_t status; + uint32_t value; +} __packed; + +enum hif_generic_indication_type { + HIF_GENERIC_INDICATION_TYPE_RAW = 0x0, + HIF_GENERIC_INDICATION_TYPE_STRING = 0x1, + HIF_GENERIC_INDICATION_TYPE_RX_STATS = 0x2 +}; + +struct hif_rx_stats { + uint32_t nb_rx_frame; + uint32_t nb_crc_frame; + uint32_t per_total; + uint32_t throughput; + uint32_t nb_rx_by_rate[API_RATE_NUM_ENTRIES]; + uint16_t per[API_RATE_NUM_ENTRIES]; + int16_t snr[API_RATE_NUM_ENTRIES]; + int16_t rssi[API_RATE_NUM_ENTRIES]; + int16_t cfo[API_RATE_NUM_ENTRIES]; + uint32_t date; + uint32_t pwr_clk_freq; + uint8_t is_ext_pwr_clk; + int8_t current_temp; +} __packed; + +union hif_indication_data { + struct hif_rx_stats rx_stats; + uint8_t raw_data[1]; +}; + +struct hif_ind_generic { + uint32_t indication_type; + union hif_indication_data indication_data; +} __packed; + + +#define HIF_EXCEPTION_DATA_SIZE 124 + +struct hif_ind_exception { + uint8_t data[HIF_EXCEPTION_DATA_SIZE]; +} __packed; + + +enum hif_error { + HIF_ERROR_FIRMWARE_ROLLBACK = 0x0, + HIF_ERROR_FIRMWARE_DEBUG_ENABLED = 0x1, + HIF_ERROR_OUTDATED_SESSION_KEY = 0x2, + HIF_ERROR_INVALID_SESSION_KEY = 0x3, + HIF_ERROR_OOR_VOLTAGE = 0x4, + HIF_ERROR_PDS_VERSION = 0x5, + HIF_ERROR_OOR_TEMPERATURE = 0x6, + HIF_ERROR_REQ_DURING_KEY_EXCHANGE = 0x7, + HIF_ERROR_MULTI_TX_CNF_SECURELINK = 0x8, + HIF_ERROR_SECURELINK_OVERFLOW = 0x9, + HIF_ERROR_SECURELINK_DECRYPTION = 0xa +}; + +struct hif_ind_error { + uint32_t type; + uint8_t data[]; +} __packed; + +enum hif_secure_link_state { + SEC_LINK_UNAVAILABLE = 0x0, + SEC_LINK_RESERVED = 0x1, + SEC_LINK_EVAL = 0x2, + SEC_LINK_ENFORCED = 0x3 +}; + +enum hif_sl_encryption_type { + NO_ENCRYPTION = 0, + TX_ENCRYPTION = 1, + RX_ENCRYPTION = 2, + HP_ENCRYPTION = 3 +}; + +struct hif_sl_msg_hdr { + uint32_t seqnum:30; + uint32_t encrypted:2; +} __packed; + +struct hif_sl_msg { + struct hif_sl_msg_hdr hdr; + uint16_t len; + uint8_t payload[]; +} __packed; + +#define AES_CCM_TAG_SIZE 16 + +struct hif_sl_tag { + uint8_t tag[16]; +} __packed; + +enum hif_sl_mac_key_dest { + SL_MAC_KEY_DEST_OTP = 0x78, + SL_MAC_KEY_DEST_RAM = 0x87 +}; + +#define API_KEY_VALUE_SIZE 32 + +struct hif_req_set_sl_mac_key { + uint8_t otp_or_ram; + uint8_t key_value[API_KEY_VALUE_SIZE]; +} __packed; + +struct hif_cnf_set_sl_mac_key { + uint32_t status; +} __packed; + +#define API_HOST_PUB_KEY_SIZE 32 +#define API_HOST_PUB_KEY_MAC_SIZE 64 + +enum hif_sl_session_key_alg { + HIF_SL_CURVE25519 = 0x01, + HIF_SL_KDF = 0x02 +}; + +struct hif_req_sl_exchange_pub_keys { + uint8_t algorithm:2; + uint8_t reserved1:6; + uint8_t reserved2[3]; + uint8_t host_pub_key[API_HOST_PUB_KEY_SIZE]; + uint8_t host_pub_key_mac[API_HOST_PUB_KEY_MAC_SIZE]; +} __packed; + +struct hif_cnf_sl_exchange_pub_keys { + uint32_t status; +} __packed; + +#define API_NCP_PUB_KEY_SIZE 32 +#define API_NCP_PUB_KEY_MAC_SIZE 64 + +struct hif_ind_sl_exchange_pub_keys { + uint32_t status; + uint8_t ncp_pub_key[API_NCP_PUB_KEY_SIZE]; + uint8_t ncp_pub_key_mac[API_NCP_PUB_KEY_MAC_SIZE]; +} __packed; + +#define API_ENCR_BMP_SIZE 32 + +struct hif_req_sl_configure { + uint8_t encr_bmp[API_ENCR_BMP_SIZE]; + uint8_t disable_session_key_protection:1; + uint8_t reserved1:7; + uint8_t reserved2[3]; +} __packed; + +struct hif_cnf_sl_configure { + uint32_t status; +} __packed; + +struct hif_req_prevent_rollback { + uint32_t magic_word; +} __packed; + +struct hif_cnf_prevent_rollback { + uint32_t status; +} __packed; + +enum hif_pta_mode { + PTA_1W_WLAN_MASTER = 0, + PTA_1W_COEX_MASTER = 1, + PTA_2W = 2, + PTA_3W = 3, + PTA_4W = 4 +}; + +enum hif_signal_level { + SIGNAL_LOW = 0, + SIGNAL_HIGH = 1 +}; + +enum hif_coex_type { + COEX_TYPE_GENERIC = 0, + COEX_TYPE_BLE = 1 +}; + +enum hif_grant_state { + NO_GRANT = 0, + GRANT = 1 +}; + +struct hif_req_pta_settings { + uint8_t pta_mode; + uint8_t request_signal_active_level; + uint8_t priority_signal_active_level; + uint8_t freq_signal_active_level; + uint8_t grant_signal_active_level; + uint8_t coex_type; + uint8_t default_grant_state; + uint8_t simultaneous_rx_accesses; + uint8_t priority_sampling_time; + uint8_t tx_rx_sampling_time; + uint8_t freq_sampling_time; + uint8_t grant_valid_time; + uint8_t fem_control_time; + uint8_t first_slot_time; + uint16_t periodic_tx_rx_sampling_time; + uint16_t coex_quota; + uint16_t wlan_quota; +} __packed; + +struct hif_cnf_pta_settings { + uint32_t status; +} __packed; + +enum hif_pta_priority { + HIF_PTA_PRIORITY_COEX_MAXIMIZED = 0x00000562, + HIF_PTA_PRIORITY_COEX_HIGH = 0x00000462, + HIF_PTA_PRIORITY_BALANCED = 0x00001461, + HIF_PTA_PRIORITY_WLAN_HIGH = 0x00001851, + HIF_PTA_PRIORITY_WLAN_MAXIMIZED = 0x00001A51 +}; + +struct hif_req_pta_priority { + uint32_t priority; +} __packed; + +struct hif_cnf_pta_priority { + uint32_t status; +} __packed; + +enum hif_pta_state { + PTA_OFF = 0, + PTA_ON = 1 +}; + +struct hif_req_pta_state { + uint32_t pta_state; +} __packed; + +struct hif_cnf_pta_state { + uint32_t status; +} __packed; + +#endif diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h new file mode 100644 index 000000000000..3c56ef2978a2 --- /dev/null +++ b/drivers/staging/wfx/hif_api_mib.h @@ -0,0 +1,558 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * WFx hardware interface definitions + * + * Copyright (c) 2018-2019, Silicon Laboratories Inc. + */ + +#ifndef WFX_HIF_API_MIB_H +#define WFX_HIF_API_MIB_H + +#include "hif_api_general.h" + +#define HIF_API_IPV4_ADDRESS_SIZE 4 +#define HIF_API_IPV6_ADDRESS_SIZE 16 + +enum hif_mib_ids { + HIF_MIB_ID_GL_OPERATIONAL_POWER_MODE = 0x2000, + HIF_MIB_ID_GL_BLOCK_ACK_INFO = 0x2001, + HIF_MIB_ID_GL_SET_MULTI_MSG = 0x2002, + HIF_MIB_ID_CCA_CONFIG = 0x2003, + HIF_MIB_ID_ETHERTYPE_DATAFRAME_CONDITION = 0x2010, + HIF_MIB_ID_PORT_DATAFRAME_CONDITION = 0x2011, + HIF_MIB_ID_MAGIC_DATAFRAME_CONDITION = 0x2012, + HIF_MIB_ID_MAC_ADDR_DATAFRAME_CONDITION = 0x2013, + HIF_MIB_ID_IPV4_ADDR_DATAFRAME_CONDITION = 0x2014, + HIF_MIB_ID_IPV6_ADDR_DATAFRAME_CONDITION = 0x2015, + HIF_MIB_ID_UC_MC_BC_DATAFRAME_CONDITION = 0x2016, + HIF_MIB_ID_CONFIG_DATA_FILTER = 0x2017, + HIF_MIB_ID_SET_DATA_FILTERING = 0x2018, + HIF_MIB_ID_ARP_IP_ADDRESSES_TABLE = 0x2019, + HIF_MIB_ID_NS_IP_ADDRESSES_TABLE = 0x201A, + HIF_MIB_ID_RX_FILTER = 0x201B, + HIF_MIB_ID_BEACON_FILTER_TABLE = 0x201C, + HIF_MIB_ID_BEACON_FILTER_ENABLE = 0x201D, + HIF_MIB_ID_GRP_SEQ_COUNTER = 0x2030, + HIF_MIB_ID_TSF_COUNTER = 0x2031, + HIF_MIB_ID_STATISTICS_TABLE = 0x2032, + HIF_MIB_ID_COUNTERS_TABLE = 0x2033, + HIF_MIB_ID_MAX_TX_POWER_LEVEL = 0x2034, + HIF_MIB_ID_EXTENDED_COUNTERS_TABLE = 0x2035, + HIF_MIB_ID_DOT11_MAC_ADDRESS = 0x2040, + HIF_MIB_ID_DOT11_MAX_TRANSMIT_MSDU_LIFETIME = 0x2041, + HIF_MIB_ID_DOT11_MAX_RECEIVE_LIFETIME = 0x2042, + HIF_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID = 0x2043, + HIF_MIB_ID_DOT11_RTS_THRESHOLD = 0x2044, + HIF_MIB_ID_SLOT_TIME = 0x2045, + HIF_MIB_ID_CURRENT_TX_POWER_LEVEL = 0x2046, + HIF_MIB_ID_NON_ERP_PROTECTION = 0x2047, + HIF_MIB_ID_TEMPLATE_FRAME = 0x2048, + HIF_MIB_ID_BEACON_WAKEUP_PERIOD = 0x2049, + HIF_MIB_ID_RCPI_RSSI_THRESHOLD = 0x204A, + HIF_MIB_ID_BLOCK_ACK_POLICY = 0x204B, + HIF_MIB_ID_OVERRIDE_INTERNAL_TX_RATE = 0x204C, + HIF_MIB_ID_SET_ASSOCIATION_MODE = 0x204D, + HIF_MIB_ID_SET_UAPSD_INFORMATION = 0x204E, + HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY = 0x204F, + HIF_MIB_ID_PROTECTED_MGMT_POLICY = 0x2050, + HIF_MIB_ID_SET_HT_PROTECTION = 0x2051, + HIF_MIB_ID_KEEP_ALIVE_PERIOD = 0x2052, + HIF_MIB_ID_ARP_KEEP_ALIVE_PERIOD = 0x2053, + HIF_MIB_ID_INACTIVITY_TIMER = 0x2054, + HIF_MIB_ID_INTERFACE_PROTECTION = 0x2055, + HIF_MIB_ID_BEACON_STATS = 0x2056, +}; + +#define HIF_OP_POWER_MODE_MASK 0xf + +enum hif_op_power_mode { + HIF_OP_POWER_MODE_ACTIVE = 0x0, + HIF_OP_POWER_MODE_DOZE = 0x1, + HIF_OP_POWER_MODE_QUIESCENT = 0x2 +}; + +struct hif_mib_gl_operational_power_mode { + uint8_t power_mode:4; + uint8_t reserved1:3; + uint8_t wup_ind_activation:1; + uint8_t reserved2[3]; +} __packed; + +struct hif_mib_gl_block_ack_info { + uint8_t rx_buffer_size; + uint8_t rx_max_num_agreements; + uint8_t tx_buffer_size; + uint8_t tx_max_num_agreements; +} __packed; + +struct hif_mib_gl_set_multi_msg { + uint8_t enable_multi_tx_conf:1; + uint8_t reserved1:7; + uint8_t reserved2[3]; +} __packed; + +enum hif_cca_thr_mode { + HIF_CCA_THR_MODE_RELATIVE = 0x0, + HIF_CCA_THR_MODE_ABSOLUTE = 0x1 +}; + +struct hif_mib_gl_cca_config { + uint8_t cca_thr_mode; + uint8_t reserved[3]; +} __packed; + +#define MAX_NUMBER_DATA_FILTERS 0xA + +#define MAX_NUMBER_IPV4_ADDR_CONDITIONS 0x4 +#define MAX_NUMBER_IPV6_ADDR_CONDITIONS 0x4 +#define MAX_NUMBER_MAC_ADDR_CONDITIONS 0x4 +#define MAX_NUMBER_UC_MC_BC_CONDITIONS 0x4 +#define MAX_NUMBER_ETHER_TYPE_CONDITIONS 0x4 +#define MAX_NUMBER_PORT_CONDITIONS 0x4 +#define MAX_NUMBER_MAGIC_CONDITIONS 0x4 +#define MAX_NUMBER_ARP_CONDITIONS 0x2 +#define MAX_NUMBER_NS_CONDITIONS 0x2 + +struct hif_mib_ethertype_data_frame_condition { + uint8_t condition_idx; + uint8_t reserved; + uint16_t ether_type; +} __packed; + +enum hif_udp_tcp_protocol { + HIF_PROTOCOL_UDP = 0x0, + HIF_PROTOCOL_TCP = 0x1, + HIF_PROTOCOL_BOTH_UDP_TCP = 0x2 +}; + +enum hif_which_port { + HIF_PORT_DST = 0x0, + HIF_PORT_SRC = 0x1, + HIF_PORT_SRC_OR_DST = 0x2 +}; + +struct hif_mib_ports_data_frame_condition { + uint8_t condition_idx; + uint8_t protocol; + uint8_t which_port; + uint8_t reserved1; + uint16_t port_number; + uint8_t reserved2[2]; +} __packed; + +#define HIF_API_MAGIC_PATTERN_SIZE 32 + +struct hif_mib_magic_data_frame_condition { + uint8_t condition_idx; + uint8_t offset; + uint8_t magic_pattern_length; + uint8_t reserved; + uint8_t magic_pattern[HIF_API_MAGIC_PATTERN_SIZE]; +} __packed; + +enum hif_mac_addr_type { + HIF_MAC_ADDR_A1 = 0x0, + HIF_MAC_ADDR_A2 = 0x1, + HIF_MAC_ADDR_A3 = 0x2 +}; + +struct hif_mib_mac_addr_data_frame_condition { + uint8_t condition_idx; + uint8_t address_type; + uint8_t mac_address[ETH_ALEN]; +} __packed; + +enum hif_ip_addr_mode { + HIF_IP_ADDR_SRC = 0x0, + HIF_IP_ADDR_DST = 0x1 +}; + +struct hif_mib_ipv4_addr_data_frame_condition { + uint8_t condition_idx; + uint8_t address_mode; + uint8_t reserved[2]; + uint8_t i_pv4_address[HIF_API_IPV4_ADDRESS_SIZE]; +} __packed; + +struct hif_mib_ipv6_addr_data_frame_condition { + uint8_t condition_idx; + uint8_t address_mode; + uint8_t reserved[2]; + uint8_t i_pv6_address[HIF_API_IPV6_ADDRESS_SIZE]; +} __packed; + +union hif_addr_type { + uint8_t value; + struct { + uint8_t type_unicast:1; + uint8_t type_multicast:1; + uint8_t type_broadcast:1; + uint8_t reserved:5; + } bits; +}; + +struct hif_mib_uc_mc_bc_data_frame_condition { + uint8_t condition_idx; + union hif_addr_type param; + uint8_t reserved[2]; +} __packed; + +struct hif_mib_config_data_filter { + uint8_t filter_idx; + uint8_t enable; + uint8_t reserved1[2]; + uint8_t eth_type_cond; + uint8_t port_cond; + uint8_t magic_cond; + uint8_t mac_cond; + uint8_t ipv4_cond; + uint8_t ipv6_cond; + uint8_t uc_mc_bc_cond; + uint8_t reserved2; +} __packed; + +struct hif_mib_set_data_filtering { + uint8_t default_filter; + uint8_t enable; + uint8_t reserved[2]; +} __packed; + +enum hif_arp_ns_frame_treatment { + HIF_ARP_NS_FILTERING_DISABLE = 0x0, + HIF_ARP_NS_FILTERING_ENABLE = 0x1, + HIF_ARP_NS_REPLY_ENABLE = 0x2 +}; + +struct hif_mib_arp_ip_addr_table { + uint8_t condition_idx; + uint8_t arp_enable; + uint8_t reserved[2]; + uint8_t ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; +} __packed; + +struct hif_mib_ns_ip_addr_table { + uint8_t condition_idx; + uint8_t ns_enable; + uint8_t reserved[2]; + uint8_t ipv6_address[HIF_API_IPV6_ADDRESS_SIZE]; +} __packed; + +struct hif_mib_rx_filter { + uint8_t reserved1:1; + uint8_t bssid_filter:1; + uint8_t reserved2:1; + uint8_t fwd_probe_req:1; + uint8_t keep_alive_filter:1; + uint8_t reserved3:3; + uint8_t reserved4[3]; +} __packed; + +#define HIF_API_OUI_SIZE 3 +#define HIF_API_MATCH_DATA_SIZE 3 + +struct hif_ie_table_entry { + uint8_t ie_id; + uint8_t has_changed:1; + uint8_t no_longer:1; + uint8_t has_appeared:1; + uint8_t reserved:1; + uint8_t num_match_data:4; + uint8_t oui[HIF_API_OUI_SIZE]; + uint8_t match_data[HIF_API_MATCH_DATA_SIZE]; +} __packed; + +struct hif_mib_bcn_filter_table { + uint32_t num_of_info_elmts; + struct hif_ie_table_entry ie_table[]; +} __packed; + +enum hif_beacon_filter { + HIF_BEACON_FILTER_DISABLE = 0x0, + HIF_BEACON_FILTER_ENABLE = 0x1, + HIF_BEACON_FILTER_AUTO_ERP = 0x2 +}; + +struct hif_mib_bcn_filter_enable { + uint32_t enable; + uint32_t bcn_count; +} __packed; + +struct hif_mib_group_seq_counter { + uint32_t bits4716; + uint16_t bits1500; + uint16_t reserved; +} __packed; + +struct hif_mib_tsf_counter { + uint32_t tsf_counterlo; + uint32_t tsf_counterhi; +} __packed; + +struct hif_mib_stats_table { + int16_t latest_snr; + uint8_t latest_rcpi; + int8_t latest_rssi; +} __packed; + +struct hif_mib_extended_count_table { + uint32_t count_plcp_errors; + uint32_t count_fcs_errors; + uint32_t count_tx_packets; + uint32_t count_rx_packets; + uint32_t count_rx_packet_errors; + uint32_t count_rx_decryption_failures; + uint32_t count_rx_mic_failures; + uint32_t count_rx_no_key_failures; + uint32_t count_tx_multicast_frames; + uint32_t count_tx_frames_success; + uint32_t count_tx_frame_failures; + uint32_t count_tx_frames_retried; + uint32_t count_tx_frames_multi_retried; + uint32_t count_rx_frame_duplicates; + uint32_t count_rts_success; + uint32_t count_rts_failures; + uint32_t count_ack_failures; + uint32_t count_rx_multicast_frames; + uint32_t count_rx_frames_success; + uint32_t count_rx_cmacicv_errors; + uint32_t count_rx_cmac_replays; + uint32_t count_rx_mgmt_ccmp_replays; + uint32_t count_rx_bipmic_errors; + uint32_t count_rx_beacon; + uint32_t count_miss_beacon; + uint32_t reserved[15]; +} __packed; + +struct hif_mib_count_table { + uint32_t count_plcp_errors; + uint32_t count_fcs_errors; + uint32_t count_tx_packets; + uint32_t count_rx_packets; + uint32_t count_rx_packet_errors; + uint32_t count_rx_decryption_failures; + uint32_t count_rx_mic_failures; + uint32_t count_rx_no_key_failures; + uint32_t count_tx_multicast_frames; + uint32_t count_tx_frames_success; + uint32_t count_tx_frame_failures; + uint32_t count_tx_frames_retried; + uint32_t count_tx_frames_multi_retried; + uint32_t count_rx_frame_duplicates; + uint32_t count_rts_success; + uint32_t count_rts_failures; + uint32_t count_ack_failures; + uint32_t count_rx_multicast_frames; + uint32_t count_rx_frames_success; + uint32_t count_rx_cmacicv_errors; + uint32_t count_rx_cmac_replays; + uint32_t count_rx_mgmt_ccmp_replays; + uint32_t count_rx_bipmic_errors; +} __packed; + +struct hif_mib_max_tx_power_level { + int32_t max_tx_power_level_rf_port1; + int32_t max_tx_power_level_rf_port2; +} __packed; + +struct hif_mib_beacon_stats { + int32_t latest_tbtt_diff; + uint32_t reserved[4]; +} __packed; + +struct hif_mib_mac_address { + uint8_t mac_addr[ETH_ALEN]; + uint16_t reserved; +} __packed; + +struct hif_mib_dot11_max_transmit_msdu_lifetime { + uint32_t max_life_time; +} __packed; + +struct hif_mib_dot11_max_receive_lifetime { + uint32_t max_life_time; +} __packed; + +struct hif_mib_wep_default_key_id { + uint8_t wep_default_key_id; + uint8_t reserved[3]; +} __packed; + +struct hif_mib_dot11_rts_threshold { + uint32_t threshold; +} __packed; + +struct hif_mib_slot_time { + uint32_t slot_time; +} __packed; + +struct hif_mib_current_tx_power_level { + int32_t power_level; +} __packed; + +struct hif_mib_non_erp_protection { + uint8_t use_cts_to_self:1; + uint8_t reserved1:7; + uint8_t reserved2[3]; +} __packed; + +enum hif_tx_mode { + HIF_TX_MODE_MIXED = 0x0, + HIF_TX_MODE_GREENFIELD = 0x1 +}; + +enum hif_tmplt { + HIF_TMPLT_PRBREQ = 0x0, + HIF_TMPLT_BCN = 0x1, + HIF_TMPLT_NULL = 0x2, + HIF_TMPLT_QOSNUL = 0x3, + HIF_TMPLT_PSPOLL = 0x4, + HIF_TMPLT_PRBRES = 0x5, + HIF_TMPLT_ARP = 0x6, + HIF_TMPLT_NA = 0x7 +}; + +#define HIF_API_MAX_TEMPLATE_FRAME_SIZE 700 + +struct hif_mib_template_frame { + uint8_t frame_type; + uint8_t init_rate:7; + uint8_t mode:1; + uint16_t frame_length; + uint8_t frame[HIF_API_MAX_TEMPLATE_FRAME_SIZE]; +} __packed; + +struct hif_mib_beacon_wake_up_period { + uint8_t wakeup_period_min; + uint8_t receive_dtim:1; + uint8_t reserved1:7; + uint8_t wakeup_period_max; + uint8_t reserved2; +} __packed; + +struct hif_mib_rcpi_rssi_threshold { + uint8_t detection:1; + uint8_t rcpi_rssi:1; + uint8_t upperthresh:1; + uint8_t lowerthresh:1; + uint8_t reserved:4; + uint8_t lower_threshold; + uint8_t upper_threshold; + uint8_t rolling_average_count; +} __packed; + +#define DEFAULT_BA_MAX_RX_BUFFER_SIZE 16 + +struct hif_mib_block_ack_policy { + uint8_t block_ack_tx_tid_policy; + uint8_t reserved1; + uint8_t block_ack_rx_tid_policy; + uint8_t block_ack_rx_max_buffer_size; +} __packed; + +struct hif_mib_override_int_rate { + uint8_t internal_tx_rate; + uint8_t non_erp_internal_tx_rate; + uint8_t reserved[2]; +} __packed; + +enum hif_mpdu_start_spacing { + HIF_MPDU_START_SPACING_NO_RESTRIC = 0x0, + HIF_MPDU_START_SPACING_QUARTER = 0x1, + HIF_MPDU_START_SPACING_HALF = 0x2, + HIF_MPDU_START_SPACING_ONE = 0x3, + HIF_MPDU_START_SPACING_TWO = 0x4, + HIF_MPDU_START_SPACING_FOUR = 0x5, + HIF_MPDU_START_SPACING_EIGHT = 0x6, + HIF_MPDU_START_SPACING_SIXTEEN = 0x7 +}; + +struct hif_mib_set_association_mode { + uint8_t preambtype_use:1; + uint8_t mode:1; + uint8_t rateset:1; + uint8_t spacing:1; + uint8_t reserved:4; + uint8_t preamble_type; + uint8_t mixed_or_greenfield_type; + uint8_t mpdu_start_spacing; + uint32_t basic_rate_set; +} __packed; + +struct hif_mib_set_uapsd_information { + uint8_t trig_bckgrnd:1; + uint8_t trig_be:1; + uint8_t trig_video:1; + uint8_t trig_voice:1; + uint8_t reserved1:4; + uint8_t deliv_bckgrnd:1; + uint8_t deliv_be:1; + uint8_t deliv_video:1; + uint8_t deliv_voice:1; + uint8_t reserved2:4; + uint16_t min_auto_trigger_interval; + uint16_t max_auto_trigger_interval; + uint16_t auto_trigger_step; +} __packed; + +struct hif_mib_tx_rate_retry_policy { + uint8_t policy_index; + uint8_t short_retry_count; + uint8_t long_retry_count; + uint8_t first_rate_sel:2; + uint8_t terminate:1; + uint8_t count_init:1; + uint8_t reserved1:4; + uint8_t rate_recovery_count; + uint8_t reserved2[3]; + uint8_t rates[12]; +} __packed; + +#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES 16 + +struct hif_mib_set_tx_rate_retry_policy { + uint8_t num_tx_rate_policies; + uint8_t reserved[3]; + struct hif_mib_tx_rate_retry_policy tx_rate_retry_policy[]; +} __packed; + +struct hif_mib_protected_mgmt_policy { + uint8_t pmf_enable:1; + uint8_t unpmf_allowed:1; + uint8_t host_enc_auth_frames:1; + uint8_t reserved1:5; + uint8_t reserved2[3]; +} __packed; + +struct hif_mib_set_ht_protection { + uint8_t dual_cts_prot:1; + uint8_t reserved1:7; + uint8_t reserved2[3]; +} __packed; + +struct hif_mib_keep_alive_period { + uint16_t keep_alive_period; + uint8_t reserved[2]; +} __packed; + +struct hif_mib_arp_keep_alive_period { + uint16_t arp_keep_alive_period; + uint8_t encr_type; + uint8_t reserved; + uint8_t sender_ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; + uint8_t target_ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; +} __packed; + +struct hif_mib_inactivity_timer { + uint8_t min_active_time; + uint8_t max_active_time; + uint16_t reserved; +} __packed; + +struct hif_mib_interface_protection { + uint8_t use_cts_prot:1; + uint8_t reserved1:7; + uint8_t reserved2[3]; +} __packed; + + +#endif -- cgit v1.2.3-59-g8ed1b From b0998f0c040daf798d2f847d9588d57f2e2ade69 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:40 +0000 Subject: staging: wfx: add IRQ handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bh_work() is in charge to schedule all HIF message from/to chip. On normal operation, when an IRQ is received, driver can get size of next message in control register. In order to save control register access, when chip send a message, it also appends a copy of control register after the message (this register is not accounted in message length declared in message header, but must accounted in bus request). This copy of control register is called "piggyback". It also handles a power saving mechanism specific to WFxxx series. This mechanism is based on a GPIO called "wakeup" GPIO. Obviously, this gpio is not part of SPI/SDIO standard buses and must be declared independently (this is the main reason for why SDIO mode try to get parameters from DT). When wakeup is enabled, host can communicate with chip only if it is awake. To wake up chip, there are two cases: - host receive an IRQ from chip (chip initiate communication): host just have to set wakeup GPIO before reading data - host want to send data to chip: host set wakeup GPIO, then wait for an IRQ (in fact, wait for an empty message) and finally send data bh_work() is also in charge to track usage of chip buffers. Normally each request expect a confirmation. However, you can notice that special "multi tx" confirmation can acknowledge multiple requests at time. Finally, note that wfx_bh_request_rx() is not atomic (because of control_reg_read()). So, in SPI mode, hard-irq handler only postpone all processing to wfx_spi_request_rx(). Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-8-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/bh.c | 277 +++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/bh.h | 32 +++++ drivers/staging/wfx/bus_sdio.c | 4 +- drivers/staging/wfx/bus_spi.c | 5 + drivers/staging/wfx/main.c | 21 ++++ drivers/staging/wfx/main.h | 2 + drivers/staging/wfx/wfx.h | 4 + 8 files changed, 345 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/wfx/bh.c create mode 100644 drivers/staging/wfx/bh.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index e568d7a6fb06..1abd3115f11d 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -4,6 +4,7 @@ CFLAGS_debug.o = -I$(src) wfx-y := \ + bh.o \ hwio.o \ fwio.o \ main.o \ diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c new file mode 100644 index 000000000000..02a42e5c1e10 --- /dev/null +++ b/drivers/staging/wfx/bh.c @@ -0,0 +1,277 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Interrupt bottom half (BH). + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "bh.h" +#include "wfx.h" +#include "hwio.h" +#include "hif_api_cmd.h" + +static void device_wakeup(struct wfx_dev *wdev) +{ + if (!wdev->pdata.gpio_wakeup) + return; + if (gpiod_get_value(wdev->pdata.gpio_wakeup)) + return; + + gpiod_set_value(wdev->pdata.gpio_wakeup, 1); + if (wfx_api_older_than(wdev, 1, 4)) { + if (!completion_done(&wdev->hif.ctrl_ready)) + udelay(2000); + } else { + // completion.h does not provide any function to wait + // completion without consume it (a kind of + // wait_for_completion_done_timeout()). So we have to emulate + // it. + if (wait_for_completion_timeout(&wdev->hif.ctrl_ready, msecs_to_jiffies(2) + 1)) + complete(&wdev->hif.ctrl_ready); + else + dev_err(wdev->dev, "timeout while wake up chip\n"); + } +} + +static void device_release(struct wfx_dev *wdev) +{ + if (!wdev->pdata.gpio_wakeup) + return; + + gpiod_set_value(wdev->pdata.gpio_wakeup, 0); +} + +static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) +{ + struct sk_buff *skb; + struct hif_msg *hif; + size_t alloc_len; + size_t computed_len; + int release_count; + int piggyback = 0; + + WARN_ON(read_len < 4); + WARN(read_len > round_down(0xFFF, 2) * sizeof(u16), + "%s: request exceed WFx capability", __func__); + + // Add 2 to take into account piggyback size + alloc_len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, read_len + 2); + skb = dev_alloc_skb(alloc_len); + if (!skb) + return -ENOMEM; + + if (wfx_data_read(wdev, skb->data, alloc_len)) + goto err; + + piggyback = le16_to_cpup((u16 *) (skb->data + alloc_len - 2)); + + hif = (struct hif_msg *) skb->data; + WARN(hif->encrypted & 0x1, "unsupported encryption type"); + if (hif->encrypted == 0x2) { + BUG(); // Not yet implemented + } else { + le16_to_cpus(hif->len); + computed_len = round_up(hif->len, 2); + } + if (computed_len != read_len) { + dev_err(wdev->dev, "inconsistent message length: %zu != %zu\n", + computed_len, read_len); + print_hex_dump(KERN_INFO, "hif: ", DUMP_PREFIX_OFFSET, 16, 1, + hif, read_len, true); + goto err; + } + + if (!(hif->id & HIF_ID_IS_INDICATION)) { + (*is_cnf)++; + if (hif->id == HIF_CNF_ID_MULTI_TRANSMIT) + release_count = le32_to_cpu(((struct hif_cnf_multi_transmit *) hif->body)->num_tx_confs); + else + release_count = 1; + WARN(wdev->hif.tx_buffers_used < release_count, "corrupted buffer counter"); + wdev->hif.tx_buffers_used -= release_count; + if (!wdev->hif.tx_buffers_used) + wake_up(&wdev->hif.tx_buffers_empty); + } + + if (hif->id != HIF_IND_ID_EXCEPTION && hif->id != HIF_IND_ID_ERROR) { + if (hif->seqnum != wdev->hif.rx_seqnum) + dev_warn(wdev->dev, "wrong message sequence: %d != %d\n", + hif->seqnum, wdev->hif.rx_seqnum); + wdev->hif.rx_seqnum = (hif->seqnum + 1) % (HIF_COUNTER_MAX + 1); + } + + skb_put(skb, hif->len); + dev_kfree_skb(skb); /* FIXME: handle received data */ + + return piggyback; + +err: + if (skb) + dev_kfree_skb(skb); + return -EIO; +} + +static int bh_work_rx(struct wfx_dev *wdev, int max_msg, int *num_cnf) +{ + size_t len; + int i; + int ctrl_reg, piggyback; + + piggyback = 0; + for (i = 0; i < max_msg; i++) { + if (piggyback & CTRL_NEXT_LEN_MASK) + ctrl_reg = piggyback; + else if (try_wait_for_completion(&wdev->hif.ctrl_ready)) + ctrl_reg = atomic_xchg(&wdev->hif.ctrl_reg, 0); + else + ctrl_reg = 0; + if (!(ctrl_reg & CTRL_NEXT_LEN_MASK)) + return i; + // ctrl_reg units are 16bits words + len = (ctrl_reg & CTRL_NEXT_LEN_MASK) * 2; + piggyback = rx_helper(wdev, len, num_cnf); + if (piggyback < 0) + return i; + if (!(piggyback & CTRL_WLAN_READY)) + dev_err(wdev->dev, "unexpected piggyback value: ready bit not set: %04x\n", + piggyback); + } + if (piggyback & CTRL_NEXT_LEN_MASK) { + ctrl_reg = atomic_xchg(&wdev->hif.ctrl_reg, piggyback); + complete(&wdev->hif.ctrl_ready); + if (ctrl_reg) + dev_err(wdev->dev, "unexpected IRQ happened: %04x/%04x\n", + ctrl_reg, piggyback); + } + return i; +} + +static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) +{ + int ret; + void *data; + bool is_encrypted = false; + size_t len = le16_to_cpu(hif->len); + + BUG_ON(len < sizeof(*hif)); + + hif->seqnum = wdev->hif.tx_seqnum; + wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1); + + data = hif; + WARN(len > wdev->hw_caps.size_inp_ch_buf, + "%s: request exceed WFx capability: %zu > %d\n", __func__, + len, wdev->hw_caps.size_inp_ch_buf); + len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, len); + ret = wfx_data_write(wdev, data, len); + if (ret) + goto end; + + wdev->hif.tx_buffers_used++; +end: + if (is_encrypted) + kfree(data); +} + +static int bh_work_tx(struct wfx_dev *wdev, int max_msg) +{ + struct hif_msg *hif; + int i; + + for (i = 0; i < max_msg; i++) { + hif = NULL; + if (wdev->hif.tx_buffers_used < wdev->hw_caps.num_inp_ch_bufs) { + /* FIXME: get queued data */ + } + if (!hif) + return i; + tx_helper(wdev, hif); + } + return i; +} + +/* In SDIO mode, it is necessary to make an access to a register to acknowledge + * last received message. It could be possible to restrict this acknowledge to + * SDIO mode and only if last operation was rx. + */ +static void ack_sdio_data(struct wfx_dev *wdev) +{ + uint32_t cfg_reg; + + config_reg_read(wdev, &cfg_reg); + if (cfg_reg & 0xFF) { + dev_warn(wdev->dev, "chip reports errors: %02x\n", cfg_reg & 0xFF); + config_reg_write_bits(wdev, 0xFF, 0x00); + } +} + +static void bh_work(struct work_struct *work) +{ + struct wfx_dev *wdev = container_of(work, struct wfx_dev, hif.bh); + int stats_req = 0, stats_cnf = 0, stats_ind = 0; + bool release_chip = false, last_op_is_rx = false; + int num_tx, num_rx; + + device_wakeup(wdev); + do { + num_tx = bh_work_tx(wdev, 32); + stats_req += num_tx; + if (num_tx) + last_op_is_rx = false; + num_rx = bh_work_rx(wdev, 32, &stats_cnf); + stats_ind += num_rx; + if (num_rx) + last_op_is_rx = true; + } while (num_rx || num_tx); + stats_ind -= stats_cnf; + + if (last_op_is_rx) + ack_sdio_data(wdev); + if (!wdev->hif.tx_buffers_used && !work_pending(work)) { + device_release(wdev); + release_chip = true; + } +} + +/* + * An IRQ from chip did occur + */ +void wfx_bh_request_rx(struct wfx_dev *wdev) +{ + u32 cur, prev; + + control_reg_read(wdev, &cur); + prev = atomic_xchg(&wdev->hif.ctrl_reg, cur); + complete(&wdev->hif.ctrl_ready); + queue_work(system_highpri_wq, &wdev->hif.bh); + + if (!(cur & CTRL_NEXT_LEN_MASK)) + dev_err(wdev->dev, "unexpected control register value: length field is 0: %04x\n", + cur); + if (prev != 0) + dev_err(wdev->dev, "received IRQ but previous data was not (yet) read: %04x/%04x\n", + prev, cur); +} + +/* + * Driver want to send data + */ +void wfx_bh_request_tx(struct wfx_dev *wdev) +{ + queue_work(system_highpri_wq, &wdev->hif.bh); +} + +void wfx_bh_register(struct wfx_dev *wdev) +{ + INIT_WORK(&wdev->hif.bh, bh_work); + init_completion(&wdev->hif.ctrl_ready); + init_waitqueue_head(&wdev->hif.tx_buffers_empty); +} + +void wfx_bh_unregister(struct wfx_dev *wdev) +{ + flush_work(&wdev->hif.bh); +} diff --git a/drivers/staging/wfx/bh.h b/drivers/staging/wfx/bh.h new file mode 100644 index 000000000000..93ca98424e0b --- /dev/null +++ b/drivers/staging/wfx/bh.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Interrupt bottom half. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_BH_H +#define WFX_BH_H + +#include +#include +#include + +struct wfx_dev; + +struct wfx_hif { + struct work_struct bh; + struct completion ctrl_ready; + wait_queue_head_t tx_buffers_empty; + atomic_t ctrl_reg; + int rx_seqnum; + int tx_seqnum; + int tx_buffers_used; +}; + +void wfx_bh_register(struct wfx_dev *wdev); +void wfx_bh_unregister(struct wfx_dev *wdev); +void wfx_bh_request_rx(struct wfx_dev *wdev); +void wfx_bh_request_tx(struct wfx_dev *wdev); + +#endif /* WFX_BH_H */ diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 25c587fe2141..c0c063c3cfc9 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -15,6 +15,7 @@ #include "wfx.h" #include "hwio.h" #include "main.h" +#include "bh.h" static const struct wfx_platform_data wfx_sdio_pdata = { .file_fw = "wfm_wf200", @@ -90,7 +91,7 @@ static void wfx_sdio_irq_handler(struct sdio_func *func) struct wfx_sdio_priv *bus = sdio_get_drvdata(func); if (bus->core) - /* empty */; + wfx_bh_request_rx(bus->core); else WARN(!bus->core, "race condition in driver init/deinit"); } @@ -104,6 +105,7 @@ static irqreturn_t wfx_sdio_irq_handler_ext(int irq, void *priv) return IRQ_NONE; } sdio_claim_host(bus->func); + wfx_bh_request_rx(bus->core); sdio_release_host(bus->func); return IRQ_HANDLED; } diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index b73b9416273f..b7cd82b4e5e7 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -18,6 +18,7 @@ #include "wfx.h" #include "hwio.h" #include "main.h" +#include "bh.h" static int gpio_reset = -2; module_param(gpio_reset, int, 0644); @@ -144,6 +145,10 @@ static irqreturn_t wfx_spi_irq_handler(int irq, void *priv) static void wfx_spi_request_rx(struct work_struct *work) { + struct wfx_spi_priv *bus = + container_of(work, struct wfx_spi_priv, request_rx); + + wfx_bh_request_rx(bus->core); } static size_t wfx_spi_align_size(void *priv, size_t size) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index a8ef29174232..f0bea053a0d9 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -23,6 +23,7 @@ #include "fwio.h" #include "hwio.h" #include "bus.h" +#include "bh.h" #include "wfx_version.h" MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); @@ -30,6 +31,21 @@ MODULE_AUTHOR("Jérôme Pouiller "); MODULE_LICENSE("GPL"); MODULE_VERSION(WFX_LABEL); +static int gpio_wakeup = -2; +module_param(gpio_wakeup, int, 0644); +MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); + +bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) +{ + if (wdev->hw_caps.api_version_major < major) + return true; + if (wdev->hw_caps.api_version_major > major) + return false; + if (wdev->hw_caps.api_version_minor < minor) + return true; + return false; +} + struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label) { struct gpio_desc *ret; @@ -82,18 +98,23 @@ int wfx_probe(struct wfx_dev *wdev) { int err; + wfx_bh_register(wdev); + err = wfx_init_device(wdev); if (err) goto err1; + return 0; err1: + wfx_bh_unregister(wdev); return err; } void wfx_release(struct wfx_dev *wdev) { + wfx_bh_unregister(wdev); } static int __init wfx_core_init(void) diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index 8b2526d81984..f7c65999a493 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -20,6 +20,7 @@ struct wfx_dev; struct wfx_platform_data { /* Keyset and ".sec" extention will appended to this string */ const char *file_fw; + struct gpio_desc *gpio_wakeup; /* * if true HIF D_out is sampled on the rising edge of the clock * (intended to be used in 50Mhz SDIO) @@ -38,5 +39,6 @@ void wfx_release(struct wfx_dev *wdev); struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label); +bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor); #endif diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 56aed33291ae..4f28938fa3a6 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -10,7 +10,9 @@ #ifndef WFX_H #define WFX_H +#include "bh.h" #include "main.h" +#include "hif_api_general.h" struct hwbus_ops; @@ -21,6 +23,8 @@ struct wfx_dev { void *hwbus_priv; u8 keyset; + struct hif_ind_startup hw_caps; + struct wfx_hif hif; }; #endif /* WFX_H */ -- cgit v1.2.3-59-g8ed1b From 1cc298c9152352b36a7b0019b40e1863689727b2 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:40 +0000 Subject: staging: wfx: add tracepoints for HIF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These tracepoints decode HIF headers and provide more human readable results. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-9-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 5 + drivers/staging/wfx/traces.h | 211 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 02a42e5c1e10..76afecdf579d 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -11,6 +11,7 @@ #include "bh.h" #include "wfx.h" #include "hwio.h" +#include "traces.h" #include "hif_api_cmd.h" static void device_wakeup(struct wfx_dev *wdev) @@ -67,6 +68,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) goto err; piggyback = le16_to_cpup((u16 *) (skb->data + alloc_len - 2)); + _trace_piggyback(piggyback, false); hif = (struct hif_msg *) skb->data; WARN(hif->encrypted & 0x1, "unsupported encryption type"); @@ -95,6 +97,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) if (!wdev->hif.tx_buffers_used) wake_up(&wdev->hif.tx_buffers_empty); } + _trace_hif_recv(hif, wdev->hif.tx_buffers_used); if (hif->id != HIF_IND_ID_EXCEPTION && hif->id != HIF_IND_ID_ERROR) { if (hif->seqnum != wdev->hif.rx_seqnum) @@ -171,6 +174,7 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) goto end; wdev->hif.tx_buffers_used++; + _trace_hif_send(hif, wdev->hif.tx_buffers_used); end: if (is_encrypted) kfree(data); @@ -234,6 +238,7 @@ static void bh_work(struct work_struct *work) device_release(wdev); release_chip = true; } + _trace_bh_stats(stats_ind, stats_req, stats_cnf, wdev->hif.tx_buffers_used, release_chip); } /* diff --git a/drivers/staging/wfx/traces.h b/drivers/staging/wfx/traces.h index 34642f3451b5..e7b03b940535 100644 --- a/drivers/staging/wfx/traces.h +++ b/drivers/staging/wfx/traces.h @@ -14,6 +14,8 @@ #include #include "bus.h" +#include "hif_api_cmd.h" +#include "hif_api_mib.h" /* The hell below need some explanations. For each symbolic number, we need to * define it with TRACE_DEFINE_ENUM() and in a list for __print_symbolic. @@ -45,6 +47,167 @@ * #define list_for_print_symbolic list_names { -1, NULL } */ +#define _hif_msg_list \ + hif_cnf_name(ADD_KEY) \ + hif_cnf_name(BEACON_TRANSMIT) \ + hif_cnf_name(EDCA_QUEUE_PARAMS) \ + hif_cnf_name(JOIN) \ + hif_cnf_name(MAP_LINK) \ + hif_cnf_name(READ_MIB) \ + hif_cnf_name(REMOVE_KEY) \ + hif_cnf_name(RESET) \ + hif_cnf_name(SET_BSS_PARAMS) \ + hif_cnf_name(SET_PM_MODE) \ + hif_cnf_name(START) \ + hif_cnf_name(START_SCAN) \ + hif_cnf_name(STOP_SCAN) \ + hif_cnf_name(TX) \ + hif_cnf_name(MULTI_TRANSMIT) \ + hif_cnf_name(UPDATE_IE) \ + hif_cnf_name(WRITE_MIB) \ + hif_cnf_name(CONFIGURATION) \ + hif_cnf_name(CONTROL_GPIO) \ + hif_cnf_name(PREVENT_ROLLBACK) \ + hif_cnf_name(SET_SL_MAC_KEY) \ + hif_cnf_name(SL_CONFIGURE) \ + hif_cnf_name(SL_EXCHANGE_PUB_KEYS) \ + hif_cnf_name(SHUT_DOWN) \ + hif_ind_name(EVENT) \ + hif_ind_name(JOIN_COMPLETE) \ + hif_ind_name(RX) \ + hif_ind_name(SCAN_CMPL) \ + hif_ind_name(SET_PM_MODE_CMPL) \ + hif_ind_name(SUSPEND_RESUME_TX) \ + hif_ind_name(SL_EXCHANGE_PUB_KEYS) \ + hif_ind_name(ERROR) \ + hif_ind_name(EXCEPTION) \ + hif_ind_name(GENERIC) \ + hif_ind_name(WAKEUP) \ + hif_ind_name(STARTUP) + +#define hif_msg_list_enum _hif_msg_list + +#undef hif_cnf_name +#undef hif_ind_name +#define hif_cnf_name(msg) TRACE_DEFINE_ENUM(HIF_CNF_ID_##msg); +#define hif_ind_name(msg) TRACE_DEFINE_ENUM(HIF_IND_ID_##msg); +hif_msg_list_enum +#undef hif_cnf_name +#undef hif_ind_name +#define hif_cnf_name(msg) { HIF_CNF_ID_##msg, #msg }, +#define hif_ind_name(msg) { HIF_IND_ID_##msg, #msg }, +#define hif_msg_list hif_msg_list_enum { -1, NULL } + +#define _hif_mib_list \ + hif_mib_name(ARP_IP_ADDRESSES_TABLE) \ + hif_mib_name(ARP_KEEP_ALIVE_PERIOD) \ + hif_mib_name(BEACON_FILTER_ENABLE) \ + hif_mib_name(BEACON_FILTER_TABLE) \ + hif_mib_name(BEACON_WAKEUP_PERIOD) \ + hif_mib_name(BLOCK_ACK_POLICY) \ + hif_mib_name(CONFIG_DATA_FILTER) \ + hif_mib_name(COUNTERS_TABLE) \ + hif_mib_name(CURRENT_TX_POWER_LEVEL) \ + hif_mib_name(DOT11_MAC_ADDRESS) \ + hif_mib_name(DOT11_MAX_RECEIVE_LIFETIME) \ + hif_mib_name(DOT11_MAX_TRANSMIT_MSDU_LIFETIME) \ + hif_mib_name(DOT11_RTS_THRESHOLD) \ + hif_mib_name(DOT11_WEP_DEFAULT_KEY_ID) \ + hif_mib_name(GL_BLOCK_ACK_INFO) \ + hif_mib_name(GL_OPERATIONAL_POWER_MODE) \ + hif_mib_name(GL_SET_MULTI_MSG) \ + hif_mib_name(INACTIVITY_TIMER) \ + hif_mib_name(INTERFACE_PROTECTION) \ + hif_mib_name(IPV4_ADDR_DATAFRAME_CONDITION) \ + hif_mib_name(IPV6_ADDR_DATAFRAME_CONDITION) \ + hif_mib_name(KEEP_ALIVE_PERIOD) \ + hif_mib_name(MAC_ADDR_DATAFRAME_CONDITION) \ + hif_mib_name(NON_ERP_PROTECTION) \ + hif_mib_name(NS_IP_ADDRESSES_TABLE) \ + hif_mib_name(OVERRIDE_INTERNAL_TX_RATE) \ + hif_mib_name(PROTECTED_MGMT_POLICY) \ + hif_mib_name(RX_FILTER) \ + hif_mib_name(RCPI_RSSI_THRESHOLD) \ + hif_mib_name(SET_ASSOCIATION_MODE) \ + hif_mib_name(SET_DATA_FILTERING) \ + hif_mib_name(ETHERTYPE_DATAFRAME_CONDITION) \ + hif_mib_name(SET_HT_PROTECTION) \ + hif_mib_name(MAGIC_DATAFRAME_CONDITION) \ + hif_mib_name(SET_TX_RATE_RETRY_POLICY) \ + hif_mib_name(SET_UAPSD_INFORMATION) \ + hif_mib_name(PORT_DATAFRAME_CONDITION) \ + hif_mib_name(SLOT_TIME) \ + hif_mib_name(STATISTICS_TABLE) \ + hif_mib_name(TEMPLATE_FRAME) \ + hif_mib_name(TSF_COUNTER) \ + hif_mib_name(UC_MC_BC_DATAFRAME_CONDITION) + +#define hif_mib_list_enum _hif_mib_list + +#undef hif_mib_name +#define hif_mib_name(mib) TRACE_DEFINE_ENUM(HIF_MIB_ID_##mib); +hif_mib_list_enum +#undef hif_mib_name +#define hif_mib_name(mib) { HIF_MIB_ID_##mib, #mib }, +#define hif_mib_list hif_mib_list_enum { -1, NULL } + +DECLARE_EVENT_CLASS(hif_data, + TP_PROTO(struct hif_msg *hif, int tx_fill_level, bool is_recv), + TP_ARGS(hif, tx_fill_level, is_recv), + TP_STRUCT__entry( + __field(int, tx_fill_level) + __field(int, msg_id) + __field(const char *, msg_type) + __field(int, msg_len) + __field(int, buf_len) + __field(int, if_id) + __field(int, mib) + __array(u8, buf, 128) + ), + TP_fast_assign( + int header_len; + + __entry->tx_fill_level = tx_fill_level; + __entry->msg_len = hif->len; + __entry->msg_id = hif->id; + __entry->if_id = hif->interface; + if (is_recv) + __entry->msg_type = __entry->msg_id & 0x80 ? "IND" : "CNF"; + else + __entry->msg_type = "REQ"; + if (!is_recv && + (__entry->msg_id == HIF_REQ_ID_READ_MIB || __entry->msg_id == HIF_REQ_ID_WRITE_MIB)) { + __entry->mib = le16_to_cpup((u16 *) hif->body); + header_len = 4; + } else { + __entry->mib = -1; + header_len = 0; + } + __entry->buf_len = min_t(int, __entry->msg_len, sizeof(__entry->buf)) + - sizeof(struct hif_msg) - header_len; + memcpy(__entry->buf, hif->body + header_len, __entry->buf_len); + ), + TP_printk("%d:%d:%s_%s%s%s: %s%s (%d bytes)", + __entry->tx_fill_level, + __entry->if_id, + __print_symbolic(__entry->msg_id, hif_msg_list), + __entry->msg_type, + __entry->mib != -1 ? "/" : "", + __entry->mib != -1 ? __print_symbolic(__entry->mib, hif_mib_list) : "", + __print_hex(__entry->buf, __entry->buf_len), + __entry->msg_len > sizeof(__entry->buf) ? " ..." : "", + __entry->msg_len + ) +); +DEFINE_EVENT(hif_data, hif_send, + TP_PROTO(struct hif_msg *hif, int tx_fill_level, bool is_recv), + TP_ARGS(hif, tx_fill_level, is_recv)); +#define _trace_hif_send(hif, tx_fill_level) trace_hif_send(hif, tx_fill_level, false) +DEFINE_EVENT(hif_data, hif_recv, + TP_PROTO(struct hif_msg *hif, int tx_fill_level, bool is_recv), + TP_ARGS(hif, tx_fill_level, is_recv)); +#define _trace_hif_recv(hif, tx_fill_level) trace_hif_recv(hif, tx_fill_level, true) + #define wfx_reg_list_enum \ wfx_reg_name(WFX_REG_CONFIG, "CONFIG") \ wfx_reg_name(WFX_REG_CONTROL, "CONTROL") \ @@ -138,6 +301,54 @@ DEFINE_EVENT(io_data32, io_read32, #define _trace_io_ind_read32(reg, addr, val) trace_io_read32(reg, addr, val) #define _trace_io_read32(reg, val) trace_io_read32(reg, -1, val) +DECLARE_EVENT_CLASS(piggyback, + TP_PROTO(u32 val, bool ignored), + TP_ARGS(val, ignored), + TP_STRUCT__entry( + __field(int, val) + __field(bool, ignored) + ), + TP_fast_assign( + __entry->val = val; + __entry->ignored = ignored; + ), + TP_printk("CONTROL: %08x%s", + __entry->val, + __entry->ignored ? " (ignored)" : "" + ) +); +DEFINE_EVENT(piggyback, piggyback, + TP_PROTO(u32 val, bool ignored), + TP_ARGS(val, ignored)); +#define _trace_piggyback(val, ignored) trace_piggyback(val, ignored) + +TRACE_EVENT(bh_stats, + TP_PROTO(int ind, int req, int cnf, int busy, bool release), + TP_ARGS(ind, req, cnf, busy, release), + TP_STRUCT__entry( + __field(int, ind) + __field(int, req) + __field(int, cnf) + __field(int, busy) + __field(bool, release) + ), + TP_fast_assign( + __entry->ind = ind; + __entry->req = req; + __entry->cnf = cnf; + __entry->busy = busy; + __entry->release = release; + ), + TP_printk("IND/REQ/CNF:%3d/%3d/%3d, REQ in progress:%3d, WUP: %s", + __entry->ind, + __entry->req, + __entry->cnf, + __entry->busy, + __entry->release ? "release" : "keep" + ) +); +#define _trace_bh_stats(ind, req, cnf, busy, release) trace_bh_stats(ind, req, cnf, busy, release) + #endif /* This part must be outside protection */ -- cgit v1.2.3-59-g8ed1b From 185c106f79bf2714e86316057948b8c2853b0666 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:41 +0000 Subject: staging: wfx: add support for start-up indication MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once firmware is loaded, it send a first indication to host. This indication signalize that host can start to communicate with firmware. In add, it contains information about chip and firmware (MAC addresses, firmware version, etc...). Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-10-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/bh.c | 4 +++- drivers/staging/wfx/hif_rx.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/hif_rx.h | 18 ++++++++++++++ drivers/staging/wfx/main.c | 45 ++++++++++++++++++++++++++++++++++ drivers/staging/wfx/wfx.h | 5 ++++ 6 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/wfx/hif_rx.c create mode 100644 drivers/staging/wfx/hif_rx.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 1abd3115f11d..35670b86c64f 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -7,6 +7,7 @@ wfx-y := \ bh.o \ hwio.o \ fwio.o \ + hif_rx.o \ main.o \ debug.o wfx-$(CONFIG_SPI) += bus_spi.o diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 76afecdf579d..c40da3f1f25d 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -12,6 +12,7 @@ #include "wfx.h" #include "hwio.h" #include "traces.h" +#include "hif_rx.h" #include "hif_api_cmd.h" static void device_wakeup(struct wfx_dev *wdev) @@ -107,7 +108,8 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) } skb_put(skb, hif->len); - dev_kfree_skb(skb); /* FIXME: handle received data */ + // wfx_handle_rx takes care on SKB livetime + wfx_handle_rx(wdev, skb); return piggyback; diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c new file mode 100644 index 000000000000..5c207e6d4348 --- /dev/null +++ b/drivers/staging/wfx/hif_rx.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Implementation of chip-to-host event (aka indications) of WFxxx Split Mac + * (WSM) API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "hif_rx.h" +#include "wfx.h" +#include "hif_api_cmd.h" + +static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_ind_startup *body = buf; + + if (body->status || body->firmware_type > 4) { + dev_err(wdev->dev, "received invalid startup indication"); + return -EINVAL; + } + memcpy(&wdev->hw_caps, body, sizeof(struct hif_ind_startup)); + le32_to_cpus(&wdev->hw_caps.status); + le16_to_cpus(&wdev->hw_caps.hardware_id); + le16_to_cpus(&wdev->hw_caps.num_inp_ch_bufs); + le16_to_cpus(&wdev->hw_caps.size_inp_ch_buf); + + complete(&wdev->firmware_ready); + return 0; +} + +static const struct { + int msg_id; + int (*handler)(struct wfx_dev *wdev, struct hif_msg *hif, void *buf); +} hif_handlers[] = { + { HIF_IND_ID_STARTUP, hif_startup_indication }, +}; + +void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) +{ + int i; + struct hif_msg *hif = (struct hif_msg *) skb->data; + int hif_id = hif->id; + + for (i = 0; i < ARRAY_SIZE(hif_handlers); i++) { + if (hif_handlers[i].msg_id == hif_id) { + if (hif_handlers[i].handler) + hif_handlers[i].handler(wdev, hif, hif->body); + goto free; + } + } + dev_err(wdev->dev, "unsupported HIF ID %02x\n", hif_id); +free: + dev_kfree_skb(skb); +} diff --git a/drivers/staging/wfx/hif_rx.h b/drivers/staging/wfx/hif_rx.h new file mode 100644 index 000000000000..f07c10c8c6bd --- /dev/null +++ b/drivers/staging/wfx/hif_rx.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Implementation of chip-to-host event (aka indications) of WFxxx Split Mac + * (WSM) API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (C) 2010, ST-Ericsson SA + */ +#ifndef WFX_HIF_RX_H +#define WFX_HIF_RX_H + +struct wfx_dev; +struct sk_buff; + +void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb); + +#endif diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index f0bea053a0d9..5e7e7225f068 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -12,6 +12,7 @@ */ #include #include +#include #include #include #include @@ -87,6 +88,9 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->hwbus_ops = hwbus_ops; wdev->hwbus_priv = hwbus_priv; memcpy(&wdev->pdata, pdata, sizeof(*pdata)); + + init_completion(&wdev->firmware_ready); + return wdev; } @@ -96,7 +100,9 @@ void wfx_free_common(struct wfx_dev *wdev) int wfx_probe(struct wfx_dev *wdev) { + int i; int err; + const void *macaddr; wfx_bh_register(wdev); @@ -104,6 +110,45 @@ int wfx_probe(struct wfx_dev *wdev) if (err) goto err1; + err = wait_for_completion_interruptible_timeout(&wdev->firmware_ready, 10 * HZ); + if (err <= 0) { + if (err == 0) { + dev_err(wdev->dev, "timeout while waiting for startup indication. IRQ configuration error?\n"); + err = -ETIMEDOUT; + } else if (err == -ERESTARTSYS) { + dev_info(wdev->dev, "probe interrupted by user\n"); + } + goto err1; + } + + // FIXME: fill wiphy::hw_version + dev_info(wdev->dev, "started firmware %d.%d.%d \"%s\" (API: %d.%d, keyset: %02X, caps: 0x%.8X)\n", + wdev->hw_caps.firmware_major, wdev->hw_caps.firmware_minor, + wdev->hw_caps.firmware_build, wdev->hw_caps.firmware_label, + wdev->hw_caps.api_version_major, wdev->hw_caps.api_version_minor, + wdev->keyset, *((u32 *) &wdev->hw_caps.capabilities)); + + if (wfx_api_older_than(wdev, 1, 0)) { + dev_err(wdev->dev, "unsupported firmware API version (expect 1 while firmware returns %d)\n", + wdev->hw_caps.api_version_major); + err = -ENOTSUPP; + goto err1; + } + + for (i = 0; i < ARRAY_SIZE(wdev->addresses); i++) { + eth_zero_addr(wdev->addresses[i].addr); + macaddr = of_get_mac_address(wdev->dev->of_node); + if (macaddr) { + ether_addr_copy(wdev->addresses[i].addr, macaddr); + wdev->addresses[i].addr[ETH_ALEN - 1] += i; + } + ether_addr_copy(wdev->addresses[i].addr, wdev->hw_caps.mac_addr[i]); + if (!is_valid_ether_addr(wdev->addresses[i].addr)) { + dev_warn(wdev->dev, "using random MAC address\n"); + eth_random_addr(wdev->addresses[i].addr); + } + dev_info(wdev->dev, "MAC address %d: %pM\n", i, wdev->addresses[i].addr); + } return 0; diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 4f28938fa3a6..f5f9a337d828 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -10,6 +10,9 @@ #ifndef WFX_H #define WFX_H +#include +#include + #include "bh.h" #include "main.h" #include "hif_api_general.h" @@ -19,10 +22,12 @@ struct hwbus_ops; struct wfx_dev { struct wfx_platform_data pdata; struct device *dev; + struct mac_address addresses[2]; const struct hwbus_ops *hwbus_ops; void *hwbus_priv; u8 keyset; + struct completion firmware_ready; struct hif_ind_startup hw_caps; struct wfx_hif hif; }; -- cgit v1.2.3-59-g8ed1b From e16e7f0716a6ba9a690fc5229a6e35e00e03b805 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:41 +0000 Subject: staging: wfx: instantiate mac80211 data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allocate a struct ieee80211_hw but do not yet register it. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-11-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/debug.c | 12 ++++++++++++ drivers/staging/wfx/debug.h | 15 +++++++++++++++ drivers/staging/wfx/main.c | 41 +++++++++++++++++++++++++++++++++++++-- drivers/staging/wfx/sta.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/sta.h | 24 +++++++++++++++++++++++ drivers/staging/wfx/wfx.h | 8 ++++++++ 7 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/wfx/debug.h create mode 100644 drivers/staging/wfx/sta.c create mode 100644 drivers/staging/wfx/sta.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 35670b86c64f..2896a2127c88 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -9,6 +9,7 @@ wfx-y := \ fwio.o \ hif_rx.o \ main.o \ + sta.o \ debug.o wfx-$(CONFIG_SPI) += bus_spi.o wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index bf44c944640d..f28c94d8de89 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -5,6 +5,18 @@ * Copyright (c) 2017-2019, Silicon Laboratories, Inc. * Copyright (c) 2010, ST-Ericsson */ +#include + +#include "wfx.h" #define CREATE_TRACE_POINTS #include "traces.h" + +int wfx_debug_init(struct wfx_dev *wdev) +{ + struct dentry *d; + + d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + + return 0; +} diff --git a/drivers/staging/wfx/debug.h b/drivers/staging/wfx/debug.h new file mode 100644 index 000000000000..8bfba1a9fa20 --- /dev/null +++ b/drivers/staging/wfx/debug.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Debugfs interface. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2011, ST-Ericsson + */ +#ifndef WFX_DEBUG_H +#define WFX_DEBUG_H + +struct wfx_dev; + +int wfx_debug_init(struct wfx_dev *wdev); + +#endif /* WFX_DEBUG_H */ diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 5e7e7225f068..ca0ca873bd7d 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -25,6 +25,9 @@ #include "hwio.h" #include "bus.h" #include "bh.h" +#include "sta.h" +#include "debug.h" +#include "hif_api_cmd.h" #include "wfx_version.h" MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); @@ -36,6 +39,13 @@ static int gpio_wakeup = -2; module_param(gpio_wakeup, int, 0644); MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); +static const struct ieee80211_ops wfx_ops = { + .start = wfx_start, + .stop = wfx_stop, + .add_interface = wfx_add_interface, + .remove_interface = wfx_remove_interface, +}; + bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) { if (wdev->hw_caps.api_version_major < major) @@ -79,11 +89,26 @@ struct wfx_dev *wfx_init_common(struct device *dev, const struct hwbus_ops *hwbus_ops, void *hwbus_priv) { + struct ieee80211_hw *hw; struct wfx_dev *wdev; - wdev = devm_kmalloc(dev, sizeof(*wdev), GFP_KERNEL); - if (!wdev) + hw = ieee80211_alloc_hw(sizeof(struct wfx_dev), &wfx_ops); + if (!hw) return NULL; + + SET_IEEE80211_DEV(hw, dev); + + hw->vif_data_size = sizeof(struct wfx_vif); + hw->sta_data_size = sizeof(struct wfx_sta_priv); + hw->queues = 4; + hw->max_rates = 8; + hw->max_rate_tries = 15; + hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_msg) + + sizeof(struct hif_req_tx) + + 4 /* alignment */ + 8 /* TKIP IV */; + + wdev = hw->priv; + wdev->hw = hw; wdev->dev = dev; wdev->hwbus_ops = hwbus_ops; wdev->hwbus_priv = hwbus_priv; @@ -96,6 +121,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, void wfx_free_common(struct wfx_dev *wdev) { + ieee80211_free_hw(wdev->hw); } int wfx_probe(struct wfx_dev *wdev) @@ -127,6 +153,11 @@ int wfx_probe(struct wfx_dev *wdev) wdev->hw_caps.firmware_build, wdev->hw_caps.firmware_label, wdev->hw_caps.api_version_major, wdev->hw_caps.api_version_minor, wdev->keyset, *((u32 *) &wdev->hw_caps.capabilities)); + snprintf(wdev->hw->wiphy->fw_version, sizeof(wdev->hw->wiphy->fw_version), + "%d.%d.%d", + wdev->hw_caps.firmware_major, + wdev->hw_caps.firmware_minor, + wdev->hw_caps.firmware_build); if (wfx_api_older_than(wdev, 1, 0)) { dev_err(wdev->dev, "unsupported firmware API version (expect 1 while firmware returns %d)\n", @@ -150,8 +181,14 @@ int wfx_probe(struct wfx_dev *wdev) dev_info(wdev->dev, "MAC address %d: %pM\n", i, wdev->addresses[i].addr); } + err = wfx_debug_init(wdev); + if (err) + goto err2; + return 0; +err2: + ieee80211_free_hw(wdev->hw); err1: wfx_bh_unregister(wdev); return err; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c new file mode 100644 index 000000000000..fe3ff6536a87 --- /dev/null +++ b/drivers/staging/wfx/sta.c @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Implementation of mac80211 API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include + +#include "sta.h" +#include "wfx.h" + +int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + int i; + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { + if (!wdev->vif[i]) { + wdev->vif[i] = vif; + wvif->id = i; + break; + } + } + if (i == ARRAY_SIZE(wdev->vif)) + return -EOPNOTSUPP; + wvif->vif = vif; + wvif->wdev = wdev; + + return 0; +} + +void wfx_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ +} + +int wfx_start(struct ieee80211_hw *hw) +{ + return 0; +} + +void wfx_stop(struct ieee80211_hw *hw) +{ +} diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h new file mode 100644 index 000000000000..f17b4d1511d7 --- /dev/null +++ b/drivers/staging/wfx/sta.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Implementation of mac80211 API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_STA_H +#define WFX_STA_H + +#include + +struct wfx_sta_priv { + int link_id; + int vif_id; +}; + +// mac80211 interface +int wfx_start(struct ieee80211_hw *hw); +void wfx_stop(struct ieee80211_hw *hw); +int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); + +#endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index f5f9a337d828..a7e571e0da30 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -22,6 +22,8 @@ struct hwbus_ops; struct wfx_dev { struct wfx_platform_data pdata; struct device *dev; + struct ieee80211_hw *hw; + struct ieee80211_vif *vif[2]; struct mac_address addresses[2]; const struct hwbus_ops *hwbus_ops; void *hwbus_priv; @@ -32,4 +34,10 @@ struct wfx_dev { struct wfx_hif hif; }; +struct wfx_vif { + struct wfx_dev *wdev; + struct ieee80211_vif *vif; + int id; +}; + #endif /* WFX_H */ -- cgit v1.2.3-59-g8ed1b From 4f8b7fabb15df3658564a98971fc67029be1815d Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:42 +0000 Subject: staging: wfx: allow to send commands to chip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chip has multiple input buffers and can handle multiple 802.11 frames in parallel. However, other HIF command must be sent sequentially. wsm_send_cmd() handles these requests. This commit also add send_hif_cmd in debugfs. This file allows to send arbitrary commands to chip. It can be used for debug and testing. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-12-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/bh.c | 5 +- drivers/staging/wfx/debug.c | 130 +++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/debug.h | 4 ++ drivers/staging/wfx/hif_rx.c | 45 +++++++++++++++ drivers/staging/wfx/hif_tx.c | 87 +++++++++++++++++++++++++++++ drivers/staging/wfx/hif_tx.h | 33 +++++++++++ drivers/staging/wfx/main.c | 1 + drivers/staging/wfx/wfx.h | 4 ++ 9 files changed, 309 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/wfx/hif_tx.c create mode 100644 drivers/staging/wfx/hif_tx.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 2896a2127c88..e158589468a3 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -7,6 +7,7 @@ wfx-y := \ bh.o \ hwio.o \ fwio.o \ + hif_tx.o \ hif_rx.o \ main.o \ sta.o \ diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index c40da3f1f25d..c94c9c401a69 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -190,7 +190,10 @@ static int bh_work_tx(struct wfx_dev *wdev, int max_msg) for (i = 0; i < max_msg; i++) { hif = NULL; if (wdev->hif.tx_buffers_used < wdev->hw_caps.num_inp_ch_bufs) { - /* FIXME: get queued data */ + if (try_wait_for_completion(&wdev->hif_cmd.ready)) { + WARN(!mutex_is_locked(&wdev->hif_cmd.lock), "data locking error"); + hif = wdev->hif_cmd.buf_send; + } } if (!hif) return i; diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index f28c94d8de89..0a328c96eaa0 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -7,16 +7,146 @@ */ #include +#include "debug.h" #include "wfx.h" #define CREATE_TRACE_POINTS #include "traces.h" +static const struct trace_print_flags hif_msg_print_map[] = { + hif_msg_list, +}; + +static const struct trace_print_flags hif_mib_print_map[] = { + hif_mib_list, +}; + +static const struct trace_print_flags wfx_reg_print_map[] = { + wfx_reg_list, +}; + +static const char *get_symbol(unsigned long val, + const struct trace_print_flags *symbol_array) +{ + int i; + + for (i = 0; symbol_array[i].mask != -1; i++) { + if (val == symbol_array[i].mask) + return symbol_array[i].name; + } + + return "unknown"; +} + +const char *get_hif_name(unsigned long id) +{ + return get_symbol(id, hif_msg_print_map); +} + +const char *get_mib_name(unsigned long id) +{ + return get_symbol(id, hif_mib_print_map); +} + +const char *get_reg_name(unsigned long id) +{ + return get_symbol(id, wfx_reg_print_map); +} + +struct dbgfs_hif_msg { + struct wfx_dev *wdev; + struct completion complete; + u8 reply[1024]; + int ret; +}; + +static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct dbgfs_hif_msg *context = file->private_data; + struct wfx_dev *wdev = context->wdev; + struct hif_msg *request; + + if (completion_done(&context->complete)) { + dev_dbg(wdev->dev, "read previous result before start a new one\n"); + return -EBUSY; + } + if (count < sizeof(struct hif_msg)) + return -EINVAL; + + // wfx_cmd_send() chekc that reply buffer is wide enough, but do not + // return precise length read. User have to know how many bytes should + // be read. Filling reply buffer with a memory pattern may help user. + memset(context->reply, sizeof(context->reply), 0xFF); + request = memdup_user(user_buf, count); + if (IS_ERR(request)) + return PTR_ERR(request); + if (request->len != count) { + kfree(request); + return -EINVAL; + } + context->ret = wfx_cmd_send(wdev, request, context->reply, sizeof(context->reply), false); + + kfree(request); + complete(&context->complete); + return count; +} + +static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct dbgfs_hif_msg *context = file->private_data; + int ret; + + if (count > sizeof(context->reply)) + return -EINVAL; + ret = wait_for_completion_interruptible(&context->complete); + if (ret) + return ret; + if (context->ret < 0) + return context->ret; + // Be carefull, write() is waiting for a full message while read() + // only return a payload + ret = copy_to_user(user_buf, context->reply, count); + if (ret) + return ret; + + return count; +} + +static int wfx_send_hif_msg_open(struct inode *inode, struct file *file) +{ + struct dbgfs_hif_msg *context = kzalloc(sizeof(*context), GFP_KERNEL); + + if (!context) + return -ENOMEM; + context->wdev = inode->i_private; + init_completion(&context->complete); + file->private_data = context; + return 0; +} + +static int wfx_send_hif_msg_release(struct inode *inode, struct file *file) +{ + struct dbgfs_hif_msg *context = file->private_data; + + kfree(context); + return 0; +} + +static const struct file_operations wfx_send_hif_msg_fops = { + .open = wfx_send_hif_msg_open, + .release = wfx_send_hif_msg_release, + .write = wfx_send_hif_msg_write, + .read = wfx_send_hif_msg_read, +}; + int wfx_debug_init(struct wfx_dev *wdev) { struct dentry *d; d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); return 0; } diff --git a/drivers/staging/wfx/debug.h b/drivers/staging/wfx/debug.h index 8bfba1a9fa20..6f2f84d64c9e 100644 --- a/drivers/staging/wfx/debug.h +++ b/drivers/staging/wfx/debug.h @@ -12,4 +12,8 @@ struct wfx_dev; int wfx_debug_init(struct wfx_dev *wdev); +const char *get_hif_name(unsigned long id); +const char *get_mib_name(unsigned long id); +const char *get_reg_name(unsigned long id); + #endif /* WFX_DEBUG_H */ diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 5c207e6d4348..ba8ea4f3c91b 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -13,6 +13,43 @@ #include "wfx.h" #include "hif_api_cmd.h" +static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + // All confirm messages start with status + int status = le32_to_cpu(*((__le32 *) buf)); + int cmd = hif->id; + int len = hif->len - 4; // drop header + + WARN(!mutex_is_locked(&wdev->hif_cmd.lock), "data locking error"); + + if (!wdev->hif_cmd.buf_send) { + dev_warn(wdev->dev, "unexpected confirmation: 0x%.2x\n", cmd); + return -EINVAL; + } + + if (cmd != wdev->hif_cmd.buf_send->id) { + dev_warn(wdev->dev, "chip response mismatch request: 0x%.2x vs 0x%.2x\n", + cmd, wdev->hif_cmd.buf_send->id); + return -EINVAL; + } + + if (wdev->hif_cmd.buf_recv) { + if (wdev->hif_cmd.len_recv >= len) + memcpy(wdev->hif_cmd.buf_recv, buf, len); + else + status = -ENOMEM; + } + wdev->hif_cmd.ret = status; + + if (!wdev->hif_cmd.async) { + complete(&wdev->hif_cmd.done); + } else { + wdev->hif_cmd.buf_send = NULL; + mutex_unlock(&wdev->hif_cmd.lock); + } + return status; +} + static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct hif_ind_startup *body = buf; @@ -44,6 +81,14 @@ void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) struct hif_msg *hif = (struct hif_msg *) skb->data; int hif_id = hif->id; + // Note: mutex_is_lock cause an implicit memory barrier that protect + // buf_send + if (mutex_is_locked(&wdev->hif_cmd.lock) + && wdev->hif_cmd.buf_send + && wdev->hif_cmd.buf_send->id == hif_id) { + hif_generic_confirm(wdev, hif, hif->body); + goto free; + } for (i = 0; i < ARRAY_SIZE(hif_handlers); i++) { if (hif_handlers[i].msg_id == hif_id) { if (hif_handlers[i].handler) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c new file mode 100644 index 000000000000..f81a19089db4 --- /dev/null +++ b/drivers/staging/wfx/hif_tx.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Implementation of host-to-chip commands (aka request/confirmation) of WFxxx + * Split Mac (WSM) API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "hif_tx.h" +#include "wfx.h" +#include "bh.h" +#include "debug.h" + +void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd) +{ + init_completion(&hif_cmd->ready); + init_completion(&hif_cmd->done); + mutex_init(&hif_cmd->lock); +} + +int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, size_t reply_len, bool async) +{ + const char *mib_name = ""; + const char *mib_sep = ""; + int cmd = request->id; + int vif = request->interface; + int ret; + + WARN(wdev->hif_cmd.buf_recv && wdev->hif_cmd.async, "API usage error"); + + // Do not wait for any reply if chip is frozen + if (wdev->chip_frozen) + return -ETIMEDOUT; + + mutex_lock(&wdev->hif_cmd.lock); + WARN(wdev->hif_cmd.buf_send, "data locking error"); + + // Note: call to complete() below has an implicit memory barrier that + // hopefully protect buf_send + wdev->hif_cmd.buf_send = request; + wdev->hif_cmd.buf_recv = reply; + wdev->hif_cmd.len_recv = reply_len; + wdev->hif_cmd.async = async; + complete(&wdev->hif_cmd.ready); + + wfx_bh_request_tx(wdev); + + // NOTE: no timeout is catched async is enabled + if (async) + return 0; + + ret = wait_for_completion_timeout(&wdev->hif_cmd.done, 1 * HZ); + if (!ret) { + dev_err(wdev->dev, "chip is abnormally long to answer\n"); + reinit_completion(&wdev->hif_cmd.ready); + ret = wait_for_completion_timeout(&wdev->hif_cmd.done, 3 * HZ); + } + if (!ret) { + dev_err(wdev->dev, "chip did not answer\n"); + wdev->chip_frozen = 1; + reinit_completion(&wdev->hif_cmd.done); + ret = -ETIMEDOUT; + } else { + ret = wdev->hif_cmd.ret; + } + + wdev->hif_cmd.buf_send = NULL; + mutex_unlock(&wdev->hif_cmd.lock); + + if (ret && (cmd == HIF_REQ_ID_READ_MIB || cmd == HIF_REQ_ID_WRITE_MIB)) { + mib_name = get_mib_name(((u16 *) request)[2]); + mib_sep = "/"; + } + if (ret < 0) + dev_err(wdev->dev, + "WSM request %s%s%s (%#.2x) on vif %d returned error %d\n", + get_hif_name(cmd), mib_sep, mib_name, cmd, vif, ret); + if (ret > 0) + dev_warn(wdev->dev, + "WSM request %s%s%s (%#.2x) on vif %d returned status %d\n", + get_hif_name(cmd), mib_sep, mib_name, cmd, vif, ret); + + return ret; +} diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h new file mode 100644 index 000000000000..ccf2b7e5e851 --- /dev/null +++ b/drivers/staging/wfx/hif_tx.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Implementation of host-to-chip commands (aka request/confirmation) of WFxxx + * Split Mac (WSM) API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (C) 2010, ST-Ericsson SA + */ +#ifndef WFX_HIF_TX_H +#define WFX_HIF_TX_H + +#include "hif_api_cmd.h" + +struct wfx_dev; +struct wfx_vif; + +struct wfx_hif_cmd { + struct mutex lock; + struct completion ready; + struct completion done; + bool async; + struct hif_msg *buf_send; + void *buf_recv; + size_t len_recv; + int ret; +}; + +void wfx_init_hif_cmd(struct wfx_hif_cmd *wfx_hif_cmd); +int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, + void *reply, size_t reply_len, bool async); + +#endif diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index ca0ca873bd7d..8973eeb60eb8 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -115,6 +115,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, memcpy(&wdev->pdata, pdata, sizeof(*pdata)); init_completion(&wdev->firmware_ready); + wfx_init_hif_cmd(&wdev->hif_cmd); return wdev; } diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index a7e571e0da30..bf9de11f8896 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -15,6 +15,7 @@ #include "bh.h" #include "main.h" +#include "hif_tx.h" #include "hif_api_general.h" struct hwbus_ops; @@ -32,6 +33,9 @@ struct wfx_dev { struct completion firmware_ready; struct hif_ind_startup hw_caps; struct wfx_hif hif; + int chip_frozen; + + struct wfx_hif_cmd hif_cmd; }; struct wfx_vif { -- cgit v1.2.3-59-g8ed1b From f95a29d40782f4f0052a692a822de3ba044b19ff Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:43 +0000 Subject: staging: wfx: add HIF commands helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide an abstraction for HIF commands. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-13-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_tx.c | 375 +++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/hif_tx.h | 33 ++++ drivers/staging/wfx/hif_tx_mib.h | 281 +++++++++++++++++++++++++++++ 3 files changed, 689 insertions(+) create mode 100644 drivers/staging/wfx/hif_tx_mib.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index f81a19089db4..781a6e28dbad 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -12,6 +12,7 @@ #include "hif_tx.h" #include "wfx.h" #include "bh.h" +#include "hwio.h" #include "debug.h" void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd) @@ -21,6 +22,29 @@ void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd) mutex_init(&hif_cmd->lock); } +static void wfx_fill_header(struct hif_msg *hif, int if_id, unsigned int cmd, size_t size) +{ + if (if_id == -1) + if_id = 2; + + WARN(cmd > 0x3f, "invalid WSM command %#.2x", cmd); + WARN(size > 0xFFF, "requested buffer is too large: %zu bytes", size); + WARN(if_id > 0x3, "invalid interface ID %d", if_id); + + hif->len = cpu_to_le16(size + 4); + hif->id = cmd; + hif->interface = if_id; +} + +static void *wfx_alloc_hif(size_t body_len, struct hif_msg **hif) +{ + *hif = kzalloc(sizeof(struct hif_msg) + body_len, GFP_KERNEL); + if (*hif) + return (*hif)->body; + else + return NULL; +} + int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, size_t reply_len, bool async) { const char *mib_name = ""; @@ -85,3 +109,354 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, siz return ret; } + +// This function is special. After HIF_REQ_ID_SHUT_DOWN, chip won't reply to any +// request anymore. We need to slightly hack struct wfx_hif_cmd for that job. Be +// carefull to only call this funcion during device unregister. +int hif_shutdown(struct wfx_dev *wdev) +{ + int ret; + struct hif_msg *hif; + + wfx_alloc_hif(0, &hif); + wfx_fill_header(hif, -1, HIF_REQ_ID_SHUT_DOWN, 0); + ret = wfx_cmd_send(wdev, hif, NULL, 0, true); + // After this command, chip won't reply. Be sure to give enough time to + // bh to send buffer: + msleep(100); + wdev->hif_cmd.buf_send = NULL; + if (wdev->pdata.gpio_wakeup) + gpiod_set_value(wdev->pdata.gpio_wakeup, 0); + else + control_reg_write(wdev, 0); + mutex_unlock(&wdev->hif_cmd.lock); + kfree(hif); + return ret; +} + +int hif_configuration(struct wfx_dev *wdev, const u8 *conf, size_t len) +{ + int ret; + size_t buf_len = sizeof(struct hif_req_configuration) + len; + struct hif_msg *hif; + struct hif_req_configuration *body = wfx_alloc_hif(buf_len, &hif); + + body->length = cpu_to_le16(len); + memcpy(body->pds_data, conf, len); + wfx_fill_header(hif, -1, HIF_REQ_ID_CONFIGURATION, buf_len); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_reset(struct wfx_vif *wvif, bool reset_stat) +{ + int ret; + struct hif_msg *hif; + struct hif_req_reset *body = wfx_alloc_hif(sizeof(*body), &hif); + + body->reset_flags.reset_stat = reset_stat; + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_RESET, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, size_t val_len) +{ + int ret; + struct hif_msg *hif; + int buf_len = sizeof(struct hif_cnf_read_mib) + val_len; + struct hif_req_read_mib *body = wfx_alloc_hif(sizeof(*body), &hif); + struct hif_cnf_read_mib *reply = kmalloc(buf_len, GFP_KERNEL); + + body->mib_id = cpu_to_le16(mib_id); + wfx_fill_header(hif, vif_id, HIF_REQ_ID_READ_MIB, sizeof(*body)); + ret = wfx_cmd_send(wdev, hif, reply, buf_len, false); + + if (!ret && mib_id != reply->mib_id) { + dev_warn(wdev->dev, "%s: confirmation mismatch request\n", __func__); + ret = -EIO; + } + if (ret == -ENOMEM) + dev_err(wdev->dev, "buffer is too small to receive %s (%zu < %d)\n", + get_mib_name(mib_id), val_len, reply->length); + if (!ret) + memcpy(val, &reply->mib_data, reply->length); + else + memset(val, 0xFF, val_len); + kfree(hif); + kfree(reply); + return ret; +} + +int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, size_t val_len) +{ + int ret; + struct hif_msg *hif; + int buf_len = sizeof(struct hif_req_write_mib) + val_len; + struct hif_req_write_mib *body = wfx_alloc_hif(buf_len, &hif); + + body->mib_id = cpu_to_le16(mib_id); + body->length = cpu_to_le16(val_len); + memcpy(&body->mib_data, val, val_len); + wfx_fill_header(hif, vif_id, HIF_REQ_ID_WRITE_MIB, buf_len); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_scan(struct wfx_vif *wvif, const struct wfx_scan_params *arg) +{ + int ret, i; + struct hif_msg *hif; + struct hif_ssid_def *ssids; + size_t buf_len = sizeof(struct hif_req_start_scan) + + arg->scan_req.num_of_channels * sizeof(u8) + + arg->scan_req.num_of_ssi_ds * sizeof(struct hif_ssid_def); + struct hif_req_start_scan *body = wfx_alloc_hif(buf_len, &hif); + u8 *ptr = (u8 *) body + sizeof(*body); + + WARN(arg->scan_req.num_of_channels > HIF_API_MAX_NB_CHANNELS, "invalid params"); + WARN(arg->scan_req.num_of_ssi_ds > 2, "invalid params"); + WARN(arg->scan_req.band > 1, "invalid params"); + + // FIXME: This API is unnecessary complex, fixing NumOfChannels and + // adding a member SsidDef at end of struct hif_req_start_scan would + // simplify that a lot. + memcpy(body, &arg->scan_req, sizeof(*body)); + cpu_to_le32s(&body->min_channel_time); + cpu_to_le32s(&body->max_channel_time); + cpu_to_le32s(&body->tx_power_level); + memcpy(ptr, arg->ssids, arg->scan_req.num_of_ssi_ds * sizeof(struct hif_ssid_def)); + ssids = (struct hif_ssid_def *) ptr; + for (i = 0; i < body->num_of_ssi_ds; ++i) + cpu_to_le32s(&ssids[i].ssid_length); + ptr += arg->scan_req.num_of_ssi_ds * sizeof(struct hif_ssid_def); + memcpy(ptr, arg->ch, arg->scan_req.num_of_channels * sizeof(u8)); + ptr += arg->scan_req.num_of_channels * sizeof(u8); + WARN(buf_len != ptr - (u8 *) body, "allocation size mismatch"); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_START_SCAN, buf_len); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_stop_scan(struct wfx_vif *wvif) +{ + int ret; + struct hif_msg *hif; + // body associated to HIF_REQ_ID_STOP_SCAN is empty + wfx_alloc_hif(0, &hif); + + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_STOP_SCAN, 0); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_join(struct wfx_vif *wvif, const struct hif_req_join *arg) +{ + int ret; + struct hif_msg *hif; + struct hif_req_join *body = wfx_alloc_hif(sizeof(*body), &hif); + + memcpy(body, arg, sizeof(struct hif_req_join)); + cpu_to_le16s(&body->channel_number); + cpu_to_le16s(&body->atim_window); + cpu_to_le32s(&body->ssid_length); + cpu_to_le32s(&body->beacon_interval); + cpu_to_le32s(&body->basic_rate_set); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_JOIN, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_set_bss_params(struct wfx_vif *wvif, const struct hif_req_set_bss_params *arg) +{ + int ret; + struct hif_msg *hif; + struct hif_req_set_bss_params *body = wfx_alloc_hif(sizeof(*body), &hif); + + memcpy(body, arg, sizeof(*body)); + cpu_to_le16s(&body->aid); + cpu_to_le32s(&body->operational_rate_set); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_SET_BSS_PARAMS, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_add_key(struct wfx_dev *wdev, const struct hif_req_add_key *arg) +{ + int ret; + struct hif_msg *hif; + // FIXME: only send necessary bits + struct hif_req_add_key *body = wfx_alloc_hif(sizeof(*body), &hif); + + // FIXME: swap bytes as necessary in body + memcpy(body, arg, sizeof(*body)); + if (wfx_api_older_than(wdev, 1, 5)) + // Legacy firmwares expect that add_key to be sent on right + // interface. + wfx_fill_header(hif, arg->int_id, HIF_REQ_ID_ADD_KEY, sizeof(*body)); + else + wfx_fill_header(hif, -1, HIF_REQ_ID_ADD_KEY, sizeof(*body)); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_remove_key(struct wfx_dev *wdev, int idx) +{ + int ret; + struct hif_msg *hif; + struct hif_req_remove_key *body = wfx_alloc_hif(sizeof(*body), &hif); + + body->entry_index = idx; + wfx_fill_header(hif, -1, HIF_REQ_ID_REMOVE_KEY, sizeof(*body)); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_set_edca_queue_params(struct wfx_vif *wvif, const struct hif_req_edca_queue_params *arg) +{ + int ret; + struct hif_msg *hif; + struct hif_req_edca_queue_params *body = wfx_alloc_hif(sizeof(*body), &hif); + + // NOTE: queues numerotation are not the same between WFx and Linux + memcpy(body, arg, sizeof(*body)); + cpu_to_le16s(&body->cw_min); + cpu_to_le16s(&body->cw_max); + cpu_to_le16s(&body->tx_op_limit); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_EDCA_QUEUE_PARAMS, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg) +{ + int ret; + struct hif_msg *hif; + struct hif_req_set_pm_mode *body = wfx_alloc_hif(sizeof(*body), &hif); + + memcpy(body, arg, sizeof(*body)); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_SET_PM_MODE, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_start(struct wfx_vif *wvif, const struct hif_req_start *arg) +{ + int ret; + struct hif_msg *hif; + struct hif_req_start *body = wfx_alloc_hif(sizeof(*body), &hif); + + memcpy(body, arg, sizeof(*body)); + cpu_to_le16s(&body->channel_number); + cpu_to_le32s(&body->beacon_interval); + cpu_to_le32s(&body->basic_rate_set); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_START, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_beacon_transmit(struct wfx_vif *wvif, bool enable_beaconing) +{ + int ret; + struct hif_msg *hif; + struct hif_req_beacon_transmit *body = wfx_alloc_hif(sizeof(*body), &hif); + + body->enable_beaconing = enable_beaconing ? 1 : 0; + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_BEACON_TRANSMIT, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_map_link(struct wfx_vif *wvif, u8 *mac_addr, int flags, int sta_id) +{ + int ret; + struct hif_msg *hif; + struct hif_req_map_link *body = wfx_alloc_hif(sizeof(*body), &hif); + + if (mac_addr) + ether_addr_copy(body->mac_addr, mac_addr); + body->map_link_flags = *(struct hif_map_link_flags *) &flags; + body->peer_sta_id = sta_id; + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_MAP_LINK, sizeof(*body)); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_update_ie(struct wfx_vif *wvif, const struct hif_ie_flags *target_frame, + const u8 *ies, size_t ies_len) +{ + int ret; + struct hif_msg *hif; + int buf_len = sizeof(struct hif_req_update_ie) + ies_len; + struct hif_req_update_ie *body = wfx_alloc_hif(buf_len, &hif); + + memcpy(&body->ie_flags, target_frame, sizeof(struct hif_ie_flags)); + body->num_i_es = cpu_to_le16(1); + memcpy(body->ie, ies, ies_len); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_UPDATE_IE, buf_len); + ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_sl_send_pub_keys(struct wfx_dev *wdev, const uint8_t *pubkey, const uint8_t *pubkey_hmac) +{ + int ret; + struct hif_msg *hif; + struct hif_req_sl_exchange_pub_keys *body = wfx_alloc_hif(sizeof(*body), &hif); + + body->algorithm = HIF_SL_CURVE25519; + memcpy(body->host_pub_key, pubkey, sizeof(body->host_pub_key)); + memcpy(body->host_pub_key_mac, pubkey_hmac, sizeof(body->host_pub_key_mac)); + wfx_fill_header(hif, -1, HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS, sizeof(*body)); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + // Compatibility with legacy secure link + if (ret == SL_PUB_KEY_EXCHANGE_STATUS_SUCCESS) + ret = 0; + return ret; +} + +int hif_sl_config(struct wfx_dev *wdev, const unsigned long *bitmap) +{ + int ret; + struct hif_msg *hif; + struct hif_req_sl_configure *body = wfx_alloc_hif(sizeof(*body), &hif); + + memcpy(body->encr_bmp, bitmap, sizeof(body->encr_bmp)); + wfx_fill_header(hif, -1, HIF_REQ_ID_SL_CONFIGURE, sizeof(*body)); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + return ret; +} + +int hif_sl_set_mac_key(struct wfx_dev *wdev, const uint8_t *slk_key, int destination) +{ + int ret; + struct hif_msg *hif; + struct hif_req_set_sl_mac_key *body = wfx_alloc_hif(sizeof(*body), &hif); + + memcpy(body->key_value, slk_key, sizeof(body->key_value)); + body->otp_or_ram = destination; + wfx_fill_header(hif, -1, HIF_REQ_ID_SET_SL_MAC_KEY, sizeof(*body)); + ret = wfx_cmd_send(wdev, hif, NULL, 0, false); + kfree(hif); + // Compatibility with legacy secure link + if (ret == SL_MAC_KEY_STATUS_SUCCESS) + ret = 0; + return ret; +} diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h index ccf2b7e5e851..31f2a02c8466 100644 --- a/drivers/staging/wfx/hif_tx.h +++ b/drivers/staging/wfx/hif_tx.h @@ -15,6 +15,12 @@ struct wfx_dev; struct wfx_vif; +struct wfx_scan_params { + struct hif_req_start_scan scan_req; + struct hif_ssid_def *ssids; + uint8_t *ch; +}; + struct wfx_hif_cmd { struct mutex lock; struct completion ready; @@ -30,4 +36,31 @@ void wfx_init_hif_cmd(struct wfx_hif_cmd *wfx_hif_cmd); int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, size_t reply_len, bool async); +int hif_shutdown(struct wfx_dev *wdev); +int hif_configuration(struct wfx_dev *wdev, const u8 *conf, size_t len); +int hif_reset(struct wfx_vif *wvif, bool reset_stat); +int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, + void *buf, size_t buf_size); +int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, + void *buf, size_t buf_size); +int hif_scan(struct wfx_vif *wvif, const struct wfx_scan_params *arg); +int hif_stop_scan(struct wfx_vif *wvif); +int hif_join(struct wfx_vif *wvif, const struct hif_req_join *arg); +int hif_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg); +int hif_set_bss_params(struct wfx_vif *wvif, + const struct hif_req_set_bss_params *arg); +int hif_add_key(struct wfx_dev *wdev, const struct hif_req_add_key *arg); +int hif_remove_key(struct wfx_dev *wdev, int idx); +int hif_set_edca_queue_params(struct wfx_vif *wvif, + const struct hif_req_edca_queue_params *arg); +int hif_start(struct wfx_vif *wvif, const struct hif_req_start *arg); +int hif_beacon_transmit(struct wfx_vif *wvif, bool enable); +int hif_map_link(struct wfx_vif *wvif, u8 *mac_addr, int flags, int sta_id); +int hif_update_ie(struct wfx_vif *wvif, const struct hif_ie_flags *target_frame, + const u8 *ies, size_t ies_len); +int hif_sl_set_mac_key(struct wfx_dev *wdev, const uint8_t *slk_key, int destination); +int hif_sl_config(struct wfx_dev *wdev, const unsigned long *bitmap); +int hif_sl_send_pub_keys(struct wfx_dev *wdev, + const uint8_t *pubkey, const uint8_t *pubkey_hmac); + #endif diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h new file mode 100644 index 000000000000..f6624a403016 --- /dev/null +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -0,0 +1,281 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Implementation of host-to-chip MIBs of WFxxx Split Mac (WSM) API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + * Copyright (C) 2010, ST-Ericsson SA + */ +#ifndef WFX_HIF_TX_MIB_H +#define WFX_HIF_TX_MIB_H + +#include + +#include "wfx.h" +#include "hif_tx.h" +#include "hif_api_mib.h" + +static inline int hif_set_output_power(struct wfx_vif *wvif, int power_level) +{ + __le32 val = cpu_to_le32(power_level); + + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_CURRENT_TX_POWER_LEVEL, + &val, sizeof(val)); +} + +static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif, + unsigned int dtim_interval, + unsigned int listen_interval) +{ + struct hif_mib_beacon_wake_up_period val = { + .wakeup_period_min = dtim_interval, + .receive_dtim = 0, + .wakeup_period_max = cpu_to_le16(listen_interval), + }; + + if (dtim_interval > 0xFF || listen_interval > 0xFFFF) + return -EINVAL; + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_BEACON_WAKEUP_PERIOD, + &val, sizeof(val)); +} + +static inline int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif, + struct hif_mib_rcpi_rssi_threshold *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_RCPI_RSSI_THRESHOLD, arg, sizeof(*arg)); +} + +static inline int hif_get_counters_table(struct wfx_dev *wdev, + struct hif_mib_extended_count_table *arg) +{ + if (wfx_api_older_than(wdev, 1, 3)) { + // extended_count_table is wider than count_table + memset(arg, 0xFF, sizeof(*arg)); + return hif_read_mib(wdev, 0, HIF_MIB_ID_COUNTERS_TABLE, + arg, sizeof(struct hif_mib_count_table)); + } else { + return hif_read_mib(wdev, 0, HIF_MIB_ID_EXTENDED_COUNTERS_TABLE, + arg, sizeof(struct hif_mib_extended_count_table)); + } +} + +static inline int hif_set_macaddr(struct wfx_vif *wvif, u8 *mac) +{ + struct hif_mib_mac_address msg = { }; + + if (mac) + ether_addr_copy(msg.mac_addr, mac); + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_DOT11_MAC_ADDRESS, + &msg, sizeof(msg)); +} + +static inline int hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid, + bool fwd_probe_req) +{ + struct hif_mib_rx_filter val = { }; + + if (filter_bssid) + val.bssid_filter = 1; + if (fwd_probe_req) + val.fwd_probe_req = 1; + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_RX_FILTER, + &val, sizeof(val)); +} + +static inline int hif_set_beacon_filter_table(struct wfx_vif *wvif, + struct hif_mib_bcn_filter_table *ft) +{ + size_t buf_len = struct_size(ft, ie_table, ft->num_of_info_elmts); + + cpu_to_le32s(&ft->num_of_info_elmts); + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_BEACON_FILTER_TABLE, ft, buf_len); +} + +static inline int hif_beacon_filter_control(struct wfx_vif *wvif, + int enable, int beacon_count) +{ + struct hif_mib_bcn_filter_enable arg = { + .enable = cpu_to_le32(enable), + .bcn_count = cpu_to_le32(beacon_count), + }; + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_BEACON_FILTER_ENABLE, &arg, sizeof(arg)); +} + +static inline int hif_set_operational_mode(struct wfx_dev *wdev, + enum hif_op_power_mode mode) +{ + struct hif_mib_gl_operational_power_mode val = { + .power_mode = mode, + .wup_ind_activation = 1, + }; + + return hif_write_mib(wdev, -1, HIF_MIB_ID_GL_OPERATIONAL_POWER_MODE, + &val, sizeof(val)); +} + +static inline int hif_set_template_frame(struct wfx_vif *wvif, + struct hif_mib_template_frame *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_TEMPLATE_FRAME, + arg, sizeof(*arg)); +} + +static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) +{ + struct hif_mib_protected_mgmt_policy val = { }; + + WARN_ON(required && !capable); + if (capable) { + val.pmf_enable = 1; + val.host_enc_auth_frames = 1; + } + if (!required) + val.unpmf_allowed = 1; + cpu_to_le32s(&val); + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_PROTECTED_MGMT_POLICY, + &val, sizeof(val)); +} + +static inline int hif_set_block_ack_policy(struct wfx_vif *wvif, + u8 tx_tid_policy, u8 rx_tid_policy) +{ + struct hif_mib_block_ack_policy val = { + .block_ack_tx_tid_policy = tx_tid_policy, + .block_ack_rx_tid_policy = rx_tid_policy, + }; + + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_BLOCK_ACK_POLICY, + &val, sizeof(val)); +} + +static inline int hif_set_association_mode(struct wfx_vif *wvif, + struct hif_mib_set_association_mode *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_SET_ASSOCIATION_MODE, arg, sizeof(*arg)); +} + +static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, + struct hif_mib_set_tx_rate_retry_policy *arg) +{ + size_t size = struct_size(arg, tx_rate_retry_policy, arg->num_tx_rate_policies); + + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); +} + +static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif, + struct hif_mib_mac_addr_data_frame_condition *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_MAC_ADDR_DATAFRAME_CONDITION, + arg, sizeof(*arg)); +} + +static inline int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif, + struct hif_mib_uc_mc_bc_data_frame_condition *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_UC_MC_BC_DATAFRAME_CONDITION, + arg, sizeof(*arg)); +} + +static inline int hif_set_config_data_filter(struct wfx_vif *wvif, + struct hif_mib_config_data_filter *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_CONFIG_DATA_FILTER, arg, sizeof(*arg)); +} + +static inline int hif_set_data_filtering(struct wfx_vif *wvif, + struct hif_mib_set_data_filtering *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_SET_DATA_FILTERING, arg, sizeof(*arg)); +} + +static inline int hif_keep_alive_period(struct wfx_vif *wvif, int period) +{ + struct hif_mib_keep_alive_period arg = { + .keep_alive_period = cpu_to_le16(period), + }; + + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_KEEP_ALIVE_PERIOD, + &arg, sizeof(arg)); +}; + +static inline int hif_set_arp_ipv4_filter(struct wfx_vif *wvif, + struct hif_mib_arp_ip_addr_table *fp) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_ARP_IP_ADDRESSES_TABLE, + fp, sizeof(*fp)); +} + +static inline int hif_use_multi_tx_conf(struct wfx_dev *wdev, + bool enabled) +{ + __le32 arg = enabled ? cpu_to_le32(1) : 0; + + return hif_write_mib(wdev, -1, HIF_MIB_ID_GL_SET_MULTI_MSG, + &arg, sizeof(arg)); +} + +static inline int hif_set_uapsd_info(struct wfx_vif *wvif, + struct hif_mib_set_uapsd_information *arg) +{ + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_SET_UAPSD_INFORMATION, + arg, sizeof(*arg)); +} + +static inline int hif_erp_use_protection(struct wfx_vif *wvif, bool enable) +{ + __le32 arg = enable ? cpu_to_le32(1) : 0; + + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_NON_ERP_PROTECTION, &arg, sizeof(arg)); +} + +static inline int hif_slot_time(struct wfx_vif *wvif, int val) +{ + __le32 arg = cpu_to_le32(val); + + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SLOT_TIME, + &arg, sizeof(arg)); +} + +static inline int hif_dual_cts_protection(struct wfx_vif *wvif, bool val) +{ + struct hif_mib_set_ht_protection arg = { + .dual_cts_prot = val, + }; + + return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SET_HT_PROTECTION, + &arg, sizeof(arg)); +} + +static inline int hif_wep_default_key_id(struct wfx_vif *wvif, int val) +{ + __le32 arg = cpu_to_le32(val); + + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID, + &arg, sizeof(arg)); +} + +static inline int hif_rts_threshold(struct wfx_vif *wvif, int val) +{ + __le32 arg = cpu_to_le32(val > 0 ? val : 0xFFFF); + + return hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_DOT11_RTS_THRESHOLD, &arg, sizeof(arg)); +} + +#endif -- cgit v1.2.3-59-g8ed1b From 846239f641db5af8dd952575a65808281f2d849e Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:43 +0000 Subject: staging: wfx: introduce "secure link" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chip support encryption of the link between host and chip. This feature is called "secure link". Driver code on github[1] support it. However, it relies on mbedtls for cryptographic functions. So, I decided to not import this feature in current patch. However, in order to keep code synchronized between github and kernel, I imported all code related to this feature, even if most of it is just no-op. [1]: https://github.com/SiliconLabs/wfx-linux-driver/ Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-14-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 31 ++++++++++++++++++++++++-- drivers/staging/wfx/debug.c | 17 +++++++++++++++ drivers/staging/wfx/hif_rx.c | 17 +++++++++++++++ drivers/staging/wfx/hif_tx.c | 6 +++++ drivers/staging/wfx/hif_tx.h | 1 + drivers/staging/wfx/main.c | 36 ++++++++++++++++++++++++++++++ drivers/staging/wfx/main.h | 2 ++ drivers/staging/wfx/secure_link.h | 46 +++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/wfx.h | 2 ++ 9 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/wfx/secure_link.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index c94c9c401a69..d321fd312d55 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -12,6 +12,7 @@ #include "wfx.h" #include "hwio.h" #include "traces.h" +#include "secure_link.h" #include "hif_rx.h" #include "hif_api_cmd.h" @@ -74,7 +75,18 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) hif = (struct hif_msg *) skb->data; WARN(hif->encrypted & 0x1, "unsupported encryption type"); if (hif->encrypted == 0x2) { - BUG(); // Not yet implemented + if (wfx_sl_decode(wdev, (void *) hif)) { + dev_kfree_skb(skb); + // If frame was a confirmation, expect trouble in next + // exchange. However, it is harmless to fail to decode + // an indication frame, so try to continue. Anyway, + // piggyback is probably correct. + return piggyback; + } + le16_to_cpus(hif->len); + computed_len = round_up(hif->len - sizeof(hif->len), 16) + + sizeof(struct hif_sl_msg) + + sizeof(struct hif_sl_tag); } else { le16_to_cpus(hif->len); computed_len = round_up(hif->len, 2); @@ -166,7 +178,22 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) hif->seqnum = wdev->hif.tx_seqnum; wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1); - data = hif; + if (wfx_is_secure_command(wdev, hif->id)) { + len = round_up(len - sizeof(hif->len), 16) + sizeof(hif->len) + + sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_sl_tag); + // AES support encryption in-place. However, mac80211 access to + // 802.11 header after frame was sent (to get MAC addresses). + // So, keep origin buffer clear. + data = kmalloc(len, GFP_KERNEL); + if (!data) + goto end; + is_encrypted = true; + ret = wfx_sl_encode(wdev, hif, data); + if (ret) + goto end; + } else { + data = hif; + } WARN(len > wdev->hw_caps.size_inp_ch_buf, "%s: request exceed WFx capability: %zu > %d\n", __func__, len, wdev->hw_caps.size_inp_ch_buf); diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 0a328c96eaa0..f79693a4be7f 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -6,6 +6,7 @@ * Copyright (c) 2010, ST-Ericsson */ #include +#include #include "debug.h" #include "wfx.h" @@ -53,6 +54,21 @@ const char *get_reg_name(unsigned long id) return get_symbol(id, wfx_reg_print_map); } +static ssize_t wfx_burn_slk_key_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wfx_dev *wdev = file->private_data; + + dev_info(wdev->dev, "this driver does not support secure link\n"); + return -EINVAL; +} + +static const struct file_operations wfx_burn_slk_key_fops = { + .open = simple_open, + .write = wfx_burn_slk_key_write, +}; + struct dbgfs_hif_msg { struct wfx_dev *wdev; struct completion complete; @@ -146,6 +162,7 @@ int wfx_debug_init(struct wfx_dev *wdev) struct dentry *d; d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + debugfs_create_file("burn_slk_key", 0200, d, wdev, &wfx_burn_slk_key_fops); debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); return 0; diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index ba8ea4f3c91b..dd5f1dea4e85 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -11,6 +11,7 @@ #include "hif_rx.h" #include "wfx.h" +#include "secure_link.h" #include "hif_api_cmd.h" static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) @@ -46,6 +47,8 @@ static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void * } else { wdev->hif_cmd.buf_send = NULL; mutex_unlock(&wdev->hif_cmd.lock); + if (cmd != HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS) + mutex_unlock(&wdev->hif_cmd.key_renew_lock); } return status; } @@ -68,11 +71,25 @@ static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi return 0; } +static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_ind_sl_exchange_pub_keys *body = buf; + + // Compatibility with legacy secure link + if (body->status == SL_PUB_KEY_EXCHANGE_STATUS_SUCCESS) + body->status = 0; + if (body->status) + dev_warn(wdev->dev, "secure link negociation error\n"); + wfx_sl_check_pubkey(wdev, body->ncp_pub_key, body->ncp_pub_key_mac); + return 0; +} + static const struct { int msg_id; int (*handler)(struct wfx_dev *wdev, struct hif_msg *hif, void *buf); } hif_handlers[] = { { HIF_IND_ID_STARTUP, hif_startup_indication }, + { HIF_IND_ID_SL_EXCHANGE_PUB_KEYS, hif_keys_indication }, }; void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 781a6e28dbad..f8ab871aa188 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -20,6 +20,7 @@ void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd) init_completion(&hif_cmd->ready); init_completion(&hif_cmd->done); mutex_init(&hif_cmd->lock); + mutex_init(&hif_cmd->key_renew_lock); } static void wfx_fill_header(struct hif_msg *hif, int if_id, unsigned int cmd, size_t size) @@ -59,6 +60,9 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, siz if (wdev->chip_frozen) return -ETIMEDOUT; + if (cmd != HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS) + mutex_lock(&wdev->hif_cmd.key_renew_lock); + mutex_lock(&wdev->hif_cmd.lock); WARN(wdev->hif_cmd.buf_send, "data locking error"); @@ -107,6 +111,8 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, siz "WSM request %s%s%s (%#.2x) on vif %d returned status %d\n", get_hif_name(cmd), mib_sep, mib_name, cmd, vif, ret); + if (cmd != HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS) + mutex_unlock(&wdev->hif_cmd.key_renew_lock); return ret; } diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h index 31f2a02c8466..6f2ea2f3a77d 100644 --- a/drivers/staging/wfx/hif_tx.h +++ b/drivers/staging/wfx/hif_tx.h @@ -23,6 +23,7 @@ struct wfx_scan_params { struct wfx_hif_cmd { struct mutex lock; + struct mutex key_renew_lock; struct completion ready; struct completion done; bool async; diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 8973eeb60eb8..0cfd6b2ec8d1 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -27,6 +27,7 @@ #include "bh.h" #include "sta.h" #include "debug.h" +#include "secure_link.h" #include "hif_api_cmd.h" #include "wfx_version.h" @@ -39,6 +40,10 @@ static int gpio_wakeup = -2; module_param(gpio_wakeup, int, 0644); MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); +static char *slk_key; +module_param(slk_key, charp, 0600); +MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexdecimal digits)."); + static const struct ieee80211_ops wfx_ops = { .start = wfx_start, .stop = wfx_stop, @@ -84,6 +89,29 @@ struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *lab return ret; } +static void wfx_fill_sl_key(struct device *dev, struct wfx_platform_data *pdata) +{ + const char *ascii_key = NULL; + int ret = 0; + + if (slk_key) + ascii_key = slk_key; + if (!ascii_key) + ret = of_property_read_string(dev->of_node, "slk_key", &ascii_key); + if (ret == -EILSEQ || ret == -ENODATA) + dev_err(dev, "ignoring malformatted key from DT\n"); + if (!ascii_key) + return; + + ret = hex2bin(pdata->slk_key, ascii_key, sizeof(pdata->slk_key)); + if (ret) { + dev_err(dev, "ignoring malformatted key: %s\n", ascii_key); + memset(pdata->slk_key, 0, sizeof(pdata->slk_key)); + return; + } + dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n"); +} + struct wfx_dev *wfx_init_common(struct device *dev, const struct wfx_platform_data *pdata, const struct hwbus_ops *hwbus_ops, @@ -113,6 +141,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->hwbus_ops = hwbus_ops; wdev->hwbus_priv = hwbus_priv; memcpy(&wdev->pdata, pdata, sizeof(*pdata)); + wfx_fill_sl_key(dev, &wdev->pdata); init_completion(&wdev->firmware_ready); wfx_init_hif_cmd(&wdev->hif_cmd); @@ -167,6 +196,12 @@ int wfx_probe(struct wfx_dev *wdev) goto err1; } + err = wfx_sl_init(wdev); + if (err && wdev->hw_caps.capabilities.link_mode == SEC_LINK_ENFORCED) { + dev_err(wdev->dev, "chip require secure_link, but can't negociate it\n"); + goto err1; + } + for (i = 0; i < ARRAY_SIZE(wdev->addresses); i++) { eth_zero_addr(wdev->addresses[i].addr); macaddr = of_get_mac_address(wdev->dev->of_node); @@ -198,6 +233,7 @@ err1: void wfx_release(struct wfx_dev *wdev) { wfx_bh_unregister(wdev); + wfx_sl_deinit(wdev); } static int __init wfx_core_init(void) diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index f7c65999a493..2c9c215455ce 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -14,12 +14,14 @@ #include #include "bus.h" +#include "hif_api_general.h" struct wfx_dev; struct wfx_platform_data { /* Keyset and ".sec" extention will appended to this string */ const char *file_fw; + unsigned char slk_key[API_KEY_VALUE_SIZE]; struct gpio_desc *gpio_wakeup; /* * if true HIF D_out is sampled on the rising edge of the clock diff --git a/drivers/staging/wfx/secure_link.h b/drivers/staging/wfx/secure_link.h new file mode 100644 index 000000000000..e2da1c73c760 --- /dev/null +++ b/drivers/staging/wfx/secure_link.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2019, Silicon Laboratories, Inc. + */ +#ifndef WFX_SECURE_LINK_H +#define WFX_SECURE_LINK_H + +#include "hif_api_general.h" + +struct wfx_dev; + + +struct sl_context { +}; + +static inline bool wfx_is_secure_command(struct wfx_dev *wdev, int cmd_id) +{ + return false; +} + +static inline int wfx_sl_decode(struct wfx_dev *wdev, struct hif_sl_msg *m) +{ + return -EIO; +} + +static inline int wfx_sl_encode(struct wfx_dev *wdev, struct hif_msg *input, struct hif_sl_msg *output) +{ + return -EIO; +} + +static inline int wfx_sl_check_pubkey(struct wfx_dev *wdev, uint8_t *ncp_pubkey, uint8_t *ncp_pubmac) +{ + return -EIO; +} + +static inline int wfx_sl_init(struct wfx_dev *wdev) +{ + return -EIO; +} + +static inline void wfx_sl_deinit(struct wfx_dev *wdev) +{ +} + + +#endif diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index bf9de11f8896..7adb5bf67e90 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -15,6 +15,7 @@ #include "bh.h" #include "main.h" +#include "secure_link.h" #include "hif_tx.h" #include "hif_api_general.h" @@ -33,6 +34,7 @@ struct wfx_dev { struct completion firmware_ready; struct hif_ind_startup hw_caps; struct wfx_hif hif; + struct sl_context sl; int chip_frozen; struct wfx_hif_cmd hif_cmd; -- cgit v1.2.3-59-g8ed1b From c7ff39dd8b5393c55b0a8a5dedb5ba13f4c838a8 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:44 +0000 Subject: staging: wfx: setup initial chip configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A few tasks remain to be done in order to finish chip initial configuration: - configure chip to use multi-tx confirmation (speed up data transfer) - configure chip to use wake-up feature (save power consumption during runtime) - set hardware configuration (clocks, RF, pinout, etc...) using a Platform Data Set (PDS) file On release, driver completely shutdown the chip to save power consumption. Documentation about PDS and PDS data for sample boards are available here[1]. One day, PDS data may find a place in device tree but, currently, PDS is too much linked with firmware to allowing that. This patch also add "send_pds" file in debugfs to be able to dynamically change PDS (only for debug, of course). [1]: https://github.com/SiliconLabs/wfx-firmware/tree/master/PDS Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-15-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bus_sdio.c | 1 + drivers/staging/wfx/bus_spi.c | 1 + drivers/staging/wfx/debug.c | 29 +++++++++++++ drivers/staging/wfx/hif_rx.c | 11 +++++ drivers/staging/wfx/main.c | 94 ++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/main.h | 2 + 6 files changed, 138 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index c0c063c3cfc9..05f02c278782 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -19,6 +19,7 @@ static const struct wfx_platform_data wfx_sdio_pdata = { .file_fw = "wfm_wf200", + .file_pds = "wf200.pds", }; struct wfx_sdio_priv { diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index b7cd82b4e5e7..f65f7d75e731 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -29,6 +29,7 @@ MODULE_PARM_DESC(gpio_reset, "gpio number for reset. -1 for none."); static const struct wfx_platform_data wfx_spi_pdata = { .file_fw = "wfm_wf200", + .file_pds = "wf200.pds", .use_rising_clk = true, }; diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index f79693a4be7f..0619c7d1cf79 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -10,6 +10,7 @@ #include "debug.h" #include "wfx.h" +#include "main.h" #define CREATE_TRACE_POINTS #include "traces.h" @@ -54,6 +55,33 @@ const char *get_reg_name(unsigned long id) return get_symbol(id, wfx_reg_print_map); } +static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wfx_dev *wdev = file->private_data; + char *buf; + int ret; + + if (*ppos != 0) { + dev_dbg(wdev->dev, "PDS data must be written in one transaction"); + return -EBUSY; + } + buf = memdup_user(user_buf, count); + if (IS_ERR(buf)) + return PTR_ERR(buf); + *ppos = *ppos + count; + ret = wfx_send_pds(wdev, buf, count); + kfree(buf); + if (ret < 0) + return ret; + return count; +} + +static const struct file_operations wfx_send_pds_fops = { + .open = simple_open, + .write = wfx_send_pds_write, +}; + static ssize_t wfx_burn_slk_key_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) @@ -162,6 +190,7 @@ int wfx_debug_init(struct wfx_dev *wdev) struct dentry *d; d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + debugfs_create_file("send_pds", 0200, d, wdev, &wfx_send_pds_fops); debugfs_create_file("burn_slk_key", 0200, d, wdev, &wfx_burn_slk_key_fops); debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index dd5f1dea4e85..6b9683d69a3f 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -71,6 +71,16 @@ static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi return 0; } +static int hif_wakeup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + if (!wdev->pdata.gpio_wakeup + || !gpiod_get_value(wdev->pdata.gpio_wakeup)) { + dev_warn(wdev->dev, "unexpected wake-up indication\n"); + return -EIO; + } + return 0; +} + static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct hif_ind_sl_exchange_pub_keys *body = buf; @@ -89,6 +99,7 @@ static const struct { int (*handler)(struct wfx_dev *wdev, struct hif_msg *hif, void *buf); } hif_handlers[] = { { HIF_IND_ID_STARTUP, hif_startup_indication }, + { HIF_IND_ID_WAKEUP, hif_wakeup_indication }, { HIF_IND_ID_SL_EXCHANGE_PUB_KEYS, hif_keys_indication }, }; diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 0cfd6b2ec8d1..5b04ea5f4353 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "main.h" #include "wfx.h" @@ -28,9 +29,12 @@ #include "sta.h" #include "debug.h" #include "secure_link.h" +#include "hif_tx_mib.h" #include "hif_api_cmd.h" #include "wfx_version.h" +#define WFX_PDS_MAX_SIZE 1500 + MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); MODULE_AUTHOR("Jérôme Pouiller "); MODULE_LICENSE("GPL"); @@ -112,6 +116,69 @@ static void wfx_fill_sl_key(struct device *dev, struct wfx_platform_data *pdata) dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n"); } +/* NOTE: wfx_send_pds() destroy buf */ +int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len) +{ + int ret; + int start, brace_level, i; + + start = 0; + brace_level = 0; + if (buf[0] != '{') { + dev_err(wdev->dev, "valid PDS start with '{'. Did you forget to compress it?\n"); + return -EINVAL; + } + for (i = 1; i < len - 1; i++) { + if (buf[i] == '{') + brace_level++; + if (buf[i] == '}') + brace_level--; + if (buf[i] == '}' && !brace_level) { + i++; + if (i - start + 1 > WFX_PDS_MAX_SIZE) + return -EFBIG; + buf[start] = '{'; + buf[i] = 0; + dev_dbg(wdev->dev, "send PDS '%s}'\n", buf + start); + buf[i] = '}'; + ret = hif_configuration(wdev, buf + start, i - start + 1); + if (ret == HIF_STATUS_FAILURE) { + dev_err(wdev->dev, "PDS bytes %d to %d: invalid data (unsupported options?)\n", start, i); + return -EINVAL; + } + if (ret == -ETIMEDOUT) { + dev_err(wdev->dev, "PDS bytes %d to %d: chip didn't reply (corrupted file?)\n", start, i); + return ret; + } + if (ret) { + dev_err(wdev->dev, "PDS bytes %d to %d: chip returned an unknown error\n", start, i); + return -EIO; + } + buf[i] = ','; + start = i; + } + } + return 0; +} + +static int wfx_send_pdata_pds(struct wfx_dev *wdev) +{ + int ret = 0; + const struct firmware *pds; + unsigned char *tmp_buf; + + ret = request_firmware(&pds, wdev->pdata.file_pds, wdev->dev); + if (ret) { + dev_err(wdev->dev, "can't load PDS file %s\n", wdev->pdata.file_pds); + return ret; + } + tmp_buf = kmemdup(pds->data, pds->size, GFP_KERNEL); + ret = wfx_send_pds(wdev, tmp_buf, pds->size); + kfree(tmp_buf); + release_firmware(pds); + return ret; +} + struct wfx_dev *wfx_init_common(struct device *dev, const struct wfx_platform_data *pdata, const struct hwbus_ops *hwbus_ops, @@ -141,6 +208,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->hwbus_ops = hwbus_ops; wdev->hwbus_priv = hwbus_priv; memcpy(&wdev->pdata, pdata, sizeof(*pdata)); + of_property_read_string(dev->of_node, "config-file", &wdev->pdata.file_pds); + wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); wfx_fill_sl_key(dev, &wdev->pdata); init_completion(&wdev->firmware_ready); @@ -159,6 +228,12 @@ int wfx_probe(struct wfx_dev *wdev) int i; int err; const void *macaddr; + struct gpio_desc *gpio_saved; + + // During first part of boot, gpio_wakeup cannot yet been used. So + // prevent bh() to touch it. + gpio_saved = wdev->pdata.gpio_wakeup; + wdev->pdata.gpio_wakeup = NULL; wfx_bh_register(wdev); @@ -202,6 +277,24 @@ int wfx_probe(struct wfx_dev *wdev) goto err1; } + dev_dbg(wdev->dev, "sending configuration file %s\n", wdev->pdata.file_pds); + err = wfx_send_pdata_pds(wdev); + if (err < 0) + goto err1; + + wdev->pdata.gpio_wakeup = gpio_saved; + if (wdev->pdata.gpio_wakeup) { + dev_dbg(wdev->dev, "enable 'quiescent' power mode with gpio %d and PDS file %s\n", + desc_to_gpio(wdev->pdata.gpio_wakeup), wdev->pdata.file_pds); + gpiod_set_value(wdev->pdata.gpio_wakeup, 1); + control_reg_write(wdev, 0); + hif_set_operational_mode(wdev, HIF_OP_POWER_MODE_QUIESCENT); + } else { + hif_set_operational_mode(wdev, HIF_OP_POWER_MODE_DOZE); + } + + hif_use_multi_tx_conf(wdev, true); + for (i = 0; i < ARRAY_SIZE(wdev->addresses); i++) { eth_zero_addr(wdev->addresses[i].addr); macaddr = of_get_mac_address(wdev->dev->of_node); @@ -232,6 +325,7 @@ err1: void wfx_release(struct wfx_dev *wdev) { + hif_shutdown(wdev); wfx_bh_unregister(wdev); wfx_sl_deinit(wdev); } diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index 2c9c215455ce..f2b07ed1627c 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -21,6 +21,7 @@ struct wfx_dev; struct wfx_platform_data { /* Keyset and ".sec" extention will appended to this string */ const char *file_fw; + const char *file_pds; unsigned char slk_key[API_KEY_VALUE_SIZE]; struct gpio_desc *gpio_wakeup; /* @@ -42,5 +43,6 @@ void wfx_release(struct wfx_dev *wdev); struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label); bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor); +int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len); #endif -- cgit v1.2.3-59-g8ed1b From f4a71ba8753d94cc5c1e73746352274a598a25ee Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:44 +0000 Subject: staging: wfx: add debug files and trace debug events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add traces when debug events happen and allow to ask internal information to chip. These features work independently from mac80211. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-16-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/debug.c | 105 +++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/hif_rx.c | 80 +++++++++++++++++++++++++++++++++ drivers/staging/wfx/main.c | 2 + drivers/staging/wfx/wfx.h | 16 +++++++ 4 files changed, 203 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 0619c7d1cf79..1e23bb5bde3e 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -6,11 +6,13 @@ * Copyright (c) 2010, ST-Ericsson */ #include +#include #include #include "debug.h" #include "wfx.h" #include "main.h" +#include "hif_tx_mib.h" #define CREATE_TRACE_POINTS #include "traces.h" @@ -55,6 +57,107 @@ const char *get_reg_name(unsigned long id) return get_symbol(id, wfx_reg_print_map); } +static int wfx_counters_show(struct seq_file *seq, void *v) +{ + int ret; + struct wfx_dev *wdev = seq->private; + struct hif_mib_extended_count_table counters; + + ret = hif_get_counters_table(wdev, &counters); + if (ret < 0) + return ret; + if (ret > 0) + return -EIO; + +#define PUT_COUNTER(name) \ + seq_printf(seq, "%24s %d\n", #name ":", le32_to_cpu(counters.count_##name)) + + PUT_COUNTER(tx_packets); + PUT_COUNTER(tx_multicast_frames); + PUT_COUNTER(tx_frames_success); + PUT_COUNTER(tx_frame_failures); + PUT_COUNTER(tx_frames_retried); + PUT_COUNTER(tx_frames_multi_retried); + + PUT_COUNTER(rts_success); + PUT_COUNTER(rts_failures); + PUT_COUNTER(ack_failures); + + PUT_COUNTER(rx_packets); + PUT_COUNTER(rx_frames_success); + PUT_COUNTER(rx_packet_errors); + PUT_COUNTER(plcp_errors); + PUT_COUNTER(fcs_errors); + PUT_COUNTER(rx_decryption_failures); + PUT_COUNTER(rx_mic_failures); + PUT_COUNTER(rx_no_key_failures); + PUT_COUNTER(rx_frame_duplicates); + PUT_COUNTER(rx_multicast_frames); + PUT_COUNTER(rx_cmacicv_errors); + PUT_COUNTER(rx_cmac_replays); + PUT_COUNTER(rx_mgmt_ccmp_replays); + + PUT_COUNTER(rx_beacon); + PUT_COUNTER(miss_beacon); + +#undef PUT_COUNTER + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(wfx_counters); + +static const char * const channel_names[] = { + [0] = "1M", + [1] = "2M", + [2] = "5.5M", + [3] = "11M", + /* Entries 4 and 5 does not exist */ + [6] = "6M", + [7] = "9M", + [8] = "12M", + [9] = "18M", + [10] = "24M", + [11] = "36M", + [12] = "48M", + [13] = "54M", + [14] = "MCS0", + [15] = "MCS1", + [16] = "MCS2", + [17] = "MCS3", + [18] = "MCS4", + [19] = "MCS5", + [20] = "MCS6", + [21] = "MCS7", +}; + +static int wfx_rx_stats_show(struct seq_file *seq, void *v) +{ + struct wfx_dev *wdev = seq->private; + struct hif_rx_stats *st = &wdev->rx_stats; + int i; + + mutex_lock(&wdev->rx_stats_lock); + seq_printf(seq, "Timestamp: %dus\n", st->date); + seq_printf(seq, "Low power clock: frequency %uHz, external %s\n", + st->pwr_clk_freq, + st->is_ext_pwr_clk ? "yes" : "no"); + seq_printf(seq, "Num. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n", + st->nb_rx_frame, st->per_total, st->throughput); + seq_puts(seq, " Num. of PER RSSI SNR CFO\n"); + seq_puts(seq, " frames (x10e4) (dBm) (dB) (kHz)\n"); + for (i = 0; i < ARRAY_SIZE(channel_names); i++) { + if (channel_names[i]) + seq_printf(seq, "%5s %8d %8d %8d %8d %8d\n", + channel_names[i], st->nb_rx_by_rate[i], + st->per[i], st->rssi[i] / 100, + st->snr[i] / 100, st->cfo[i]); + } + mutex_unlock(&wdev->rx_stats_lock); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(wfx_rx_stats); + static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -190,6 +293,8 @@ int wfx_debug_init(struct wfx_dev *wdev) struct dentry *d; d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir); + debugfs_create_file("counters", 0444, d, wdev, &wfx_counters_fops); + debugfs_create_file("rx_stats", 0444, d, wdev, &wfx_rx_stats_fops); debugfs_create_file("send_pds", 0200, d, wdev, &wfx_send_pds_fops); debugfs_create_file("burn_slk_key", 0200, d, wdev, &wfx_burn_slk_key_fops); debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 6b9683d69a3f..c93bae1b6acf 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -94,13 +94,93 @@ static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void * return 0; } +static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + + WARN_ON(!wvif); + dev_warn(wdev->dev, "unattended JoinCompleteInd\n"); + + return 0; +} + +static int hif_error_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_ind_error *body = buf; + u8 *pRollback = (u8 *) body->data; + u32 *pStatus = (u32 *) body->data; + + switch (body->type) { + case HIF_ERROR_FIRMWARE_ROLLBACK: + dev_err(wdev->dev, "asynchronous error: firmware rollback error %d\n", *pRollback); + break; + case HIF_ERROR_FIRMWARE_DEBUG_ENABLED: + dev_err(wdev->dev, "asynchronous error: firmware debug feature enabled\n"); + break; + case HIF_ERROR_OUTDATED_SESSION_KEY: + dev_err(wdev->dev, "asynchronous error: secure link outdated key: %#.8x\n", *pStatus); + break; + case HIF_ERROR_INVALID_SESSION_KEY: + dev_err(wdev->dev, "asynchronous error: invalid session key\n"); + break; + case HIF_ERROR_OOR_VOLTAGE: + dev_err(wdev->dev, "asynchronous error: out-of-range overvoltage: %#.8x\n", *pStatus); + break; + case HIF_ERROR_PDS_VERSION: + dev_err(wdev->dev, "asynchronous error: wrong PDS payload or version: %#.8x\n", *pStatus); + break; + default: + dev_err(wdev->dev, "asynchronous error: unknown (%d)\n", body->type); + break; + } + return 0; +} + +static int hif_generic_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_ind_generic *body = buf; + + switch (body->indication_type) { + case HIF_GENERIC_INDICATION_TYPE_RAW: + return 0; + case HIF_GENERIC_INDICATION_TYPE_STRING: + dev_info(wdev->dev, "firmware says: %s\n", (char *) body->indication_data.raw_data); + return 0; + case HIF_GENERIC_INDICATION_TYPE_RX_STATS: + mutex_lock(&wdev->rx_stats_lock); + // Older firmware send a generic indication beside RxStats + if (!wfx_api_older_than(wdev, 1, 4)) + dev_info(wdev->dev, "Rx test ongoing. Temperature: %d°C\n", body->indication_data.rx_stats.current_temp); + memcpy(&wdev->rx_stats, &body->indication_data.rx_stats, sizeof(wdev->rx_stats)); + mutex_unlock(&wdev->rx_stats_lock); + return 0; + default: + dev_err(wdev->dev, "generic_indication: unknown indication type: %#.8x\n", body->indication_type); + return -EIO; + } +} + +static int hif_exception_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + size_t len = hif->len - 4; // drop header + dev_err(wdev->dev, "firmware exception\n"); + print_hex_dump_bytes("Dump: ", DUMP_PREFIX_NONE, buf, len); + wdev->chip_frozen = 1; + + return -1; +} + static const struct { int msg_id; int (*handler)(struct wfx_dev *wdev, struct hif_msg *hif, void *buf); } hif_handlers[] = { { HIF_IND_ID_STARTUP, hif_startup_indication }, { HIF_IND_ID_WAKEUP, hif_wakeup_indication }, + { HIF_IND_ID_JOIN_COMPLETE, hif_join_complete_indication }, { HIF_IND_ID_SL_EXCHANGE_PUB_KEYS, hif_keys_indication }, + { HIF_IND_ID_GENERIC, hif_generic_indication }, + { HIF_IND_ID_ERROR, hif_error_indication }, + { HIF_IND_ID_EXCEPTION, hif_exception_indication }, }; void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 5b04ea5f4353..2e71f446d4d4 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -212,6 +212,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); wfx_fill_sl_key(dev, &wdev->pdata); + mutex_init(&wdev->rx_stats_lock); init_completion(&wdev->firmware_ready); wfx_init_hif_cmd(&wdev->hif_cmd); @@ -220,6 +221,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, void wfx_free_common(struct wfx_dev *wdev) { + mutex_destroy(&wdev->rx_stats_lock); ieee80211_free_hw(wdev->hw); } diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 7adb5bf67e90..49b776a07515 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -38,6 +38,9 @@ struct wfx_dev { int chip_frozen; struct wfx_hif_cmd hif_cmd; + + struct hif_rx_stats rx_stats; + struct mutex rx_stats_lock; }; struct wfx_vif { @@ -46,4 +49,17 @@ struct wfx_vif { int id; }; +static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) +{ + if (vif_id >= ARRAY_SIZE(wdev->vif)) { + dev_dbg(wdev->dev, "requesting non-existent vif: %d\n", vif_id); + return NULL; + } + if (!wdev->vif[vif_id]) { + dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", vif_id); + return NULL; + } + return (struct wfx_vif *) wdev->vif[vif_id]->drv_priv; +} + #endif /* WFX_H */ -- cgit v1.2.3-59-g8ed1b From 9bca45f3d6924f19f29c0d019e961af3f41bdc9e Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:45 +0000 Subject: staging: wfx: allow to send 802.11 frames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three things make this task more complex than it should: - Chip necessitate to associate a link-id to each station. It is same thing than association ID but, using 8 bits only. - Rate policy is sent separately from Tx frames - Driver try to handle itself power saving of stations and multicast data Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-17-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 3 + drivers/staging/wfx/bh.c | 2 + drivers/staging/wfx/data_tx.c | 783 ++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/data_tx.h | 93 +++++ drivers/staging/wfx/hif_rx.c | 37 ++ drivers/staging/wfx/hif_tx.c | 1 + drivers/staging/wfx/main.c | 4 + drivers/staging/wfx/queue.c | 526 ++++++++++++++++++++++++++++ drivers/staging/wfx/queue.h | 59 ++++ drivers/staging/wfx/sta.c | 135 ++++++++ drivers/staging/wfx/sta.h | 8 + drivers/staging/wfx/traces.h | 74 ++++ drivers/staging/wfx/wfx.h | 58 ++++ 13 files changed, 1783 insertions(+) create mode 100644 drivers/staging/wfx/data_tx.c create mode 100644 drivers/staging/wfx/data_tx.h create mode 100644 drivers/staging/wfx/queue.c create mode 100644 drivers/staging/wfx/queue.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index e158589468a3..d5ac9fafd1f1 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -9,6 +9,9 @@ wfx-y := \ fwio.o \ hif_tx.o \ hif_rx.o \ + queue.o \ + data_tx.o \ + sta.o \ main.o \ sta.o \ debug.o diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index d321fd312d55..ed81c3924d98 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -220,6 +220,8 @@ static int bh_work_tx(struct wfx_dev *wdev, int max_msg) if (try_wait_for_completion(&wdev->hif_cmd.ready)) { WARN(!mutex_is_locked(&wdev->hif_cmd.lock), "data locking error"); hif = wdev->hif_cmd.buf_send; + } else { + hif = wfx_tx_queues_get(wdev); } } if (!hif) diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c new file mode 100644 index 000000000000..217d3c270706 --- /dev/null +++ b/drivers/staging/wfx/data_tx.c @@ -0,0 +1,783 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Datapath implementation. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include + +#include "data_tx.h" +#include "wfx.h" +#include "bh.h" +#include "queue.h" +#include "debug.h" +#include "traces.h" +#include "hif_tx_mib.h" + +#define WFX_INVALID_RATE_ID (0xFF) +#define WFX_LINK_ID_GC_TIMEOUT ((unsigned long)(10 * HZ)) + +static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate *rate) +{ + if (rate->idx < 0) + return -1; + if (rate->flags & IEEE80211_TX_RC_MCS) { + if (rate->idx > 7) { + WARN(1, "wrong rate->idx value: %d", rate->idx); + return -1; + } + return rate->idx + 14; + } + // WFx only support 2GHz, else band information should be retreived + // from ieee80211_tx_info + return wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->bitrates[rate->idx].hw_value; +} + +/* TX policy cache implementation */ + +static void tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, + struct ieee80211_tx_rate *rates) +{ + int i; + size_t count; + struct wfx_dev *wdev = wvif->wdev; + + BUG_ON(rates[0].idx < 0); + memset(policy, 0, sizeof(*policy)); + for (i = 1; i < IEEE80211_TX_MAX_RATES; i++) + if (rates[i].idx < 0) + break; + count = i; + + /* HACK!!! Device has problems (at least) switching from + * 54Mbps CTS to 1Mbps. This switch takes enormous amount + * of time (100-200 ms), leading to valuable throughput drop. + * As a workaround, additional g-rates are injected to the + * policy. + */ + if (count == 2 && !(rates[0].flags & IEEE80211_TX_RC_MCS) && + rates[0].idx > 4 && rates[0].count > 2 && + rates[1].idx < 2) { + int mid_rate = (rates[0].idx + 4) >> 1; + + /* Decrease number of retries for the initial rate */ + rates[0].count -= 2; + + if (mid_rate != 4) { + /* Keep fallback rate at 1Mbps. */ + rates[3] = rates[1]; + + /* Inject 1 transmission on lowest g-rate */ + rates[2].idx = 4; + rates[2].count = 1; + rates[2].flags = rates[1].flags; + + /* Inject 1 transmission on mid-rate */ + rates[1].idx = mid_rate; + rates[1].count = 1; + + /* Fallback to 1 Mbps is a really bad thing, + * so let's try to increase probability of + * successful transmission on the lowest g rate + * even more + */ + if (rates[0].count >= 3) { + --rates[0].count; + ++rates[2].count; + } + + /* Adjust amount of rates defined */ + count += 2; + } else { + /* Keep fallback rate at 1Mbps. */ + rates[2] = rates[1]; + + /* Inject 2 transmissions on lowest g-rate */ + rates[1].idx = 4; + rates[1].count = 2; + + /* Adjust amount of rates defined */ + count += 1; + } + } + + for (i = 0; i < IEEE80211_TX_MAX_RATES; ++i) { + int rateid; + uint8_t count; + + if (rates[i].idx < 0) + break; + WARN_ON(rates[i].count > 15); + rateid = wfx_get_hw_rate(wdev, &rates[i]); + // Pack two values in each byte of policy->rates + count = rates[i].count; + if (rateid % 2) + count <<= 4; + policy->rates[rateid / 2] |= count; + } +} + +static bool tx_policy_is_equal(const struct tx_policy *a, const struct tx_policy *b) +{ + return !memcmp(a->rates, b->rates, sizeof(a->rates)); +} + +static int tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *wanted) +{ + struct tx_policy *it; + + list_for_each_entry(it, &cache->used, link) + if (tx_policy_is_equal(wanted, it)) + return it - cache->cache; + list_for_each_entry(it, &cache->free, link) + if (tx_policy_is_equal(wanted, it)) + return it - cache->cache; + return -1; +} + +static void tx_policy_use(struct tx_policy_cache *cache, struct tx_policy *entry) +{ + ++entry->usage_count; + list_move(&entry->link, &cache->used); +} + +static int tx_policy_release(struct tx_policy_cache *cache, struct tx_policy *entry) +{ + int ret = --entry->usage_count; + + if (!ret) + list_move(&entry->link, &cache->free); + return ret; +} + +static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, + bool *renew) +{ + int idx; + struct tx_policy_cache *cache = &wvif->tx_policy_cache; + struct tx_policy wanted; + + tx_policy_build(wvif, &wanted, rates); + + spin_lock_bh(&cache->lock); + if (WARN_ON_ONCE(list_empty(&cache->free))) { + spin_unlock_bh(&cache->lock); + return WFX_INVALID_RATE_ID; + } + idx = tx_policy_find(cache, &wanted); + if (idx >= 0) { + *renew = false; + } else { + struct tx_policy *entry; + *renew = true; + /* If policy is not found create a new one + * using the oldest entry in "free" list + */ + entry = list_entry(cache->free.prev, struct tx_policy, link); + memcpy(entry->rates, wanted.rates, sizeof(entry->rates)); + entry->uploaded = 0; + entry->usage_count = 0; + idx = entry - cache->cache; + } + tx_policy_use(cache, &cache->cache[idx]); + if (list_empty(&cache->free)) { + /* Lock TX queues. */ + wfx_tx_queues_lock(wvif->wdev); + } + spin_unlock_bh(&cache->lock); + return idx; +} + +static void tx_policy_put(struct wfx_vif *wvif, int idx) +{ + int usage, locked; + struct tx_policy_cache *cache = &wvif->tx_policy_cache; + + spin_lock_bh(&cache->lock); + locked = list_empty(&cache->free); + usage = tx_policy_release(cache, &cache->cache[idx]); + if (locked && !usage) { + /* Unlock TX queues. */ + wfx_tx_queues_unlock(wvif->wdev); + } + spin_unlock_bh(&cache->lock); +} + +static int tx_policy_upload(struct wfx_vif *wvif) +{ + int i; + struct tx_policy_cache *cache = &wvif->tx_policy_cache; + struct hif_mib_set_tx_rate_retry_policy *arg = + kzalloc(struct_size(arg, tx_rate_retry_policy, HIF_MIB_NUM_TX_RATE_RETRY_POLICIES), GFP_KERNEL); + struct hif_mib_tx_rate_retry_policy *dst; + + spin_lock_bh(&cache->lock); + /* Upload only modified entries. */ + for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) { + struct tx_policy *src = &cache->cache[i]; + + if (!src->uploaded && memzcmp(src->rates, sizeof(src->rates))) { + dst = arg->tx_rate_retry_policy + arg->num_tx_rate_policies; + + dst->policy_index = i; + dst->short_retry_count = 255; + dst->long_retry_count = 255; + dst->first_rate_sel = 1; + dst->terminate = 1; + dst->count_init = 1; + memcpy(&dst->rates, src->rates, sizeof(src->rates)); + src->uploaded = 1; + arg->num_tx_rate_policies++; + } + } + spin_unlock_bh(&cache->lock); + hif_set_tx_rate_retry_policy(wvif, arg); + kfree(arg); + return 0; +} + +static void tx_policy_upload_work(struct work_struct *work) +{ + struct wfx_vif *wvif = + container_of(work, struct wfx_vif, tx_policy_upload_work); + + tx_policy_upload(wvif); + + wfx_tx_unlock(wvif->wdev); + wfx_tx_queues_unlock(wvif->wdev); +} + +void tx_policy_init(struct wfx_vif *wvif) +{ + struct tx_policy_cache *cache = &wvif->tx_policy_cache; + int i; + + memset(cache, 0, sizeof(*cache)); + + spin_lock_init(&cache->lock); + INIT_LIST_HEAD(&cache->used); + INIT_LIST_HEAD(&cache->free); + INIT_WORK(&wvif->tx_policy_upload_work, tx_policy_upload_work); + + for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) + list_add(&cache->cache[i].link, &cache->free); +} + +/* Link ID related functions */ + +static int wfx_alloc_link_id(struct wfx_vif *wvif, const u8 *mac) +{ + int i, ret = 0; + unsigned long max_inactivity = 0; + unsigned long now = jiffies; + + spin_lock_bh(&wvif->ps_state_lock); + for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) { + if (!wvif->link_id_db[i].status) { + ret = i + 1; + break; + } else if (wvif->link_id_db[i].status != WFX_LINK_HARD && + !wvif->wdev->tx_queue_stats.link_map_cache[i + 1]) { + unsigned long inactivity = + now - wvif->link_id_db[i].timestamp; + + if (inactivity < max_inactivity) + continue; + max_inactivity = inactivity; + ret = i + 1; + } + } + + if (ret) { + struct wfx_link_entry *entry = &wvif->link_id_db[ret - 1]; + + entry->status = WFX_LINK_RESERVE; + ether_addr_copy(entry->mac, mac); + memset(&entry->buffered, 0, WFX_MAX_TID); + skb_queue_head_init(&entry->rx_queue); + wfx_tx_lock(wvif->wdev); + + if (!schedule_work(&wvif->link_id_work)) + wfx_tx_unlock(wvif->wdev); + } else { + dev_info(wvif->wdev->dev, "no more link-id available\n"); + } + spin_unlock_bh(&wvif->ps_state_lock); + return ret; +} + +int wfx_find_link_id(struct wfx_vif *wvif, const u8 *mac) +{ + int i, ret = 0; + + spin_lock_bh(&wvif->ps_state_lock); + for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) { + if (ether_addr_equal(mac, wvif->link_id_db[i].mac) && + wvif->link_id_db[i].status) { + wvif->link_id_db[i].timestamp = jiffies; + ret = i + 1; + break; + } + } + spin_unlock_bh(&wvif->ps_state_lock); + return ret; +} + +static int wfx_map_link(struct wfx_vif *wvif, struct wfx_link_entry *link_entry, int sta_id) +{ + int ret; + + ret = hif_map_link(wvif, link_entry->mac, 0, sta_id); + + if (ret == 0) + /* Save the MAC address currently associated with the peer + * for future unmap request + */ + ether_addr_copy(link_entry->old_mac, link_entry->mac); + + return ret; +} + +int wfx_unmap_link(struct wfx_vif *wvif, int sta_id) +{ + u8 *mac_addr = NULL; + + if (sta_id) + mac_addr = wvif->link_id_db[sta_id - 1].old_mac; + + return hif_map_link(wvif, mac_addr, 1, sta_id); +} + +void wfx_link_id_gc_work(struct work_struct *work) +{ + struct wfx_vif *wvif = + container_of(work, struct wfx_vif, link_id_gc_work.work); + unsigned long now = jiffies; + unsigned long next_gc = -1; + long ttl; + u32 mask; + int i; + + wfx_tx_lock_flush(wvif->wdev); + spin_lock_bh(&wvif->ps_state_lock); + for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) { + bool need_reset = false; + + mask = BIT(i + 1); + if (wvif->link_id_db[i].status == WFX_LINK_RESERVE || + (wvif->link_id_db[i].status == WFX_LINK_HARD && + !(wvif->link_id_map & mask))) { + if (wvif->link_id_map & mask) { + wvif->sta_asleep_mask &= ~mask; + wvif->pspoll_mask &= ~mask; + need_reset = true; + } + wvif->link_id_map |= mask; + if (wvif->link_id_db[i].status != WFX_LINK_HARD) + wvif->link_id_db[i].status = WFX_LINK_SOFT; + + spin_unlock_bh(&wvif->ps_state_lock); + if (need_reset) + wfx_unmap_link(wvif, i + 1); + wfx_map_link(wvif, &wvif->link_id_db[i], i + 1); + next_gc = min(next_gc, WFX_LINK_ID_GC_TIMEOUT); + spin_lock_bh(&wvif->ps_state_lock); + } else if (wvif->link_id_db[i].status == WFX_LINK_SOFT) { + ttl = wvif->link_id_db[i].timestamp - now + + WFX_LINK_ID_GC_TIMEOUT; + if (ttl <= 0) { + need_reset = true; + wvif->link_id_db[i].status = WFX_LINK_OFF; + wvif->link_id_map &= ~mask; + wvif->sta_asleep_mask &= ~mask; + wvif->pspoll_mask &= ~mask; + spin_unlock_bh(&wvif->ps_state_lock); + wfx_unmap_link(wvif, i + 1); + spin_lock_bh(&wvif->ps_state_lock); + } else { + next_gc = min_t(unsigned long, next_gc, ttl); + } + } + if (need_reset) + skb_queue_purge(&wvif->link_id_db[i].rx_queue); + } + spin_unlock_bh(&wvif->ps_state_lock); + if (next_gc != -1) + schedule_delayed_work(&wvif->link_id_gc_work, next_gc); + wfx_tx_unlock(wvif->wdev); +} + +void wfx_link_id_work(struct work_struct *work) +{ + struct wfx_vif *wvif = + container_of(work, struct wfx_vif, link_id_work); + + wfx_tx_flush(wvif->wdev); + wfx_link_id_gc_work(&wvif->link_id_gc_work.work); + wfx_tx_unlock(wvif->wdev); +} + +/* Tx implementation */ + +static bool ieee80211_is_action_back(struct ieee80211_hdr *hdr) +{ + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) hdr; + + if (!ieee80211_is_action(mgmt->frame_control)) + return false; + if (mgmt->u.action.category != WLAN_CATEGORY_BACK) + return false; + return true; +} + +static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, + struct wfx_tx_priv *tx_priv, struct ieee80211_sta *sta) +{ + u32 mask = ~BIT(tx_priv->raw_link_id); + + spin_lock_bh(&wvif->ps_state_lock); + if (ieee80211_is_auth(hdr->frame_control)) { + wvif->sta_asleep_mask &= mask; + wvif->pspoll_mask &= mask; + } + + if (tx_priv->link_id == WFX_LINK_ID_AFTER_DTIM && !wvif->mcast_buffered) { + wvif->mcast_buffered = true; + if (wvif->sta_asleep_mask) + schedule_work(&wvif->mcast_start_work); + } + + if (tx_priv->raw_link_id) { + wvif->link_id_db[tx_priv->raw_link_id - 1].timestamp = jiffies; + if (tx_priv->tid < WFX_MAX_TID) + wvif->link_id_db[tx_priv->raw_link_id - 1].buffered[tx_priv->tid]++; + } + spin_unlock_bh(&wvif->ps_state_lock); + + if (sta) + ieee80211_sta_set_buffered(sta, tx_priv->tid, true); +} + +static uint8_t wfx_tx_get_raw_link_id(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct ieee80211_hdr *hdr) +{ + struct wfx_sta_priv *sta_priv = sta ? (struct wfx_sta_priv *) &sta->drv_priv : NULL; + const u8 *da = ieee80211_get_DA(hdr); + int ret; + + if (sta_priv && sta_priv->link_id) + return sta_priv->link_id; + if (wvif->vif->type != NL80211_IFTYPE_AP) + return 0; + if (is_multicast_ether_addr(da)) + return 0; + ret = wfx_find_link_id(wvif, da); + if (!ret) + ret = wfx_alloc_link_id(wvif, da); + if (!ret) { + dev_err(wvif->wdev->dev, "no more link-id available\n"); + return -ENOENT; + } + return ret; +} + +static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates) +{ + int i; + bool finished; + + // Firmware is not able to mix rates with differents flags + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { + if (rates[0].flags & IEEE80211_TX_RC_SHORT_GI) + rates[i].flags |= IEEE80211_TX_RC_SHORT_GI; + if (!(rates[0].flags & IEEE80211_TX_RC_SHORT_GI)) + rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI; + if (!(rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS)) + rates[i].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS; + } + + // Sort rates and remove duplicates + do { + finished = true; + for (i = 0; i < IEEE80211_TX_MAX_RATES - 1; i++) { + if (rates[i + 1].idx == rates[i].idx && rates[i].idx != -1) { + rates[i].count = max_t(int, rates[i].count, rates[i + 1].count); + rates[i + 1].idx = -1; + rates[i + 1].count = 0; + + finished = false; + } + if (rates[i + 1].idx > rates[i].idx) { + swap(rates[i + 1], rates[i]); + finished = false; + } + } + } while (!finished); + // All retries use long GI + for (i = 1; i < IEEE80211_TX_MAX_RATES; i++) + rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI; +} + +static uint8_t wfx_tx_get_rate_id(struct wfx_vif *wvif, struct ieee80211_tx_info *tx_info) +{ + bool tx_policy_renew = false; + uint8_t rate_id; + + rate_id = tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); + WARN(rate_id == WFX_INVALID_RATE_ID, "unable to get a valid Tx policy"); + + if (tx_policy_renew) { + /* FIXME: It's not so optimal to stop TX queues every now and + * then. Better to reimplement task scheduling with a counter. + */ + wfx_tx_lock(wvif->wdev); + wfx_tx_queues_lock(wvif->wdev); + if (!schedule_work(&wvif->tx_policy_upload_work)) { + wfx_tx_queues_unlock(wvif->wdev); + wfx_tx_unlock(wvif->wdev); + } + } + return rate_id; +} + +static struct hif_ht_tx_parameters wfx_tx_get_tx_parms(struct wfx_dev *wdev, struct ieee80211_tx_info *tx_info) +{ + struct ieee80211_tx_rate *rate = &tx_info->driver_rates[0]; + struct hif_ht_tx_parameters ret = { }; + + if (!(rate->flags & IEEE80211_TX_RC_MCS)) + ret.frame_format = HIF_FRAME_FORMAT_NON_HT; + else if (!(rate->flags & IEEE80211_TX_RC_GREEN_FIELD)) + ret.frame_format = HIF_FRAME_FORMAT_MIXED_FORMAT_HT; + else + ret.frame_format = HIF_FRAME_FORMAT_GF_HT_11N; + if (rate->flags & IEEE80211_TX_RC_SHORT_GI) + ret.short_gi = 1; + if (tx_info->flags & IEEE80211_TX_CTL_STBC) + ret.stbc = 0; // FIXME: Not yet supported by firmware? + return ret; +} + +static uint8_t wfx_tx_get_tid(struct ieee80211_hdr *hdr) +{ + // FIXME: ieee80211_get_tid(hdr) should be sufficient for all cases. + if (!ieee80211_is_data(hdr->frame_control)) + return WFX_MAX_TID; + if (ieee80211_is_data_qos(hdr->frame_control)) + return ieee80211_get_tid(hdr); + else + return 0; +} + +static int wfx_tx_get_icv_len(struct ieee80211_key_conf *hw_key) +{ + int mic_space; + + if (!hw_key) + return 0; + mic_space = (hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) ? 8 : 0; + return hw_key->icv_len + mic_space; +} + +static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct sk_buff *skb) +{ + struct hif_msg *hif_msg; + struct hif_req_tx *req; + struct wfx_tx_priv *tx_priv; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + int queue_id = tx_info->hw_queue; + size_t offset = (size_t) skb->data & 3; + int wmsg_len = sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + offset; + + WARN(queue_id >= IEEE80211_NUM_ACS, "unsupported queue_id"); + wfx_tx_fixup_rates(tx_info->driver_rates); + + // From now tx_info->control is unusable + memset(tx_info->rate_driver_data, 0, sizeof(struct wfx_tx_priv)); + // Fill tx_priv + tx_priv = (struct wfx_tx_priv *) tx_info->rate_driver_data; + tx_priv->tid = wfx_tx_get_tid(hdr); + tx_priv->raw_link_id = wfx_tx_get_raw_link_id(wvif, sta, hdr); + tx_priv->link_id = tx_priv->raw_link_id; + if (ieee80211_has_protected(hdr->frame_control)) + tx_priv->hw_key = hw_key; + if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) + tx_priv->link_id = WFX_LINK_ID_AFTER_DTIM; + if (sta && (sta->uapsd_queues & BIT(queue_id))) + tx_priv->link_id = WFX_LINK_ID_UAPSD; + + // Fill hif_msg + WARN(skb_headroom(skb) < wmsg_len, "not enough space in skb"); + WARN(offset & 1, "attempt to transmit an unaligned frame"); + skb_put(skb, wfx_tx_get_icv_len(tx_priv->hw_key)); + skb_push(skb, wmsg_len); + memset(skb->data, 0, wmsg_len); + hif_msg = (struct hif_msg *) skb->data; + hif_msg->len = cpu_to_le16(skb->len); + hif_msg->id = cpu_to_le16(HIF_REQ_ID_TX); + hif_msg->interface = wvif->id; + if (skb->len > wvif->wdev->hw_caps.size_inp_ch_buf) { + dev_warn(wvif->wdev->dev, "requested frame size (%d) is larger than maximum supported (%d)\n", + skb->len, wvif->wdev->hw_caps.size_inp_ch_buf); + skb_pull(skb, wmsg_len); + return -EIO; + } + + // Fill tx request + req = (struct hif_req_tx *) hif_msg->body; + req->packet_id = queue_id << 16 | IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); + req->data_flags.fc_offset = offset; + req->queue_id.peer_sta_id = tx_priv->raw_link_id; + // Queue index are inverted between firmware and Linux + req->queue_id.queue_id = 3 - queue_id; + req->ht_tx_parameters = wfx_tx_get_tx_parms(wvif->wdev, tx_info); + req->tx_flags.retry_policy_index = wfx_tx_get_rate_id(wvif, tx_info); + + // Auxilliary operations + wfx_tx_manage_pm(wvif, hdr, tx_priv, sta); + wfx_tx_queue_put(wvif->wdev, &wvif->wdev->tx_queue[queue_id], skb); + wfx_bh_request_tx(wvif->wdev); + return 0; +} + +void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, + struct sk_buff *skb) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif; + struct ieee80211_sta *sta = control ? control->sta : NULL; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + size_t driver_data_room = FIELD_SIZEOF(struct ieee80211_tx_info, rate_driver_data); + + compiletime_assert(sizeof(struct wfx_tx_priv) <= driver_data_room, + "struct tx_priv is too large"); + WARN(skb->next || skb->prev, "skb is already member of a list"); + // control.vif can be NULL for injected frames + if (tx_info->control.vif) + wvif = (struct wfx_vif *) tx_info->control.vif->drv_priv; + else + wvif = wvif_iterate(wdev, NULL); + if (WARN_ON(!wvif)) + goto drop; + // FIXME: why? + if (ieee80211_is_action_back(hdr)) { + dev_info(wdev->dev, "drop BA action\n"); + goto drop; + } + if (wfx_tx_inner(wvif, sta, skb)) + goto drop; + + return; + +drop: + ieee80211_tx_status_irqsafe(wdev->hw, skb); +} + +void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) +{ + int i; + int tx_count; + struct sk_buff *skb; + struct ieee80211_tx_rate *rate; + struct ieee80211_tx_info *tx_info; + const struct wfx_tx_priv *tx_priv; + + skb = wfx_pending_get(wvif->wdev, arg->packet_id); + if (!skb) { + dev_warn(wvif->wdev->dev, "received unknown packet_id (%#.8x) from chip\n", arg->packet_id); + return; + } + tx_info = IEEE80211_SKB_CB(skb); + tx_priv = wfx_skb_tx_priv(skb); + _trace_tx_stats(arg, skb, wfx_pending_get_pkt_us_delay(wvif->wdev, skb)); + + // You can touch to tx_priv, but don't touch to tx_info->status. + tx_count = arg->ack_failures; + if (!arg->status || arg->ack_failures) + tx_count += 1; // Also report success + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { + rate = &tx_info->status.rates[i]; + if (rate->idx < 0) + break; + if (tx_count < rate->count && arg->status && arg->ack_failures) + dev_dbg(wvif->wdev->dev, "all retries were not consumed: %d != %d\n", + rate->count, tx_count); + if (tx_count <= rate->count && tx_count && arg->txed_rate != wfx_get_hw_rate(wvif->wdev, rate)) + dev_dbg(wvif->wdev->dev, "inconsistent tx_info rates: %d != %d\n", + arg->txed_rate, wfx_get_hw_rate(wvif->wdev, rate)); + if (tx_count > rate->count) { + tx_count -= rate->count; + } else if (!tx_count) { + rate->count = 0; + rate->idx = -1; + } else { + rate->count = tx_count; + tx_count = 0; + } + } + if (tx_count) + dev_dbg(wvif->wdev->dev, "%d more retries than expected\n", tx_count); + skb_trim(skb, skb->len - wfx_tx_get_icv_len(tx_priv->hw_key)); + + // From now, you can touch to tx_info->status, but do not touch to + // tx_priv anymore + // FIXME: use ieee80211_tx_info_clear_status() + memset(tx_info->rate_driver_data, 0, sizeof(tx_info->rate_driver_data)); + memset(tx_info->pad, 0, sizeof(tx_info->pad)); + + if (!arg->status) { + tx_info->status.tx_time = arg->media_delay - arg->tx_queue_delay; + if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) + tx_info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; + else + tx_info->flags |= IEEE80211_TX_STAT_ACK; + } else if (arg->status == HIF_REQUEUE) { + WARN(!arg->tx_result_flags.requeue, "incoherent status and result_flags"); + tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; + } + wfx_pending_remove(wvif->wdev, skb); +} + +static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb, + struct hif_req_tx *req) +{ + struct ieee80211_sta *sta; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + int tid = wfx_tx_get_tid(hdr); + int raw_link_id = req->queue_id.peer_sta_id; + u8 *buffered; + + if (raw_link_id && tid < WFX_MAX_TID) { + buffered = wvif->link_id_db[raw_link_id - 1].buffered; + + spin_lock_bh(&wvif->ps_state_lock); + WARN(!buffered[tid], "inconsistent notification"); + buffered[tid]--; + spin_unlock_bh(&wvif->ps_state_lock); + + if (!buffered[tid]) { + rcu_read_lock(); + sta = ieee80211_find_sta(wvif->vif, hdr->addr1); + if (sta) + ieee80211_sta_set_buffered(sta, tid, false); + rcu_read_unlock(); + } + } +} + +void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb) +{ + struct hif_msg *hif = (struct hif_msg *) skb->data; + struct hif_req_tx *req = (struct hif_req_tx *) hif->body; + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + unsigned int offset = sizeof(struct hif_req_tx) + sizeof(struct hif_msg) + req->data_flags.fc_offset; + + WARN_ON(!wvif); + skb_pull(skb, offset); + wfx_notify_buffered_tx(wvif, skb, req); + tx_policy_put(wvif, req->tx_flags.retry_policy_index); + ieee80211_tx_status_irqsafe(wdev->hw, skb); +} diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h new file mode 100644 index 000000000000..f59a259bb744 --- /dev/null +++ b/drivers/staging/wfx/data_tx.h @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Datapath implementation. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_DATA_TX_H +#define WFX_DATA_TX_H + +#include +#include + +#include "hif_api_cmd.h" +#include "hif_api_mib.h" + +// FIXME: use IEEE80211_NUM_TIDS +#define WFX_MAX_TID 8 + +struct wfx_tx_priv; +struct wfx_dev; +struct wfx_vif; + +enum wfx_link_status { + WFX_LINK_OFF, + WFX_LINK_RESERVE, + WFX_LINK_SOFT, + WFX_LINK_HARD, +}; + +struct wfx_link_entry { + unsigned long timestamp; + enum wfx_link_status status; + uint8_t mac[ETH_ALEN]; + uint8_t old_mac[ETH_ALEN]; + uint8_t buffered[WFX_MAX_TID]; + struct sk_buff_head rx_queue; +}; + +struct tx_policy { + struct list_head link; + uint8_t rates[12]; + uint8_t usage_count; + uint8_t uploaded; +}; + +struct tx_policy_cache { + struct tx_policy cache[HIF_MIB_NUM_TX_RATE_RETRY_POLICIES]; + // FIXME: use a trees and drop hash from tx_policy + struct list_head used; + struct list_head free; + spinlock_t lock; +}; + +struct wfx_tx_priv { + ktime_t xmit_timestamp; + struct ieee80211_key_conf *hw_key; + uint8_t link_id; + uint8_t raw_link_id; + uint8_t tid; +} __packed; + +void tx_policy_init(struct wfx_vif *wvif); + +void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, + struct sk_buff *skb); +void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg); +void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb); + +int wfx_unmap_link(struct wfx_vif *wvif, int link_id); +void wfx_link_id_work(struct work_struct *work); +void wfx_link_id_gc_work(struct work_struct *work); +int wfx_find_link_id(struct wfx_vif *wvif, const u8 *mac); + +static inline struct wfx_tx_priv *wfx_skb_tx_priv(struct sk_buff *skb) +{ + struct ieee80211_tx_info *tx_info; + + if (!skb) + return NULL; + tx_info = IEEE80211_SKB_CB(skb); + return (struct wfx_tx_priv *) tx_info->rate_driver_data; +} + +static inline struct hif_req_tx *wfx_skb_txreq(struct sk_buff *skb) +{ + struct hif_msg *hif = (struct hif_msg *) skb->data; + struct hif_req_tx *req = (struct hif_req_tx *) hif->body; + + return req; +} + +#endif /* WFX_DATA_TX_H */ diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index c93bae1b6acf..97c4c2f082fb 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -53,6 +53,39 @@ static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void * return status; } +static int hif_tx_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_cnf_tx *body = buf; + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + + WARN_ON(!wvif); + if (!wvif) + return -EFAULT; + + wfx_tx_confirm_cb(wvif, body); + return 0; +} + +static int hif_multi_tx_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct hif_cnf_multi_transmit *body = buf; + struct hif_cnf_tx *buf_loc = (struct hif_cnf_tx *) &body->tx_conf_payload; + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + int count = body->num_tx_confs; + int i; + + WARN(count <= 0, "corrupted message"); + WARN_ON(!wvif); + if (!wvif) + return -EFAULT; + + for (i = 0; i < count; ++i) { + wfx_tx_confirm_cb(wvif, buf_loc); + buf_loc++; + } + return 0; +} + static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct hif_ind_startup *body = buf; @@ -174,6 +207,10 @@ static const struct { int msg_id; int (*handler)(struct wfx_dev *wdev, struct hif_msg *hif, void *buf); } hif_handlers[] = { + /* Confirmations */ + { HIF_CNF_ID_TX, hif_tx_confirm }, + { HIF_CNF_ID_MULTI_TRANSMIT, hif_multi_tx_confirm }, + /* Indications */ { HIF_IND_ID_STARTUP, hif_startup_indication }, { HIF_IND_ID_WAKEUP, hif_wakeup_indication }, { HIF_IND_ID_JOIN_COMPLETE, hif_join_complete_indication }, diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index f8ab871aa188..157ab177b73f 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -88,6 +88,7 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, siz } if (!ret) { dev_err(wdev->dev, "chip did not answer\n"); + wfx_pending_dump_old_frames(wdev, 3000); wdev->chip_frozen = 1; reinit_completion(&wdev->hif_cmd.done); ret = -ETIMEDOUT; diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 2e71f446d4d4..cce4e30dd94a 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -28,6 +28,7 @@ #include "bh.h" #include "sta.h" #include "debug.h" +#include "data_tx.h" #include "secure_link.h" #include "hif_tx_mib.h" #include "hif_api_cmd.h" @@ -53,6 +54,7 @@ static const struct ieee80211_ops wfx_ops = { .stop = wfx_stop, .add_interface = wfx_add_interface, .remove_interface = wfx_remove_interface, + .tx = wfx_tx, }; bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) @@ -215,6 +217,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, mutex_init(&wdev->rx_stats_lock); init_completion(&wdev->firmware_ready); wfx_init_hif_cmd(&wdev->hif_cmd); + wfx_tx_queues_init(wdev); return wdev; } @@ -222,6 +225,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, void wfx_free_common(struct wfx_dev *wdev) { mutex_destroy(&wdev->rx_stats_lock); + wfx_tx_queues_deinit(wdev); ieee80211_free_hw(wdev->hw); } diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c new file mode 100644 index 000000000000..aa438be21d37 --- /dev/null +++ b/drivers/staging/wfx/queue.c @@ -0,0 +1,526 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * O(1) TX queue with built-in allocator. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "queue.h" +#include "wfx.h" +#include "sta.h" +#include "data_tx.h" + +void wfx_tx_lock(struct wfx_dev *wdev) +{ + atomic_inc(&wdev->tx_lock); +} + +void wfx_tx_unlock(struct wfx_dev *wdev) +{ + int tx_lock = atomic_dec_return(&wdev->tx_lock); + + WARN(tx_lock < 0, "inconsistent tx_lock value"); + if (!tx_lock) + wfx_bh_request_tx(wdev); +} + +void wfx_tx_flush(struct wfx_dev *wdev) +{ + int ret; + + WARN(!atomic_read(&wdev->tx_lock), "tx_lock is not locked"); + + // Do not wait for any reply if chip is frozen + if (wdev->chip_frozen) + return; + + mutex_lock(&wdev->hif_cmd.lock); + ret = wait_event_timeout(wdev->hif.tx_buffers_empty, + !wdev->hif.tx_buffers_used, + msecs_to_jiffies(3000)); + if (!ret) { + dev_warn(wdev->dev, "cannot flush tx buffers (%d still busy)\n", wdev->hif.tx_buffers_used); + wfx_pending_dump_old_frames(wdev, 3000); + // FIXME: drop pending frames here + wdev->chip_frozen = 1; + } + mutex_unlock(&wdev->hif_cmd.lock); +} + +void wfx_tx_lock_flush(struct wfx_dev *wdev) +{ + wfx_tx_lock(wdev); + wfx_tx_flush(wdev); +} + +void wfx_tx_queues_lock(struct wfx_dev *wdev) +{ + int i; + struct wfx_queue *queue; + + for (i = 0; i < IEEE80211_NUM_ACS; ++i) { + queue = &wdev->tx_queue[i]; + spin_lock_bh(&queue->queue.lock); + if (queue->tx_locked_cnt++ == 0) + ieee80211_stop_queue(wdev->hw, queue->queue_id); + spin_unlock_bh(&queue->queue.lock); + } +} + +void wfx_tx_queues_unlock(struct wfx_dev *wdev) +{ + int i; + struct wfx_queue *queue; + + for (i = 0; i < IEEE80211_NUM_ACS; ++i) { + queue = &wdev->tx_queue[i]; + spin_lock_bh(&queue->queue.lock); + BUG_ON(!queue->tx_locked_cnt); + if (--queue->tx_locked_cnt == 0) + ieee80211_wake_queue(wdev->hw, queue->queue_id); + spin_unlock_bh(&queue->queue.lock); + } +} + +/* If successful, LOCKS the TX queue! */ +void wfx_tx_queues_wait_empty_vif(struct wfx_vif *wvif) +{ + int i; + bool done; + struct wfx_queue *queue; + struct sk_buff *item; + struct wfx_dev *wdev = wvif->wdev; + struct hif_msg *hif; + + if (wvif->wdev->chip_frozen) { + wfx_tx_lock_flush(wdev); + wfx_tx_queues_clear(wdev); + return; + } + + do { + done = true; + wfx_tx_lock_flush(wdev); + for (i = 0; i < IEEE80211_NUM_ACS && done; ++i) { + queue = &wdev->tx_queue[i]; + spin_lock_bh(&queue->queue.lock); + skb_queue_walk(&queue->queue, item) { + hif = (struct hif_msg *) item->data; + if (hif->interface == wvif->id) + done = false; + } + spin_unlock_bh(&queue->queue.lock); + } + if (!done) { + wfx_tx_unlock(wdev); + msleep(20); + } + } while (!done); +} + +static void wfx_tx_queue_clear(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff_head *gc_list) +{ + int i; + struct sk_buff *item; + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + + spin_lock_bh(&queue->queue.lock); + while ((item = __skb_dequeue(&queue->queue)) != NULL) + skb_queue_head(gc_list, item); + spin_lock_bh(&stats->pending.lock); + for (i = 0; i < ARRAY_SIZE(stats->link_map_cache); ++i) { + stats->link_map_cache[i] -= queue->link_map_cache[i]; + queue->link_map_cache[i] = 0; + } + spin_unlock_bh(&stats->pending.lock); + spin_unlock_bh(&queue->queue.lock); +} + +void wfx_tx_queues_clear(struct wfx_dev *wdev) +{ + int i; + struct sk_buff *item; + struct sk_buff_head gc_list; + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + + skb_queue_head_init(&gc_list); + for (i = 0; i < IEEE80211_NUM_ACS; ++i) + wfx_tx_queue_clear(wdev, &wdev->tx_queue[i], &gc_list); + wake_up(&stats->wait_link_id_empty); + while ((item = skb_dequeue(&gc_list)) != NULL) + wfx_skb_dtor(wdev, item); +} + +void wfx_tx_queues_init(struct wfx_dev *wdev) +{ + int i; + + memset(&wdev->tx_queue_stats, 0, sizeof(wdev->tx_queue_stats)); + memset(wdev->tx_queue, 0, sizeof(wdev->tx_queue)); + skb_queue_head_init(&wdev->tx_queue_stats.pending); + init_waitqueue_head(&wdev->tx_queue_stats.wait_link_id_empty); + + for (i = 0; i < IEEE80211_NUM_ACS; ++i) { + wdev->tx_queue[i].queue_id = i; + skb_queue_head_init(&wdev->tx_queue[i].queue); + } +} + +void wfx_tx_queues_deinit(struct wfx_dev *wdev) +{ + WARN_ON(!skb_queue_empty(&wdev->tx_queue_stats.pending)); + wfx_tx_queues_clear(wdev); +} + +size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, + u32 link_id_map) +{ + size_t ret; + int i, bit; + + if (!link_id_map) + return 0; + + spin_lock_bh(&queue->queue.lock); + if (link_id_map == (u32)-1) { + ret = skb_queue_len(&queue->queue); + } else { + ret = 0; + for (i = 0, bit = 1; i < ARRAY_SIZE(queue->link_map_cache); ++i, bit <<= 1) { + if (link_id_map & bit) + ret += queue->link_map_cache[i]; + } + } + spin_unlock_bh(&queue->queue.lock); + return ret; +} + +void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff *skb) +{ + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); + + WARN(tx_priv->link_id >= ARRAY_SIZE(stats->link_map_cache), "invalid link-id value"); + spin_lock_bh(&queue->queue.lock); + __skb_queue_tail(&queue->queue, skb); + + ++queue->link_map_cache[tx_priv->link_id]; + + spin_lock_bh(&stats->pending.lock); + ++stats->link_map_cache[tx_priv->link_id]; + spin_unlock_bh(&stats->pending.lock); + spin_unlock_bh(&queue->queue.lock); +} + +struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue *queue, u32 link_id_map) +{ + struct sk_buff *skb = NULL; + struct sk_buff *item; + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + struct wfx_tx_priv *tx_priv; + bool wakeup_stats = false; + + spin_lock_bh(&queue->queue.lock); + skb_queue_walk(&queue->queue, item) { + tx_priv = wfx_skb_tx_priv(item); + if (link_id_map & BIT(tx_priv->link_id)) { + skb = item; + break; + } + } + WARN_ON(!skb); + if (skb) { + tx_priv = wfx_skb_tx_priv(skb); + tx_priv->xmit_timestamp = ktime_get(); + __skb_unlink(skb, &queue->queue); + --queue->link_map_cache[tx_priv->link_id]; + + spin_lock_bh(&stats->pending.lock); + __skb_queue_tail(&stats->pending, skb); + if (!--stats->link_map_cache[tx_priv->link_id]) + wakeup_stats = true; + spin_unlock_bh(&stats->pending.lock); + } + spin_unlock_bh(&queue->queue.lock); + if (wakeup_stats) + wake_up(&stats->wait_link_id_empty); + return skb; +} + +int wfx_pending_requeue(struct wfx_dev *wdev, struct sk_buff *skb) +{ + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); + struct wfx_queue *queue = &wdev->tx_queue[skb_get_queue_mapping(skb)]; + + WARN_ON(skb_get_queue_mapping(skb) > 3); + spin_lock_bh(&queue->queue.lock); + ++queue->link_map_cache[tx_priv->link_id]; + + spin_lock_bh(&stats->pending.lock); + ++stats->link_map_cache[tx_priv->link_id]; + __skb_unlink(skb, &stats->pending); + spin_unlock_bh(&stats->pending.lock); + __skb_queue_tail(&queue->queue, skb); + spin_unlock_bh(&queue->queue.lock); + return 0; +} + +int wfx_pending_remove(struct wfx_dev *wdev, struct sk_buff *skb) +{ + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + + spin_lock_bh(&stats->pending.lock); + __skb_unlink(skb, &stats->pending); + spin_unlock_bh(&stats->pending.lock); + wfx_skb_dtor(wdev, skb); + + return 0; +} + +struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id) +{ + struct sk_buff *skb; + struct hif_req_tx *req; + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + + spin_lock_bh(&stats->pending.lock); + skb_queue_walk(&stats->pending, skb) { + req = wfx_skb_txreq(skb); + if (req->packet_id == packet_id) { + spin_unlock_bh(&stats->pending.lock); + return skb; + } + } + WARN_ON(1); + spin_unlock_bh(&stats->pending.lock); + return NULL; +} + +void wfx_pending_dump_old_frames(struct wfx_dev *wdev, unsigned int limit_ms) +{ + struct wfx_queue_stats *stats = &wdev->tx_queue_stats; + ktime_t now = ktime_get(); + struct wfx_tx_priv *tx_priv; + struct hif_req_tx *req; + struct sk_buff *skb; + bool first = true; + + spin_lock_bh(&stats->pending.lock); + skb_queue_walk(&stats->pending, skb) { + tx_priv = wfx_skb_tx_priv(skb); + req = wfx_skb_txreq(skb); + if (ktime_after(now, ktime_add_ms(tx_priv->xmit_timestamp, limit_ms))) { + if (first) { + dev_info(wdev->dev, "frames stuck in firmware since %dms or more:\n", + limit_ms); + first = false; + } + dev_info(wdev->dev, " id %08x sent %lldms ago\n", + req->packet_id, + ktime_ms_delta(now, tx_priv->xmit_timestamp)); + } + } + spin_unlock_bh(&stats->pending.lock); +} + +unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb) +{ + ktime_t now = ktime_get(); + struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); + + return ktime_us_delta(now, tx_priv->xmit_timestamp); +} + +bool wfx_tx_queues_is_empty(struct wfx_dev *wdev) +{ + int i; + struct sk_buff_head *queue; + bool ret = true; + + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + queue = &wdev->tx_queue[i].queue; + spin_lock_bh(&queue->lock); + if (!skb_queue_empty(queue)) + ret = false; + spin_unlock_bh(&queue->lock); + } + return ret; +} + +static int wfx_get_prio_queue(struct wfx_vif *wvif, + u32 tx_allowed_mask, int *total) +{ + static const int urgent = BIT(WFX_LINK_ID_AFTER_DTIM) | + BIT(WFX_LINK_ID_UAPSD); + struct hif_req_edca_queue_params *edca; + unsigned int score, best = -1; + int winner = -1; + int i; + + /* search for a winner using edca params */ + for (i = 0; i < IEEE80211_NUM_ACS; ++i) { + int queued; + + edca = &wvif->edca.params[i]; + queued = wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[i], + tx_allowed_mask); + if (!queued) + continue; + *total += queued; + score = ((edca->aifsn + edca->cw_min) << 16) + + ((edca->cw_max - edca->cw_min) * + (get_random_int() & 0xFFFF)); + if (score < best && (winner < 0 || i != 3)) { + best = score; + winner = i; + } + } + + /* override winner if bursting */ + if (winner >= 0 && wvif->wdev->tx_burst_idx >= 0 && + winner != wvif->wdev->tx_burst_idx && + !wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[winner], tx_allowed_mask & urgent) && + wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[wvif->wdev->tx_burst_idx], tx_allowed_mask)) + winner = wvif->wdev->tx_burst_idx; + + return winner; +} + +static int wfx_tx_queue_mask_get(struct wfx_vif *wvif, + struct wfx_queue **queue_p, + u32 *tx_allowed_mask_p, + bool *more) +{ + int idx; + u32 tx_allowed_mask; + int total = 0; + + /* Search for a queue with multicast frames buffered */ + if (wvif->mcast_tx) { + tx_allowed_mask = BIT(WFX_LINK_ID_AFTER_DTIM); + idx = wfx_get_prio_queue(wvif, tx_allowed_mask, &total); + if (idx >= 0) { + *more = total > 1; + goto found; + } + } + + /* Search for unicast traffic */ + tx_allowed_mask = ~wvif->sta_asleep_mask; + tx_allowed_mask |= BIT(WFX_LINK_ID_UAPSD); + if (wvif->sta_asleep_mask) { + tx_allowed_mask |= wvif->pspoll_mask; + tx_allowed_mask &= ~BIT(WFX_LINK_ID_AFTER_DTIM); + } else { + tx_allowed_mask |= BIT(WFX_LINK_ID_AFTER_DTIM); + } + idx = wfx_get_prio_queue(wvif, tx_allowed_mask, &total); + if (idx < 0) + return -ENOENT; + +found: + *queue_p = &wvif->wdev->tx_queue[idx]; + *tx_allowed_mask_p = tx_allowed_mask; + return 0; +} + +struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) +{ + struct sk_buff *skb; + struct hif_msg *hif = NULL; + struct hif_req_tx *req = NULL; + struct wfx_queue *queue = NULL; + struct wfx_queue *vif_queue = NULL; + u32 tx_allowed_mask = 0; + u32 vif_tx_allowed_mask = 0; + const struct wfx_tx_priv *tx_priv = NULL; + struct wfx_vif *wvif; + /* More is used only for broadcasts. */ + bool more = false; + bool vif_more = false; + int not_found; + int burst; + + for (;;) { + int ret = -ENOENT; + int queue_num; + struct ieee80211_hdr *hdr; + + if (atomic_read(&wdev->tx_lock)) + return NULL; + + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + spin_lock_bh(&wvif->ps_state_lock); + + not_found = wfx_tx_queue_mask_get(wvif, &vif_queue, &vif_tx_allowed_mask, &vif_more); + + if (wvif->mcast_buffered && (not_found || !vif_more) && + (wvif->mcast_tx || !wvif->sta_asleep_mask)) { + wvif->mcast_buffered = false; + if (wvif->mcast_tx) { + wvif->mcast_tx = false; + schedule_work(&wvif->mcast_stop_work); + } + } + + spin_unlock_bh(&wvif->ps_state_lock); + + if (vif_more) { + more = 1; + tx_allowed_mask = vif_tx_allowed_mask; + queue = vif_queue; + ret = 0; + break; + } else if (!not_found) { + if (queue && queue != vif_queue) + dev_info(wdev->dev, "vifs disagree about queue priority\n"); + tx_allowed_mask |= vif_tx_allowed_mask; + queue = vif_queue; + ret = 0; + } + } + + if (ret) + return 0; + + queue_num = queue - wdev->tx_queue; + + skb = wfx_tx_queue_get(wdev, queue, tx_allowed_mask); + if (!skb) + continue; + tx_priv = wfx_skb_tx_priv(skb); + hif = (struct hif_msg *) skb->data; + wvif = wdev_to_wvif(wdev, hif->interface); + WARN_ON(!wvif); + + wvif->pspoll_mask &= ~BIT(tx_priv->raw_link_id); + + /* allow bursting if txop is set */ + if (wvif->edca.params[queue_num].tx_op_limit) + burst = (int)wfx_tx_queue_get_num_queued(queue, tx_allowed_mask) + 1; + else + burst = 1; + + /* store index of bursting queue */ + if (burst > 1) + wdev->tx_burst_idx = queue_num; + else + wdev->tx_burst_idx = -1; + + /* more buffered multicast/broadcast frames + * ==> set MoreData flag in IEEE 802.11 header + * to inform PS STAs + */ + if (more) { + req = (struct hif_req_tx *) hif->body; + hdr = (struct ieee80211_hdr *) (req->frame + req->data_flags.fc_offset); + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); + } + return hif; + } +} diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h new file mode 100644 index 000000000000..938dbf3469e7 --- /dev/null +++ b/drivers/staging/wfx/queue.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * O(1) TX queue with built-in allocator. + * + * Copyright (c) 2017-2018, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_QUEUE_H +#define WFX_QUEUE_H + +#include + +#include "hif_api_cmd.h" + +#define WFX_MAX_STA_IN_AP_MODE 14 +#define WFX_LINK_ID_AFTER_DTIM (WFX_MAX_STA_IN_AP_MODE + 1) +#define WFX_LINK_ID_UAPSD (WFX_MAX_STA_IN_AP_MODE + 2) +#define WFX_LINK_ID_MAX (WFX_MAX_STA_IN_AP_MODE + 3) + +struct wfx_dev; +struct wfx_vif; + +struct wfx_queue { + struct sk_buff_head queue; + int tx_locked_cnt; + int link_map_cache[WFX_LINK_ID_MAX]; + u8 queue_id; +}; + +struct wfx_queue_stats { + int link_map_cache[WFX_LINK_ID_MAX]; + struct sk_buff_head pending; + wait_queue_head_t wait_link_id_empty; +}; + +void wfx_tx_lock(struct wfx_dev *wdev); +void wfx_tx_unlock(struct wfx_dev *wdev); +void wfx_tx_flush(struct wfx_dev *wdev); +void wfx_tx_lock_flush(struct wfx_dev *wdev); + +void wfx_tx_queues_init(struct wfx_dev *wdev); +void wfx_tx_queues_deinit(struct wfx_dev *wdev); +void wfx_tx_queues_lock(struct wfx_dev *wdev); +void wfx_tx_queues_unlock(struct wfx_dev *wdev); +void wfx_tx_queues_clear(struct wfx_dev *wdev); +bool wfx_tx_queues_is_empty(struct wfx_dev *wdev); +void wfx_tx_queues_wait_empty_vif(struct wfx_vif *wvif); +struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev); + +void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff *skb); +size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, u32 link_id_map); + +struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id); +int wfx_pending_remove(struct wfx_dev *wdev, struct sk_buff *skb); +int wfx_pending_requeue(struct wfx_dev *wdev, struct sk_buff *skb); +unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb); +void wfx_pending_dump_old_frames(struct wfx_dev *wdev, unsigned int limit_ms); + +#endif /* WFX_QUEUE_H */ diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index fe3ff6536a87..5714aba1432c 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -10,11 +10,123 @@ #include "sta.h" #include "wfx.h" +#define TXOP_UNIT 32 + +static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) +{ + struct sk_buff *skb; + struct hif_ie_flags target_frame = { + .beacon = 1, + }; + u16 tim_offset, tim_length; + u8 *tim_ptr; + + skb = ieee80211_beacon_get_tim(wvif->wdev->hw, wvif->vif, + &tim_offset, &tim_length); + if (!skb) + return -ENOENT; + tim_ptr = skb->data + tim_offset; + + if (tim_offset && tim_length >= 6) { + /* Ignore DTIM count from mac80211: + * firmware handles DTIM internally. + */ + tim_ptr[2] = 0; + + /* Set/reset aid0 bit */ + if (aid0_bit_set) + tim_ptr[4] |= 1; + else + tim_ptr[4] &= ~1; + } + + hif_update_ie(wvif, &target_frame, tim_ptr, tim_length); + dev_kfree_skb(skb); + + return 0; +} + +static void wfx_mcast_start_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, mcast_start_work); + + cancel_work_sync(&wvif->mcast_stop_work); + if (!wvif->aid0_bit_set) { + wfx_tx_lock_flush(wvif->wdev); + wfx_set_tim_impl(wvif, true); + wvif->aid0_bit_set = true; + mod_timer(&wvif->mcast_timeout, TU_TO_JIFFIES(1000)); + wfx_tx_unlock(wvif->wdev); + } +} + +static void wfx_mcast_stop_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, mcast_stop_work); + + if (wvif->aid0_bit_set) { + del_timer_sync(&wvif->mcast_timeout); + wfx_tx_lock_flush(wvif->wdev); + wvif->aid0_bit_set = false; + wfx_set_tim_impl(wvif, false); + wfx_tx_unlock(wvif->wdev); + } +} + +static void wfx_mcast_timeout(struct timer_list *t) +{ + struct wfx_vif *wvif = from_timer(wvif, t, mcast_timeout); + + dev_warn(wvif->wdev->dev, "multicast delivery timeout\n"); + spin_lock_bh(&wvif->ps_state_lock); + wvif->mcast_tx = wvif->aid0_bit_set && wvif->mcast_buffered; + if (wvif->mcast_tx) + wfx_bh_request_tx(wvif->wdev); + spin_unlock_bh(&wvif->ps_state_lock); +} + int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { int i; struct wfx_dev *wdev = hw->priv; struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + // FIXME: parameters are set by kernel juste after interface_add. + // Keep struct hif_req_edca_queue_params blank? + struct hif_req_edca_queue_params default_edca_params[] = { + [IEEE80211_AC_VO] = { + .queue_id = HIF_QUEUE_ID_VOICE, + .aifsn = 2, + .cw_min = 3, + .cw_max = 7, + .tx_op_limit = TXOP_UNIT * 47, + }, + [IEEE80211_AC_VI] = { + .queue_id = HIF_QUEUE_ID_VIDEO, + .aifsn = 2, + .cw_min = 7, + .cw_max = 15, + .tx_op_limit = TXOP_UNIT * 94, + }, + [IEEE80211_AC_BE] = { + .queue_id = HIF_QUEUE_ID_BESTEFFORT, + .aifsn = 3, + .cw_min = 15, + .cw_max = 1023, + .tx_op_limit = TXOP_UNIT * 0, + }, + [IEEE80211_AC_BK] = { + .queue_id = HIF_QUEUE_ID_BACKGROUND, + .aifsn = 7, + .cw_min = 15, + .cw_max = 1023, + .tx_op_limit = TXOP_UNIT * 0, + }, + }; + + if (wfx_api_older_than(wdev, 2, 0)) { + default_edca_params[IEEE80211_AC_BE].queue_id = HIF_QUEUE_ID_BACKGROUND; + default_edca_params[IEEE80211_AC_BK].queue_id = HIF_QUEUE_ID_BESTEFFORT; + } for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { if (!wdev->vif[i]) { @@ -28,12 +140,29 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) wvif->vif = vif; wvif->wdev = wdev; + INIT_WORK(&wvif->link_id_work, wfx_link_id_work); + INIT_DELAYED_WORK(&wvif->link_id_gc_work, wfx_link_id_gc_work); + + spin_lock_init(&wvif->ps_state_lock); + + INIT_WORK(&wvif->mcast_start_work, wfx_mcast_start_work); + INIT_WORK(&wvif->mcast_stop_work, wfx_mcast_stop_work); + timer_setup(&wvif->mcast_timeout, wfx_mcast_timeout, 0); + BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); + for (i = 0; i < IEEE80211_NUM_ACS; i++) + memcpy(&wvif->edca.params[i], &default_edca_params[i], sizeof(default_edca_params[i])); + tx_policy_init(wvif); return 0; } void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + + wfx_tx_queues_wait_empty_vif(wvif); + cancel_delayed_work_sync(&wvif->link_id_gc_work); + del_timer_sync(&wvif->mcast_timeout); } int wfx_start(struct ieee80211_hw *hw) @@ -43,4 +172,10 @@ int wfx_start(struct ieee80211_hw *hw) void wfx_stop(struct ieee80211_hw *hw) { + struct wfx_dev *wdev = hw->priv; + + wfx_tx_lock_flush(wdev); + wfx_tx_queues_clear(wdev); + wfx_tx_unlock(wdev); + WARN(atomic_read(&wdev->tx_lock), "tx_lock is locked"); } diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index f17b4d1511d7..f36d94f907c7 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -10,6 +10,14 @@ #include +#include "hif_api_cmd.h" + +struct wfx_edca_params { + /* NOTE: index is a linux queue id. */ + struct hif_req_edca_queue_params params[IEEE80211_NUM_ACS]; + bool uapsd_enable[IEEE80211_NUM_ACS]; +}; + struct wfx_sta_priv { int link_id; int vif_id; diff --git a/drivers/staging/wfx/traces.h b/drivers/staging/wfx/traces.h index e7b03b940535..67457cda133b 100644 --- a/drivers/staging/wfx/traces.h +++ b/drivers/staging/wfx/traces.h @@ -12,6 +12,7 @@ #define _WFX_TRACE_H #include +#include #include "bus.h" #include "hif_api_cmd.h" @@ -349,6 +350,79 @@ TRACE_EVENT(bh_stats, ); #define _trace_bh_stats(ind, req, cnf, busy, release) trace_bh_stats(ind, req, cnf, busy, release) +TRACE_EVENT(tx_stats, + TP_PROTO(struct hif_cnf_tx *tx_cnf, struct sk_buff *skb, int delay), + TP_ARGS(tx_cnf, skb, delay), + TP_STRUCT__entry( + __field(int, pkt_id) + __field(int, delay_media) + __field(int, delay_queue) + __field(int, delay_fw) + __field(int, ack_failures) + __field(int, flags) + __array(int, rate, 4) + __array(int, tx_count, 4) + ), + TP_fast_assign( + // Keep sync with wfx_rates definition in main.c + static const int hw_rate[] = { 0, 1, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13 }; + struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); + struct ieee80211_tx_rate *rates = tx_info->driver_rates; + int i; + + __entry->pkt_id = tx_cnf->packet_id; + __entry->delay_media = tx_cnf->media_delay; + __entry->delay_queue = tx_cnf->tx_queue_delay; + __entry->delay_fw = delay; + __entry->ack_failures = tx_cnf->ack_failures; + if (!tx_cnf->status || __entry->ack_failures) + __entry->ack_failures += 1; + + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + if (rates[0].flags & IEEE80211_TX_RC_MCS) + __entry->rate[i] = rates[i].idx; + else + __entry->rate[i] = hw_rate[rates[i].idx]; + __entry->tx_count[i] = rates[i].count; + } + __entry->flags = 0; + if (rates[0].flags & IEEE80211_TX_RC_MCS) + __entry->flags |= 0x01; + if (rates[0].flags & IEEE80211_TX_RC_SHORT_GI) + __entry->flags |= 0x02; + if (rates[0].flags & IEEE80211_TX_RC_GREEN_FIELD) + __entry->flags |= 0x04; + if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) + __entry->flags |= 0x08; + if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) + __entry->flags |= 0x10; + if (tx_cnf->status) + __entry->flags |= 0x20; + if (tx_cnf->status == HIF_REQUEUE) + __entry->flags |= 0x40; + ), + TP_printk("packet ID: %08x, rate policy: %s %d|%d %d|%d %d|%d %d|%d -> %d attempt, Delays media/queue/total: %4dus/%4dus/%4dus", + __entry->pkt_id, + __print_flags(__entry->flags, NULL, + { 0x01, "M" }, { 0x02, "S" }, { 0x04, "G" }, + { 0x08, "R" }, { 0x10, "D" }, { 0x20, "F" }, + { 0x40, "Q" }), + __entry->rate[0], + __entry->tx_count[0], + __entry->rate[1], + __entry->tx_count[1], + __entry->rate[2], + __entry->tx_count[2], + __entry->rate[3], + __entry->tx_count[3], + __entry->ack_failures, + __entry->delay_media, + __entry->delay_queue, + __entry->delay_fw + ) +); +#define _trace_tx_stats(tx_cnf, skb, delay) trace_tx_stats(tx_cnf, skb, delay) + #endif /* This part must be outside protection */ diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 49b776a07515..11775b1e06ef 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -14,8 +14,11 @@ #include #include "bh.h" +#include "data_tx.h" #include "main.h" +#include "queue.h" #include "secure_link.h" +#include "sta.h" #include "hif_tx.h" #include "hif_api_general.h" @@ -38,6 +41,10 @@ struct wfx_dev { int chip_frozen; struct wfx_hif_cmd hif_cmd; + struct wfx_queue tx_queue[4]; + struct wfx_queue_stats tx_queue_stats; + int tx_burst_idx; + atomic_t tx_lock; struct hif_rx_stats rx_stats; struct mutex rx_stats_lock; @@ -47,6 +54,28 @@ struct wfx_vif { struct wfx_dev *wdev; struct ieee80211_vif *vif; int id; + + + u32 link_id_map; + struct wfx_link_entry link_id_db[WFX_MAX_STA_IN_AP_MODE]; + struct delayed_work link_id_gc_work; + struct work_struct link_id_work; + + bool aid0_bit_set; + bool mcast_tx; + bool mcast_buffered; + struct timer_list mcast_timeout; + struct work_struct mcast_start_work; + struct work_struct mcast_stop_work; + + + struct tx_policy_cache tx_policy_cache; + struct work_struct tx_policy_upload_work; + u32 sta_asleep_mask; + u32 pspoll_mask; + spinlock_t ps_state_lock; + + struct wfx_edca_params edca; }; static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) @@ -62,4 +91,33 @@ static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) return (struct wfx_vif *) wdev->vif[vif_id]->drv_priv; } +static inline struct wfx_vif *wvif_iterate(struct wfx_dev *wdev, struct wfx_vif *cur) +{ + int i; + int mark = 0; + struct wfx_vif *tmp; + + if (!cur) + mark = 1; + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { + tmp = wdev_to_wvif(wdev, i); + if (mark && tmp) + return tmp; + if (tmp == cur) + mark = 1; + } + return NULL; +} + +static inline int memzcmp(void *src, unsigned int size) +{ + uint8_t *buf = src; + + if (!size) + return 0; + if (*buf) + return 1; + return memcmp(buf, buf + 1, size - 1); +} + #endif /* WFX_H */ -- cgit v1.2.3-59-g8ed1b From 1f21b7fefa7290f4d66d4f23117e892b1aaf10d9 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:46 +0000 Subject: staging: wfx: allow to receive 802.11 frames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Again, this task is more complex than it should since driver try to handle itself power saving of stations. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-18-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/data_rx.c | 182 ++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/data_rx.h | 18 +++++ drivers/staging/wfx/hif_rx.c | 23 ++++++ 4 files changed, 224 insertions(+) create mode 100644 drivers/staging/wfx/data_rx.c create mode 100644 drivers/staging/wfx/data_rx.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index d5ac9fafd1f1..d9e21515d08e 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -11,6 +11,7 @@ wfx-y := \ hif_rx.o \ queue.o \ data_tx.o \ + data_rx.o \ sta.o \ main.o \ sta.o \ diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c new file mode 100644 index 000000000000..3b3117b2edac --- /dev/null +++ b/drivers/staging/wfx/data_rx.c @@ -0,0 +1,182 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Datapath implementation. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include +#include + +#include "data_rx.h" +#include "wfx.h" +#include "bh.h" +#include "sta.h" + +static int wfx_handle_pspoll(struct wfx_vif *wvif, struct sk_buff *skb) +{ + struct ieee80211_sta *sta; + struct ieee80211_pspoll *pspoll = (struct ieee80211_pspoll *)skb->data; + int link_id = 0; + u32 pspoll_mask = 0; + int i; + + if (!ether_addr_equal(wvif->vif->addr, pspoll->bssid)) + return 1; + + rcu_read_lock(); + sta = ieee80211_find_sta(wvif->vif, pspoll->ta); + if (sta) + link_id = ((struct wfx_sta_priv *) &sta->drv_priv)->link_id; + rcu_read_unlock(); + if (link_id) + pspoll_mask = BIT(link_id); + else + return 1; + + wvif->pspoll_mask |= pspoll_mask; + /* Do not report pspols if data for given link id is queued already. */ + for (i = 0; i < IEEE80211_NUM_ACS; ++i) { + if (wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[i], + pspoll_mask)) { + wfx_bh_request_tx(wvif->wdev); + return 1; + } + } + return 0; +} + +static int wfx_drop_encrypt_data(struct wfx_dev *wdev, struct hif_ind_rx *arg, struct sk_buff *skb) +{ + struct ieee80211_hdr *frame = (struct ieee80211_hdr *) skb->data; + size_t hdrlen = ieee80211_hdrlen(frame->frame_control); + size_t iv_len, icv_len; + + /* Oops... There is no fast way to ask mac80211 about + * IV/ICV lengths. Even defineas are not exposed. + */ + switch (arg->rx_flags.encryp) { + case HIF_RI_FLAGS_WEP_ENCRYPTED: + iv_len = 4 /* WEP_IV_LEN */; + icv_len = 4 /* WEP_ICV_LEN */; + break; + case HIF_RI_FLAGS_TKIP_ENCRYPTED: + iv_len = 8 /* TKIP_IV_LEN */; + icv_len = 4 /* TKIP_ICV_LEN */ + + 8 /*MICHAEL_MIC_LEN*/; + break; + case HIF_RI_FLAGS_AES_ENCRYPTED: + iv_len = 8 /* CCMP_HDR_LEN */; + icv_len = 8 /* CCMP_MIC_LEN */; + break; + case HIF_RI_FLAGS_WAPI_ENCRYPTED: + iv_len = 18 /* WAPI_HDR_LEN */; + icv_len = 16 /* WAPI_MIC_LEN */; + break; + default: + dev_err(wdev->dev, "unknown encryption type %d\n", + arg->rx_flags.encryp); + return -EIO; + } + + /* Firmware strips ICV in case of MIC failure. */ + if (arg->status == HIF_STATUS_MICFAILURE) + icv_len = 0; + + if (skb->len < hdrlen + iv_len + icv_len) { + dev_warn(wdev->dev, "malformed SDU received\n"); + return -EIO; + } + + /* Remove IV, ICV and MIC */ + skb_trim(skb, skb->len - icv_len); + memmove(skb->data + iv_len, skb->data, hdrlen); + skb_pull(skb, iv_len); + return 0; + +} + +void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb) +{ + int link_id = arg->rx_flags.peer_sta_id; + struct ieee80211_rx_status *hdr = IEEE80211_SKB_RXCB(skb); + struct ieee80211_hdr *frame = (struct ieee80211_hdr *) skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + struct wfx_link_entry *entry = NULL; + bool early_data = false; + + memset(hdr, 0, sizeof(*hdr)); + + // FIXME: Why do we drop these frames? + if (!arg->rcpi_rssi && + (ieee80211_is_probe_resp(frame->frame_control) || + ieee80211_is_beacon(frame->frame_control))) + goto drop; + + if (link_id && link_id <= WFX_MAX_STA_IN_AP_MODE) { + entry = &wvif->link_id_db[link_id - 1]; + entry->timestamp = jiffies; + if (entry->status == WFX_LINK_SOFT && ieee80211_is_data(frame->frame_control)) + early_data = true; + } + + if (arg->status == HIF_STATUS_MICFAILURE) + hdr->flag |= RX_FLAG_MMIC_ERROR; + else if (arg->status) + goto drop; + + if (skb->len < sizeof(struct ieee80211_pspoll)) { + dev_warn(wvif->wdev->dev, "malformed SDU received\n"); + goto drop; + } + + if (ieee80211_is_pspoll(frame->frame_control)) + if (wfx_handle_pspoll(wvif, skb)) + goto drop; + + hdr->band = NL80211_BAND_2GHZ; + hdr->freq = ieee80211_channel_to_frequency(arg->channel_number, hdr->band); + + if (arg->rxed_rate >= 14) { + hdr->encoding = RX_ENC_HT; + hdr->rate_idx = arg->rxed_rate - 14; + } else if (arg->rxed_rate >= 4) { + hdr->rate_idx = arg->rxed_rate - 2; + } else { + hdr->rate_idx = arg->rxed_rate; + } + + hdr->signal = arg->rcpi_rssi / 2 - 110; + hdr->antenna = 0; + + if (arg->rx_flags.encryp) { + if (wfx_drop_encrypt_data(wvif->wdev, arg, skb)) + goto drop; + hdr->flag |= RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED; + if (arg->rx_flags.encryp == HIF_RI_FLAGS_TKIP_ENCRYPTED) + hdr->flag |= RX_FLAG_MMIC_STRIPPED; + } + + /* Filter block ACK negotiation: fully controlled by firmware */ + if (ieee80211_is_action(frame->frame_control) + && arg->rx_flags.match_uc_addr + && mgmt->u.action.category == WLAN_CATEGORY_BACK) + goto drop; + + if (early_data) { + spin_lock_bh(&wvif->ps_state_lock); + /* Double-check status with lock held */ + if (entry->status == WFX_LINK_SOFT) + skb_queue_tail(&entry->rx_queue, skb); + else + ieee80211_rx_irqsafe(wvif->wdev->hw, skb); + spin_unlock_bh(&wvif->ps_state_lock); + } else { + ieee80211_rx_irqsafe(wvif->wdev->hw, skb); + } + + return; + +drop: + dev_kfree_skb(skb); +} diff --git a/drivers/staging/wfx/data_rx.h b/drivers/staging/wfx/data_rx.h new file mode 100644 index 000000000000..b44d15268f83 --- /dev/null +++ b/drivers/staging/wfx/data_rx.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Datapath implementation. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_DATA_RX_H +#define WFX_DATA_RX_H + +#include "hif_api_cmd.h" + +struct wfx_vif; +struct sk_buff; + +void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb); + +#endif /* WFX_DATA_RX_H */ diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 97c4c2f082fb..c07984b0535d 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -11,6 +11,7 @@ #include "hif_rx.h" #include "wfx.h" +#include "data_rx.h" #include "secure_link.h" #include "hif_api_cmd.h" @@ -127,6 +128,21 @@ static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void * return 0; } +static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf, struct sk_buff *skb) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + struct hif_ind_rx *body = buf; + + if (!wvif) { + dev_warn(wdev->dev, "ignore rx data for non existant vif %d\n", hif->interface); + return 0; + } + skb_pull(skb, sizeof(struct hif_msg) + sizeof(struct hif_ind_rx)); + wfx_rx_cb(wvif, body, skb); + + return 0; +} + static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); @@ -218,6 +234,8 @@ static const struct { { HIF_IND_ID_GENERIC, hif_generic_indication }, { HIF_IND_ID_ERROR, hif_error_indication }, { HIF_IND_ID_EXCEPTION, hif_exception_indication }, + // FIXME: allocate skb_p from hif_receive_indication and make it generic + //{ HIF_IND_ID_RX, hif_receive_indication }, }; void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) @@ -226,6 +244,11 @@ void wfx_handle_rx(struct wfx_dev *wdev, struct sk_buff *skb) struct hif_msg *hif = (struct hif_msg *) skb->data; int hif_id = hif->id; + if (hif_id == HIF_IND_ID_RX) { + // hif_receive_indication take care of skb lifetime + hif_receive_indication(wdev, hif, hif->body, skb); + return; + } // Note: mutex_is_lock cause an implicit memory barrier that protect // buf_send if (mutex_is_locked(&wdev->hif_cmd.lock) -- cgit v1.2.3-59-g8ed1b From 1a61af0f8cbecd1610c6fc380d0fb00f57fd43f2 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:47 +0000 Subject: staging: wfx: allow to scan networks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chip can make foreground scan or background, but both can't be mixed in same request. So, we need to split each mac80211 requests into multiple HIF requests. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-19-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/bh.c | 2 +- drivers/staging/wfx/hif_rx.c | 13 +++ drivers/staging/wfx/main.c | 5 + drivers/staging/wfx/scan.c | 249 +++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/scan.h | 42 ++++++++ drivers/staging/wfx/sta.c | 23 +++- drivers/staging/wfx/sta.h | 4 + drivers/staging/wfx/wfx.h | 11 ++ 9 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/wfx/scan.c create mode 100644 drivers/staging/wfx/scan.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index d9e21515d08e..2b8a5fa86fac 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -12,6 +12,7 @@ wfx-y := \ queue.o \ data_tx.o \ data_rx.o \ + scan.o \ sta.o \ main.o \ sta.o \ diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index ed81c3924d98..6000c03bb658 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -268,7 +268,7 @@ static void bh_work(struct work_struct *work) if (last_op_is_rx) ack_sdio_data(wdev); - if (!wdev->hif.tx_buffers_used && !work_pending(work)) { + if (!wdev->hif.tx_buffers_used && !work_pending(work) && !atomic_read(&wdev->scan_in_progress)) { device_release(wdev); release_chip = true; } diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index c07984b0535d..d386fab0a90f 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -11,6 +11,7 @@ #include "hif_rx.h" #include "wfx.h" +#include "scan.h" #include "data_rx.h" #include "secure_link.h" #include "hif_api_cmd.h" @@ -143,6 +144,17 @@ static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi return 0; } +static int hif_scan_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + struct hif_ind_scan_cmpl *body = buf; + + WARN_ON(!wvif); + wfx_scan_complete_cb(wvif, body); + + return 0; +} + static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); @@ -230,6 +242,7 @@ static const struct { { HIF_IND_ID_STARTUP, hif_startup_indication }, { HIF_IND_ID_WAKEUP, hif_wakeup_indication }, { HIF_IND_ID_JOIN_COMPLETE, hif_join_complete_indication }, + { HIF_IND_ID_SCAN_CMPL, hif_scan_complete_indication }, { HIF_IND_ID_SL_EXCHANGE_PUB_KEYS, hif_keys_indication }, { HIF_IND_ID_GENERIC, hif_generic_indication }, { HIF_IND_ID_ERROR, hif_error_indication }, diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index cce4e30dd94a..06220bac5b75 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -55,6 +55,7 @@ static const struct ieee80211_ops wfx_ops = { .add_interface = wfx_add_interface, .remove_interface = wfx_remove_interface, .tx = wfx_tx, + .hw_scan = wfx_hw_scan, }; bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) @@ -203,6 +204,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + 4 /* alignment */ + 8 /* TKIP IV */; + hw->wiphy->max_scan_ssids = 2; + hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; wdev = hw->priv; wdev->hw = hw; @@ -214,6 +217,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); wfx_fill_sl_key(dev, &wdev->pdata); + mutex_init(&wdev->conf_mutex); mutex_init(&wdev->rx_stats_lock); init_completion(&wdev->firmware_ready); wfx_init_hif_cmd(&wdev->hif_cmd); @@ -225,6 +229,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, void wfx_free_common(struct wfx_dev *wdev) { mutex_destroy(&wdev->rx_stats_lock); + mutex_destroy(&wdev->conf_mutex); wfx_tx_queues_deinit(wdev); ieee80211_free_hw(wdev->hw); } diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c new file mode 100644 index 000000000000..207b26ebc9fd --- /dev/null +++ b/drivers/staging/wfx/scan.c @@ -0,0 +1,249 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Scan related functions. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include + +#include "scan.h" +#include "wfx.h" +#include "sta.h" +#include "hif_tx_mib.h" + +static void __ieee80211_scan_completed_compat(struct ieee80211_hw *hw, bool aborted) +{ + struct cfg80211_scan_info info = { + .aborted = aborted ? 1 : 0, + }; + + ieee80211_scan_completed(hw, &info); +} + +static int wfx_scan_start(struct wfx_vif *wvif, struct wfx_scan_params *scan) +{ + int ret; + int tmo = 500; + + tmo += scan->scan_req.num_of_channels * + ((20 * (scan->scan_req.max_channel_time)) + 10); + atomic_set(&wvif->scan.in_progress, 1); + atomic_set(&wvif->wdev->scan_in_progress, 1); + + schedule_delayed_work(&wvif->scan.timeout, msecs_to_jiffies(tmo)); + ret = hif_scan(wvif, scan); + if (ret) { + wfx_scan_failed_cb(wvif); + atomic_set(&wvif->scan.in_progress, 0); + atomic_set(&wvif->wdev->scan_in_progress, 0); + cancel_delayed_work_sync(&wvif->scan.timeout); + } + return ret; +} + +int wfx_hw_scan(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_scan_request *hw_req) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + struct cfg80211_scan_request *req = &hw_req->req; + struct sk_buff *skb; + int i, ret; + struct hif_mib_template_frame *p; + + if (!wvif) + return -EINVAL; + + if (req->n_ssids == 1 && !req->ssids[0].ssid_len) + req->n_ssids = 0; + + if (req->n_ssids > HIF_API_MAX_NB_SSIDS) + return -EINVAL; + + skb = ieee80211_probereq_get(hw, wvif->vif->addr, NULL, 0, req->ie_len); + if (!skb) + return -ENOMEM; + + if (req->ie_len) + memcpy(skb_put(skb, req->ie_len), req->ie, req->ie_len); + + mutex_lock(&wdev->conf_mutex); + + p = (struct hif_mib_template_frame *)skb_push(skb, 4); + p->frame_type = HIF_TMPLT_PRBREQ; + p->frame_length = cpu_to_le16(skb->len - 4); + ret = hif_set_template_frame(wvif, p); + skb_pull(skb, 4); + + if (!ret) + /* Host want to be the probe responder. */ + ret = wfx_fwd_probe_req(wvif, true); + if (ret) { + mutex_unlock(&wdev->conf_mutex); + dev_kfree_skb(skb); + return ret; + } + + wfx_tx_lock_flush(wdev); + + BUG_ON(wvif->scan.req); + wvif->scan.req = req; + wvif->scan.n_ssids = 0; + wvif->scan.status = 0; + wvif->scan.begin = &req->channels[0]; + wvif->scan.curr = wvif->scan.begin; + wvif->scan.end = &req->channels[req->n_channels]; + wvif->scan.output_power = wdev->output_power; + + for (i = 0; i < req->n_ssids; ++i) { + struct hif_ssid_def *dst = &wvif->scan.ssids[wvif->scan.n_ssids]; + + memcpy(&dst->ssid[0], req->ssids[i].ssid, sizeof(dst->ssid)); + dst->ssid_length = req->ssids[i].ssid_len; + ++wvif->scan.n_ssids; + } + + mutex_unlock(&wdev->conf_mutex); + + if (skb) + dev_kfree_skb(skb); + schedule_work(&wvif->scan.work); + return 0; +} + +void wfx_scan_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, scan.work); + struct ieee80211_channel **it; + struct wfx_scan_params scan = { + .scan_req.scan_type.type = 0, /* Foreground */ + }; + struct ieee80211_channel *first; + int i; + + down(&wvif->scan.lock); + mutex_lock(&wvif->wdev->conf_mutex); + + if (!wvif->scan.req || wvif->scan.curr == wvif->scan.end) { + if (wvif->scan.output_power != wvif->wdev->output_power) + hif_set_output_power(wvif, wvif->wdev->output_power * 10); + + if (wvif->scan.status < 0) + dev_warn(wvif->wdev->dev, "scan failed\n"); + else if (wvif->scan.req) + dev_dbg(wvif->wdev->dev, "scan completed\n"); + else + dev_dbg(wvif->wdev->dev, "scan canceled\n"); + + wvif->scan.req = NULL; + wfx_tx_unlock(wvif->wdev); + mutex_unlock(&wvif->wdev->conf_mutex); + __ieee80211_scan_completed_compat(wvif->wdev->hw, wvif->scan.status ? 1 : 0); + up(&wvif->scan.lock); + return; + } + first = *wvif->scan.curr; + + for (it = wvif->scan.curr + 1, i = 1; + it != wvif->scan.end && i < HIF_API_MAX_NB_CHANNELS; + ++it, ++i) { + if ((*it)->band != first->band) + break; + if (((*it)->flags ^ first->flags) & + IEEE80211_CHAN_NO_IR) + break; + if (!(first->flags & IEEE80211_CHAN_NO_IR) && + (*it)->max_power != first->max_power) + break; + } + scan.scan_req.band = first->band; + + if (wvif->scan.req->no_cck) + scan.scan_req.max_transmit_rate = API_RATE_INDEX_G_6MBPS; + else + scan.scan_req.max_transmit_rate = API_RATE_INDEX_B_1MBPS; + scan.scan_req.num_of_probe_requests = + (first->flags & IEEE80211_CHAN_NO_IR) ? 0 : 2; + scan.scan_req.num_of_ssi_ds = wvif->scan.n_ssids; + scan.ssids = &wvif->scan.ssids[0]; + scan.scan_req.num_of_channels = it - wvif->scan.curr; + scan.scan_req.probe_delay = 100; + + scan.ch = kcalloc(scan.scan_req.num_of_channels, sizeof(u8), GFP_KERNEL); + + if (!scan.ch) { + wvif->scan.status = -ENOMEM; + goto fail; + } + for (i = 0; i < scan.scan_req.num_of_channels; ++i) + scan.ch[i] = wvif->scan.curr[i]->hw_value; + + if (wvif->scan.curr[0]->flags & IEEE80211_CHAN_NO_IR) { + scan.scan_req.min_channel_time = 50; + scan.scan_req.max_channel_time = 150; + } else { + scan.scan_req.min_channel_time = 10; + scan.scan_req.max_channel_time = 50; + } + if (!(first->flags & IEEE80211_CHAN_NO_IR) && + wvif->scan.output_power != first->max_power) { + wvif->scan.output_power = first->max_power; + hif_set_output_power(wvif, wvif->scan.output_power * 10); + } + wvif->scan.status = wfx_scan_start(wvif, &scan); + kfree(scan.ch); + if (wvif->scan.status) + goto fail; + wvif->scan.curr = it; + mutex_unlock(&wvif->wdev->conf_mutex); + return; + +fail: + wvif->scan.curr = wvif->scan.end; + mutex_unlock(&wvif->wdev->conf_mutex); + up(&wvif->scan.lock); + schedule_work(&wvif->scan.work); +} + +static void wfx_scan_complete(struct wfx_vif *wvif) +{ + up(&wvif->scan.lock); + atomic_set(&wvif->wdev->scan_in_progress, 0); + + wfx_scan_work(&wvif->scan.work); +} + +void wfx_scan_failed_cb(struct wfx_vif *wvif) +{ + if (cancel_delayed_work_sync(&wvif->scan.timeout) > 0) { + wvif->scan.status = -EIO; + schedule_work(&wvif->scan.timeout.work); + } +} + +void wfx_scan_complete_cb(struct wfx_vif *wvif, struct hif_ind_scan_cmpl *arg) +{ + if (cancel_delayed_work_sync(&wvif->scan.timeout) > 0) { + wvif->scan.status = 1; + schedule_work(&wvif->scan.timeout.work); + } +} + +void wfx_scan_timeout(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, scan.timeout.work); + + if (atomic_xchg(&wvif->scan.in_progress, 0)) { + if (wvif->scan.status > 0) { + wvif->scan.status = 0; + } else if (!wvif->scan.status) { + dev_warn(wvif->wdev->dev, "timeout waiting for scan complete notification\n"); + wvif->scan.status = -ETIMEDOUT; + wvif->scan.curr = wvif->scan.end; + hif_stop_scan(wvif); + } + wfx_scan_complete(wvif); + } +} diff --git a/drivers/staging/wfx/scan.h b/drivers/staging/wfx/scan.h new file mode 100644 index 000000000000..b4ddd0771a9b --- /dev/null +++ b/drivers/staging/wfx/scan.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Scan related functions. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_SCAN_H +#define WFX_SCAN_H + +#include +#include +#include + +#include "hif_api_cmd.h" + +struct wfx_dev; +struct wfx_vif; + +struct wfx_scan { + struct semaphore lock; + struct work_struct work; + struct delayed_work timeout; + struct cfg80211_scan_request *req; + struct ieee80211_channel **begin; + struct ieee80211_channel **curr; + struct ieee80211_channel **end; + struct hif_ssid_def ssids[HIF_API_MAX_NB_SSIDS]; + int output_power; + int n_ssids; + int status; + atomic_t in_progress; +}; + +int wfx_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_scan_request *req); +void wfx_scan_work(struct work_struct *work); +void wfx_scan_timeout(struct work_struct *work); +void wfx_scan_complete_cb(struct wfx_vif *wvif, struct hif_ind_scan_cmpl *arg); +void wfx_scan_failed_cb(struct wfx_vif *wvif); + +#endif /* WFX_SCAN_H */ diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 5714aba1432c..5a8140100e97 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -9,9 +9,18 @@ #include "sta.h" #include "wfx.h" +#include "scan.h" +#include "hif_tx_mib.h" #define TXOP_UNIT 32 +int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable) +{ + wvif->fwd_probe_req = enable; + return hif_set_rx_filter(wvif, wvif->filter_bssid, + wvif->fwd_probe_req); +} + static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) { struct sk_buff *skb; @@ -128,6 +137,8 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) default_edca_params[IEEE80211_AC_BK].queue_id = HIF_QUEUE_ID_BESTEFFORT; } + mutex_lock(&wdev->conf_mutex); + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { if (!wdev->vif[i]) { wdev->vif[i] = vif; @@ -135,8 +146,10 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) break; } } - if (i == ARRAY_SIZE(wdev->vif)) + if (i == ARRAY_SIZE(wdev->vif)) { + mutex_unlock(&wdev->conf_mutex); return -EOPNOTSUPP; + } wvif->vif = vif; wvif->wdev = wdev; @@ -148,6 +161,12 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) INIT_WORK(&wvif->mcast_start_work, wfx_mcast_start_work); INIT_WORK(&wvif->mcast_stop_work, wfx_mcast_stop_work); timer_setup(&wvif->mcast_timeout, wfx_mcast_timeout, 0); + + sema_init(&wvif->scan.lock, 1); + INIT_WORK(&wvif->scan.work, wfx_scan_work); + INIT_DELAYED_WORK(&wvif->scan.timeout, wfx_scan_timeout); + + mutex_unlock(&wdev->conf_mutex); BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); for (i = 0; i < IEEE80211_NUM_ACS; i++) memcpy(&wvif->edca.params[i], &default_edca_params[i], sizeof(default_edca_params[i])); @@ -175,7 +194,9 @@ void wfx_stop(struct ieee80211_hw *hw) struct wfx_dev *wdev = hw->priv; wfx_tx_lock_flush(wdev); + mutex_lock(&wdev->conf_mutex); wfx_tx_queues_clear(wdev); + mutex_unlock(&wdev->conf_mutex); wfx_tx_unlock(wdev); WARN(atomic_read(&wdev->tx_lock), "tx_lock is locked"); } diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index f36d94f907c7..dd1b6b3fc2f1 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -12,6 +12,8 @@ #include "hif_api_cmd.h" +struct wfx_vif; + struct wfx_edca_params { /* NOTE: index is a linux queue id. */ struct hif_req_edca_queue_params params[IEEE80211_NUM_ACS]; @@ -29,4 +31,6 @@ void wfx_stop(struct ieee80211_hw *hw); int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable); + #endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 11775b1e06ef..50c0d9c0e528 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -19,6 +19,7 @@ #include "queue.h" #include "secure_link.h" #include "sta.h" +#include "scan.h" #include "hif_tx.h" #include "hif_api_general.h" @@ -39,6 +40,7 @@ struct wfx_dev { struct wfx_hif hif; struct sl_context sl; int chip_frozen; + struct mutex conf_mutex; struct wfx_hif_cmd hif_cmd; struct wfx_queue tx_queue[4]; @@ -48,6 +50,9 @@ struct wfx_dev { struct hif_rx_stats rx_stats; struct mutex rx_stats_lock; + + int output_power; + atomic_t scan_in_progress; }; struct wfx_vif { @@ -71,11 +76,17 @@ struct wfx_vif { struct tx_policy_cache tx_policy_cache; struct work_struct tx_policy_upload_work; + u32 sta_asleep_mask; u32 pspoll_mask; spinlock_t ps_state_lock; + bool filter_bssid; + bool fwd_probe_req; + struct wfx_edca_params edca; + + struct wfx_scan scan; }; static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) -- cgit v1.2.3-59-g8ed1b From fb2490f693ee0151c0d847d1e4c575313a46b13b Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:47 +0000 Subject: staging: wfx: implement 802.11 key handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wfx_set_key() mostly copy bytes on correct offsets. A big piece of code for a simple work. Unfortunately, I did not found any way to factorize it. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-20-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Makefile | 1 + drivers/staging/wfx/key.c | 258 +++++++++++++++++++++++++++++++++++++++++++ drivers/staging/wfx/key.h | 22 ++++ drivers/staging/wfx/main.c | 2 + drivers/staging/wfx/sta.c | 4 + drivers/staging/wfx/wfx.h | 19 ++++ 6 files changed, 306 insertions(+) create mode 100644 drivers/staging/wfx/key.c create mode 100644 drivers/staging/wfx/key.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 2b8a5fa86fac..0d9c1ed092f6 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -14,6 +14,7 @@ wfx-y := \ data_rx.o \ scan.o \ sta.o \ + key.o \ main.o \ sta.o \ debug.o diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c new file mode 100644 index 000000000000..4e7d2b510a9c --- /dev/null +++ b/drivers/staging/wfx/key.c @@ -0,0 +1,258 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Key management related functions. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#include + +#include "key.h" +#include "wfx.h" +#include "hif_tx_mib.h" + +static int wfx_alloc_key(struct wfx_dev *wdev) +{ + int idx; + + idx = ffs(~wdev->key_map) - 1; + if (idx < 0 || idx >= MAX_KEY_ENTRIES) + return -1; + + wdev->key_map |= BIT(idx); + wdev->keys[idx].entry_index = idx; + return idx; +} + +static void wfx_free_key(struct wfx_dev *wdev, int idx) +{ + BUG_ON(!(wdev->key_map & BIT(idx))); + memset(&wdev->keys[idx], 0, sizeof(wdev->keys[idx])); + wdev->key_map &= ~BIT(idx); +} + +static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, + struct ieee80211_key_conf *key, u8 *peer_addr) +{ + WARN_ON(key->keylen > sizeof(msg->key_data)); + msg->key_length = key->keylen; + memcpy(msg->key_data, key->key, key->keylen); + ether_addr_copy(msg->peer_address, peer_addr); + return HIF_KEY_TYPE_WEP_PAIRWISE; +} + +static uint8_t fill_wep_group(struct hif_wep_group_key *msg, + struct ieee80211_key_conf *key) +{ + WARN_ON(key->keylen > sizeof(msg->key_data)); + msg->key_id = key->keyidx; + msg->key_length = key->keylen; + memcpy(msg->key_data, key->key, key->keylen); + return HIF_KEY_TYPE_WEP_DEFAULT; +} + +static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, + struct ieee80211_key_conf *key, u8 *peer_addr) +{ + uint8_t *keybuf = key->key; + + WARN_ON(key->keylen != sizeof(msg->tkip_key_data) + + sizeof(msg->tx_mic_key) + + sizeof(msg->rx_mic_key)); + memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data)); + keybuf += sizeof(msg->tkip_key_data); + memcpy(msg->tx_mic_key, keybuf, sizeof(msg->tx_mic_key)); + keybuf += sizeof(msg->tx_mic_key); + memcpy(msg->rx_mic_key, keybuf, sizeof(msg->rx_mic_key)); + ether_addr_copy(msg->peer_address, peer_addr); + return HIF_KEY_TYPE_TKIP_PAIRWISE; +} + +static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, + struct ieee80211_key_conf *key, + struct ieee80211_key_seq *seq, + enum nl80211_iftype iftype) +{ + uint8_t *keybuf = key->key; + + WARN_ON(key->keylen != sizeof(msg->tkip_key_data) + + 2 * sizeof(msg->rx_mic_key)); + msg->key_id = key->keyidx; + memcpy(msg->rx_sequence_counter, &seq->tkip.iv16, sizeof(seq->tkip.iv16)); + memcpy(msg->rx_sequence_counter + sizeof(uint16_t), &seq->tkip.iv32, sizeof(seq->tkip.iv32)); + memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data)); + keybuf += sizeof(msg->tkip_key_data); + if (iftype == NL80211_IFTYPE_AP) + // Use Tx MIC Key + memcpy(msg->rx_mic_key, keybuf + 0, sizeof(msg->rx_mic_key)); + else + // Use Rx MIC Key + memcpy(msg->rx_mic_key, keybuf + 8, sizeof(msg->rx_mic_key)); + return HIF_KEY_TYPE_TKIP_GROUP; +} + +static uint8_t fill_ccmp_pair(struct hif_aes_pairwise_key *msg, + struct ieee80211_key_conf *key, u8 *peer_addr) +{ + WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + ether_addr_copy(msg->peer_address, peer_addr); + memcpy(msg->aes_key_data, key->key, key->keylen); + return HIF_KEY_TYPE_AES_PAIRWISE; +} + +static uint8_t fill_ccmp_group(struct hif_aes_group_key *msg, + struct ieee80211_key_conf *key, + struct ieee80211_key_seq *seq) +{ + WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + memcpy(msg->aes_key_data, key->key, key->keylen); + memcpy(msg->rx_sequence_counter, seq->ccmp.pn, sizeof(seq->ccmp.pn)); + memreverse(msg->rx_sequence_counter, sizeof(seq->ccmp.pn)); + msg->key_id = key->keyidx; + return HIF_KEY_TYPE_AES_GROUP; +} + +static uint8_t fill_sms4_pair(struct hif_wapi_pairwise_key *msg, + struct ieee80211_key_conf *key, u8 *peer_addr) +{ + uint8_t *keybuf = key->key; + + WARN_ON(key->keylen != sizeof(msg->wapi_key_data) + + sizeof(msg->mic_key_data)); + ether_addr_copy(msg->peer_address, peer_addr); + memcpy(msg->wapi_key_data, keybuf, sizeof(msg->wapi_key_data)); + keybuf += sizeof(msg->wapi_key_data); + memcpy(msg->mic_key_data, keybuf, sizeof(msg->mic_key_data)); + msg->key_id = key->keyidx; + return HIF_KEY_TYPE_WAPI_PAIRWISE; +} + +static uint8_t fill_sms4_group(struct hif_wapi_group_key *msg, + struct ieee80211_key_conf *key) +{ + uint8_t *keybuf = key->key; + + WARN_ON(key->keylen != sizeof(msg->wapi_key_data) + + sizeof(msg->mic_key_data)); + memcpy(msg->wapi_key_data, keybuf, sizeof(msg->wapi_key_data)); + keybuf += sizeof(msg->wapi_key_data); + memcpy(msg->mic_key_data, keybuf, sizeof(msg->mic_key_data)); + msg->key_id = key->keyidx; + return HIF_KEY_TYPE_WAPI_GROUP; +} + +static uint8_t fill_aes_cmac_group(struct hif_igtk_group_key *msg, + struct ieee80211_key_conf *key, + struct ieee80211_key_seq *seq) +{ + WARN_ON(key->keylen != sizeof(msg->igtk_key_data)); + memcpy(msg->igtk_key_data, key->key, key->keylen); + memcpy(msg->ipn, seq->aes_cmac.pn, sizeof(seq->aes_cmac.pn)); + memreverse(msg->ipn, sizeof(seq->aes_cmac.pn)); + msg->key_id = key->keyidx; + return HIF_KEY_TYPE_IGTK_GROUP; +} + +static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + int ret; + struct hif_req_add_key *k; + struct ieee80211_key_seq seq; + struct wfx_dev *wdev = wvif->wdev; + int idx = wfx_alloc_key(wvif->wdev); + bool pairwise = key->flags & IEEE80211_KEY_FLAG_PAIRWISE; + + WARN_ON(key->flags & IEEE80211_KEY_FLAG_PAIRWISE && !sta); + ieee80211_get_key_rx_seq(key, 0, &seq); + if (idx < 0) + return -EINVAL; + k = &wdev->keys[idx]; + k->int_id = wvif->id; + if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) { + if (pairwise) + k->type = fill_wep_pair(&k->key.wep_pairwise_key, key, sta->addr); + else + k->type = fill_wep_group(&k->key.wep_group_key, key); + } else if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { + if (pairwise) + k->type = fill_tkip_pair(&k->key.tkip_pairwise_key, key, sta->addr); + else + k->type = fill_tkip_group(&k->key.tkip_group_key, key, &seq, wvif->vif->type); + } else if (key->cipher == WLAN_CIPHER_SUITE_CCMP) { + if (pairwise) + k->type = fill_ccmp_pair(&k->key.aes_pairwise_key, key, sta->addr); + else + k->type = fill_ccmp_group(&k->key.aes_group_key, key, &seq); + } else if (key->cipher == WLAN_CIPHER_SUITE_SMS4) { + if (pairwise) + k->type = fill_sms4_pair(&k->key.wapi_pairwise_key, key, sta->addr); + else + k->type = fill_sms4_group(&k->key.wapi_group_key, key); + } else if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { + k->type = fill_aes_cmac_group(&k->key.igtk_group_key, key, &seq); + } else { + dev_warn(wdev->dev, "unsupported key type %d\n", key->cipher); + wfx_free_key(wdev, idx); + return -EOPNOTSUPP; + } + ret = hif_add_key(wdev, k); + if (ret) { + wfx_free_key(wdev, idx); + return -EOPNOTSUPP; + } + key->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE | + IEEE80211_KEY_FLAG_RESERVE_TAILROOM; + key->hw_key_idx = idx; + return 0; +} + +static int wfx_remove_key(struct wfx_vif *wvif, struct ieee80211_key_conf *key) +{ + WARN(key->hw_key_idx >= MAX_KEY_ENTRIES, "corrupted hw_key_idx"); + wfx_free_key(wvif->wdev, key->hw_key_idx); + return hif_remove_key(wvif->wdev, key->hw_key_idx); +} + +int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + int ret = -EOPNOTSUPP; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + + mutex_lock(&wvif->wdev->conf_mutex); + if (cmd == SET_KEY) + ret = wfx_add_key(wvif, sta, key); + if (cmd == DISABLE_KEY) + ret = wfx_remove_key(wvif, key); + mutex_unlock(&wvif->wdev->conf_mutex); + return ret; +} + +int wfx_upload_keys(struct wfx_vif *wvif) +{ + int i; + struct hif_req_add_key *key; + struct wfx_dev *wdev = wvif->wdev; + + for (i = 0; i < ARRAY_SIZE(wdev->keys); i++) { + if (wdev->key_map & BIT(i)) { + key = &wdev->keys[i]; + if (key->int_id == wvif->id) + hif_add_key(wdev, key); + } + } + return 0; +} + +void wfx_wep_key_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, wep_key_work); + + wfx_tx_flush(wvif->wdev); + hif_wep_default_key_id(wvif, wvif->wep_default_key_id); + wfx_pending_requeue(wvif->wdev, wvif->wep_pending_skb); + wvif->wep_pending_skb = NULL; + wfx_tx_unlock(wvif->wdev); +} diff --git a/drivers/staging/wfx/key.h b/drivers/staging/wfx/key.h new file mode 100644 index 000000000000..9436ccdf4d3b --- /dev/null +++ b/drivers/staging/wfx/key.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Implementation of mac80211 API. + * + * Copyright (c) 2017-2019, Silicon Laboratories, Inc. + * Copyright (c) 2010, ST-Ericsson + */ +#ifndef WFX_KEY_H +#define WFX_KEY_H + +#include + +struct wfx_dev; +struct wfx_vif; + +int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key); +int wfx_upload_keys(struct wfx_vif *wvif); +void wfx_wep_key_work(struct work_struct *work); + +#endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 06220bac5b75..e7bba24aae0b 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -27,6 +27,7 @@ #include "bus.h" #include "bh.h" #include "sta.h" +#include "key.h" #include "debug.h" #include "data_tx.h" #include "secure_link.h" @@ -56,6 +57,7 @@ static const struct ieee80211_ops wfx_ops = { .remove_interface = wfx_remove_interface, .tx = wfx_tx, .hw_scan = wfx_hw_scan, + .set_key = wfx_set_key, }; bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 5a8140100e97..2e709b8a3bf4 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -9,6 +9,7 @@ #include "sta.h" #include "wfx.h" +#include "key.h" #include "scan.h" #include "hif_tx_mib.h" @@ -162,6 +163,9 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) INIT_WORK(&wvif->mcast_stop_work, wfx_mcast_stop_work); timer_setup(&wvif->mcast_timeout, wfx_mcast_timeout, 0); + wvif->wep_default_key_id = -1; + INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work); + sema_init(&wvif->scan.lock, 1); INIT_WORK(&wvif->scan.work, wfx_scan_work); INIT_DELAYED_WORK(&wvif->scan.timeout, wfx_scan_timeout); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 50c0d9c0e528..a86ddfaed825 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -48,6 +48,9 @@ struct wfx_dev { int tx_burst_idx; atomic_t tx_lock; + u32 key_map; + struct hif_req_add_key keys[MAX_KEY_ENTRIES]; + struct hif_rx_stats rx_stats; struct mutex rx_stats_lock; @@ -73,6 +76,9 @@ struct wfx_vif { struct work_struct mcast_start_work; struct work_struct mcast_stop_work; + s8 wep_default_key_id; + struct sk_buff *wep_pending_skb; + struct work_struct wep_key_work; struct tx_policy_cache tx_policy_cache; struct work_struct tx_policy_upload_work; @@ -120,6 +126,19 @@ static inline struct wfx_vif *wvif_iterate(struct wfx_dev *wdev, struct wfx_vif return NULL; } +static inline void memreverse(uint8_t *src, uint8_t length) +{ + uint8_t *lo = src; + uint8_t *hi = src + length - 1; + uint8_t swap; + + while (lo < hi) { + swap = *lo; + *lo++ = *hi; + *hi-- = swap; + } +} + static inline int memzcmp(void *src, unsigned int size) { uint8_t *buf = src; -- cgit v1.2.3-59-g8ed1b From 40115bbc40e2fd2de0e01ef2a28e0d09a1b5d0d1 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 19 Sep 2019 14:25:48 +0000 Subject: staging: wfx: implement the rest of mac80211 API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finish to fill struct ieee80211_ops with necessary callbacks. Driver is now ready to be registered to mac80211. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20190919142527.31797-21-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_rx.c | 26 + drivers/staging/wfx/data_tx.c | 16 + drivers/staging/wfx/debug.c | 2 + drivers/staging/wfx/hif_rx.c | 53 ++ drivers/staging/wfx/hif_tx.c | 1 + drivers/staging/wfx/main.c | 133 ++++ drivers/staging/wfx/queue.c | 80 +++ drivers/staging/wfx/scan.c | 40 ++ drivers/staging/wfx/sta.c | 1443 ++++++++++++++++++++++++++++++++++++++++- drivers/staging/wfx/sta.h | 65 ++ drivers/staging/wfx/wfx.h | 51 ++ 11 files changed, 1907 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 3b3117b2edac..3a79089c8501 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -21,6 +21,8 @@ static int wfx_handle_pspoll(struct wfx_vif *wvif, struct sk_buff *skb) u32 pspoll_mask = 0; int i; + if (wvif->state != WFX_STATE_AP) + return 1; if (!ether_addr_equal(wvif->vif->addr, pspoll->bssid)) return 1; @@ -162,6 +164,30 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb && arg->rx_flags.match_uc_addr && mgmt->u.action.category == WLAN_CATEGORY_BACK) goto drop; + if (ieee80211_is_beacon(frame->frame_control) + && !arg->status && wvif->vif + && ether_addr_equal(ieee80211_get_SA(frame), wvif->vif->bss_conf.bssid)) { + const u8 *tim_ie; + u8 *ies = mgmt->u.beacon.variable; + size_t ies_len = skb->len - (ies - skb->data); + + tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); + if (tim_ie) { + struct ieee80211_tim_ie *tim = (struct ieee80211_tim_ie *) &tim_ie[2]; + + if (wvif->dtim_period != tim->dtim_period) { + wvif->dtim_period = tim->dtim_period; + schedule_work(&wvif->set_beacon_wakeup_period_work); + } + } + + /* Disable beacon filter once we're associated... */ + if (wvif->disable_beacon_filter && + (wvif->vif->bss_conf.assoc || wvif->vif->bss_conf.ibss_joined)) { + wvif->disable_beacon_filter = false; + schedule_work(&wvif->update_filtering_work); + } + } if (early_data) { spin_lock_bh(&wvif->ps_state_lock); diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 217d3c270706..7f2799fbdafe 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -10,6 +10,7 @@ #include "data_tx.h" #include "wfx.h" #include "bh.h" +#include "sta.h" #include "queue.h" #include "debug.h" #include "traces.h" @@ -359,6 +360,9 @@ void wfx_link_id_gc_work(struct work_struct *work) u32 mask; int i; + if (wvif->state != WFX_STATE_AP) + return; + wfx_tx_lock_flush(wvif->wdev); spin_lock_bh(&wvif->ps_state_lock); for (i = 0; i < WFX_MAX_STA_IN_AP_MODE; ++i) { @@ -729,14 +733,26 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) memset(tx_info->pad, 0, sizeof(tx_info->pad)); if (!arg->status) { + if (wvif->bss_loss_state && arg->packet_id == wvif->bss_loss_confirm_id) + wfx_cqm_bssloss_sm(wvif, 0, 1, 0); tx_info->status.tx_time = arg->media_delay - arg->tx_queue_delay; if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) tx_info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; else tx_info->flags |= IEEE80211_TX_STAT_ACK; } else if (arg->status == HIF_REQUEUE) { + /* "REQUEUE" means "implicit suspend" */ + struct hif_ind_suspend_resume_tx suspend = { + .suspend_resume_flags.resume = 0, + .suspend_resume_flags.bc_mc_only = 1, + }; + WARN(!arg->tx_result_flags.requeue, "incoherent status and result_flags"); + wfx_suspend_resume(wvif, &suspend); tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; + } else { + if (wvif->bss_loss_state && arg->packet_id == wvif->bss_loss_confirm_id) + wfx_cqm_bssloss_sm(wvif, 0, 0, 1); } wfx_pending_remove(wvif->wdev, skb); } diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 1e23bb5bde3e..3261b267c385 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -11,7 +11,9 @@ #include "debug.h" #include "wfx.h" +#include "sta.h" #include "main.h" +#include "hif_tx.h" #include "hif_tx_mib.h" #define CREATE_TRACE_POINTS diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index d386fab0a90f..52db02d3aa41 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -12,6 +12,8 @@ #include "hif_rx.h" #include "wfx.h" #include "scan.h" +#include "bh.h" +#include "sta.h" #include "data_rx.h" #include "secure_link.h" #include "hif_api_cmd.h" @@ -144,6 +146,43 @@ static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi return 0; } +static int hif_event_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + struct hif_ind_event *body = buf; + struct wfx_hif_event *event; + int first; + + WARN_ON(!wvif); + if (!wvif) + return 0; + + event = kzalloc(sizeof(*event), GFP_KERNEL); + if (!event) + return -ENOMEM; + + memcpy(&event->evt, body, sizeof(struct hif_ind_event)); + spin_lock(&wvif->event_queue_lock); + first = list_empty(&wvif->event_queue); + list_add_tail(&event->link, &wvif->event_queue); + spin_unlock(&wvif->event_queue_lock); + + if (first) + schedule_work(&wvif->event_handler_work); + + return 0; +} + +static int hif_pm_mode_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + + WARN_ON(!wvif); + complete(&wvif->set_pm_mode_complete); + + return 0; +} + static int hif_scan_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); @@ -165,6 +204,17 @@ static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hi return 0; } +static int hif_suspend_resume_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +{ + struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); + struct hif_ind_suspend_resume_tx *body = buf; + + WARN_ON(!wvif); + wfx_suspend_resume(wvif, body); + + return 0; +} + static int hif_error_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) { struct hif_ind_error *body = buf; @@ -242,8 +292,11 @@ static const struct { { HIF_IND_ID_STARTUP, hif_startup_indication }, { HIF_IND_ID_WAKEUP, hif_wakeup_indication }, { HIF_IND_ID_JOIN_COMPLETE, hif_join_complete_indication }, + { HIF_IND_ID_SET_PM_MODE_CMPL, hif_pm_mode_complete_indication }, { HIF_IND_ID_SCAN_CMPL, hif_scan_complete_indication }, + { HIF_IND_ID_SUSPEND_RESUME_TX, hif_suspend_resume_indication }, { HIF_IND_ID_SL_EXCHANGE_PUB_KEYS, hif_keys_indication }, + { HIF_IND_ID_EVENT, hif_event_indication }, { HIF_IND_ID_GENERIC, hif_generic_indication }, { HIF_IND_ID_ERROR, hif_error_indication }, { HIF_IND_ID_EXCEPTION, hif_exception_indication }, diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 157ab177b73f..2d40225a0fce 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -14,6 +14,7 @@ #include "bh.h" #include "hwio.h" #include "debug.h" +#include "sta.h" void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd) { diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index e7bba24aae0b..fe9a89703897 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -50,14 +50,112 @@ static char *slk_key; module_param(slk_key, charp, 0600); MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexdecimal digits)."); +#define RATETAB_ENT(_rate, _rateid, _flags) { \ + .bitrate = (_rate), \ + .hw_value = (_rateid), \ + .flags = (_flags), \ +} + +static struct ieee80211_rate wfx_rates[] = { + RATETAB_ENT(10, 0, 0), + RATETAB_ENT(20, 1, IEEE80211_RATE_SHORT_PREAMBLE), + RATETAB_ENT(55, 2, IEEE80211_RATE_SHORT_PREAMBLE), + RATETAB_ENT(110, 3, IEEE80211_RATE_SHORT_PREAMBLE), + RATETAB_ENT(60, 6, 0), + RATETAB_ENT(90, 7, 0), + RATETAB_ENT(120, 8, 0), + RATETAB_ENT(180, 9, 0), + RATETAB_ENT(240, 10, 0), + RATETAB_ENT(360, 11, 0), + RATETAB_ENT(480, 12, 0), + RATETAB_ENT(540, 13, 0), +}; + +#define CHAN2G(_channel, _freq, _flags) { \ + .band = NL80211_BAND_2GHZ, \ + .center_freq = (_freq), \ + .hw_value = (_channel), \ + .flags = (_flags), \ + .max_antenna_gain = 0, \ + .max_power = 30, \ +} + +static struct ieee80211_channel wfx_2ghz_chantable[] = { + CHAN2G(1, 2412, 0), + CHAN2G(2, 2417, 0), + CHAN2G(3, 2422, 0), + CHAN2G(4, 2427, 0), + CHAN2G(5, 2432, 0), + CHAN2G(6, 2437, 0), + CHAN2G(7, 2442, 0), + CHAN2G(8, 2447, 0), + CHAN2G(9, 2452, 0), + CHAN2G(10, 2457, 0), + CHAN2G(11, 2462, 0), + CHAN2G(12, 2467, 0), + CHAN2G(13, 2472, 0), + CHAN2G(14, 2484, 0), +}; + +static const struct ieee80211_supported_band wfx_band_2ghz = { + .channels = wfx_2ghz_chantable, + .n_channels = ARRAY_SIZE(wfx_2ghz_chantable), + .bitrates = wfx_rates, + .n_bitrates = ARRAY_SIZE(wfx_rates), + .ht_cap = { + // Receive caps + .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_MAX_AMSDU | (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT), + .ht_supported = 1, + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K, + .ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE, + .mcs = { + .rx_mask = { 0xFF }, // MCS0 to MCS7 + .rx_highest = 65, + .tx_params = IEEE80211_HT_MCS_TX_DEFINED, + }, + }, +}; + +static const struct ieee80211_iface_limit wdev_iface_limits[] = { + { .max = 1, .types = BIT(NL80211_IFTYPE_STATION) }, + { .max = 1, .types = BIT(NL80211_IFTYPE_AP) }, +}; + +static const struct ieee80211_iface_combination wfx_iface_combinations[] = { + { + .num_different_channels = 2, + .max_interfaces = 2, + .limits = wdev_iface_limits, + .n_limits = ARRAY_SIZE(wdev_iface_limits), + } +}; + static const struct ieee80211_ops wfx_ops = { .start = wfx_start, .stop = wfx_stop, .add_interface = wfx_add_interface, .remove_interface = wfx_remove_interface, + .config = wfx_config, .tx = wfx_tx, + .conf_tx = wfx_conf_tx, .hw_scan = wfx_hw_scan, + .sta_add = wfx_sta_add, + .sta_remove = wfx_sta_remove, + .sta_notify = wfx_sta_notify, + .set_tim = wfx_set_tim, .set_key = wfx_set_key, + .set_rts_threshold = wfx_set_rts_threshold, + .bss_info_changed = wfx_bss_info_changed, + .prepare_multicast = wfx_prepare_multicast, + .configure_filter = wfx_configure_filter, + .ampdu_action = wfx_ampdu_action, + .flush = wfx_flush, + .add_chanctx = wfx_add_chanctx, + .remove_chanctx = wfx_remove_chanctx, + .change_chanctx = wfx_change_chanctx, + .assign_vif_chanctx = wfx_assign_vif_chanctx, + .unassign_vif_chanctx = wfx_unassign_vif_chanctx, }; bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) @@ -198,6 +296,16 @@ struct wfx_dev *wfx_init_common(struct device *dev, SET_IEEE80211_DEV(hw, dev); + ieee80211_hw_set(hw, NEED_DTIM_BEFORE_ASSOC); + ieee80211_hw_set(hw, TX_AMPDU_SETUP_IN_HW); + ieee80211_hw_set(hw, AMPDU_AGGREGATION); + ieee80211_hw_set(hw, CONNECTION_MONITOR); + ieee80211_hw_set(hw, REPORTS_TX_ACK_STATUS); + ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS); + ieee80211_hw_set(hw, SIGNAL_DBM); + ieee80211_hw_set(hw, SUPPORTS_PS); + ieee80211_hw_set(hw, MFP_CAPABLE); + hw->vif_data_size = sizeof(struct wfx_vif); hw->sta_data_size = sizeof(struct wfx_sta_priv); hw->queues = 4; @@ -206,8 +314,19 @@ struct wfx_dev *wfx_init_common(struct device *dev, hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + 4 /* alignment */ + 8 /* TKIP IV */; + hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC) | + BIT(NL80211_IFTYPE_AP); + hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD; + hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + hw->wiphy->max_ap_assoc_sta = WFX_MAX_STA_IN_AP_MODE; hw->wiphy->max_scan_ssids = 2; hw->wiphy->max_scan_ie_len = IEEE80211_MAX_DATA_LEN; + hw->wiphy->n_iface_combinations = ARRAY_SIZE(wfx_iface_combinations); + hw->wiphy->iface_combinations = wfx_iface_combinations; + hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmalloc(dev, sizeof(wfx_band_2ghz), GFP_KERNEL); + // FIXME: also copy wfx_rates and wfx_2ghz_chantable + memcpy(hw->wiphy->bands[NL80211_BAND_2GHZ], &wfx_band_2ghz, sizeof(wfx_band_2ghz)); wdev = hw->priv; wdev->hw = hw; @@ -290,6 +409,12 @@ int wfx_probe(struct wfx_dev *wdev) goto err1; } + if (wdev->hw_caps.regul_sel_mode_info.region_sel_mode) { + wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[11].flags |= IEEE80211_CHAN_NO_IR; + wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[12].flags |= IEEE80211_CHAN_NO_IR; + wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[13].flags |= IEEE80211_CHAN_DISABLED; + } + dev_dbg(wdev->dev, "sending configuration file %s\n", wdev->pdata.file_pds); err = wfx_send_pdata_pds(wdev); if (err < 0) @@ -322,6 +447,12 @@ int wfx_probe(struct wfx_dev *wdev) } dev_info(wdev->dev, "MAC address %d: %pM\n", i, wdev->addresses[i].addr); } + wdev->hw->wiphy->n_addresses = ARRAY_SIZE(wdev->addresses); + wdev->hw->wiphy->addresses = wdev->addresses; + + err = ieee80211_register_hw(wdev->hw); + if (err) + goto err1; err = wfx_debug_init(wdev); if (err) @@ -330,6 +461,7 @@ int wfx_probe(struct wfx_dev *wdev) return 0; err2: + ieee80211_unregister_hw(wdev->hw); ieee80211_free_hw(wdev->hw); err1: wfx_bh_unregister(wdev); @@ -338,6 +470,7 @@ err1: void wfx_release(struct wfx_dev *wdev) { + ieee80211_unregister_hw(wdev->hw); hif_shutdown(wdev); wfx_bh_unregister(wdev); wfx_sl_deinit(wdev); diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index aa438be21d37..6f1be4f6f463 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -351,6 +351,83 @@ bool wfx_tx_queues_is_empty(struct wfx_dev *wdev) return ret; } +static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb, + struct wfx_queue *queue) +{ + bool handled = false; + struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); + struct hif_req_tx *req = wfx_skb_txreq(skb); + struct ieee80211_hdr *frame = (struct ieee80211_hdr *) (req->frame + req->data_flags.fc_offset); + + enum { + do_probe, + do_drop, + do_wep, + do_tx, + } action = do_tx; + + switch (wvif->vif->type) { + case NL80211_IFTYPE_STATION: + if (wvif->state < WFX_STATE_PRE_STA) + action = do_drop; + break; + case NL80211_IFTYPE_AP: + if (!wvif->state) { + action = do_drop; + } else if (!(BIT(tx_priv->raw_link_id) & (BIT(0) | wvif->link_id_map))) { + dev_warn(wvif->wdev->dev, "a frame with expired link-id is dropped\n"); + action = do_drop; + } + break; + case NL80211_IFTYPE_ADHOC: + if (wvif->state != WFX_STATE_IBSS) + action = do_drop; + break; + case NL80211_IFTYPE_MONITOR: + default: + action = do_drop; + break; + } + + if (action == do_tx) { + if (ieee80211_is_nullfunc(frame->frame_control)) { + mutex_lock(&wvif->bss_loss_lock); + if (wvif->bss_loss_state) { + wvif->bss_loss_confirm_id = req->packet_id; + req->queue_id.queue_id = HIF_QUEUE_ID_VOICE; + } + mutex_unlock(&wvif->bss_loss_lock); + } else if (ieee80211_has_protected(frame->frame_control) && + tx_priv->hw_key && + tx_priv->hw_key->keyidx != wvif->wep_default_key_id && + (tx_priv->hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 || + tx_priv->hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) { + action = do_wep; + } + } + + switch (action) { + case do_drop: + BUG_ON(wfx_pending_remove(wvif->wdev, skb)); + handled = true; + break; + case do_wep: + wfx_tx_lock(wvif->wdev); + wvif->wep_default_key_id = tx_priv->hw_key->keyidx; + wvif->wep_pending_skb = skb; + if (!schedule_work(&wvif->wep_key_work)) + wfx_tx_unlock(wvif->wdev); + handled = true; + break; + case do_tx: + break; + default: + /* Do nothing */ + break; + } + return handled; +} + static int wfx_get_prio_queue(struct wfx_vif *wvif, u32 tx_allowed_mask, int *total) { @@ -498,6 +575,9 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) wvif = wdev_to_wvif(wdev, hif->interface); WARN_ON(!wvif); + if (hif_handle_tx_data(wvif, skb, queue)) + continue; /* Handled by WSM */ + wvif->pspoll_mask &= ~BIT(tx_priv->raw_link_id); /* allow bursting if txop is set */ diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index 207b26ebc9fd..ea5001c915f6 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -21,11 +21,26 @@ static void __ieee80211_scan_completed_compat(struct ieee80211_hw *hw, bool abor ieee80211_scan_completed(hw, &info); } +static void wfx_scan_restart_delayed(struct wfx_vif *wvif) +{ + if (wvif->delayed_unjoin) { + wvif->delayed_unjoin = false; + if (!schedule_work(&wvif->unjoin_work)) + wfx_tx_unlock(wvif->wdev); + } else if (wvif->delayed_link_loss) { + wvif->delayed_link_loss = 0; + wfx_cqm_bssloss_sm(wvif, 1, 0, 0); + } +} + static int wfx_scan_start(struct wfx_vif *wvif, struct wfx_scan_params *scan) { int ret; int tmo = 500; + if (wvif->state == WFX_STATE_PRE_STA) + return -EBUSY; + tmo += scan->scan_req.num_of_channels * ((20 * (scan->scan_req.max_channel_time)) + 10); atomic_set(&wvif->scan.in_progress, 1); @@ -38,6 +53,7 @@ static int wfx_scan_start(struct wfx_vif *wvif, struct wfx_scan_params *scan) atomic_set(&wvif->scan.in_progress, 0); atomic_set(&wvif->wdev->scan_in_progress, 0); cancel_delayed_work_sync(&wvif->scan.timeout); + wfx_scan_restart_delayed(wvif); } return ret; } @@ -56,6 +72,9 @@ int wfx_hw_scan(struct ieee80211_hw *hw, if (!wvif) return -EINVAL; + if (wvif->state == WFX_STATE_AP) + return -EOPNOTSUPP; + if (req->n_ssids == 1 && !req->ssids[0].ssid_len) req->n_ssids = 0; @@ -121,11 +140,23 @@ void wfx_scan_work(struct work_struct *work) .scan_req.scan_type.type = 0, /* Foreground */ }; struct ieee80211_channel *first; + bool first_run = (wvif->scan.begin == wvif->scan.curr && + wvif->scan.begin != wvif->scan.end); int i; down(&wvif->scan.lock); mutex_lock(&wvif->wdev->conf_mutex); + if (first_run) { + if (wvif->state == WFX_STATE_STA && + !(wvif->powersave_mode.pm_mode.enter_psm)) { + struct hif_req_set_pm_mode pm = wvif->powersave_mode; + + pm.pm_mode.enter_psm = 1; + wfx_set_pm(wvif, &pm); + } + } + if (!wvif->scan.req || wvif->scan.curr == wvif->scan.end) { if (wvif->scan.output_power != wvif->wdev->output_power) hif_set_output_power(wvif, wvif->wdev->output_power * 10); @@ -138,10 +169,14 @@ void wfx_scan_work(struct work_struct *work) dev_dbg(wvif->wdev->dev, "scan canceled\n"); wvif->scan.req = NULL; + wfx_scan_restart_delayed(wvif); wfx_tx_unlock(wvif->wdev); mutex_unlock(&wvif->wdev->conf_mutex); __ieee80211_scan_completed_compat(wvif->wdev->hw, wvif->scan.status ? 1 : 0); up(&wvif->scan.lock); + if (wvif->state == WFX_STATE_STA && + !(wvif->powersave_mode.pm_mode.enter_psm)) + wfx_set_pm(wvif, &wvif->powersave_mode); return; } first = *wvif->scan.curr; @@ -170,6 +205,11 @@ void wfx_scan_work(struct work_struct *work) scan.ssids = &wvif->scan.ssids[0]; scan.scan_req.num_of_channels = it - wvif->scan.curr; scan.scan_req.probe_delay = 100; + // FIXME: Check if FW can do active scan while joined. + if (wvif->state == WFX_STATE_STA) { + scan.scan_req.scan_type.type = 1; + scan.scan_req.scan_flags.fbg = 1; + } scan.ch = kcalloc(scan.scan_req.num_of_channels, sizeof(u8), GFP_KERNEL); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 2e709b8a3bf4..2855d14a709c 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -9,11 +9,148 @@ #include "sta.h" #include "wfx.h" +#include "fwio.h" +#include "bh.h" #include "key.h" #include "scan.h" +#include "debug.h" +#include "hif_tx.h" #include "hif_tx_mib.h" #define TXOP_UNIT 32 +#define HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES 2 + +static u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates) +{ + int i; + u32 ret = 0; + // WFx only support 2GHz + struct ieee80211_supported_band *sband = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]; + + for (i = 0; i < sband->n_bitrates; i++) { + if (rates & BIT(i)) { + if (i >= sband->n_bitrates) + dev_warn(wdev->dev, "unsupported basic rate\n"); + else + ret |= BIT(sband->bitrates[i].hw_value); + } + } + return ret; +} + +static void __wfx_free_event_queue(struct list_head *list) +{ + struct wfx_hif_event *event, *tmp; + + list_for_each_entry_safe(event, tmp, list, link) { + list_del(&event->link); + kfree(event); + } +} + +static void wfx_free_event_queue(struct wfx_vif *wvif) +{ + LIST_HEAD(list); + + spin_lock(&wvif->event_queue_lock); + list_splice_init(&wvif->event_queue, &list); + spin_unlock(&wvif->event_queue_lock); + + __wfx_free_event_queue(&list); +} + +void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad) +{ + int tx = 0; + + mutex_lock(&wvif->bss_loss_lock); + wvif->delayed_link_loss = 0; + cancel_work_sync(&wvif->bss_params_work); + + /* If we have a pending unjoin */ + if (wvif->delayed_unjoin) + goto end; + + if (init) { + schedule_delayed_work(&wvif->bss_loss_work, HZ); + wvif->bss_loss_state = 0; + + if (!atomic_read(&wvif->wdev->tx_lock)) + tx = 1; + } else if (good) { + cancel_delayed_work_sync(&wvif->bss_loss_work); + wvif->bss_loss_state = 0; + schedule_work(&wvif->bss_params_work); + } else if (bad) { + /* FIXME Should we just keep going until we time out? */ + if (wvif->bss_loss_state < 3) + tx = 1; + } else { + cancel_delayed_work_sync(&wvif->bss_loss_work); + wvif->bss_loss_state = 0; + } + + /* Spit out a NULL packet to our AP if necessary */ + // FIXME: call ieee80211_beacon_loss/ieee80211_connection_loss instead + if (tx) { + struct sk_buff *skb; + + wvif->bss_loss_state++; + + skb = ieee80211_nullfunc_get(wvif->wdev->hw, wvif->vif, false); + if (!skb) + goto end; + memset(IEEE80211_SKB_CB(skb), 0, sizeof(*IEEE80211_SKB_CB(skb))); + IEEE80211_SKB_CB(skb)->control.vif = wvif->vif; + IEEE80211_SKB_CB(skb)->driver_rates[0].idx = 0; + IEEE80211_SKB_CB(skb)->driver_rates[0].count = 1; + IEEE80211_SKB_CB(skb)->driver_rates[1].idx = -1; + wfx_tx(wvif->wdev->hw, NULL, skb); + } +end: + mutex_unlock(&wvif->bss_loss_lock); +} + +static int wfx_set_uapsd_param(struct wfx_vif *wvif, + const struct wfx_edca_params *arg) +{ + int ret; + + /* Here's the mapping AC [queue, bit] + * VO [0,3], VI [1, 2], BE [2, 1], BK [3, 0] + */ + + if (arg->uapsd_enable[IEEE80211_AC_VO]) + wvif->uapsd_info.trig_voice = 1; + else + wvif->uapsd_info.trig_voice = 0; + + if (arg->uapsd_enable[IEEE80211_AC_VI]) + wvif->uapsd_info.trig_video = 1; + else + wvif->uapsd_info.trig_video = 0; + + if (arg->uapsd_enable[IEEE80211_AC_BE]) + wvif->uapsd_info.trig_be = 1; + else + wvif->uapsd_info.trig_be = 0; + + if (arg->uapsd_enable[IEEE80211_AC_BK]) + wvif->uapsd_info.trig_bckgrnd = 1; + else + wvif->uapsd_info.trig_bckgrnd = 0; + + /* Currently pseudo U-APSD operation is not supported, so setting + * MinAutoTriggerInterval, MaxAutoTriggerInterval and + * AutoTriggerStep to 0 + */ + wvif->uapsd_info.min_auto_trigger_interval = 0; + wvif->uapsd_info.max_auto_trigger_interval = 0; + wvif->uapsd_info.auto_trigger_step = 0; + + ret = hif_set_uapsd_info(wvif, &wvif->uapsd_info); + return ret; +} int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable) { @@ -22,6 +159,1044 @@ int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable) wvif->fwd_probe_req); } +static int wfx_set_mcast_filter(struct wfx_vif *wvif, + struct wfx_grp_addr_table *fp) +{ + int i, ret; + struct hif_mib_config_data_filter config = { }; + struct hif_mib_set_data_filtering filter_data = { }; + struct hif_mib_mac_addr_data_frame_condition filter_addr_val = { }; + struct hif_mib_uc_mc_bc_data_frame_condition filter_addr_type = { }; + + // Temporary workaround for filters + return hif_set_data_filtering(wvif, &filter_data); + + if (!fp->enable) { + filter_data.enable = 0; + return hif_set_data_filtering(wvif, &filter_data); + } + + // A1 Address match on list + for (i = 0; i < fp->num_addresses; i++) { + filter_addr_val.condition_idx = i; + filter_addr_val.address_type = HIF_MAC_ADDR_A1; + ether_addr_copy(filter_addr_val.mac_address, fp->address_list[i]); + ret = hif_set_mac_addr_condition(wvif, &filter_addr_val); + if (ret) + return ret; + config.mac_cond |= 1 << i; + } + + // Accept unicast and broadcast + filter_addr_type.condition_idx = 0; + filter_addr_type.param.bits.type_unicast = 1; + filter_addr_type.param.bits.type_broadcast = 1; + ret = hif_set_uc_mc_bc_condition(wvif, &filter_addr_type); + if (ret) + return ret; + + config.uc_mc_bc_cond = 1; + config.filter_idx = 0; // TODO #define MULTICAST_FILTERING 0 + config.enable = 1; + ret = hif_set_config_data_filter(wvif, &config); + if (ret) + return ret; + + // discard all data frames except match filter + filter_data.enable = 1; + filter_data.default_filter = 1; // discard all + ret = hif_set_data_filtering(wvif, &filter_data); + + return ret; +} + +void wfx_update_filtering(struct wfx_vif *wvif) +{ + int ret; + bool is_sta = wvif->vif && NL80211_IFTYPE_STATION == wvif->vif->type; + bool filter_bssid = wvif->filter_bssid; + bool fwd_probe_req = wvif->fwd_probe_req; + struct hif_mib_bcn_filter_enable bf_ctrl; + struct hif_mib_bcn_filter_table *bf_tbl; + struct hif_ie_table_entry ie_tbl[] = { + { + .ie_id = WLAN_EID_VENDOR_SPECIFIC, + .has_changed = 1, + .no_longer = 1, + .has_appeared = 1, + .oui = { 0x50, 0x6F, 0x9A}, + }, { + .ie_id = WLAN_EID_HT_OPERATION, + .has_changed = 1, + .no_longer = 1, + .has_appeared = 1, + }, { + .ie_id = WLAN_EID_ERP_INFO, + .has_changed = 1, + .no_longer = 1, + .has_appeared = 1, + } + }; + + if (wvif->state == WFX_STATE_PASSIVE) + return; + + bf_tbl = kmalloc(sizeof(struct hif_mib_bcn_filter_table) + sizeof(ie_tbl), GFP_KERNEL); + memcpy(bf_tbl->ie_table, ie_tbl, sizeof(ie_tbl)); + if (wvif->disable_beacon_filter) { + bf_ctrl.enable = 0; + bf_ctrl.bcn_count = 1; + bf_tbl->num_of_info_elmts = 0; + } else if (!is_sta) { + bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE | HIF_BEACON_FILTER_AUTO_ERP; + bf_ctrl.bcn_count = 0; + bf_tbl->num_of_info_elmts = 2; + } else { + bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE; + bf_ctrl.bcn_count = 0; + bf_tbl->num_of_info_elmts = 3; + } + + ret = hif_set_rx_filter(wvif, filter_bssid, fwd_probe_req); + if (!ret) + ret = hif_set_beacon_filter_table(wvif, bf_tbl); + if (!ret) + ret = hif_beacon_filter_control(wvif, bf_ctrl.enable, bf_ctrl.bcn_count); + if (!ret) + ret = wfx_set_mcast_filter(wvif, &wvif->mcast_filter); + if (ret) + dev_err(wvif->wdev->dev, "update filtering failed: %d\n", ret); + kfree(bf_tbl); +} + +void wfx_update_filtering_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, update_filtering_work); + + wfx_update_filtering(wvif); +} + +u64 wfx_prepare_multicast(struct ieee80211_hw *hw, struct netdev_hw_addr_list *mc_list) +{ + int i; + struct netdev_hw_addr *ha; + struct wfx_vif *wvif = NULL; + struct wfx_dev *wdev = hw->priv; + int count = netdev_hw_addr_list_count(mc_list); + + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + memset(&wvif->mcast_filter, 0x00, sizeof(wvif->mcast_filter)); + if (!count || count > ARRAY_SIZE(wvif->mcast_filter.address_list)) + continue; + + i = 0; + netdev_hw_addr_list_for_each(ha, mc_list) { + ether_addr_copy(wvif->mcast_filter.address_list[i], ha->addr); + i++; + } + wvif->mcast_filter.enable = 1; + wvif->mcast_filter.num_addresses = count; + } + + return 0; +} + +void wfx_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 unused) +{ + struct wfx_vif *wvif = NULL; + struct wfx_dev *wdev = hw->priv; + + *total_flags &= FIF_OTHER_BSS | FIF_FCSFAIL | FIF_PROBE_REQ; + + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + down(&wvif->scan.lock); + wvif->filter_bssid = (*total_flags & (FIF_OTHER_BSS | FIF_PROBE_REQ)) ? 0 : 1; + wvif->disable_beacon_filter = !(*total_flags & FIF_PROBE_REQ); + wfx_fwd_probe_req(wvif, true); + wfx_update_filtering(wvif); + up(&wvif->scan.lock); + } +} + +int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u16 queue, const struct ieee80211_tx_queue_params *params) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + int ret = 0; + /* To prevent re-applying PM request OID again and again*/ + u16 old_uapsd_flags, new_uapsd_flags; + struct hif_req_edca_queue_params *edca; + + mutex_lock(&wdev->conf_mutex); + + if (queue < hw->queues) { + old_uapsd_flags = *((u16 *) &wvif->uapsd_info); + edca = &wvif->edca.params[queue]; + + wvif->edca.uapsd_enable[queue] = params->uapsd; + edca->aifsn = params->aifs; + edca->cw_min = params->cw_min; + edca->cw_max = params->cw_max; + edca->tx_op_limit = params->txop * TXOP_UNIT; + edca->allowed_medium_time = 0; + ret = hif_set_edca_queue_params(wvif, edca); + if (ret) { + ret = -EINVAL; + goto out; + } + + if (wvif->vif->type == NL80211_IFTYPE_STATION) { + ret = wfx_set_uapsd_param(wvif, &wvif->edca); + new_uapsd_flags = *((u16 *) &wvif->uapsd_info); + if (!ret && wvif->setbssparams_done && + wvif->state == WFX_STATE_STA && + old_uapsd_flags != new_uapsd_flags) + ret = wfx_set_pm(wvif, &wvif->powersave_mode); + } + } else { + ret = -EINVAL; + } + +out: + mutex_unlock(&wdev->conf_mutex); + return ret; +} + +int wfx_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg) +{ + struct hif_req_set_pm_mode pm = *arg; + u16 uapsd_flags; + int ret; + + if (wvif->state != WFX_STATE_STA || !wvif->bss_params.aid) + return 0; + + memcpy(&uapsd_flags, &wvif->uapsd_info, sizeof(uapsd_flags)); + + if (uapsd_flags != 0) + pm.pm_mode.fast_psm = 0; + + // Kernel disable PowerSave when multiple vifs are in use. In contrary, + // it is absolutly necessary to enable PowerSave for WF200 + if (wvif_count(wvif->wdev) > 1) { + pm.pm_mode.enter_psm = 1; + pm.pm_mode.fast_psm = 0; + } + + if (!wait_for_completion_timeout(&wvif->set_pm_mode_complete, msecs_to_jiffies(300))) + dev_warn(wvif->wdev->dev, "timeout while waiting of set_pm_mode_complete\n"); + ret = hif_set_pm(wvif, &pm); + // FIXME: why ? + if (-ETIMEDOUT == wvif->scan.status) + wvif->scan.status = 1; + return ret; +} + +int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = NULL; + + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) + hif_rts_threshold(wvif, value); + return 0; +} + +/* If successful, LOCKS the TX queue! */ +static int __wfx_flush(struct wfx_dev *wdev, bool drop) +{ + int ret; + + for (;;) { + if (drop) { + wfx_tx_queues_clear(wdev); + } else { + ret = wait_event_timeout( + wdev->tx_queue_stats.wait_link_id_empty, + wfx_tx_queues_is_empty(wdev), + 2 * HZ); + } + + if (!drop && ret <= 0) { + ret = -ETIMEDOUT; + break; + } + ret = 0; + + wfx_tx_lock_flush(wdev); + if (!wfx_tx_queues_is_empty(wdev)) { + /* Highly unlikely: WSM requeued frames. */ + wfx_tx_unlock(wdev); + continue; + } + break; + } + return ret; +} + +void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 queues, bool drop) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif; + + if (vif) { + wvif = (struct wfx_vif *) vif->drv_priv; + if (wvif->vif->type == NL80211_IFTYPE_MONITOR) + drop = true; + if (wvif->vif->type == NL80211_IFTYPE_AP && !wvif->enable_beacon) + drop = true; + } + + // FIXME: only flush requested vif + if (!__wfx_flush(wdev, drop)) + wfx_tx_unlock(wdev); +} + +/* WSM callbacks */ + +static void wfx_event_report_rssi(struct wfx_vif *wvif, uint8_t raw_rcpi_rssi) +{ + /* RSSI: signed Q8.0, RCPI: unsigned Q7.1 + * RSSI = RCPI / 2 - 110 + */ + int rcpi_rssi; + int cqm_evt; + + rcpi_rssi = raw_rcpi_rssi / 2 - 110; + if (rcpi_rssi <= wvif->cqm_rssi_thold) + cqm_evt = NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW; + else + cqm_evt = NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH; + ieee80211_cqm_rssi_notify(wvif->vif, cqm_evt, rcpi_rssi, GFP_KERNEL); +} + +void wfx_event_handler_work(struct work_struct *work) +{ + struct wfx_vif *wvif = + container_of(work, struct wfx_vif, event_handler_work); + struct wfx_hif_event *event; + + LIST_HEAD(list); + + spin_lock(&wvif->event_queue_lock); + list_splice_init(&wvif->event_queue, &list); + spin_unlock(&wvif->event_queue_lock); + + list_for_each_entry(event, &list, link) { + switch (event->evt.event_id) { + case HIF_EVENT_IND_BSSLOST: + cancel_work_sync(&wvif->unjoin_work); + if (!down_trylock(&wvif->scan.lock)) { + wfx_cqm_bssloss_sm(wvif, 1, 0, 0); + up(&wvif->scan.lock); + } else { + /* Scan is in progress. Delay reporting. + * Scan complete will trigger bss_loss_work + */ + wvif->delayed_link_loss = 1; + /* Also start a watchdog. */ + schedule_delayed_work(&wvif->bss_loss_work, 5 * HZ); + } + break; + case HIF_EVENT_IND_BSSREGAINED: + wfx_cqm_bssloss_sm(wvif, 0, 0, 0); + cancel_work_sync(&wvif->unjoin_work); + break; + case HIF_EVENT_IND_RCPI_RSSI: + wfx_event_report_rssi(wvif, event->evt.event_data.rcpi_rssi); + break; + case HIF_EVENT_IND_PS_MODE_ERROR: + dev_warn(wvif->wdev->dev, "error while processing power save request\n"); + break; + default: + dev_warn(wvif->wdev->dev, "unhandled event indication: %.2x\n", event->evt.event_id); + break; + } + } + __wfx_free_event_queue(&list); +} + +void wfx_bss_loss_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, bss_loss_work.work); + + ieee80211_connection_loss(wvif->vif); +} + +void wfx_bss_params_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, bss_params_work); + + mutex_lock(&wvif->wdev->conf_mutex); + wvif->bss_params.bss_flags.lost_count_only = 1; + hif_set_bss_params(wvif, &wvif->bss_params); + wvif->bss_params.bss_flags.lost_count_only = 0; + mutex_unlock(&wvif->wdev->conf_mutex); +} + +void wfx_set_beacon_wakeup_period_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_beacon_wakeup_period_work); + + hif_set_beacon_wakeup_period(wvif, wvif->dtim_period, wvif->dtim_period); +} + +static void wfx_do_unjoin(struct wfx_vif *wvif) +{ + mutex_lock(&wvif->wdev->conf_mutex); + + if (atomic_read(&wvif->scan.in_progress)) { + if (wvif->delayed_unjoin) + dev_dbg(wvif->wdev->dev, "delayed unjoin is already scheduled\n"); + else + wvif->delayed_unjoin = true; + goto done; + } + + wvif->delayed_link_loss = false; + + if (!wvif->state) + goto done; + + if (wvif->state == WFX_STATE_AP) + goto done; + + cancel_work_sync(&wvif->update_filtering_work); + cancel_work_sync(&wvif->set_beacon_wakeup_period_work); + wvif->state = WFX_STATE_PASSIVE; + + /* Unjoin is a reset. */ + wfx_tx_flush(wvif->wdev); + hif_keep_alive_period(wvif, 0); + hif_reset(wvif, false); + hif_set_output_power(wvif, wvif->wdev->output_power * 10); + wvif->dtim_period = 0; + hif_set_macaddr(wvif, wvif->vif->addr); + wfx_free_event_queue(wvif); + cancel_work_sync(&wvif->event_handler_work); + wfx_cqm_bssloss_sm(wvif, 0, 0, 0); + + /* Disable Block ACKs */ + hif_set_block_ack_policy(wvif, 0, 0); + + wvif->disable_beacon_filter = false; + wfx_update_filtering(wvif); + memset(&wvif->bss_params, 0, sizeof(wvif->bss_params)); + wvif->setbssparams_done = false; + memset(&wvif->ht_info, 0, sizeof(wvif->ht_info)); + +done: + mutex_unlock(&wvif->wdev->conf_mutex); +} + +static void wfx_set_mfp(struct wfx_vif *wvif, struct cfg80211_bss *bss) +{ + const int pairwise_cipher_suite_count_offset = 8 / sizeof(uint16_t); + const int pairwise_cipher_suite_size = 4 / sizeof(uint16_t); + const int akm_suite_size = 4 / sizeof(uint16_t); + const uint16_t *ptr = NULL; + bool mfpc = false; + bool mfpr = false; + + /* 802.11w protected mgmt frames */ + + /* retrieve MFPC and MFPR flags from beacon or PBRSP */ + + rcu_read_lock(); + if (bss) + ptr = (const uint16_t *) ieee80211_bss_get_ie(bss, WLAN_EID_RSN); + + if (ptr) { + ptr += pairwise_cipher_suite_count_offset; + ptr += 1 + pairwise_cipher_suite_size * *ptr; + ptr += 1 + akm_suite_size * *ptr; + mfpr = *ptr & BIT(6); + mfpc = *ptr & BIT(7); + } + rcu_read_unlock(); + + hif_set_mfp(wvif, mfpc, mfpr); +} + +/* MUST be called with tx_lock held! It will be unlocked for us. */ +static void wfx_do_join(struct wfx_vif *wvif) +{ + const u8 *bssid; + struct ieee80211_bss_conf *conf = &wvif->vif->bss_conf; + struct cfg80211_bss *bss = NULL; + struct hif_req_join join = { + .mode = conf->ibss_joined ? HIF_MODE_IBSS : HIF_MODE_BSS, + .preamble_type = conf->use_short_preamble ? HIF_PREAMBLE_SHORT : HIF_PREAMBLE_LONG, + .probe_for_join = 1, + .atim_window = 0, + .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates), + }; + + if (wvif->channel->flags & IEEE80211_CHAN_NO_IR) + join.probe_for_join = 0; + + if (wvif->state) + wfx_do_unjoin(wvif); + + bssid = wvif->vif->bss_conf.bssid; + + bss = cfg80211_get_bss(wvif->wdev->hw->wiphy, wvif->channel, bssid, NULL, 0, + IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY); + + if (!bss && !conf->ibss_joined) { + wfx_tx_unlock(wvif->wdev); + return; + } + + mutex_lock(&wvif->wdev->conf_mutex); + + /* Under the conf lock: check scan status and + * bail out if it is in progress. + */ + if (atomic_read(&wvif->scan.in_progress)) { + wfx_tx_unlock(wvif->wdev); + goto done_put; + } + + /* Sanity check basic rates */ + if (!join.basic_rate_set) + join.basic_rate_set = 7; + + /* Sanity check beacon interval */ + if (!wvif->beacon_int) + wvif->beacon_int = 1; + + join.beacon_interval = wvif->beacon_int; + + // DTIM period will be set on first Beacon + wvif->dtim_period = 0; + + join.channel_number = wvif->channel->hw_value; + memcpy(join.bssid, bssid, sizeof(join.bssid)); + + if (!conf->ibss_joined) { + const u8 *ssidie; + + rcu_read_lock(); + ssidie = ieee80211_bss_get_ie(bss, WLAN_EID_SSID); + if (ssidie) { + join.ssid_length = ssidie[1]; + memcpy(join.ssid, &ssidie[2], join.ssid_length); + } + rcu_read_unlock(); + } + + wfx_tx_flush(wvif->wdev); + + if (wvif_count(wvif->wdev) <= 1) + hif_set_block_ack_policy(wvif, 0xFF, 0xFF); + + wfx_set_mfp(wvif, bss); + + /* Perform actual join */ + wvif->wdev->tx_burst_idx = -1; + if (hif_join(wvif, &join)) { + ieee80211_connection_loss(wvif->vif); + wvif->join_complete_status = -1; + /* Tx lock still held, unjoin will clear it. */ + if (!schedule_work(&wvif->unjoin_work)) + wfx_tx_unlock(wvif->wdev); + } else { + wvif->join_complete_status = 0; + if (wvif->vif->type == NL80211_IFTYPE_ADHOC) + wvif->state = WFX_STATE_IBSS; + else + wvif->state = WFX_STATE_PRE_STA; + wfx_tx_unlock(wvif->wdev); + + /* Upload keys */ + wfx_upload_keys(wvif); + + /* Due to beacon filtering it is possible that the + * AP's beacon is not known for the mac80211 stack. + * Disable filtering temporary to make sure the stack + * receives at least one + */ + wvif->disable_beacon_filter = true; + } + wfx_update_filtering(wvif); + +done_put: + mutex_unlock(&wvif->wdev->conf_mutex); + if (bss) + cfg80211_put_bss(wvif->wdev->hw->wiphy, bss); +} + +void wfx_unjoin_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, unjoin_work); + + wfx_do_unjoin(wvif); + wfx_tx_unlock(wvif->wdev); +} + +int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv; + struct wfx_link_entry *entry; + struct sk_buff *skb; + + if (wvif->vif->type != NL80211_IFTYPE_AP) + return 0; + + sta_priv->vif_id = wvif->id; + sta_priv->link_id = wfx_find_link_id(wvif, sta->addr); + if (!sta_priv->link_id) { + dev_warn(wdev->dev, "mo more link-id available\n"); + return -ENOENT; + } + + entry = &wvif->link_id_db[sta_priv->link_id - 1]; + spin_lock_bh(&wvif->ps_state_lock); + if ((sta->uapsd_queues & IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) == + IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK) + wvif->sta_asleep_mask |= BIT(sta_priv->link_id); + entry->status = WFX_LINK_HARD; + while ((skb = skb_dequeue(&entry->rx_queue))) + ieee80211_rx_irqsafe(wdev->hw, skb); + spin_unlock_bh(&wvif->ps_state_lock); + return 0; +} + +int wfx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv; + struct wfx_link_entry *entry; + + if (wvif->vif->type != NL80211_IFTYPE_AP || !sta_priv->link_id) + return 0; + + entry = &wvif->link_id_db[sta_priv->link_id - 1]; + spin_lock_bh(&wvif->ps_state_lock); + entry->status = WFX_LINK_RESERVE; + entry->timestamp = jiffies; + wfx_tx_lock(wdev); + if (!schedule_work(&wvif->link_id_work)) + wfx_tx_unlock(wdev); + spin_unlock_bh(&wvif->ps_state_lock); + flush_work(&wvif->link_id_work); + return 0; +} + +void wfx_set_cts_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_cts_work); + u8 erp_ie[3] = { WLAN_EID_ERP_INFO, 1, 0 }; + struct hif_ie_flags target_frame = { + .beacon = 1, + }; + + mutex_lock(&wvif->wdev->conf_mutex); + erp_ie[2] = wvif->erp_info; + mutex_unlock(&wvif->wdev->conf_mutex); + + hif_erp_use_protection(wvif, erp_ie[2] & WLAN_ERP_USE_PROTECTION); + + if (wvif->vif->type != NL80211_IFTYPE_STATION) + hif_update_ie(wvif, &target_frame, erp_ie, sizeof(erp_ie)); +} + +static int wfx_start_ap(struct wfx_vif *wvif) +{ + int ret; + struct ieee80211_bss_conf *conf = &wvif->vif->bss_conf; + struct hif_req_start start = { + .channel_number = wvif->channel->hw_value, + .beacon_interval = conf->beacon_int, + .dtim_period = conf->dtim_period, + .preamble_type = conf->use_short_preamble ? HIF_PREAMBLE_SHORT : HIF_PREAMBLE_LONG, + .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates), + }; + + memset(start.ssid, 0, sizeof(start.ssid)); + if (!conf->hidden_ssid) { + start.ssid_length = conf->ssid_len; + memcpy(start.ssid, conf->ssid, start.ssid_length); + } + + wvif->beacon_int = conf->beacon_int; + wvif->dtim_period = conf->dtim_period; + + memset(&wvif->link_id_db, 0, sizeof(wvif->link_id_db)); + + wvif->wdev->tx_burst_idx = -1; + ret = hif_start(wvif, &start); + if (!ret) + ret = wfx_upload_keys(wvif); + if (!ret) { + if (wvif_count(wvif->wdev) <= 1) + hif_set_block_ack_policy(wvif, 0xFF, 0xFF); + wvif->state = WFX_STATE_AP; + wfx_update_filtering(wvif); + } + return ret; +} + +static int wfx_update_beaconing(struct wfx_vif *wvif) +{ + struct ieee80211_bss_conf *conf = &wvif->vif->bss_conf; + + if (wvif->vif->type == NL80211_IFTYPE_AP) { + /* TODO: check if changed channel, band */ + if (wvif->state != WFX_STATE_AP || + wvif->beacon_int != conf->beacon_int) { + wfx_tx_lock_flush(wvif->wdev); + if (wvif->state != WFX_STATE_PASSIVE) + hif_reset(wvif, false); + wvif->state = WFX_STATE_PASSIVE; + wfx_start_ap(wvif); + wfx_tx_unlock(wvif->wdev); + } else { + } + } + return 0; +} + +static int wfx_upload_beacon(struct wfx_vif *wvif) +{ + int ret = 0; + struct sk_buff *skb = NULL; + struct ieee80211_mgmt *mgmt; + struct hif_mib_template_frame *p; + + if (wvif->vif->type == NL80211_IFTYPE_STATION || + wvif->vif->type == NL80211_IFTYPE_MONITOR || + wvif->vif->type == NL80211_IFTYPE_UNSPECIFIED) + goto done; + + skb = ieee80211_beacon_get(wvif->wdev->hw, wvif->vif); + + if (!skb) + return -ENOMEM; + + p = (struct hif_mib_template_frame *) skb_push(skb, 4); + p->frame_type = HIF_TMPLT_BCN; + p->init_rate = API_RATE_INDEX_B_1MBPS; /* 1Mbps DSSS */ + p->frame_length = cpu_to_le16(skb->len - 4); + + ret = hif_set_template_frame(wvif, p); + + skb_pull(skb, 4); + + if (ret) + goto done; + /* TODO: Distill probe resp; remove TIM and any other beacon-specific + * IEs + */ + mgmt = (void *)skb->data; + mgmt->frame_control = + cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); + + p->frame_type = HIF_TMPLT_PRBRES; + + ret = hif_set_template_frame(wvif, p); + wfx_fwd_probe_req(wvif, false); + +done: + if (!skb) + dev_kfree_skb(skb); + return ret; +} + +static int wfx_is_ht(const struct wfx_ht_info *ht_info) +{ + return ht_info->channel_type != NL80211_CHAN_NO_HT; +} + +static int wfx_ht_greenfield(const struct wfx_ht_info *ht_info) +{ + return wfx_is_ht(ht_info) && + (ht_info->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && + !(ht_info->operation_mode & + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); +} + +static int wfx_ht_ampdu_density(const struct wfx_ht_info *ht_info) +{ + if (!wfx_is_ht(ht_info)) + return 0; + return ht_info->ht_cap.ampdu_density; +} + +static void wfx_join_finalize(struct wfx_vif *wvif, struct ieee80211_bss_conf *info) +{ + struct ieee80211_sta *sta = NULL; + struct hif_mib_set_association_mode association_mode = { }; + + if (info->dtim_period) + wvif->dtim_period = info->dtim_period; + wvif->beacon_int = info->beacon_int; + + rcu_read_lock(); + if (info->bssid && !info->ibss_joined) + sta = ieee80211_find_sta(wvif->vif, info->bssid); + if (sta) { + wvif->ht_info.ht_cap = sta->ht_cap; + wvif->bss_params.operational_rate_set = + wfx_rate_mask_to_hw(wvif->wdev, sta->supp_rates[wvif->channel->band]); + wvif->ht_info.operation_mode = info->ht_operation_mode; + } else { + memset(&wvif->ht_info, 0, sizeof(wvif->ht_info)); + wvif->bss_params.operational_rate_set = -1; + } + rcu_read_unlock(); + + /* Non Greenfield stations present */ + if (wvif->ht_info.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) + hif_dual_cts_protection(wvif, true); + else + hif_dual_cts_protection(wvif, false); + + association_mode.preambtype_use = 1; + association_mode.mode = 1; + association_mode.rateset = 1; + association_mode.spacing = 1; + association_mode.preamble_type = info->use_short_preamble ? HIF_PREAMBLE_SHORT : HIF_PREAMBLE_LONG; + association_mode.basic_rate_set = cpu_to_le32(wfx_rate_mask_to_hw(wvif->wdev, info->basic_rates)); + association_mode.mixed_or_greenfield_type = wfx_ht_greenfield(&wvif->ht_info); + association_mode.mpdu_start_spacing = wfx_ht_ampdu_density(&wvif->ht_info); + + wfx_cqm_bssloss_sm(wvif, 0, 0, 0); + cancel_work_sync(&wvif->unjoin_work); + + wvif->bss_params.beacon_lost_count = 20; + wvif->bss_params.aid = info->aid; + + if (wvif->dtim_period < 1) + wvif->dtim_period = 1; + + hif_set_association_mode(wvif, &association_mode); + + if (!info->ibss_joined) { + hif_keep_alive_period(wvif, 30 /* sec */); + hif_set_bss_params(wvif, &wvif->bss_params); + wvif->setbssparams_done = true; + wfx_set_beacon_wakeup_period_work(&wvif->set_beacon_wakeup_period_work); + wfx_set_pm(wvif, &wvif->powersave_mode); + } +} + +void wfx_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *info, + u32 changed) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + bool do_join = false; + int i; + int nb_arp_addr; + + mutex_lock(&wdev->conf_mutex); + + /* TODO: BSS_CHANGED_QOS */ + if (changed & BSS_CHANGED_ARP_FILTER) { + struct hif_mib_arp_ip_addr_table filter = { }; + + nb_arp_addr = info->arp_addr_cnt; + if (nb_arp_addr <= 0 || nb_arp_addr > HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES) + nb_arp_addr = 0; + + for (i = 0; i < HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES; i++) { + filter.condition_idx = i; + if (i < nb_arp_addr) { + // Caution: type of arp_addr_list[i] is __be32 + memcpy(filter.ipv4_address, &info->arp_addr_list[i], sizeof(filter.ipv4_address)); + filter.arp_enable = HIF_ARP_NS_FILTERING_ENABLE; + } else { + filter.arp_enable = HIF_ARP_NS_FILTERING_DISABLE; + } + hif_set_arp_ipv4_filter(wvif, &filter); + } + } + + if (changed & + (BSS_CHANGED_BEACON | BSS_CHANGED_AP_PROBE_RESP | + BSS_CHANGED_BSSID | BSS_CHANGED_SSID | BSS_CHANGED_IBSS)) { + wvif->beacon_int = info->beacon_int; + wfx_update_beaconing(wvif); + wfx_upload_beacon(wvif); + } + + if (changed & BSS_CHANGED_BEACON_ENABLED && wvif->state != WFX_STATE_IBSS) { + if (wvif->enable_beacon != info->enable_beacon) { + hif_beacon_transmit(wvif, info->enable_beacon); + wvif->enable_beacon = info->enable_beacon; + } + } + + /* assoc/disassoc, or maybe AID changed */ + if (changed & BSS_CHANGED_ASSOC) { + wfx_tx_lock_flush(wdev); + wvif->wep_default_key_id = -1; + wfx_tx_unlock(wdev); + } + + if (changed & BSS_CHANGED_ASSOC && !info->assoc && + (wvif->state == WFX_STATE_STA || wvif->state == WFX_STATE_IBSS)) { + /* Shedule unjoin work */ + wfx_tx_lock(wdev); + if (!schedule_work(&wvif->unjoin_work)) + wfx_tx_unlock(wdev); + } else { + if (changed & BSS_CHANGED_BEACON_INT) { + if (info->ibss_joined) + do_join = true; + else if (wvif->state == WFX_STATE_AP) + wfx_update_beaconing(wvif); + } + + if (changed & BSS_CHANGED_BSSID) + do_join = true; + + if (changed & + (BSS_CHANGED_ASSOC | BSS_CHANGED_BSSID | + BSS_CHANGED_IBSS | BSS_CHANGED_BASIC_RATES | BSS_CHANGED_HT)) { + if (info->assoc) { + if (wvif->state < WFX_STATE_PRE_STA) { + ieee80211_connection_loss(vif); + mutex_unlock(&wdev->conf_mutex); + return; + } else if (wvif->state == WFX_STATE_PRE_STA) { + wvif->state = WFX_STATE_STA; + } + } else { + do_join = true; + } + + if (info->assoc || info->ibss_joined) + wfx_join_finalize(wvif, info); + else + memset(&wvif->bss_params, 0, sizeof(wvif->bss_params)); + } + } + + /* ERP Protection */ + if (changed & (BSS_CHANGED_ASSOC | + BSS_CHANGED_ERP_CTS_PROT | + BSS_CHANGED_ERP_PREAMBLE)) { + u32 prev_erp_info = wvif->erp_info; + + if (info->use_cts_prot) + wvif->erp_info |= WLAN_ERP_USE_PROTECTION; + else if (!(prev_erp_info & WLAN_ERP_NON_ERP_PRESENT)) + wvif->erp_info &= ~WLAN_ERP_USE_PROTECTION; + + if (info->use_short_preamble) + wvif->erp_info |= WLAN_ERP_BARKER_PREAMBLE; + else + wvif->erp_info &= ~WLAN_ERP_BARKER_PREAMBLE; + + if (prev_erp_info != wvif->erp_info) + schedule_work(&wvif->set_cts_work); + } + + if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_ERP_SLOT)) + hif_slot_time(wvif, info->use_short_slot ? 9 : 20); + + if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_CQM)) { + struct hif_mib_rcpi_rssi_threshold th = { + .rolling_average_count = 8, + .detection = 1, + }; + + wvif->cqm_rssi_thold = info->cqm_rssi_thold; + + if (!info->cqm_rssi_thold && !info->cqm_rssi_hyst) { + th.upperthresh = 1; + th.lowerthresh = 1; + } else { + /* FIXME It's not a correct way of setting threshold. + * Upper and lower must be set equal here and adjusted + * in callback. However current implementation is much + * more reliable and stable. + */ + /* RSSI: signed Q8.0, RCPI: unsigned Q7.1 + * RSSI = RCPI / 2 - 110 + */ + th.upper_threshold = info->cqm_rssi_thold + info->cqm_rssi_hyst; + th.upper_threshold = (th.upper_threshold + 110) * 2; + th.lower_threshold = info->cqm_rssi_thold; + th.lower_threshold = (th.lower_threshold + 110) * 2; + } + hif_set_rcpi_rssi_threshold(wvif, &th); + } + + if (changed & BSS_CHANGED_TXPOWER && info->txpower != wdev->output_power) { + wdev->output_power = info->txpower; + hif_set_output_power(wvif, wdev->output_power * 10); + } + mutex_unlock(&wdev->conf_mutex); + + if (do_join) { + wfx_tx_lock_flush(wdev); + wfx_do_join(wvif); /* Will unlock it for us */ + } +} + +static void wfx_ps_notify(struct wfx_vif *wvif, enum sta_notify_cmd notify_cmd, + int link_id) +{ + u32 bit, prev; + + spin_lock_bh(&wvif->ps_state_lock); + /* Zero link id means "for all link IDs" */ + if (link_id) { + bit = BIT(link_id); + } else if (notify_cmd != STA_NOTIFY_AWAKE) { + dev_warn(wvif->wdev->dev, "unsupported notify command\n"); + bit = 0; + } else { + bit = wvif->link_id_map; + } + prev = wvif->sta_asleep_mask & bit; + + switch (notify_cmd) { + case STA_NOTIFY_SLEEP: + if (!prev) { + if (wvif->mcast_buffered && !wvif->sta_asleep_mask) + schedule_work(&wvif->mcast_start_work); + wvif->sta_asleep_mask |= bit; + } + break; + case STA_NOTIFY_AWAKE: + if (prev) { + wvif->sta_asleep_mask &= ~bit; + wvif->pspoll_mask &= ~bit; + if (link_id && !wvif->sta_asleep_mask) + schedule_work(&wvif->mcast_stop_work); + wfx_bh_request_tx(wvif->wdev); + } + break; + } + spin_unlock_bh(&wvif->ps_state_lock); +} + +void wfx_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + enum sta_notify_cmd notify_cmd, struct ieee80211_sta *sta) +{ + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *) &sta->drv_priv; + + wfx_ps_notify(wvif, notify_cmd, sta_priv->link_id); +} + static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) { struct sk_buff *skb; @@ -33,8 +1208,11 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) skb = ieee80211_beacon_get_tim(wvif->wdev->hw, wvif->vif, &tim_offset, &tim_length); - if (!skb) + if (!skb) { + if (!__wfx_flush(wvif->wdev, true)) + wfx_tx_unlock(wvif->wdev); return -ENOENT; + } tim_ptr = skb->data + tim_offset; if (tim_offset && tim_length >= 6) { @@ -56,16 +1234,34 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) return 0; } +void wfx_set_tim_work(struct work_struct *work) +{ + struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_tim_work); + + wfx_set_tim_impl(wvif, wvif->aid0_bit_set); +} + +int wfx_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) +{ + struct wfx_dev *wdev = hw->priv; + struct wfx_sta_priv *sta_dev = (struct wfx_sta_priv *) &sta->drv_priv; + struct wfx_vif *wvif = wdev_to_wvif(wdev, sta_dev->vif_id); + + schedule_work(&wvif->set_tim_work); + return 0; +} + static void wfx_mcast_start_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, mcast_start_work); + long tmo = wvif->dtim_period * TU_TO_JIFFIES(wvif->beacon_int + 20); cancel_work_sync(&wvif->mcast_stop_work); if (!wvif->aid0_bit_set) { wfx_tx_lock_flush(wvif->wdev); wfx_set_tim_impl(wvif, true); wvif->aid0_bit_set = true; - mod_timer(&wvif->mcast_timeout, TU_TO_JIFFIES(1000)); + mod_timer(&wvif->mcast_timeout, jiffies + tmo); wfx_tx_unlock(wvif->wdev); } } @@ -95,6 +1291,134 @@ static void wfx_mcast_timeout(struct timer_list *t) spin_unlock_bh(&wvif->ps_state_lock); } +int wfx_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_ampdu_params *params) +{ + /* Aggregation is implemented fully in firmware, + * including block ack negotiation. Do not allow + * mac80211 stack to do anything: it interferes with + * the firmware. + */ + + /* Note that we still need this function stubbed. */ + + return -ENOTSUPP; +} + +void wfx_suspend_resume(struct wfx_vif *wvif, + struct hif_ind_suspend_resume_tx *arg) +{ + if (arg->suspend_resume_flags.bc_mc_only) { + bool cancel_tmo = false; + + spin_lock_bh(&wvif->ps_state_lock); + if (!arg->suspend_resume_flags.resume) + wvif->mcast_tx = false; + else + wvif->mcast_tx = wvif->aid0_bit_set && wvif->mcast_buffered; + if (wvif->mcast_tx) { + cancel_tmo = true; + wfx_bh_request_tx(wvif->wdev); + } + spin_unlock_bh(&wvif->ps_state_lock); + if (cancel_tmo) + del_timer_sync(&wvif->mcast_timeout); + } else if (arg->suspend_resume_flags.resume) { + // FIXME: should change each station status independently + wfx_ps_notify(wvif, STA_NOTIFY_AWAKE, 0); + wfx_bh_request_tx(wvif->wdev); + } else { + // FIXME: should change each station status independently + wfx_ps_notify(wvif, STA_NOTIFY_SLEEP, 0); + } +} + +int wfx_add_chanctx(struct ieee80211_hw *hw, + struct ieee80211_chanctx_conf *conf) +{ + return 0; +} + +void wfx_remove_chanctx(struct ieee80211_hw *hw, + struct ieee80211_chanctx_conf *conf) +{ +} + +void wfx_change_chanctx(struct ieee80211_hw *hw, + struct ieee80211_chanctx_conf *conf, + u32 changed) +{ +} + +int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_chanctx_conf *conf) +{ + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + struct ieee80211_channel *ch = conf->def.chan; + + WARN(wvif->channel, "channel overwrite"); + wvif->channel = ch; + wvif->ht_info.channel_type = cfg80211_get_chandef_type(&conf->def); + + return 0; +} + +void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_chanctx_conf *conf) +{ + struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + struct ieee80211_channel *ch = conf->def.chan; + + WARN(wvif->channel != ch, "channel mismatch"); + wvif->channel = NULL; +} + +int wfx_config(struct ieee80211_hw *hw, u32 changed) +{ + int ret = 0; + struct wfx_dev *wdev = hw->priv; + struct ieee80211_conf *conf = &hw->conf; + struct wfx_vif *wvif; + + // FIXME: Interface id should not been hardcoded + wvif = wdev_to_wvif(wdev, 0); + if (!wvif) { + WARN(1, "interface 0 does not exist anymore"); + return 0; + } + + down(&wvif->scan.lock); + mutex_lock(&wdev->conf_mutex); + if (changed & IEEE80211_CONF_CHANGE_POWER) { + wdev->output_power = conf->power_level; + hif_set_output_power(wvif, wdev->output_power * 10); + } + + if (changed & IEEE80211_CONF_CHANGE_PS) { + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + memset(&wvif->powersave_mode, 0, sizeof(wvif->powersave_mode)); + if (conf->flags & IEEE80211_CONF_PS) { + wvif->powersave_mode.pm_mode.enter_psm = 1; + if (conf->dynamic_ps_timeout > 0) { + wvif->powersave_mode.pm_mode.fast_psm = 1; + // Firmware does not support more than 128ms + wvif->powersave_mode.fast_psm_idle_period = + min(conf->dynamic_ps_timeout * 2, 255); + } + } + if (wvif->state == WFX_STATE_STA && wvif->bss_params.aid) + wfx_set_pm(wvif, &wvif->powersave_mode); + } + wvif = wdev_to_wvif(wdev, 0); + } + + mutex_unlock(&wdev->conf_mutex); + up(&wvif->scan.lock); + return ret; +} + int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { int i; @@ -138,8 +1462,22 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) default_edca_params[IEEE80211_AC_BK].queue_id = HIF_QUEUE_ID_BESTEFFORT; } + vif->driver_flags |= IEEE80211_VIF_BEACON_FILTER | + IEEE80211_VIF_SUPPORTS_UAPSD | + IEEE80211_VIF_SUPPORTS_CQM_RSSI; + mutex_lock(&wdev->conf_mutex); + switch (vif->type) { + case NL80211_IFTYPE_STATION: + case NL80211_IFTYPE_ADHOC: + case NL80211_IFTYPE_AP: + break; + default: + mutex_unlock(&wdev->conf_mutex); + return -EOPNOTSUPP; + } + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { if (!wdev->vif[i]) { wdev->vif[i] = vif; @@ -151,6 +1489,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mutex_unlock(&wdev->conf_mutex); return -EOPNOTSUPP; } + // FIXME: prefer use of container_of() to get vif wvif->vif = vif; wvif->wdev = wdev; @@ -158,11 +1497,16 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) INIT_DELAYED_WORK(&wvif->link_id_gc_work, wfx_link_id_gc_work); spin_lock_init(&wvif->ps_state_lock); + INIT_WORK(&wvif->set_tim_work, wfx_set_tim_work); INIT_WORK(&wvif->mcast_start_work, wfx_mcast_start_work); INIT_WORK(&wvif->mcast_stop_work, wfx_mcast_stop_work); timer_setup(&wvif->mcast_timeout, wfx_mcast_timeout, 0); + wvif->setbssparams_done = false; + mutex_init(&wvif->bss_loss_lock); + INIT_DELAYED_WORK(&wvif->bss_loss_work, wfx_bss_loss_work); + wvif->wep_default_key_id = -1; INIT_WORK(&wvif->wep_key_work, wfx_wep_key_work); @@ -170,22 +1514,115 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) INIT_WORK(&wvif->scan.work, wfx_scan_work); INIT_DELAYED_WORK(&wvif->scan.timeout, wfx_scan_timeout); + spin_lock_init(&wvif->event_queue_lock); + INIT_LIST_HEAD(&wvif->event_queue); + INIT_WORK(&wvif->event_handler_work, wfx_event_handler_work); + + init_completion(&wvif->set_pm_mode_complete); + complete(&wvif->set_pm_mode_complete); + INIT_WORK(&wvif->set_beacon_wakeup_period_work, wfx_set_beacon_wakeup_period_work); + INIT_WORK(&wvif->update_filtering_work, wfx_update_filtering_work); + INIT_WORK(&wvif->bss_params_work, wfx_bss_params_work); + INIT_WORK(&wvif->set_cts_work, wfx_set_cts_work); + INIT_WORK(&wvif->unjoin_work, wfx_unjoin_work); + mutex_unlock(&wdev->conf_mutex); + + hif_set_macaddr(wvif, vif->addr); BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); - for (i = 0; i < IEEE80211_NUM_ACS; i++) + for (i = 0; i < IEEE80211_NUM_ACS; i++) { memcpy(&wvif->edca.params[i], &default_edca_params[i], sizeof(default_edca_params[i])); + wvif->edca.uapsd_enable[i] = false; + hif_set_edca_queue_params(wvif, &wvif->edca.params[i]); + } + wfx_set_uapsd_param(wvif, &wvif->edca); + tx_policy_init(wvif); + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + // Combo mode does not support Block Acks. We can re-enable them + if (wvif_count(wdev) == 1) + hif_set_block_ack_policy(wvif, 0xFF, 0xFF); + else + hif_set_block_ack_policy(wvif, 0x00, 0x00); + // Combo force powersave mode. We can re-enable it now + wfx_set_pm(wvif, &wvif->powersave_mode); + } return 0; } void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { + struct wfx_dev *wdev = hw->priv; struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; + int i; + + // If scan is in progress, stop it + while (down_trylock(&wvif->scan.lock)) + schedule(); + up(&wvif->scan.lock); + wait_for_completion_timeout(&wvif->set_pm_mode_complete, msecs_to_jiffies(300)); + mutex_lock(&wdev->conf_mutex); + switch (wvif->state) { + case WFX_STATE_PRE_STA: + case WFX_STATE_STA: + case WFX_STATE_IBSS: + wfx_tx_lock_flush(wdev); + if (!schedule_work(&wvif->unjoin_work)) + wfx_tx_unlock(wdev); + break; + case WFX_STATE_AP: + for (i = 0; wvif->link_id_map; ++i) { + if (wvif->link_id_map & BIT(i)) { + wfx_unmap_link(wvif, i); + wvif->link_id_map &= ~BIT(i); + } + } + memset(wvif->link_id_db, 0, sizeof(wvif->link_id_db)); + wvif->sta_asleep_mask = 0; + wvif->enable_beacon = false; + wvif->mcast_tx = false; + wvif->aid0_bit_set = false; + wvif->mcast_buffered = false; + wvif->pspoll_mask = 0; + /* reset.link_id = 0; */ + hif_reset(wvif, false); + break; + default: + break; + } + + wvif->state = WFX_STATE_PASSIVE; wfx_tx_queues_wait_empty_vif(wvif); + wfx_tx_unlock(wdev); + + /* FIXME: In add to reset MAC address, try to reset interface */ + hif_set_macaddr(wvif, NULL); + + cancel_delayed_work_sync(&wvif->scan.timeout); + + wfx_cqm_bssloss_sm(wvif, 0, 0, 0); + cancel_work_sync(&wvif->unjoin_work); cancel_delayed_work_sync(&wvif->link_id_gc_work); del_timer_sync(&wvif->mcast_timeout); + wfx_free_event_queue(wvif); + + wdev->vif[wvif->id] = NULL; + wvif->vif = NULL; + + mutex_unlock(&wdev->conf_mutex); + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + // Combo mode does not support Block Acks. We can re-enable them + if (wvif_count(wdev) == 1) + hif_set_block_ack_policy(wvif, 0xFF, 0xFF); + else + hif_set_block_ack_policy(wvif, 0x00, 0x00); + // Combo force powersave mode. We can re-enable it now + wfx_set_pm(wvif, &wvif->powersave_mode); + } } int wfx_start(struct ieee80211_hw *hw) diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index dd1b6b3fc2f1..307ed0196110 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -12,14 +12,40 @@ #include "hif_api_cmd.h" +struct wfx_dev; struct wfx_vif; +enum wfx_state { + WFX_STATE_PASSIVE = 0, + WFX_STATE_PRE_STA, + WFX_STATE_STA, + WFX_STATE_IBSS, + WFX_STATE_AP, +}; + +struct wfx_ht_info { + struct ieee80211_sta_ht_cap ht_cap; + enum nl80211_channel_type channel_type; + uint16_t operation_mode; +}; + +struct wfx_hif_event { + struct list_head link; + struct hif_ind_event evt; +}; + struct wfx_edca_params { /* NOTE: index is a linux queue id. */ struct hif_req_edca_queue_params params[IEEE80211_NUM_ACS]; bool uapsd_enable[IEEE80211_NUM_ACS]; }; +struct wfx_grp_addr_table { + bool enable; + int num_addresses; + u8 address_list[8][ETH_ALEN]; +}; + struct wfx_sta_priv { int link_id; int vif_id; @@ -28,9 +54,48 @@ struct wfx_sta_priv { // mac80211 interface int wfx_start(struct ieee80211_hw *hw); void wfx_stop(struct ieee80211_hw *hw); +int wfx_config(struct ieee80211_hw *hw, u32 changed); +int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value); +u64 wfx_prepare_multicast(struct ieee80211_hw *hw, + struct netdev_hw_addr_list *mc_list); +void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, + unsigned int *total_flags, u64 unused); + int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 queues, bool drop); +int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u16 queue, const struct ieee80211_tx_queue_params *params); +void wfx_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_bss_conf *info, u32 changed); +int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta); +int wfx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta); +void wfx_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + enum sta_notify_cmd cmd, struct ieee80211_sta *sta); +int wfx_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set); +int wfx_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_ampdu_params *params); +int wfx_add_chanctx(struct ieee80211_hw *hw, + struct ieee80211_chanctx_conf *conf); +void wfx_remove_chanctx(struct ieee80211_hw *hw, + struct ieee80211_chanctx_conf *conf); +void wfx_change_chanctx(struct ieee80211_hw *hw, + struct ieee80211_chanctx_conf *conf, u32 changed); +int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_chanctx_conf *conf); +void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_chanctx_conf *conf); + +// WSM Callbacks +void wfx_suspend_resume(struct wfx_vif *wvif, struct hif_ind_suspend_resume_tx *arg); +// Other Helpers +void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad); +void wfx_update_filtering(struct wfx_vif *wvif); +int wfx_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg); int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable); #endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index a86ddfaed825..489836837b0a 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -11,6 +11,8 @@ #define WFX_H #include +#include +#include #include #include "bh.h" @@ -61,8 +63,15 @@ struct wfx_dev { struct wfx_vif { struct wfx_dev *wdev; struct ieee80211_vif *vif; + struct ieee80211_channel *channel; int id; + enum wfx_state state; + int delayed_link_loss; + int bss_loss_state; + u32 bss_loss_confirm_id; + struct mutex bss_loss_lock; + struct delayed_work bss_loss_work; u32 link_id_map; struct wfx_link_entry link_id_db[WFX_MAX_STA_IN_AP_MODE]; @@ -72,6 +81,7 @@ struct wfx_vif { bool aid0_bit_set; bool mcast_tx; bool mcast_buffered; + struct wfx_grp_addr_table mcast_filter; struct timer_list mcast_timeout; struct work_struct mcast_start_work; struct work_struct mcast_stop_work; @@ -86,13 +96,40 @@ struct wfx_vif { u32 sta_asleep_mask; u32 pspoll_mask; spinlock_t ps_state_lock; + struct work_struct set_tim_work; + + int dtim_period; + int beacon_int; + bool enable_beacon; + struct work_struct set_beacon_wakeup_period_work; bool filter_bssid; bool fwd_probe_req; + bool disable_beacon_filter; + struct work_struct update_filtering_work; + u32 erp_info; + int cqm_rssi_thold; + bool setbssparams_done; + struct wfx_ht_info ht_info; struct wfx_edca_params edca; + struct hif_mib_set_uapsd_information uapsd_info; + struct hif_req_set_bss_params bss_params; + struct work_struct bss_params_work; + struct work_struct set_cts_work; + + int join_complete_status; + bool delayed_unjoin; + struct work_struct unjoin_work; struct wfx_scan scan; + + struct hif_req_set_pm_mode powersave_mode; + struct completion set_pm_mode_complete; + + struct list_head event_queue; + spinlock_t event_queue_lock; + struct work_struct event_handler_work; }; static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) @@ -126,6 +163,20 @@ static inline struct wfx_vif *wvif_iterate(struct wfx_dev *wdev, struct wfx_vif return NULL; } +static inline int wvif_count(struct wfx_dev *wdev) +{ + int i; + int ret = 0; + struct wfx_vif *wvif; + + for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) { + wvif = wdev_to_wvif(wdev, i); + if (wvif) + ret++; + } + return ret; +} + static inline void memreverse(uint8_t *src, uint8_t length) { uint8_t *lo = src; -- cgit v1.2.3-59-g8ed1b From d7618e38461e6a3f190d88fb941befd51b7c29b0 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:11:55 +0900 Subject: staging: qlge: Fix irq masking in INTx mode Tracing the driver operation reveals that the INTR_EN_EN bit (per-queue interrupt control) does not immediately prevent rx completion interrupts when the device is operating in INTx mode. This leads to interrupts being raised while napi is scheduled/running. Those interrupts are ignored by qlge_isr() and falsely reported as IRQ_NONE thanks to the irq_cnt scheme. This in turn can cause frames to loiter in the receive queue until a later frame leads to another rx interrupt that will schedule napi. Use the INTR_EN_EI bit (master interrupt control) instead. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-2-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 6cae33072496..d7b64d360ea8 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -3366,6 +3366,7 @@ msi: } } qlge_irq_type = LEG_IRQ; + set_bit(QL_LEGACY_ENABLED, &qdev->flags); netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, "Running with legacy interrupts.\n"); } @@ -3509,6 +3510,16 @@ static void ql_resolve_queues_to_irqs(struct ql_adapter *qdev) intr_context->intr_dis_mask = INTR_EN_TYPE_MASK | INTR_EN_INTR_MASK | INTR_EN_TYPE_DISABLE; + if (test_bit(QL_LEGACY_ENABLED, &qdev->flags)) { + /* Experience shows that when using INTx interrupts, + * the device does not always auto-mask INTR_EN_EN. + * Moreover, masking INTR_EN_EN manually does not + * immediately prevent interrupt generation. + */ + intr_context->intr_en_mask |= INTR_EN_EI << 16 | + INTR_EN_EI; + intr_context->intr_dis_mask |= INTR_EN_EI << 16; + } intr_context->intr_read_mask = INTR_EN_TYPE_MASK | INTR_EN_INTR_MASK | INTR_EN_TYPE_READ; /* -- cgit v1.2.3-59-g8ed1b From e759b5cf70894a1a4a6a5e60a3bd63b7dc788b01 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:11:56 +0900 Subject: staging: qlge: Remove irq_cnt qlge uses an irq enable/disable refcounting scheme that is: * poorly implemented Uses a spin_lock to protect accesses to the irq_cnt atomic variable. * buggy Breaks when there is not a 1:1 sequence of irq - napi_poll, such as when using SO_BUSY_POLL. * unnecessary The purpose or irq_cnt is to reduce irq control writes when multiple work items result from one irq: the irq is re-enabled after all work is done. Analysis of the irq handler shows that there is only one case where there might be two workers scheduled at once, and those have separate irq masking bits. Therefore, remove irq_cnt. Additionally, we get a performance improvement: perf stat -e cycles -a -r5 super_netperf 100 -H 192.168.33.1 -t TCP_RR Before: 628560 628056 622103 622744 627202 [...] 268,803,947,669 cycles ( +- 0.09% ) After: 636300 634106 634984 638555 634188 [...] 259,237,291,449 cycles ( +- 0.19% ) Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-3-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 7 --- drivers/staging/qlge/qlge_main.c | 98 +++++++++++----------------------------- drivers/staging/qlge/qlge_mpi.c | 1 - 3 files changed, 27 insertions(+), 79 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index ad7c5eb8a3b6..5d9a36deda08 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1982,11 +1982,6 @@ struct intr_context { u32 intr_dis_mask; /* value/mask used to disable this intr */ u32 intr_read_mask; /* value/mask used to read this intr */ char name[IFNAMSIZ * 2]; - atomic_t irq_cnt; /* irq_cnt is used in single vector - * environment. It's incremented for each - * irq handler that is scheduled. When each - * handler finishes it decrements irq_cnt and - * enables interrupts if it's zero. */ irq_handler_t handler; }; @@ -2074,7 +2069,6 @@ struct ql_adapter { u32 port; /* Port number this adapter */ spinlock_t adapter_lock; - spinlock_t hw_lock; spinlock_t stats_lock; /* PCI Bus Relative Register Addresses */ @@ -2235,7 +2229,6 @@ void ql_mpi_reset_work(struct work_struct *work); void ql_mpi_core_to_log(struct work_struct *work); int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 ebit); void ql_queue_asic_error(struct ql_adapter *qdev); -u32 ql_enable_completion_interrupt(struct ql_adapter *qdev, u32 intr); void ql_set_ethtool_ops(struct net_device *ndev); int ql_read_xgmac_reg64(struct ql_adapter *qdev, u32 reg, u64 *data); void ql_mpi_idc_work(struct work_struct *work); diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index d7b64d360ea8..7a8d6390d5de 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -625,75 +625,26 @@ static void ql_disable_interrupts(struct ql_adapter *qdev) ql_write32(qdev, INTR_EN, (INTR_EN_EI << 16)); } -/* If we're running with multiple MSI-X vectors then we enable on the fly. - * Otherwise, we may have multiple outstanding workers and don't want to - * enable until the last one finishes. In this case, the irq_cnt gets - * incremented every time we queue a worker and decremented every time - * a worker finishes. Once it hits zero we enable the interrupt. - */ -u32 ql_enable_completion_interrupt(struct ql_adapter *qdev, u32 intr) +static void ql_enable_completion_interrupt(struct ql_adapter *qdev, u32 intr) { - u32 var = 0; - unsigned long hw_flags = 0; - struct intr_context *ctx = qdev->intr_context + intr; - - if (likely(test_bit(QL_MSIX_ENABLED, &qdev->flags) && intr)) { - /* Always enable if we're MSIX multi interrupts and - * it's not the default (zeroeth) interrupt. - */ - ql_write32(qdev, INTR_EN, - ctx->intr_en_mask); - var = ql_read32(qdev, STS); - return var; - } + struct intr_context *ctx = &qdev->intr_context[intr]; - spin_lock_irqsave(&qdev->hw_lock, hw_flags); - if (atomic_dec_and_test(&ctx->irq_cnt)) { - ql_write32(qdev, INTR_EN, - ctx->intr_en_mask); - var = ql_read32(qdev, STS); - } - spin_unlock_irqrestore(&qdev->hw_lock, hw_flags); - return var; + ql_write32(qdev, INTR_EN, ctx->intr_en_mask); } -static u32 ql_disable_completion_interrupt(struct ql_adapter *qdev, u32 intr) +static void ql_disable_completion_interrupt(struct ql_adapter *qdev, u32 intr) { - u32 var = 0; - struct intr_context *ctx; + struct intr_context *ctx = &qdev->intr_context[intr]; - /* HW disables for us if we're MSIX multi interrupts and - * it's not the default (zeroeth) interrupt. - */ - if (likely(test_bit(QL_MSIX_ENABLED, &qdev->flags) && intr)) - return 0; - - ctx = qdev->intr_context + intr; - spin_lock(&qdev->hw_lock); - if (!atomic_read(&ctx->irq_cnt)) { - ql_write32(qdev, INTR_EN, - ctx->intr_dis_mask); - var = ql_read32(qdev, STS); - } - atomic_inc(&ctx->irq_cnt); - spin_unlock(&qdev->hw_lock); - return var; + ql_write32(qdev, INTR_EN, ctx->intr_dis_mask); } static void ql_enable_all_completion_interrupts(struct ql_adapter *qdev) { int i; - for (i = 0; i < qdev->intr_count; i++) { - /* The enable call does a atomic_dec_and_test - * and enables only if the result is zero. - * So we precharge it here. - */ - if (unlikely(!test_bit(QL_MSIX_ENABLED, &qdev->flags) || - i == 0)) - atomic_set(&qdev->intr_context[i].irq_cnt, 1); - ql_enable_completion_interrupt(qdev, i); - } + for (i = 0; i < qdev->intr_count; i++) + ql_enable_completion_interrupt(qdev, i); } static int ql_validate_flash(struct ql_adapter *qdev, u32 size, const char *str) @@ -2500,21 +2451,22 @@ static irqreturn_t qlge_isr(int irq, void *dev_id) u32 var; int work_done = 0; - spin_lock(&qdev->hw_lock); - if (atomic_read(&qdev->intr_context[0].irq_cnt)) { - netif_printk(qdev, intr, KERN_DEBUG, qdev->ndev, - "Shared Interrupt, Not ours!\n"); - spin_unlock(&qdev->hw_lock); - return IRQ_NONE; - } - spin_unlock(&qdev->hw_lock); + /* Experience shows that when using INTx interrupts, interrupts must + * be masked manually. + * When using MSI mode, INTR_EN_EN must be explicitly disabled + * (even though it is auto-masked), otherwise a later command to + * enable it is not effective. + */ + if (!test_bit(QL_MSIX_ENABLED, &qdev->flags)) + ql_disable_completion_interrupt(qdev, 0); - var = ql_disable_completion_interrupt(qdev, intr_context->intr); + var = ql_read32(qdev, STS); /* * Check for fatal error. */ if (var & STS_FE) { + ql_disable_completion_interrupt(qdev, 0); ql_queue_asic_error(qdev); netdev_err(qdev->ndev, "Got fatal error, STS = %x.\n", var); var = ql_read32(qdev, ERR_STS); @@ -2534,7 +2486,6 @@ static irqreturn_t qlge_isr(int irq, void *dev_id) */ netif_err(qdev, intr, qdev->ndev, "Got MPI processor interrupt.\n"); - ql_disable_completion_interrupt(qdev, intr_context->intr); ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16)); queue_delayed_work_on(smp_processor_id(), qdev->workqueue, &qdev->mpi_work, 0); @@ -2550,11 +2501,18 @@ static irqreturn_t qlge_isr(int irq, void *dev_id) if (var & intr_context->irq_mask) { netif_info(qdev, intr, qdev->ndev, "Waking handler for rx_ring[0].\n"); - ql_disable_completion_interrupt(qdev, intr_context->intr); napi_schedule(&rx_ring->napi); work_done++; + } else { + /* Experience shows that the device sometimes signals an + * interrupt but no work is scheduled from this function. + * Nevertheless, the interrupt is auto-masked. Therefore, we + * systematically re-enable the interrupt if we didn't + * schedule napi. + */ + ql_enable_completion_interrupt(qdev, 0); } - ql_enable_completion_interrupt(qdev, intr_context->intr); + return work_done ? IRQ_HANDLED : IRQ_NONE; } @@ -3568,7 +3526,6 @@ static int ql_request_irq(struct ql_adapter *qdev) ql_resolve_queues_to_irqs(qdev); for (i = 0; i < qdev->intr_count; i++, intr_context++) { - atomic_set(&intr_context->irq_cnt, 0); if (test_bit(QL_MSIX_ENABLED, &qdev->flags)) { status = request_irq(qdev->msi_x_entry[i].vector, intr_context->handler, @@ -4653,7 +4610,6 @@ static int ql_init_device(struct pci_dev *pdev, struct net_device *ndev, goto err_out2; } qdev->msg_enable = netif_msg_init(debug, default_msg); - spin_lock_init(&qdev->hw_lock); spin_lock_init(&qdev->stats_lock); if (qlge_mpi_coredump) { diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index 957c72985a06..9e422bbbb6ab 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -1257,7 +1257,6 @@ void ql_mpi_work(struct work_struct *work) /* End polled mode for MPI */ ql_write32(qdev, INTR_MASK, (INTR_MASK_PI << 16) | INTR_MASK_PI); mutex_unlock(&qdev->mpi_mutex); - ql_enable_completion_interrupt(qdev, 0); } void ql_mpi_reset_work(struct work_struct *work) -- cgit v1.2.3-59-g8ed1b From f70e8459fdea1905ca9bfbf987daf9f1a1c545e8 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:11:57 +0900 Subject: staging: qlge: Remove page_chunk.last_flag As already done in ql_get_curr_lchunk(), this member can be replaced by a simple test. Signed-off-by: Benjamin Poirier Acked-by: Manish Chopra Link: https://lore.kernel.org/r/20190927101210.23856-4-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 1 - drivers/staging/qlge/qlge_main.c | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 5d9a36deda08..0a156a95e981 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1363,7 +1363,6 @@ struct page_chunk { char *va; /* virt addr for this chunk */ u64 map; /* mapping for master */ unsigned int offset; /* offset for this chunk */ - unsigned int last_flag; /* flag set for last chunk in page */ }; struct bq_desc { diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 7a8d6390d5de..a82920776e6b 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1077,11 +1077,9 @@ static int ql_get_next_chunk(struct ql_adapter *qdev, struct rx_ring *rx_ring, rx_ring->pg_chunk.offset += rx_ring->lbq_buf_size; if (rx_ring->pg_chunk.offset == ql_lbq_block_size(qdev)) { rx_ring->pg_chunk.page = NULL; - lbq_desc->p.pg_chunk.last_flag = 1; } else { rx_ring->pg_chunk.va += rx_ring->lbq_buf_size; get_page(rx_ring->pg_chunk.page); - lbq_desc->p.pg_chunk.last_flag = 0; } return 0; } @@ -2778,6 +2776,8 @@ pci_alloc_err: static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring) { + unsigned int last_offset = ql_lbq_block_size(qdev) - + rx_ring->lbq_buf_size; struct bq_desc *lbq_desc; uint32_t curr_idx, clean_idx; @@ -2787,13 +2787,10 @@ static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring while (curr_idx != clean_idx) { lbq_desc = &rx_ring->lbq[curr_idx]; - if (lbq_desc->p.pg_chunk.last_flag) { - pci_unmap_page(qdev->pdev, - lbq_desc->p.pg_chunk.map, - ql_lbq_block_size(qdev), + if (lbq_desc->p.pg_chunk.offset == last_offset) + pci_unmap_page(qdev->pdev, lbq_desc->p.pg_chunk.map, + ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); - lbq_desc->p.pg_chunk.last_flag = 0; - } put_page(lbq_desc->p.pg_chunk.page); lbq_desc->p.pg_chunk.page = NULL; -- cgit v1.2.3-59-g8ed1b From 2b27fc39da55ee45ad30bcf2f7b4deb017cb89b8 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:11:58 +0900 Subject: staging: qlge: Deduplicate lbq_buf_size lbq_buf_size is duplicated to every rx_ring structure whereas lbq_buf_order is present once in the ql_adapter structure. All rings use the same buf size, keep only one copy of it. Also factor out the calculation of lbq_buf_size instead of having two copies. Signed-off-by: Benjamin Poirier Acked-by: Willem de Bruijn Link: https://lore.kernel.org/r/20190927101210.23856-5-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 2 +- drivers/staging/qlge/qlge_dbg.c | 2 +- drivers/staging/qlge/qlge_main.c | 61 +++++++++++++++++----------------------- 3 files changed, 28 insertions(+), 37 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 0a156a95e981..ba61b4559dd6 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1433,7 +1433,6 @@ struct rx_ring { /* Large buffer queue elements. */ u32 lbq_len; /* entry count */ u32 lbq_size; /* size in bytes of queue */ - u32 lbq_buf_size; void *lbq_base; dma_addr_t lbq_base_dma; void *lbq_base_indirect; @@ -2108,6 +2107,7 @@ struct ql_adapter { struct rx_ring rx_ring[MAX_RX_RINGS]; struct tx_ring tx_ring[MAX_TX_RINGS]; unsigned int lbq_buf_order; + u32 lbq_buf_size; int rx_csum; u32 default_rx_queue; diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 5599525a19d5..718943e78406 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1629,6 +1629,7 @@ void ql_dump_qdev(struct ql_adapter *qdev) DUMP_QDEV_FIELD(qdev, "0x%08x", xg_sem_mask); DUMP_QDEV_FIELD(qdev, "0x%08x", port_link_up); DUMP_QDEV_FIELD(qdev, "0x%08x", port_init); + DUMP_QDEV_FIELD(qdev, "%u", lbq_buf_size); } #endif @@ -1773,7 +1774,6 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->lbq_curr_idx = %d\n", rx_ring->lbq_curr_idx); pr_err("rx_ring->lbq_clean_idx = %d\n", rx_ring->lbq_clean_idx); pr_err("rx_ring->lbq_free_cnt = %d\n", rx_ring->lbq_free_cnt); - pr_err("rx_ring->lbq_buf_size = %d\n", rx_ring->lbq_buf_size); pr_err("rx_ring->sbq_base = %p\n", rx_ring->sbq_base); pr_err("rx_ring->sbq_base_dma = %llx\n", diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index a82920776e6b..2b1cc4b29bed 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -995,15 +995,14 @@ static struct bq_desc *ql_get_curr_lchunk(struct ql_adapter *qdev, struct bq_desc *lbq_desc = ql_get_curr_lbuf(rx_ring); pci_dma_sync_single_for_cpu(qdev->pdev, - dma_unmap_addr(lbq_desc, mapaddr), - rx_ring->lbq_buf_size, - PCI_DMA_FROMDEVICE); + dma_unmap_addr(lbq_desc, mapaddr), + qdev->lbq_buf_size, PCI_DMA_FROMDEVICE); /* If it's the last chunk of our master page then * we unmap it. */ - if ((lbq_desc->p.pg_chunk.offset + rx_ring->lbq_buf_size) - == ql_lbq_block_size(qdev)) + if (lbq_desc->p.pg_chunk.offset + qdev->lbq_buf_size == + ql_lbq_block_size(qdev)) pci_unmap_page(qdev->pdev, lbq_desc->p.pg_chunk.map, ql_lbq_block_size(qdev), @@ -1074,11 +1073,11 @@ static int ql_get_next_chunk(struct ql_adapter *qdev, struct rx_ring *rx_ring, /* Adjust the master page chunk for next * buffer get. */ - rx_ring->pg_chunk.offset += rx_ring->lbq_buf_size; + rx_ring->pg_chunk.offset += qdev->lbq_buf_size; if (rx_ring->pg_chunk.offset == ql_lbq_block_size(qdev)) { rx_ring->pg_chunk.page = NULL; } else { - rx_ring->pg_chunk.va += rx_ring->lbq_buf_size; + rx_ring->pg_chunk.va += qdev->lbq_buf_size; get_page(rx_ring->pg_chunk.page); } return 0; @@ -1110,12 +1109,12 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) lbq_desc->p.pg_chunk.offset; dma_unmap_addr_set(lbq_desc, mapaddr, map); dma_unmap_len_set(lbq_desc, maplen, - rx_ring->lbq_buf_size); + qdev->lbq_buf_size); *lbq_desc->addr = cpu_to_le64(map); pci_dma_sync_single_for_device(qdev->pdev, map, - rx_ring->lbq_buf_size, - PCI_DMA_FROMDEVICE); + qdev->lbq_buf_size, + PCI_DMA_FROMDEVICE); clean_idx++; if (clean_idx == rx_ring->lbq_len) clean_idx = 0; @@ -1880,8 +1879,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, } do { lbq_desc = ql_get_curr_lchunk(qdev, rx_ring); - size = (length < rx_ring->lbq_buf_size) ? length : - rx_ring->lbq_buf_size; + size = min(length, qdev->lbq_buf_size); netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "Adding page %d to skb for %d bytes.\n", @@ -2776,12 +2774,12 @@ pci_alloc_err: static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring) { - unsigned int last_offset = ql_lbq_block_size(qdev) - - rx_ring->lbq_buf_size; + unsigned int last_offset; struct bq_desc *lbq_desc; uint32_t curr_idx, clean_idx; + last_offset = ql_lbq_block_size(qdev) - qdev->lbq_buf_size; curr_idx = rx_ring->lbq_curr_idx; clean_idx = rx_ring->lbq_clean_idx; while (curr_idx != clean_idx) { @@ -3149,8 +3147,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->lbq_len)); cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq_base_indirect_dma); - bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 : - (u16) rx_ring->lbq_buf_size; + bq_len = (qdev->lbq_buf_size == 65536) ? 0 : + (u16)qdev->lbq_buf_size; cqicb->lbq_buf_size = cpu_to_le16(bq_len); bq_len = (rx_ring->lbq_len == 65536) ? 0 : (u16) rx_ring->lbq_len; @@ -4059,16 +4057,21 @@ static int qlge_close(struct net_device *ndev) return 0; } +static void qlge_set_lb_size(struct ql_adapter *qdev) +{ + if (qdev->ndev->mtu <= 1500) + qdev->lbq_buf_size = LARGE_BUFFER_MIN_SIZE; + else + qdev->lbq_buf_size = LARGE_BUFFER_MAX_SIZE; + qdev->lbq_buf_order = get_order(qdev->lbq_buf_size); +} + static int ql_configure_rings(struct ql_adapter *qdev) { int i; struct rx_ring *rx_ring; struct tx_ring *tx_ring; int cpu_cnt = min(MAX_CPUS, (int)num_online_cpus()); - unsigned int lbq_buf_len = (qdev->ndev->mtu > 1500) ? - LARGE_BUFFER_MAX_SIZE : LARGE_BUFFER_MIN_SIZE; - - qdev->lbq_buf_order = get_order(lbq_buf_len); /* In a perfect world we have one RSS ring for each CPU * and each has it's own vector. To do that we ask for @@ -4116,7 +4119,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->lbq_len = NUM_LARGE_BUFFERS; rx_ring->lbq_size = rx_ring->lbq_len * sizeof(__le64); - rx_ring->lbq_buf_size = (u16)lbq_buf_len; rx_ring->sbq_len = NUM_SMALL_BUFFERS; rx_ring->sbq_size = rx_ring->sbq_len * sizeof(__le64); @@ -4132,7 +4134,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); rx_ring->lbq_len = 0; rx_ring->lbq_size = 0; - rx_ring->lbq_buf_size = 0; rx_ring->sbq_len = 0; rx_ring->sbq_size = 0; rx_ring->sbq_buf_size = 0; @@ -4151,6 +4152,7 @@ static int qlge_open(struct net_device *ndev) if (err) return err; + qlge_set_lb_size(qdev); err = ql_configure_rings(qdev); if (err) return err; @@ -4172,9 +4174,7 @@ error_up: static int ql_change_rx_buffers(struct ql_adapter *qdev) { - struct rx_ring *rx_ring; - int i, status; - u32 lbq_buf_len; + int status; /* Wait for an outstanding reset to complete. */ if (!test_bit(QL_ADAPTER_UP, &qdev->flags)) { @@ -4197,16 +4197,7 @@ static int ql_change_rx_buffers(struct ql_adapter *qdev) if (status) goto error; - /* Get the new rx buffer size. */ - lbq_buf_len = (qdev->ndev->mtu > 1500) ? - LARGE_BUFFER_MAX_SIZE : LARGE_BUFFER_MIN_SIZE; - qdev->lbq_buf_order = get_order(lbq_buf_len); - - for (i = 0; i < qdev->rss_ring_count; i++) { - rx_ring = &qdev->rx_ring[i]; - /* Set the new size. */ - rx_ring->lbq_buf_size = lbq_buf_len; - } + qlge_set_lb_size(qdev); status = ql_adapter_up(qdev); if (status) -- cgit v1.2.3-59-g8ed1b From a68a5b2fd3a2490b74cbdda53fb2de5302e973bb Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:11:59 +0900 Subject: staging: qlge: Remove bq_desc.maplen The size of the mapping is known statically in all cases, there's no need to save it at runtime. Remove this member. Signed-off-by: Benjamin Poirier Acked-by: Manish Chopra Link: https://lore.kernel.org/r/20190927101210.23856-6-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 1 - drivers/staging/qlge/qlge_main.c | 43 ++++++++++++++-------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index ba61b4559dd6..f32da8c7679f 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1373,7 +1373,6 @@ struct bq_desc { __le64 *addr; u32 index; DEFINE_DMA_UNMAP_ADDR(mapaddr); - DEFINE_DMA_UNMAP_LEN(maplen); }; #define QL_TXQ_IDX(qdev, skb) (smp_processor_id()%(qdev->tx_ring_count)) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 2b1cc4b29bed..34bc1d9560ce 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1108,8 +1108,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) map = lbq_desc->p.pg_chunk.map + lbq_desc->p.pg_chunk.offset; dma_unmap_addr_set(lbq_desc, mapaddr, map); - dma_unmap_len_set(lbq_desc, maplen, - qdev->lbq_buf_size); *lbq_desc->addr = cpu_to_le64(map); pci_dma_sync_single_for_device(qdev->pdev, map, @@ -1177,8 +1175,6 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) return; } dma_unmap_addr_set(sbq_desc, mapaddr, map); - dma_unmap_len_set(sbq_desc, maplen, - rx_ring->sbq_buf_size); *sbq_desc->addr = cpu_to_le64(map); } @@ -1598,14 +1594,14 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, pci_dma_sync_single_for_cpu(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - dma_unmap_len(sbq_desc, maplen), + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); skb_put_data(new_skb, skb->data, length); pci_dma_sync_single_for_device(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - dma_unmap_len(sbq_desc, maplen), + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); skb = new_skb; @@ -1727,8 +1723,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, sbq_desc = ql_get_curr_sbuf(rx_ring); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - dma_unmap_len(sbq_desc, maplen), - PCI_DMA_FROMDEVICE); + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); skb = sbq_desc->p.skb; ql_realign_skb(skb, hdr_len); skb_put(skb, hdr_len); @@ -1758,19 +1753,15 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, */ sbq_desc = ql_get_curr_sbuf(rx_ring); pci_dma_sync_single_for_cpu(qdev->pdev, - dma_unmap_addr - (sbq_desc, mapaddr), - dma_unmap_len - (sbq_desc, maplen), + dma_unmap_addr(sbq_desc, + mapaddr), + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); skb_put_data(skb, sbq_desc->p.skb->data, length); pci_dma_sync_single_for_device(qdev->pdev, - dma_unmap_addr - (sbq_desc, - mapaddr), - dma_unmap_len - (sbq_desc, - maplen), + dma_unmap_addr(sbq_desc, + mapaddr), + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); } else { netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, @@ -1781,10 +1772,8 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, ql_realign_skb(skb, length); skb_put(skb, length); pci_unmap_single(qdev->pdev, - dma_unmap_addr(sbq_desc, - mapaddr), - dma_unmap_len(sbq_desc, - maplen), + dma_unmap_addr(sbq_desc, mapaddr), + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); sbq_desc->p.skb = NULL; } @@ -1822,9 +1811,8 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, return NULL; } pci_unmap_page(qdev->pdev, - dma_unmap_addr(lbq_desc, - mapaddr), - dma_unmap_len(lbq_desc, maplen), + dma_unmap_addr(lbq_desc, mapaddr), + qdev->lbq_buf_size, PCI_DMA_FROMDEVICE); skb_reserve(skb, NET_IP_ALIGN); netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, @@ -1858,8 +1846,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, sbq_desc = ql_get_curr_sbuf(rx_ring); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - dma_unmap_len(sbq_desc, maplen), - PCI_DMA_FROMDEVICE); + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); if (!(ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS)) { /* * This is an non TCP/UDP IP frame, so @@ -2820,7 +2807,7 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring if (sbq_desc->p.skb) { pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - dma_unmap_len(sbq_desc, maplen), + rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); dev_kfree_skb(sbq_desc->p.skb); sbq_desc->p.skb = NULL; -- cgit v1.2.3-59-g8ed1b From 16714d98bf631909864f7eacd591ab5f7cf1588c Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:00 +0900 Subject: staging: qlge: Remove rx_ring.sbq_buf_size Tx completion rings have sbq_buf_size = 0 but there's no case where the code actually tests on that value. We can remove sbq_buf_size and use a constant instead. Signed-off-by: Benjamin Poirier Reviewed-by: Willem de Bruijn Link: https://lore.kernel.org/r/20190927101210.23856-7-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 1 - drivers/staging/qlge/qlge_dbg.c | 1 - drivers/staging/qlge/qlge_main.c | 24 ++++++++++-------------- 3 files changed, 10 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index f32da8c7679f..a3a52bbc2821 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1447,7 +1447,6 @@ struct rx_ring { /* Small buffer queue elements. */ u32 sbq_len; /* entry count */ u32 sbq_size; /* size in bytes of queue */ - u32 sbq_buf_size; void *sbq_base; dma_addr_t sbq_base_dma; void *sbq_base_indirect; diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 718943e78406..9f3f1b014023 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1791,7 +1791,6 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->sbq_curr_idx = %d\n", rx_ring->sbq_curr_idx); pr_err("rx_ring->sbq_clean_idx = %d\n", rx_ring->sbq_clean_idx); pr_err("rx_ring->sbq_free_cnt = %d\n", rx_ring->sbq_free_cnt); - pr_err("rx_ring->sbq_buf_size = %d\n", rx_ring->sbq_buf_size); pr_err("rx_ring->cq_id = %d\n", rx_ring->cq_id); pr_err("rx_ring->irq = %d\n", rx_ring->irq); pr_err("rx_ring->cpu = %d\n", rx_ring->cpu); diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 34bc1d9560ce..0a3809c50c10 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1164,7 +1164,7 @@ static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) skb_reserve(sbq_desc->p.skb, QLGE_SB_PAD); map = pci_map_single(qdev->pdev, sbq_desc->p.skb->data, - rx_ring->sbq_buf_size, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); if (pci_dma_mapping_error(qdev->pdev, map)) { netif_err(qdev, ifup, qdev->ndev, @@ -1594,14 +1594,13 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, pci_dma_sync_single_for_cpu(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, - PCI_DMA_FROMDEVICE); + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb_put_data(new_skb, skb->data, length); pci_dma_sync_single_for_device(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb = new_skb; @@ -1723,7 +1722,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, sbq_desc = ql_get_curr_sbuf(rx_ring); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb = sbq_desc->p.skb; ql_realign_skb(skb, hdr_len); skb_put(skb, hdr_len); @@ -1755,13 +1754,13 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, pci_dma_sync_single_for_cpu(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb_put_data(skb, sbq_desc->p.skb->data, length); pci_dma_sync_single_for_device(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); } else { netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, @@ -1773,7 +1772,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, skb_put(skb, length); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); sbq_desc->p.skb = NULL; } @@ -1846,7 +1845,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, sbq_desc = ql_get_curr_sbuf(rx_ring); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, PCI_DMA_FROMDEVICE); + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); if (!(ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS)) { /* * This is an non TCP/UDP IP frame, so @@ -2807,7 +2806,7 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring if (sbq_desc->p.skb) { pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), - rx_ring->sbq_buf_size, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(sbq_desc->p.skb); sbq_desc->p.skb = NULL; @@ -3158,8 +3157,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->sbq_len)); cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq_base_indirect_dma); - cqicb->sbq_buf_size = - cpu_to_le16((u16)(rx_ring->sbq_buf_size)); + cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUF_MAP_SIZE); bq_len = (rx_ring->sbq_len == 65536) ? 0 : (u16) rx_ring->sbq_len; cqicb->sbq_len = cpu_to_le16(bq_len); @@ -4109,7 +4107,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->sbq_len = NUM_SMALL_BUFFERS; rx_ring->sbq_size = rx_ring->sbq_len * sizeof(__le64); - rx_ring->sbq_buf_size = SMALL_BUF_MAP_SIZE; rx_ring->type = RX_Q; } else { /* @@ -4123,7 +4120,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->lbq_size = 0; rx_ring->sbq_len = 0; rx_ring->sbq_size = 0; - rx_ring->sbq_buf_size = 0; rx_ring->type = TX_Q; } } -- cgit v1.2.3-59-g8ed1b From cf1c2987bfd890a9c4ef3f174ed6148ec9b2b622 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:01 +0900 Subject: staging: qlge: Remove useless dma synchronization calls This is unneeded for two reasons: 1) the cpu does not write data for the device in the mapping 2) calls like ..._sync_..._for_device(..., ..._FROMDEVICE) are nonsensical, see commit 3f0fb4e85b38 ("Documentation/DMA-API-HOWTO.txt: fix misleading example") Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-8-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 0a3809c50c10..03403718a273 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1110,9 +1110,6 @@ static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) dma_unmap_addr_set(lbq_desc, mapaddr, map); *lbq_desc->addr = cpu_to_le64(map); - pci_dma_sync_single_for_device(qdev->pdev, map, - qdev->lbq_buf_size, - PCI_DMA_FROMDEVICE); clean_idx++; if (clean_idx == rx_ring->lbq_len) clean_idx = 0; @@ -1598,10 +1595,6 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, skb_put_data(new_skb, skb->data, length); - pci_dma_sync_single_for_device(qdev->pdev, - dma_unmap_addr(sbq_desc, mapaddr), - SMALL_BUF_MAP_SIZE, - PCI_DMA_FROMDEVICE); skb = new_skb; /* Frame error, so drop the packet. */ @@ -1757,11 +1750,6 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb_put_data(skb, sbq_desc->p.skb->data, length); - pci_dma_sync_single_for_device(qdev->pdev, - dma_unmap_addr(sbq_desc, - mapaddr), - SMALL_BUF_MAP_SIZE, - PCI_DMA_FROMDEVICE); } else { netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "%d bytes in a single small buffer.\n", -- cgit v1.2.3-59-g8ed1b From 03a0e14bd8bc8df2ea478b336ee65f429375acbb Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:02 +0900 Subject: staging: qlge: Deduplicate rx buffer queue management The qlge driver (and device) uses two kinds of buffers for reception, so-called "small buffers" and "large buffers". The two are arranged in rings, the sbq and lbq. These two share similar data structures and code. Factor out data structures into a common struct qlge_bq, make required adjustments to code and dedup the most obvious cases of copy/paste. This patch should not introduce any functional change other than to some of the printk format strings. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-9-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 96 ++++--- drivers/staging/qlge/qlge_dbg.c | 60 ++-- drivers/staging/qlge/qlge_main.c | 573 +++++++++++++++++---------------------- 3 files changed, 335 insertions(+), 394 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index a3a52bbc2821..a84aa264dfa8 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1358,23 +1358,6 @@ struct tx_ring_desc { struct tx_ring_desc *next; }; -struct page_chunk { - struct page *page; /* master page */ - char *va; /* virt addr for this chunk */ - u64 map; /* mapping for master */ - unsigned int offset; /* offset for this chunk */ -}; - -struct bq_desc { - union { - struct page_chunk pg_chunk; - struct sk_buff *skb; - } p; - __le64 *addr; - u32 index; - DEFINE_DMA_UNMAP_ADDR(mapaddr); -}; - #define QL_TXQ_IDX(qdev, skb) (smp_processor_id()%(qdev->tx_ring_count)) struct tx_ring { @@ -1413,6 +1396,56 @@ enum { RX_Q = 4, /* Handles inbound completions. */ }; +struct qlge_page_chunk { + struct page *page; + void *va; /* virt addr including offset */ + unsigned int offset; +}; + +struct qlge_bq_desc { + union { + /* for large buffers */ + struct qlge_page_chunk pg_chunk; + /* for small buffers */ + struct sk_buff *skb; + } p; + dma_addr_t dma_addr; + /* address in ring where the buffer address (dma_addr) is written for + * the device + */ + __le64 *buf_ptr; + u32 index; + DEFINE_DMA_UNMAP_ADDR(mapaddr); +}; + +/* buffer queue */ +struct qlge_bq { + __le64 *base; + dma_addr_t base_dma; + __le64 *base_indirect; + dma_addr_t base_indirect_dma; + struct qlge_bq_desc *queue; + void __iomem *prod_idx_db_reg; + u32 len; /* entry count */ + u32 size; /* size in bytes of hw ring */ + u32 prod_idx; /* current sw prod idx */ + u32 curr_idx; /* next entry we expect */ + u32 clean_idx; /* beginning of new descs */ + u32 free_cnt; /* free buffer desc cnt */ + enum { + QLGE_SB, /* small buffer */ + QLGE_LB, /* large buffer */ + } type; +}; + +#define QLGE_BQ_CONTAINER(bq) \ +({ \ + typeof(bq) _bq = bq; \ + (struct rx_ring *)((char *)_bq - (_bq->type == QLGE_SB ? \ + offsetof(struct rx_ring, sbq) : \ + offsetof(struct rx_ring, lbq))); \ +}) + struct rx_ring { struct cqicb cqicb; /* The chip's completion queue init control block. */ @@ -1430,33 +1463,12 @@ struct rx_ring { void __iomem *valid_db_reg; /* PCI doorbell mem area + 0x04 */ /* Large buffer queue elements. */ - u32 lbq_len; /* entry count */ - u32 lbq_size; /* size in bytes of queue */ - void *lbq_base; - dma_addr_t lbq_base_dma; - void *lbq_base_indirect; - dma_addr_t lbq_base_indirect_dma; - struct page_chunk pg_chunk; /* current page for chunks */ - struct bq_desc *lbq; /* array of control blocks */ - void __iomem *lbq_prod_idx_db_reg; /* PCI doorbell mem area + 0x18 */ - u32 lbq_prod_idx; /* current sw prod idx */ - u32 lbq_curr_idx; /* next entry we expect */ - u32 lbq_clean_idx; /* beginning of new descs */ - u32 lbq_free_cnt; /* free buffer desc cnt */ + struct qlge_bq lbq; + struct qlge_page_chunk master_chunk; + dma_addr_t chunk_dma_addr; /* Small buffer queue elements. */ - u32 sbq_len; /* entry count */ - u32 sbq_size; /* size in bytes of queue */ - void *sbq_base; - dma_addr_t sbq_base_dma; - void *sbq_base_indirect; - dma_addr_t sbq_base_indirect_dma; - struct bq_desc *sbq; /* array of control blocks */ - void __iomem *sbq_prod_idx_db_reg; /* PCI doorbell mem area + 0x1c */ - u32 sbq_prod_idx; /* current sw prod idx */ - u32 sbq_curr_idx; /* next entry we expect */ - u32 sbq_clean_idx; /* beginning of new descs */ - u32 sbq_free_cnt; /* free buffer desc cnt */ + struct qlge_bq sbq; /* Misc. handler elements. */ u32 type; /* Type of queue, tx, rx. */ diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 9f3f1b014023..e8ad8209d487 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1758,39 +1758,39 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->curr_entry = %p\n", rx_ring->curr_entry); pr_err("rx_ring->valid_db_reg = %p\n", rx_ring->valid_db_reg); - pr_err("rx_ring->lbq_base = %p\n", rx_ring->lbq_base); - pr_err("rx_ring->lbq_base_dma = %llx\n", - (unsigned long long) rx_ring->lbq_base_dma); - pr_err("rx_ring->lbq_base_indirect = %p\n", - rx_ring->lbq_base_indirect); - pr_err("rx_ring->lbq_base_indirect_dma = %llx\n", - (unsigned long long) rx_ring->lbq_base_indirect_dma); - pr_err("rx_ring->lbq = %p\n", rx_ring->lbq); - pr_err("rx_ring->lbq_len = %d\n", rx_ring->lbq_len); - pr_err("rx_ring->lbq_size = %d\n", rx_ring->lbq_size); - pr_err("rx_ring->lbq_prod_idx_db_reg = %p\n", - rx_ring->lbq_prod_idx_db_reg); - pr_err("rx_ring->lbq_prod_idx = %d\n", rx_ring->lbq_prod_idx); - pr_err("rx_ring->lbq_curr_idx = %d\n", rx_ring->lbq_curr_idx); + pr_err("rx_ring->lbq.base = %p\n", rx_ring->lbq.base); + pr_err("rx_ring->lbq.base_dma = %llx\n", + (unsigned long long)rx_ring->lbq.base_dma); + pr_err("rx_ring->lbq.base_indirect = %p\n", + rx_ring->lbq.base_indirect); + pr_err("rx_ring->lbq.base_indirect_dma = %llx\n", + (unsigned long long)rx_ring->lbq.base_indirect_dma); + pr_err("rx_ring->lbq = %p\n", rx_ring->lbq.queue); + pr_err("rx_ring->lbq.len = %d\n", rx_ring->lbq.len); + pr_err("rx_ring->lbq.size = %d\n", rx_ring->lbq.size); + pr_err("rx_ring->lbq.prod_idx_db_reg = %p\n", + rx_ring->lbq.prod_idx_db_reg); + pr_err("rx_ring->lbq.prod_idx = %d\n", rx_ring->lbq.prod_idx); + pr_err("rx_ring->lbq.curr_idx = %d\n", rx_ring->lbq.curr_idx); pr_err("rx_ring->lbq_clean_idx = %d\n", rx_ring->lbq_clean_idx); pr_err("rx_ring->lbq_free_cnt = %d\n", rx_ring->lbq_free_cnt); - pr_err("rx_ring->sbq_base = %p\n", rx_ring->sbq_base); - pr_err("rx_ring->sbq_base_dma = %llx\n", - (unsigned long long) rx_ring->sbq_base_dma); - pr_err("rx_ring->sbq_base_indirect = %p\n", - rx_ring->sbq_base_indirect); - pr_err("rx_ring->sbq_base_indirect_dma = %llx\n", - (unsigned long long) rx_ring->sbq_base_indirect_dma); - pr_err("rx_ring->sbq = %p\n", rx_ring->sbq); - pr_err("rx_ring->sbq_len = %d\n", rx_ring->sbq_len); - pr_err("rx_ring->sbq_size = %d\n", rx_ring->sbq_size); - pr_err("rx_ring->sbq_prod_idx_db_reg addr = %p\n", - rx_ring->sbq_prod_idx_db_reg); - pr_err("rx_ring->sbq_prod_idx = %d\n", rx_ring->sbq_prod_idx); - pr_err("rx_ring->sbq_curr_idx = %d\n", rx_ring->sbq_curr_idx); - pr_err("rx_ring->sbq_clean_idx = %d\n", rx_ring->sbq_clean_idx); - pr_err("rx_ring->sbq_free_cnt = %d\n", rx_ring->sbq_free_cnt); + pr_err("rx_ring->sbq.base = %p\n", rx_ring->sbq.base); + pr_err("rx_ring->sbq.base_dma = %llx\n", + (unsigned long long)rx_ring->sbq.base_dma); + pr_err("rx_ring->sbq.base_indirect = %p\n", + rx_ring->sbq.base_indirect); + pr_err("rx_ring->sbq.base_indirect_dma = %llx\n", + (unsigned long long)rx_ring->sbq.base_indirect_dma); + pr_err("rx_ring->sbq = %p\n", rx_ring->sbq.queue); + pr_err("rx_ring->sbq.len = %d\n", rx_ring->sbq.len); + pr_err("rx_ring->sbq.size = %d\n", rx_ring->sbq.size); + pr_err("rx_ring->sbq.prod_idx_db_reg addr = %p\n", + rx_ring->sbq.prod_idx_db_reg); + pr_err("rx_ring->sbq.prod_idx = %d\n", rx_ring->sbq.prod_idx); + pr_err("rx_ring->sbq.curr_idx = %d\n", rx_ring->sbq.curr_idx); + pr_err("rx_ring->sbq.clean_idx = %d\n", rx_ring->sbq.clean_idx); + pr_err("rx_ring->sbq.free_cnt = %d\n", rx_ring->sbq.free_cnt); pr_err("rx_ring->cq_id = %d\n", rx_ring->cq_id); pr_err("rx_ring->irq = %d\n", rx_ring->irq); pr_err("rx_ring->cpu = %d\n", rx_ring->cpu); diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 03403718a273..ba133d1f2b74 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -978,47 +978,36 @@ static inline unsigned int ql_lbq_block_size(struct ql_adapter *qdev) return PAGE_SIZE << qdev->lbq_buf_order; } -/* Get the next large buffer. */ -static struct bq_desc *ql_get_curr_lbuf(struct rx_ring *rx_ring) -{ - struct bq_desc *lbq_desc = &rx_ring->lbq[rx_ring->lbq_curr_idx]; - rx_ring->lbq_curr_idx++; - if (rx_ring->lbq_curr_idx == rx_ring->lbq_len) - rx_ring->lbq_curr_idx = 0; - rx_ring->lbq_free_cnt++; - return lbq_desc; +static struct qlge_bq_desc *qlge_get_curr_buf(struct qlge_bq *bq) +{ + struct qlge_bq_desc *bq_desc; + + bq_desc = &bq->queue[bq->curr_idx++]; + if (bq->curr_idx == bq->len) + bq->curr_idx = 0; + bq->free_cnt++; + + return bq_desc; } -static struct bq_desc *ql_get_curr_lchunk(struct ql_adapter *qdev, - struct rx_ring *rx_ring) +static struct qlge_bq_desc *ql_get_curr_lchunk(struct ql_adapter *qdev, + struct rx_ring *rx_ring) { - struct bq_desc *lbq_desc = ql_get_curr_lbuf(rx_ring); + struct qlge_bq_desc *lbq_desc = qlge_get_curr_buf(&rx_ring->lbq); pci_dma_sync_single_for_cpu(qdev->pdev, dma_unmap_addr(lbq_desc, mapaddr), qdev->lbq_buf_size, PCI_DMA_FROMDEVICE); - /* If it's the last chunk of our master page then - * we unmap it. - */ - if (lbq_desc->p.pg_chunk.offset + qdev->lbq_buf_size == - ql_lbq_block_size(qdev)) - pci_unmap_page(qdev->pdev, - lbq_desc->p.pg_chunk.map, - ql_lbq_block_size(qdev), - PCI_DMA_FROMDEVICE); - return lbq_desc; -} + if ((lbq_desc->p.pg_chunk.offset + qdev->lbq_buf_size) == + ql_lbq_block_size(qdev)) { + /* last chunk of the master page */ + pci_unmap_page(qdev->pdev, lbq_desc->dma_addr - + lbq_desc->p.pg_chunk.offset, + ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); + } -/* Get the next small buffer. */ -static struct bq_desc *ql_get_curr_sbuf(struct rx_ring *rx_ring) -{ - struct bq_desc *sbq_desc = &rx_ring->sbq[rx_ring->sbq_curr_idx]; - rx_ring->sbq_curr_idx++; - if (rx_ring->sbq_curr_idx == rx_ring->sbq_len) - rx_ring->sbq_curr_idx = 0; - rx_ring->sbq_free_cnt++; - return sbq_desc; + return lbq_desc; } /* Update an rx ring index. */ @@ -1037,169 +1026,159 @@ static void ql_write_cq_idx(struct rx_ring *rx_ring) ql_write_db_reg(rx_ring->cnsmr_idx, rx_ring->cnsmr_idx_db_reg); } -static int ql_get_next_chunk(struct ql_adapter *qdev, struct rx_ring *rx_ring, - struct bq_desc *lbq_desc) +static const char * const bq_type_name[] = { + [QLGE_SB] = "sbq", + [QLGE_LB] = "lbq", +}; + +/* return size of allocated buffer (may be 0) or negative error */ +static int qlge_refill_sb(struct rx_ring *rx_ring, + struct qlge_bq_desc *sbq_desc) { - if (!rx_ring->pg_chunk.page) { - u64 map; - rx_ring->pg_chunk.page = alloc_pages(__GFP_COMP | GFP_ATOMIC, - qdev->lbq_buf_order); - if (unlikely(!rx_ring->pg_chunk.page)) { - netif_err(qdev, drv, qdev->ndev, - "page allocation failed.\n"); + struct ql_adapter *qdev = rx_ring->qdev; + struct sk_buff *skb; + + if (sbq_desc->p.skb) + return 0; + + netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, + "ring %u sbq: getting new skb for index %d.\n", + rx_ring->cq_id, sbq_desc->index); + + skb = netdev_alloc_skb(qdev->ndev, SMALL_BUFFER_SIZE); + if (!skb) + return -ENOMEM; + skb_reserve(skb, QLGE_SB_PAD); + + sbq_desc->dma_addr = pci_map_single(qdev->pdev, skb->data, + SMALL_BUF_MAP_SIZE, + PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(qdev->pdev, sbq_desc->dma_addr)) { + netif_err(qdev, ifup, qdev->ndev, "PCI mapping failed.\n"); + dev_kfree_skb_any(skb); + return -EIO; + } + + sbq_desc->p.skb = skb; + return SMALL_BUFFER_SIZE; +} + +/* return size of allocated buffer or negative error */ +static int qlge_refill_lb(struct rx_ring *rx_ring, + struct qlge_bq_desc *lbq_desc) +{ + struct ql_adapter *qdev = rx_ring->qdev; + struct qlge_page_chunk *master_chunk = &rx_ring->master_chunk; + + if (!master_chunk->page) { + struct page *page; + dma_addr_t dma_addr; + + page = alloc_pages(__GFP_COMP | GFP_ATOMIC, + qdev->lbq_buf_order); + if (unlikely(!page)) return -ENOMEM; - } - rx_ring->pg_chunk.offset = 0; - map = pci_map_page(qdev->pdev, rx_ring->pg_chunk.page, - 0, ql_lbq_block_size(qdev), + dma_addr = pci_map_page(qdev->pdev, page, 0, + ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(qdev->pdev, map)) { - __free_pages(rx_ring->pg_chunk.page, - qdev->lbq_buf_order); - rx_ring->pg_chunk.page = NULL; + if (pci_dma_mapping_error(qdev->pdev, dma_addr)) { + __free_pages(page, qdev->lbq_buf_order); netif_err(qdev, drv, qdev->ndev, "PCI mapping failed.\n"); - return -ENOMEM; + return -EIO; } - rx_ring->pg_chunk.map = map; - rx_ring->pg_chunk.va = page_address(rx_ring->pg_chunk.page); + master_chunk->page = page; + master_chunk->va = page_address(page); + master_chunk->offset = 0; + rx_ring->chunk_dma_addr = dma_addr; } - /* Copy the current master pg_chunk info - * to the current descriptor. - */ - lbq_desc->p.pg_chunk = rx_ring->pg_chunk; + lbq_desc->p.pg_chunk = *master_chunk; + lbq_desc->dma_addr = rx_ring->chunk_dma_addr + master_chunk->offset; /* Adjust the master page chunk for next * buffer get. */ - rx_ring->pg_chunk.offset += qdev->lbq_buf_size; - if (rx_ring->pg_chunk.offset == ql_lbq_block_size(qdev)) { - rx_ring->pg_chunk.page = NULL; + master_chunk->offset += qdev->lbq_buf_size; + if (master_chunk->offset == ql_lbq_block_size(qdev)) { + master_chunk->page = NULL; } else { - rx_ring->pg_chunk.va += qdev->lbq_buf_size; - get_page(rx_ring->pg_chunk.page); + master_chunk->va += qdev->lbq_buf_size; + get_page(master_chunk->page); } - return 0; + + return qdev->lbq_buf_size; } -/* Process (refill) a large buffer queue. */ -static void ql_update_lbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) + +static void qlge_refill_bq(struct qlge_bq *bq) { - u32 clean_idx = rx_ring->lbq_clean_idx; + struct rx_ring *rx_ring = QLGE_BQ_CONTAINER(bq); + struct ql_adapter *qdev = rx_ring->qdev; + u32 clean_idx = bq->clean_idx; + unsigned int reserved_count; u32 start_idx = clean_idx; - struct bq_desc *lbq_desc; - u64 map; int i; - while (rx_ring->lbq_free_cnt > 32) { - for (i = (rx_ring->lbq_clean_idx % 16); i < 16; i++) { + if (bq->type == QLGE_SB) + reserved_count = 16; + else + reserved_count = 32; + + while (bq->free_cnt > reserved_count) { + for (i = (bq->clean_idx % 16); i < 16; i++) { + struct qlge_bq_desc *bq_desc = &bq->queue[clean_idx]; + int retval; + netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "lbq: try cleaning clean_idx = %d.\n", + "ring %u %s: try cleaning clean_idx = %d.\n", + rx_ring->cq_id, bq_type_name[bq->type], clean_idx); - lbq_desc = &rx_ring->lbq[clean_idx]; - if (ql_get_next_chunk(qdev, rx_ring, lbq_desc)) { - rx_ring->lbq_clean_idx = clean_idx; + + if (bq->type == QLGE_SB) + retval = qlge_refill_sb(rx_ring, bq_desc); + else + retval = qlge_refill_lb(rx_ring, bq_desc); + + if (retval > 0) { + dma_unmap_addr_set(bq_desc, mapaddr, + bq_desc->dma_addr); + *bq_desc->buf_ptr = + cpu_to_le64(bq_desc->dma_addr); + } else if (retval < 0) { + bq->clean_idx = clean_idx; netif_err(qdev, ifup, qdev->ndev, - "Could not get a page chunk, i=%d, clean_idx =%d .\n", - i, clean_idx); + "ring %u %s: Could not get a page chunk, i=%d, clean_idx =%d .\n", + rx_ring->cq_id, + bq_type_name[bq->type], i, + clean_idx); return; } - map = lbq_desc->p.pg_chunk.map + - lbq_desc->p.pg_chunk.offset; - dma_unmap_addr_set(lbq_desc, mapaddr, map); - *lbq_desc->addr = cpu_to_le64(map); - clean_idx++; - if (clean_idx == rx_ring->lbq_len) + if (clean_idx == bq->len) clean_idx = 0; } - rx_ring->lbq_clean_idx = clean_idx; - rx_ring->lbq_prod_idx += 16; - if (rx_ring->lbq_prod_idx == rx_ring->lbq_len) - rx_ring->lbq_prod_idx = 0; - rx_ring->lbq_free_cnt -= 16; - } - - if (start_idx != clean_idx) { - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "lbq: updating prod idx = %d.\n", - rx_ring->lbq_prod_idx); - ql_write_db_reg(rx_ring->lbq_prod_idx, - rx_ring->lbq_prod_idx_db_reg); - } -} - -/* Process (refill) a small buffer queue. */ -static void ql_update_sbq(struct ql_adapter *qdev, struct rx_ring *rx_ring) -{ - u32 clean_idx = rx_ring->sbq_clean_idx; - u32 start_idx = clean_idx; - struct bq_desc *sbq_desc; - u64 map; - int i; - - while (rx_ring->sbq_free_cnt > 16) { - for (i = (rx_ring->sbq_clean_idx % 16); i < 16; i++) { - sbq_desc = &rx_ring->sbq[clean_idx]; - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "sbq: try cleaning clean_idx = %d.\n", - clean_idx); - if (sbq_desc->p.skb == NULL) { - netif_printk(qdev, rx_status, KERN_DEBUG, - qdev->ndev, - "sbq: getting new skb for index %d.\n", - sbq_desc->index); - sbq_desc->p.skb = - netdev_alloc_skb(qdev->ndev, - SMALL_BUFFER_SIZE); - if (sbq_desc->p.skb == NULL) { - rx_ring->sbq_clean_idx = clean_idx; - return; - } - skb_reserve(sbq_desc->p.skb, QLGE_SB_PAD); - map = pci_map_single(qdev->pdev, - sbq_desc->p.skb->data, - SMALL_BUF_MAP_SIZE, - PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(qdev->pdev, map)) { - netif_err(qdev, ifup, qdev->ndev, - "PCI mapping failed.\n"); - rx_ring->sbq_clean_idx = clean_idx; - dev_kfree_skb_any(sbq_desc->p.skb); - sbq_desc->p.skb = NULL; - return; - } - dma_unmap_addr_set(sbq_desc, mapaddr, map); - *sbq_desc->addr = cpu_to_le64(map); - } - - clean_idx++; - if (clean_idx == rx_ring->sbq_len) - clean_idx = 0; - } - rx_ring->sbq_clean_idx = clean_idx; - rx_ring->sbq_prod_idx += 16; - if (rx_ring->sbq_prod_idx == rx_ring->sbq_len) - rx_ring->sbq_prod_idx = 0; - rx_ring->sbq_free_cnt -= 16; + bq->clean_idx = clean_idx; + bq->prod_idx += 16; + if (bq->prod_idx == bq->len) + bq->prod_idx = 0; + bq->free_cnt -= 16; } if (start_idx != clean_idx) { netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "sbq: updating prod idx = %d.\n", - rx_ring->sbq_prod_idx); - ql_write_db_reg(rx_ring->sbq_prod_idx, - rx_ring->sbq_prod_idx_db_reg); + "ring %u %s: updating prod idx = %d.\n", + rx_ring->cq_id, bq_type_name[bq->type], + bq->prod_idx); + ql_write_db_reg(bq->prod_idx, bq->prod_idx_db_reg); } } -static void ql_update_buffer_queues(struct ql_adapter *qdev, - struct rx_ring *rx_ring) +static void ql_update_buffer_queues(struct rx_ring *rx_ring) { - ql_update_sbq(qdev, rx_ring); - ql_update_lbq(qdev, rx_ring); + qlge_refill_bq(&rx_ring->sbq); + qlge_refill_bq(&rx_ring->lbq); } /* Unmaps tx buffers. Can be called from send() if a pci mapping @@ -1436,7 +1415,7 @@ static void ql_process_mac_rx_gro_page(struct ql_adapter *qdev, u16 vlan_id) { struct sk_buff *skb; - struct bq_desc *lbq_desc = ql_get_curr_lchunk(qdev, rx_ring); + struct qlge_bq_desc *lbq_desc = ql_get_curr_lchunk(qdev, rx_ring); struct napi_struct *napi = &rx_ring->napi; /* Frame error, so drop the packet. */ @@ -1485,7 +1464,7 @@ static void ql_process_mac_rx_page(struct ql_adapter *qdev, struct net_device *ndev = qdev->ndev; struct sk_buff *skb = NULL; void *addr; - struct bq_desc *lbq_desc = ql_get_curr_lchunk(qdev, rx_ring); + struct qlge_bq_desc *lbq_desc = ql_get_curr_lchunk(qdev, rx_ring); struct napi_struct *napi = &rx_ring->napi; size_t hlen = ETH_HLEN; @@ -1575,10 +1554,9 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, u32 length, u16 vlan_id) { + struct qlge_bq_desc *sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); struct net_device *ndev = qdev->ndev; - struct sk_buff *skb = NULL; - struct sk_buff *new_skb = NULL; - struct bq_desc *sbq_desc = ql_get_curr_sbuf(rx_ring); + struct sk_buff *skb, *new_skb; skb = sbq_desc->p.skb; /* Allocate new_skb and copy */ @@ -1695,11 +1673,10 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, struct rx_ring *rx_ring, struct ib_mac_iocb_rsp *ib_mac_rsp) { - struct bq_desc *lbq_desc; - struct bq_desc *sbq_desc; - struct sk_buff *skb = NULL; u32 length = le32_to_cpu(ib_mac_rsp->data_len); u32 hdr_len = le32_to_cpu(ib_mac_rsp->hdr_len); + struct qlge_bq_desc *lbq_desc, *sbq_desc; + struct sk_buff *skb = NULL; size_t hlen = ETH_HLEN; /* @@ -1712,7 +1689,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, /* * Headers fit nicely into a small buffer. */ - sbq_desc = ql_get_curr_sbuf(rx_ring); + sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); @@ -1743,7 +1720,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, * from the "data" small buffer to the "header" small * buffer. */ - sbq_desc = ql_get_curr_sbuf(rx_ring); + sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); pci_dma_sync_single_for_cpu(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), @@ -1754,7 +1731,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "%d bytes in a single small buffer.\n", length); - sbq_desc = ql_get_curr_sbuf(rx_ring); + sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); skb = sbq_desc->p.skb; ql_realign_skb(skb, length); skb_put(skb, length); @@ -1830,7 +1807,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, * eventually be in trouble. */ int size, i = 0; - sbq_desc = ql_get_curr_sbuf(rx_ring); + sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); pci_unmap_single(qdev->pdev, dma_unmap_addr(sbq_desc, mapaddr), SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); @@ -2207,7 +2184,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) if (count == budget) break; } - ql_update_buffer_queues(qdev, rx_ring); + ql_update_buffer_queues(rx_ring); ql_write_cq_idx(rx_ring); return count; } @@ -2749,43 +2726,42 @@ pci_alloc_err: static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring) { unsigned int last_offset; - struct bq_desc *lbq_desc; uint32_t curr_idx, clean_idx; last_offset = ql_lbq_block_size(qdev) - qdev->lbq_buf_size; - curr_idx = rx_ring->lbq_curr_idx; - clean_idx = rx_ring->lbq_clean_idx; + curr_idx = rx_ring->lbq.curr_idx; + clean_idx = rx_ring->lbq.clean_idx; while (curr_idx != clean_idx) { - lbq_desc = &rx_ring->lbq[curr_idx]; + struct qlge_bq_desc *lbq_desc = &rx_ring->lbq.queue[curr_idx]; if (lbq_desc->p.pg_chunk.offset == last_offset) - pci_unmap_page(qdev->pdev, lbq_desc->p.pg_chunk.map, - ql_lbq_block_size(qdev), + pci_unmap_page(qdev->pdev, lbq_desc->dma_addr - + last_offset, ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); put_page(lbq_desc->p.pg_chunk.page); lbq_desc->p.pg_chunk.page = NULL; - if (++curr_idx == rx_ring->lbq_len) + if (++curr_idx == rx_ring->lbq.len) curr_idx = 0; - } - if (rx_ring->pg_chunk.page) { - pci_unmap_page(qdev->pdev, rx_ring->pg_chunk.map, - ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); - put_page(rx_ring->pg_chunk.page); - rx_ring->pg_chunk.page = NULL; + + if (rx_ring->master_chunk.page) { + pci_unmap_page(qdev->pdev, rx_ring->chunk_dma_addr, + ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); + put_page(rx_ring->master_chunk.page); + rx_ring->master_chunk.page = NULL; } } static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring) { int i; - struct bq_desc *sbq_desc; - for (i = 0; i < rx_ring->sbq_len; i++) { - sbq_desc = &rx_ring->sbq[i]; + for (i = 0; i < rx_ring->sbq.len; i++) { + struct qlge_bq_desc *sbq_desc = &rx_ring->sbq.queue[i]; + if (sbq_desc == NULL) { netif_err(qdev, ifup, qdev->ndev, "sbq_desc %d is NULL.\n", i); @@ -2808,13 +2784,13 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring static void ql_free_rx_buffers(struct ql_adapter *qdev) { int i; - struct rx_ring *rx_ring; for (i = 0; i < qdev->rx_ring_count; i++) { - rx_ring = &qdev->rx_ring[i]; - if (rx_ring->lbq) + struct rx_ring *rx_ring = &qdev->rx_ring[i]; + + if (rx_ring->lbq.queue) ql_free_lbq_buffers(qdev, rx_ring); - if (rx_ring->sbq) + if (rx_ring->sbq.queue) ql_free_sbq_buffers(qdev, rx_ring); } } @@ -2827,70 +2803,70 @@ static void ql_alloc_rx_buffers(struct ql_adapter *qdev) for (i = 0; i < qdev->rx_ring_count; i++) { rx_ring = &qdev->rx_ring[i]; if (rx_ring->type != TX_Q) - ql_update_buffer_queues(qdev, rx_ring); + ql_update_buffer_queues(rx_ring); } } -static void ql_init_lbq_ring(struct ql_adapter *qdev, - struct rx_ring *rx_ring) +static int qlge_init_bq(struct qlge_bq *bq) { + struct rx_ring *rx_ring = QLGE_BQ_CONTAINER(bq); + struct ql_adapter *qdev = rx_ring->qdev; + struct qlge_bq_desc *bq_desc; + __le64 *buf_ptr; int i; - struct bq_desc *lbq_desc; - __le64 *bq = rx_ring->lbq_base; - memset(rx_ring->lbq, 0, rx_ring->lbq_len * sizeof(struct bq_desc)); - for (i = 0; i < rx_ring->lbq_len; i++) { - lbq_desc = &rx_ring->lbq[i]; - memset(lbq_desc, 0, sizeof(*lbq_desc)); - lbq_desc->index = i; - lbq_desc->addr = bq; - bq++; + bq->base = pci_alloc_consistent(qdev->pdev, bq->size, &bq->base_dma); + if (!bq->base) { + netif_err(qdev, ifup, qdev->ndev, + "ring %u %s allocation failed.\n", rx_ring->cq_id, + bq_type_name[bq->type]); + return -ENOMEM; } -} -static void ql_init_sbq_ring(struct ql_adapter *qdev, - struct rx_ring *rx_ring) -{ - int i; - struct bq_desc *sbq_desc; - __le64 *bq = rx_ring->sbq_base; + bq->queue = kmalloc_array(bq->len, sizeof(struct qlge_bq_desc), + GFP_KERNEL); + if (!bq->queue) + return -ENOMEM; - memset(rx_ring->sbq, 0, rx_ring->sbq_len * sizeof(struct bq_desc)); - for (i = 0; i < rx_ring->sbq_len; i++) { - sbq_desc = &rx_ring->sbq[i]; - memset(sbq_desc, 0, sizeof(*sbq_desc)); - sbq_desc->index = i; - sbq_desc->addr = bq; - bq++; + memset(bq->queue, 0, bq->len * sizeof(struct qlge_bq_desc)); + + buf_ptr = bq->base; + bq_desc = &bq->queue[0]; + for (i = 0; i < bq->len; i++, buf_ptr++, bq_desc++) { + memset(bq_desc, 0, sizeof(*bq_desc)); + bq_desc->index = i; + bq_desc->buf_ptr = buf_ptr; } + + return 0; } static void ql_free_rx_resources(struct ql_adapter *qdev, struct rx_ring *rx_ring) { /* Free the small buffer queue. */ - if (rx_ring->sbq_base) { + if (rx_ring->sbq.base) { pci_free_consistent(qdev->pdev, - rx_ring->sbq_size, - rx_ring->sbq_base, rx_ring->sbq_base_dma); - rx_ring->sbq_base = NULL; + rx_ring->sbq.size, + rx_ring->sbq.base, rx_ring->sbq.base_dma); + rx_ring->sbq.base = NULL; } /* Free the small buffer queue control blocks. */ - kfree(rx_ring->sbq); - rx_ring->sbq = NULL; + kfree(rx_ring->sbq.queue); + rx_ring->sbq.queue = NULL; /* Free the large buffer queue. */ - if (rx_ring->lbq_base) { + if (rx_ring->lbq.base) { pci_free_consistent(qdev->pdev, - rx_ring->lbq_size, - rx_ring->lbq_base, rx_ring->lbq_base_dma); - rx_ring->lbq_base = NULL; + rx_ring->lbq.size, + rx_ring->lbq.base, rx_ring->lbq.base_dma); + rx_ring->lbq.base = NULL; } /* Free the large buffer queue control blocks. */ - kfree(rx_ring->lbq); - rx_ring->lbq = NULL; + kfree(rx_ring->lbq.queue); + rx_ring->lbq.queue = NULL; /* Free the rx queue. */ if (rx_ring->cq_base) { @@ -2919,56 +2895,10 @@ static int ql_alloc_rx_resources(struct ql_adapter *qdev, return -ENOMEM; } - if (rx_ring->sbq_len) { - /* - * Allocate small buffer queue. - */ - rx_ring->sbq_base = - pci_alloc_consistent(qdev->pdev, rx_ring->sbq_size, - &rx_ring->sbq_base_dma); - - if (rx_ring->sbq_base == NULL) { - netif_err(qdev, ifup, qdev->ndev, - "Small buffer queue allocation failed.\n"); - goto err_mem; - } - - /* - * Allocate small buffer queue control blocks. - */ - rx_ring->sbq = kmalloc_array(rx_ring->sbq_len, - sizeof(struct bq_desc), - GFP_KERNEL); - if (rx_ring->sbq == NULL) - goto err_mem; - - ql_init_sbq_ring(qdev, rx_ring); - } - - if (rx_ring->lbq_len) { - /* - * Allocate large buffer queue. - */ - rx_ring->lbq_base = - pci_alloc_consistent(qdev->pdev, rx_ring->lbq_size, - &rx_ring->lbq_base_dma); - - if (rx_ring->lbq_base == NULL) { - netif_err(qdev, ifup, qdev->ndev, - "Large buffer queue allocation failed.\n"); - goto err_mem; - } - /* - * Allocate large buffer queue control blocks. - */ - rx_ring->lbq = kmalloc_array(rx_ring->lbq_len, - sizeof(struct bq_desc), - GFP_KERNEL); - if (rx_ring->lbq == NULL) - goto err_mem; - - ql_init_lbq_ring(qdev, rx_ring); - } + if (rx_ring->sbq.len && qlge_init_bq(&rx_ring->sbq)) + goto err_mem; + if (rx_ring->lbq.len && qlge_init_bq(&rx_ring->lbq)) + goto err_mem; return 0; @@ -3071,12 +3001,12 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) *rx_ring->prod_idx_sh_reg = 0; shadow_reg += sizeof(u64); shadow_reg_dma += sizeof(u64); - rx_ring->lbq_base_indirect = shadow_reg; - rx_ring->lbq_base_indirect_dma = shadow_reg_dma; - shadow_reg += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(rx_ring->lbq_len)); - shadow_reg_dma += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(rx_ring->lbq_len)); - rx_ring->sbq_base_indirect = shadow_reg; - rx_ring->sbq_base_indirect_dma = shadow_reg_dma; + rx_ring->lbq.base_indirect = shadow_reg; + rx_ring->lbq.base_indirect_dma = shadow_reg_dma; + shadow_reg += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); + shadow_reg_dma += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); + rx_ring->sbq.base_indirect = shadow_reg; + rx_ring->sbq.base_indirect_dma = shadow_reg_dma; /* PCI doorbell mem area + 0x00 for consumer index register */ rx_ring->cnsmr_idx_db_reg = (u32 __iomem *) doorbell_area; @@ -3087,10 +3017,10 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) rx_ring->valid_db_reg = doorbell_area + 0x04; /* PCI doorbell mem area + 0x18 for large buffer consumer */ - rx_ring->lbq_prod_idx_db_reg = (u32 __iomem *) (doorbell_area + 0x18); + rx_ring->lbq.prod_idx_db_reg = (u32 __iomem *)(doorbell_area + 0x18); /* PCI doorbell mem area + 0x1c */ - rx_ring->sbq_prod_idx_db_reg = (u32 __iomem *) (doorbell_area + 0x1c); + rx_ring->sbq.prod_idx_db_reg = (u32 __iomem *)(doorbell_area + 0x1c); memset((void *)cqicb, 0, sizeof(struct cqicb)); cqicb->msix_vect = rx_ring->irq; @@ -3108,51 +3038,50 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) cqicb->flags = FLAGS_LC | /* Load queue base address */ FLAGS_LV | /* Load MSI-X vector */ FLAGS_LI; /* Load irq delay values */ - if (rx_ring->lbq_len) { + if (rx_ring->lbq.len) { cqicb->flags |= FLAGS_LL; /* Load lbq values */ - tmp = (u64)rx_ring->lbq_base_dma; - base_indirect_ptr = rx_ring->lbq_base_indirect; + tmp = (u64)rx_ring->lbq.base_dma; + base_indirect_ptr = rx_ring->lbq.base_indirect; page_entries = 0; do { *base_indirect_ptr = cpu_to_le64(tmp); tmp += DB_PAGE_SIZE; base_indirect_ptr++; page_entries++; - } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->lbq_len)); - cqicb->lbq_addr = - cpu_to_le64(rx_ring->lbq_base_indirect_dma); - bq_len = (qdev->lbq_buf_size == 65536) ? 0 : + } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); + cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma); + bq_len = qdev->lbq_buf_size == 65536 ? 0 : (u16)qdev->lbq_buf_size; cqicb->lbq_buf_size = cpu_to_le16(bq_len); - bq_len = (rx_ring->lbq_len == 65536) ? 0 : - (u16) rx_ring->lbq_len; + bq_len = (rx_ring->lbq.len == 65536) ? 0 : + (u16)rx_ring->lbq.len; cqicb->lbq_len = cpu_to_le16(bq_len); - rx_ring->lbq_prod_idx = 0; - rx_ring->lbq_curr_idx = 0; - rx_ring->lbq_clean_idx = 0; - rx_ring->lbq_free_cnt = rx_ring->lbq_len; + rx_ring->lbq.prod_idx = 0; + rx_ring->lbq.curr_idx = 0; + rx_ring->lbq.clean_idx = 0; + rx_ring->lbq.free_cnt = rx_ring->lbq.len; } - if (rx_ring->sbq_len) { + if (rx_ring->sbq.len) { cqicb->flags |= FLAGS_LS; /* Load sbq values */ - tmp = (u64)rx_ring->sbq_base_dma; - base_indirect_ptr = rx_ring->sbq_base_indirect; + tmp = (u64)rx_ring->sbq.base_dma; + base_indirect_ptr = rx_ring->sbq.base_indirect; page_entries = 0; do { *base_indirect_ptr = cpu_to_le64(tmp); tmp += DB_PAGE_SIZE; base_indirect_ptr++; page_entries++; - } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->sbq_len)); + } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->sbq.len)); cqicb->sbq_addr = - cpu_to_le64(rx_ring->sbq_base_indirect_dma); - cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUF_MAP_SIZE); - bq_len = (rx_ring->sbq_len == 65536) ? 0 : - (u16) rx_ring->sbq_len; + cpu_to_le64(rx_ring->sbq.base_indirect_dma); + cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE); + bq_len = (rx_ring->sbq.len == 65536) ? 0 : + (u16)rx_ring->sbq.len; cqicb->sbq_len = cpu_to_le16(bq_len); - rx_ring->sbq_prod_idx = 0; - rx_ring->sbq_curr_idx = 0; - rx_ring->sbq_clean_idx = 0; - rx_ring->sbq_free_cnt = rx_ring->sbq_len; + rx_ring->sbq.prod_idx = 0; + rx_ring->sbq.curr_idx = 0; + rx_ring->sbq.clean_idx = 0; + rx_ring->sbq.free_cnt = rx_ring->sbq.len; } switch (rx_ring->type) { case TX_Q: @@ -4089,12 +4018,12 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->cq_len = qdev->rx_ring_size; rx_ring->cq_size = rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); - rx_ring->lbq_len = NUM_LARGE_BUFFERS; - rx_ring->lbq_size = - rx_ring->lbq_len * sizeof(__le64); - rx_ring->sbq_len = NUM_SMALL_BUFFERS; - rx_ring->sbq_size = - rx_ring->sbq_len * sizeof(__le64); + rx_ring->lbq.type = QLGE_LB; + rx_ring->lbq.len = NUM_LARGE_BUFFERS; + rx_ring->lbq.size = rx_ring->lbq.len * sizeof(__le64); + rx_ring->sbq.type = QLGE_SB; + rx_ring->sbq.len = NUM_SMALL_BUFFERS; + rx_ring->sbq.size = rx_ring->sbq.len * sizeof(__le64); rx_ring->type = RX_Q; } else { /* @@ -4104,10 +4033,10 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->cq_len = qdev->tx_ring_size; rx_ring->cq_size = rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); - rx_ring->lbq_len = 0; - rx_ring->lbq_size = 0; - rx_ring->sbq_len = 0; - rx_ring->sbq_size = 0; + rx_ring->lbq.len = 0; + rx_ring->lbq.size = 0; + rx_ring->sbq.len = 0; + rx_ring->sbq.size = 0; rx_ring->type = TX_Q; } } -- cgit v1.2.3-59-g8ed1b From 6f5740b1d35ea9d25b895c0eb836aaa7b1ee427b Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:03 +0900 Subject: staging: qlge: Fix dma_sync_single calls Using the unmap addr elsewhere than unmap calls is a misuse of the dma api. In prevision of this fix, qlge kept two copies of the dma address around ;) Fixes: c4e84bde1d59 ("qlge: New Qlogic 10Gb Ethernet Driver.") Fixes: 7c734359d350 ("qlge: Size RX buffers based on MTU.") Fixes: 2c9a266afefe ("qlge: Fix receive packets drop.") Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-10-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 5 +--- drivers/staging/qlge/qlge_main.c | 54 ++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 37 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index a84aa264dfa8..519fa39dd194 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1410,12 +1410,9 @@ struct qlge_bq_desc { struct sk_buff *skb; } p; dma_addr_t dma_addr; - /* address in ring where the buffer address (dma_addr) is written for - * the device - */ + /* address in ring where the buffer address is written for the device */ __le64 *buf_ptr; u32 index; - DEFINE_DMA_UNMAP_ADDR(mapaddr); }; /* buffer queue */ diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index ba133d1f2b74..609a87804a94 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -995,15 +995,13 @@ static struct qlge_bq_desc *ql_get_curr_lchunk(struct ql_adapter *qdev, { struct qlge_bq_desc *lbq_desc = qlge_get_curr_buf(&rx_ring->lbq); - pci_dma_sync_single_for_cpu(qdev->pdev, - dma_unmap_addr(lbq_desc, mapaddr), + pci_dma_sync_single_for_cpu(qdev->pdev, lbq_desc->dma_addr, qdev->lbq_buf_size, PCI_DMA_FROMDEVICE); if ((lbq_desc->p.pg_chunk.offset + qdev->lbq_buf_size) == ql_lbq_block_size(qdev)) { /* last chunk of the master page */ - pci_unmap_page(qdev->pdev, lbq_desc->dma_addr - - lbq_desc->p.pg_chunk.offset, + pci_unmap_page(qdev->pdev, lbq_desc->dma_addr, ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); } @@ -1031,7 +1029,7 @@ static const char * const bq_type_name[] = { [QLGE_LB] = "lbq", }; -/* return size of allocated buffer (may be 0) or negative error */ +/* return 0 or negative error */ static int qlge_refill_sb(struct rx_ring *rx_ring, struct qlge_bq_desc *sbq_desc) { @@ -1058,12 +1056,13 @@ static int qlge_refill_sb(struct rx_ring *rx_ring, dev_kfree_skb_any(skb); return -EIO; } + *sbq_desc->buf_ptr = cpu_to_le64(sbq_desc->dma_addr); sbq_desc->p.skb = skb; - return SMALL_BUFFER_SIZE; + return 0; } -/* return size of allocated buffer or negative error */ +/* return 0 or negative error */ static int qlge_refill_lb(struct rx_ring *rx_ring, struct qlge_bq_desc *lbq_desc) { @@ -1094,7 +1093,9 @@ static int qlge_refill_lb(struct rx_ring *rx_ring, } lbq_desc->p.pg_chunk = *master_chunk; - lbq_desc->dma_addr = rx_ring->chunk_dma_addr + master_chunk->offset; + lbq_desc->dma_addr = rx_ring->chunk_dma_addr; + *lbq_desc->buf_ptr = cpu_to_le64(lbq_desc->dma_addr + + lbq_desc->p.pg_chunk.offset); /* Adjust the master page chunk for next * buffer get. @@ -1107,7 +1108,7 @@ static int qlge_refill_lb(struct rx_ring *rx_ring, get_page(master_chunk->page); } - return qdev->lbq_buf_size; + return 0; } static void qlge_refill_bq(struct qlge_bq *bq) @@ -1138,13 +1139,7 @@ static void qlge_refill_bq(struct qlge_bq *bq) retval = qlge_refill_sb(rx_ring, bq_desc); else retval = qlge_refill_lb(rx_ring, bq_desc); - - if (retval > 0) { - dma_unmap_addr_set(bq_desc, mapaddr, - bq_desc->dma_addr); - *bq_desc->buf_ptr = - cpu_to_le64(bq_desc->dma_addr); - } else if (retval < 0) { + if (retval < 0) { bq->clean_idx = clean_idx; netif_err(qdev, ifup, qdev->ndev, "ring %u %s: Could not get a page chunk, i=%d, clean_idx =%d .\n", @@ -1567,8 +1562,7 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, } skb_reserve(new_skb, NET_IP_ALIGN); - pci_dma_sync_single_for_cpu(qdev->pdev, - dma_unmap_addr(sbq_desc, mapaddr), + pci_dma_sync_single_for_cpu(qdev->pdev, sbq_desc->dma_addr, SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb_put_data(new_skb, skb->data, length); @@ -1690,9 +1684,8 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, * Headers fit nicely into a small buffer. */ sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); - pci_unmap_single(qdev->pdev, - dma_unmap_addr(sbq_desc, mapaddr), - SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); + pci_unmap_single(qdev->pdev, sbq_desc->dma_addr, + SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb = sbq_desc->p.skb; ql_realign_skb(skb, hdr_len); skb_put(skb, hdr_len); @@ -1722,8 +1715,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, */ sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); pci_dma_sync_single_for_cpu(qdev->pdev, - dma_unmap_addr(sbq_desc, - mapaddr), + sbq_desc->dma_addr, SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); skb_put_data(skb, sbq_desc->p.skb->data, length); @@ -1735,8 +1727,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, skb = sbq_desc->p.skb; ql_realign_skb(skb, length); skb_put(skb, length); - pci_unmap_single(qdev->pdev, - dma_unmap_addr(sbq_desc, mapaddr), + pci_unmap_single(qdev->pdev, sbq_desc->dma_addr, SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); sbq_desc->p.skb = NULL; @@ -1774,8 +1765,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, "No skb available, drop the packet.\n"); return NULL; } - pci_unmap_page(qdev->pdev, - dma_unmap_addr(lbq_desc, mapaddr), + pci_unmap_page(qdev->pdev, lbq_desc->dma_addr, qdev->lbq_buf_size, PCI_DMA_FROMDEVICE); skb_reserve(skb, NET_IP_ALIGN); @@ -1808,8 +1798,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, */ int size, i = 0; sbq_desc = qlge_get_curr_buf(&rx_ring->sbq); - pci_unmap_single(qdev->pdev, - dma_unmap_addr(sbq_desc, mapaddr), + pci_unmap_single(qdev->pdev, sbq_desc->dma_addr, SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); if (!(ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS)) { /* @@ -2736,8 +2725,8 @@ static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring struct qlge_bq_desc *lbq_desc = &rx_ring->lbq.queue[curr_idx]; if (lbq_desc->p.pg_chunk.offset == last_offset) - pci_unmap_page(qdev->pdev, lbq_desc->dma_addr - - last_offset, ql_lbq_block_size(qdev), + pci_unmap_page(qdev->pdev, lbq_desc->dma_addr, + ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); put_page(lbq_desc->p.pg_chunk.page); @@ -2768,8 +2757,7 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring return; } if (sbq_desc->p.skb) { - pci_unmap_single(qdev->pdev, - dma_unmap_addr(sbq_desc, mapaddr), + pci_unmap_single(qdev->pdev, sbq_desc->dma_addr, SMALL_BUF_MAP_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(sbq_desc->p.skb); -- cgit v1.2.3-59-g8ed1b From e4c911a73c8948a679981c2001c0aed9d0054ab1 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:04 +0900 Subject: staging: qlge: Remove rx_ring.type This field is redundant, the type can be determined from the index, cq_id. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-11-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 10 ---------- drivers/staging/qlge/qlge_dbg.c | 16 ++++++++++++---- drivers/staging/qlge/qlge_main.c | 31 +++++++------------------------ 3 files changed, 19 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 519fa39dd194..5a4b2520cd2a 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1387,15 +1387,6 @@ struct tx_ring { u64 tx_errors; }; -/* - * Type of inbound queue. - */ -enum { - DEFAULT_Q = 2, /* Handles slow queue and chip/MPI events. */ - TX_Q = 3, /* Handles outbound completions. */ - RX_Q = 4, /* Handles inbound completions. */ -}; - struct qlge_page_chunk { struct page *page; void *va; /* virt addr including offset */ @@ -1468,7 +1459,6 @@ struct rx_ring { struct qlge_bq sbq; /* Misc. handler elements. */ - u32 type; /* Type of queue, tx, rx. */ u32 irq; /* Which vector this ring is assigned. */ u32 cpu; /* Which CPU this should run on. */ char name[IFNAMSIZ + 5]; diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index e8ad8209d487..81fbee7f2af6 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1730,16 +1730,24 @@ void ql_dump_cqicb(struct cqicb *cqicb) le16_to_cpu(cqicb->sbq_len)); } +static const char *qlge_rx_ring_type_name(struct rx_ring *rx_ring) +{ + struct ql_adapter *qdev = rx_ring->qdev; + + if (rx_ring->cq_id < qdev->rss_ring_count) + return "RX COMPLETION"; + else + return "TX COMPLETION"; +}; + void ql_dump_rx_ring(struct rx_ring *rx_ring) { if (rx_ring == NULL) return; pr_err("===================== Dumping rx_ring %d ===============\n", rx_ring->cq_id); - pr_err("Dumping rx_ring %d, type = %s%s%s\n", - rx_ring->cq_id, rx_ring->type == DEFAULT_Q ? "DEFAULT" : "", - rx_ring->type == TX_Q ? "OUTBOUND COMPLETIONS" : "", - rx_ring->type == RX_Q ? "INBOUND_COMPLETIONS" : ""); + pr_err("Dumping rx_ring %d, type = %s\n", rx_ring->cq_id, + qlge_rx_ring_type_name(rx_ring)); pr_err("rx_ring->cqicb = %p\n", &rx_ring->cqicb); pr_err("rx_ring->cq_base = %p\n", rx_ring->cq_base); pr_err("rx_ring->cq_base_dma = %llx\n", diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 609a87804a94..0e304a7ac22f 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -2785,14 +2785,10 @@ static void ql_free_rx_buffers(struct ql_adapter *qdev) static void ql_alloc_rx_buffers(struct ql_adapter *qdev) { - struct rx_ring *rx_ring; int i; - for (i = 0; i < qdev->rx_ring_count; i++) { - rx_ring = &qdev->rx_ring[i]; - if (rx_ring->type != TX_Q) - ql_update_buffer_queues(rx_ring); - } + for (i = 0; i < qdev->rss_ring_count; i++) + ql_update_buffer_queues(&qdev->rx_ring[i]); } static int qlge_init_bq(struct qlge_bq *bq) @@ -3071,12 +3067,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) rx_ring->sbq.clean_idx = 0; rx_ring->sbq.free_cnt = rx_ring->sbq.len; } - switch (rx_ring->type) { - case TX_Q: - cqicb->irq_delay = cpu_to_le16(qdev->tx_coalesce_usecs); - cqicb->pkt_delay = cpu_to_le16(qdev->tx_max_coalesced_frames); - break; - case RX_Q: + if (rx_ring->cq_id < qdev->rss_ring_count) { /* Inbound completion handling rx_rings run in * separate NAPI contexts. */ @@ -3084,10 +3075,9 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) 64); cqicb->irq_delay = cpu_to_le16(qdev->rx_coalesce_usecs); cqicb->pkt_delay = cpu_to_le16(qdev->rx_max_coalesced_frames); - break; - default: - netif_printk(qdev, ifup, KERN_DEBUG, qdev->ndev, - "Invalid rx_ring->type = %d.\n", rx_ring->type); + } else { + cqicb->irq_delay = cpu_to_le16(qdev->tx_coalesce_usecs); + cqicb->pkt_delay = cpu_to_le16(qdev->tx_max_coalesced_frames); } err = ql_write_cfg(qdev, cqicb, sizeof(struct cqicb), CFG_LCQ, rx_ring->cq_id); @@ -3444,12 +3434,7 @@ static int ql_request_irq(struct ql_adapter *qdev) goto err_irq; netif_err(qdev, ifup, qdev->ndev, - "Hooked intr %d, queue type %s, with name %s.\n", - i, - qdev->rx_ring[0].type == DEFAULT_Q ? - "DEFAULT_Q" : - qdev->rx_ring[0].type == TX_Q ? "TX_Q" : - qdev->rx_ring[0].type == RX_Q ? "RX_Q" : "", + "Hooked intr 0, queue type RX_Q, with name %s.\n", intr_context->name); } intr_context->hooked = 1; @@ -4012,7 +3997,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->sbq.type = QLGE_SB; rx_ring->sbq.len = NUM_SMALL_BUFFERS; rx_ring->sbq.size = rx_ring->sbq.len * sizeof(__le64); - rx_ring->type = RX_Q; } else { /* * Outbound queue handles outbound completions only. @@ -4025,7 +4009,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->lbq.size = 0; rx_ring->sbq.len = 0; rx_ring->sbq.size = 0; - rx_ring->type = TX_Q; } } return 0; -- cgit v1.2.3-59-g8ed1b From dc4eec33bf15eb936d1888872f4039d53565d26c Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:05 +0900 Subject: staging: qlge: Factor out duplicated expression Given that (u16) 65536 == 0, that expression can be replaced by a simple cast. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-12-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 5 +++++ drivers/staging/qlge/qlge_main.c | 18 ++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 5a4b2520cd2a..24af938da7a4 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -77,6 +77,11 @@ #define LSD(x) ((u32)((u64)(x))) #define MSD(x) ((u32)((((u64)(x)) >> 32))) +/* In some cases, the device interprets a value of 0x0000 as 65536. These + * cases are marked using the following macro. + */ +#define QLGE_FIT16(value) ((u16)(value)) + /* MPI test register definitions. This register * is used for determining alternate NIC function's * PCI->func number. diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 0e304a7ac22f..e1099bd29672 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -2974,7 +2974,6 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) void __iomem *doorbell_area = qdev->doorbell_area + (DB_PAGE_SIZE * (128 + rx_ring->cq_id)); int err = 0; - u16 bq_len; u64 tmp; __le64 *base_indirect_ptr; int page_entries; @@ -3009,8 +3008,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) memset((void *)cqicb, 0, sizeof(struct cqicb)); cqicb->msix_vect = rx_ring->irq; - bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len; - cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT); + cqicb->len = cpu_to_le16(QLGE_FIT16(rx_ring->cq_len) | LEN_V | + LEN_CPP_CONT); cqicb->addr = cpu_to_le64(rx_ring->cq_base_dma); @@ -3034,12 +3033,9 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) page_entries++; } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma); - bq_len = qdev->lbq_buf_size == 65536 ? 0 : - (u16)qdev->lbq_buf_size; - cqicb->lbq_buf_size = cpu_to_le16(bq_len); - bq_len = (rx_ring->lbq.len == 65536) ? 0 : - (u16)rx_ring->lbq.len; - cqicb->lbq_len = cpu_to_le16(bq_len); + cqicb->lbq_buf_size = + cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size)); + cqicb->lbq_len = cpu_to_le16(QLGE_FIT16(rx_ring->lbq.len)); rx_ring->lbq.prod_idx = 0; rx_ring->lbq.curr_idx = 0; rx_ring->lbq.clean_idx = 0; @@ -3059,9 +3055,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma); cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE); - bq_len = (rx_ring->sbq.len == 65536) ? 0 : - (u16)rx_ring->sbq.len; - cqicb->sbq_len = cpu_to_le16(bq_len); + cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(rx_ring->sbq.len)); rx_ring->sbq.prod_idx = 0; rx_ring->sbq.curr_idx = 0; rx_ring->sbq.clean_idx = 0; -- cgit v1.2.3-59-g8ed1b From ec705b983b46b8e2d3cafd40c188458bf4241f11 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:06 +0900 Subject: staging: qlge: Remove qlge_bq.len & size Given the way the driver currently works, these values are always known at compile time. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-13-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 17 +++++---- drivers/staging/qlge/qlge_dbg.c | 4 --- drivers/staging/qlge/qlge_main.c | 75 +++++++++++++++------------------------- 3 files changed, 39 insertions(+), 57 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 24af938da7a4..5e773af50397 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -34,8 +34,13 @@ #define NUM_TX_RING_ENTRIES 256 #define NUM_RX_RING_ENTRIES 256 -#define NUM_SMALL_BUFFERS 512 -#define NUM_LARGE_BUFFERS 512 +/* Use the same len for sbq and lbq. Note that it seems like the device might + * support different sizes. + */ +#define QLGE_BQ_SHIFT 9 +#define QLGE_BQ_LEN BIT(QLGE_BQ_SHIFT) +#define QLGE_BQ_SIZE (QLGE_BQ_LEN * sizeof(__le64)) + #define DB_PAGE_SIZE 4096 /* Calculate the number of (4k) pages required to @@ -46,8 +51,8 @@ (((x * sizeof(u64)) % DB_PAGE_SIZE) ? 1 : 0)) #define RX_RING_SHADOW_SPACE (sizeof(u64) + \ - MAX_DB_PAGES_PER_BQ(NUM_SMALL_BUFFERS) * sizeof(u64) + \ - MAX_DB_PAGES_PER_BQ(NUM_LARGE_BUFFERS) * sizeof(u64)) + MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN) * sizeof(u64) + \ + MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN) * sizeof(u64)) #define LARGE_BUFFER_MAX_SIZE 8192 #define LARGE_BUFFER_MIN_SIZE 2048 @@ -1419,8 +1424,6 @@ struct qlge_bq { dma_addr_t base_indirect_dma; struct qlge_bq_desc *queue; void __iomem *prod_idx_db_reg; - u32 len; /* entry count */ - u32 size; /* size in bytes of hw ring */ u32 prod_idx; /* current sw prod idx */ u32 curr_idx; /* next entry we expect */ u32 clean_idx; /* beginning of new descs */ @@ -1439,6 +1442,8 @@ struct qlge_bq { offsetof(struct rx_ring, lbq))); \ }) +#define QLGE_BQ_WRAP(index) ((index) & (QLGE_BQ_LEN - 1)) + struct rx_ring { struct cqicb cqicb; /* The chip's completion queue init control block. */ diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 81fbee7f2af6..c6bf78517410 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1774,8 +1774,6 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->lbq.base_indirect_dma = %llx\n", (unsigned long long)rx_ring->lbq.base_indirect_dma); pr_err("rx_ring->lbq = %p\n", rx_ring->lbq.queue); - pr_err("rx_ring->lbq.len = %d\n", rx_ring->lbq.len); - pr_err("rx_ring->lbq.size = %d\n", rx_ring->lbq.size); pr_err("rx_ring->lbq.prod_idx_db_reg = %p\n", rx_ring->lbq.prod_idx_db_reg); pr_err("rx_ring->lbq.prod_idx = %d\n", rx_ring->lbq.prod_idx); @@ -1791,8 +1789,6 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->sbq.base_indirect_dma = %llx\n", (unsigned long long)rx_ring->sbq.base_indirect_dma); pr_err("rx_ring->sbq = %p\n", rx_ring->sbq.queue); - pr_err("rx_ring->sbq.len = %d\n", rx_ring->sbq.len); - pr_err("rx_ring->sbq.size = %d\n", rx_ring->sbq.size); pr_err("rx_ring->sbq.prod_idx_db_reg addr = %p\n", rx_ring->sbq.prod_idx_db_reg); pr_err("rx_ring->sbq.prod_idx = %d\n", rx_ring->sbq.prod_idx); diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index e1099bd29672..ef33db118aa1 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -982,9 +982,8 @@ static struct qlge_bq_desc *qlge_get_curr_buf(struct qlge_bq *bq) { struct qlge_bq_desc *bq_desc; - bq_desc = &bq->queue[bq->curr_idx++]; - if (bq->curr_idx == bq->len) - bq->curr_idx = 0; + bq_desc = &bq->queue[bq->curr_idx]; + bq->curr_idx = QLGE_BQ_WRAP(bq->curr_idx + 1); bq->free_cnt++; return bq_desc; @@ -1149,15 +1148,11 @@ static void qlge_refill_bq(struct qlge_bq *bq) return; } - clean_idx++; - if (clean_idx == bq->len) - clean_idx = 0; + clean_idx = QLGE_BQ_WRAP(clean_idx + 1); } bq->clean_idx = clean_idx; - bq->prod_idx += 16; - if (bq->prod_idx == bq->len) - bq->prod_idx = 0; + bq->prod_idx = QLGE_BQ_WRAP(bq->prod_idx + 16); bq->free_cnt -= 16; } @@ -2732,8 +2727,7 @@ static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring put_page(lbq_desc->p.pg_chunk.page); lbq_desc->p.pg_chunk.page = NULL; - if (++curr_idx == rx_ring->lbq.len) - curr_idx = 0; + curr_idx = QLGE_BQ_WRAP(curr_idx + 1); } if (rx_ring->master_chunk.page) { @@ -2748,7 +2742,7 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring { int i; - for (i = 0; i < rx_ring->sbq.len; i++) { + for (i = 0; i < QLGE_BQ_LEN; i++) { struct qlge_bq_desc *sbq_desc = &rx_ring->sbq.queue[i]; if (sbq_desc == NULL) { @@ -2799,7 +2793,8 @@ static int qlge_init_bq(struct qlge_bq *bq) __le64 *buf_ptr; int i; - bq->base = pci_alloc_consistent(qdev->pdev, bq->size, &bq->base_dma); + bq->base = pci_alloc_consistent(qdev->pdev, QLGE_BQ_SIZE, + &bq->base_dma); if (!bq->base) { netif_err(qdev, ifup, qdev->ndev, "ring %u %s allocation failed.\n", rx_ring->cq_id, @@ -2807,16 +2802,16 @@ static int qlge_init_bq(struct qlge_bq *bq) return -ENOMEM; } - bq->queue = kmalloc_array(bq->len, sizeof(struct qlge_bq_desc), + bq->queue = kmalloc_array(QLGE_BQ_LEN, sizeof(struct qlge_bq_desc), GFP_KERNEL); if (!bq->queue) return -ENOMEM; - memset(bq->queue, 0, bq->len * sizeof(struct qlge_bq_desc)); + memset(bq->queue, 0, QLGE_BQ_LEN * sizeof(struct qlge_bq_desc)); buf_ptr = bq->base; bq_desc = &bq->queue[0]; - for (i = 0; i < bq->len; i++, buf_ptr++, bq_desc++) { + for (i = 0; i < QLGE_BQ_LEN; i++, buf_ptr++, bq_desc++) { memset(bq_desc, 0, sizeof(*bq_desc)); bq_desc->index = i; bq_desc->buf_ptr = buf_ptr; @@ -2830,8 +2825,7 @@ static void ql_free_rx_resources(struct ql_adapter *qdev, { /* Free the small buffer queue. */ if (rx_ring->sbq.base) { - pci_free_consistent(qdev->pdev, - rx_ring->sbq.size, + pci_free_consistent(qdev->pdev, QLGE_BQ_SIZE, rx_ring->sbq.base, rx_ring->sbq.base_dma); rx_ring->sbq.base = NULL; } @@ -2842,8 +2836,7 @@ static void ql_free_rx_resources(struct ql_adapter *qdev, /* Free the large buffer queue. */ if (rx_ring->lbq.base) { - pci_free_consistent(qdev->pdev, - rx_ring->lbq.size, + pci_free_consistent(qdev->pdev, QLGE_BQ_SIZE, rx_ring->lbq.base, rx_ring->lbq.base_dma); rx_ring->lbq.base = NULL; } @@ -2879,16 +2872,13 @@ static int ql_alloc_rx_resources(struct ql_adapter *qdev, return -ENOMEM; } - if (rx_ring->sbq.len && qlge_init_bq(&rx_ring->sbq)) - goto err_mem; - if (rx_ring->lbq.len && qlge_init_bq(&rx_ring->lbq)) - goto err_mem; + if (rx_ring->cq_id < qdev->rss_ring_count && + (qlge_init_bq(&rx_ring->sbq) || qlge_init_bq(&rx_ring->lbq))) { + ql_free_rx_resources(qdev, rx_ring); + return -ENOMEM; + } return 0; - -err_mem: - ql_free_rx_resources(qdev, rx_ring); - return -ENOMEM; } static void ql_tx_ring_clean(struct ql_adapter *qdev) @@ -2986,8 +2976,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) shadow_reg_dma += sizeof(u64); rx_ring->lbq.base_indirect = shadow_reg; rx_ring->lbq.base_indirect_dma = shadow_reg_dma; - shadow_reg += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); - shadow_reg_dma += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); + shadow_reg += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN)); + shadow_reg_dma += (sizeof(u64) * MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN)); rx_ring->sbq.base_indirect = shadow_reg; rx_ring->sbq.base_indirect_dma = shadow_reg_dma; @@ -3021,7 +3011,7 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) cqicb->flags = FLAGS_LC | /* Load queue base address */ FLAGS_LV | /* Load MSI-X vector */ FLAGS_LI; /* Load irq delay values */ - if (rx_ring->lbq.len) { + if (rx_ring->cq_id < qdev->rss_ring_count) { cqicb->flags |= FLAGS_LL; /* Load lbq values */ tmp = (u64)rx_ring->lbq.base_dma; base_indirect_ptr = rx_ring->lbq.base_indirect; @@ -3031,17 +3021,16 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) tmp += DB_PAGE_SIZE; base_indirect_ptr++; page_entries++; - } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->lbq.len)); + } while (page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN)); cqicb->lbq_addr = cpu_to_le64(rx_ring->lbq.base_indirect_dma); cqicb->lbq_buf_size = cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size)); - cqicb->lbq_len = cpu_to_le16(QLGE_FIT16(rx_ring->lbq.len)); + cqicb->lbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN)); rx_ring->lbq.prod_idx = 0; rx_ring->lbq.curr_idx = 0; rx_ring->lbq.clean_idx = 0; - rx_ring->lbq.free_cnt = rx_ring->lbq.len; - } - if (rx_ring->sbq.len) { + rx_ring->lbq.free_cnt = QLGE_BQ_LEN; + cqicb->flags |= FLAGS_LS; /* Load sbq values */ tmp = (u64)rx_ring->sbq.base_dma; base_indirect_ptr = rx_ring->sbq.base_indirect; @@ -3051,15 +3040,15 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) tmp += DB_PAGE_SIZE; base_indirect_ptr++; page_entries++; - } while (page_entries < MAX_DB_PAGES_PER_BQ(rx_ring->sbq.len)); + } while (page_entries < MAX_DB_PAGES_PER_BQ(QLGE_BQ_LEN)); cqicb->sbq_addr = cpu_to_le64(rx_ring->sbq.base_indirect_dma); cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE); - cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(rx_ring->sbq.len)); + cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN)); rx_ring->sbq.prod_idx = 0; rx_ring->sbq.curr_idx = 0; rx_ring->sbq.clean_idx = 0; - rx_ring->sbq.free_cnt = rx_ring->sbq.len; + rx_ring->sbq.free_cnt = QLGE_BQ_LEN; } if (rx_ring->cq_id < qdev->rss_ring_count) { /* Inbound completion handling rx_rings run in @@ -3986,11 +3975,7 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->cq_size = rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); rx_ring->lbq.type = QLGE_LB; - rx_ring->lbq.len = NUM_LARGE_BUFFERS; - rx_ring->lbq.size = rx_ring->lbq.len * sizeof(__le64); rx_ring->sbq.type = QLGE_SB; - rx_ring->sbq.len = NUM_SMALL_BUFFERS; - rx_ring->sbq.size = rx_ring->sbq.len * sizeof(__le64); } else { /* * Outbound queue handles outbound completions only. @@ -3999,10 +3984,6 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->cq_len = qdev->tx_ring_size; rx_ring->cq_size = rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); - rx_ring->lbq.len = 0; - rx_ring->lbq.size = 0; - rx_ring->sbq.len = 0; - rx_ring->sbq.size = 0; } } return 0; -- cgit v1.2.3-59-g8ed1b From 7be4c3f92077e4c5e1423edc5056c890f8bddfc7 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:07 +0900 Subject: staging: qlge: Remove useless memset This just repeats what the other memset a few lines above did. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-14-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index ef33db118aa1..8da596922582 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -2812,7 +2812,6 @@ static int qlge_init_bq(struct qlge_bq *bq) buf_ptr = bq->base; bq_desc = &bq->queue[0]; for (i = 0; i < QLGE_BQ_LEN; i++, buf_ptr++, bq_desc++) { - memset(bq_desc, 0, sizeof(*bq_desc)); bq_desc->index = i; bq_desc->buf_ptr = buf_ptr; } -- cgit v1.2.3-59-g8ed1b From c8c1ff5c19021a241afa78d1272c23ef7e7297aa Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:08 +0900 Subject: staging: qlge: Replace memset with assignment Instead of clearing the structure wholesale, it is sufficient to initialize the skb member which is used to manage sbq instances. lbq instances are managed according to curr_idx and clean_idx. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-15-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 8da596922582..009934bcb515 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -2807,11 +2807,10 @@ static int qlge_init_bq(struct qlge_bq *bq) if (!bq->queue) return -ENOMEM; - memset(bq->queue, 0, QLGE_BQ_LEN * sizeof(struct qlge_bq_desc)); - buf_ptr = bq->base; bq_desc = &bq->queue[0]; for (i = 0; i < QLGE_BQ_LEN; i++, buf_ptr++, bq_desc++) { + bq_desc->p.skb = NULL; bq_desc->index = i; bq_desc->buf_ptr = buf_ptr; } -- cgit v1.2.3-59-g8ed1b From aec626d2092f2b203f4acec5b57ed7c1e3095802 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:09 +0900 Subject: staging: qlge: Update buffer queue prod index despite oom Currently, if we repeatedly fail to allocate all of the buffers from the desired batching budget, we will never update the prod_idx register. Restructure code to always update prod_idx if new buffers could be allocated. This eliminates the current two stage process (clean_idx -> prod_idx) and some associated bookkeeping variables. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-16-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 8 +-- drivers/staging/qlge/qlge_dbg.c | 10 ++-- drivers/staging/qlge/qlge_main.c | 105 +++++++++++++++++++-------------------- 3 files changed, 60 insertions(+), 63 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 5e773af50397..7c48e333d29b 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1424,10 +1424,10 @@ struct qlge_bq { dma_addr_t base_indirect_dma; struct qlge_bq_desc *queue; void __iomem *prod_idx_db_reg; - u32 prod_idx; /* current sw prod idx */ - u32 curr_idx; /* next entry we expect */ - u32 clean_idx; /* beginning of new descs */ - u32 free_cnt; /* free buffer desc cnt */ + /* next index where sw should refill a buffer for hw */ + u16 next_to_use; + /* next index where sw expects to find a buffer filled by hw */ + u16 next_to_clean; enum { QLGE_SB, /* small buffer */ QLGE_LB, /* large buffer */ diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index c6bf78517410..7e16066a3527 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1776,8 +1776,8 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->lbq = %p\n", rx_ring->lbq.queue); pr_err("rx_ring->lbq.prod_idx_db_reg = %p\n", rx_ring->lbq.prod_idx_db_reg); - pr_err("rx_ring->lbq.prod_idx = %d\n", rx_ring->lbq.prod_idx); - pr_err("rx_ring->lbq.curr_idx = %d\n", rx_ring->lbq.curr_idx); + pr_err("rx_ring->lbq.next_to_use = %d\n", rx_ring->lbq.next_to_use); + pr_err("rx_ring->lbq.next_to_clean = %d\n", rx_ring->lbq.next_to_clean); pr_err("rx_ring->lbq_clean_idx = %d\n", rx_ring->lbq_clean_idx); pr_err("rx_ring->lbq_free_cnt = %d\n", rx_ring->lbq_free_cnt); @@ -1791,10 +1791,8 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) pr_err("rx_ring->sbq = %p\n", rx_ring->sbq.queue); pr_err("rx_ring->sbq.prod_idx_db_reg addr = %p\n", rx_ring->sbq.prod_idx_db_reg); - pr_err("rx_ring->sbq.prod_idx = %d\n", rx_ring->sbq.prod_idx); - pr_err("rx_ring->sbq.curr_idx = %d\n", rx_ring->sbq.curr_idx); - pr_err("rx_ring->sbq.clean_idx = %d\n", rx_ring->sbq.clean_idx); - pr_err("rx_ring->sbq.free_cnt = %d\n", rx_ring->sbq.free_cnt); + pr_err("rx_ring->sbq.next_to_use = %d\n", rx_ring->sbq.next_to_use); + pr_err("rx_ring->sbq.next_to_clean = %d\n", rx_ring->sbq.next_to_clean); pr_err("rx_ring->cq_id = %d\n", rx_ring->cq_id); pr_err("rx_ring->irq = %d\n", rx_ring->irq); pr_err("rx_ring->cpu = %d\n", rx_ring->cpu); diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 009934bcb515..83e75005688a 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -982,9 +982,8 @@ static struct qlge_bq_desc *qlge_get_curr_buf(struct qlge_bq *bq) { struct qlge_bq_desc *bq_desc; - bq_desc = &bq->queue[bq->curr_idx]; - bq->curr_idx = QLGE_BQ_WRAP(bq->curr_idx + 1); - bq->free_cnt++; + bq_desc = &bq->queue[bq->next_to_clean]; + bq->next_to_clean = QLGE_BQ_WRAP(bq->next_to_clean + 1); return bq_desc; } @@ -1114,9 +1113,9 @@ static void qlge_refill_bq(struct qlge_bq *bq) { struct rx_ring *rx_ring = QLGE_BQ_CONTAINER(bq); struct ql_adapter *qdev = rx_ring->qdev; - u32 clean_idx = bq->clean_idx; + struct qlge_bq_desc *bq_desc; + int free_count, refill_count; unsigned int reserved_count; - u32 start_idx = clean_idx; int i; if (bq->type == QLGE_SB) @@ -1124,44 +1123,52 @@ static void qlge_refill_bq(struct qlge_bq *bq) else reserved_count = 32; - while (bq->free_cnt > reserved_count) { - for (i = (bq->clean_idx % 16); i < 16; i++) { - struct qlge_bq_desc *bq_desc = &bq->queue[clean_idx]; - int retval; + free_count = bq->next_to_clean - bq->next_to_use; + if (free_count <= 0) + free_count += QLGE_BQ_LEN; - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "ring %u %s: try cleaning clean_idx = %d.\n", - rx_ring->cq_id, bq_type_name[bq->type], - clean_idx); - - if (bq->type == QLGE_SB) - retval = qlge_refill_sb(rx_ring, bq_desc); - else - retval = qlge_refill_lb(rx_ring, bq_desc); - if (retval < 0) { - bq->clean_idx = clean_idx; - netif_err(qdev, ifup, qdev->ndev, - "ring %u %s: Could not get a page chunk, i=%d, clean_idx =%d .\n", - rx_ring->cq_id, - bq_type_name[bq->type], i, - clean_idx); - return; - } + refill_count = free_count - reserved_count; + /* refill batch size */ + if (refill_count < 16) + return; + + i = bq->next_to_use; + bq_desc = &bq->queue[i]; + i -= QLGE_BQ_LEN; + do { + int retval; + + netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, + "ring %u %s: try cleaning idx %d\n", + rx_ring->cq_id, bq_type_name[bq->type], i); - clean_idx = QLGE_BQ_WRAP(clean_idx + 1); + if (bq->type == QLGE_SB) + retval = qlge_refill_sb(rx_ring, bq_desc); + else + retval = qlge_refill_lb(rx_ring, bq_desc); + if (retval < 0) { + netif_err(qdev, ifup, qdev->ndev, + "ring %u %s: Could not get a page chunk, idx %d\n", + rx_ring->cq_id, bq_type_name[bq->type], i); + break; } - bq->clean_idx = clean_idx; - bq->prod_idx = QLGE_BQ_WRAP(bq->prod_idx + 16); - bq->free_cnt -= 16; - } + bq_desc++; + i++; + if (unlikely(!i)) { + bq_desc = &bq->queue[0]; + i -= QLGE_BQ_LEN; + } + refill_count--; + } while (refill_count); + i += QLGE_BQ_LEN; - if (start_idx != clean_idx) { + if (bq->next_to_use != i) { netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "ring %u %s: updating prod idx = %d.\n", - rx_ring->cq_id, bq_type_name[bq->type], - bq->prod_idx); - ql_write_db_reg(bq->prod_idx, bq->prod_idx_db_reg); + rx_ring->cq_id, bq_type_name[bq->type], i); + bq->next_to_use = i; + ql_write_db_reg(bq->next_to_use, bq->prod_idx_db_reg); } } @@ -2709,25 +2716,21 @@ pci_alloc_err: static void ql_free_lbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring) { + struct qlge_bq *lbq = &rx_ring->lbq; unsigned int last_offset; - uint32_t curr_idx, clean_idx; - last_offset = ql_lbq_block_size(qdev) - qdev->lbq_buf_size; - curr_idx = rx_ring->lbq.curr_idx; - clean_idx = rx_ring->lbq.clean_idx; - while (curr_idx != clean_idx) { - struct qlge_bq_desc *lbq_desc = &rx_ring->lbq.queue[curr_idx]; + while (lbq->next_to_clean != lbq->next_to_use) { + struct qlge_bq_desc *lbq_desc = + &lbq->queue[lbq->next_to_clean]; if (lbq_desc->p.pg_chunk.offset == last_offset) pci_unmap_page(qdev->pdev, lbq_desc->dma_addr, ql_lbq_block_size(qdev), PCI_DMA_FROMDEVICE); - put_page(lbq_desc->p.pg_chunk.page); - lbq_desc->p.pg_chunk.page = NULL; - curr_idx = QLGE_BQ_WRAP(curr_idx + 1); + lbq->next_to_clean = QLGE_BQ_WRAP(lbq->next_to_clean + 1); } if (rx_ring->master_chunk.page) { @@ -3024,10 +3027,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) cqicb->lbq_buf_size = cpu_to_le16(QLGE_FIT16(qdev->lbq_buf_size)); cqicb->lbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN)); - rx_ring->lbq.prod_idx = 0; - rx_ring->lbq.curr_idx = 0; - rx_ring->lbq.clean_idx = 0; - rx_ring->lbq.free_cnt = QLGE_BQ_LEN; + rx_ring->lbq.next_to_use = 0; + rx_ring->lbq.next_to_clean = 0; cqicb->flags |= FLAGS_LS; /* Load sbq values */ tmp = (u64)rx_ring->sbq.base_dma; @@ -3043,10 +3044,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring) cpu_to_le64(rx_ring->sbq.base_indirect_dma); cqicb->sbq_buf_size = cpu_to_le16(SMALL_BUFFER_SIZE); cqicb->sbq_len = cpu_to_le16(QLGE_FIT16(QLGE_BQ_LEN)); - rx_ring->sbq.prod_idx = 0; - rx_ring->sbq.curr_idx = 0; - rx_ring->sbq.clean_idx = 0; - rx_ring->sbq.free_cnt = QLGE_BQ_LEN; + rx_ring->sbq.next_to_use = 0; + rx_ring->sbq.next_to_clean = 0; } if (rx_ring->cq_id < qdev->rss_ring_count) { /* Inbound completion handling rx_rings run in -- cgit v1.2.3-59-g8ed1b From 6e9c52b920974b90c4ca994c5d8c5bc56742017f Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:10 +0900 Subject: staging: qlge: Refill rx buffers up to multiple of 16 Reading the {s,l}bq_prod_idx registers on a running device, it appears that the adapter will only use buffers up to prod_idx & 0xfff0. The driver currently uses fixed-size guard zones (16 for sbq, 32 for lbq - don't know why this difference). After the previous patch, this approach no longer guarantees prod_idx values aligned on multiples of 16. While it appears that we can write unaligned values to prod_idx without ill effects on device operation, it makes more sense to change qlge_refill_bq() to refill up to a limit that corresponds with the device's behavior. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-17-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 8 ++++++++ drivers/staging/qlge/qlge_main.c | 29 +++++++++++------------------ 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 7c48e333d29b..e5a352df8228 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1423,6 +1423,9 @@ struct qlge_bq { __le64 *base_indirect; dma_addr_t base_indirect_dma; struct qlge_bq_desc *queue; + /* prod_idx is the index of the first buffer that may NOT be used by + * hw, ie. one after the last. Advanced by sw. + */ void __iomem *prod_idx_db_reg; /* next index where sw should refill a buffer for hw */ u16 next_to_use; @@ -1442,6 +1445,11 @@ struct qlge_bq { offsetof(struct rx_ring, lbq))); \ }) +/* Experience shows that the device ignores the low 4 bits of the tail index. + * Refill up to a x16 multiple. + */ +#define QLGE_BQ_ALIGN(index) ALIGN_DOWN(index, 16) + #define QLGE_BQ_WRAP(index) ((index) & (QLGE_BQ_LEN - 1)) struct rx_ring { diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 83e75005688a..02ad0cdf4856 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1114,22 +1114,12 @@ static void qlge_refill_bq(struct qlge_bq *bq) struct rx_ring *rx_ring = QLGE_BQ_CONTAINER(bq); struct ql_adapter *qdev = rx_ring->qdev; struct qlge_bq_desc *bq_desc; - int free_count, refill_count; - unsigned int reserved_count; + int refill_count; int i; - if (bq->type == QLGE_SB) - reserved_count = 16; - else - reserved_count = 32; - - free_count = bq->next_to_clean - bq->next_to_use; - if (free_count <= 0) - free_count += QLGE_BQ_LEN; - - refill_count = free_count - reserved_count; - /* refill batch size */ - if (refill_count < 16) + refill_count = QLGE_BQ_WRAP(QLGE_BQ_ALIGN(bq->next_to_clean - 1) - + bq->next_to_use); + if (!refill_count) return; i = bq->next_to_use; @@ -1164,11 +1154,14 @@ static void qlge_refill_bq(struct qlge_bq *bq) i += QLGE_BQ_LEN; if (bq->next_to_use != i) { - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, - "ring %u %s: updating prod idx = %d.\n", - rx_ring->cq_id, bq_type_name[bq->type], i); + if (QLGE_BQ_ALIGN(bq->next_to_use) != QLGE_BQ_ALIGN(i)) { + netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, + "ring %u %s: updating prod idx = %d.\n", + rx_ring->cq_id, bq_type_name[bq->type], + i); + ql_write_db_reg(i, bq->prod_idx_db_reg); + } bq->next_to_use = i; - ql_write_db_reg(bq->next_to_use, bq->prod_idx_db_reg); } } -- cgit v1.2.3-59-g8ed1b From b91fec1ecf6f0a93d909f8cb98ad8aea7109e81b Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Fri, 27 Sep 2019 19:12:11 +0900 Subject: staging: qlge: Refill empty buffer queues from wq When operating at mtu 9000, qlge does order-1 allocations for rx buffers in atomic context. This is especially unreliable when free memory is low or fragmented. Add an approach similar to commit 3161e453e496 ("virtio: net refill on out-of-memory") to qlge so that the device doesn't lock up if there are allocation failures. Signed-off-by: Benjamin Poirier Link: https://lore.kernel.org/r/20190927101210.23856-18-bpoirier@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/TODO | 3 -- drivers/staging/qlge/qlge.h | 8 ++++ drivers/staging/qlge/qlge_main.c | 80 ++++++++++++++++++++++++++++++++-------- 3 files changed, 72 insertions(+), 19 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/TODO b/drivers/staging/qlge/TODO index 51c509084e80..f93f7428f5d5 100644 --- a/drivers/staging/qlge/TODO +++ b/drivers/staging/qlge/TODO @@ -1,6 +1,3 @@ -* reception stalls permanently (until admin intervention) if the rx buffer - queues become empty because of allocation failures (ex. under memory - pressure) * commit 7c734359d350 ("qlge: Size RX buffers based on MTU.", v2.6.33-rc1) introduced dead code in the receive routines, which should be rewritten anyways by the admission of the author himself, see the comment above diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index e5a352df8228..6ec7e3ce3863 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1452,6 +1452,13 @@ struct qlge_bq { #define QLGE_BQ_WRAP(index) ((index) & (QLGE_BQ_LEN - 1)) +#define QLGE_BQ_HW_OWNED(bq) \ +({ \ + typeof(bq) _bq = bq; \ + QLGE_BQ_WRAP(QLGE_BQ_ALIGN((_bq)->next_to_use) - \ + (_bq)->next_to_clean); \ +}) + struct rx_ring { struct cqicb cqicb; /* The chip's completion queue init control block. */ @@ -1479,6 +1486,7 @@ struct rx_ring { /* Misc. handler elements. */ u32 irq; /* Which vector this ring is assigned. */ u32 cpu; /* Which CPU this should run on. */ + struct delayed_work refill_work; char name[IFNAMSIZ + 5]; struct napi_struct napi; u8 reserved; diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 02ad0cdf4856..0c381d91faa6 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1029,7 +1029,7 @@ static const char * const bq_type_name[] = { /* return 0 or negative error */ static int qlge_refill_sb(struct rx_ring *rx_ring, - struct qlge_bq_desc *sbq_desc) + struct qlge_bq_desc *sbq_desc, gfp_t gfp) { struct ql_adapter *qdev = rx_ring->qdev; struct sk_buff *skb; @@ -1041,7 +1041,7 @@ static int qlge_refill_sb(struct rx_ring *rx_ring, "ring %u sbq: getting new skb for index %d.\n", rx_ring->cq_id, sbq_desc->index); - skb = netdev_alloc_skb(qdev->ndev, SMALL_BUFFER_SIZE); + skb = __netdev_alloc_skb(qdev->ndev, SMALL_BUFFER_SIZE, gfp); if (!skb) return -ENOMEM; skb_reserve(skb, QLGE_SB_PAD); @@ -1062,7 +1062,7 @@ static int qlge_refill_sb(struct rx_ring *rx_ring, /* return 0 or negative error */ static int qlge_refill_lb(struct rx_ring *rx_ring, - struct qlge_bq_desc *lbq_desc) + struct qlge_bq_desc *lbq_desc, gfp_t gfp) { struct ql_adapter *qdev = rx_ring->qdev; struct qlge_page_chunk *master_chunk = &rx_ring->master_chunk; @@ -1071,8 +1071,7 @@ static int qlge_refill_lb(struct rx_ring *rx_ring, struct page *page; dma_addr_t dma_addr; - page = alloc_pages(__GFP_COMP | GFP_ATOMIC, - qdev->lbq_buf_order); + page = alloc_pages(gfp | __GFP_COMP, qdev->lbq_buf_order); if (unlikely(!page)) return -ENOMEM; dma_addr = pci_map_page(qdev->pdev, page, 0, @@ -1109,33 +1108,33 @@ static int qlge_refill_lb(struct rx_ring *rx_ring, return 0; } -static void qlge_refill_bq(struct qlge_bq *bq) +/* return 0 or negative error */ +static int qlge_refill_bq(struct qlge_bq *bq, gfp_t gfp) { struct rx_ring *rx_ring = QLGE_BQ_CONTAINER(bq); struct ql_adapter *qdev = rx_ring->qdev; struct qlge_bq_desc *bq_desc; int refill_count; + int retval; int i; refill_count = QLGE_BQ_WRAP(QLGE_BQ_ALIGN(bq->next_to_clean - 1) - bq->next_to_use); if (!refill_count) - return; + return 0; i = bq->next_to_use; bq_desc = &bq->queue[i]; i -= QLGE_BQ_LEN; do { - int retval; - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "ring %u %s: try cleaning idx %d\n", rx_ring->cq_id, bq_type_name[bq->type], i); if (bq->type == QLGE_SB) - retval = qlge_refill_sb(rx_ring, bq_desc); + retval = qlge_refill_sb(rx_ring, bq_desc, gfp); else - retval = qlge_refill_lb(rx_ring, bq_desc); + retval = qlge_refill_lb(rx_ring, bq_desc, gfp); if (retval < 0) { netif_err(qdev, ifup, qdev->ndev, "ring %u %s: Could not get a page chunk, idx %d\n", @@ -1163,12 +1162,52 @@ static void qlge_refill_bq(struct qlge_bq *bq) } bq->next_to_use = i; } + + return retval; +} + +static void ql_update_buffer_queues(struct rx_ring *rx_ring, gfp_t gfp, + unsigned long delay) +{ + bool sbq_fail, lbq_fail; + + sbq_fail = !!qlge_refill_bq(&rx_ring->sbq, gfp); + lbq_fail = !!qlge_refill_bq(&rx_ring->lbq, gfp); + + /* Minimum number of buffers needed to be able to receive at least one + * frame of any format: + * sbq: 1 for header + 1 for data + * lbq: mtu 9000 / lb size + * Below this, the queue might stall. + */ + if ((sbq_fail && QLGE_BQ_HW_OWNED(&rx_ring->sbq) < 2) || + (lbq_fail && QLGE_BQ_HW_OWNED(&rx_ring->lbq) < + DIV_ROUND_UP(9000, LARGE_BUFFER_MAX_SIZE))) + /* Allocations can take a long time in certain cases (ex. + * reclaim). Therefore, use a workqueue for long-running + * work items. + */ + queue_delayed_work_on(smp_processor_id(), system_long_wq, + &rx_ring->refill_work, delay); } -static void ql_update_buffer_queues(struct rx_ring *rx_ring) +static void qlge_slow_refill(struct work_struct *work) { - qlge_refill_bq(&rx_ring->sbq); - qlge_refill_bq(&rx_ring->lbq); + struct rx_ring *rx_ring = container_of(work, struct rx_ring, + refill_work.work); + struct napi_struct *napi = &rx_ring->napi; + + napi_disable(napi); + ql_update_buffer_queues(rx_ring, GFP_KERNEL, HZ / 2); + napi_enable(napi); + + local_bh_disable(); + /* napi_disable() might have prevented incomplete napi work from being + * rescheduled. + */ + napi_schedule(napi); + /* trigger softirq processing */ + local_bh_enable(); } /* Unmaps tx buffers. Can be called from send() if a pci mapping @@ -2168,7 +2207,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) if (count == budget) break; } - ql_update_buffer_queues(rx_ring); + ql_update_buffer_queues(rx_ring, GFP_ATOMIC, 0); ql_write_cq_idx(rx_ring); return count; } @@ -2778,7 +2817,8 @@ static void ql_alloc_rx_buffers(struct ql_adapter *qdev) int i; for (i = 0; i < qdev->rss_ring_count; i++) - ql_update_buffer_queues(&qdev->rx_ring[i]); + ql_update_buffer_queues(&qdev->rx_ring[i], GFP_KERNEL, + HZ / 2); } static int qlge_init_bq(struct qlge_bq *bq) @@ -3883,6 +3923,7 @@ static int ql_get_adapter_resources(struct ql_adapter *qdev) static int qlge_close(struct net_device *ndev) { struct ql_adapter *qdev = netdev_priv(ndev); + int i; /* If we hit pci_channel_io_perm_failure * failure condition, then we already @@ -3900,6 +3941,11 @@ static int qlge_close(struct net_device *ndev) */ while (!test_bit(QL_ADAPTER_UP, &qdev->flags)) msleep(1); + + /* Make sure refill_work doesn't re-enable napi */ + for (i = 0; i < qdev->rss_ring_count; i++) + cancel_delayed_work_sync(&qdev->rx_ring[i].refill_work); + ql_adapter_down(qdev); ql_release_adapter_resources(qdev); return 0; @@ -3966,6 +4012,8 @@ static int ql_configure_rings(struct ql_adapter *qdev) rx_ring->cq_len * sizeof(struct ql_net_rsp_iocb); rx_ring->lbq.type = QLGE_LB; rx_ring->sbq.type = QLGE_SB; + INIT_DELAYED_WORK(&rx_ring->refill_work, + &qlge_slow_refill); } else { /* * Outbound queue handles outbound completions only. -- cgit v1.2.3-59-g8ed1b From bf653da8623178e84e185f8412d75ae644ce533b Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Sun, 6 Oct 2019 08:30:19 -0500 Subject: staging: rtl8723bs: Remove unnecessary braces Remove unnecessary braces for single statement block. Issue found by checkpatch. Signed-off-by: Javier F. Arias Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191006133016.GA22297@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index b5dcb78fb4f4..29acbb1ee869 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -3022,9 +3022,8 @@ int rtw_sctx_wait(struct submit_ctx *sctx, const char *msg) status = sctx->status; } - if (status == RTW_SCTX_DONE_SUCCESS) { + if (status == RTW_SCTX_DONE_SUCCESS) ret = _SUCCESS; - } return ret; } -- cgit v1.2.3-59-g8ed1b From ef0abd6f24d3e935491f303f64d402dab5270c37 Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Fri, 4 Oct 2019 21:40:22 +0000 Subject: staging: wilc1000: don't use wdev while setting tx power WILC doesn't support per-vif tx power, and hence, wdev will always be null in calls to set_tx_power. Instead, wiphy should be used to execute the operation Signed-off-by: Adham Abozaeid Link: https://lore.kernel.org/r/20191004214011.7623-1-adham.abozaeid@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 3882c90dc3fb..cc56abc2fe37 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1685,9 +1685,22 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, enum nl80211_tx_power_setting type, int mbm) { int ret; + int srcu_idx; s32 tx_power = MBM_TO_DBM(mbm); - struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + if (!wl->initialized) + return -EIO; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) { + srcu_read_unlock(&wl->srcu, srcu_idx); + return -EINVAL; + } + + netdev_info(vif->ndev, "Setting tx power %d\n", tx_power); if (tx_power < 0) tx_power = 0; else if (tx_power > 18) @@ -1695,6 +1708,7 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, ret = wilc_set_tx_power(vif, tx_power); if (ret) netdev_err(vif->ndev, "Failed to set tx power\n"); + srcu_read_unlock(&wl->srcu, srcu_idx); return ret; } -- cgit v1.2.3-59-g8ed1b From ea60b4eb4420ba59172a3283bf26192d609a114d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 5 Oct 2019 16:18:52 +0200 Subject: staging: rtl8188eu: remove unnecessary asignment and initialization Variable badworden is asigned in two subsequent lines. So the first asignment is useless and not needed. Also the initialization to zero is not needed. Remove the first asignment and the initialization. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191005141852.88712-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 02c476f45b33..d191dbef0bb3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -615,10 +615,9 @@ static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuse static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt) { u16 efuse_addr = *pAddr; - u8 badworden = 0; + u8 badworden; u32 PgWriteSuccess = 0; - badworden = 0x0f; badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr + 1, pTargetPkt->word_en, pTargetPkt->data); if (badworden == 0x0F) { /* write ok */ -- cgit v1.2.3-59-g8ed1b From a5a5ec2538ab76fda4ec66f86adf0b80ef7c40bc Mon Sep 17 00:00:00 2001 From: zhengbin Date: Sun, 6 Oct 2019 17:33:02 +0800 Subject: staging: rtl8723bs: Remove set but not used variable 'oldcnt' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/hal/sdio_ops.c: In function sdio_read_port: drivers/staging/rtl8723bs/hal/sdio_ops.c:430:6: warning: variable oldcnt set but not used [-Wunused-but-set-variable] It is not used since commit dedf215bd1c7 ("staging: rtl8723bs: remove unused code") Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1570354382-86879-1-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 301d327d0624..1267fe9f9af2 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -427,7 +427,6 @@ static u32 sdio_read_port( struct adapter *adapter; struct sdio_data *psdio; struct hal_com_data *hal; - u32 oldcnt; s32 err; @@ -437,7 +436,6 @@ static u32 sdio_read_port( HalSdioGetCmdAddr8723BSdio(adapter, addr, hal->SdioRxFIFOCnt++, &addr); - oldcnt = cnt; if (cnt > psdio->block_transfer_len) cnt = _RND(cnt, psdio->block_transfer_len); /* cnt = sdio_align_size(cnt); */ -- cgit v1.2.3-59-g8ed1b From d8a363ef0046ddef23c0b3350af7fdb85b296749 Mon Sep 17 00:00:00 2001 From: Sumera Priyadarsini Date: Sun, 6 Oct 2019 16:23:00 +0530 Subject: staging: rtl8192u: Fix indentation for cleaner code Fixes indentation for if condition in the file r8190_rtl8256.c for better readability as suggested by Dan Carpenter. Reported-by: Dan Carpenter Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/20191006105300.10181-1-sylphrenadin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8190_rtl8256.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.c b/drivers/staging/rtl8192u/r8190_rtl8256.c index b169460b9f26..63e0f7b1b852 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.c +++ b/drivers/staging/rtl8192u/r8190_rtl8256.c @@ -43,8 +43,8 @@ void phy_set_rf8256_bandwidth(struct net_device *dev, enum ht_channel_width Band switch (Bandwidth) { case HT_CHANNEL_WIDTH_20: if (priv->card_8192_version == VERSION_819XU_A || - priv->card_8192_version == - VERSION_819XU_B) { /* 8256 D-cut, E-cut, xiong: consider it later! */ + priv->card_8192_version == VERSION_819XU_B) { + /* 8256 D-cut, E-cut, xiong: consider it later! */ rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)eRFPath, 0x0b, bMask12Bits, 0x100); /* phy para:1ba */ -- cgit v1.2.3-59-g8ed1b From b483b4e4d3f6bfd5089b9e6dc9ba259879c6ce6f Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 6 Oct 2019 20:10:32 +0200 Subject: staging: mt7621-pci: add quirks for 'E2' revision using 'soc_device_attribute' Depending on revision of the chip, reset lines are inverted. Make code more readable making use of 'soc_device_match' in driver probe function. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20191006181032.19112-1-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 6b98827da57f..3633c924848e 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -29,15 +29,14 @@ #include #include #include +#include #include #include #include "../../pci/pci.h" /* sysctl */ -#define MT7621_CHIP_REV_ID 0x0c #define MT7621_GPIO_MODE 0x60 -#define CHIP_REV_MT7621_E2 0x0101 /* MediaTek specific configuration registers */ #define PCIE_FTS_NUM 0x70c @@ -126,6 +125,8 @@ struct mt7621_pcie_port { * @ports: pointer to PCIe port information * @perst: gpio reset * @rst: pointer to pcie reset + * @resets_inverted: depends on chip revision + * reset lines are inverted. */ struct mt7621_pcie { void __iomem *base; @@ -140,6 +141,7 @@ struct mt7621_pcie { struct list_head ports; struct gpio_desc *perst; struct reset_control *rst; + bool resets_inverted; }; static inline u32 pcie_read(struct mt7621_pcie *pcie, u32 reg) @@ -229,9 +231,9 @@ static inline void mt7621_pcie_port_clk_disable(struct mt7621_pcie_port *port) static inline void mt7621_control_assert(struct mt7621_pcie_port *port) { - u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); + struct mt7621_pcie *pcie = port->pcie; - if ((chip_rev_id & 0xFFFF) == CHIP_REV_MT7621_E2) + if (pcie->resets_inverted) reset_control_assert(port->pcie_rst); else reset_control_deassert(port->pcie_rst); @@ -239,9 +241,9 @@ static inline void mt7621_control_assert(struct mt7621_pcie_port *port) static inline void mt7621_control_deassert(struct mt7621_pcie_port *port) { - u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); + struct mt7621_pcie *pcie = port->pcie; - if ((chip_rev_id & 0xFFFF) == CHIP_REV_MT7621_E2) + if (pcie->resets_inverted) reset_control_deassert(port->pcie_rst); else reset_control_assert(port->pcie_rst); @@ -641,9 +643,14 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host, return pci_host_probe(host); } +static const struct soc_device_attribute mt7621_pci_quirks_match[] = { + { .soc_id = "mt7621", .revision = "E2" } +}; + static int mt7621_pci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct soc_device_attribute *attr; struct mt7621_pcie *pcie; struct pci_host_bridge *bridge; int err; @@ -661,6 +668,10 @@ static int mt7621_pci_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pcie); INIT_LIST_HEAD(&pcie->ports); + attr = soc_device_match(mt7621_pci_quirks_match); + if (attr) + pcie->resets_inverted = true; + err = mt7621_pcie_parse_dt(pcie); if (err) { dev_err(dev, "Parsing DT failed\n"); -- cgit v1.2.3-59-g8ed1b From f3c3f2d43484b387e2d54bfcb6283755d0f581d9 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Sun, 6 Oct 2019 16:58:54 -0300 Subject: staging: vt6656: remove duplicated blank line Cleans up checks of "don't use multiple blank line" Signed-off-by: Gabriela Bittencourt Reviewed-by: Quentin Deslandes Link: https://lore.kernel.org/r/20191006195854.9843-1-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3478a10f8025..4ac85ecb0921 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -362,7 +362,6 @@ static int vnt_init_registers(struct vnt_private *priv) goto end; } - ret = vnt_mac_set_led(priv, LEDSTS_TMLEN, 0x38); if (ret) goto end; -- cgit v1.2.3-59-g8ed1b From 6d9a930cd9aaf054d50119955a62cb234e2a3e23 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Sun, 6 Oct 2019 18:03:30 -0500 Subject: staging: rtl8723bs: Remove unnecessary braces Remove braces that are not necessary for any arm of this statement. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/20191006230327.GA4168@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 29acbb1ee869..bc5ef56a7d53 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -3074,9 +3074,8 @@ void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status) { struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; - if (pxmitpriv->ack_tx) { + if (pxmitpriv->ack_tx) rtw_sctx_done_err(&pack_tx_ops, status); - } else { + else DBG_871X("%s ack_tx not set\n", __func__); - } } -- cgit v1.2.3-59-g8ed1b From 164eec46ea9967a968e6a5950041ac9a48f2200b Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Sun, 6 Oct 2019 16:40:30 -0300 Subject: staging: vt6656: reorganize characters so the lines are under 80 ch Cleans up warnings of "line over 80 characters" Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191006194030.8854-1-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 4e9cfacf75f2..f9020a4f7bbf 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -112,11 +112,11 @@ static u32 vnt_get_rsvtime(struct vnt_private *priv, u8 pkt_type, frame_length, rate); if (pkt_type == PK_TYPE_11B) - ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, - 14, (u16)priv->top_cck_basic_rate); + ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14, + (u16)priv->top_cck_basic_rate); else - ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, - 14, (u16)priv->top_ofdm_basic_rate); + ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type, 14, + (u16)priv->top_ofdm_basic_rate); if (need_ack) return data_time + priv->sifs + ack_time; -- cgit v1.2.3-59-g8ed1b From 3dbcdf183b3292c04db7c2e0401e090950acd575 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Sun, 6 Oct 2019 22:32:05 -0500 Subject: staging: rtl8723bs: Switch constant place in test Switch constant place as it should be on the right side of the test. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/20191007033202.45czxuochtylkddf@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index bc5ef56a7d53..6190ef08236a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2992,7 +2992,7 @@ int rtw_xmit_thread(void *context) do { err = rtw_hal_xmit_thread_handler(padapter); flush_signals_thread(); - } while (_SUCCESS == err); + } while (err == _SUCCESS); complete(&padapter->xmitpriv.terminate_xmitthread_comp); -- cgit v1.2.3-59-g8ed1b From 402bd53e964f60ef9ef87eb3c210e161dd039f80 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Sun, 6 Oct 2019 21:39:02 -0300 Subject: staging: rtl8712: align arguments with open parenthesis in file rtl8712_led.c Cleans up checks of "Alignment should match open parenthesis" Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191007003902.21911-1-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl8712_led.c b/drivers/staging/rtl8712/rtl8712_led.c index db99129d3169..5901026949f2 100644 --- a/drivers/staging/rtl8712/rtl8712_led.c +++ b/drivers/staging/rtl8712/rtl8712_led.c @@ -75,7 +75,7 @@ static void BlinkWorkItemCallback(struct work_struct *work); * Initialize an LED_871x object. */ static void InitLed871x(struct _adapter *padapter, struct LED_871x *pLed, - enum LED_PIN_871x LedPin) + enum LED_PIN_871x LedPin) { pLed->padapter = padapter; pLed->LedPin = LedPin; -- cgit v1.2.3-59-g8ed1b From 4ccb5b0bc3e8fb36db931c42a47cf29d20ada427 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Sun, 6 Oct 2019 17:09:56 +0800 Subject: staging: rtl8723bs: Remove set but not used variable 'tmp_aid' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/core/rtw_sta_mgt.c: In function rtw_alloc_stainfo: drivers/staging/rtl8723bs/core/rtw_sta_mgt.c:190:7: warning: variable tmp_aid set but not used [-Wunused-but-set-variable] It is not used since commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1570352999-45790-3-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index bdc52d8d5625..09d2ca30d653 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -187,7 +187,6 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) /* struct sta_info *rtw_alloc_stainfo(_queue *pfree_sta_queue, unsigned char *hwaddr) */ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { - uint tmp_aid; s32 index; struct list_head *phash_list; struct sta_info *psta; @@ -211,8 +210,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) /* spin_unlock_bh(&(pfree_sta_queue->lock)); */ - tmp_aid = psta->aid; - _rtw_init_stainfo(psta); psta->padapter = pstapriv->padapter; -- cgit v1.2.3-59-g8ed1b From d34befc134d14c2ca8f69f62be1e6225f8fae738 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Sun, 6 Oct 2019 17:09:57 +0800 Subject: staging: rtl8723bs: Remove set but not used variable 'prwskeylen' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/core/rtw_security.c: In function rtw_tkip_encrypt: drivers/staging/rtl8723bs/core/rtw_security.c:660:6: warning: variable prwskeylen set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_security.c: In function rtw_tkip_decrypt: drivers/staging/rtl8723bs/core/rtw_security.c:768:6: warning: variable prwskeylen set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_security.c: In function rtw_aes_encrypt: drivers/staging/rtl8723bs/core/rtw_security.c:1528:6: warning: variable prwskeylen set but not used [-Wunused-but-set-variable] It is not used since commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1570352999-45790-4-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 5ffaf9bfa6e8..ed1d85499858 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -656,7 +656,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 hw_hdr_offset = 0; struct arc4context mycontext; sint curfragnum, length; - u32 prwskeylen; u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; @@ -703,8 +702,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) /* prwskey =&stainfo->dot118021x_UncstKey.skey[0]; */ prwskey = pattrib->dot118021x_UncstKey.skey; - prwskeylen = 16; - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { iv = pframe+pattrib->hdrlen; payload = pframe+pattrib->iv_len+pattrib->hdrlen; @@ -764,7 +761,6 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) u8 crc[4]; struct arc4context mycontext; sint length; - u32 prwskeylen; u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; @@ -819,10 +815,8 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) /* DBG_871X("rx bc/mc packets, to perform sw rtw_tkip_decrypt\n"); */ /* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */ prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; - prwskeylen = 16; } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; - prwskeylen = 16; } iv = pframe+prxattrib->hdrlen; @@ -1524,7 +1518,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* Intermediate Buffers */ sint curfragnum, length; - u32 prwskeylen; u8 *pframe, *prwskey; /* *payload,*iv */ u8 hw_hdr_offset = 0; /* struct sta_info *stainfo = NULL; */ @@ -1551,8 +1544,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* prwskey =&stainfo->dot118021x_UncstKey.skey[0]; */ prwskey = pattrib->dot118021x_UncstKey.skey; - prwskeylen = 16; - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; -- cgit v1.2.3-59-g8ed1b From 0fd1dc1ea477942fe1354fc49578dc3906dbd354 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Sun, 6 Oct 2019 17:09:58 +0800 Subject: staging: rtl8723bs: Remove set but not used variables 'ppp', 'type', 'data' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/core/rtw_recv.c: In function validate_80211w_mgmt: drivers/staging/rtl8723bs/core/rtw_recv.c:1415:8: warning: variable ppp set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_recv.c: In function validate_80211w_mgmt: drivers/staging/rtl8723bs/core/rtw_recv.c:1403:5: warning: variable type set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/core/rtw_recv.c: In function recvframe_defrag: drivers/staging/rtl8723bs/core/rtw_recv.c:1713:6: warning: variable data set but not used [-Wunused-but-set-variable] They are not used since commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1570352999-45790-5-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 687ff3c6f09f..7fa8c84cf5f4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -1400,10 +1400,8 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; u8 *ptr = precv_frame->u.hdr.rx_data; - u8 type; u8 subtype; - type = GetFrameType(ptr); subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */ /* only support station mode */ @@ -1412,9 +1410,8 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec /* unicast management frame decrypt */ if (pattrib->privacy && !(IS_MCAST(GetAddr1Ptr(ptr))) && (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || subtype == WIFI_ACTION)) { - u8 *ppp, *mgmt_DATA; + u8 *mgmt_DATA; u32 data_len = 0; - ppp = GetAddr2Ptr(ptr); pattrib->bdecrypted = 0; pattrib->encrypt = _AES_; @@ -1709,7 +1706,7 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) { struct list_head *plist, *phead; - u8 *data, wlanhdr_offset; + u8 wlanhdr_offset; u8 curfragnum; struct recv_frame_hdr *pfhdr, *pnfhdr; union recv_frame *prframe, *pnextrframe; @@ -1739,8 +1736,6 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, plist = get_next(plist); - data = get_recvframe_data(prframe); - while (phead != plist) { pnextrframe = (union recv_frame *)plist; pnfhdr = &pnextrframe->u.hdr; -- cgit v1.2.3-59-g8ed1b From f342e258085bde61696bd64505f7551829647934 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Sun, 6 Oct 2019 17:09:59 +0800 Subject: staging: rtl8723bs: Remove set but not used variable 'adapter' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/core/rtw_mlme.c: In function rtw_select_roaming_candidate: drivers/staging/rtl8723bs/core/rtw_mlme.c:2007:18: warning: variable adapter set but not used [-Wunused-but-set-variable] It is not used since commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1570352999-45790-6-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 4000125054c3..0ac7712223af 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1989,7 +1989,6 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) { int ret = _FAIL; struct list_head *phead; - struct adapter *adapter; struct __queue *queue = &(mlme->scanned_queue); struct wlan_network *pnetwork = NULL; struct wlan_network *candidate = NULL; @@ -2001,7 +2000,6 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) spin_lock_bh(&(mlme->scanned_queue.lock)); phead = get_list_head(queue); - adapter = (struct adapter *)mlme->nic_hdl; mlme->pscanned = get_next(phead); -- cgit v1.2.3-59-g8ed1b From d4fbce956db1207a1ad625db1f4e922c7b73808b Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 6 Oct 2019 14:46:21 +0530 Subject: staging: vc04_services: make use of devm_platform_ioremap_resource fix below issue reported by coccicheck drivers/staging//vc04_services/interface/vchiq_arm/vchiq_2835_arm.c:139 WARNING: Use devm_platform_ioremap_resource for g_regs Signed-off-by: Hariprasad Kelam Link: https://lore.kernel.org/r/1570353394-9991-1-git-send-email-hariprasad.kelam@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 8dc730cfe7a6..6559f0e50db1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -81,7 +81,6 @@ int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) struct vchiq_drvdata *drvdata = platform_get_drvdata(pdev); struct rpi_firmware *fw = drvdata->fw; struct vchiq_slot_zero *vchiq_slot_zero; - struct resource *res; void *slot_mem; dma_addr_t slot_phys; u32 channelbase; @@ -135,8 +134,7 @@ int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) if (vchiq_init_state(state, vchiq_slot_zero) != VCHIQ_SUCCESS) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - g_regs = devm_ioremap_resource(&pdev->dev, res); + g_regs = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(g_regs)) return PTR_ERR(g_regs); -- cgit v1.2.3-59-g8ed1b From e772cd8c9c9cd3d08715800aabaf50b771b395d9 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Sun, 6 Oct 2019 16:07:45 +0200 Subject: staging: wlan-ng: p80211wep.c: use lib/crc32 Use lib/crc32 instead of another implementation. Signed-off-by: Thomas Meyer Link: https://lore.kernel.org/r/20191006140745.9952-1-thomas@m3y3r.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211wep.c | 64 ++----------------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/p80211wep.c b/drivers/staging/wlan-ng/p80211wep.c index 8bd92bba0ac1..51d917c8cdc8 100644 --- a/drivers/staging/wlan-ng/p80211wep.c +++ b/drivers/staging/wlan-ng/p80211wep.c @@ -49,6 +49,7 @@ /*================================================================*/ /* System Includes */ +#include #include #include #include @@ -61,61 +62,6 @@ #define WEP_KEY(x) (((x) & 0xC0) >> 6) -static const u32 wep_crc32_table[256] = { - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL -}; - /* keylen in bytes! */ int wep_change_key(struct wlandevice *wlandev, int keynum, u8 *key, int keylen) @@ -184,7 +130,6 @@ int wep_decrypt(struct wlandevice *wlandev, u8 *buf, u32 len, int key_override, } /* Apply the RC4 to the data, update the CRC32 */ - crc = ~0; i = 0; j = 0; for (k = 0; k < len; k++) { @@ -192,9 +137,8 @@ int wep_decrypt(struct wlandevice *wlandev, u8 *buf, u32 len, int key_override, j = (j + s[i]) & 0xff; swap(i, j); buf[k] ^= s[(s[i] + s[j]) & 0xff]; - crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); } - crc = ~crc; + crc = ~crc32_le(~0, buf, len); /* now let's check the crc */ c_crc[0] = crc; @@ -257,17 +201,15 @@ int wep_encrypt(struct wlandevice *wlandev, u8 *buf, } /* Update CRC32 then apply RC4 to the data */ - crc = ~0; i = 0; j = 0; for (k = 0; k < len; k++) { - crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8); i = (i + 1) & 0xff; j = (j + s[i]) & 0xff; swap(i, j); dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff]; } - crc = ~crc; + crc = ~crc32_le(~0, buf, len); /* now let's encrypt the crc */ icv[0] = crc; -- cgit v1.2.3-59-g8ed1b From c54f9f0e8c81192b17e2ae2eb7af6a037fd250a5 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:42:58 +0000 Subject: staging: wfx: simplify memory allocation in wfx_update_filtering() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original code did not handle case where kmalloc failed. By the way, it is more convenient to allocate and build HIF message in hif_set_beacon_filter_table() instead of to ask to caller function to build it. Fixes: 40115bbc40e2 ("staging: wfx: implement the rest of mac80211 API") Reported-by: kbuild test robot Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-2-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_tx_mib.h | 21 +++++++++++++++------ drivers/staging/wfx/sta.c | 17 +++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index f6624a403016..167c5dec009f 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -86,13 +86,22 @@ static inline int hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid, } static inline int hif_set_beacon_filter_table(struct wfx_vif *wvif, - struct hif_mib_bcn_filter_table *ft) + int tbl_len, + struct hif_ie_table_entry *tbl) { - size_t buf_len = struct_size(ft, ie_table, ft->num_of_info_elmts); - - cpu_to_le32s(&ft->num_of_info_elmts); - return hif_write_mib(wvif->wdev, wvif->id, - HIF_MIB_ID_BEACON_FILTER_TABLE, ft, buf_len); + int ret; + struct hif_mib_bcn_filter_table *val; + int buf_len = struct_size(val, ie_table, tbl_len); + + val = kzalloc(buf_len, GFP_KERNEL); + if (!val) + return -ENOMEM; + val->num_of_info_elmts = cpu_to_le32(tbl_len); + memcpy(val->ie_table, tbl, tbl_len * sizeof(*tbl)); + ret = hif_write_mib(wvif->wdev, wvif->id, + HIF_MIB_ID_BEACON_FILTER_TABLE, val, buf_len); + kfree(val); + return ret; } static inline int hif_beacon_filter_control(struct wfx_vif *wvif, diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 2855d14a709c..12198b8f3685 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -217,14 +217,13 @@ void wfx_update_filtering(struct wfx_vif *wvif) bool filter_bssid = wvif->filter_bssid; bool fwd_probe_req = wvif->fwd_probe_req; struct hif_mib_bcn_filter_enable bf_ctrl; - struct hif_mib_bcn_filter_table *bf_tbl; - struct hif_ie_table_entry ie_tbl[] = { + struct hif_ie_table_entry filter_ies[] = { { .ie_id = WLAN_EID_VENDOR_SPECIFIC, .has_changed = 1, .no_longer = 1, .has_appeared = 1, - .oui = { 0x50, 0x6F, 0x9A}, + .oui = { 0x50, 0x6F, 0x9A }, }, { .ie_id = WLAN_EID_HT_OPERATION, .has_changed = 1, @@ -237,36 +236,34 @@ void wfx_update_filtering(struct wfx_vif *wvif) .has_appeared = 1, } }; + int n_filter_ies; if (wvif->state == WFX_STATE_PASSIVE) return; - bf_tbl = kmalloc(sizeof(struct hif_mib_bcn_filter_table) + sizeof(ie_tbl), GFP_KERNEL); - memcpy(bf_tbl->ie_table, ie_tbl, sizeof(ie_tbl)); if (wvif->disable_beacon_filter) { bf_ctrl.enable = 0; bf_ctrl.bcn_count = 1; - bf_tbl->num_of_info_elmts = 0; + n_filter_ies = 0; } else if (!is_sta) { bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE | HIF_BEACON_FILTER_AUTO_ERP; bf_ctrl.bcn_count = 0; - bf_tbl->num_of_info_elmts = 2; + n_filter_ies = 2; } else { bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE; bf_ctrl.bcn_count = 0; - bf_tbl->num_of_info_elmts = 3; + n_filter_ies = 3; } ret = hif_set_rx_filter(wvif, filter_bssid, fwd_probe_req); if (!ret) - ret = hif_set_beacon_filter_table(wvif, bf_tbl); + ret = hif_set_beacon_filter_table(wvif, n_filter_ies, filter_ies); if (!ret) ret = hif_beacon_filter_control(wvif, bf_ctrl.enable, bf_ctrl.bcn_count); if (!ret) ret = wfx_set_mcast_filter(wvif, &wvif->mcast_filter); if (ret) dev_err(wvif->wdev->dev, "update filtering failed: %d\n", ret); - kfree(bf_tbl); } void wfx_update_filtering_work(struct work_struct *work) -- cgit v1.2.3-59-g8ed1b From 488d349061fa0ae61d5a50118e7d9cf2d28f03b5 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:42:59 +0000 Subject: staging: wfx: remove misused call to cpu_to_le16() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Indeed, hif_msg->id is a uint8_t, so use of cpu_to_le16() is a madness. Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Reported-by: kbuild test robot Reported-by: Stephen Rothwell Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-3-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 7f2799fbdafe..1891bcaaf9fc 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -620,7 +620,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct memset(skb->data, 0, wmsg_len); hif_msg = (struct hif_msg *) skb->data; hif_msg->len = cpu_to_le16(skb->len); - hif_msg->id = cpu_to_le16(HIF_REQ_ID_TX); + hif_msg->id = HIF_REQ_ID_TX; hif_msg->interface = wvif->id; if (skb->len > wvif->wdev->hw_caps.size_inp_ch_buf) { dev_warn(wvif->wdev->dev, "requested frame size (%d) is larger than maximum supported (%d)\n", -- cgit v1.2.3-59-g8ed1b From 6d68ac8b5b5c27013a8223766cd8d397229c7802 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:42:59 +0000 Subject: staging: wfx: le16_to_cpus() takes a reference as parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original code caused an (100% reproducible) invalid memory access on big-endian targets. Fixes: b0998f0c040d "staging: wfx: add IRQ handling" Reported-by: kbuild test robot Reported-by: Stephen Rothwell Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-4-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 6000c03bb658..3715bb18bd78 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -83,12 +83,12 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) // piggyback is probably correct. return piggyback; } - le16_to_cpus(hif->len); + le16_to_cpus(&hif->len); computed_len = round_up(hif->len - sizeof(hif->len), 16) + sizeof(struct hif_sl_msg) + sizeof(struct hif_sl_tag); } else { - le16_to_cpus(hif->len); + le16_to_cpus(&hif->len); computed_len = round_up(hif->len, 2); } if (computed_len != read_len) { -- cgit v1.2.3-59-g8ed1b From 53707c85d2c1ffe844266368cb7c7db137161881 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:43:00 +0000 Subject: staging: wfx: correctly cast data on big-endian targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When built for a big-endian target, original code caused error: include/uapi/linux/swab.h:242:29: note: expected '__u32 * {aka unsigned int *}' but argument is of type 'struct hif_mib_protected_mgmt_policy *' Fixes: f95a29d40782 ("staging: wfx: add HIF commands helpers") Reported-by: kbuild test robot Reported-by: Stephen Rothwell Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-5-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_tx_mib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index 167c5dec009f..4f132348f5fa 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -145,7 +145,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) } if (!required) val.unpmf_allowed = 1; - cpu_to_le32s(&val); + cpu_to_le32s((uint32_t *) &val); return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_PROTECTED_MGMT_POLICY, &val, sizeof(val)); -- cgit v1.2.3-59-g8ed1b From 51f589c82f6d4b3c9e417b39141836fb3db86093 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:43:00 +0000 Subject: staging: wfx: fix copy_{to,from}_user() usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On error, copy_to_user() returns number of bytes remaining. Driver should return -EFAULT. Fixes: 4f8b7fabb15d ("staging: wfx: allow to send commands to chip") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 3261b267c385..8de16ad7c710 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -256,9 +256,8 @@ static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf, return context->ret; // Be carefull, write() is waiting for a full message while read() // only return a payload - ret = copy_to_user(user_buf, context->reply, count); - if (ret) - return ret; + if (copy_to_user(user_buf, context->reply, count)) + return -EFAULT; return count; } -- cgit v1.2.3-59-g8ed1b From b5be2aa3b3ac153f056f93406c520dc74a1cebbe Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:43:01 +0000 Subject: staging: wfx: drop calls to BUG_ON() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most of calls to BUG_ON() could replaced by WARN(). By the way, this patch also try to favor WARN() (that include a comment about the problem) instead of WARN_ON(). Reported-by: Andrew Lunn Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-7-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 4 ++-- drivers/staging/wfx/bus_sdio.c | 4 ++-- drivers/staging/wfx/data_tx.c | 4 ++-- drivers/staging/wfx/hif_tx_mib.h | 2 +- drivers/staging/wfx/key.c | 32 ++++++++++++++++---------------- drivers/staging/wfx/queue.c | 6 +++--- drivers/staging/wfx/scan.c | 2 +- drivers/staging/wfx/sta.c | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 3715bb18bd78..3355183fc86c 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -56,7 +56,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) int release_count; int piggyback = 0; - WARN_ON(read_len < 4); + WARN(read_len < 4, "corrupted read"); WARN(read_len > round_down(0xFFF, 2) * sizeof(u16), "%s: request exceed WFx capability", __func__); @@ -173,7 +173,7 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) bool is_encrypted = false; size_t len = le16_to_cpu(hif->len); - BUG_ON(len < sizeof(*hif)); + WARN(len < sizeof(*hif), "try to send corrupted data"); hif->seqnum = wdev->hif.tx_seqnum; wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1); diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 05f02c278782..f97360513150 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -37,7 +37,7 @@ static int wfx_sdio_copy_from_io(void *priv, unsigned int reg_id, unsigned int sdio_addr = reg_id << 2; int ret; - BUG_ON(reg_id > 7); + WARN(reg_id > 7, "chip only has 7 registers"); WARN(((uintptr_t) dst) & 3, "unaligned buffer size"); WARN(count & 3, "unaligned buffer address"); @@ -58,7 +58,7 @@ static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id, unsigned int sdio_addr = reg_id << 2; int ret; - BUG_ON(reg_id > 7); + WARN(reg_id > 7, "chip only has 7 registers"); WARN(((uintptr_t) src) & 3, "unaligned buffer size"); WARN(count & 3, "unaligned buffer address"); diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 1891bcaaf9fc..b2ca3986c6d0 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -44,7 +44,7 @@ static void tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, size_t count; struct wfx_dev *wdev = wvif->wdev; - BUG_ON(rates[0].idx < 0); + WARN(rates[0].idx < 0, "invalid rate policy"); memset(policy, 0, sizeof(*policy)); for (i = 1; i < IEEE80211_TX_MAX_RATES; i++) if (rates[i].idx < 0) @@ -162,7 +162,7 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, tx_policy_build(wvif, &wanted, rates); spin_lock_bh(&cache->lock); - if (WARN_ON_ONCE(list_empty(&cache->free))) { + if (WARN_ON(list_empty(&cache->free))) { spin_unlock_bh(&cache->lock); return WFX_INVALID_RATE_ID; } diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index 4f132348f5fa..3339ad95f732 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -138,7 +138,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) { struct hif_mib_protected_mgmt_policy val = { }; - WARN_ON(required && !capable); + WARN(required && !capable, "incoherent arguments"); if (capable) { val.pmf_enable = 1; val.host_enc_auth_frames = 1; diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c index 4e7d2b510a9c..6d03abec20e4 100644 --- a/drivers/staging/wfx/key.c +++ b/drivers/staging/wfx/key.c @@ -26,7 +26,7 @@ static int wfx_alloc_key(struct wfx_dev *wdev) static void wfx_free_key(struct wfx_dev *wdev, int idx) { - BUG_ON(!(wdev->key_map & BIT(idx))); + WARN(!(wdev->key_map & BIT(idx)), "inconsistent key allocation"); memset(&wdev->keys[idx], 0, sizeof(wdev->keys[idx])); wdev->key_map &= ~BIT(idx); } @@ -34,7 +34,7 @@ static void wfx_free_key(struct wfx_dev *wdev, int idx) static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { - WARN_ON(key->keylen > sizeof(msg->key_data)); + WARN(key->keylen > sizeof(msg->key_data), "inconsistent data"); msg->key_length = key->keylen; memcpy(msg->key_data, key->key, key->keylen); ether_addr_copy(msg->peer_address, peer_addr); @@ -44,7 +44,7 @@ static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, static uint8_t fill_wep_group(struct hif_wep_group_key *msg, struct ieee80211_key_conf *key) { - WARN_ON(key->keylen > sizeof(msg->key_data)); + WARN(key->keylen > sizeof(msg->key_data), "inconsistent data"); msg->key_id = key->keyidx; msg->key_length = key->keylen; memcpy(msg->key_data, key->key, key->keylen); @@ -56,9 +56,9 @@ static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->tkip_key_data) - + sizeof(msg->tx_mic_key) - + sizeof(msg->rx_mic_key)); + WARN(key->keylen != sizeof(msg->tkip_key_data) + + sizeof(msg->tx_mic_key) + + sizeof(msg->rx_mic_key), "inconsistent data"); memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data)); keybuf += sizeof(msg->tkip_key_data); memcpy(msg->tx_mic_key, keybuf, sizeof(msg->tx_mic_key)); @@ -75,8 +75,8 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->tkip_key_data) - + 2 * sizeof(msg->rx_mic_key)); + WARN(key->keylen != sizeof(msg->tkip_key_data) + + 2 * sizeof(msg->rx_mic_key), "inconsistent data"); msg->key_id = key->keyidx; memcpy(msg->rx_sequence_counter, &seq->tkip.iv16, sizeof(seq->tkip.iv16)); memcpy(msg->rx_sequence_counter + sizeof(uint16_t), &seq->tkip.iv32, sizeof(seq->tkip.iv32)); @@ -94,7 +94,7 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, static uint8_t fill_ccmp_pair(struct hif_aes_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { - WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + WARN(key->keylen != sizeof(msg->aes_key_data), "inconsistent data"); ether_addr_copy(msg->peer_address, peer_addr); memcpy(msg->aes_key_data, key->key, key->keylen); return HIF_KEY_TYPE_AES_PAIRWISE; @@ -104,7 +104,7 @@ static uint8_t fill_ccmp_group(struct hif_aes_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { - WARN_ON(key->keylen != sizeof(msg->aes_key_data)); + WARN(key->keylen != sizeof(msg->aes_key_data), "inconsistent data"); memcpy(msg->aes_key_data, key->key, key->keylen); memcpy(msg->rx_sequence_counter, seq->ccmp.pn, sizeof(seq->ccmp.pn)); memreverse(msg->rx_sequence_counter, sizeof(seq->ccmp.pn)); @@ -117,8 +117,8 @@ static uint8_t fill_sms4_pair(struct hif_wapi_pairwise_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->wapi_key_data) - + sizeof(msg->mic_key_data)); + WARN(key->keylen != sizeof(msg->wapi_key_data) + + sizeof(msg->mic_key_data), "inconsistent data"); ether_addr_copy(msg->peer_address, peer_addr); memcpy(msg->wapi_key_data, keybuf, sizeof(msg->wapi_key_data)); keybuf += sizeof(msg->wapi_key_data); @@ -132,8 +132,8 @@ static uint8_t fill_sms4_group(struct hif_wapi_group_key *msg, { uint8_t *keybuf = key->key; - WARN_ON(key->keylen != sizeof(msg->wapi_key_data) - + sizeof(msg->mic_key_data)); + WARN(key->keylen != sizeof(msg->wapi_key_data) + + sizeof(msg->mic_key_data), "inconsistent data"); memcpy(msg->wapi_key_data, keybuf, sizeof(msg->wapi_key_data)); keybuf += sizeof(msg->wapi_key_data); memcpy(msg->mic_key_data, keybuf, sizeof(msg->mic_key_data)); @@ -145,7 +145,7 @@ static uint8_t fill_aes_cmac_group(struct hif_igtk_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { - WARN_ON(key->keylen != sizeof(msg->igtk_key_data)); + WARN(key->keylen != sizeof(msg->igtk_key_data), "inconsistent data"); memcpy(msg->igtk_key_data, key->key, key->keylen); memcpy(msg->ipn, seq->aes_cmac.pn, sizeof(seq->aes_cmac.pn)); memreverse(msg->ipn, sizeof(seq->aes_cmac.pn)); @@ -163,7 +163,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta, int idx = wfx_alloc_key(wvif->wdev); bool pairwise = key->flags & IEEE80211_KEY_FLAG_PAIRWISE; - WARN_ON(key->flags & IEEE80211_KEY_FLAG_PAIRWISE && !sta); + WARN(key->flags & IEEE80211_KEY_FLAG_PAIRWISE && !sta, "inconsistent data"); ieee80211_get_key_rx_seq(key, 0, &seq); if (idx < 0) return -EINVAL; diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 6f1be4f6f463..ee9b2c3fde5a 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -78,7 +78,7 @@ void wfx_tx_queues_unlock(struct wfx_dev *wdev) for (i = 0; i < IEEE80211_NUM_ACS; ++i) { queue = &wdev->tx_queue[i]; spin_lock_bh(&queue->queue.lock); - BUG_ON(!queue->tx_locked_cnt); + WARN(!queue->tx_locked_cnt, "queue already unlocked"); if (--queue->tx_locked_cnt == 0) ieee80211_wake_queue(wdev->hw, queue->queue_id); spin_unlock_bh(&queue->queue.lock); @@ -295,8 +295,8 @@ struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id) return skb; } } - WARN_ON(1); spin_unlock_bh(&stats->pending.lock); + WARN(1, "cannot find packet in pending queue"); return NULL; } @@ -408,7 +408,7 @@ static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb, switch (action) { case do_drop: - BUG_ON(wfx_pending_remove(wvif->wdev, skb)); + wfx_pending_remove(wvif->wdev, skb); handled = true; break; case do_wep: diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index ea5001c915f6..cba735c1e73c 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -107,7 +107,7 @@ int wfx_hw_scan(struct ieee80211_hw *hw, wfx_tx_lock_flush(wdev); - BUG_ON(wvif->scan.req); + WARN(wvif->scan.req, "unexpected concurrent scan"); wvif->scan.req = req; wvif->scan.n_ssids = 0; wvif->scan.status = 0; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 12198b8f3685..733b93a8f830 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -1454,6 +1454,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) }, }; + BUILD_BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); if (wfx_api_older_than(wdev, 2, 0)) { default_edca_params[IEEE80211_AC_BE].queue_id = HIF_QUEUE_ID_BACKGROUND; default_edca_params[IEEE80211_AC_BK].queue_id = HIF_QUEUE_ID_BESTEFFORT; @@ -1526,7 +1527,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mutex_unlock(&wdev->conf_mutex); hif_set_macaddr(wvif, vif->addr); - BUG_ON(ARRAY_SIZE(default_edca_params) != ARRAY_SIZE(wvif->edca.params)); for (i = 0; i < IEEE80211_NUM_ACS; i++) { memcpy(&wvif->edca.params[i], &default_edca_params[i], sizeof(default_edca_params[i])); wvif->edca.uapsd_enable[i] = false; -- cgit v1.2.3-59-g8ed1b From fcd6c0f9a12369ae6d500d747e668ed98ef5edd6 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:43:01 +0000 Subject: staging: wfx: avoid namespace contamination MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tx_policy_init() was already defined in driver cw1200. So, compilation failed when wfx and cw1200 were both built-in. In order to keep a coherent naming scheme, this patch prefixes all "tx_policy_*" functions with "wfx_". Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Reported-by: kbuild test robot Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-8-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 34 +++++++++++++++++----------------- drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/sta.c | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index b2ca3986c6d0..6e4dd4ac5544 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -37,7 +37,7 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate /* TX policy cache implementation */ -static void tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, +static void wfx_tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, struct ieee80211_tx_rate *rates) { int i; @@ -124,7 +124,7 @@ static bool tx_policy_is_equal(const struct tx_policy *a, const struct tx_policy return !memcmp(a->rates, b->rates, sizeof(a->rates)); } -static int tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *wanted) +static int wfx_tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *wanted) { struct tx_policy *it; @@ -137,13 +137,13 @@ static int tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *wante return -1; } -static void tx_policy_use(struct tx_policy_cache *cache, struct tx_policy *entry) +static void wfx_tx_policy_use(struct tx_policy_cache *cache, struct tx_policy *entry) { ++entry->usage_count; list_move(&entry->link, &cache->used); } -static int tx_policy_release(struct tx_policy_cache *cache, struct tx_policy *entry) +static int wfx_tx_policy_release(struct tx_policy_cache *cache, struct tx_policy *entry) { int ret = --entry->usage_count; @@ -152,21 +152,21 @@ static int tx_policy_release(struct tx_policy_cache *cache, struct tx_policy *en return ret; } -static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, +static int wfx_tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, bool *renew) { int idx; struct tx_policy_cache *cache = &wvif->tx_policy_cache; struct tx_policy wanted; - tx_policy_build(wvif, &wanted, rates); + wfx_tx_policy_build(wvif, &wanted, rates); spin_lock_bh(&cache->lock); if (WARN_ON(list_empty(&cache->free))) { spin_unlock_bh(&cache->lock); return WFX_INVALID_RATE_ID; } - idx = tx_policy_find(cache, &wanted); + idx = wfx_tx_policy_find(cache, &wanted); if (idx >= 0) { *renew = false; } else { @@ -181,7 +181,7 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, entry->usage_count = 0; idx = entry - cache->cache; } - tx_policy_use(cache, &cache->cache[idx]); + wfx_tx_policy_use(cache, &cache->cache[idx]); if (list_empty(&cache->free)) { /* Lock TX queues. */ wfx_tx_queues_lock(wvif->wdev); @@ -190,14 +190,14 @@ static int tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, return idx; } -static void tx_policy_put(struct wfx_vif *wvif, int idx) +static void wfx_tx_policy_put(struct wfx_vif *wvif, int idx) { int usage, locked; struct tx_policy_cache *cache = &wvif->tx_policy_cache; spin_lock_bh(&cache->lock); locked = list_empty(&cache->free); - usage = tx_policy_release(cache, &cache->cache[idx]); + usage = wfx_tx_policy_release(cache, &cache->cache[idx]); if (locked && !usage) { /* Unlock TX queues. */ wfx_tx_queues_unlock(wvif->wdev); @@ -205,7 +205,7 @@ static void tx_policy_put(struct wfx_vif *wvif, int idx) spin_unlock_bh(&cache->lock); } -static int tx_policy_upload(struct wfx_vif *wvif) +static int wfx_tx_policy_upload(struct wfx_vif *wvif) { int i; struct tx_policy_cache *cache = &wvif->tx_policy_cache; @@ -238,18 +238,18 @@ static int tx_policy_upload(struct wfx_vif *wvif) return 0; } -static void tx_policy_upload_work(struct work_struct *work) +static void wfx_tx_policy_upload_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, tx_policy_upload_work); - tx_policy_upload(wvif); + wfx_tx_policy_upload(wvif); wfx_tx_unlock(wvif->wdev); wfx_tx_queues_unlock(wvif->wdev); } -void tx_policy_init(struct wfx_vif *wvif) +void wfx_tx_policy_init(struct wfx_vif *wvif) { struct tx_policy_cache *cache = &wvif->tx_policy_cache; int i; @@ -259,7 +259,7 @@ void tx_policy_init(struct wfx_vif *wvif) spin_lock_init(&cache->lock); INIT_LIST_HEAD(&cache->used); INIT_LIST_HEAD(&cache->free); - INIT_WORK(&wvif->tx_policy_upload_work, tx_policy_upload_work); + INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work); for (i = 0; i < HIF_MIB_NUM_TX_RATE_RETRY_POLICIES; ++i) list_add(&cache->cache[i].link, &cache->free); @@ -527,7 +527,7 @@ static uint8_t wfx_tx_get_rate_id(struct wfx_vif *wvif, struct ieee80211_tx_info bool tx_policy_renew = false; uint8_t rate_id; - rate_id = tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); + rate_id = wfx_tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); WARN(rate_id == WFX_INVALID_RATE_ID, "unable to get a valid Tx policy"); if (tx_policy_renew) { @@ -794,6 +794,6 @@ void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb) WARN_ON(!wvif); skb_pull(skb, offset); wfx_notify_buffered_tx(wvif, skb, req); - tx_policy_put(wvif, req->tx_flags.retry_policy_index); + wfx_tx_policy_put(wvif, req->tx_flags.retry_policy_index); ieee80211_tx_status_irqsafe(wdev->hw, skb); } diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index f59a259bb744..0a19ef10a4ab 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -60,7 +60,7 @@ struct wfx_tx_priv { uint8_t tid; } __packed; -void tx_policy_init(struct wfx_vif *wvif); +void wfx_tx_policy_init(struct wfx_vif *wvif); void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 733b93a8f830..3c715cc88ab2 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -1534,7 +1534,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) } wfx_set_uapsd_param(wvif, &wvif->edca); - tx_policy_init(wvif); + wfx_tx_policy_init(wvif); wvif = NULL; while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { // Combo mode does not support Block Acks. We can re-enable them -- cgit v1.2.3-59-g8ed1b From 81aa377559f74f39b87423e64e475714484f2c44 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 8 Oct 2019 09:22:05 +0100 Subject: staging: wfx: fix spelling mistake "hexdecimal" -> "hexadecimal" There is a spelling mistake in the documentation and a module parameter description. Fix these. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20191008082205.19740-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- .../wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt | 2 +- drivers/staging/wfx/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt b/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt index 15965c9b4180..26de6762b942 100644 --- a/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt +++ b/drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/siliabs,wfx.txt @@ -89,7 +89,7 @@ Some properties are recognized either by SPI and SDIO versions: this property, driver will disable most of power saving features. - config-file: Use an alternative file as PDS. Default is `wf200.pds`. Only necessary for development/debug purpose. - - slk_key: String representing hexdecimal value of secure link key to use. + - slk_key: String representing hexadecimal value of secure link key to use. Must contains 64 hexadecimal digits. Not supported in current version. WFx driver also supports `mac-address` and `local-mac-address` as described in diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index fe9a89703897..d2508bc950fa 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -48,7 +48,7 @@ MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); static char *slk_key; module_param(slk_key, charp, 0600); -MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexdecimal digits)."); +MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexadecimal digits)."); #define RATETAB_ENT(_rate, _rateid, _flags) { \ .bitrate = (_rate), \ -- cgit v1.2.3-59-g8ed1b From d53c90c5d474434cdeb1518b815659fc622907ff Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Tue, 8 Oct 2019 07:09:43 +0300 Subject: staging: octeon: Remove typedef declaration Fixes checkpatch.pl warning: do not add new typedefs in drivers/staging/octeon/octeon-stubs.h:41 Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191008040943.9283-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index a4ac3bfb62a8..773591348ef4 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -38,7 +38,7 @@ #define CVMX_NPI_RSL_INT_BLOCKS 0 #define CVMX_POW_WQ_INT_PC 0 -typedef union { +union cvmx_pip_wqe_word2 { uint64_t u64; struct { uint64_t bufs:8; @@ -114,7 +114,7 @@ typedef union { uint64_t err_code:8; } snoip; -} cvmx_pip_wqe_word2; +}; union cvmx_pip_wqe_word0 { struct { @@ -183,7 +183,7 @@ union cvmx_buf_ptr { typedef struct { union cvmx_wqe_word0 word0; union cvmx_wqe_word1 word1; - cvmx_pip_wqe_word2 word2; + union cvmx_pip_wqe_word2 word2; union cvmx_buf_ptr packet_ptr; uint8_t packet_data[96]; } cvmx_wqe_t; -- cgit v1.2.3-59-g8ed1b From f806c4d55721742087073147feaa665b45088852 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Mon, 7 Oct 2019 17:43:03 +0200 Subject: staging: rtl8723bs: fix typo of "mechanism" in comment Fix typo s/mechansim/mechanism/ Signed-off-by: Antonio Borneo Link: https://lore.kernel.org/r/20191007154306.95827-2-antonio.borneo@st.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 6e4a1fcb8790..d5793e4614bf 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -1315,7 +1315,7 @@ void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist) /* * Description: - *Run BT-Coexist mechansim or not + *Run BT-Coexist mechanism or not * */ void hal_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist) -- cgit v1.2.3-59-g8ed1b From c67855589ca0bfb86924dc0c1a2592a38c95798b Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Mon, 7 Oct 2019 21:52:23 -0500 Subject: staging: rtl8723bs: Remove commented code Remove commented code for a cleaner file. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/20191008025221.q4j4igctqjowur2s@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 6190ef08236a..43d663c8486d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2690,14 +2690,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; -/* - spin_unlock_bh(&psta->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe) == true) - { - rtw_os_xmit_complete(padapter, pxmitframe); - } - spin_lock_bh(&psta->sleep_q.lock); -*/ rtw_hal_xmitframe_enqueue(padapter, pxmitframe); -- cgit v1.2.3-59-g8ed1b From a30b30f00462b5bc685a39f46a7a9623ea45bdab Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Mon, 7 Oct 2019 22:09:13 -0700 Subject: staging: rtl8723bs: os_dep: Remove typecast in kfree Remove typecast in the call to kfree as it is not needed. Issue found using the below coccinelle script, @@ type t1; expression e; @@ -kfree((t1 *)e); +kfree(e); Signed-off-by: Nachammai Karuppiah Acked-by: Julia Lawall Link: https://lore.kernel.org/r/1570511353-64646-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 10 +++++----- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 67d56f3c0717..8555f52ceb7c 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -165,7 +165,7 @@ static void rtw_spt_band_free(struct ieee80211_supported_band *spt_band) + sizeof(struct ieee80211_channel)*RTW_2G_CHANNELS_NUM + sizeof(struct ieee80211_rate)*RTW_G_RATES_NUM; } - kfree((u8 *)spt_band); + kfree(spt_band); } static const struct ieee80211_txrx_stypes @@ -1156,7 +1156,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, } addkey_end: - kfree((u8 *)param); + kfree(param); return ret; @@ -2193,7 +2193,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, ret = -EOPNOTSUPP ; } - kfree((u8 *)pwep); + kfree(pwep); if (ret < 0) goto exit; @@ -2646,7 +2646,7 @@ static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, st out: if (ret && mon_wdev) { - kfree((u8 *)mon_wdev); + kfree(mon_wdev); mon_wdev = NULL; } @@ -3502,7 +3502,7 @@ void rtw_wdev_free(struct wireless_dev *wdev) wiphy_free(wdev->wiphy); - kfree((u8 *)wdev); + kfree(wdev); } void rtw_wdev_unregister(struct wireless_dev *wdev) diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index ec3a75485233..5044f7373b8b 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -1142,7 +1142,7 @@ void rtw_ndev_destructor(struct net_device *ndev) DBG_871X(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); if (ndev->ieee80211_ptr) - kfree((u8 *)ndev->ieee80211_ptr); + kfree(ndev->ieee80211_ptr); } void rtw_dev_unload(struct adapter *padapter) -- cgit v1.2.3-59-g8ed1b From 17a29fea086ba18b000d28439bd5cb4f2b0a527b Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Mon, 7 Oct 2019 23:18:06 +0000 Subject: staging/octeon: Use stubs for MIPS && !CAVIUM_OCTEON_SOC When building for a non-Cavium MIPS system with COMPILE_TEST=y, the Octeon ethernet driver hits a number of issues due to use of macros provided only for CONFIG_CAVIUM_OCTEON_SOC=y configurations. For example: drivers/staging/octeon/ethernet-rx.c:190:6: error: 'CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE' undeclared (first use in this function) drivers/staging/octeon/ethernet-rx.c:472:25: error: 'OCTEON_IRQ_WORKQ0' undeclared (first use in this function) These come from various asm/ headers that a non-Octeon build will be using a non-Octeon version of. Fix this by using the octeon-stubs.h header for non-Cavium MIPS builds, and only using the real asm/octeon/ headers when building a Cavium Octeon kernel configuration. This requires that octeon-stubs.h doesn't redefine XKPHYS_TO_PHYS, which is defined for MIPS by asm/addrspace.h which is pulled in by many other common asm/ headers. Signed-off-by: Paul Burton Reported-by: Geert Uytterhoeven URL: https://lore.kernel.org/linux-mips/CAMuHMdXvu+BppwzsU9imNWVKea_hoLcRt9N+a29Q-QsjW=ip2g@mail.gmail.com/ Fixes: 171a9bae68c7 ("staging/octeon: Allow test build on !MIPS") Cc: Matthew Wilcox (Oracle) Cc: David S. Miller Link: https://lore.kernel.org/r/20191007231741.2012860-1-paul.burton@mips.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-ethernet.h | 2 +- drivers/staging/octeon/octeon-stubs.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index a8a864b40913..042220d86d33 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -14,7 +14,7 @@ #include #include -#ifdef CONFIG_MIPS +#ifdef CONFIG_CAVIUM_OCTEON_SOC #include diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index 773591348ef4..38954b6c89e1 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -1,5 +1,8 @@ #define CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE 512 -#define XKPHYS_TO_PHYS(p) (p) + +#ifndef XKPHYS_TO_PHYS +# define XKPHYS_TO_PHYS(p) (p) +#endif #define OCTEON_IRQ_WORKQ0 0 #define OCTEON_IRQ_RML 0 -- cgit v1.2.3-59-g8ed1b From 5193dbdaf0b07a46b6659c7a38c80c947f7ab732 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Tue, 8 Oct 2019 15:41:50 +0800 Subject: staging: bcm2835-audio: Need to judge the return value of vchi_msg_dequeue in audio_vchi_callback If vchi_msg_dequeue return -1, variable m is not assigined, need to return. Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/1570520515-2186-2-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 23fba01107b9..6780b3ff4fbb 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -103,6 +103,9 @@ static void audio_vchi_callback(void *param, status = vchi_msg_dequeue(instance->vchi_handle, &m, sizeof(m), &msg_len, VCHI_FLAGS_NONE); + if (status) + return; + if (m.type == VC_AUDIO_MSG_TYPE_RESULT) { instance->result = m.result.success; complete(&instance->msg_avail_comp); -- cgit v1.2.3-59-g8ed1b From 66bc9cde241ef69031e90a9971e91c634521e94e Mon Sep 17 00:00:00 2001 From: zhengbin Date: Tue, 8 Oct 2019 15:41:51 +0800 Subject: staging: sm750fb: Remove set but not used variable 'uiActualPixelClk' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/sm750fb/ddk750_mode.c: In function ddk750_setModeTiming: drivers/staging/sm750fb/ddk750_mode.c:212:15: warning: variable uiActualPixelClk set but not used [-Wunused-but-set-variable] It is not used since commit 81dee67e215b ("staging: sm750fb: add sm750 to staging") Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/1570520515-2186-3-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_mode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index 9722692125d7..e0230f4ffc8b 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -209,12 +209,11 @@ static int programModeRegisters(struct mode_parameter *pModeParam, int ddk750_setModeTiming(struct mode_parameter *parm, enum clock_type clock) { struct pll_value pll; - unsigned int uiActualPixelClk; pll.input_freq = DEFAULT_INPUT_CLOCK; pll.clock_type = clock; - uiActualPixelClk = sm750_calc_pll_value(parm->pixel_clock, &pll); + sm750_calc_pll_value(parm->pixel_clock, &pll); if (sm750_get_chip_type() == SM750LE) { /* set graphic mode via IO method */ outb_p(0x88, 0x3d4); -- cgit v1.2.3-59-g8ed1b From 3740b6351509d19d44ba39e47f6a76aa68799586 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Tue, 8 Oct 2019 15:41:52 +0800 Subject: staging: sm750fb: Remove set but not used variable 'actual_mx_clk' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/sm750fb/ddk750_chip.c: In function set_chip_clock: drivers/staging/sm750fb/ddk750_chip.c:59:15: warning: variable actual_mx_clk set but not used [-Wunused-but-set-variable] It is not used since commit f0977109a577 ("staging: sm750fb: lower case to fix camelcase checkpatch warning") Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/1570520515-2186-4-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_chip.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c index e598881308d7..02860d3ec365 100644 --- a/drivers/staging/sm750fb/ddk750_chip.c +++ b/drivers/staging/sm750fb/ddk750_chip.c @@ -56,7 +56,6 @@ static unsigned int get_mxclk_freq(void) static void set_chip_clock(unsigned int frequency) { struct pll_value pll; - unsigned int actual_mx_clk; /* Cheok_0509: For SM750LE, the chip clock is fixed. Nothing to set. */ if (sm750_get_chip_type() == SM750LE) @@ -76,7 +75,7 @@ static void set_chip_clock(unsigned int frequency) * Return value of sm750_calc_pll_value gives the actual * possible clock. */ - actual_mx_clk = sm750_calc_pll_value(frequency, &pll); + sm750_calc_pll_value(frequency, &pll); /* Master Clock Control: MXCLK_PLL */ poke32(MXCLK_PLL_CTRL, sm750_format_pll_reg(&pll)); -- cgit v1.2.3-59-g8ed1b From 82d20bc5083d259b5dd799aa699abee270c4a358 Mon Sep 17 00:00:00 2001 From: Matteo Croce Date: Tue, 8 Oct 2019 14:33:46 +0200 Subject: staging: vchiq: don't print pointless kernel address Since commit ad67b74d2469d9b8 ("printk: hash addresses printed with %p"), an obfuscated kernel pointer is printed at boot: vchiq: vchiq_init_state: slot_zero = (____ptrval____) Remove the the print completely, as it's useless without the address. Signed-off-by: Matteo Croce Link: https://lore.kernel.org/r/20191008123346.3931-1-mcroce@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index b0e0653ffc23..663cc0f090cd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2132,9 +2132,6 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) char threadname[16]; int i; - vchiq_log_warning(vchiq_core_log_level, - "%s: slot_zero = %pK", __func__, slot_zero); - if (vchiq_states[0]) { pr_err("%s: VCHIQ state already initialized\n", __func__); return VCHIQ_ERROR; -- cgit v1.2.3-59-g8ed1b From d49d1c76b96ebf39539e93d5ab7943a01ef70e4f Mon Sep 17 00:00:00 2001 From: zhengbin Date: Tue, 8 Oct 2019 15:41:55 +0800 Subject: staging: comedi: Remove set but not used variable 'aref' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/comedi/drivers/dt3000.c: In function dt3k_ai_insn_read: drivers/staging/comedi/drivers/dt3000.c:511:27: warning: variable aref set but not used [-Wunused-but-set-variable] It is not used since commit 2e310235ca8f ("staging: comedi: dt3000: rename dt3k_ai_insn()") Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Dan Carpenter Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/1570520515-2186-7-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt3000.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index caf4d4df4bd3..f7c365b70106 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -508,12 +508,11 @@ static int dt3k_ai_insn_read(struct comedi_device *dev, unsigned int *data) { int i; - unsigned int chan, gain, aref; + unsigned int chan, gain; chan = CR_CHAN(insn->chanspec); gain = CR_RANGE(insn->chanspec); /* XXX docs don't explain how to select aref */ - aref = CR_AREF(insn->chanspec); for (i = 0; i < insn->n; i++) data[i] = dt3k_readsingle(dev, DPR_SUBSYS_AI, chan, gain); -- cgit v1.2.3-59-g8ed1b From c0981afd8cd6e7176b4b9fe2186087695463ebde Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Wed, 9 Oct 2019 20:07:03 +0300 Subject: staging: kpc2000: Remove unnecessary return variable Remove unnecessary variable `val` in kp_spi_read_reg() that only holds the return value from readq(). Issue found by coccinelle using the script: @@ local idexpression ret; expression e; @@ -ret = +return e; -return ret; Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191009170703.GA2869@wambui Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 3be33c450cab..6ba94b0131da 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -162,14 +162,12 @@ union kp_spi_ffctrl { kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) { u64 __iomem *addr = cs->base; - u64 val; addr += idx; if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) return cs->conf_cache; - val = readq(addr); - return val; + return readq(addr); } static inline void -- cgit v1.2.3-59-g8ed1b From 0bb0dff0cc16ac58e3f0123bda3035547da30d55 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 9 Oct 2019 10:46:02 +0100 Subject: staging: wfx: fix swapped arguments in memset call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The memset appears to have the 2nd and 3rd arguments in the wrong order, fix this by swapping these around into the correct order. Addresses-Coverity: ("Memset fill truncated") Fixes: 4f8b7fabb15d ("staging: wfx: allow to send commands to chip") Signed-off-by: Colin Ian King Reviewed-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191009094602.19663-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 8de16ad7c710..761ad9b4f27e 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -226,7 +226,7 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user // wfx_cmd_send() chekc that reply buffer is wide enough, but do not // return precise length read. User have to know how many bytes should // be read. Filling reply buffer with a memory pattern may help user. - memset(context->reply, sizeof(context->reply), 0xFF); + memset(context->reply, 0xFF, sizeof(context->reply)); request = memdup_user(user_buf, count); if (IS_ERR(request)) return PTR_ERR(request); -- cgit v1.2.3-59-g8ed1b From 7638621da743388629b3754a867a27184722c83c Mon Sep 17 00:00:00 2001 From: zhengbin Date: Wed, 9 Oct 2019 21:50:28 +0800 Subject: staging: wfx: Make function 'sram_write_dma_safe', 'load_firmware_secure' static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix sparse warnings: drivers/staging/wfx/fwio.c:83:5: warning: symbol 'sram_write_dma_safe' was not declared. Should it be static? drivers/staging/wfx/fwio.c:229:5: warning: symbol 'load_firmware_secure' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Jérôme Pouiller Link: https://lore.kernel.org/r/1570629030-29888-2-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/fwio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c index 8fb4a9f6d1a6..6d82c6244c7f 100644 --- a/drivers/staging/wfx/fwio.c +++ b/drivers/staging/wfx/fwio.c @@ -80,7 +80,8 @@ static const char * const fwio_error_strings[] = { * NOTE: it may also be possible to use 'pages' from struct firmware and avoid * bounce buffer */ -int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, size_t len) +static int sram_write_dma_safe(struct wfx_dev *wdev, u32 addr, const u8 *buf, + size_t len) { int ret; const u8 *tmp; @@ -226,7 +227,7 @@ static void print_boot_status(struct wfx_dev *wdev) } } -int load_firmware_secure(struct wfx_dev *wdev) +static int load_firmware_secure(struct wfx_dev *wdev) { const struct firmware *fw = NULL; int header_size; -- cgit v1.2.3-59-g8ed1b From dc3d13fba4695f53d55d4eebe0d714c8b1da62bd Mon Sep 17 00:00:00 2001 From: zhengbin Date: Wed, 9 Oct 2019 21:50:29 +0800 Subject: staging: wfx: Make function 'wfx_tx_queue_get' static MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix sparse warnings: drivers/staging/wfx/queue.c:218:16: warning: symbol 'wfx_tx_queue_get' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Jérôme Pouiller Link: https://lore.kernel.org/r/1570629030-29888-3-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/queue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index ee9b2c3fde5a..ef3ee55cf621 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -215,7 +215,9 @@ void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_b spin_unlock_bh(&queue->queue.lock); } -struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, struct wfx_queue *queue, u32 link_id_map) +static struct sk_buff *wfx_tx_queue_get(struct wfx_dev *wdev, + struct wfx_queue *queue, + u32 link_id_map) { struct sk_buff *skb = NULL; struct sk_buff *item; -- cgit v1.2.3-59-g8ed1b From 8fd1fe824f20692a09279fabe952cf65bedffeee Mon Sep 17 00:00:00 2001 From: zhengbin Date: Wed, 9 Oct 2019 21:50:30 +0800 Subject: staging: wfx: Make some functions static in sta.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix sparse warnings: drivers/staging/wfx/sta.c:269:6: warning: symbol 'wfx_update_filtering_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:475:6: warning: symbol 'wfx_event_handler_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:521:6: warning: symbol 'wfx_bss_loss_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:528:6: warning: symbol 'wfx_bss_params_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:539:6: warning: symbol 'wfx_set_beacon_wakeup_period_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:732:6: warning: symbol 'wfx_unjoin_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:794:6: warning: symbol 'wfx_set_cts_work' was not declared. Should it be static? drivers/staging/wfx/sta.c:1234:6: warning: symbol 'wfx_set_tim_work' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: zhengbin Reviewed-by: Jérôme Pouiller Link: https://lore.kernel.org/r/1570629030-29888-4-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/sta.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 3c715cc88ab2..688586e823c0 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -266,7 +266,7 @@ void wfx_update_filtering(struct wfx_vif *wvif) dev_err(wvif->wdev->dev, "update filtering failed: %d\n", ret); } -void wfx_update_filtering_work(struct work_struct *work) +static void wfx_update_filtering_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, update_filtering_work); @@ -472,7 +472,7 @@ static void wfx_event_report_rssi(struct wfx_vif *wvif, uint8_t raw_rcpi_rssi) ieee80211_cqm_rssi_notify(wvif->vif, cqm_evt, rcpi_rssi, GFP_KERNEL); } -void wfx_event_handler_work(struct work_struct *work) +static void wfx_event_handler_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, event_handler_work); @@ -518,14 +518,14 @@ void wfx_event_handler_work(struct work_struct *work) __wfx_free_event_queue(&list); } -void wfx_bss_loss_work(struct work_struct *work) +static void wfx_bss_loss_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, bss_loss_work.work); ieee80211_connection_loss(wvif->vif); } -void wfx_bss_params_work(struct work_struct *work) +static void wfx_bss_params_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, bss_params_work); @@ -536,7 +536,7 @@ void wfx_bss_params_work(struct work_struct *work) mutex_unlock(&wvif->wdev->conf_mutex); } -void wfx_set_beacon_wakeup_period_work(struct work_struct *work) +static void wfx_set_beacon_wakeup_period_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_beacon_wakeup_period_work); @@ -729,7 +729,7 @@ done_put: cfg80211_put_bss(wvif->wdev->hw->wiphy, bss); } -void wfx_unjoin_work(struct work_struct *work) +static void wfx_unjoin_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, unjoin_work); @@ -791,7 +791,7 @@ int wfx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return 0; } -void wfx_set_cts_work(struct work_struct *work) +static void wfx_set_cts_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_cts_work); u8 erp_ie[3] = { WLAN_EID_ERP_INFO, 1, 0 }; @@ -1231,7 +1231,7 @@ static int wfx_set_tim_impl(struct wfx_vif *wvif, bool aid0_bit_set) return 0; } -void wfx_set_tim_work(struct work_struct *work) +static void wfx_set_tim_work(struct work_struct *work) { struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_tim_work); -- cgit v1.2.3-59-g8ed1b From 2dac96b334aad29ab5a29a9150b3f5c04e2e0d63 Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Tue, 8 Oct 2019 13:17:38 -0700 Subject: staging: rtl8723bs: core: Remove typecast in call to kfree Remove typecast in the call to kfree as it is not needed. Issue found using the below coccinelle script with options -I and --recursive-includes, @@ type t1; expression *e; @@ -kfree((t1 *)e); +kfree(e); Signed-off-by: Nachammai Karuppiah Acked-by: Julia Lawall Link: https://lore.kernel.org/r/1570565858-91737-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_cmd.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 6d18d23acdc0..a1f501655392 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1453,7 +1453,7 @@ u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta) psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm)); if (psetstakey_para == NULL) { - kfree((u8 *)ph2c); + kfree(ph2c); res = _FAIL; goto exit; } @@ -1496,7 +1496,7 @@ static int rtw_ap_set_key( } psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm)); if (psetkeyparm == NULL) { - kfree((unsigned char *)pcmd); + kfree(pcmd); res = _FAIL; goto exit; } diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 8d93c2f26890..e6fea9665dff 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -372,13 +372,13 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) { /* free parmbuf in cmd_obj */ - kfree((unsigned char *)pcmd->parmbuf); + kfree(pcmd->parmbuf); } if (pcmd->rsp != NULL) { if (pcmd->rspsz != 0) { /* free rsp in cmd_obj */ - kfree((unsigned char *)pcmd->rsp); + kfree(pcmd->rsp); } } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 0ac7712223af..1b29a200a4d7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2207,7 +2207,7 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm)); if (psetauthparm == NULL) { - kfree((unsigned char *)pcmd); + kfree(pcmd); res = _FAIL; goto exit; } @@ -2284,7 +2284,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s default: RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; - kfree((unsigned char *)psetkeyparm); + kfree(psetkeyparm); goto exit; } @@ -2292,7 +2292,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s if (enqueue) { pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { - kfree((unsigned char *)psetkeyparm); + kfree(psetkeyparm); res = _FAIL; /* try again */ goto exit; } @@ -2308,7 +2308,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s res = rtw_enqueue_cmd(pcmdpriv, pcmd); } else { setkey_hdl(adapter, (u8 *)psetkeyparm); - kfree((u8 *) psetkeyparm); + kfree(psetkeyparm); } exit: return res; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 3933e8637e57..9590e6f351c1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1466,11 +1466,11 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } } - kfree((u8 *)bssid); + kfree(bssid); return _SUCCESS; _mismatch: - kfree((u8 *)bssid); + kfree(bssid); if (pmlmepriv->NumOfBcnInfoChkFail == 0) pmlmepriv->timeBcnInfoChkStart = jiffies; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 43d663c8486d..f5cb5ae7790b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2212,7 +2212,7 @@ void rtw_free_hwxmits(struct adapter *padapter) hwxmits = pxmitpriv->hwxmits; if (hwxmits) - kfree((u8 *)hwxmits); + kfree(hwxmits); } void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry) -- cgit v1.2.3-59-g8ed1b From cf490d84dbef9599b67ad4250c4c65db73453947 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 8 Oct 2019 16:48:53 -0500 Subject: staging: rtl8723bs: Replace string with identifier Replace the hardcoded function name with its predefined identifier. Signed-off-by: Javier F. Arias Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191008214851.p4w7cbpuldnwkne4@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index f5cb5ae7790b..2bd37992d44c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2310,7 +2310,7 @@ s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt) if (!pxmitframe) { drop_cnt++; - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("%s: no more pxmitframe\n", __func__)); DBG_COUNTER(padapter->tx_logs.core_tx_err_pxmitframe); return -1; } @@ -2318,7 +2318,7 @@ s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt) res = update_attrib(padapter, *ppkt, &pxmitframe->attrib); if (res == _FAIL) { - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: update attrib fail\n")); + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("%s: update attrib fail\n", __func__)); #ifdef DBG_TX_DROP_FRAME DBG_871X("DBG_TX_DROP_FRAME %s update attrib fail\n", __func__); #endif -- cgit v1.2.3-59-g8ed1b From a883d97fc538b6b92ecf5c45338997b97f6d5fb7 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 8 Oct 2019 16:16:00 -0500 Subject: staging: rtl8723bs: Remove space before tab Fix warning by removing space before tab. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/20191008211557.iv3hdpbklgaddlt3@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 1b29a200a4d7..a03cc005f053 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -19,7 +19,7 @@ int rtw_init_mlme_priv(struct adapter *padapter) int i; u8 *pbuf; struct wlan_network *pnetwork; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int res = _SUCCESS; pmlmepriv->nic_hdl = (u8 *)padapter; -- cgit v1.2.3-59-g8ed1b From 348c59749ffe1aa1dd9ecd1349a74fc3fae9283d Mon Sep 17 00:00:00 2001 From: zhengbin Date: Wed, 9 Oct 2019 07:55:05 +0800 Subject: staging: rtl8723bs: Remove set but not used variable 'i' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/core/rtw_xmit.c: In function update_attrib: drivers/staging/rtl8723bs/core/rtw_xmit.c:680:7: warning: variable i set but not used [-Wunused-but-set-variable] It is not used since commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1570578905-95675-1-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 2bd37992d44c..7011c2aa25cb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -675,7 +675,6 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib *pattrib) { - uint i; struct pkt_file pktfile; struct sta_info *psta = NULL; struct ethhdr etherhdr; @@ -689,7 +688,7 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib); _rtw_open_pktfile(pkt, &pktfile); - i = _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); + _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); pattrib->ether_type = ntohs(etherhdr.h_proto); -- cgit v1.2.3-59-g8ed1b From 8c0c8b661bc7f498a6521d13760d66a45d87d4b7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 9 Oct 2019 14:32:19 +0200 Subject: staging: rtl8723bs: Remove phy_Config*With*ParaFile() calls The rtl8723bs driver tries to load various parameters from disk, circumventing the standard firmware loader mechanism and using DIY code for this. No devices which run the mainline kernel ship with these files and even if these files were present then they still would not be loaded without additional module parameters. To be precise the following 3 conditions must all 3 be true for on disk parameters to be used: 1) The rtw_load_phy_file modparam must contain the mask for the type, this defaults to(LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE) so with the default settings this condition is only true for: phy_ConfigBBWithPgParaFile() PHY_ConfigRFWithPowerLimitTableParaFile(); and 2) rtw_phy_file_path modparam must be set to say "/lib/firmware/"; and 3) Store a /lib/firmware/rtl8723b/XXX file in the expected format. In practice all 3 being true never happens, so the phy_Config*With*ParaFile() calls are nops, remove them. The actual code implementing them will be removed in a separate patch. Note the ODM_ConfigRFWithHeaderFile() and ODM_ConfigBBWithHeaderFile() functions always return HAL_STATUS_SUCCESS, this patch makes use of this to simplify the new code without the phy_Config*With*ParaFile() calls. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20191009123223.163241-1-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c | 77 +++---------------------- drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c | 41 ++----------- 2 files changed, 13 insertions(+), 105 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c index 6df2b58bdc67..cf23414d7224 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c @@ -362,24 +362,10 @@ void PHY_SetRFReg_8723B( */ s32 PHY_MACConfig8723B(struct adapter *Adapter) { - int rtStatus = _SUCCESS; struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - s8 *pszMACRegFile; - s8 sz8723MACRegFile[] = RTL8723B_PHY_MACREG; - - - pszMACRegFile = sz8723MACRegFile; - - /* */ - /* Config MAC */ - /* */ - rtStatus = phy_ConfigMACWithParaFile(Adapter, pszMACRegFile); - if (rtStatus == _FAIL) { - ODM_ReadAndConfig_MP_8723B_MAC_REG(&pHalData->odmpriv); - rtStatus = _SUCCESS; - } - return rtStatus; + ODM_ReadAndConfig_MP_8723B_MAC_REG(&pHalData->odmpriv); + return _SUCCESS; } /** @@ -427,17 +413,6 @@ static void phy_InitBBRFRegisterDefinition(struct adapter *Adapter) static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter) { struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rtStatus = _SUCCESS; - u8 sz8723BBRegFile[] = RTL8723B_PHY_REG; - u8 sz8723AGCTableFile[] = RTL8723B_AGC_TAB; - u8 sz8723BBBRegPgFile[] = RTL8723B_PHY_REG_PG; - u8 sz8723BRFTxPwrLmtFile[] = RTL8723B_TXPWR_LMT; - u8 *pszBBRegFile = NULL, *pszAGCTableFile = NULL, *pszBBRegPgFile = NULL, *pszRFTxPwrLmtFile = NULL; - - pszBBRegFile = sz8723BBRegFile; - pszAGCTableFile = sz8723AGCTableFile; - pszBBRegPgFile = sz8723BBBRegPgFile; - pszRFTxPwrLmtFile = sz8723BRFTxPwrLmtFile; /* Read Tx Power Limit File */ PHY_InitTxPowerLimit(Adapter); @@ -445,30 +420,14 @@ static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter) Adapter->registrypriv.RegEnableTxPowerLimit == 1 || (Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory == 1) ) { - if (PHY_ConfigRFWithPowerLimitTableParaFile(Adapter, pszRFTxPwrLmtFile) == _FAIL) { - if (HAL_STATUS_SUCCESS != ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_TXPWR_LMT, (ODM_RF_RADIO_PATH_E)0)) - rtStatus = _FAIL; - } - - if (rtStatus != _SUCCESS) { - DBG_871X("%s():Read Tx power limit fail\n", __func__); - goto phy_BB8190_Config_ParaFile_Fail; - } + ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, + CONFIG_RF_TXPWR_LMT, 0); } /* */ /* 1. Read PHY_REG.TXT BB INIT!! */ /* */ - if (phy_ConfigBBWithParaFile(Adapter, pszBBRegFile, CONFIG_BB_PHY_REG) == - _FAIL) { - if (HAL_STATUS_SUCCESS != ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG)) - rtStatus = _FAIL; - } - - if (rtStatus != _SUCCESS) { - DBG_8192C("%s():Write BB Reg Fail!!", __func__); - goto phy_BB8190_Config_ParaFile_Fail; - } + ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG); /* If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ PHY_InitTxPowerByRate(Adapter); @@ -476,11 +435,8 @@ static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter) Adapter->registrypriv.RegEnableTxPowerByRate == 1 || (Adapter->registrypriv.RegEnableTxPowerByRate == 2 && pHalData->EEPROMRegulatory != 2) ) { - if (phy_ConfigBBWithPgParaFile(Adapter, pszBBRegPgFile) == - _FAIL) { - if (HAL_STATUS_SUCCESS != ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG_PG)) - rtStatus = _FAIL; - } + ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, + CONFIG_BB_PHY_REG_PG); if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) PHY_TxPowerByRateConfiguration(Adapter); @@ -490,29 +446,14 @@ static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter) (Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory == 1) ) PHY_ConvertTxPowerLimitToPowerIndex(Adapter); - - if (rtStatus != _SUCCESS) { - DBG_8192C("%s():BB_PG Reg Fail!!\n", __func__); - } } /* */ /* 2. Read BB AGC table Initialization */ /* */ - if (phy_ConfigBBWithParaFile(Adapter, pszAGCTableFile, - CONFIG_BB_AGC_TAB) == _FAIL) { - if (HAL_STATUS_SUCCESS != ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_AGC_TAB)) - rtStatus = _FAIL; - } - - if (rtStatus != _SUCCESS) { - DBG_8192C("%s():AGC Table Fail\n", __func__); - goto phy_BB8190_Config_ParaFile_Fail; - } - -phy_BB8190_Config_ParaFile_Fail: + ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_AGC_TAB); - return rtStatus; + return _SUCCESS; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c index d0ffe0af5339..aafceaf9b139 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c @@ -85,19 +85,8 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) u32 u4RegValue = 0; u8 eRFPath; struct bb_register_def *pPhyReg; - - int rtStatus = _SUCCESS; struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - static char sz8723RadioAFile[] = RTL8723B_PHY_RADIO_A; - static char sz8723RadioBFile[] = RTL8723B_PHY_RADIO_B; - static s8 sz8723BTxPwrTrackFile[] = RTL8723B_TXPWR_TRACK; - char *pszRadioAFile, *pszRadioBFile, *pszTxPwrTrackFile; - - pszRadioAFile = sz8723RadioAFile; - pszRadioBFile = sz8723RadioBFile; - pszTxPwrTrackFile = sz8723BTxPwrTrackFile; - /* 3----------------------------------------------------------------- */ /* 3 <2> Initialize RF */ /* 3----------------------------------------------------------------- */ @@ -136,21 +125,11 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { case RF_PATH_A: - if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, - eRFPath) == _FAIL) { - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) - rtStatus = _FAIL; - } - break; case RF_PATH_B: - if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, - eRFPath) == _FAIL) { - if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) - rtStatus = _FAIL; - } + ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, + CONFIG_RF_RADIO, eRFPath); break; case RF_PATH_C: - break; case RF_PATH_D: break; } @@ -166,28 +145,16 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue); break; } - - if (rtStatus != _SUCCESS) { - /* RT_TRACE(COMP_FPGA, DBG_LOUD, ("phy_RF6052_Config_ParaFile():Radio[%d] Fail!!", eRFPath)); */ - goto phy_RF6052_Config_ParaFile_Fail; - } - } /* 3 ----------------------------------------------------------------- */ /* 3 Configuration of Tx Power Tracking */ /* 3 ----------------------------------------------------------------- */ - if (PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, pszTxPwrTrackFile) == - _FAIL) { - ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv); - } + ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv); /* RT_TRACE(COMP_INIT, DBG_LOUD, ("<---phy_RF6052_Config_ParaFile()\n")); */ - return rtStatus; - -phy_RF6052_Config_ParaFile_Fail: - return rtStatus; + return _SUCCESS; } -- cgit v1.2.3-59-g8ed1b From efe0b0a07238b958bf8339018b583064d1bac8b5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 9 Oct 2019 14:32:20 +0200 Subject: staging: rtl8723bs: Remove phy_Config*WithParaFile() functions These are no longer used, so remove them and also remove various struct definitions only used by these functions. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20191009123223.163241-2-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com.c | 1 - drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 1076 -------------------- drivers/staging/rtl8723bs/include/hal_com_phycfg.h | 26 - drivers/staging/rtl8723bs/include/hal_data.h | 21 - 4 files changed, 1124 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index eddd56abbb2d..109bd85b0cd8 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -30,7 +30,6 @@ void rtw_hal_data_deinit(struct adapter *padapter) { if (is_primary_adapter(padapter)) { /* if (padapter->isprimary) */ if (padapter->HalData) { - phy_free_filebuf(padapter); vfree(padapter->HalData); padapter->HalData = NULL; padapter->hal_data_sz = 0; diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 6539bee9b5ba..eb7de3617d83 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -2202,1079 +2202,3 @@ void Hal_ChannelPlanToRegulation(struct adapter *Adapter, u16 ChannelPlan) break; } } - - -static char file_path_bs[PATH_MAX]; - -#define GetLineFromBuffer(buffer) strsep(&buffer, "\n") - -int phy_ConfigMACWithParaFile(struct adapter *Adapter, char *pFileName) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - - if (!(Adapter->registrypriv.load_phy_file & LOAD_MAC_PARA_FILE)) - return rtStatus; - - memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->mac_reg_len == 0) && !pHalData->mac_reg) { - rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); - - if (rtw_is_file_readable(file_path_bs) == true) { - rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) { - rtStatus = _SUCCESS; - pHalData->mac_reg = vzalloc(rlen); - if (pHalData->mac_reg) { - memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen); - pHalData->mac_reg_len = rlen; - } else - DBG_871X("%s mac_reg alloc fail !\n", __func__); - } - } - } else { - if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != NULL)) { - memcpy(pHalData->para_file_buf, pHalData->mac_reg, pHalData->mac_reg_len); - rtStatus = _SUCCESS; - } else - DBG_871X("%s(): Critical Error !!!\n", __func__); - } - - if (rtStatus == _SUCCESS) { - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - if (!IsCommentString(szLine)) { - /* Get 1st hex value as register offset */ - if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { - if (u4bRegOffset == 0xffff) /* Ending. */ - break; - - /* Get 2nd hex value as register value. */ - szLine += u4bMove; - if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - rtw_write8(Adapter, u4bRegOffset, (u8)u4bRegValue); - } - } - } - } else - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); - - return rtStatus; -} - -int phy_ConfigBBWithParaFile( - struct adapter *Adapter, char *pFileName, u32 ConfigType -) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - char *pBuf = NULL; - u32 *pBufLen = NULL; - - if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE)) - return rtStatus; - - switch (ConfigType) { - case CONFIG_BB_PHY_REG: - pBuf = pHalData->bb_phy_reg; - pBufLen = &pHalData->bb_phy_reg_len; - break; - case CONFIG_BB_AGC_TAB: - pBuf = pHalData->bb_agc_tab; - pBufLen = &pHalData->bb_agc_tab_len; - break; - default: - DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType); - break; - } - - memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if (pBufLen && (*pBufLen == 0) && !pBuf) { - rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); - - if (rtw_is_file_readable(file_path_bs) == true) { - rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) { - rtStatus = _SUCCESS; - pBuf = vzalloc(rlen); - if (pBuf) { - memcpy(pBuf, pHalData->para_file_buf, rlen); - *pBufLen = rlen; - - switch (ConfigType) { - case CONFIG_BB_PHY_REG: - pHalData->bb_phy_reg = pBuf; - break; - case CONFIG_BB_AGC_TAB: - pHalData->bb_agc_tab = pBuf; - break; - } - } else - DBG_871X("%s(): ConfigType %d alloc fail !\n", __func__, ConfigType); - } - } - } else { - if (pBufLen && (*pBufLen == 0) && !pBuf) { - memcpy(pHalData->para_file_buf, pBuf, *pBufLen); - rtStatus = _SUCCESS; - } else - DBG_871X("%s(): Critical Error !!!\n", __func__); - } - - if (rtStatus == _SUCCESS) { - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - if (!IsCommentString(szLine)) { - /* Get 1st hex value as register offset. */ - if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { - if (u4bRegOffset == 0xffff) /* Ending. */ - break; - else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) - msleep(50); - else if (u4bRegOffset == 0xfd) - mdelay(5); - else if (u4bRegOffset == 0xfc) - mdelay(1); - else if (u4bRegOffset == 0xfb) - udelay(50); - else if (u4bRegOffset == 0xfa) - udelay(5); - else if (u4bRegOffset == 0xf9) - udelay(1); - - /* Get 2nd hex value as register value. */ - szLine += u4bMove; - if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { - /* DBG_871X("[BB-ADDR]%03lX =%08lX\n", u4bRegOffset, u4bRegValue); */ - PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue); - - if (u4bRegOffset == 0xa24) - pHalData->odmpriv.RFCalibrateInfo.RegA24 = u4bRegValue; - - /* Add 1us delay between BB/RF register setting. */ - udelay(1); - } - } - } - } - } else - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); - - return rtStatus; -} - -static void phy_DecryptBBPgParaFile(struct adapter *Adapter, char *buffer) -{ - u32 i = 0, j = 0; - u8 map[95] = {0}; - u8 currentChar; - char *BufOfLines, *ptmp; - - /* DBG_871X("=====>phy_DecryptBBPgParaFile()\n"); */ - /* 32 the ascii code of the first visable char, 126 the last one */ - for (i = 0; i < 95; ++i) - map[i] = (u8) (94 - i); - - ptmp = buffer; - i = 0; - for (BufOfLines = GetLineFromBuffer(ptmp); BufOfLines != NULL; BufOfLines = GetLineFromBuffer(ptmp)) { - /* DBG_871X("Encrypted Line: %s\n", BufOfLines); */ - - for (j = 0; j < strlen(BufOfLines); ++j) { - currentChar = BufOfLines[j]; - - if (currentChar == '\0') - break; - - currentChar -= (u8) ((((i + j) * 3) % 128)); - - BufOfLines[j] = map[currentChar - 32] + 32; - } - /* DBG_871X("Decrypted Line: %s\n", BufOfLines); */ - if (strlen(BufOfLines) != 0) - i++; - BufOfLines[strlen(BufOfLines)] = '\n'; - } -} - -static int phy_ParseBBPgParaFile(struct adapter *Adapter, char *buffer) -{ - int rtStatus = _SUCCESS; - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegMask, u4bRegValue; - u32 u4bMove; - bool firstLine = true; - u8 tx_num = 0; - u8 band = 0, rf_path = 0; - - /* DBG_871X("=====>phy_ParseBBPgParaFile()\n"); */ - - if (Adapter->registrypriv.RegDecryptCustomFile == 1) - phy_DecryptBBPgParaFile(Adapter, buffer); - - ptmp = buffer; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - if (!IsCommentString(szLine)) { - if (isAllSpaceOrTab(szLine, sizeof(*szLine))) - continue; - - /* Get header info (relative value or exact value) */ - if (firstLine) { - if (eqNByte(szLine, (u8 *)("#[v1]"), 5)) { - - pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0'; - /* DBG_871X("This is a new format PHY_REG_PG.txt\n"); */ - } else if (eqNByte(szLine, (u8 *)("#[v0]"), 5)) { - pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0'; - /* DBG_871X("This is a old format PHY_REG_PG.txt ok\n"); */ - } else { - DBG_871X("The format in PHY_REG_PG are invalid %s\n", szLine); - return _FAIL; - } - - if (eqNByte(szLine + 5, (u8 *)("[Exact]#"), 8)) { - pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; - /* DBG_871X("The values in PHY_REG_PG are exact values ok\n"); */ - firstLine = false; - continue; - } else if (eqNByte(szLine + 5, (u8 *)("[Relative]#"), 11)) { - pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_RELATIVE_VALUE; - /* DBG_871X("The values in PHY_REG_PG are relative values ok\n"); */ - firstLine = false; - continue; - } else { - DBG_871X("The values in PHY_REG_PG are invalid %s\n", szLine); - return _FAIL; - } - } - - if (pHalData->odmpriv.PhyRegPgVersion == 0) { - /* Get 1st hex value as register offset. */ - if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { - szLine += u4bMove; - if (u4bRegOffset == 0xffff) /* Ending. */ - break; - - /* Get 2nd hex value as register mask. */ - if (GetHexValueFromString(szLine, &u4bRegMask, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE) { - /* Get 3rd hex value as register value. */ - if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { - PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, u4bRegValue); - /* DBG_871X("[ADDR] %03X =%08X Mask =%08x\n", u4bRegOffset, u4bRegValue, u4bRegMask); */ - } else - return _FAIL; - } else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { - u32 combineValue = 0; - u8 integer = 0, fraction = 0; - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue <<= 8; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue <<= 8; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue <<= 8; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, combineValue); - - /* DBG_871X("[ADDR] 0x%3x = 0x%4x\n", u4bRegOffset, combineValue); */ - } - } - } else if (pHalData->odmpriv.PhyRegPgVersion > 0) { - u32 index = 0; - - if (eqNByte(szLine, "0xffff", 6)) - break; - - if (!eqNByte("#[END]#", szLine, 7)) { - /* load the table label info */ - if (szLine[0] == '#') { - index = 0; - if (eqNByte(szLine, "#[2.4G]", 7)) { - band = BAND_ON_2_4G; - index += 8; - } else if (eqNByte(szLine, "#[5G]", 5)) { - band = BAND_ON_5G; - index += 6; - } else { - DBG_871X("Invalid band %s in PHY_REG_PG.txt\n", szLine); - return _FAIL; - } - - rf_path = szLine[index] - 'A'; - /* DBG_871X(" Table label Band %d, RfPath %d\n", band, rf_path); */ - } else { /* load rows of tables */ - if (szLine[1] == '1') - tx_num = RF_1TX; - else if (szLine[1] == '2') - tx_num = RF_2TX; - else if (szLine[1] == '3') - tx_num = RF_3TX; - else if (szLine[1] == '4') - tx_num = RF_4TX; - else { - DBG_871X("Invalid row in PHY_REG_PG.txt %c\n", szLine[1]); - return _FAIL; - } - - while (szLine[index] != ']') - ++index; - ++index;/* skip ] */ - - /* Get 2nd hex value as register offset. */ - szLine += index; - if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - /* Get 2nd hex value as register mask. */ - if (GetHexValueFromString(szLine, &u4bRegMask, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE) { - /* Get 3rd hex value as register value. */ - if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { - PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, u4bRegValue); - /* DBG_871X("[ADDR] %03X (tx_num %d) =%08X Mask =%08x\n", u4bRegOffset, tx_num, u4bRegValue, u4bRegMask); */ - } else - return _FAIL; - } else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { - u32 combineValue = 0; - u8 integer = 0, fraction = 0; - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue <<= 8; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue <<= 8; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - - if (GetFractionValueFromString(szLine, &integer, &fraction, &u4bMove)) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if (fraction == 5) - integer += 1; - combineValue <<= 8; - combineValue |= (((integer / 10) << 4) + (integer % 10)); - /* DBG_871X(" %d", integer); */ - PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, combineValue); - - /* DBG_871X("[ADDR] 0x%3x (tx_num %d) = 0x%4x\n", u4bRegOffset, tx_num, combineValue); */ - } - } - } - } - } - } - /* DBG_871X("<=====phy_ParseBBPgParaFile()\n"); */ - return rtStatus; -} - -int phy_ConfigBBWithPgParaFile(struct adapter *Adapter, char *pFileName) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - - if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PG_PARA_FILE)) - return rtStatus; - - memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->bb_phy_reg_pg_len == 0) && !pHalData->bb_phy_reg_pg) { - rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); - - if (rtw_is_file_readable(file_path_bs) == true) { - rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) { - rtStatus = _SUCCESS; - pHalData->bb_phy_reg_pg = vzalloc(rlen); - if (pHalData->bb_phy_reg_pg) { - memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen); - pHalData->bb_phy_reg_pg_len = rlen; - } else - DBG_871X("%s bb_phy_reg_pg alloc fail !\n", __func__); - } - } - } else { - if ((pHalData->bb_phy_reg_pg_len != 0) && (pHalData->bb_phy_reg_pg != NULL)) { - memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len); - rtStatus = _SUCCESS; - } else - DBG_871X("%s(): Critical Error !!!\n", __func__); - } - - if (rtStatus == _SUCCESS) { - /* DBG_871X("phy_ConfigBBWithPgParaFile(): read %s ok\n", pFileName); */ - phy_ParseBBPgParaFile(Adapter, pHalData->para_file_buf); - } else - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); - - return rtStatus; -} - -int PHY_ConfigRFWithParaFile( - struct adapter *Adapter, char *pFileName, u8 eRFPath -) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - u16 i; - char *pBuf = NULL; - u32 *pBufLen = NULL; - - if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_PARA_FILE)) - return rtStatus; - - switch (eRFPath) { - case ODM_RF_PATH_A: - pBuf = pHalData->rf_radio_a; - pBufLen = &pHalData->rf_radio_a_len; - break; - case ODM_RF_PATH_B: - pBuf = pHalData->rf_radio_b; - pBufLen = &pHalData->rf_radio_b_len; - break; - default: - DBG_871X("Unknown RF path!! %d\r\n", eRFPath); - break; - } - - memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if (pBufLen && (*pBufLen == 0) && !pBuf) { - rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); - - if (rtw_is_file_readable(file_path_bs) == true) { - rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) { - rtStatus = _SUCCESS; - pBuf = vzalloc(rlen); - if (pBuf) { - memcpy(pBuf, pHalData->para_file_buf, rlen); - *pBufLen = rlen; - - switch (eRFPath) { - case ODM_RF_PATH_A: - pHalData->rf_radio_a = pBuf; - break; - case ODM_RF_PATH_B: - pHalData->rf_radio_b = pBuf; - break; - } - } else - DBG_871X("%s(): eRFPath =%d alloc fail !\n", __func__, eRFPath); - } - } - } else { - if (pBufLen && (*pBufLen == 0) && !pBuf) { - memcpy(pHalData->para_file_buf, pBuf, *pBufLen); - rtStatus = _SUCCESS; - } else - DBG_871X("%s(): Critical Error !!!\n", __func__); - } - - if (rtStatus == _SUCCESS) { - /* DBG_871X("%s(): read %s successfully\n", __func__, pFileName); */ - - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - if (!IsCommentString(szLine)) { - /* Get 1st hex value as register offset. */ - if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { - if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) /* Deay specific ms. Only RF configuration require delay. */ - msleep(50); - else if (u4bRegOffset == 0xfd) { - /* mdelay(5); */ - for (i = 0; i < 100; i++) - udelay(MAX_STALL_TIME); - } else if (u4bRegOffset == 0xfc) { - /* mdelay(1); */ - for (i = 0; i < 20; i++) - udelay(MAX_STALL_TIME); - } else if (u4bRegOffset == 0xfb) - udelay(50); - else if (u4bRegOffset == 0xfa) - udelay(5); - else if (u4bRegOffset == 0xf9) - udelay(1); - else if (u4bRegOffset == 0xffff) - break; - - /* Get 2nd hex value as register value. */ - szLine += u4bMove; - if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { - PHY_SetRFReg(Adapter, eRFPath, u4bRegOffset, bRFRegOffsetMask, u4bRegValue); - - /* Temp add, for frequency lock, if no delay, that may cause */ - /* frequency shift, ex: 2412MHz => 2417MHz */ - /* If frequency shift, the following action may works. */ - /* Fractional-N table in radio_a.txt */ - /* 0x2a 0x00001 channel 1 */ - /* 0x2b 0x00808 frequency divider. */ - /* 0x2b 0x53333 */ - /* 0x2c 0x0000c */ - udelay(1); - } - } - } - } - } else - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); - - return rtStatus; -} - -static void initDeltaSwingIndexTables( - struct adapter *Adapter, - char *Band, - char *Path, - char *Sign, - char *Channel, - char *Rate, - char *Data -) -{ - #define STR_EQUAL_5G(_band, _path, _sign, _rate, _chnl) \ - ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\ - (strcmp(Rate, _rate) == 0) && (strcmp(Channel, _chnl) == 0)\ - ) - #define STR_EQUAL_2G(_band, _path, _sign, _rate) \ - ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\ - (strcmp(Rate, _rate) == 0)\ - ) - - #define STORE_SWING_TABLE(_array, _iteratedIdx) \ - for (token = strsep(&Data, delim); token != NULL; token = strsep(&Data, delim)) {\ - sscanf(token, "%d", &idx);\ - _array[_iteratedIdx++] = (u8)idx;\ - } \ - - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - PDM_ODM_T pDM_Odm = &pHalData->odmpriv; - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - u32 j = 0; - char *token; - char delim[] = ","; - u32 idx = 0; - - /* DBG_871X("===>initDeltaSwingIndexTables(): Band: %s;\nPath: %s;\nSign: %s;\nChannel: %s;\nRate: %s;\n, Data: %s;\n", */ - /* Band, Path, Sign, Channel, Rate, Data); */ - - if (STR_EQUAL_2G("2G", "A", "+", "CCK")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, j); - } else if (STR_EQUAL_2G("2G", "A", "-", "CCK")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, j); - } else if (STR_EQUAL_2G("2G", "B", "+", "CCK")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, j); - } else if (STR_EQUAL_2G("2G", "B", "-", "CCK")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, j); - } else if (STR_EQUAL_2G("2G", "A", "+", "ALL")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, j); - } else if (STR_EQUAL_2G("2G", "A", "-", "ALL")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, j); - } else if (STR_EQUAL_2G("2G", "B", "+", "ALL")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, j); - } else if (STR_EQUAL_2G("2G", "B", "-", "ALL")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, j); - } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "0")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[0], j); - } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "0")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[0], j); - } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "0")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[0], j); - } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "0")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[0], j); - } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "1")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[1], j); - } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "1")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[1], j); - } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "1")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[1], j); - } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "1")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[1], j); - } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "2")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[2], j); - } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "2")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[2], j); - } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "2")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[2], j); - } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "2")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[2], j); - } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "3")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[3], j); - } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "3")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[3], j); - } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "3")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[3], j); - } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "3")) { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[3], j); - } else - DBG_871X("===>initDeltaSwingIndexTables(): The input is invalid!!\n"); -} - -int PHY_ConfigRFWithTxPwrTrackParaFile(struct adapter *Adapter, char *pFileName) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - - if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_TRACK_PARA_FILE)) - return rtStatus; - - memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->rf_tx_pwr_track_len == 0) && !pHalData->rf_tx_pwr_track) { - rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); - - if (rtw_is_file_readable(file_path_bs) == true) { - rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) { - rtStatus = _SUCCESS; - pHalData->rf_tx_pwr_track = vzalloc(rlen); - if (pHalData->rf_tx_pwr_track) { - memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen); - pHalData->rf_tx_pwr_track_len = rlen; - } else - DBG_871X("%s rf_tx_pwr_track alloc fail !\n", __func__); - } - } - } else { - if ((pHalData->rf_tx_pwr_track_len != 0) && (pHalData->rf_tx_pwr_track != NULL)) { - memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len); - rtStatus = _SUCCESS; - } else - DBG_871X("%s(): Critical Error !!!\n", __func__); - } - - if (rtStatus == _SUCCESS) { - /* DBG_871X("%s(): read %s successfully\n", __func__, pFileName); */ - - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - if (!IsCommentString(szLine)) { - char band[5] = "", path[5] = "", sign[5] = ""; - char chnl[5] = "", rate[10] = ""; - char data[300] = ""; /* 100 is too small */ - const int len = strlen(szLine); - int i; - - if (len < 10 || szLine[0] != '[') - continue; - - strncpy(band, szLine+1, 2); - strncpy(path, szLine+5, 1); - strncpy(sign, szLine+8, 1); - - i = 10; /* szLine+10 */ - if (!ParseQualifiedString(szLine, &i, rate, '[', ']')) { - /* DBG_871X("Fail to parse rate!\n"); */ - } - if (!ParseQualifiedString(szLine, &i, chnl, '[', ']')) { - /* DBG_871X("Fail to parse channel group!\n"); */ - } - while (i < len && szLine[i] != '{') - i++; - if (!ParseQualifiedString(szLine, &i, data, '{', '}')) { - /* DBG_871X("Fail to parse data!\n"); */ - } - - initDeltaSwingIndexTables(Adapter, band, path, sign, chnl, rate, data); - } - } - } else - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); - - return rtStatus; -} - -static int phy_ParsePowerLimitTableFile(struct adapter *Adapter, char *buffer) -{ - u32 i = 0, forCnt = 0; - u8 loadingStage = 0, limitValue = 0, fraction = 0; - char *szLine, *ptmp; - int rtStatus = _SUCCESS; - char band[10], bandwidth[10], rateSection[10], - regulation[TXPWR_LMT_MAX_REGULATION_NUM][10], rfPath[10], colNumBuf[10]; - u8 colNum = 0; - - DBG_871X("===>phy_ParsePowerLimitTableFile()\n"); - - if (Adapter->registrypriv.RegDecryptCustomFile == 1) - phy_DecryptBBPgParaFile(Adapter, buffer); - - ptmp = buffer; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - /* skip comment */ - if (IsCommentString(szLine)) { - continue; - } - - if (loadingStage == 0) { - for (forCnt = 0; forCnt < TXPWR_LMT_MAX_REGULATION_NUM; ++forCnt) - memset((void *) regulation[forCnt], 0, 10); - - memset((void *) band, 0, 10); - memset((void *) bandwidth, 0, 10); - memset((void *) rateSection, 0, 10); - memset((void *) rfPath, 0, 10); - memset((void *) colNumBuf, 0, 10); - - if (szLine[0] != '#' || szLine[1] != '#') - continue; - - /* skip the space */ - i = 2; - while (szLine[i] == ' ' || szLine[i] == '\t') - ++i; - - szLine[--i] = ' '; /* return the space in front of the regulation info */ - - /* Parse the label of the table */ - if (!ParseQualifiedString(szLine, &i, band, ' ', ',')) { - DBG_871X("Fail to parse band!\n"); - return _FAIL; - } - if (!ParseQualifiedString(szLine, &i, bandwidth, ' ', ',')) { - DBG_871X("Fail to parse bandwidth!\n"); - return _FAIL; - } - if (!ParseQualifiedString(szLine, &i, rfPath, ' ', ',')) { - DBG_871X("Fail to parse rf path!\n"); - return _FAIL; - } - if (!ParseQualifiedString(szLine, &i, rateSection, ' ', ',')) { - DBG_871X("Fail to parse rate!\n"); - return _FAIL; - } - - loadingStage = 1; - } else if (loadingStage == 1) { - if (szLine[0] != '#' || szLine[1] != '#') - continue; - - /* skip the space */ - i = 2; - while (szLine[i] == ' ' || szLine[i] == '\t') - ++i; - - if (!eqNByte((u8 *)(szLine + i), (u8 *)("START"), 5)) { - DBG_871X("Lost \"## START\" label\n"); - return _FAIL; - } - - loadingStage = 2; - } else if (loadingStage == 2) { - if (szLine[0] != '#' || szLine[1] != '#') - continue; - - /* skip the space */ - i = 2; - while (szLine[i] == ' ' || szLine[i] == '\t') - ++i; - - if (!ParseQualifiedString(szLine, &i, colNumBuf, '#', '#')) { - DBG_871X("Fail to parse column number!\n"); - return _FAIL; - } - - if (!GetU1ByteIntegerFromStringInDecimal(colNumBuf, &colNum)) - return _FAIL; - - if (colNum > TXPWR_LMT_MAX_REGULATION_NUM) { - DBG_871X( - "invalid col number %d (greater than max %d)\n", - colNum, TXPWR_LMT_MAX_REGULATION_NUM - ); - return _FAIL; - } - - for (forCnt = 0; forCnt < colNum; ++forCnt) { - u8 regulation_name_cnt = 0; - - /* skip the space */ - while (szLine[i] == ' ' || szLine[i] == '\t') - ++i; - - while (szLine[i] != ' ' && szLine[i] != '\t' && szLine[i] != '\0') - regulation[forCnt][regulation_name_cnt++] = szLine[i++]; - /* DBG_871X("regulation %s!\n", regulation[forCnt]); */ - - if (regulation_name_cnt == 0) { - DBG_871X("invalid number of regulation!\n"); - return _FAIL; - } - } - - loadingStage = 3; - } else if (loadingStage == 3) { - char channel[10] = {0}, powerLimit[10] = {0}; - u8 cnt = 0; - - /* the table ends */ - if (szLine[0] == '#' && szLine[1] == '#') { - i = 2; - while (szLine[i] == ' ' || szLine[i] == '\t') - ++i; - - if (eqNByte((u8 *)(szLine + i), (u8 *)("END"), 3)) { - loadingStage = 0; - continue; - } else { - DBG_871X("Wrong format\n"); - DBG_871X("<===== phy_ParsePowerLimitTableFile()\n"); - return _FAIL; - } - } - - if ((szLine[0] != 'c' && szLine[0] != 'C') || - (szLine[1] != 'h' && szLine[1] != 'H')) { - DBG_871X("Meet wrong channel => power limt pair\n"); - continue; - } - i = 2;/* move to the location behind 'h' */ - - /* load the channel number */ - cnt = 0; - while (szLine[i] >= '0' && szLine[i] <= '9') { - channel[cnt] = szLine[i]; - ++cnt; - ++i; - } - /* DBG_871X("chnl %s!\n", channel); */ - - for (forCnt = 0; forCnt < colNum; ++forCnt) { - /* skip the space between channel number and the power limit value */ - while (szLine[i] == ' ' || szLine[i] == '\t') - ++i; - - /* load the power limit value */ - cnt = 0; - fraction = 0; - memset((void *) powerLimit, 0, 10); - while ((szLine[i] >= '0' && szLine[i] <= '9') || szLine[i] == '.') { - if (szLine[i] == '.') { - if ((szLine[i+1] >= '0' && szLine[i+1] <= '9')) { - fraction = szLine[i+1]; - i += 2; - } else { - DBG_871X("Wrong fraction in TXPWR_LMT.txt\n"); - return _FAIL; - } - - break; - } - - powerLimit[cnt] = szLine[i]; - ++cnt; - ++i; - } - - if (powerLimit[0] == '\0') { - powerLimit[0] = '6'; - powerLimit[1] = '3'; - i += 2; - } else { - if (!GetU1ByteIntegerFromStringInDecimal(powerLimit, &limitValue)) - return _FAIL; - - limitValue *= 2; - cnt = 0; - if (fraction == '5') - ++limitValue; - - /* the value is greater or equal to 100 */ - if (limitValue >= 100) { - powerLimit[cnt++] = limitValue/100 + '0'; - limitValue %= 100; - - if (limitValue >= 10) { - powerLimit[cnt++] = limitValue/10 + '0'; - limitValue %= 10; - } else - powerLimit[cnt++] = '0'; - - powerLimit[cnt++] = limitValue + '0'; - } else if (limitValue >= 10) { /* the value is greater or equal to 10 */ - powerLimit[cnt++] = limitValue/10 + '0'; - limitValue %= 10; - powerLimit[cnt++] = limitValue + '0'; - } - /* the value is less than 10 */ - else - powerLimit[cnt++] = limitValue + '0'; - - powerLimit[cnt] = '\0'; - } - - /* DBG_871X("ch%s => %s\n", channel, powerLimit); */ - - /* store the power limit value */ - PHY_SetTxPowerLimit(Adapter, (u8 *)regulation[forCnt], (u8 *)band, - (u8 *)bandwidth, (u8 *)rateSection, (u8 *)rfPath, (u8 *)channel, (u8 *)powerLimit); - - } - } else { - DBG_871X("Abnormal loading stage in phy_ParsePowerLimitTableFile()!\n"); - rtStatus = _FAIL; - break; - } - } - - DBG_871X("<===phy_ParsePowerLimitTableFile()\n"); - return rtStatus; -} - -int PHY_ConfigRFWithPowerLimitTableParaFile( - struct adapter *Adapter, char *pFileName -) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - - if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_LMT_PARA_FILE)) - return rtStatus; - - memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->rf_tx_pwr_lmt_len == 0) && !pHalData->rf_tx_pwr_lmt) { - rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); - - if (rtw_is_file_readable(file_path_bs) == true) { - rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) { - rtStatus = _SUCCESS; - pHalData->rf_tx_pwr_lmt = vzalloc(rlen); - if (pHalData->rf_tx_pwr_lmt) { - memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen); - pHalData->rf_tx_pwr_lmt_len = rlen; - } else - DBG_871X("%s rf_tx_pwr_lmt alloc fail !\n", __func__); - } - } - } else { - if ((pHalData->rf_tx_pwr_lmt_len != 0) && (pHalData->rf_tx_pwr_lmt != NULL)) { - memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len); - rtStatus = _SUCCESS; - } else - DBG_871X("%s(): Critical Error !!!\n", __func__); - } - - if (rtStatus == _SUCCESS) { - /* DBG_871X("%s(): read %s ok\n", __func__, pFileName); */ - rtStatus = phy_ParsePowerLimitTableFile(Adapter, pHalData->para_file_buf); - } else - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); - - return rtStatus; -} - -void phy_free_filebuf(struct adapter *padapter) -{ - struct hal_com_data *pHalData = GET_HAL_DATA(padapter); - - if (pHalData->mac_reg) - vfree(pHalData->mac_reg); - if (pHalData->bb_phy_reg) - vfree(pHalData->bb_phy_reg); - if (pHalData->bb_agc_tab) - vfree(pHalData->bb_agc_tab); - if (pHalData->bb_phy_reg_pg) - vfree(pHalData->bb_phy_reg_pg); - if (pHalData->bb_phy_reg_mp) - vfree(pHalData->bb_phy_reg_mp); - if (pHalData->rf_radio_a) - vfree(pHalData->rf_radio_a); - if (pHalData->rf_radio_b) - vfree(pHalData->rf_radio_b); - if (pHalData->rf_tx_pwr_track) - vfree(pHalData->rf_tx_pwr_track); - if (pHalData->rf_tx_pwr_lmt) - vfree(pHalData->rf_tx_pwr_lmt); - -} diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h index 9167f1e7827f..e9a3006a3e20 100644 --- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h +++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h @@ -219,30 +219,4 @@ struct adapter * Adapter, u16 ChannelPlan ); -#define MAX_PARA_FILE_BUF_LEN 25600 - -#define LOAD_MAC_PARA_FILE BIT0 -#define LOAD_BB_PARA_FILE BIT1 -#define LOAD_BB_PG_PARA_FILE BIT2 -#define LOAD_BB_MP_PARA_FILE BIT3 -#define LOAD_RF_PARA_FILE BIT4 -#define LOAD_RF_TXPWR_TRACK_PARA_FILE BIT5 -#define LOAD_RF_TXPWR_LMT_PARA_FILE BIT6 - -int phy_ConfigMACWithParaFile(struct adapter *Adapter, char*pFileName); - -int phy_ConfigBBWithParaFile(struct adapter *Adapter, char*pFileName, u32 ConfigType); - -int phy_ConfigBBWithPgParaFile(struct adapter *Adapter, char*pFileName); - -int phy_ConfigBBWithMpParaFile(struct adapter *Adapter, char*pFileName); - -int PHY_ConfigRFWithParaFile(struct adapter *Adapter, char*pFileName, u8 eRFPath); - -int PHY_ConfigRFWithTxPwrTrackParaFile(struct adapter *Adapter, char*pFileName); - -int PHY_ConfigRFWithPowerLimitTableParaFile(struct adapter *Adapter, char*pFileName); - -void phy_free_filebuf(struct adapter *padapter); - #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h index 7d782659a84f..e5e667df6154 100644 --- a/drivers/staging/rtl8723bs/include/hal_data.h +++ b/drivers/staging/rtl8723bs/include/hal_data.h @@ -440,27 +440,6 @@ struct hal_com_data { u32 SysIntrStatus; u32 SysIntrMask; - - char para_file_buf[MAX_PARA_FILE_BUF_LEN]; - char *mac_reg; - u32 mac_reg_len; - char *bb_phy_reg; - u32 bb_phy_reg_len; - char *bb_agc_tab; - u32 bb_agc_tab_len; - char *bb_phy_reg_pg; - u32 bb_phy_reg_pg_len; - char *bb_phy_reg_mp; - u32 bb_phy_reg_mp_len; - char *rf_radio_a; - u32 rf_radio_a_len; - char *rf_radio_b; - u32 rf_radio_b_len; - char *rf_tx_pwr_track; - u32 rf_tx_pwr_track_len; - char *rf_tx_pwr_lmt; - u32 rf_tx_pwr_lmt_len; - #ifdef CONFIG_BACKGROUND_NOISE_MONITOR s16 noise[ODM_MAX_CHANNEL_NUM]; #endif -- cgit v1.2.3-59-g8ed1b From 9d411eee434258a769db4dda4ac2a952b2868aaa Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 9 Oct 2019 14:32:21 +0200 Subject: staging: rtl8723bs: Remove phy_Config*WithParaFile() configuration leftovers Now that the phy_Config*WithParaFile() functions have been removed nothing is using these module-parameters and defines anymore. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20191009123223.163241-3-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/drv_types.h | 4 ---- drivers/staging/rtl8723bs/include/rtl8723b_hal.h | 15 --------------- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 20 -------------------- 3 files changed, 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index 8d7fce1e39b7..6ec9087f2eb1 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -197,9 +197,6 @@ struct registry_priv u8 RFE_Type; u8 check_fw_ps; - u8 load_phy_file; - u8 RegDecryptCustomFile; - #ifdef CONFIG_MULTI_VIR_IFACES u8 ext_iface_num;/* primary/secondary iface is excluded */ #endif @@ -693,7 +690,6 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter); void indicate_wx_scan_complete_event(struct adapter *padapter); int rtw_change_ifname(struct adapter *padapter, const char *ifname); -extern char *rtw_phy_file_path; extern char *rtw_initmac; extern int rtw_mc2u_disable; extern int rtw_ht_enable; diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h index 8f00ced1c697..f36516fa84c7 100644 --- a/drivers/staging/rtl8723bs/include/rtl8723b_hal.h +++ b/drivers/staging/rtl8723bs/include/rtl8723b_hal.h @@ -20,21 +20,6 @@ #include "hal_phy_reg_8723b.h" #include "hal_phy_cfg.h" -/* */ -/* RTL8723B From file */ -/* */ -#define RTL8723B_FW_IMG "rtl8723b/FW_NIC.bin" -#define RTL8723B_FW_WW_IMG "rtl8723b/FW_WoWLAN.bin" -#define RTL8723B_PHY_REG "rtl8723b/PHY_REG.txt" -#define RTL8723B_PHY_RADIO_A "rtl8723b/RadioA.txt" -#define RTL8723B_PHY_RADIO_B "rtl8723b/RadioB.txt" -#define RTL8723B_TXPWR_TRACK "rtl8723b/TxPowerTrack.txt" -#define RTL8723B_AGC_TAB "rtl8723b/AGC_TAB.txt" -#define RTL8723B_PHY_MACREG "rtl8723b/MAC_REG.txt" -#define RTL8723B_PHY_REG_PG "rtl8723b/PHY_REG_PG.txt" -#define RTL8723B_PHY_REG_MP "rtl8723b/PHY_REG_MP.txt" -#define RTL8723B_TXPWR_LMT "rtl8723b/TXPWR_LMT.txt" - /* */ /* RTL8723B From header */ /* */ diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 5044f7373b8b..cb4c86728d26 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -201,24 +201,6 @@ MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable, "0:Disable, 1:Enable, 2: Depend on efuse module_param(rtw_tx_pwr_by_rate, int, 0644); MODULE_PARM_DESC(rtw_tx_pwr_by_rate, "0:Disable, 1:Enable, 2: Depend on efuse"); -char *rtw_phy_file_path = ""; -module_param(rtw_phy_file_path, charp, 0644); -MODULE_PARM_DESC(rtw_phy_file_path, "The path of phy parameter"); -/* PHY FILE Bit Map */ -/* BIT0 - MAC, 0: non-support, 1: support */ -/* BIT1 - BB, 0: non-support, 1: support */ -/* BIT2 - BB_PG, 0: non-support, 1: support */ -/* BIT3 - BB_MP, 0: non-support, 1: support */ -/* BIT4 - RF, 0: non-support, 1: support */ -/* BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support */ -/* BIT6 - RF_TXPWR_LMT, 0: non-support, 1: support */ -static int rtw_load_phy_file = (BIT2 | BIT6); -module_param(rtw_load_phy_file, int, 0644); -MODULE_PARM_DESC(rtw_load_phy_file, "PHY File Bit Map"); -static int rtw_decrypt_phy_file; -module_param(rtw_decrypt_phy_file, int, 0644); -MODULE_PARM_DESC(rtw_decrypt_phy_file, "Enable Decrypt PHY File"); - int _netdev_open(struct net_device *pnetdev); int netdev_open (struct net_device *pnetdev); static int netdev_close (struct net_device *pnetdev); @@ -321,8 +303,6 @@ static void loadparam(struct adapter *padapter, _nic_hdl pnetdev) registry_par->bEn_RFE = 1; registry_par->RFE_Type = 64; - registry_par->load_phy_file = (u8)rtw_load_phy_file; - registry_par->RegDecryptCustomFile = (u8)rtw_decrypt_phy_file; registry_par->qos_opt_enable = (u8)rtw_qos_opt_enable; registry_par->hiq_filter = (u8)rtw_hiq_filter; -- cgit v1.2.3-59-g8ed1b From 44bcfb27d29ecc71e24f98bf8fecb41e9556b270 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 9 Oct 2019 14:32:22 +0200 Subject: staging: rtl8723bs: Remove rtw_merge_string() function The phy_Config*WithParaFile() functions were the only user of this function. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20191009123223.163241-4-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/osdep_service_linux.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index c582ede1ac12..a2d9de866c4b 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -127,13 +127,6 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev) netif_tx_stop_all_queues(pnetdev); } -static inline void rtw_merge_string(char *dst, int dst_len, char *src1, char *src2) -{ - int len = 0; - len += snprintf(dst+len, dst_len - len, "%s", src1); - len += snprintf(dst+len, dst_len - len, "%s", src2); -} - #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1) #define rtw_netdev_priv(netdev) (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv) -- cgit v1.2.3-59-g8ed1b From 38c077d7070c5a9808f55227bafde0999a91fe02 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 9 Oct 2019 14:32:23 +0200 Subject: staging: rtl8723bs: Remove File operation APIs rtl8723bs had 2 private file operation helpers: rtw_is_file_readable() rtw_retrive_from_file() These were only used by the removed phy_Config*WithParaFile() functions, so they can be removed now. Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20191009123223.163241-5-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/osdep_service.h | 4 - drivers/staging/rtl8723bs/os_dep/osdep_service.c | 136 ---------------------- 2 files changed, 140 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index 81a9c19ecc6a..a40cf7b60a69 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -171,10 +171,6 @@ extern void rtw_softap_lock_suspend(void); extern void rtw_softap_unlock_suspend(void); #endif -/* File operation APIs, just for linux now */ -extern int rtw_is_file_readable(char *path); -extern int rtw_retrive_from_file(char *path, u8 *buf, u32 sz); - extern void rtw_free_netdev(struct net_device * netdev); diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 25a80041ce87..f5614e56371e 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -65,142 +65,6 @@ void _rtw_init_queue(struct __queue *pqueue) spin_lock_init(&(pqueue->lock)); } -/* -* Open a file with the specific @param path, @param flag, @param mode -* @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success -* @param path the path of the file to open -* @param flag file operation flags, please refer to linux document -* @param mode please refer to linux document -* @return Linux specific error code -*/ -static int openFile(struct file **fpp, char *path, int flag, int mode) -{ - struct file *fp; - - fp = filp_open(path, flag, mode); - if (IS_ERR(fp)) { - *fpp = NULL; - return PTR_ERR(fp); - } - else { - *fpp = fp; - return 0; - } -} - -/* -* Close the file with the specific @param fp -* @param fp the pointer of struct file to close -* @return always 0 -*/ -static int closeFile(struct file *fp) -{ - filp_close(fp, NULL); - return 0; -} - -static int readFile(struct file *fp, char *buf, int len) -{ - int rlen = 0, sum = 0; - - if (!fp->f_op || !fp->f_op->read) - return -EPERM; - - while (sum < len) { - rlen = kernel_read(fp, buf + sum, len - sum, &fp->f_pos); - if (rlen > 0) - sum += rlen; - else if (0 != rlen) - return rlen; - else - break; - } - - return sum; - -} - -/* -* Test if the specifi @param path is a file and readable -* @param path the path of the file to test -* @return Linux specific error code -*/ -static int isFileReadable(char *path) -{ - struct file *fp; - int ret = 0; - char buf; - - fp = filp_open(path, O_RDONLY, 0); - if (IS_ERR(fp)) - return PTR_ERR(fp); - - if (readFile(fp, &buf, 1) != 1) - ret = -EINVAL; - - filp_close(fp, NULL); - return ret; -} - -/* -* Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most -* @param path the path of the file to open and read -* @param buf the starting address of the buffer to store file content -* @param sz how many bytes to read at most -* @return the byte we've read, or Linux specific error code -*/ -static int retriveFromFile(char *path, u8 *buf, u32 sz) -{ - int ret = -1; - struct file *fp; - - if (path && buf) { - ret = openFile(&fp, path, O_RDONLY, 0); - - if (ret == 0) { - DBG_871X("%s openFile path:%s fp =%p\n", __func__, path , fp); - - ret = readFile(fp, buf, sz); - closeFile(fp); - - DBG_871X("%s readFile, ret:%d\n", __func__, ret); - - } else { - DBG_871X("%s openFile path:%s Fail, ret:%d\n", __func__, path, ret); - } - } else { - DBG_871X("%s NULL pointer\n", __func__); - ret = -EINVAL; - } - return ret; -} - -/* -* Test if the specifi @param path is a file and readable -* @param path the path of the file to test -* @return true or false -*/ -int rtw_is_file_readable(char *path) -{ - if (isFileReadable(path) == 0) - return true; - else - return false; -} - -/* -* Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most -* @param path the path of the file to open and read -* @param buf the starting address of the buffer to store file content -* @param sz how many bytes to read at most -* @return the byte we've read -*/ -int rtw_retrive_from_file(char *path, u8 *buf, u32 sz) -{ - int ret = retriveFromFile(path, buf, sz); - return ret >= 0 ? ret : 0; -} - struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv) { struct net_device *pnetdev; -- cgit v1.2.3-59-g8ed1b From a9ce2354f7cbecf114a6bc6cd0734e7a9cc04e13 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 8 Oct 2019 19:24:36 -0500 Subject: staging: rtl8723bs: Fix line over 80 characters Break last two function call arguments into two separate lines. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/9a8f7b026780b3a7387c29f1d67a7c23d4b159eb.1570577926.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index a1f501655392..e3246a77e2a5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -217,7 +217,8 @@ void expire_timeout_chk(struct adapter *padapter) #ifdef DBG_EXPIRATION_CHK if (phead != plist) { DBG_871X(FUNC_NDEV_FMT" auth_list, cnt:%u\n" - , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->auth_list_cnt); + , FUNC_NDEV_ARG(padapter->pnetdev) + , pstapriv->auth_list_cnt); } #endif while (phead != plist) { -- cgit v1.2.3-59-g8ed1b From af2f2c5e20bff6137684d7100d84da2aaea37aed Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 8 Oct 2019 19:25:05 -0500 Subject: staging: rtl8723bs: Fix function call wrapping style Fix the wrapping style used for the function call. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/f43f9295d7412d610e278be608fba6f2cc14cac9.1570577926.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index e3246a77e2a5..cec2f9f2d5ca 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -216,9 +216,9 @@ void expire_timeout_chk(struct adapter *padapter) /* check auth_queue */ #ifdef DBG_EXPIRATION_CHK if (phead != plist) { - DBG_871X(FUNC_NDEV_FMT" auth_list, cnt:%u\n" - , FUNC_NDEV_ARG(padapter->pnetdev) - , pstapriv->auth_list_cnt); + DBG_871X(FUNC_NDEV_FMT" auth_list, cnt:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), + pstapriv->auth_list_cnt); } #endif while (phead != plist) { -- cgit v1.2.3-59-g8ed1b From c44b23f51f4c31688a035933ef4e0a193bee52ad Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 8 Oct 2019 19:25:45 -0500 Subject: staging: rtl8723bs: Add space between elements Concatenated strings should use spaces between elements. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/a2387d4c10c2ed0cbca9d5c7ded424892452178f.1570577926.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index cec2f9f2d5ca..80027ac765d0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -216,7 +216,7 @@ void expire_timeout_chk(struct adapter *padapter) /* check auth_queue */ #ifdef DBG_EXPIRATION_CHK if (phead != plist) { - DBG_871X(FUNC_NDEV_FMT" auth_list, cnt:%u\n", + DBG_871X(FUNC_NDEV_FMT " auth_list, cnt:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->auth_list_cnt); } -- cgit v1.2.3-59-g8ed1b From c9ca79b3a5b0e20eccc5fdcf1c08e56ebbe3d526 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 9 Oct 2019 18:19:56 -0500 Subject: staging: rtl8723bs: Fix incorrect type in declaration Fix incorrect type in declaration to solve the warnings 'incorrect type in argument 2' in the rtw_get_wpa_ie and rtw_get_wpa_ie function calls, as both expect the same variable in argument 2 with the type int *. Issue found by Sparse. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/20191009231953.GA8774@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 8e58763c8a8d..db6528a01229 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2430,7 +2430,8 @@ static int rtw_get_ap_info(struct net_device *dev, union iwreq_data *wrqu, char *extra) { int ret = 0; - u32 cnt = 0, wpa_ielen; + int wpa_ielen; + u32 cnt = 0; struct list_head *plist, *phead; unsigned char *pbuf; u8 bssid[ETH_ALEN]; -- cgit v1.2.3-59-g8ed1b From 26752254faebb268bc26ab43e29c118144149f11 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 9 Oct 2019 21:14:47 -0500 Subject: staging: rtl8723bs: Remove commented code Remove commented code for a cleaner file. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/132126f0d04d5ca1129e9d682dfe9a535ec7bb39.1570672544.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 33 -------------------------------- 1 file changed, 33 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 1267fe9f9af2..75b51e02293e 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -72,9 +72,6 @@ static u8 get_deviceid(u32 addr) devide_id = WLAN_IOREG_DEVICE_ID; break; -/* case 0x1027: */ -/* devide_id = SDIO_FIRMWARE_FIFO; */ -/* break; */ case 0x1031: devide_id = WLAN_TX_HIQ_DEVICE_ID; @@ -93,7 +90,6 @@ static u8 get_deviceid(u32 addr) break; default: -/* devide_id = (u8)((addr >> 13) & 0xF); */ devide_id = WLAN_IOREG_DEVICE_ID; break; } @@ -438,7 +434,6 @@ static u32 sdio_read_port( if (cnt > psdio->block_transfer_len) cnt = _RND(cnt, psdio->block_transfer_len); -/* cnt = sdio_align_size(cnt); */ err = _sd_read(intfhdl, addr, cnt, mem); @@ -488,7 +483,6 @@ static u32 sdio_write_port( if (cnt > psdio->block_transfer_len) cnt = _RND(cnt, psdio->block_transfer_len); -/* cnt = sdio_align_size(cnt); */ err = sd_write(intfhdl, addr, cnt, xmitbuf->pdata); @@ -752,22 +746,6 @@ void InitInterrupt8723BSdio(struct adapter *adapter) haldata->sdio_himr = (u32)( \ SDIO_HIMR_RX_REQUEST_MSK | SDIO_HIMR_AVAL_MSK | -/* SDIO_HIMR_TXERR_MSK | */ -/* SDIO_HIMR_RXERR_MSK | */ -/* SDIO_HIMR_TXFOVW_MSK | */ -/* SDIO_HIMR_RXFOVW_MSK | */ -/* SDIO_HIMR_TXBCNOK_MSK | */ -/* SDIO_HIMR_TXBCNERR_MSK | */ -/* SDIO_HIMR_BCNERLY_INT_MSK | */ -/* SDIO_HIMR_C2HCMD_MSK | */ -/* SDIO_HIMR_HSISR_IND_MSK | */ -/* SDIO_HIMR_GTINT3_IND_MSK | */ -/* SDIO_HIMR_GTINT4_IND_MSK | */ -/* SDIO_HIMR_PSTIMEOUT_MSK | */ -/* SDIO_HIMR_OCPINT_MSK | */ -/* SDIO_HIMR_ATIMEND_MSK | */ -/* SDIO_HIMR_ATIMEND_E_MSK | */ -/* SDIO_HIMR_CTWEND_MSK | */ 0); } @@ -785,11 +763,6 @@ void InitSysInterrupt8723BSdio(struct adapter *adapter) haldata = GET_HAL_DATA(adapter); haldata->SysIntrMask = ( \ -/* HSIMR_GPIO12_0_INT_EN | */ -/* HSIMR_SPS_OCP_INT_EN | */ -/* HSIMR_RON_INT_EN | */ -/* HSIMR_PDNINT_EN | */ -/* HSIMR_GPIO9_INT_EN | */ 0); } @@ -990,7 +963,6 @@ void sd_int_dpc(struct adapter *adapter) report.state = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_HCPWM1_8723B); - /* cpwm_int_hdl(adapter, &report); */ _set_workitem(&(pwrctl->cpwm_event)); } @@ -1053,7 +1025,6 @@ void sd_int_dpc(struct adapter *adapter) int alloc_fail_time = 0; u32 hisr; -/* DBG_8192C("%s: RX Request, size =%d\n", __func__, hal->SdioRxFIFOSize); */ hal->sdio_hisr ^= SDIO_HISR_RX_REQUEST; do { hal->SdioRxFIFOSize = SdioLocalCmd52Read2Byte(adapter, SDIO_REG_RX0_REQ_LEN); @@ -1131,14 +1102,12 @@ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter) { struct hal_com_data *hal; u32 numof_free_page; - /* _irql irql; */ hal = GET_HAL_DATA(adapter); numof_free_page = SdioLocalCmd53Read4Byte(adapter, SDIO_REG_FREE_TXPG); - /* spin_lock_bh(&phal->SdioTxFIFOFreePageLock); */ memcpy(hal->SdioTxFIFOFreePage, &numof_free_page, 4); RT_TRACE(_module_hci_ops_c_, _drv_notice_, ("%s: Free page for HIQ(%#x), MIDQ(%#x), LOWQ(%#x), PUBQ(%#x)\n", @@ -1147,7 +1116,6 @@ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter) hal->SdioTxFIFOFreePage[MID_QUEUE_IDX], hal->SdioTxFIFOFreePage[LOW_QUEUE_IDX], hal->SdioTxFIFOFreePage[PUBLIC_QUEUE_IDX])); - /* spin_unlock_bh(&hal->SdioTxFIFOFreePageLock); */ return true; } @@ -1188,7 +1156,6 @@ u8 RecvOnePkt(struct adapter *adapter, u32 size) recvbuf = sd_recv_rxfifo(adapter, size); if (recvbuf) { - /* printk("Completed Recv One Pkt.\n"); */ sd_rxhandler(adapter, recvbuf); res = true; } else { -- cgit v1.2.3-59-g8ed1b From 5bb48864d34c287e4285d7fcf1f352557f53656f Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 9 Oct 2019 21:16:07 -0500 Subject: staging: rtl8723bs: Remove duplicate blank lines Remove duplicate blank lines. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/cdc1899acadc436c2f0247ded9ec2a8b3423350e.1570672544.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 75b51e02293e..a1f2877ab360 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -61,7 +61,6 @@ static u8 get_deviceid(u32 addr) u8 devide_id; u16 pseudo_id; - pseudo_id = (u16)(addr >> 16); switch (pseudo_id) { case 0x1025: @@ -72,7 +71,6 @@ static u8 get_deviceid(u32 addr) devide_id = WLAN_IOREG_DEVICE_ID; break; - case 0x1031: devide_id = WLAN_TX_HIQ_DEVICE_ID; break; @@ -107,7 +105,6 @@ static u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset) u16 offset; u32 ftaddr; - device_id = get_deviceid(addr); offset = 0; @@ -425,7 +422,6 @@ static u32 sdio_read_port( struct hal_com_data *hal; s32 err; - adapter = intfhdl->padapter; psdio = &adapter_to_dvobj(adapter)->intf_data; hal = GET_HAL_DATA(adapter); @@ -530,7 +526,6 @@ static s32 _sdio_local_read( u8 *tmpbuf; u32 n; - intfhdl = &adapter->iopriv.intf; HalSdioGetCmdAddr8723BSdio(adapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); @@ -703,7 +698,6 @@ static s32 ReadInterrupt8723BSdio(struct adapter *adapter, u32 *phisr) u32 hisr, himr; u8 val8, hisr_len; - if (!phisr) return false; @@ -741,7 +735,6 @@ void InitInterrupt8723BSdio(struct adapter *adapter) { struct hal_com_data *haldata; - haldata = GET_HAL_DATA(adapter); haldata->sdio_himr = (u32)( \ SDIO_HIMR_RX_REQUEST_MSK | @@ -759,7 +752,6 @@ void InitSysInterrupt8723BSdio(struct adapter *adapter) { struct hal_com_data *haldata; - haldata = GET_HAL_DATA(adapter); haldata->SysIntrMask = ( \ @@ -867,7 +859,6 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size) struct recv_priv *recv_priv; struct recv_buf *recvbuf; - /* Patch for some SDIO Host 4 bytes issue */ /* ex. RK3188 */ readsize = RND4(size); @@ -909,7 +900,6 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size) return NULL; } - /* 3 4. init recvbuf */ recvbuf->len = size; recvbuf->phead = recvbuf->pskb->head; @@ -943,7 +933,6 @@ void sd_int_dpc(struct adapter *adapter) struct intf_hdl *intfhdl = &adapter->iopriv.intf; struct pwrctrl_priv *pwrctl; - hal = GET_HAL_DATA(adapter); dvobj = adapter_to_dvobj(adapter); pwrctl = dvobj_to_pwrctl(dvobj); @@ -1019,7 +1008,6 @@ void sd_int_dpc(struct adapter *adapter) if (hal->sdio_hisr & SDIO_HISR_RXERR) DBG_8192C("%s: Rx Error\n", __func__); - if (hal->sdio_hisr & SDIO_HISR_RX_REQUEST) { struct recv_buf *recvbuf; int alloc_fail_time = 0; @@ -1059,7 +1047,6 @@ void sd_int_hdl(struct adapter *adapter) { struct hal_com_data *hal; - if ( (adapter->bDriverStopped) || (adapter->bSurpriseRemoved) ) @@ -1103,7 +1090,6 @@ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter) struct hal_com_data *hal; u32 numof_free_page; - hal = GET_HAL_DATA(adapter); numof_free_page = SdioLocalCmd53Read4Byte(adapter, SDIO_REG_FREE_TXPG); -- cgit v1.2.3-59-g8ed1b From 042e9a6857b8b767f8507eaee537a987acc5eabf Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 9 Oct 2019 21:16:29 -0500 Subject: staging: rtl8723bs: Remove space before tabs Remove space before tabs to fix checkpatch warning. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/120800f884986092ca757235781d9ddc740ec832.1570672544.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 66 ++++++++++++++++---------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index a1f2877ab360..0bd32808c74b 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -15,7 +15,7 @@ /* */ /* Description: */ -/* The following mapping is for SDIO host local register space. */ +/* The following mapping is for SDIO host local register space. */ /* */ /* Creadted by Roger, 2011.01.31. */ /* */ @@ -723,13 +723,13 @@ static s32 ReadInterrupt8723BSdio(struct adapter *adapter, u32 *phisr) } /* */ -/* Description: */ -/* Initialize SDIO Host Interrupt Mask configuration variables for future use. */ +/* Description: */ +/* Initialize SDIO Host Interrupt Mask configuration variables for future use. */ /* */ -/* Assumption: */ -/* Using SDIO Local register ONLY for configuration. */ +/* Assumption: */ +/* Using SDIO Local register ONLY for configuration. */ /* */ -/* Created by Roger, 2011.02.11. */ +/* Created by Roger, 2011.02.11. */ /* */ void InitInterrupt8723BSdio(struct adapter *adapter) { @@ -743,10 +743,10 @@ void InitInterrupt8723BSdio(struct adapter *adapter) } /* */ -/* Description: */ -/* Initialize System Host Interrupt Mask configuration variables for future use. */ +/* Description: */ +/* Initialize System Host Interrupt Mask configuration variables for future use. */ /* */ -/* Created by Roger, 2011.08.03. */ +/* Created by Roger, 2011.08.03. */ /* */ void InitSysInterrupt8723BSdio(struct adapter *adapter) { @@ -759,14 +759,14 @@ void InitSysInterrupt8723BSdio(struct adapter *adapter) } /* */ -/* Description: */ -/* Enalbe SDIO Host Interrupt Mask configuration on SDIO local domain. */ +/* Description: */ +/* Enalbe SDIO Host Interrupt Mask configuration on SDIO local domain. */ /* */ -/* Assumption: */ -/* 1. Using SDIO Local register ONLY for configuration. */ -/* 2. PASSIVE LEVEL */ +/* Assumption: */ +/* 1. Using SDIO Local register ONLY for configuration. */ +/* 2. PASSIVE LEVEL */ /* */ -/* Created by Roger, 2011.02.11. */ +/* Created by Roger, 2011.02.11. */ /* */ void EnableInterrupt8723BSdio(struct adapter *adapter) { @@ -812,13 +812,13 @@ void EnableInterrupt8723BSdio(struct adapter *adapter) } /* */ -/* Description: */ -/* Disable SDIO Host IMR configuration to mask unnecessary interrupt service. */ +/* Description: */ +/* Disable SDIO Host IMR configuration to mask unnecessary interrupt service. */ /* */ -/* Assumption: */ -/* Using SDIO Local register ONLY for configuration. */ +/* Assumption: */ +/* Using SDIO Local register ONLY for configuration. */ /* */ -/* Created by Roger, 2011.02.11. */ +/* Created by Roger, 2011.02.11. */ /* */ void DisableInterrupt8723BSdio(struct adapter *adapter) { @@ -829,13 +829,13 @@ void DisableInterrupt8723BSdio(struct adapter *adapter) } /* */ -/* Description: */ -/* Using 0x100 to check the power status of FW. */ +/* Description: */ +/* Using 0x100 to check the power status of FW. */ /* */ -/* Assumption: */ -/* Using SDIO Local register ONLY for configuration. */ +/* Assumption: */ +/* Using SDIO Local register ONLY for configuration. */ /* */ -/* Created by Isaac, 2013.09.10. */ +/* Created by Isaac, 2013.09.10. */ /* */ u8 CheckIPSStatus(struct adapter *adapter) { @@ -1076,14 +1076,14 @@ void sd_int_hdl(struct adapter *adapter) } /* */ -/* Description: */ -/* Query SDIO Local register to query current the number of Free TxPacketBuffer page. */ +/* Description: */ +/* Query SDIO Local register to query current the number of Free TxPacketBuffer page. */ /* */ -/* Assumption: */ -/* 1. Running at PASSIVE_LEVEL */ -/* 2. RT_TX_SPINLOCK is NOT acquired. */ +/* Assumption: */ +/* 1. Running at PASSIVE_LEVEL */ +/* 2. RT_TX_SPINLOCK is NOT acquired. */ /* */ -/* Created by Roger, 2011.01.28. */ +/* Created by Roger, 2011.01.28. */ /* */ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter) { @@ -1107,8 +1107,8 @@ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter) } /* */ -/* Description: */ -/* Query SDIO Local register to get the current number of TX OQT Free Space. */ +/* Description: */ +/* Query SDIO Local register to get the current number of TX OQT Free Space. */ /* */ void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *adapter) { -- cgit v1.2.3-59-g8ed1b From ac478ce77304e81c706588eebcb2a54bc459b863 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 9 Oct 2019 21:16:49 -0500 Subject: staging: rtl8723bs: Fix style in definitions Fix the style in definitions where commented code was previously removed for an improved code readability. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/fc488562c0ddf3fa8a59e86be9b33506496ccd0c.1570672544.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 0bd32808c74b..5ecd1c873871 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -736,10 +736,9 @@ void InitInterrupt8723BSdio(struct adapter *adapter) struct hal_com_data *haldata; haldata = GET_HAL_DATA(adapter); - haldata->sdio_himr = (u32)( \ - SDIO_HIMR_RX_REQUEST_MSK | - SDIO_HIMR_AVAL_MSK | - 0); + haldata->sdio_himr = (u32)(SDIO_HIMR_RX_REQUEST_MSK | + SDIO_HIMR_AVAL_MSK | + 0); } /* */ @@ -754,8 +753,7 @@ void InitSysInterrupt8723BSdio(struct adapter *adapter) haldata = GET_HAL_DATA(adapter); - haldata->SysIntrMask = ( \ - 0); + haldata->SysIntrMask = (0); } /* */ -- cgit v1.2.3-59-g8ed1b From 06f9c65a8dd46f375de62868e89eb645a76eb0fc Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Tue, 8 Oct 2019 22:53:50 +0300 Subject: staging: rtl8712: Align function arguments with opening paranthesis Fixes checkpatch.pl "CHECK Alignment should match open parenthesis" on drivers/staging/rtl8712/rtl8712_recv.c:122 Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191008195350.20544-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 9901815604f4..af12c16d6468 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -119,7 +119,7 @@ void r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf) } void r8712_free_recvframe(union recv_frame *precvframe, - struct __queue *pfree_recv_queue) + struct __queue *pfree_recv_queue) { unsigned long irqL; struct _adapter *padapter = precvframe->u.hdr.adapter; -- cgit v1.2.3-59-g8ed1b From fbf12784d3434ebd35a9712e649b52fd14d2fbb2 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Thu, 10 Oct 2019 07:38:15 +0300 Subject: staging: octeon: Fix incorrect type in assignment Fix the following warning generated by sparse in drivers/staging/octeon/ethernet-tx.c: drivers/staging/octeon/ethernet-tx.c:563:50: warning: incorrect type in assignment (different base types) drivers/staging/octeon/ethernet-tx.c:563:50: expected unsigned short [usertype] hw_chksum drivers/staging/octeon/ethernet-tx.c:563:50: got restricted __wsum [usertype] csum Warning generated by running: make C=2 CF="-D__CHECK_ENDIAN__" drivers/staging/octeon/ Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191010043815.14027-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index 38954b6c89e1..b2e3c72205dd 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -123,7 +123,7 @@ union cvmx_pip_wqe_word0 { struct { uint64_t next_ptr:40; uint8_t unused; - uint16_t hw_chksum; + __wsum hw_chksum; } cn38xx; struct { uint64_t pknd:6; /* 0..5 */ -- cgit v1.2.3-59-g8ed1b From f595f03bfdfc3ce4526a653174024250d7287a8d Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 9 Oct 2019 23:04:27 +0800 Subject: staging: clocking-wizard: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191009150427.10852-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c index 15b7a82f4b1e..e52a64be93f3 100644 --- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c +++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c @@ -135,7 +135,6 @@ static int clk_wzrd_probe(struct platform_device *pdev) unsigned long rate; const char *clk_name; struct clk_wzrd *clk_wzrd; - struct resource *mem; struct device_node *np = pdev->dev.of_node; clk_wzrd = devm_kzalloc(&pdev->dev, sizeof(*clk_wzrd), GFP_KERNEL); @@ -143,8 +142,7 @@ static int clk_wzrd_probe(struct platform_device *pdev) return -ENOMEM; platform_set_drvdata(pdev, clk_wzrd); - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - clk_wzrd->base = devm_ioremap_resource(&pdev->dev, mem); + clk_wzrd->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(clk_wzrd->base)) return PTR_ERR(clk_wzrd->base); -- cgit v1.2.3-59-g8ed1b From 039f8b21d153aea4b413636d66619d53b725fc86 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 9 Oct 2019 23:05:35 +0800 Subject: staging: emxx_udc: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191009150535.6412-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 147481bf680c..9e0c19eb867c 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -3078,7 +3078,6 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) { int status = -ENODEV; struct nbu2ss_udc *udc; - struct resource *r; int irq; void __iomem *mmio_base; @@ -3088,8 +3087,7 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) platform_set_drvdata(pdev, udc); /* require I/O memory and IRQ to be provided as resources */ - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mmio_base = devm_ioremap_resource(&pdev->dev, r); + mmio_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(mmio_base)) return PTR_ERR(mmio_base); -- cgit v1.2.3-59-g8ed1b From 161ca4c0feeb983245e40355d9eb1101529326a8 Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Tue, 8 Oct 2019 19:44:15 -0700 Subject: staging: vc04_services: Avoid NULL comparison Remove NULL comparison. Issue found using checkpatch.pl Signed-off-by: Nachammai Karuppiah Link: https://lore.kernel.org/r/1570589056-14386-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_2835_arm.c | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 22 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 6559f0e50db1..b86d7e436357 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -524,11 +524,11 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) return NULL; } - WARN_ON(g_free_fragments == NULL); + WARN_ON(!g_free_fragments); down(&g_free_fragments_mutex); fragments = g_free_fragments; - WARN_ON(fragments == NULL); + WARN_ON(!fragments); g_free_fragments = *(char **) g_free_fragments; up(&g_free_fragments_mutex); pagelist->type = PAGELIST_READ_WITH_FRAGMENTS + diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 280e237e3b42..dc54f443ef3d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -827,7 +827,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* Remove all services */ i = 0; while ((service = next_service_by_instance(instance->state, - instance, &i)) != NULL) { + instance, &i))) { status = vchiq_remove_service(service->handle); unlock_service(service); if (status != VCHIQ_SUCCESS) @@ -907,7 +907,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &args.params, srvstate, instance, user_service_free); - if (service != NULL) { + if (service) { user_service->service = service; user_service->userdata = userdata; user_service->instance = instance; @@ -988,7 +988,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; service = find_service_for_instance(instance, handle); - if (service != NULL) { + if (service) { status = (cmd == VCHIQ_IOC_USE_SERVICE) ? vchiq_use_service_internal(service) : vchiq_release_service_internal(service); @@ -1021,7 +1021,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) service = find_service_for_instance(instance, args.handle); - if ((service != NULL) && (args.count <= MAX_ELEMENTS)) { + if (service && (args.count <= MAX_ELEMENTS)) { /* Copy elements into kernel space */ struct vchiq_element elements[MAX_ELEMENTS]; @@ -1343,11 +1343,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) spin_unlock(&msg_queue_spinlock); complete(&user_service->remove_event); - if (header == NULL) + if (!header) ret = -ENOTCONN; else if (header->size <= args.bufsize) { /* Copy to user space if msgbuf is not NULL */ - if ((args.buf == NULL) || + if (!args.buf || (copy_to_user((void __user *)args.buf, header->data, header->size) == 0)) { @@ -1426,7 +1426,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; service = find_closed_service_for_instance(instance, handle); - if (service != NULL) { + if (service) { struct user_service *user_service = (struct user_service *)service->base.userdata; close_delivered(user_service); @@ -2223,13 +2223,13 @@ struct vchiq_state * vchiq_get_state(void) { - if (g_state.remote == NULL) + if (!g_state.remote) printk(KERN_ERR "%s: g_state.remote == NULL\n", __func__); else if (g_state.remote->initialised != 1) printk(KERN_NOTICE "%s: g_state.remote->initialised != 1 (%d)\n", __func__, g_state.remote->initialised); - return ((g_state.remote != NULL) && + return (g_state.remote && (g_state.remote->initialised == 1)) ? &g_state : NULL; } @@ -2924,7 +2924,7 @@ vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance) i = 0; while ((service = next_service_by_instance(instance->state, - instance, &i)) != NULL) { + instance, &i))) { use_count += service->service_use_count; unlock_service(service); } @@ -2951,7 +2951,7 @@ vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace) i = 0; while ((service = next_service_by_instance(instance->state, - instance, &i)) != NULL) { + instance, &i))) { service->trace = trace; unlock_service(service); } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 663cc0f090cd..e1898cfa5e91 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -542,7 +542,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) if (space > slot_space) { struct vchiq_header *header; /* Fill the remaining space with padding */ - WARN_ON(state->tx_data == NULL); + WARN_ON(!state->tx_data); header = (struct vchiq_header *) (state->tx_data + (tx_pos & VCHIQ_SLOT_MASK)); header->msgid = VCHIQ_MSGID_PADDING; @@ -3575,7 +3575,7 @@ void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, } *s++ = '\0'; - if ((label != NULL) && (*label != '\0')) + if (label && (*label != '\0')) vchiq_log_trace(VCHIQ_LOG_TRACE, "%s: %08x: %s", label, addr, line_buf); else diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 575e2daedc89..5e26f0abd5ee 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -628,7 +628,7 @@ int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, } } - return (service != NULL) ? 0 : -1; + return service ? 0 : -1; } EXPORT_SYMBOL(vchi_service_open); -- cgit v1.2.3-59-g8ed1b From d13cf9eae44414120e67d83229d981408c5ddafa Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 10 Oct 2019 10:57:48 +0100 Subject: staging: wfx: fix spelling mistake "non existant" -> "non-existent" There is a spelling mistake in a dev_warn message. Fix it. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20191010095748.17047-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 52db02d3aa41..36e171b27ae2 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -137,7 +137,7 @@ static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi struct hif_ind_rx *body = buf; if (!wvif) { - dev_warn(wdev->dev, "ignore rx data for non existant vif %d\n", hif->interface); + dev_warn(wdev->dev, "ignore rx data for non-existent vif %d\n", hif->interface); return 0; } skb_pull(skb, sizeof(struct hif_msg) + sizeof(struct hif_ind_rx)); -- cgit v1.2.3-59-g8ed1b From 409e8332037898dbc5713f9a5285e3c539ab931b Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Thu, 10 Oct 2019 16:15:29 +0300 Subject: staging: rtl8723bs: Remove comparisons to NULL in conditionals Remove most comparisons to NULL in conditionals in drivers/staging/rtl8723bs/core/rtw_mlme.c Issues reported by checkpatch.pl as: CHECK: Comparison to NULL could be written Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/f4752d3a49e02193ed7b47a353e18e56d94b5a68.1570712632.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 50 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index a03cc005f053..b0018fe7bae3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -40,7 +40,7 @@ int rtw_init_mlme_priv(struct adapter *padapter) pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network))); - if (pbuf == NULL) { + if (!pbuf) { res = _FAIL; goto exit; } @@ -185,7 +185,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor /* _irqL irqL; */ struct __queue *free_queue = &(pmlmepriv->free_bss_pool); - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed == true) @@ -220,7 +220,7 @@ void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network * struct __queue *free_queue = &(pmlmepriv->free_bss_pool); - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed == true) @@ -633,7 +633,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t /* If there are no more slots, expire the oldest */ /* list_del_init(&oldest->list); */ pnetwork = oldest; - if (pnetwork == NULL) { + if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); goto exit; } @@ -654,7 +654,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ - if (pnetwork == NULL) { + if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); goto exit; } @@ -738,7 +738,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL) + if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -1166,7 +1166,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); - if (psta == NULL) { + if (!psta) { psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); } @@ -1413,7 +1413,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); - if (ptarget_sta == NULL) { + if (!ptarget_sta) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); goto ignore_joinbss_callback; @@ -1503,7 +1503,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u3 { u16 media_status_rpt; - if (psta == NULL) + if (!psta) return; media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /* MACID|OPMODE:1 connect */ @@ -1561,7 +1561,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) /* for AD-HOC mode */ psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta != NULL) { + if (psta) { /* the sta have been in sta_info_queue => do nothing */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); @@ -1570,7 +1570,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) } psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); return; } @@ -1993,7 +1993,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) struct wlan_network *pnetwork = NULL; struct wlan_network *candidate = NULL; - if (mlme->cur_network_scanned == NULL) { + if (!mlme->cur_network_scanned) { rtw_warn_on(1); return ret; } @@ -2006,7 +2006,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) while (phead != mlme->pscanned) { pnetwork = LIST_CONTAINOR(mlme->pscanned, struct wlan_network, list); - if (pnetwork == NULL) { + if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__)); ret = _FAIL; goto exit; @@ -2024,7 +2024,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) } - if (candidate == NULL) { + if (!candidate) { DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__); ret = _FAIL; goto exit; @@ -2141,7 +2141,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) while (phead != pmlmepriv->pscanned) { pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); - if (pnetwork == NULL) { + if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__)); ret = _FAIL; goto exit; @@ -2159,7 +2159,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) } - if (candidate == NULL) { + if (!candidate) { DBG_871X("%s: return _FAIL(candidate == NULL)\n", __func__); #ifdef CONFIG_WOWLAN _clr_fwstate_(pmlmepriv, _FW_LINKED|_FW_UNDER_LINKING); @@ -2200,14 +2200,14 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) sint res = _SUCCESS; pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; /* try again */ goto exit; } psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm)); - if (psetauthparm == NULL) { - kfree(pcmd); + if (!psetauthparm) { + kfree((unsigned char *)pcmd); res = _FAIL; goto exit; } @@ -2240,7 +2240,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s sint res = _SUCCESS; psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm)); - if (psetkeyparm == NULL) { + if (!psetkeyparm) { res = _FAIL; goto exit; } @@ -2291,8 +2291,8 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s if (enqueue) { pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { - kfree(psetkeyparm); + if (!pcmd) { + kfree((unsigned char *)psetkeyparm); res = _FAIL; /* try again */ goto exit; } @@ -2672,7 +2672,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_SGI_20); /* Get HT BW */ - if (in_ie == NULL) { + if (!in_ie) { /* TDLS: TODO 20/40 issue */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { operation_bw = padapter->mlmeextpriv.cur_bwmode; @@ -2787,7 +2787,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ phtpriv->ht_option = true; - if (in_ie != NULL) { + if (in_ie) { p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; @@ -2954,7 +2954,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr return; } - if (psta == NULL) { + if (!psta) { DBG_871X("%s, psta ==NUL\n", __func__); return; } -- cgit v1.2.3-59-g8ed1b From 92f87db5a964d4450264e97480addf1552c9e9bf Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Thu, 10 Oct 2019 16:15:30 +0300 Subject: staging: rtl8723bs: Remove unnecessary braces for single statements Clean up multiple unnecessary braces around single statement blocks in drivers/staging/rtl8723bs/core/rtw_mlme.c Issues reported by checkpatch.pl as: WARNING: braces {} are not necessary for single statement blocks or WARNING: braces {} are not necessary for any arm of this statement Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/c459741e8dc51dc2283fc69f07ed947e2994d0e9.1570712632.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 37 ++++++++++--------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index b0018fe7bae3..52f490d5ebfb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -112,9 +112,8 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { if (pmlmepriv) { rtw_free_mlme_priv_ie_data(pmlmepriv); - if (pmlmepriv->free_bss_buf) { + if (pmlmepriv->free_bss_buf) vfree(pmlmepriv->free_bss_buf); - } } } @@ -753,11 +752,10 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) { p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) { + if (p && ie_len > 0) bselected = true; - } else { + else bselected = false; - } } } @@ -822,9 +820,8 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* lock pmlmepriv->lock when you accessing network_q */ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { - if (pnetwork->Ssid.Ssid[0] == 0) { + if (pnetwork->Ssid.Ssid[0] == 0) pnetwork->Ssid.SsidLength = 0; - } rtw_add_network(adapter, pnetwork); } @@ -893,9 +890,8 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; - if (rtw_createbss_cmd(adapter) != _SUCCESS) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n")); - } + if (rtw_createbss_cmd(adapter) != _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n")); pmlmepriv->to_join = false; } @@ -1166,9 +1162,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); - if (!psta) { + if (!psta) psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); - } if (psta) { /* update ptarget_sta */ @@ -1347,11 +1342,10 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) rtw_get_encrypt_decrypt_from_registrypriv(adapter); - if (pmlmepriv->assoc_ssid.SsidLength == 0) { + if (pmlmepriv->assoc_ssid.SsidLength == 0) RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); - } else { + else RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - } the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); @@ -1723,13 +1717,8 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); } - if (rtw_createbss_cmd(adapter) != _SUCCESS) { - + if (rtw_createbss_cmd(adapter) != _SUCCESS) RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status FAIL***\n ")); - - } - - } } @@ -1902,9 +1891,8 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) } } else { - if (is_primary_adapter(adapter)) { + if (is_primary_adapter(adapter)) rtw_dynamic_chk_wk_cmd(adapter); - } } /* auto site survey */ @@ -2988,9 +2976,8 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 *out_ie, uint *pout_len u8 *pframe; - if (phtpriv->bss_coexist) { + if (phtpriv->bss_coexist) SET_EXT_CAPABILITY_ELE_BSS_COEXIST(cap_content, 1); - } pframe = rtw_set_ie(out_ie + *pout_len, EID_EXTCapability, 8, cap_content, pout_len); } -- cgit v1.2.3-59-g8ed1b From e7e12d6650ec16f4fa88674c523f000d5a1fa8ea Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Thu, 10 Oct 2019 16:15:31 +0300 Subject: staging: rtl8723bs: Remove comparisons to booleans in conditionals. Remove comparisons to true and false in multiple if statements in drivers/staging/rtl8723bs/core/rtw_mlme.c Issues reported by checkpatch.pl as: CHECK: Using comparison to false is error prone CHECK: Using comparison to true is error prone Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/d97eaa803566c15a2658df10cf2ca77acddea7fb.1570712632.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 52f490d5ebfb..7ec693a38396 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -187,7 +187,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor if (!pnetwork) return; - if (pnetwork->fixed == true) + if (pnetwork->fixed) return; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || @@ -222,7 +222,7 @@ void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network * if (!pnetwork) return; - if (pnetwork->fixed == true) + if (pnetwork->fixed) return; /* spin_lock_irqsave(&free_queue->lock, irqL); */ @@ -480,7 +480,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) pwlan = LIST_CONTAINOR(plist, struct wlan_network, list); - if (pwlan->fixed != true) { + if (!pwlan->fixed) { if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) oldest = pwlan; } @@ -867,7 +867,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) rtw_set_signal_stat_timer(&adapter->recvpriv); - if (pmlmepriv->to_join == true) { + if (pmlmepriv->to_join) { if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); @@ -1368,7 +1368,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { - if (the_same_macaddr == true) { + if (the_same_macaddr) { ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); } else { pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); @@ -1843,7 +1843,7 @@ static void rtw_auto_scan_handler(struct adapter *padapter) goto exit; } - if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) { + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", FUNC_ADPT_ARG(padapter)); goto exit; } @@ -1863,20 +1863,20 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) if (!adapter) return; - if (adapter->hw_init_completed == false) + if (!adapter->hw_init_completed) return; - if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == true)) + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) return; - if (adapter->net_closed == true) + if (adapter->net_closed) return; if (is_primary_adapter(adapter)) DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter)); - if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true) - && (hal_btcoex_IsBtControlLps(adapter) == false) + if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode) + && !(hal_btcoex_IsBtControlLps(adapter)) ) { u8 bEnterPS; @@ -2047,7 +2047,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme /* check bssid, if needed */ - if (mlme->assoc_by_bssid == true) { + if (mlme->assoc_by_bssid) { if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, ETH_ALEN)) goto exit; } @@ -2805,7 +2805,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 cbw40_enable = 0; - if (!phtpriv->ht_option) return; @@ -2815,7 +2814,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe DBG_871X("+rtw_update_ht_cap()\n"); /* maybe needs check if ap supports rx ampdu. */ - if ((phtpriv->ampdu_enable == false) && (pregistrypriv->ampdu_enable == 1)) { + if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == 1) { if (pregistrypriv->wifi_spec == 1) { /* remove this part because testbed AP should disable RX AMPDU */ /* phtpriv->ampdu_enable = false; */ @@ -2955,7 +2954,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr phtpriv = &psta->htpriv; - if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) { + if (phtpriv->ht_option && phtpriv->ampdu_enable) { issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; -- cgit v1.2.3-59-g8ed1b From 2e821be2206ca03168e35dd9fd1f77fbb9faf0f1 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Thu, 10 Oct 2019 16:15:32 +0300 Subject: staging: rtl8723bs: Remove unnecessary blank lines Remove multiple blank lines in drivers/staging/rtl8723bs/core/rtw_mlme.c. Issues reported by checkpatch.pl as: CHECK: Please don't use multiple blank lines Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/50abec172689dfa413437589745032d678b82d04.1570712632.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 47 ------------------------------- 1 file changed, 47 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 7ec693a38396..3030ae5b6b6d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -208,7 +208,6 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor pmlmepriv->num_of_scanned--; - /* DBG_871X("_rtw_free_network:SSID =%s\n", pnetwork->network.Ssid.Ssid); */ spin_unlock_bh(&free_queue->lock); @@ -300,12 +299,8 @@ void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) spin_unlock_bh(&scanned_queue->lock); } - - - sint rtw_if_up(struct adapter *padapter) { - sint res; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || @@ -317,7 +312,6 @@ sint rtw_if_up(struct adapter *padapter) return res; } - void rtw_generate_random_ibss(u8 *pibss) { unsigned long curtime = jiffies; @@ -335,7 +329,6 @@ u8 *rtw_get_capability_from_ie(u8 *ie) return ie + 8 + 2; } - u16 rtw_get_capability(struct wlan_bssid_ex *bss) { __le16 val; @@ -423,7 +416,6 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 fea memcpy((u8 *)&tmps, rtw_get_capability_from_ie(src->IEs), 2); memcpy((u8 *)&tmpd, rtw_get_capability_from_ie(dst->IEs), 2); - s_cap = le16_to_cpu(tmps); d_cap = le16_to_cpu(tmpd); @@ -465,7 +457,6 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) { struct list_head *plist, *phead; - struct wlan_network *pwlan = NULL; struct wlan_network *oldest = NULL; @@ -577,12 +568,8 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex } } - /* - Caller must hold pmlmepriv->lock first. - - */ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target) { @@ -623,7 +610,6 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t } - /* If we didn't find a match, then get a new network slot to initialize * with this beacon's information */ /* if (phead == plist) { */ @@ -759,7 +745,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor } } - if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { DBG_871X("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); bselected = false; @@ -770,7 +755,6 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor bselected = false; } - return bselected; } @@ -780,7 +764,6 @@ void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf) RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_event\n")); } - void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) { u32 len; @@ -797,7 +780,6 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) return; } - spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ @@ -830,8 +812,6 @@ exit: spin_unlock_bh(&pmlmepriv->lock); } - - void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { u8 timer_cancelled = false; @@ -862,7 +842,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (timer_cancelled) _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); - spin_lock_bh(&pmlmepriv->lock); rtw_set_signal_stat_timer(&adapter->recvpriv); @@ -1002,7 +981,6 @@ static void find_network(struct adapter *adapter) else RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_assoc_resources : pwlan == NULL\n\n")); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1)) rtw_free_network_nolock(adapter, pwlan); @@ -1181,7 +1159,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str psta->wireless_mode = pmlmeext->cur_wireless_mode; psta->raid = networktype_to_raid_ex(padapter, psta); - /* sta mode */ rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); @@ -1213,7 +1190,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str padapter->securitypriv.wps_ie_len = 0; } - /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ /* if A-MPDU Rx is enabled, resetting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ /* todo: check if AP can send A-MPDU packets */ @@ -1230,7 +1206,6 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str preorder_ctrl->wsize_b = 64;/* max_ampdu_sz;ex. 32(kbytes) -> wsize_b =32 */ } - bmc_sta = rtw_get_bcmc_stainfo(padapter); if (bmc_sta) { for (i = 0; i < 16 ; i++) { @@ -1264,7 +1239,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:"MAC_FMT"\n" , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress))); - /* why not use ptarget_wlan?? */ memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ @@ -1273,7 +1247,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net cur_network->aid = pnetwork->join_res; - rtw_set_signal_stat_timer(&padapter->recvpriv); padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; @@ -1341,7 +1314,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) rtw_get_encrypt_decrypt_from_registrypriv(adapter); - if (pmlmepriv->assoc_ssid.SsidLength == 0) RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); else @@ -1403,7 +1375,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) goto ignore_joinbss_callback; } - /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); @@ -1423,7 +1394,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); } - /* s5. Cancel assoc_timer */ _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); @@ -1582,7 +1552,6 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; - psta->ieee8021x_blocked = false; spin_lock_bh(&pmlmepriv->lock); @@ -1603,7 +1572,6 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); - mlmeext_sta_add_event_callback(adapter, psta); } @@ -1639,7 +1607,6 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) return; - mlmeext_sta_del_event_callback(adapter); spin_lock_bh(&pmlmepriv->lock); @@ -1736,7 +1703,6 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) cpwm_int_hdl(padapter, preportpwrstate); } - void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf) { WMMOnAssocRsp(padapter); @@ -1899,7 +1865,6 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) rtw_auto_scan_handler(adapter); } - inline bool rtw_is_scan_deny(struct adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; @@ -2045,7 +2010,6 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme int updated = false; struct adapter *adapter = container_of(mlme, struct adapter, mlmepriv); - /* check bssid, if needed */ if (mlme->assoc_by_bssid) { if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, ETH_ALEN)) @@ -2096,12 +2060,8 @@ exit: /* Calling context: The caller of the sub-routine will be in critical section... - The caller must hold the following spinlock - pmlmepriv->lock - - */ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) @@ -2208,7 +2168,6 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) pcmd->rsp = NULL; pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("after enqueue set_auth_cmd, auth_mode =%x\n", psecuritypriv->dot11AuthAlgrthm)); @@ -2276,7 +2235,6 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s goto exit; } - if (enqueue) { pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (!pcmd) { @@ -2331,7 +2289,6 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ } - /* */ /* Ported from 8185: IsInPreAuthKeyList(). (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) */ /* Added by Annie, 2006-05-07. */ @@ -2827,7 +2784,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe /* phtpriv->ampdu_enable = true; */ } - /* check Max Rx A-MPDU Size */ len = 0; p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); @@ -2841,7 +2797,6 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe } - len = 0; p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); if (p && len > 0) { @@ -2951,7 +2906,6 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr return; } - phtpriv = &psta->htpriv; if (phtpriv->ht_option && phtpriv->ampdu_enable) { @@ -2974,7 +2928,6 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 *out_ie, uint *pout_len u8 cap_content[8] = {0}; u8 *pframe; - if (phtpriv->bss_coexist) SET_EXT_CAPABILITY_ELE_BSS_COEXIST(cap_content, 1); -- cgit v1.2.3-59-g8ed1b From 0fa79a78b1d7e671f889b41a981c229075cbfb36 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Thu, 10 Oct 2019 23:33:25 +0800 Subject: staging: rtl8723bs: Remove unnecessary null check Null check before kfree is redundant, so remove it. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191010153325.16836-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index cb4c86728d26..47e984d5b7cb 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -1121,8 +1121,7 @@ void rtw_ndev_destructor(struct net_device *ndev) { DBG_871X(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); - if (ndev->ieee80211_ptr) - kfree(ndev->ieee80211_ptr); + kfree(ndev->ieee80211_ptr); } void rtw_dev_unload(struct adapter *padapter) -- cgit v1.2.3-59-g8ed1b From 52c4326a56ec69920062593086451f082ce66f33 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 10 Oct 2019 18:21:14 +0100 Subject: staging: qlge: correct a misspelled word Fix a misspelling of "several" detected by checkpatch Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191010172114.12345-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 7e16066a3527..a743971e5782 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -354,7 +354,7 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 *buf, for (i = PAUSE_SRC_LO; i < XGMAC_REGISTER_END; i += 4, buf++) { /* We're reading 400 xgmac registers, but we filter out - * serveral locations that are non-responsive to reads. + * several locations that are non-responsive to reads. */ if ((i == 0x00000114) || (i == 0x00000118) || -- cgit v1.2.3-59-g8ed1b From a8bfbd7cf3fd507e83e296d61b8b59755864413b Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 10 Oct 2019 22:40:03 +0100 Subject: staging: qlge: fix "alignment should match open parenthesis" checks Fix "alignment should mactch open parenthesis" checks issued by checkpatch.pl tool: "CHECK: Alignment should match open parenthesis". Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191010214006.23677-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 182 ++++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 91 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index a743971e5782..a6ac9f796d81 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -7,7 +7,7 @@ /* Read a NIC register from the alternate function. */ static u32 ql_read_other_func_reg(struct ql_adapter *qdev, - u32 reg) + u32 reg) { u32 register_to_read; u32 reg_val; @@ -26,7 +26,7 @@ static u32 ql_read_other_func_reg(struct ql_adapter *qdev, /* Write a NIC register from the alternate function. */ static int ql_write_other_func_reg(struct ql_adapter *qdev, - u32 reg, u32 reg_val) + u32 reg, u32 reg_val) { u32 register_to_read; int status = 0; @@ -41,7 +41,7 @@ static int ql_write_other_func_reg(struct ql_adapter *qdev, } static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg, - u32 bit, u32 err_bit) + u32 bit, u32 err_bit) { u32 temp; int count = 10; @@ -61,13 +61,13 @@ static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg, } static int ql_read_other_func_serdes_reg(struct ql_adapter *qdev, u32 reg, - u32 *data) + u32 *data) { int status; /* wait for reg to come ready */ status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4, - XG_SERDES_ADDR_RDY, 0); + XG_SERDES_ADDR_RDY, 0); if (status) goto exit; @@ -76,7 +76,7 @@ static int ql_read_other_func_serdes_reg(struct ql_adapter *qdev, u32 reg, /* wait for reg to come ready */ status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4, - XG_SERDES_ADDR_RDY, 0); + XG_SERDES_ADDR_RDY, 0); if (status) goto exit; @@ -111,7 +111,7 @@ exit: } static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr, - u32 *direct_ptr, u32 *indirect_ptr, + u32 *direct_ptr, u32 *indirect_ptr, unsigned int direct_valid, unsigned int indirect_valid) { unsigned int status; @@ -133,7 +133,7 @@ static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr, } static int ql_get_serdes_regs(struct ql_adapter *qdev, - struct ql_mpi_coredump *mpi_coredump) + struct ql_mpi_coredump *mpi_coredump) { int status; unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid; @@ -203,7 +203,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, for (i = 0; i <= 0x000000034; i += 4, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xaui_direct_valid, xaui_indirect_valid); + xaui_direct_valid, xaui_indirect_valid); /* Get XAUI_HSS_PCS register block. */ if (qdev->func & 1) { @@ -220,7 +220,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, for (i = 0x800; i <= 0x880; i += 4, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xaui_direct_valid, xaui_indirect_valid); + xaui_direct_valid, xaui_indirect_valid); /* Get XAUI_XFI_AN register block. */ if (qdev->func & 1) { @@ -233,7 +233,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, for (i = 0x1000; i <= 0x1034; i += 4, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xfi_direct_valid, xfi_indirect_valid); + xfi_direct_valid, xfi_indirect_valid); /* Get XAUI_XFI_TRAIN register block. */ if (qdev->func & 1) { @@ -248,7 +248,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, for (i = 0x1050; i <= 0x107c; i += 4, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xfi_direct_valid, xfi_indirect_valid); + xfi_direct_valid, xfi_indirect_valid); /* Get XAUI_XFI_HSS_PCS register block. */ if (qdev->func & 1) { @@ -265,7 +265,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, for (i = 0x1800; i <= 0x1838; i += 4, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xfi_direct_valid, xfi_indirect_valid); + xfi_direct_valid, xfi_indirect_valid); /* Get XAUI_XFI_HSS_TX register block. */ if (qdev->func & 1) { @@ -280,7 +280,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, } for (i = 0x1c00; i <= 0x1c1f; i++, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xfi_direct_valid, xfi_indirect_valid); + xfi_direct_valid, xfi_indirect_valid); /* Get XAUI_XFI_HSS_RX register block. */ if (qdev->func & 1) { @@ -296,7 +296,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, for (i = 0x1c40; i <= 0x1c5f; i++, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xfi_direct_valid, xfi_indirect_valid); + xfi_direct_valid, xfi_indirect_valid); /* Get XAUI_XFI_HSS_PLL register block. */ @@ -313,18 +313,18 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, } for (i = 0x1e00; i <= 0x1e1f; i++, direct_ptr++, indirect_ptr++) ql_get_both_serdes(qdev, i, direct_ptr, indirect_ptr, - xfi_direct_valid, xfi_indirect_valid); + xfi_direct_valid, xfi_indirect_valid); return 0; } static int ql_read_other_func_xgmac_reg(struct ql_adapter *qdev, u32 reg, - u32 *data) + u32 *data) { int status = 0; /* wait for reg to come ready */ status = ql_wait_other_func_reg_rdy(qdev, XGMAC_ADDR / 4, - XGMAC_ADDR_RDY, XGMAC_ADDR_XME); + XGMAC_ADDR_RDY, XGMAC_ADDR_XME); if (status) goto exit; @@ -333,7 +333,7 @@ static int ql_read_other_func_xgmac_reg(struct ql_adapter *qdev, u32 reg, /* wait for reg to come ready */ status = ql_wait_other_func_reg_rdy(qdev, XGMAC_ADDR / 4, - XGMAC_ADDR_RDY, XGMAC_ADDR_XME); + XGMAC_ADDR_RDY, XGMAC_ADDR_XME); if (status) goto exit; @@ -347,7 +347,7 @@ exit: * skipping unused locations. */ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 *buf, - unsigned int other_function) + unsigned int other_function) { int status = 0; int i; @@ -357,7 +357,7 @@ static int ql_get_xgmac_regs(struct ql_adapter *qdev, u32 *buf, * several locations that are non-responsive to reads. */ if ((i == 0x00000114) || - (i == 0x00000118) || + (i == 0x00000118) || (i == 0x0000013c) || (i == 0x00000140) || (i > 0x00000150 && i < 0x000001fc) || @@ -410,7 +410,7 @@ static void ql_get_intr_states(struct ql_adapter *qdev, u32 *buf) for (i = 0; i < qdev->rx_ring_count; i++, buf++) { ql_write32(qdev, INTR_EN, - qdev->intr_context[i].intr_read_mask); + qdev->intr_context[i].intr_read_mask); *buf = ql_read32(qdev, INTR_EN); } } @@ -426,7 +426,7 @@ static int ql_get_cam_entries(struct ql_adapter *qdev, u32 *buf) for (i = 0; i < 16; i++) { status = ql_get_mac_addr_reg(qdev, - MAC_ADDR_TYPE_CAM_MAC, i, value); + MAC_ADDR_TYPE_CAM_MAC, i, value); if (status) { netif_err(qdev, drv, qdev->ndev, "Failed read of mac index register\n"); @@ -438,7 +438,7 @@ static int ql_get_cam_entries(struct ql_adapter *qdev, u32 *buf) } for (i = 0; i < 32; i++) { status = ql_get_mac_addr_reg(qdev, - MAC_ADDR_TYPE_MULTI_MAC, i, value); + MAC_ADDR_TYPE_MULTI_MAC, i, value); if (status) { netif_err(qdev, drv, qdev->ndev, "Failed read of mac index register\n"); @@ -497,7 +497,7 @@ end: /* Read the MPI Processor core registers */ static int ql_get_mpi_regs(struct ql_adapter *qdev, u32 *buf, - u32 offset, u32 count) + u32 offset, u32 count) { int i, status = 0; for (i = 0; i < count; i++, buf++) { @@ -510,7 +510,7 @@ static int ql_get_mpi_regs(struct ql_adapter *qdev, u32 *buf, /* Read the ASIC probe dump */ static unsigned int *ql_get_probe(struct ql_adapter *qdev, u32 clock, - u32 valid, u32 *buf) + u32 valid, u32 *buf) { u32 module, mux_sel, probe, lo_val, hi_val; @@ -545,13 +545,13 @@ static int ql_get_probe_dump(struct ql_adapter *qdev, unsigned int *buf) /* First we have to enable the probe mux */ ql_write_mpi_reg(qdev, MPI_TEST_FUNC_PRB_CTL, MPI_TEST_FUNC_PRB_EN); buf = ql_get_probe(qdev, PRB_MX_ADDR_SYS_CLOCK, - PRB_MX_ADDR_VALID_SYS_MOD, buf); + PRB_MX_ADDR_VALID_SYS_MOD, buf); buf = ql_get_probe(qdev, PRB_MX_ADDR_PCI_CLOCK, - PRB_MX_ADDR_VALID_PCI_MOD, buf); + PRB_MX_ADDR_VALID_PCI_MOD, buf); buf = ql_get_probe(qdev, PRB_MX_ADDR_XGM_CLOCK, - PRB_MX_ADDR_VALID_XGM_MOD, buf); + PRB_MX_ADDR_VALID_XGM_MOD, buf); buf = ql_get_probe(qdev, PRB_MX_ADDR_FC_CLOCK, - PRB_MX_ADDR_VALID_FC_MOD, buf); + PRB_MX_ADDR_VALID_FC_MOD, buf); return 0; } @@ -666,7 +666,7 @@ static void ql_get_mac_protocol_registers(struct ql_adapter *qdev, u32 *buf) result_index = 0; while ((result_index & MAC_ADDR_MR) == 0) { result_index = ql_read32(qdev, - MAC_ADDR_IDX); + MAC_ADDR_IDX); } result_data = ql_read32(qdev, MAC_ADDR_DATA); *buf = result_index; @@ -740,7 +740,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Insert the global header */ memset(&(mpi_coredump->mpi_global_header), 0, - sizeof(struct mpi_coredump_global_header)); + sizeof(struct mpi_coredump_global_header)); mpi_coredump->mpi_global_header.cookie = MPI_COREDUMP_COOKIE; mpi_coredump->mpi_global_header.headerSize = sizeof(struct mpi_coredump_global_header); @@ -751,23 +751,23 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get generic NIC reg dump */ ql_build_coredump_seg_header(&mpi_coredump->nic_regs_seg_hdr, - NIC1_CONTROL_SEG_NUM, + NIC1_CONTROL_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic_regs), "NIC1 Registers"); ql_build_coredump_seg_header(&mpi_coredump->nic2_regs_seg_hdr, - NIC2_CONTROL_SEG_NUM, + NIC2_CONTROL_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic2_regs), "NIC2 Registers"); /* Get XGMac registers. (Segment 18, Rev C. step 21) */ ql_build_coredump_seg_header(&mpi_coredump->xgmac1_seg_hdr, - NIC1_XGMAC_SEG_NUM, + NIC1_XGMAC_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->xgmac1), "NIC1 XGMac Registers"); ql_build_coredump_seg_header(&mpi_coredump->xgmac2_seg_hdr, - NIC2_XGMAC_SEG_NUM, + NIC2_XGMAC_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->xgmac2), "NIC2 XGMac Registers"); @@ -798,97 +798,97 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Rev C. Step 20a */ ql_build_coredump_seg_header(&mpi_coredump->xaui_an_hdr, - XAUI_AN_SEG_NUM, + XAUI_AN_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xaui_an), "XAUI AN Registers"); /* Rev C. Step 20b */ ql_build_coredump_seg_header(&mpi_coredump->xaui_hss_pcs_hdr, - XAUI_HSS_PCS_SEG_NUM, + XAUI_HSS_PCS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xaui_hss_pcs), "XAUI HSS PCS Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi_an_hdr, XFI_AN_SEG_NUM, - sizeof(struct mpi_coredump_segment_header) + + sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xfi_an), "XFI AN Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi_train_hdr, - XFI_TRAIN_SEG_NUM, + XFI_TRAIN_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xfi_train), "XFI TRAIN Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_pcs_hdr, - XFI_HSS_PCS_SEG_NUM, + XFI_HSS_PCS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xfi_hss_pcs), "XFI HSS PCS Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_tx_hdr, - XFI_HSS_TX_SEG_NUM, + XFI_HSS_TX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xfi_hss_tx), "XFI HSS TX Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_rx_hdr, - XFI_HSS_RX_SEG_NUM, + XFI_HSS_RX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xfi_hss_rx), "XFI HSS RX Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi_hss_pll_hdr, - XFI_HSS_PLL_SEG_NUM, + XFI_HSS_PLL_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes_xfi_hss_pll), "XFI HSS PLL Registers"); ql_build_coredump_seg_header(&mpi_coredump->xaui2_an_hdr, - XAUI2_AN_SEG_NUM, + XAUI2_AN_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xaui_an), "XAUI2 AN Registers"); ql_build_coredump_seg_header(&mpi_coredump->xaui2_hss_pcs_hdr, - XAUI2_HSS_PCS_SEG_NUM, + XAUI2_HSS_PCS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xaui_hss_pcs), "XAUI2 HSS PCS Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi2_an_hdr, - XFI2_AN_SEG_NUM, + XFI2_AN_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xfi_an), "XFI2 AN Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi2_train_hdr, - XFI2_TRAIN_SEG_NUM, + XFI2_TRAIN_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xfi_train), "XFI2 TRAIN Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_pcs_hdr, - XFI2_HSS_PCS_SEG_NUM, + XFI2_HSS_PCS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xfi_hss_pcs), "XFI2 HSS PCS Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_tx_hdr, - XFI2_HSS_TX_SEG_NUM, + XFI2_HSS_TX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xfi_hss_tx), "XFI2 HSS TX Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_rx_hdr, - XFI2_HSS_RX_SEG_NUM, + XFI2_HSS_RX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xfi_hss_rx), "XFI2 HSS RX Registers"); ql_build_coredump_seg_header(&mpi_coredump->xfi2_hss_pll_hdr, - XFI2_HSS_PLL_SEG_NUM, + XFI2_HSS_PLL_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->serdes2_xfi_hss_pll), "XFI2 HSS PLL Registers"); @@ -902,7 +902,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) } ql_build_coredump_seg_header(&mpi_coredump->core_regs_seg_hdr, - CORE_SEG_NUM, + CORE_SEG_NUM, sizeof(mpi_coredump->core_regs_seg_hdr) + sizeof(mpi_coredump->mpi_core_regs) + sizeof(mpi_coredump->mpi_core_sh_regs), @@ -921,7 +921,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the Test Logic Registers */ ql_build_coredump_seg_header(&mpi_coredump->test_logic_regs_seg_hdr, - TEST_LOGIC_SEG_NUM, + TEST_LOGIC_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->test_logic_regs), "Test Logic Regs"); @@ -932,7 +932,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the RMII Registers */ ql_build_coredump_seg_header(&mpi_coredump->rmii_regs_seg_hdr, - RMII_SEG_NUM, + RMII_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->rmii_regs), "RMII Registers"); @@ -943,7 +943,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the FCMAC1 Registers */ ql_build_coredump_seg_header(&mpi_coredump->fcmac1_regs_seg_hdr, - FCMAC1_SEG_NUM, + FCMAC1_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->fcmac1_regs), "FCMAC1 Registers"); @@ -955,7 +955,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the FCMAC2 Registers */ ql_build_coredump_seg_header(&mpi_coredump->fcmac2_regs_seg_hdr, - FCMAC2_SEG_NUM, + FCMAC2_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->fcmac2_regs), "FCMAC2 Registers"); @@ -967,7 +967,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the FC1 MBX Registers */ ql_build_coredump_seg_header(&mpi_coredump->fc1_mbx_regs_seg_hdr, - FC1_MBOX_SEG_NUM, + FC1_MBOX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->fc1_mbx_regs), "FC1 MBox Regs"); @@ -978,7 +978,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the IDE Registers */ ql_build_coredump_seg_header(&mpi_coredump->ide_regs_seg_hdr, - IDE_SEG_NUM, + IDE_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->ide_regs), "IDE Registers"); @@ -989,7 +989,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the NIC1 MBX Registers */ ql_build_coredump_seg_header(&mpi_coredump->nic1_mbx_regs_seg_hdr, - NIC1_MBOX_SEG_NUM, + NIC1_MBOX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic1_mbx_regs), "NIC1 MBox Regs"); @@ -1000,7 +1000,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the SMBus Registers */ ql_build_coredump_seg_header(&mpi_coredump->smbus_regs_seg_hdr, - SMBUS_SEG_NUM, + SMBUS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->smbus_regs), "SMBus Registers"); @@ -1011,7 +1011,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the FC2 MBX Registers */ ql_build_coredump_seg_header(&mpi_coredump->fc2_mbx_regs_seg_hdr, - FC2_MBOX_SEG_NUM, + FC2_MBOX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->fc2_mbx_regs), "FC2 MBox Regs"); @@ -1022,7 +1022,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the NIC2 MBX Registers */ ql_build_coredump_seg_header(&mpi_coredump->nic2_mbx_regs_seg_hdr, - NIC2_MBOX_SEG_NUM, + NIC2_MBOX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic2_mbx_regs), "NIC2 MBox Regs"); @@ -1033,7 +1033,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the I2C Registers */ ql_build_coredump_seg_header(&mpi_coredump->i2c_regs_seg_hdr, - I2C_SEG_NUM, + I2C_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->i2c_regs), "I2C Registers"); @@ -1044,7 +1044,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the MEMC Registers */ ql_build_coredump_seg_header(&mpi_coredump->memc_regs_seg_hdr, - MEMC_SEG_NUM, + MEMC_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->memc_regs), "MEMC Registers"); @@ -1055,7 +1055,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the PBus Registers */ ql_build_coredump_seg_header(&mpi_coredump->pbus_regs_seg_hdr, - PBUS_SEG_NUM, + PBUS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->pbus_regs), "PBUS Registers"); @@ -1066,7 +1066,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the MDE Registers */ ql_build_coredump_seg_header(&mpi_coredump->mde_regs_seg_hdr, - MDE_SEG_NUM, + MDE_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->mde_regs), "MDE Registers"); @@ -1076,7 +1076,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) goto err; ql_build_coredump_seg_header(&mpi_coredump->misc_nic_seg_hdr, - MISC_NIC_INFO_SEG_NUM, + MISC_NIC_INFO_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->misc_nic_info), "MISC NIC INFO"); @@ -1088,14 +1088,14 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Segment 31 */ /* Get indexed register values. */ ql_build_coredump_seg_header(&mpi_coredump->intr_states_seg_hdr, - INTR_STATES_SEG_NUM, + INTR_STATES_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->intr_states), "INTR States"); ql_get_intr_states(qdev, &mpi_coredump->intr_states[0]); ql_build_coredump_seg_header(&mpi_coredump->cam_entries_seg_hdr, - CAM_ENTRIES_SEG_NUM, + CAM_ENTRIES_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->cam_entries), "CAM Entries"); @@ -1104,18 +1104,18 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) goto err; ql_build_coredump_seg_header(&mpi_coredump->nic_routing_words_seg_hdr, - ROUTING_WORDS_SEG_NUM, + ROUTING_WORDS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic_routing_words), "Routing Words"); status = ql_get_routing_entries(qdev, - &mpi_coredump->nic_routing_words[0]); + &mpi_coredump->nic_routing_words[0]); if (status) goto err; /* Segment 34 (Rev C. step 23) */ ql_build_coredump_seg_header(&mpi_coredump->ets_seg_hdr, - ETS_SEG_NUM, + ETS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->ets), "ETS Registers"); @@ -1124,24 +1124,24 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) goto err; ql_build_coredump_seg_header(&mpi_coredump->probe_dump_seg_hdr, - PROBE_DUMP_SEG_NUM, + PROBE_DUMP_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->probe_dump), "Probe Dump"); ql_get_probe_dump(qdev, &mpi_coredump->probe_dump[0]); ql_build_coredump_seg_header(&mpi_coredump->routing_reg_seg_hdr, - ROUTING_INDEX_SEG_NUM, + ROUTING_INDEX_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->routing_regs), "Routing Regs"); status = ql_get_routing_index_registers(qdev, - &mpi_coredump->routing_regs[0]); + &mpi_coredump->routing_regs[0]); if (status) goto err; ql_build_coredump_seg_header(&mpi_coredump->mac_prot_reg_seg_hdr, - MAC_PROTOCOL_SEG_NUM, + MAC_PROTOCOL_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->mac_prot_regs), "MAC Prot Regs"); @@ -1149,7 +1149,7 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Get the semaphore registers for all 5 functions */ ql_build_coredump_seg_header(&mpi_coredump->sem_regs_seg_hdr, - SEM_REGS_SEG_NUM, + SEM_REGS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->sem_regs), "Sem Registers"); @@ -1175,12 +1175,12 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) } ql_build_coredump_seg_header(&mpi_coredump->code_ram_seg_hdr, - WCS_RAM_SEG_NUM, + WCS_RAM_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->code_ram), "WCS RAM"); status = ql_dump_risc_ram_area(qdev, &mpi_coredump->code_ram[0], - CODE_RAM_ADDR, CODE_RAM_CNT); + CODE_RAM_ADDR, CODE_RAM_CNT); if (status) { netif_err(qdev, drv, qdev->ndev, "Failed Dump of CODE RAM. Status = 0x%.08x\n", @@ -1190,12 +1190,12 @@ int ql_core_dump(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) /* Insert the segment header */ ql_build_coredump_seg_header(&mpi_coredump->memc_ram_seg_hdr, - MEMC_RAM_SEG_NUM, + MEMC_RAM_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->memc_ram), "MEMC RAM"); status = ql_dump_risc_ram_area(qdev, &mpi_coredump->memc_ram[0], - MEMC_RAM_ADDR, MEMC_RAM_CNT); + MEMC_RAM_ADDR, MEMC_RAM_CNT); if (status) { netif_err(qdev, drv, qdev->ndev, "Failed Dump of MEMC RAM. Status = 0x%.08x\n", @@ -1230,7 +1230,7 @@ static void ql_gen_reg_dump(struct ql_adapter *qdev, memset(&(mpi_coredump->mpi_global_header), 0, - sizeof(struct mpi_coredump_global_header)); + sizeof(struct mpi_coredump_global_header)); mpi_coredump->mpi_global_header.cookie = MPI_COREDUMP_COOKIE; mpi_coredump->mpi_global_header.headerSize = sizeof(struct mpi_coredump_global_header); @@ -1242,7 +1242,7 @@ static void ql_gen_reg_dump(struct ql_adapter *qdev, /* segment 16 */ ql_build_coredump_seg_header(&mpi_coredump->misc_nic_seg_hdr, - MISC_NIC_INFO_SEG_NUM, + MISC_NIC_INFO_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->misc_nic_info), "MISC NIC INFO"); @@ -1253,7 +1253,7 @@ static void ql_gen_reg_dump(struct ql_adapter *qdev, /* Segment 16, Rev C. Step 18 */ ql_build_coredump_seg_header(&mpi_coredump->nic_regs_seg_hdr, - NIC1_CONTROL_SEG_NUM, + NIC1_CONTROL_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic_regs), "NIC Registers"); @@ -1264,14 +1264,14 @@ static void ql_gen_reg_dump(struct ql_adapter *qdev, /* Segment 31 */ /* Get indexed register values. */ ql_build_coredump_seg_header(&mpi_coredump->intr_states_seg_hdr, - INTR_STATES_SEG_NUM, + INTR_STATES_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->intr_states), "INTR States"); ql_get_intr_states(qdev, &mpi_coredump->intr_states[0]); ql_build_coredump_seg_header(&mpi_coredump->cam_entries_seg_hdr, - CAM_ENTRIES_SEG_NUM, + CAM_ENTRIES_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->cam_entries), "CAM Entries"); @@ -1280,18 +1280,18 @@ static void ql_gen_reg_dump(struct ql_adapter *qdev, return; ql_build_coredump_seg_header(&mpi_coredump->nic_routing_words_seg_hdr, - ROUTING_WORDS_SEG_NUM, + ROUTING_WORDS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->nic_routing_words), "Routing Words"); status = ql_get_routing_entries(qdev, - &mpi_coredump->nic_routing_words[0]); + &mpi_coredump->nic_routing_words[0]); if (status) return; /* Segment 34 (Rev C. step 23) */ ql_build_coredump_seg_header(&mpi_coredump->ets_seg_hdr, - ETS_SEG_NUM, + ETS_SEG_NUM, sizeof(struct mpi_coredump_segment_header) + sizeof(mpi_coredump->ets), "ETS Registers"); @@ -1992,7 +1992,7 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp) le16_to_cpu(ib_mac_rsp->vlan_id)); pr_err("flags4 = %s%s%s\n", - ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "", + ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "", ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS ? "HS " : "", ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HL ? "HL " : ""); -- cgit v1.2.3-59-g8ed1b From b883582d734074bc0f0c4176998becec4a394a04 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 10 Oct 2019 22:40:04 +0100 Subject: staging: qlge: Fix multiple assignments warning by replacing integer variables to bool Fix multiple assignments warning " check issue detected by checkpatch tool: "CHECK: multiple assignments should be avoided". Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191010214006.23677-2-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index a6ac9f796d81..ac162176f6f5 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -112,7 +112,7 @@ exit: static void ql_get_both_serdes(struct ql_adapter *qdev, u32 addr, u32 *direct_ptr, u32 *indirect_ptr, - unsigned int direct_valid, unsigned int indirect_valid) + bool direct_valid, bool indirect_valid) { unsigned int status; @@ -136,13 +136,12 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, struct ql_mpi_coredump *mpi_coredump) { int status; - unsigned int xfi_direct_valid, xfi_indirect_valid, xaui_direct_valid; - unsigned int xaui_indirect_valid, i; + bool xfi_direct_valid = false, xfi_indirect_valid = false; + bool xaui_direct_valid = true, xaui_indirect_valid = true; + unsigned int i; u32 *direct_ptr, temp; u32 *indirect_ptr; - xfi_direct_valid = xfi_indirect_valid = 0; - xaui_direct_valid = xaui_indirect_valid = 1; /* The XAUI needs to be read out per port */ status = ql_read_other_func_serdes_reg(qdev, @@ -152,7 +151,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) == XG_SERDES_ADDR_XAUI_PWR_DOWN) - xaui_indirect_valid = 0; + xaui_indirect_valid = false; status = ql_read_serdes_reg(qdev, XG_SERDES_XAUI_HSS_PCS_START, &temp); @@ -161,7 +160,7 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, if ((temp & XG_SERDES_ADDR_XAUI_PWR_DOWN) == XG_SERDES_ADDR_XAUI_PWR_DOWN) - xaui_direct_valid = 0; + xaui_direct_valid = false; /* * XFI register is shared so only need to read one @@ -176,18 +175,18 @@ static int ql_get_serdes_regs(struct ql_adapter *qdev, /* now see if i'm NIC 1 or NIC 2 */ if (qdev->func & 1) /* I'm NIC 2, so the indirect (NIC1) xfi is up. */ - xfi_indirect_valid = 1; + xfi_indirect_valid = true; else - xfi_direct_valid = 1; + xfi_direct_valid = true; } if ((temp & XG_SERDES_ADDR_XFI2_PWR_UP) == XG_SERDES_ADDR_XFI2_PWR_UP) { /* now see if i'm NIC 1 or NIC 2 */ if (qdev->func & 1) /* I'm NIC 2, so the indirect (NIC1) xfi is up. */ - xfi_direct_valid = 1; + xfi_direct_valid = true; else - xfi_indirect_valid = 1; + xfi_indirect_valid = true; } /* Get XAUI_AN register block. */ -- cgit v1.2.3-59-g8ed1b From e311f25e186560b0315e66707177ee152e718228 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 10 Oct 2019 22:40:05 +0100 Subject: staging: qlge: add space to fix check warning Add space to fix warning of preferred space near the division operator issue detected by checkpatch. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191010214006.23677-3-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index ac162176f6f5..182a07ae5e61 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -72,7 +72,7 @@ static int ql_read_other_func_serdes_reg(struct ql_adapter *qdev, u32 reg, goto exit; /* set up for reg read */ - ql_write_other_func_reg(qdev, XG_SERDES_ADDR/4, reg | PROC_ADDR_R); + ql_write_other_func_reg(qdev, XG_SERDES_ADDR / 4, reg | PROC_ADDR_R); /* wait for reg to come ready */ status = ql_wait_other_func_reg_rdy(qdev, XG_SERDES_ADDR / 4, -- cgit v1.2.3-59-g8ed1b From db4b23d5a898cda286e83fcb3650f0951a235d12 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 10 Oct 2019 22:40:06 +0100 Subject: staging: qlge: fix comparison to NULL warning Fix comparison to NULL by replacing with !ptr instead. Issue detected by checkpatch. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191010214006.23677-4-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 182a07ae5e61..019b7e6a1b7a 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1805,7 +1805,7 @@ void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id) pr_err("%s: Enter\n", __func__); ptr = kmalloc(size, GFP_ATOMIC); - if (ptr == NULL) + if (!ptr) return; if (ql_write_cfg(qdev, ptr, size, bit, q_id)) { -- cgit v1.2.3-59-g8ed1b From 850d80a2d8682999b5aafa361ae239838c8636c2 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Fri, 11 Oct 2019 10:20:44 +0300 Subject: staging: isdn: remove assignment in if conditionals Remove variable assignment in if statements in drivers/staging/isdn/avm/b1.c. Issues reported by checkpatch.pl as: ERROR: do not use assignment in if condition Also refactor code around some if statements to remove comparisons to NULL and unnecessary braces in single statement blocks. Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191011072044.7022-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/isdn/avm/b1.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/isdn/avm/b1.c b/drivers/staging/isdn/avm/b1.c index 40ca1e8fa09f..32ec8cf31fd0 100644 --- a/drivers/staging/isdn/avm/b1.c +++ b/drivers/staging/isdn/avm/b1.c @@ -261,9 +261,10 @@ int b1_loaded(avmcard *card) b1_put_byte(base, SEND_POLL); for (stop = jiffies + tout * HZ; time_before(jiffies, stop);) { if (b1_rx_full(base)) { - if ((ans = b1_get_byte(base)) == RECEIVE_POLL) { + ans = b1_get_byte(base); + if (ans == RECEIVE_POLL) return 1; - } + printk(KERN_ERR "%s: b1_loaded: got 0x%x, firmware not running\n", card->name, ans); return 0; @@ -284,8 +285,9 @@ int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) int retval; b1_reset(port); + retval = b1_load_t4file(card, &data->firmware); - if ((retval = b1_load_t4file(card, &data->firmware))) { + if (retval) { b1_reset(port); printk(KERN_ERR "%s: failed to load t4file!!\n", card->name); @@ -295,7 +297,8 @@ int b1_load_firmware(struct capi_ctr *ctrl, capiloaddata *data) b1_disable_irq(port); if (data->configuration.len > 0 && data->configuration.data) { - if ((retval = b1_load_config(card, &data->configuration))) { + retval = b1_load_config(card, &data->configuration); + if (retval) { b1_reset(port); printk(KERN_ERR "%s: failed to load config!!\n", card->name); @@ -525,7 +528,9 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) MsgLen = 30; CAPIMSG_SETLEN(card->msgbuf, 30); } - if (!(skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC))) { + + skb = alloc_skb(DataB3Len + MsgLen, GFP_ATOMIC); + if (!skb) { printk(KERN_ERR "%s: incoming packet dropped\n", card->name); } else { @@ -539,7 +544,9 @@ irqreturn_t b1_interrupt(int interrupt, void *devptr) ApplId = (unsigned) b1_get_word(card->port); MsgLen = b1_get_slice(card->port, card->msgbuf); - if (!(skb = alloc_skb(MsgLen, GFP_ATOMIC))) { + skb = alloc_skb(MsgLen, GFP_ATOMIC); + + if (!skb) { printk(KERN_ERR "%s: incoming packet dropped\n", card->name); spin_unlock_irqrestore(&card->lock, flags); @@ -663,11 +670,17 @@ int b1_proc_show(struct seq_file *m, void *v) seq_printf(m, "%-16s %s\n", "type", s); if (card->cardtype == avm_t1isa) seq_printf(m, "%-16s %d\n", "cardnr", card->cardnr); - if ((s = cinfo->version[VER_DRIVER]) != NULL) + + s = cinfo->version[VER_DRIVER]; + if (s) seq_printf(m, "%-16s %s\n", "ver_driver", s); - if ((s = cinfo->version[VER_CARDTYPE]) != NULL) + + s = cinfo->version[VER_CARDTYPE]; + if (s) seq_printf(m, "%-16s %s\n", "ver_cardtype", s); - if ((s = cinfo->version[VER_SERIAL]) != NULL) + + s = cinfo->version[VER_SERIAL]; + if (s) seq_printf(m, "%-16s %s\n", "ver_serial", s); if (card->cardtype != avm_m1) { @@ -784,13 +797,15 @@ static int __init b1_init(void) char *p; char rev[32]; - if ((p = strchr(revision, ':')) != NULL && p[1]) { + p = strchr(revision, ':'); + if (p && p[1]) { strlcpy(rev, p + 2, 32); - if ((p = strchr(rev, '$')) != NULL && p > rev) + p = strchr(rev, '$'); + if (p && p > rev) *(p - 1) = 0; - } else + } else { strcpy(rev, "1.0"); - + } printk(KERN_INFO "b1: revision %s\n", rev); return 0; -- cgit v1.2.3-59-g8ed1b From f152f52c308dbaf41f3874805f9a2811f96730da Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Sat, 12 Oct 2019 16:18:05 +0100 Subject: staging: vc04_services: place the AND operator at the end of the previous line Place the AND logical operator at the end of the previous line; to fix warning of "Logical continuations should be on the previous line". Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191012151805.17988-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index d4d1e44b16b2..beb6a0063bb8 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1090,8 +1090,8 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, ret = vchiq_mmal_port_set_format(dev->instance, camera_port); - if (!ret - && camera_port == + if (!ret && + camera_port == &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO]) { bool overlay_enabled = !!dev->component[COMP_PREVIEW]->enabled; -- cgit v1.2.3-59-g8ed1b From 91d6f911b348dcb8e22d87913f4a0f52e646e990 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 11 Oct 2019 14:24:41 +0300 Subject: staging: fbtft: fbtft-core: Fix last line displayed on fbcon For the special case when fbtft_mkdirty() is called with with -1 for the y coordinate, the height is truncated by 1. This isn't required, and causes the last line to not update. Signed-off-by: Michael Hennerich Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20191011112441.31003-1-alexandru.ardelean@analog.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index cf5700a2ea66..90eec45d11fc 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -317,7 +317,7 @@ static void fbtft_mkdirty(struct fb_info *info, int y, int height) /* special case, needed ? */ if (y == -1) { y = 0; - height = info->var.yres - 1; + height = info->var.yres; } /* Mark display lines/area as dirty */ -- cgit v1.2.3-59-g8ed1b From c86673e884199206c46d356551288d91a53e7b1a Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Thu, 10 Oct 2019 16:20:58 +0300 Subject: staging: rtl8723bs: Remove comparison to NULL Remove comparison to NULL in drivers/staging/rtl8723bs/core/rtw_ap.c:1449. Issue found by checkpatch.pl Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191010132058.20887-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 80027ac765d0..7117d16a30f9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1447,7 +1447,7 @@ u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta) u8 res = _SUCCESS; ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } -- cgit v1.2.3-59-g8ed1b From ef1fe6b7369a822d86a2fb8a688c721ae7f4eed3 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sat, 12 Oct 2019 21:04:31 +0300 Subject: staging: octeon: remove typedef declaration for cvmx_wqe Remove typedef declaration from struct cvmx_wqe. Also replace its previous uses with new struct declaration. Issue found by checkpatch.pl Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/fa82104ea8d7ff54dc66bfbfedb6cca541701991.1570821661.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-rx.c | 6 +++--- drivers/staging/octeon/ethernet-tx.c | 2 +- drivers/staging/octeon/ethernet.c | 2 +- drivers/staging/octeon/octeon-stubs.h | 22 +++++++++++----------- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c index 0e65955c746b..2c16230f993c 100644 --- a/drivers/staging/octeon/ethernet-rx.c +++ b/drivers/staging/octeon/ethernet-rx.c @@ -60,7 +60,7 @@ static irqreturn_t cvm_oct_do_interrupt(int irq, void *napi_id) * * Returns Non-zero if the packet can be dropped, zero otherwise. */ -static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work) +static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work) { int port; @@ -135,7 +135,7 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work) return 0; } -static void copy_segments_to_skb(cvmx_wqe_t *work, struct sk_buff *skb) +static void copy_segments_to_skb(struct cvmx_wqe *work, struct sk_buff *skb) { int segments = work->word2.s.bufs; union cvmx_buf_ptr segment_ptr = work->packet_ptr; @@ -215,7 +215,7 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget) struct sk_buff *skb = NULL; struct sk_buff **pskb = NULL; int skb_in_hw; - cvmx_wqe_t *work; + struct cvmx_wqe *work; int port; if (USE_ASYNC_IOBDMA && did_work_request) diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 83469061a542..5481e6bb330a 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -514,7 +514,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev) void *copy_location; /* Get a work queue entry */ - cvmx_wqe_t *work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL); + struct cvmx_wqe *work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL); if (unlikely(!work)) { printk_ratelimited("%s: Failed to allocate a work queue entry\n", diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index cf8e9a23ebf9..f892f1ad4638 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -172,7 +172,7 @@ static void cvm_oct_configure_common_hw(void) */ int cvm_oct_free_work(void *work_queue_entry) { - cvmx_wqe_t *work = work_queue_entry; + struct cvmx_wqe *work = work_queue_entry; int segments = work->word2.s.bufs; union cvmx_buf_ptr segment_ptr = work->packet_ptr; diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index 2393bb60891a..0e102aee272b 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -183,13 +183,13 @@ union cvmx_buf_ptr { } s; }; -typedef struct { +struct cvmx_wqe { union cvmx_wqe_word0 word0; union cvmx_wqe_word1 word1; union cvmx_pip_wqe_word2 word2; union cvmx_buf_ptr packet_ptr; uint8_t packet_data[96]; -} cvmx_wqe_t; +}; typedef union { uint64_t u64; @@ -1198,7 +1198,7 @@ static inline uint64_t cvmx_scratch_read64(uint64_t address) static inline void cvmx_scratch_write64(uint64_t address, uint64_t value) { } -static inline int cvmx_wqe_get_grp(cvmx_wqe_t *work) +static inline int cvmx_wqe_get_grp(struct cvmx_wqe *work) { return 0; } @@ -1345,14 +1345,14 @@ static inline void cvmx_pow_work_request_async(int scr_addr, cvmx_pow_wait_t wait) { } -static inline cvmx_wqe_t *cvmx_pow_work_response_async(int scr_addr) +static inline struct cvmx_wqe *cvmx_pow_work_response_async(int scr_addr) { - cvmx_wqe_t *wqe = (void *)(unsigned long)scr_addr; + struct cvmx_wqe *wqe = (void *)(unsigned long)scr_addr; return wqe; } -static inline cvmx_wqe_t *cvmx_pow_work_request_sync(cvmx_pow_wait_t wait) +static inline struct cvmx_wqe *cvmx_pow_work_request_sync(cvmx_pow_wait_t wait) { return (void *)(unsigned long)wait; } @@ -1390,21 +1390,21 @@ static inline cvmx_pko_status_t cvmx_pko_send_packet_finish(uint64_t port, return ret; } -static inline void cvmx_wqe_set_port(cvmx_wqe_t *work, int port) +static inline void cvmx_wqe_set_port(struct cvmx_wqe *work, int port) { } -static inline void cvmx_wqe_set_qos(cvmx_wqe_t *work, int qos) +static inline void cvmx_wqe_set_qos(struct cvmx_wqe *work, int qos) { } -static inline int cvmx_wqe_get_qos(cvmx_wqe_t *work) +static inline int cvmx_wqe_get_qos(struct cvmx_wqe *work) { return 0; } -static inline void cvmx_wqe_set_grp(cvmx_wqe_t *work, int grp) +static inline void cvmx_wqe_set_grp(struct cvmx_wqe *work, int grp) { } -static inline void cvmx_pow_work_submit(cvmx_wqe_t *wqp, uint32_t tag, +static inline void cvmx_pow_work_submit(struct cvmx_wqe *wqp, uint32_t tag, enum cvmx_pow_tag_type tag_type, uint64_t qos, uint64_t grp) { } -- cgit v1.2.3-59-g8ed1b From 73aef0c9d2c6f746e8c84775b73ef374b7a2a4dc Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sat, 12 Oct 2019 21:04:32 +0300 Subject: staging: octeon: remove typedef declaration for cvmx_helper_link_info Remove declaration of union cvmx_helper_link_info as typedef. Also replace its previous uses with new union declaration. Issue found by checkpatch.pl Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/fb373aed8fd2b04d01198f5a5769fd2476714e88.1570821661.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-mdio.c | 6 +++--- drivers/staging/octeon/ethernet-rgmii.c | 4 ++-- drivers/staging/octeon/ethernet.c | 4 ++-- drivers/staging/octeon/octeon-ethernet.h | 2 +- drivers/staging/octeon/octeon-stubs.h | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index ffac0c4b3f5c..c798672d61b2 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -65,7 +65,7 @@ int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } void cvm_oct_note_carrier(struct octeon_ethernet *priv, - cvmx_helper_link_info_t li) + union cvmx_helper_link_info li) { if (li.s.link_up) { pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d, queue %d\n", @@ -81,7 +81,7 @@ void cvm_oct_note_carrier(struct octeon_ethernet *priv, void cvm_oct_adjust_link(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; + union cvmx_helper_link_info link_info; link_info.u64 = 0; link_info.s.link_up = dev->phydev->link ? 1 : 0; @@ -106,7 +106,7 @@ int cvm_oct_common_stop(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); int interface = INTERFACE(priv->port); - cvmx_helper_link_info_t link_info; + union cvmx_helper_link_info link_info; union cvmx_gmxx_prtx_cfg gmx_cfg; int index = INDEX(priv->port); diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index d91fd5ce9e68..0c4fac31540a 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -53,7 +53,7 @@ static void cvm_oct_set_hw_preamble(struct octeon_ethernet *priv, bool enable) static void cvm_oct_check_preamble_errors(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; + union cvmx_helper_link_info link_info; unsigned long flags; link_info.u64 = priv->link_info; @@ -103,7 +103,7 @@ static void cvm_oct_check_preamble_errors(struct net_device *dev) static void cvm_oct_rgmii_poll(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; + union cvmx_helper_link_info link_info; bool status_change; link_info = cvmx_helper_link_get(priv->port); diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index f892f1ad4638..f42c3816ce49 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -460,7 +460,7 @@ int cvm_oct_common_open(struct net_device *dev, struct octeon_ethernet *priv = netdev_priv(dev); int interface = INTERFACE(priv->port); int index = INDEX(priv->port); - cvmx_helper_link_info_t link_info; + union cvmx_helper_link_info link_info; int rv; rv = cvm_oct_phy_setup_device(dev); @@ -496,7 +496,7 @@ int cvm_oct_common_open(struct net_device *dev, void cvm_oct_link_poll(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; + union cvmx_helper_link_info link_info; link_info = cvmx_helper_link_get(priv->port); if (link_info.u64 == priv->link_info) diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 042220d86d33..a6140705706f 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -91,7 +91,7 @@ int cvm_oct_common_stop(struct net_device *dev); int cvm_oct_common_open(struct net_device *dev, void (*link_poll)(struct net_device *)); void cvm_oct_note_carrier(struct octeon_ethernet *priv, - cvmx_helper_link_info_t li); + union cvmx_helper_link_info li); void cvm_oct_link_poll(struct net_device *dev); extern int always_use_pow; diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index 0e102aee272b..152b2cbff86a 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -191,7 +191,7 @@ struct cvmx_wqe { uint8_t packet_data[96]; }; -typedef union { +union cvmx_helper_link_info { uint64_t u64; struct { uint64_t reserved_20_63:44; @@ -199,7 +199,7 @@ typedef union { uint64_t full_duplex:1; /**< 1 if the link is full duplex */ uint64_t speed:18; /**< Speed of the link in Mbps */ } s; -} cvmx_helper_link_info_t; +}; typedef enum { CVMX_FAU_REG_32_START = 0, @@ -1267,15 +1267,15 @@ static inline cvmx_helper_interface_mode_t cvmx_helper_interface_get_mode(int return 0; } -static inline cvmx_helper_link_info_t cvmx_helper_link_get(int ipd_port) +static inline union cvmx_helper_link_info cvmx_helper_link_get(int ipd_port) { - cvmx_helper_link_info_t ret = { .u64 = 0 }; + union cvmx_helper_link_info ret = { .u64 = 0 }; return ret; } static inline int cvmx_helper_link_set(int ipd_port, - cvmx_helper_link_info_t link_info) + union cvmx_helper_link_info link_info) { return 0; } -- cgit v1.2.3-59-g8ed1b From 1691741fe31d9d2767e7534a83daf3b31390454b Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sat, 12 Oct 2019 21:04:33 +0300 Subject: staging: octeon: remove typedef declaration for cvmx_fau_reg_32 Remove typedef declaration for enum cvmx_fau_reg_32. Also replace its previous uses with new declaration format. Issue found by checkpatch.pl Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/b7216f423d8e06b2ed7ac2df643a9215cd95be32.1570821661.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index 152b2cbff86a..c328f0771985 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -201,9 +201,9 @@ union cvmx_helper_link_info { } s; }; -typedef enum { +enum cvmx_fau_reg_32 { CVMX_FAU_REG_32_START = 0, -} cvmx_fau_reg_32_t; +}; typedef enum { CVMX_FAU_OP_SIZE_8 = 0, @@ -1178,16 +1178,18 @@ union cvmx_gmxx_rxx_rx_inbnd { } s; }; -static inline int32_t cvmx_fau_fetch_and_add32(cvmx_fau_reg_32_t reg, +static inline int32_t cvmx_fau_fetch_and_add32(enum cvmx_fau_reg_32 reg, int32_t value) { return value; } -static inline void cvmx_fau_atomic_add32(cvmx_fau_reg_32_t reg, int32_t value) +static inline void cvmx_fau_atomic_add32(enum cvmx_fau_reg_32 reg, + int32_t value) { } -static inline void cvmx_fau_atomic_write32(cvmx_fau_reg_32_t reg, int32_t value) +static inline void cvmx_fau_atomic_write32(enum cvmx_fau_reg_32 reg, + int32_t value) { } static inline uint64_t cvmx_scratch_read64(uint64_t address) @@ -1364,7 +1366,7 @@ static inline int cvmx_spi_restart_interface(int interface, } static inline void cvmx_fau_async_fetch_and_add32(uint64_t scraddr, - cvmx_fau_reg_32_t reg, + enum cvmx_fau_reg_32 reg, int32_t value) { } -- cgit v1.2.3-59-g8ed1b From 6cc5e1c700316c11b61975af3be8ebcab1e2f8b9 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sat, 12 Oct 2019 21:04:34 +0300 Subject: staging: octeon: remove typedef declartion for cvmx_pko_command_word0 Removes addition of new typedef declaration for cvmx_pko_command_word0. Also replace previous instances with new union declaration. Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/40bb26b250d7ba5b0d5199072e773be2fb0fed90.1570821661.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-tx.c | 2 +- drivers/staging/octeon/octeon-stubs.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 5481e6bb330a..5114273826ec 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -127,7 +127,7 @@ static void cvm_oct_free_tx_skbs(struct net_device *dev) */ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev) { - cvmx_pko_command_word0_t pko_command; + union cvmx_pko_command_word0 pko_command; union cvmx_buf_ptr hw_buffer; u64 old_scratch; u64 old_scratch2; diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index c328f0771985..9711bf379710 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -1137,7 +1137,7 @@ union cvmx_npi_rsl_int_blocks { } cn50xx; }; -typedef union { +union cvmx_pko_command_word0 { uint64_t u64; struct { uint64_t total_bytes:16; @@ -1157,7 +1157,7 @@ typedef union { uint64_t size0:2; uint64_t size1:2; } s; -} cvmx_pko_command_word0_t; +}; union cvmx_ciu_timx { uint64_t u64; @@ -1384,7 +1384,7 @@ static inline void cvmx_pko_send_packet_prepare(uint64_t port, uint64_t queue, { } static inline cvmx_pko_status_t cvmx_pko_send_packet_finish(uint64_t port, - uint64_t queue, cvmx_pko_command_word0_t pko_command, + uint64_t queue, union cvmx_pko_command_word0 pko_command, union cvmx_buf_ptr packet, cvmx_pko_lock_t use_locking) { cvmx_pko_status_t ret = 0; -- cgit v1.2.3-59-g8ed1b From 180245d2d01686f61b3d1909bdf349a6d153008b Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sat, 12 Oct 2019 21:04:35 +0300 Subject: staging: octeon: remove typedef declaration for cvmx_fau_op_size Remove addition of new typedef for enum cvmx_fau_op_size. Issue found by checkpatch.pl Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/0130bbbffd4c3c9e0e2ab0fc02cb7fa704ee410c.1570821661.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index 9711bf379710..b07f5e24acbc 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -205,12 +205,12 @@ enum cvmx_fau_reg_32 { CVMX_FAU_REG_32_START = 0, }; -typedef enum { +enum cvmx_fau_op_size { CVMX_FAU_OP_SIZE_8 = 0, CVMX_FAU_OP_SIZE_16 = 1, CVMX_FAU_OP_SIZE_32 = 2, CVMX_FAU_OP_SIZE_64 = 3 -} cvmx_fau_op_size_t; +}; typedef enum { CVMX_SPI_MODE_UNKNOWN = 0, -- cgit v1.2.3-59-g8ed1b From f89c7d575d7c8b92c53e5472d90d542bbdeb47f6 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sun, 13 Oct 2019 01:19:15 +0300 Subject: staging: rtl8712: remove unnecessary return variables Remove variables that are only used to hold and return constants and have the functions directly return the constants. Issue found by coccinelle: @@ local idexpression ret; expression e; @@ -ret = +return e; -return ret; Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/f61a0f036af24228c682c6b12c3a8e6cf6736185.1570918228.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 46 ++++++++++++------------------ 1 file changed, 19 insertions(+), 27 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index aa8f8500cbb2..8af7892809ca 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -283,13 +283,12 @@ uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - uint status = RNDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != SET_OID) return RNDIS_STATUS_NOT_ACCEPTED; if (mp_stop_test(Adapter) == _FAIL) - status = RNDIS_STATUS_NOT_ACCEPTED; - return status; + return RNDIS_STATUS_NOT_ACCEPTED; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv @@ -350,64 +349,58 @@ uint oid_rt_pro_set_tx_power_control_hdl( uint oid_rt_pro_query_tx_packet_sent_hdl( struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = RNDIS_STATUS_NOT_ACCEPTED; - return status; - } + if (poid_par_priv->type_of_oid != QUERY_OID) + return RNDIS_STATUS_NOT_ACCEPTED; + if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.tx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else { - status = RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; } - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_query_rx_packet_received_hdl( struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = RNDIS_STATUS_NOT_ACCEPTED; - return status; - } + if (poid_par_priv->type_of_oid != QUERY_OID) + return RNDIS_STATUS_NOT_ACCEPTED; + if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else { - status = RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; } - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_query_rx_packet_crc32_error_hdl( struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); - if (poid_par_priv->type_of_oid != QUERY_OID) { - status = RNDIS_STATUS_NOT_ACCEPTED; - return status; - } + if (poid_par_priv->type_of_oid != QUERY_OID) + return RNDIS_STATUS_NOT_ACCEPTED; + if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; } else { - status = RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; } - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv @@ -425,7 +418,6 @@ uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { - uint status = RNDIS_STATUS_SUCCESS; struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -435,9 +427,9 @@ uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv Adapter->mppriv.rx_pktcount = 0; Adapter->mppriv.rx_crcerrpktcount = 0; } else { - status = RNDIS_STATUS_INVALID_LENGTH; + return RNDIS_STATUS_INVALID_LENGTH; } - return status; + return RNDIS_STATUS_SUCCESS; } uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv -- cgit v1.2.3-59-g8ed1b From 02d7aa2f3bfa3969f9805a47dd620609f31bb626 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sun, 13 Oct 2019 01:19:16 +0300 Subject: staging: rtl8712: clean up function headers Remove unnecessary line-breaks in function headers to improve readability of function headers. Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/c14b9e60b1e9bab635bc9527cbd2a2a07436ba44.1570918228.git.wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 57 ++++++++++-------------------- 1 file changed, 19 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 8af7892809ca..29b85330815f 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -231,8 +231,7 @@ end_of_mp_stop_test: return _SUCCESS; } -uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -291,8 +290,7 @@ uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -327,8 +325,7 @@ uint oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_tx_power_control_hdl( - struct oid_par_priv *poid_par_priv) +uint oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -346,8 +343,7 @@ uint oid_rt_pro_set_tx_power_control_hdl( return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_query_tx_packet_sent_hdl( - struct oid_par_priv *poid_par_priv) +uint oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -365,8 +361,7 @@ uint oid_rt_pro_query_tx_packet_sent_hdl( return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_query_rx_packet_received_hdl( - struct oid_par_priv *poid_par_priv) +uint oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -384,8 +379,7 @@ uint oid_rt_pro_query_rx_packet_received_hdl( return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_query_rx_packet_crc32_error_hdl( - struct oid_par_priv *poid_par_priv) +uint oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -403,8 +397,7 @@ uint oid_rt_pro_query_rx_packet_crc32_error_hdl( return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -415,8 +408,7 @@ uint oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -432,8 +424,7 @@ uint oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -444,8 +435,7 @@ uint oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -460,8 +450,7 @@ uint oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -476,8 +465,7 @@ uint oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -489,8 +477,7 @@ uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -503,8 +490,7 @@ uint oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -517,8 +503,7 @@ uint oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -531,8 +516,7 @@ uint oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -545,8 +529,7 @@ uint oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv return RNDIS_STATUS_SUCCESS; } -uint oid_rt_pro_read_register_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -727,8 +710,7 @@ uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) } /*----------------------------------------------------------------------*/ -uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); @@ -821,8 +803,7 @@ uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) return RNDIS_STATUS_SUCCESS; } -uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv - *poid_par_priv) +uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) { struct _adapter *Adapter = (struct _adapter *) (poid_par_priv->adapter_context); -- cgit v1.2.3-59-g8ed1b From 29c03456f157e6c1a29fa546e30ca4eb73e6e79a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 13 Oct 2019 15:12:48 +0200 Subject: staging: rtl8188eu: remove braces from single statement if block Remove braces from single statement if block to comply with kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191013131249.34422-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 1ec3b237212e..e764436e120f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -2045,9 +2045,9 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) while (1) { do_join_r = rtw_do_join(padapter); - if (do_join_r == _SUCCESS) { + if (do_join_r == _SUCCESS) break; - } + DBG_88E("roaming do_join return %d\n", do_join_r); pmlmepriv->to_roaming--; -- cgit v1.2.3-59-g8ed1b From 51a50b26c6dd296413350744722e4e5964c0991a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 13 Oct 2019 15:12:49 +0200 Subject: staging: rtl8188eu: remove unnecessary conversion to bool Comparsions evaluate to bool, explicit conversion with ternary operator is overly verbose and unnecessary, so remove it. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191013131249.34422-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 7b16632048b7..03dc7e5fcc38 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -514,7 +514,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; else pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ - pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE) ? true : false; + pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE); pwrctrlpriv->bFwCurrentInPSMode = false; @@ -621,7 +621,7 @@ int rtw_pm_set_lps(struct adapter *padapter, u8 mode) else pwrctrlpriv->LpsIdleCount = 2; pwrctrlpriv->power_mgnt = mode; - pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE) ? true : false; + pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE); } } else { ret = -EINVAL; -- cgit v1.2.3-59-g8ed1b From 388fa43d5979c400be9a73649058b33a2701cea0 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sun, 13 Oct 2019 21:47:50 +0300 Subject: staging: vc04_services: use DIV_ROUND_UP helper macro Replace open-coded division calculation with the DIV_ROUND_UP helper macro for better readability. Issue found using coccinelle: @@ expression n,d; @@ ( - ((n + d - 1) / d) + DIV_ROUND_UP(n,d) | - ((n + (d - 1)) / d) + DIV_ROUND_UP(n,d) ) Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191013184750.32766-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 63f71b2a492f..75104986201b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -60,8 +60,8 @@ vchiq_static_assert(IS_POW2(VCHIQ_MAX_SLOTS_PER_SIDE)); #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) #define VCHIQ_SLOT_QUEUE_MASK (VCHIQ_MAX_SLOTS_PER_SIDE - 1) -#define VCHIQ_SLOT_ZERO_SLOTS ((sizeof(struct vchiq_slot_zero) + \ - VCHIQ_SLOT_SIZE - 1) / VCHIQ_SLOT_SIZE) +#define VCHIQ_SLOT_ZERO_SLOTS DIV_ROUND_UP(sizeof(struct vchiq_slot_zero), \ + VCHIQ_SLOT_SIZE) #define VCHIQ_MSG_PADDING 0 /* - */ #define VCHIQ_MSG_CONNECT 1 /* - */ -- cgit v1.2.3-59-g8ed1b From 807411911d99fe13ade4c02db4606f2df672f589 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Sun, 13 Oct 2019 22:10:27 +0300 Subject: staging: rtl8723bs: use DIV_ROUND_UP helper macro Use the DIV_ROUND_UP macro to replace open-coded divisor calculation to improve readability. Issue found using coccinelle: @@ expression n,d; @@ ( - ((n + d - 1) / d) + DIV_ROUND_UP(n,d) | - ((n + (d - 1)) / d) + DIV_ROUND_UP(n,d) ) Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191013191027.6470-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 87535a4c2e14..22931ab3a5fc 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -4156,9 +4156,8 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) break; } - /* The value of ((usNavUpper + HAL_NAV_UPPER_UNIT_8723B - 1) / HAL_NAV_UPPER_UNIT_8723B) */ - /* is getting the upper integer. */ - usNavUpper = (usNavUpper + HAL_NAV_UPPER_UNIT_8723B - 1) / HAL_NAV_UPPER_UNIT_8723B; + usNavUpper = DIV_ROUND_UP(usNavUpper, + HAL_NAV_UPPER_UNIT_8723B); rtw_write8(padapter, REG_NAV_UPPER, (u8)usNavUpper); } break; -- cgit v1.2.3-59-g8ed1b From 44288f1101feba11beef9536b176dadae420d874 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Fri, 11 Oct 2019 10:16:41 +0000 Subject: staging: wfx: fix error handling in wfx_tx_get_raw_link_id() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since wfx_tx_get_raw_link_id() return an unsigned, it makes no sense to return a negative value. "15" is a better value since it is used by firmware for stations that have not yet associated link-ids. Note that this should never happens since driver set max_ap_assoc_sta to 14. Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191011101639.31025-1-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 6e4dd4ac5544..8ed38cac19f6 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -17,6 +17,7 @@ #include "hif_tx_mib.h" #define WFX_INVALID_RATE_ID (0xFF) +#define WFX_LINK_ID_NO_ASSOC 15 #define WFX_LINK_ID_GC_TIMEOUT ((unsigned long)(10 * HZ)) static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate *rate) @@ -480,7 +481,7 @@ static uint8_t wfx_tx_get_raw_link_id(struct wfx_vif *wvif, struct ieee80211_sta ret = wfx_alloc_link_id(wvif, da); if (!ret) { dev_err(wvif->wdev->dev, "no more link-id available\n"); - return -ENOENT; + return WFX_LINK_ID_NO_ASSOC; } return ret; } -- cgit v1.2.3-59-g8ed1b From 88d0facf186c6c652c2203536fecd77089b43a4e Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Fri, 11 Oct 2019 16:47:51 +0000 Subject: staging: wfx: fix potential vulnerability to spectre MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit array_index_nospec() should be applied after a bound check. Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191011164746.2518-1-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/wfx.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 489836837b0a..d678b5a08873 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "bh.h" @@ -138,6 +139,7 @@ static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) dev_dbg(wdev->dev, "requesting non-existent vif: %d\n", vif_id); return NULL; } + vif_id = array_index_nospec(vif_id, ARRAY_SIZE(wdev->vif)); if (!wdev->vif[vif_id]) { dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", vif_id); return NULL; -- cgit v1.2.3-59-g8ed1b From bbecf7de097690af75d9a292a6ac1316092a7389 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 15 Oct 2019 19:55:11 +0800 Subject: staging: rtl8723bs: remove unnecessary null check Null check before kfree is redundant, so remove it. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191015115511.26560-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 7011c2aa25cb..6d193f137b7e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2206,12 +2206,9 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter) void rtw_free_hwxmits(struct adapter *padapter) { - struct hw_xmit *hwxmits; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - hwxmits = pxmitpriv->hwxmits; - if (hwxmits) - kfree(hwxmits); + kfree(pxmitpriv->hwxmits); } void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry) -- cgit v1.2.3-59-g8ed1b From f57ff0a9b806ebce507e699e4a4ee2c6f06178fc Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Tue, 15 Oct 2019 14:26:37 +0300 Subject: staging: rtl8723bs: remove casts to pointers in kfree Remove unnecessary casts in pointer types passed to kfree. Signed-off-by: Wambui Karuga Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191015112637.20824-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 3030ae5b6b6d..71fcb466019a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2155,7 +2155,7 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm)); if (!psetauthparm) { - kfree((unsigned char *)pcmd); + kfree(pcmd); res = _FAIL; goto exit; } @@ -2238,7 +2238,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s if (enqueue) { pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (!pcmd) { - kfree((unsigned char *)psetkeyparm); + kfree(psetkeyparm); res = _FAIL; /* try again */ goto exit; } -- cgit v1.2.3-59-g8ed1b From d9cceb24b407d57229d45853f9c399623e768d39 Mon Sep 17 00:00:00 2001 From: Wambui Karuga Date: Tue, 15 Oct 2019 11:47:31 +0300 Subject: staging: octeon: fix restricted __be16 degrades to integer Add cast to fix the following sparse warning: warning: restricted __be16 degrades to integer Signed-off-by: Wambui Karuga Link: https://lore.kernel.org/r/20191015084731.8514-1-wambui.karugax@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c index 5114273826ec..b334cf89794e 100644 --- a/drivers/staging/octeon/ethernet-tx.c +++ b/drivers/staging/octeon/ethernet-tx.c @@ -598,7 +598,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev) #endif work->word2.s.is_frag = !((ip_hdr(skb)->frag_off == 0) || (ip_hdr(skb)->frag_off == - 1 << 14)); + cpu_to_be16(1 << 14))); #if 0 /* Assume Linux is sending a good packet */ work->word2.s.IP_exc = 0; -- cgit v1.2.3-59-g8ed1b From b0906aa3f7ecf29992bca52a29f6d1116bfde319 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 15 Oct 2019 17:45:33 +0200 Subject: staging: rtl8188eu: rename variables to avoid mixed case Rename local variables to avoid mixed case. max_AMPDU_len -> max_ampdu_len min_MPDU_spacing -> min_mpdu_spacing Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191015154535.27979-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index c985b1468d41..6d56ca7ee7b4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -667,7 +667,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { unsigned int i; - u8 max_AMPDU_len, min_MPDU_spacing; + u8 max_ampdu_len, min_mpdu_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -689,16 +689,16 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) } else { /* modify from fw by Thomas 2010/11/17 */ if ((pmlmeinfo->HT_caps.ampdu_params_info & 0x3) > (pIE->data[i] & 0x3)) - max_AMPDU_len = pIE->data[i] & 0x3; + max_ampdu_len = pIE->data[i] & 0x3; else - max_AMPDU_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x3; + max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x3; if ((pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) > (pIE->data[i] & 0x1c)) - min_MPDU_spacing = pmlmeinfo->HT_caps.ampdu_params_info & 0x1c; + min_mpdu_spacing = pmlmeinfo->HT_caps.ampdu_params_info & 0x1c; else - min_MPDU_spacing = pIE->data[i] & 0x1c; + min_mpdu_spacing = pIE->data[i] & 0x1c; - pmlmeinfo->HT_caps.ampdu_params_info = max_AMPDU_len | min_MPDU_spacing; + pmlmeinfo->HT_caps.ampdu_params_info = max_ampdu_len | min_mpdu_spacing; } } @@ -729,8 +729,8 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void HTOnAssocRsp(struct adapter *padapter) { - unsigned char max_AMPDU_len; - unsigned char min_MPDU_spacing; + unsigned char max_ampdu_len; + unsigned char min_mpdu_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -748,13 +748,13 @@ void HTOnAssocRsp(struct adapter *padapter) * AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k * AMPDU_para [4:2]:Min MPDU Start Spacing */ - max_AMPDU_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; + max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; - min_MPDU_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; + min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_mpdu_spacing)); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_ampdu_len)); } void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -- cgit v1.2.3-59-g8ed1b From ec26697cd92d5c2f66bba58a15b88d254a87d62e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 15 Oct 2019 17:45:34 +0200 Subject: staging: rtl8188eu: convert variables from unsigned char to u8 Convert the local variables max_ampdu_len and min_mpdu_spacing from unsigned char to u8 and remove unnecessary castings to u8 pointer. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191015154535.27979-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 6d56ca7ee7b4..1e261ff8f0a0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -729,8 +729,8 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void HTOnAssocRsp(struct adapter *padapter) { - unsigned char max_ampdu_len; - unsigned char min_mpdu_spacing; + u8 max_ampdu_len; + u8 min_mpdu_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -752,9 +752,9 @@ void HTOnAssocRsp(struct adapter *padapter) min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_mpdu_spacing)); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_ampdu_len)); + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); } void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -- cgit v1.2.3-59-g8ed1b From 5ffa18ec0b7459823bfd52bfa7d5033fafafa08c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 15 Oct 2019 17:45:35 +0200 Subject: staging: rtl8188eu: remove blank lines Remove blank lines to reduce whitespace and improve readability. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191015154535.27979-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 1e261ff8f0a0..af8a79ce8736 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -749,11 +749,9 @@ void HTOnAssocRsp(struct adapter *padapter) * AMPDU_para [4:2]:Min MPDU Start Spacing */ max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; - min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); } -- cgit v1.2.3-59-g8ed1b From 8193e6ad6916030845c5b2c0492ea19315a40a4d Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Mon, 14 Oct 2019 20:12:12 -0700 Subject: staging: sm750fb: Fix lines over 80 characters Fix lines over 80 character warnings. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/1f635b0469f93d8460d513f5fabd877dc5054a33.1571108943.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_display.c | 4 ++-- drivers/staging/sm750fb/ddk750_mode.c | 5 +++-- drivers/staging/sm750fb/ddk750_sii164.c | 28 +++++++++++++++++++--------- drivers/staging/sm750fb/ddk750_sii164.h | 11 +++++++---- 4 files changed, 31 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/ddk750_display.c b/drivers/staging/sm750fb/ddk750_display.c index 887ea8aef43f..172624ff98b0 100644 --- a/drivers/staging/sm750fb/ddk750_display.c +++ b/drivers/staging/sm750fb/ddk750_display.c @@ -147,8 +147,8 @@ void ddk750_set_logical_disp_out(enum disp_output output) if (output & PNL_SEQ_USAGE) { /* set panel sequence */ - sw_panel_power_sequence((output & PNL_SEQ_MASK) >> PNL_SEQ_OFFSET, - 4); + sw_panel_power_sequence((output & PNL_SEQ_MASK) >> + PNL_SEQ_OFFSET, 4); } if (output & DAC_USAGE) diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c index e0230f4ffc8b..e00a6cb31947 100644 --- a/drivers/staging/sm750fb/ddk750_mode.c +++ b/drivers/staging/sm750fb/ddk750_mode.c @@ -13,8 +13,9 @@ * HW only supports 7 predefined pixel clocks, and clock select is * in bit 29:27 of Display Control register. */ -static unsigned long displayControlAdjust_SM750LE(struct mode_parameter *pModeParam, - unsigned long dispControl) +static unsigned long +displayControlAdjust_SM750LE(struct mode_parameter *pModeParam, + unsigned long dispControl) { unsigned long x, y; diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c index c8e856c13912..bee58edc84e7 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.c +++ b/drivers/staging/sm750fb/ddk750_sii164.c @@ -39,8 +39,10 @@ unsigned short sii164GetVendorID(void) { unsigned short vendorID; - vendorID = ((unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_HIGH) << 8) | - (unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_VENDOR_ID_LOW); + vendorID = ((unsigned short)i2cReadReg(SII164_I2C_ADDRESS, + SII164_VENDOR_ID_HIGH) << 8) | + (unsigned short)i2cReadReg(SII164_I2C_ADDRESS, + SII164_VENDOR_ID_LOW); return vendorID; } @@ -56,13 +58,18 @@ unsigned short sii164GetDeviceID(void) { unsigned short deviceID; - deviceID = ((unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_HIGH) << 8) | - (unsigned short)i2cReadReg(SII164_I2C_ADDRESS, SII164_DEVICE_ID_LOW); + deviceID = ((unsigned short)i2cReadReg(SII164_I2C_ADDRESS, + SII164_DEVICE_ID_HIGH) << 8) | + (unsigned short)i2cReadReg(SII164_I2C_ADDRESS, + SII164_DEVICE_ID_LOW); return deviceID; } -/* DVI.C will handle all SiI164 chip stuffs and try it best to make code minimal and useful */ +/* + * DVI.C will handle all SiI164 chip stuffs and try its best to make code + * minimal and useful + */ /* * sii164InitChip @@ -133,7 +140,8 @@ long sii164InitChip(unsigned char edge_select, #endif /* Check if SII164 Chip exists */ - if ((sii164GetVendorID() == SII164_VENDOR_ID) && (sii164GetDeviceID() == SII164_DEVICE_ID)) { + if ((sii164GetVendorID() == SII164_VENDOR_ID) && + (sii164GetDeviceID() == SII164_DEVICE_ID)) { /* * Initialize SII164 controller chip. */ @@ -254,7 +262,9 @@ void sii164ResetChip(void) /* * sii164GetChipString - * This function returns a char string name of the current DVI Controller chip. + * This function returns a char string name of the current DVI Controller + * chip. + * * It's convenient for application need to display the chip name. */ char *sii164GetChipString(void) @@ -330,8 +340,8 @@ void sii164EnableHotPlugDetection(unsigned char enableHotPlug) detectReg = i2cReadReg(SII164_I2C_ADDRESS, SII164_DETECT); - /* Depending on each DVI controller, need to enable the hot plug based on each - * individual chip design. + /* Depending on each DVI controller, need to enable the hot plug based + * on each individual chip design. */ if (enableHotPlug != 0) sii164SelectHotPlugDetectionMode(SII164_HOTPLUG_USE_MDI); diff --git a/drivers/staging/sm750fb/ddk750_sii164.h b/drivers/staging/sm750fb/ddk750_sii164.h index 862e7bf27353..d940cb729066 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.h +++ b/drivers/staging/sm750fb/ddk750_sii164.h @@ -6,10 +6,13 @@ /* Hot Plug detection mode structure */ enum sii164_hot_plug_mode { - SII164_HOTPLUG_DISABLE = 0, /* Disable Hot Plug output bit (always high). */ - SII164_HOTPLUG_USE_MDI, /* Use Monitor Detect Interrupt bit. */ - SII164_HOTPLUG_USE_RSEN, /* Use Receiver Sense detect bit. */ - SII164_HOTPLUG_USE_HTPLG /* Use Hot Plug detect bit. */ + SII164_HOTPLUG_DISABLE = 0, /* Disable Hot Plug output bit + * (always high). + */ + + SII164_HOTPLUG_USE_MDI, /* Use Monitor Detect Interrupt bit. */ + SII164_HOTPLUG_USE_RSEN, /* Use Receiver Sense detect bit. */ + SII164_HOTPLUG_USE_HTPLG /* Use Hot Plug detect bit. */ }; /* Silicon Image SiI164 chip prototype */ -- cgit v1.2.3-59-g8ed1b From a96de139301385e5992768c0f60240ddfbb33325 Mon Sep 17 00:00:00 2001 From: Chuhong Yuan Date: Wed, 16 Oct 2019 22:25:40 +0800 Subject: staging: iio: ad9834: add a check for devm_clk_get ad9834_probe misses a check for devm_clk_get and may cause problems. Add a check like what ad9832 does to fix it. Signed-off-by: Chuhong Yuan Reviewed-by: Dan Carpenter Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/frequency/ad9834.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 038d6732c3fd..23026978a5a5 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -417,6 +417,10 @@ static int ad9834_probe(struct spi_device *spi) st = iio_priv(indio_dev); mutex_init(&st->lock); st->mclk = devm_clk_get(&spi->dev, NULL); + if (IS_ERR(st->mclk)) { + ret = PTR_ERR(st->mclk); + goto error_disable_reg; + } ret = clk_prepare_enable(st->mclk); if (ret) { -- cgit v1.2.3-59-g8ed1b From 6fc77fc892d87fcaf2d06129d1fadaea09f4e3dd Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 16 Oct 2019 17:03:05 +0800 Subject: staging: ralink-gdma: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191016090305.23392-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ralink-gdma/ralink-gdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c b/drivers/staging/ralink-gdma/ralink-gdma.c index 900424db9b97..eabf1093328e 100644 --- a/drivers/staging/ralink-gdma/ralink-gdma.c +++ b/drivers/staging/ralink-gdma/ralink-gdma.c @@ -796,7 +796,6 @@ static int gdma_dma_probe(struct platform_device *pdev) struct gdma_dma_dev *dma_dev; struct dma_device *dd; unsigned int i; - struct resource *res; int ret; int irq; void __iomem *base; @@ -818,8 +817,7 @@ static int gdma_dma_probe(struct platform_device *pdev) return -EINVAL; dma_dev->data = data; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); + base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); dma_dev->base = base; -- cgit v1.2.3-59-g8ed1b From f1ca32696aea8e65b0b5122b494b52e128e66630 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 16 Oct 2019 17:01:36 +0800 Subject: staging: netlogic: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191016090136.20620-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/netlogic/xlr_net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c index 05079f7be841..204fcdfc022f 100644 --- a/drivers/staging/netlogic/xlr_net.c +++ b/drivers/staging/netlogic/xlr_net.c @@ -976,8 +976,7 @@ static int xlr_net_probe(struct platform_device *pdev) priv->ndev = ndev; priv->port_id = (pdev->id * 4) + port; priv->nd = (struct xlr_net_data *)pdev->dev.platform_data; - res = platform_get_resource(pdev, IORESOURCE_MEM, port); - priv->base_addr = devm_ioremap_resource(&pdev->dev, res); + priv->base_addr = devm_platform_ioremap_resource(pdev, port); if (IS_ERR(priv->base_addr)) { err = PTR_ERR(priv->base_addr); goto err_gmac; -- cgit v1.2.3-59-g8ed1b From 390e4f967299179d5b43a3d265150500d8fe2986 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 16 Oct 2019 16:58:33 +0800 Subject: staging: mt7621-dma: use devm_platform_ioremap_resource() to simplify code Use devm_platform_ioremap_resource() to simplify the code a bit. This is detected by coccinelle. Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191016085833.26376-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index d964642d95a3..03c8937f80b0 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -650,7 +650,6 @@ static int mtk_hsdma_probe(struct platform_device *pdev) struct mtk_hsdma_chan *chan; struct mtk_hsdam_engine *hsdma; struct dma_device *dd; - struct resource *res; int ret; int irq; void __iomem *base; @@ -667,8 +666,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev) if (!hsdma) return -EINVAL; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&pdev->dev, res); + base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); hsdma->base = base + HSDMA_BASE_OFFSET; -- cgit v1.2.3-59-g8ed1b From bb84f28f0d865a4c0b4a7405683d32748b27d03a Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 16 Oct 2019 09:58:34 +0300 Subject: staging: rtl8188eu: make efuse_power_switch() function static The `rtl8188eu` driver is built as a kmod in order to avoid symbol conflicts (at link-time) with other Realtek drivers. Internally, we use this driver as builtin [vs kmod], and we've identified the `efuse_power_switch()` symbol to be conflicting at link-time with the one from the `rtlwifi` driver. An alternative solution would have been to rename the function, but it doesn't look like it's being used outside of this driver, so just make it static. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20191016065834.12186-1-alexandru.ardelean@analog.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 2 +- drivers/staging/rtl8188eu/include/rtw_efuse.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index d191dbef0bb3..d9b0f9e6235c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -25,7 +25,7 @@ enum{ * When we want to enable write operation, we should change to pwr on state. * When we stop write, we should switch to 500k mode and disable LDO 2.5V. */ -void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) +static void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) { u8 tempval; u16 tmpv16; diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h index 3ec53761e9fd..7a9c8ff0daa9 100644 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -82,7 +82,6 @@ u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data); void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf); -void efuse_power_switch(struct adapter *adapt, u8 write, u8 pwrstate); int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data); bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data); void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); -- cgit v1.2.3-59-g8ed1b From be88dae8e2a9cda2b900040318c70a3d3c5b21cd Mon Sep 17 00:00:00 2001 From: Aliasgar Surti Date: Thu, 17 Oct 2019 19:48:26 +0530 Subject: staging: rtl8723bs: removed unwanted if..else condition There is use of if..elseif..else condition which has same logic in all three blocks. Removed if..else block and placed log message instead that. Signed-off-by: Aliasgar Surti Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/1571321906-15074-1-git-send-email-aliasgar.surti500@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index e6fea9665dff..13a9b54b4561 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -507,19 +507,9 @@ post_process: cmd_process_time = jiffies_to_msecs(jiffies - cmd_start_time); if (cmd_process_time > 1000) { - if (pcmd->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) { - DBG_871X(ADPT_FMT" cmd =%d process_time =%lu > 1 sec\n", - ADPT_ARG(pcmd->padapter), pcmd->cmdcode, cmd_process_time); - /* rtw_warn_on(1); */ - } else if (pcmd->cmdcode == GEN_CMD_CODE(_Set_MLME_EVT)) { - DBG_871X(ADPT_FMT" cmd =%d, process_time =%lu > 1 sec\n", - ADPT_ARG(pcmd->padapter), pcmd->cmdcode, cmd_process_time); - /* rtw_warn_on(1); */ - } else { - DBG_871X(ADPT_FMT" cmd =%d, process_time =%lu > 1 sec\n", - ADPT_ARG(pcmd->padapter), pcmd->cmdcode, cmd_process_time); - /* rtw_warn_on(1); */ - } + DBG_871X(ADPT_FMT "cmd= %d process_time= %lu > 1 sec\n", + ADPT_ARG(pcmd->padapter), pcmd->cmdcode, + cmd_process_time); } /* call callback function for post-processed */ -- cgit v1.2.3-59-g8ed1b From 9f665d82039187072263e22294ab6e290312f6bf Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 18 Oct 2019 11:48:37 +0100 Subject: staging: rtl8723bs: reduce stack usage of rtw_cfg80211_unlink_bss The build of xtensa allmodconfig gives warning of: In function 'rtw_cfg80211_unlink_bss': warning: the frame size of 1136 bytes is larger than 1024 bytes Instead of having 'select_network' structure as a variable use it as a pointer. Signed-off-by: Sudip Mukherjee Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20191018104837.23246-1-sudipm.mukherjee@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 8555f52ceb7c..02f493d0b83b 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1410,16 +1410,17 @@ void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnet struct wireless_dev *pwdev = padapter->rtw_wdev; struct wiphy *wiphy = pwdev->wiphy; struct cfg80211_bss *bss = NULL; - struct wlan_bssid_ex select_network = pnetwork->network; + struct wlan_bssid_ex *select_network = &pnetwork->network; bss = cfg80211_get_bss(wiphy, NULL/*notify_channel*/, - select_network.MacAddress, select_network.Ssid.Ssid, - select_network.Ssid.SsidLength, 0/*WLAN_CAPABILITY_ESS*/, + select_network->MacAddress, select_network->Ssid.Ssid, + select_network->Ssid.SsidLength, 0/*WLAN_CAPABILITY_ESS*/, 0/*WLAN_CAPABILITY_ESS*/); if (bss) { cfg80211_unlink_bss(wiphy, bss); - DBG_8192C("%s(): cfg80211_unlink %s!! () ", __func__, select_network.Ssid.Ssid); + DBG_8192C("%s(): cfg80211_unlink %s!! () ", __func__, + select_network->Ssid.Ssid); cfg80211_put_bss(padapter->rtw_wdev->wiphy, bss); } } -- cgit v1.2.3-59-g8ed1b From f306bde1860d1572993e4a6f48b02944d0a7e918 Mon Sep 17 00:00:00 2001 From: Sudip Mukherjee Date: Fri, 18 Oct 2019 11:18:54 +0100 Subject: staging: rtl8723bs: reduce stack usage of cfg80211_rtw_scan The build of xtensa allmodconfig gives warning of: In function 'cfg80211_rtw_scan': warning: the frame size of 1040 bytes is larger than 1024 bytes Allocate memory for ssid dynamically to reduce the stack usage, as an added benifit we can remove the memset by using kzalloc while allocating memory. Signed-off-by: Sudip Mukherjee Link: https://lore.kernel.org/r/20191018101854.31876-1-sudipm.mukherjee@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 02f493d0b83b..a25c535b6b4f 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1513,7 +1513,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy int i; u8 _status = false; int ret = 0; - struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; + struct ndis_802_11_ssid *ssid = NULL; struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; u8 survey_times =3; u8 survey_times_for_one_ch =6; @@ -1604,7 +1604,13 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy goto check_need_indicate_scan_done; } - memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); + ssid = kzalloc(RTW_SSID_SCAN_AMOUNT * sizeof(struct ndis_802_11_ssid), + GFP_KERNEL); + if (!ssid) { + ret = -ENOMEM; + goto check_need_indicate_scan_done; + } + /* parsing request ssids, n_ssids */ for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) { #ifdef DEBUG_CFG80211 @@ -1648,6 +1654,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy } check_need_indicate_scan_done: + kfree(ssid); if (need_indicate_scan_done) { rtw_cfg80211_surveydone_event_callback(padapter); -- cgit v1.2.3-59-g8ed1b From 2f2e28866bd7bb1b4d73e338d22100d4edf710ec Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:12 -0400 Subject: staging: exfat: Clean up return codes - FFS_FULL Start cleaning up the odd scheme of return codes, starting with FFS_FULL Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-2-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_core.c | 10 +++++----- drivers/staging/exfat/exfat_super.c | 16 ++++++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 3abab33e932c..548b7ada3c44 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i) #define FFS_PERMISSIONERR 11 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 -#define FFS_FULL 14 #define FFS_EOF 15 #define FFS_DIRBUSY 16 #define FFS_MEMORYERR 17 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 79174e5c4145..5ac57e573764 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -3216,7 +3216,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, /* find_empty_entry must be called before alloc_cluster */ dentry = find_empty_entry(inode, p_dir, num_entries); if (dentry < 0) - return FFS_FULL; + return -ENOSPC; clu.dir = CLUSTER_32(~0); clu.size = 0; @@ -3227,7 +3227,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, if (ret < 0) return FFS_MEDIAERR; else if (ret == 0) - return FFS_FULL; + return -ENOSPC; ret = clear_cluster(sb, clu.dir); if (ret != FFS_SUCCESS) @@ -3319,7 +3319,7 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir, /* find_empty_entry must be called before alloc_cluster() */ dentry = find_empty_entry(inode, p_dir, num_entries); if (dentry < 0) - return FFS_FULL; + return -ENOSPC; /* (1) update the directory entry */ /* fill the dos name directory entry information of the created file. @@ -3418,7 +3418,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, newentry = find_empty_entry(inode, p_dir, num_new_entries); if (newentry < 0) { buf_unlock(sb, sector_old); - return FFS_FULL; + return -ENOSPC; } epnew = get_entry_in_dir(sb, p_dir, newentry, §or_new); @@ -3529,7 +3529,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, newentry = find_empty_entry(inode, p_newdir, num_new_entries); if (newentry < 0) { buf_unlock(sb, sector_mov); - return FFS_FULL; + return -ENOSPC; } epnew = get_entry_in_dir(sb, p_newdir, newentry, §or_new); diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 86ace780a60b..90ae0f2841f2 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -1051,7 +1051,7 @@ err_out: *wcount = write_bytes; if (num_alloced == 0) - ret = FFS_FULL; + ret = -ENOSPC; else if (p_fs->dev_ejected) ret = FFS_MEDIAERR; @@ -1807,7 +1807,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) ret = FFS_MEDIAERR; goto out; } else if (num_alloced == 0) { - ret = FFS_FULL; + ret = -ENOSPC; goto out; } @@ -2366,7 +2366,7 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, err = -EINVAL; else if (err == FFS_FILEEXIST) err = -EEXIST; - else if (err == FFS_FULL) + else if (err == -ENOSPC) err = -ENOSPC; else if (err == FFS_NAMETOOLONG) err = -ENAMETOOLONG; @@ -2577,7 +2577,7 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, err = -EINVAL; else if (err == FFS_FILEEXIST) err = -EEXIST; - else if (err == FFS_FULL) + else if (err == -ENOSPC) err = -ENOSPC; else err = -EIO; @@ -2589,7 +2589,7 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, if (err) { ffsRemoveFile(dir, &fid); - if (err == FFS_FULL) + if (err == -ENOSPC) err = -ENOSPC; else err = -EIO; @@ -2647,7 +2647,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) err = -EINVAL; else if (err == FFS_FILEEXIST) err = -EEXIST; - else if (err == FFS_FULL) + else if (err == -ENOSPC) err = -ENOSPC; else if (err == FFS_NAMETOOLONG) err = -ENAMETOOLONG; @@ -2760,7 +2760,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, err = -EEXIST; else if (err == FFS_NOTFOUND) err = -ENOENT; - else if (err == FFS_FULL) + else if (err == -ENOSPC) err = -ENOSPC; else err = -EIO; @@ -3115,7 +3115,7 @@ static int exfat_bmap(struct inode *inode, sector_t sector, sector_t *phys, err = ffsMapCluster(inode, clu_offset, &cluster); if (err) { - if (err == FFS_FULL) + if (err == -ENOSPC) return -ENOSPC; else return -EIO; -- cgit v1.2.3-59-g8ed1b From 67f8224c3b52908c100311bfef9d0fb60ae5b449 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:13 -0400 Subject: staging: exfat: Clean up return codes - FFS_NOTFOUND Convert FFS_NOTFOUND to -ENOENT Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-3-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_super.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 548b7ada3c44..26120dfcaba5 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i) #define FFS_SEMAPHOREERR 6 #define FFS_INVALIDPATH 7 #define FFS_INVALIDFID 8 -#define FFS_NOTFOUND 9 #define FFS_FILEEXIST 10 #define FFS_PERMISSIONERR 11 #define FFS_NOTOPENED 12 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 90ae0f2841f2..7b1ed81efadd 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -578,7 +578,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) dentry = p_fs->fs_func->find_dir_entry(sb, &dir, &uni_name, num_entries, &dos_name, TYPE_ALL); if (dentry < -1) { - ret = FFS_NOTFOUND; + ret = -ENOENT; goto out; } @@ -2701,7 +2701,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) err = -EINVAL; else if (err == FFS_FILEEXIST) err = -ENOTEMPTY; - else if (err == FFS_NOTFOUND) + else if (err == -ENOENT) err = -ENOENT; else if (err == FFS_DIRBUSY) err = -EBUSY; @@ -2758,7 +2758,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, err = -EINVAL; else if (err == FFS_FILEEXIST) err = -EEXIST; - else if (err == FFS_NOTFOUND) + else if (err == -ENOENT) err = -ENOENT; else if (err == -ENOSPC) err = -ENOSPC; -- cgit v1.2.3-59-g8ed1b From df7098f84f7eff2cb0a669557f2519f1ee68a74e Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:14 -0400 Subject: staging: exfat: Clean up return codes - FFS_DIRBUSY Convert FFS_DIRBUSY to -EBUSY Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-4-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_super.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 26120dfcaba5..f3736b33ca56 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i) #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 #define FFS_EOF 15 -#define FFS_DIRBUSY 16 #define FFS_MEMORYERR 17 #define FFS_NAMETOOLONG 18 #define FFS_ERROR 19 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 7b1ed81efadd..638de11eb625 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -2703,7 +2703,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) err = -ENOTEMPTY; else if (err == -ENOENT) err = -ENOENT; - else if (err == FFS_DIRBUSY) + else if (err == -EBUSY) err = -EBUSY; else err = -EIO; -- cgit v1.2.3-59-g8ed1b From 7ca8049f09807004639dc7d44f1476ac6ef7c917 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:15 -0400 Subject: staging: exfat: Clean up return codes - FFS_PERMISSIONERR Convert FFS_PERMISSIONERR to -EPERM Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-5-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_super.c | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index f3736b33ca56..a6e0c79ba6a4 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -217,7 +217,6 @@ static inline u16 get_row_index(u16 i) #define FFS_INVALIDPATH 7 #define FFS_INVALIDFID 8 #define FFS_FILEEXIST 10 -#define FFS_PERMISSIONERR 11 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 #define FFS_EOF 15 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 638de11eb625..afa687a786a3 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -708,7 +708,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, /* check if the given file ID is opened */ if (fid->type != TYPE_FILE) { - ret = FFS_PERMISSIONERR; + ret = -EPERM; goto out; } @@ -838,7 +838,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, /* check if the given file ID is opened */ if (fid->type != TYPE_FILE) { - ret = FFS_PERMISSIONERR; + ret = -EPERM; goto out; } @@ -1085,7 +1085,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) /* check if the given file ID is opened */ if (fid->type != TYPE_FILE) { - ret = FFS_PERMISSIONERR; + ret = -EPERM; goto out; } @@ -1252,7 +1252,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, /* check if the old file is "." or ".." */ if (p_fs->vol_type != EXFAT) { if ((olddir.dir != p_fs->root_dir) && (dentry < 2)) { - ret = FFS_PERMISSIONERR; + ret = -EPERM; goto out2; } } @@ -1264,7 +1264,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, } if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) { - ret = FFS_PERMISSIONERR; + ret = -EPERM; goto out2; } @@ -1371,7 +1371,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) } if (p_fs->fs_func->get_entry_attr(ep) & ATTR_READONLY) { - ret = FFS_PERMISSIONERR; + ret = -EPERM; goto out; } fs_set_vol_flags(sb, VOL_DIRTY); @@ -1953,7 +1953,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) /* check if the given file ID is opened */ if (fid->type != TYPE_DIR) - return FFS_PERMISSIONERR; + return -EPERM; /* acquire the lock for file system critical section */ down(&p_fs->v_sem); @@ -2151,7 +2151,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) /* check if the file is "." or ".." */ if (p_fs->vol_type != EXFAT) { if ((dir.dir != p_fs->root_dir) && (dentry < 2)) - return FFS_PERMISSIONERR; + return -EPERM; } /* acquire the lock for file system critical section */ @@ -2532,7 +2532,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid)); if (err) { - if (err == FFS_PERMISSIONERR) + if (err == -EPERM) err = -EPERM; else err = -EIO; @@ -2752,7 +2752,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir, new_dentry); if (err) { - if (err == FFS_PERMISSIONERR) + if (err == -EPERM) err = -EPERM; else if (err == FFS_INVALIDPATH) err = -EINVAL; -- cgit v1.2.3-59-g8ed1b From ab5a321da0082f1877dab619f56b966997dbc4fb Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:16 -0400 Subject: staging: exfat: Clean up return codes - FFS_NAMETOOLONG Convert FFS_NOTNAMETOOLONG to -ENAMETOOLONG Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-6-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_super.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index a6e0c79ba6a4..0c8e8606472b 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -221,7 +221,6 @@ static inline u16 get_row_index(u16 i) #define FFS_MAXOPENED 13 #define FFS_EOF 15 #define FFS_MEMORYERR 17 -#define FFS_NAMETOOLONG 18 #define FFS_ERROR 19 #define NUM_UPCASE 2918 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index afa687a786a3..cf0300a4e0f4 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -2368,7 +2368,7 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, err = -EEXIST; else if (err == -ENOSPC) err = -ENOSPC; - else if (err == FFS_NAMETOOLONG) + else if (err == -ENAMETOOLONG) err = -ENAMETOOLONG; else err = -EIO; @@ -2649,7 +2649,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) err = -EEXIST; else if (err == -ENOSPC) err = -ENOSPC; - else if (err == FFS_NAMETOOLONG) + else if (err == -ENAMETOOLONG) err = -ENAMETOOLONG; else err = -EIO; -- cgit v1.2.3-59-g8ed1b From c76c4ad5470cd907ed9c432f0e8cabd924cc2b54 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:17 -0400 Subject: staging: exfat: Clean up return codes - FFS_FILEEXIST Convert FFS_FILEEXIST to -EEXIST Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-7-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_core.c | 2 +- drivers/staging/exfat/exfat_super.c | 14 +++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 0c8e8606472b..b7dac748aaf9 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i) #define FFS_SEMAPHOREERR 6 #define FFS_INVALIDPATH 7 #define FFS_INVALIDFID 8 -#define FFS_FILEEXIST 10 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 #define FFS_EOF 15 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 5ac57e573764..43aaa9566260 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -2828,7 +2828,7 @@ s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, } if ((count == 0) || (count >= 1024)) - return FFS_FILEEXIST; + return -EEXIST; fat_attach_count_to_dos_name(p_dosname->name, count); /* Now dos_name has DOS~????.EXT */ diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index cf0300a4e0f4..bc175b3366ac 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -1294,7 +1294,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, new_clu.flags = new_fid->flags; if (!is_dir_empty(sb, &new_clu)) { - ret = FFS_FILEEXIST; + ret = -EEXIST; goto out; } } @@ -2162,7 +2162,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) clu_to_free.flags = fid->flags; if (!is_dir_empty(sb, &clu_to_free)) { - ret = FFS_FILEEXIST; + ret = -EEXIST; goto out; } @@ -2364,7 +2364,7 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, if (err) { if (err == FFS_INVALIDPATH) err = -EINVAL; - else if (err == FFS_FILEEXIST) + else if (err == -EEXIST) err = -EEXIST; else if (err == -ENOSPC) err = -ENOSPC; @@ -2575,7 +2575,7 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, if (err) { if (err == FFS_INVALIDPATH) err = -EINVAL; - else if (err == FFS_FILEEXIST) + else if (err == -EEXIST) err = -EEXIST; else if (err == -ENOSPC) err = -ENOSPC; @@ -2645,7 +2645,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) if (err) { if (err == FFS_INVALIDPATH) err = -EINVAL; - else if (err == FFS_FILEEXIST) + else if (err == -EEXIST) err = -EEXIST; else if (err == -ENOSPC) err = -ENOSPC; @@ -2699,7 +2699,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) if (err) { if (err == FFS_INVALIDPATH) err = -EINVAL; - else if (err == FFS_FILEEXIST) + else if (err == -EEXIST) err = -ENOTEMPTY; else if (err == -ENOENT) err = -ENOENT; @@ -2756,7 +2756,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, err = -EPERM; else if (err == FFS_INVALIDPATH) err = -EINVAL; - else if (err == FFS_FILEEXIST) + else if (err == -EEXIST) err = -EEXIST; else if (err == -ENOENT) err = -ENOENT; -- cgit v1.2.3-59-g8ed1b From 03eac8d594738fc6a678a4df2176d17f9ee130f4 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:18 -0400 Subject: staging: exfat: Clean up return codes - FFS_INVALIDPATH Convert FFS_INVALIDPATH to -EINVAL Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-8-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_core.c | 10 +++++----- drivers/staging/exfat/exfat_super.c | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index b7dac748aaf9..8cb6d2e2ad8d 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -214,7 +214,6 @@ static inline u16 get_row_index(u16 i) #define FFS_NOTMOUNTED 4 #define FFS_ALIGNMENTERR 5 #define FFS_SEMAPHOREERR 6 -#define FFS_INVALIDPATH 7 #define FFS_INVALIDFID 8 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 43aaa9566260..0331fa6724ff 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -2571,7 +2571,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, num_entries = p_fs->fs_func->calc_num_entries(p_uniname); if (num_entries == 0) - return FFS_INVALIDPATH; + return -EINVAL; if (p_fs->vol_type != EXFAT) { nls_uniname_to_dosname(sb, p_dosname, p_uniname, &lossy); @@ -2583,7 +2583,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, } else { for (r = reserved_names; *r; r++) { if (!strncmp((void *)p_dosname->name, *r, 8)) - return FFS_INVALIDPATH; + return -EINVAL; } if (p_dosname->name_case != 0xFF) @@ -2962,11 +2962,11 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, struct file_id_t *fid = &(EXFAT_I(inode)->fid); if (strscpy(name_buf, path, sizeof(name_buf)) < 0) - return FFS_INVALIDPATH; + return -EINVAL; nls_cstring_to_uniname(sb, p_uniname, name_buf, &lossy); if (lossy) - return FFS_INVALIDPATH; + return -EINVAL; fid->size = i_size_read(inode); @@ -3506,7 +3506,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, /* check if the source and target directory is the same */ if (fs_func->get_entry_type(epmov) == TYPE_DIR && fs_func->get_entry_clu0(epmov) == p_newdir->dir) - return FFS_INVALIDPATH; + return -EINVAL; buf_lock(sb, sector_mov); diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index bc175b3366ac..dcf90b5f147b 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -2362,7 +2362,7 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_REGULAR, &fid); if (err) { - if (err == FFS_INVALIDPATH) + if (err == -EINVAL) err = -EINVAL; else if (err == -EEXIST) err = -EEXIST; @@ -2573,7 +2573,7 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_SYMLINK, &fid); if (err) { - if (err == FFS_INVALIDPATH) + if (err == -EINVAL) err = -EINVAL; else if (err == -EEXIST) err = -EEXIST; @@ -2643,7 +2643,7 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) err = ffsCreateDir(dir, (u8 *)dentry->d_name.name, &fid); if (err) { - if (err == FFS_INVALIDPATH) + if (err == -EINVAL) err = -EINVAL; else if (err == -EEXIST) err = -EEXIST; @@ -2697,7 +2697,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) err = ffsRemoveDir(dir, &(EXFAT_I(inode)->fid)); if (err) { - if (err == FFS_INVALIDPATH) + if (err == -EINVAL) err = -EINVAL; else if (err == -EEXIST) err = -ENOTEMPTY; @@ -2754,7 +2754,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, if (err) { if (err == -EPERM) err = -EPERM; - else if (err == FFS_INVALIDPATH) + else if (err == -EINVAL) err = -EINVAL; else if (err == -EEXIST) err = -EEXIST; -- cgit v1.2.3-59-g8ed1b From 630d00b8b26de7d0487df6c45a3afbdae66475e6 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Thu, 24 Oct 2019 11:53:19 -0400 Subject: staging: exfat: Clean up return code - FFS_MEMORYERR Convert FFS_MEMORYERR to -ENOMEM Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191024155327.1095907-9-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_core.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 8cb6d2e2ad8d..6142e880f682 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -218,7 +218,6 @@ static inline u16 get_row_index(u16 i) #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 #define FFS_EOF 15 -#define FFS_MEMORYERR 17 #define FFS_ERROR 19 #define NUM_UPCASE 2918 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 0331fa6724ff..80fd3f0d6db4 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -544,7 +544,7 @@ s32 load_alloc_bitmap(struct super_block *sb) sizeof(struct buffer_head *), GFP_KERNEL); if (!p_fs->vol_amap) - return FFS_MEMORYERR; + return -ENOMEM; sector = START_SECTOR(p_fs->map_clu); @@ -715,7 +715,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector, upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *), GFP_KERNEL); if (!upcase_table) - return FFS_MEMORYERR; + return -ENOMEM; memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *)); while (sector < end_sector) { @@ -755,7 +755,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector, upcase_table[col_index] = kmalloc_array(UTBL_ROW_COUNT, sizeof(u16), GFP_KERNEL); if (!upcase_table[col_index]) { - ret = FFS_MEMORYERR; + ret = -ENOMEM; goto error; } @@ -795,7 +795,7 @@ static s32 __load_default_upcase_table(struct super_block *sb) upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *), GFP_KERNEL); if (!upcase_table) - return FFS_MEMORYERR; + return -ENOMEM; memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *)); for (i = 0; index <= 0xFFFF && i < NUM_UPCASE * 2; i += 2) { @@ -818,7 +818,7 @@ static s32 __load_default_upcase_table(struct super_block *sb) sizeof(u16), GFP_KERNEL); if (!upcase_table[col_index]) { - ret = FFS_MEMORYERR; + ret = -ENOMEM; goto error; } -- cgit v1.2.3-59-g8ed1b From 77b97aa69bd08a889c78397193d7390cd6a51122 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Wed, 23 Oct 2019 15:52:06 +0800 Subject: staging: comedi: remove unused variable 'route_table_size' drivers/staging/comedi/drivers/ni_routes.c:52:21: warning: route_table_size defined but not used [-Wunused-const-variable=] It is never used since introduction. Signed-off-by: YueHaibing Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/20191023075206.33088-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_routes.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/ni_routes.c b/drivers/staging/comedi/drivers/ni_routes.c index eb61494dc2bd..673d732dcb8f 100644 --- a/drivers/staging/comedi/drivers/ni_routes.c +++ b/drivers/staging/comedi/drivers/ni_routes.c @@ -49,8 +49,6 @@ /* Helper for accessing data. */ #define RVi(table, src, dest) ((table)[(dest) * NI_NUM_NAMES + (src)]) -static const size_t route_table_size = NI_NUM_NAMES * NI_NUM_NAMES; - /* * Find the proper route_values and ni_device_routes tables for this particular * device. -- cgit v1.2.3-59-g8ed1b From c671dfdaedefc69000955b3a257538175bcb8aba Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Thu, 24 Oct 2019 15:39:37 -0700 Subject: staging: most: Change bool init to true/false Bool initializations should use true and false. Bool tests don't need comparisons. Based on contributions from Joe Perches, Rusty Russell and Bruce W Allan. The semantic patch that makes this report is available in scripts/coccinelle/misc/boolinit.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/20191024223937.2800-1-jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c index 025495657b68..64c65c217d07 100644 --- a/drivers/staging/most/configfs.c +++ b/drivers/staging/most/configfs.c @@ -487,7 +487,7 @@ static struct config_item *most_snd_grp_make_item(struct config_group *group, return ERR_PTR(-ENOMEM); config_item_init_type_name(&mdev_link->item, name, &mdev_link_type); - mdev_link->create_link = 0; + mdev_link->create_link = false; strcpy(mdev_link->name, name); strcpy(mdev_link->comp, "sound"); return &mdev_link->item; -- cgit v1.2.3-59-g8ed1b From 663328205c0d7b246cbf01247d4a81b15460f312 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Tue, 22 Oct 2019 19:53:28 +0100 Subject: staging: uwb: fix coccinelle warnings of comparison to bool Fix warnings of comparision to bool. Issue detected by coccinelle tool. Signed-off-by: Jules Irenge Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191022185328.9387-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/uwb/rsv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/uwb/rsv.c b/drivers/staging/uwb/rsv.c index f45a04ff7275..d593a41c3d8d 100644 --- a/drivers/staging/uwb/rsv.c +++ b/drivers/staging/uwb/rsv.c @@ -614,7 +614,7 @@ int uwb_rsv_try_move(struct uwb_rsv *rsv, struct uwb_mas_bm *available) struct uwb_rsv_move *mv; int ret = 0; - if (bow->can_reserve_extra_mases == false) + if (!bow->can_reserve_extra_mases) return -EBUSY; mv = &rsv->mv; @@ -643,7 +643,7 @@ void uwb_rsv_handle_drp_avail_change(struct uwb_rc *rc) struct uwb_rsv *rsv; struct uwb_mas_bm mas; - if (bow->can_reserve_extra_mases == false) + if (!bow->can_reserve_extra_mases) return; list_for_each_entry(rsv, &rc->reservations, rc_node) { -- cgit v1.2.3-59-g8ed1b From f44e565e91557ded98049e72ed9b63088ff88018 Mon Sep 17 00:00:00 2001 From: Evan Chime Date: Fri, 18 Oct 2019 18:57:25 +0100 Subject: Staging: Netlogic: Fix grammatical error Change "in to" in "Changing comments in to linux standred format" on line 3 to "into" Signed-off-by: Evan Chime Link: https://lore.kernel.org/r/20191018175725.GA8274@ik-ubuntu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/netlogic/TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/netlogic/TODO b/drivers/staging/netlogic/TODO index 8f172b017b94..de8fb8009ce3 100644 --- a/drivers/staging/netlogic/TODO +++ b/drivers/staging/netlogic/TODO @@ -1,6 +1,6 @@ * Implementing 64bit stat counter in software * All memory allocation should be changed to DMA allocations -* Changing comments in to linux standred format +* Changing comments into linux standred format Please send patches To: -- cgit v1.2.3-59-g8ed1b From 7fb50738e2f61e040cb3bfa46258e675267638c2 Mon Sep 17 00:00:00 2001 From: Evan Chime Date: Fri, 18 Oct 2019 18:57:59 +0100 Subject: Staging: Netlogic: Fix spelling mistake Change "standred" on line 3 to "standard" Signed-off-by: Evan Chime Link: https://lore.kernel.org/r/20191018175759.GA8294@ik-ubuntu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/netlogic/TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/netlogic/TODO b/drivers/staging/netlogic/TODO index de8fb8009ce3..20e22ecb9903 100644 --- a/drivers/staging/netlogic/TODO +++ b/drivers/staging/netlogic/TODO @@ -1,6 +1,6 @@ * Implementing 64bit stat counter in software * All memory allocation should be changed to DMA allocations -* Changing comments into linux standred format +* Changing comments into linux standard format Please send patches To: -- cgit v1.2.3-59-g8ed1b From b7697f054018ea2583a77d11b1547c50c805a841 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 17 Oct 2019 16:00:44 +0100 Subject: staging: vc04_services: fix check warnings of line over 80 characters Fix warnings of line over 80 characters. Issue detected by checkepatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191017150044.17746-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchi/vchi_cfg.h | 168 +++++++++++++-------- 1 file changed, 106 insertions(+), 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h index 89aa4e6122cd..94c2fcf50468 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h @@ -4,13 +4,17 @@ #ifndef VCHI_CFG_H_ #define VCHI_CFG_H_ -/**************************************************************************************** - * Defines in this first section are part of the VCHI API and may be examined by VCHI - * services. - ***************************************************************************************/ - -/* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */ -/* Really determined by the message driver, and should be available from a run-time call. */ +/******************************************************************************* + * Defines in this first section are part of the VCHI API and may be examined by + * VCHI services. + ******************************************************************************/ + +/* + * Required alignment of base addresses for bulk transfer, if unaligned + * transfers are not enabled + * Really determined by the message driver, and should be available from + * a run-time call. + */ #ifndef VCHI_BULK_ALIGN # if __VCCOREVER__ >= 0x04000000 # define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans @@ -19,9 +23,13 @@ # endif #endif -/* Required length multiple for bulk transfers, if unaligned transfers are not enabled */ -/* May be less than or greater than VCHI_BULK_ALIGN */ -/* Really determined by the message driver, and should be available from a run-time call. */ +/* + * Required length multiple for bulk transfers, if unaligned transfers are + * not enabled + * May be less than or greater than VCHI_BULK_ALIGN + * Really determined by the message driver, and should be available from + * a run-time call. + */ #ifndef VCHI_BULK_GRANULARITY # if __VCCOREVER__ >= 0x04000000 # define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans @@ -39,19 +47,24 @@ # endif #endif -/****************************************************************************************** - * Defines below are system configuration options, and should not be used by VCHI services. - *****************************************************************************************/ +/****************************************************************************** + * Defines below are system configuration options, and should not be used by + * VCHI services. + ******************************************************************************/ -/* How many connections can we support? A localhost implementation uses 2 connections, - * 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW - * driver. */ +/* + * How many connections can we support? A localhost implementation uses + * 2 connections, 1 for host-app, 1 for VMCS, and these are hooked together + * by a loopback MPHI VCFW driver. + */ #ifndef VCHI_MAX_NUM_CONNECTIONS # define VCHI_MAX_NUM_CONNECTIONS 3 #endif -/* How many services can we open per connection? Extending this doesn't cost processing time, just a small - * amount of static memory. */ +/* + * How many services can we open per connection? Extending this doesn't cost + * processing time, just a small amount of static memory. + */ #ifndef VCHI_MAX_SERVICES_PER_CONNECTION # define VCHI_MAX_SERVICES_PER_CONNECTION 36 #endif @@ -66,8 +79,10 @@ # define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI #endif -/* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective - * receive queue space, less message headers. */ +/* + * How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the + * effective receive queue space, less message headers. + */ #ifndef VCHI_NUM_READ_SLOTS # if defined(VCHI_LOCAL_HOST_PORT) # define VCHI_NUM_READ_SLOTS 4 @@ -76,112 +91,141 @@ # endif #endif -/* Do we utilise overrun facility for receive message slots? Can aid peer transmit - * performance. Only define on VideoCore end, talking to host. +/* + * Do we utilise overrun facility for receive message slots? Can aid peer + * transmit performance. Only define on VideoCore end, talking to host. */ //#define VCHI_MSG_RX_OVERRUN -/* How many transmit slots do we use. Generally don't need many, as the hardware driver - * underneath VCHI will usually have its own buffering. */ +/* + * How many transmit slots do we use. Generally don't need many, + * as the hardware driver underneath VCHI will usually have its own buffering. + */ #ifndef VCHI_NUM_WRITE_SLOTS # define VCHI_NUM_WRITE_SLOTS 4 #endif -/* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots, - * then it's taking up too much buffer space, and the peer service will be told to stop - * transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS - * needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency - * is too high. */ +/* + * If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or + * more slots, then it's taking up too much buffer space, + * and the peer service will be told to stop transmitting with an XOFF message. + * For this to be effective, the VCHI_NUM_READ_SLOTS needs to be considerably + * bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency is too high. + */ #ifndef VCHI_XOFF_THRESHOLD # define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2) #endif -/* After we've sent an XOFF, the peer will be told to resume transmission once the local - * service has dequeued/released enough messages that it's now occupying - * VCHI_XON_THRESHOLD slots or fewer. */ +/* + * After we've sent an XOFF, the peer will be told to resume transmission + * once the local service has dequeued/released enough messages that it's now + * occupying VCHI_XON_THRESHOLD slots or fewer. + */ #ifndef VCHI_XON_THRESHOLD # define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4) #endif -/* A size below which a bulk transfer omits the handshake completely and always goes - * via the message channel, if bulk auxiliary is being sent on that service. (The user - * can guarantee this by enabling unaligned transmits). - * Not API. */ +/* + * A size below which a bulk transfer omits the handshake completely and always + * goes via the message channel, if bulk auxiliary is being sent on that + * service. (The user can guarantee this by enabling unaligned transmits). + * Not API. + */ #ifndef VCHI_MIN_BULK_SIZE # define VCHI_MIN_BULK_SIZE (VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096) #endif -/* Maximum size of bulk transmission chunks, for each interface type. A trade-off between - * speed and latency; the smaller the chunk size the better change of messages and other - * bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not - * break transmissions into chunks. +/* + * Maximum size of bulk transmission chunks, for each interface type. + * A trade-off between speed and latency; the smaller the chunk size the better + * change of messages and other bulk transmissions getting in when big bulk + * transfers are happening. Set to 0 to not break transmissions into chunks. */ #ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI # define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024) #endif -/* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using "JPEG8" mode - * with multiple-line frames. Only use if the receiver can cope. */ +/* + * NB Chunked CCP2 transmissions violate the letter of the CCP2 spec + * by using "JPEG8" mode with multiple-line frames. Only use if the receiver + * can cope. + */ #ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2 # define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0 #endif -/* How many TX messages can we have pending in our transmit slots. Once exhausted, - * vchi_msg_queue will be blocked. */ +/* + * How many TX messages can we have pending in our transmit slots. + * Once exhausted, vchi_msg_queue will be blocked. + */ #ifndef VCHI_TX_MSG_QUEUE_SIZE # define VCHI_TX_MSG_QUEUE_SIZE 256 #endif -/* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing - * will be suspended until older messages are dequeued/released. */ +/* + * How many RX messages can we have parsed in the receive slots. Once exhausted, + * parsing will be suspended until older messages are dequeued/released. + */ #ifndef VCHI_RX_MSG_QUEUE_SIZE # define VCHI_RX_MSG_QUEUE_SIZE 256 #endif -/* Really should be able to cope if we run out of received message descriptors, by - * suspending parsing as the comment above says, but we don't. This sweeps the issue - * under the carpet. */ +/* + * Really should be able to cope if we run out of received message descriptors, + * by suspending parsing as the comment above says, but we don't. + * This sweeps the issue under the carpet. + */ #if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS # undef VCHI_RX_MSG_QUEUE_SIZE # define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS) #endif -/* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit - * will be blocked. */ +/* + * How many bulk transmits can we have pending. Once exhausted, + * vchi_bulk_queue_transmit will be blocked. + */ #ifndef VCHI_TX_BULK_QUEUE_SIZE # define VCHI_TX_BULK_QUEUE_SIZE 64 #endif -/* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive - * will be blocked. */ +/* + * How many bulk receives can we have pending. Once exhausted, + *vchi_bulk_queue_receive will be blocked. + */ #ifndef VCHI_RX_BULK_QUEUE_SIZE # define VCHI_RX_BULK_QUEUE_SIZE 64 #endif -/* A limit on how many outstanding bulk requests we expect the peer to give us. If - * the peer asks for more than this, VCHI will fail and assert. The number is determined - * by the peer's hardware - it's the number of outstanding requests that can be queued - * on all bulk channels. VC3's MPHI peripheral allows 16. */ +/* + * A limit on how many outstanding bulk requests we expect the peer to give us. + * If the peer asks for more than this, VCHI will fail and assert. + * The number is determined by the peer's hardware + * - it's the number of outstanding requests that can be queued + * on all bulk channels. VC3's MPHI peripheral allows 16. + */ #ifndef VCHI_MAX_PEER_BULK_REQUESTS # define VCHI_MAX_PEER_BULK_REQUESTS 32 #endif -/* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2 +/* + * Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2 * transmitter on and off. */ /*#define VCHI_CCP2TX_MANUAL_POWER*/ #ifndef VCHI_CCP2TX_MANUAL_POWER -/* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set - * negative for no IDLE. +/* + * Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. + * Set negative for no IDLE. */ # ifndef VCHI_CCP2TX_IDLE_TIMEOUT # define VCHI_CCP2TX_IDLE_TIMEOUT 5 # endif -/* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set - * negative for no OFF. +/* + * Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. + * Set negative for no OFF. */ # ifndef VCHI_CCP2TX_OFF_TIMEOUT # define VCHI_CCP2TX_OFF_TIMEOUT 1000 -- cgit v1.2.3-59-g8ed1b From 3e722c805cdf9cb6b43ca3646cc72013cb186af2 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 17 Oct 2019 17:31:26 +0100 Subject: staging: vc04_services: fix warnings of scpace required between operator Fix warnings of space required between operator and variables. Issue detected by checkpatch tool Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191017163126.23992-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 8 ++++---- drivers/staging/vc04_services/interface/vchi/vchi_cfg.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index f85562b9ba9e..bdc393d36769 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -11,14 +11,14 @@ Global defs *****************************************************************************/ -#define VCHI_BULK_ROUND_UP(x) ((((unsigned long)(x))+VCHI_BULK_ALIGN-1) & ~(VCHI_BULK_ALIGN-1)) -#define VCHI_BULK_ROUND_DOWN(x) (((unsigned long)(x)) & ~(VCHI_BULK_ALIGN-1)) -#define VCHI_BULK_ALIGN_NBYTES(x) (VCHI_BULK_ALIGNED(x) ? 0 : (VCHI_BULK_ALIGN - ((unsigned long)(x) & (VCHI_BULK_ALIGN-1)))) +#define VCHI_BULK_ROUND_UP(x) ((((unsigned long)(x)) + VCHI_BULK_ALIGN - 1) & ~(VCHI_BULK_ALIGN - 1)) +#define VCHI_BULK_ROUND_DOWN(x) (((unsigned long)(x)) & ~(VCHI_BULK_ALIGN - 1)) +#define VCHI_BULK_ALIGN_NBYTES(x) (VCHI_BULK_ALIGNED(x) ? 0 : (VCHI_BULK_ALIGN - ((unsigned long)(x) & (VCHI_BULK_ALIGN - 1)))) #ifdef USE_VCHIQ_ARM #define VCHI_BULK_ALIGNED(x) 1 #else -#define VCHI_BULK_ALIGNED(x) (((unsigned long)(x) & (VCHI_BULK_ALIGN-1)) == 0) +#define VCHI_BULK_ALIGNED(x) (((unsigned long)(x) & (VCHI_BULK_ALIGN - 1)) == 0) #endif struct vchi_version { diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h index 94c2fcf50468..138c36151a22 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h @@ -175,9 +175,9 @@ * by suspending parsing as the comment above says, but we don't. * This sweeps the issue under the carpet. */ -#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS +#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE / 16 + 1) * VCHI_NUM_READ_SLOTS # undef VCHI_RX_MSG_QUEUE_SIZE -# define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS) +# define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE / 16 + 1) * VCHI_NUM_READ_SLOTS) #endif /* -- cgit v1.2.3-59-g8ed1b From 25c42086c711719f3d3b520fc837ac422f73aa85 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Thu, 17 Oct 2019 18:38:37 +0100 Subject: staging: vc04_services: fix warnings of Block comments use of * Fix warnings of Block comments use * on subsequent lines. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191017173837.27336-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index bdc393d36769..0a353a468f34 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -8,7 +8,7 @@ #include "interface/vchi/vchi_common.h" /****************************************************************************** - Global defs + * Global defs *****************************************************************************/ #define VCHI_BULK_ROUND_UP(x) ((((unsigned long)(x)) + VCHI_BULK_ALIGN - 1) & ~(VCHI_BULK_ALIGN - 1)) @@ -56,7 +56,8 @@ typedef struct opaque_vchi_instance_handle_t *VCHI_INSTANCE_T; typedef struct opaque_vchi_service_handle_t *VCHI_SERVICE_HANDLE_T; /****************************************************************************** - Global funcs - implementation is specific to which side you are on (local / remote) + * Global funcs - implementation is specific to which side you are on + * (local / remote) *****************************************************************************/ #ifdef __cplusplus @@ -80,7 +81,7 @@ extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address); extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle); /****************************************************************************** - Global service API + * Global service API *****************************************************************************/ // Routine to destroy a service extern int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle); @@ -153,9 +154,10 @@ extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle, struct vchi_msg_iter *iter, VCHI_FLAGS_T flags); -/****************************************************************************** - Global service support API - operations on held messages and message iterators - *****************************************************************************/ +/******************************************************************************* + * Global service support API - operations on held messages + * and message iterators + ******************************************************************************/ // Routine to get the address of a held message extern void *vchi_held_msg_ptr(const struct vchi_held_msg *message); @@ -196,7 +198,7 @@ extern int32_t vchi_msg_iter_hold_next(struct vchi_msg_iter *iter, struct vchi_held_msg *message); /****************************************************************************** - Global bulk API + * Global bulk API *****************************************************************************/ // Routine to prepare interface for a transfer from the other side @@ -221,7 +223,7 @@ extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, void *transfer_handle); /****************************************************************************** - Configuration plumbing + * Configuration plumbing *****************************************************************************/ #ifdef __cplusplus -- cgit v1.2.3-59-g8ed1b From 3bcfd0e77e93b583fa2752192bcc35e4439c2b22 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Wed, 23 Oct 2019 13:30:13 -0300 Subject: staging: sm750fb: format description of parameters in accel.c Formatting comments in file drivers/staging/sm750fb/sm750_accel.c. Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191023163016.30217-2-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.c | 72 +++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 28 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index dbcbbd1055da..645813a87490 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -130,20 +130,28 @@ int sm750_hw_fillrect(struct lynx_accel *accel, return 0; } -int sm750_hw_copyarea( -struct lynx_accel *accel, -unsigned int sBase, /* Address of source: offset in frame buffer */ -unsigned int sPitch, /* Pitch value of source surface in BYTE */ -unsigned int sx, -unsigned int sy, /* Starting coordinate of source surface */ -unsigned int dBase, /* Address of destination: offset in frame buffer */ -unsigned int dPitch, /* Pitch value of destination surface in BYTE */ -unsigned int Bpp, /* Color depth of destination surface */ -unsigned int dx, -unsigned int dy, /* Starting coordinate of destination surface */ -unsigned int width, -unsigned int height, /* width and height of rectangle in pixel value */ -unsigned int rop2) /* ROP value */ +/** + * sm750_hm_copyarea + * @sBase: Address of source: offset in frame buffer + * @sPitch: Pitch value of source surface in BYTE + * @sx: Starting x coordinate of source surface + * @sy: Starting y coordinate of source surface + * @dBase: Address of destination: offset in frame buffer + * @dPitch: Pitch value of destination surface in BYTE + * @Bpp: Color depth of destination surface + * @dx: Starting x coordinate of destination surface + * @dy: Starting y coordinate of destination surface + * @width: width of rectangle in pixel value + * @height: height of rectangle in pixel value + * @rop2: ROP value + */ +int sm750_hw_copyarea(struct lynx_accel *accel, + unsigned int sBase, unsigned int sPitch, + unsigned int sx, unsigned int sy, + unsigned int dBase, unsigned int dPitch, + unsigned int Bpp, unsigned int dx, unsigned int dy, + unsigned int width, unsigned int height, + unsigned int rop2) { unsigned int nDirection, de_ctrl; @@ -288,20 +296,28 @@ static unsigned int deGetTransparency(struct lynx_accel *accel) return de_ctrl; } -int sm750_hw_imageblit(struct lynx_accel *accel, - const char *pSrcbuf, /* pointer to start of source buffer in system memory */ - u32 srcDelta, /* Pitch value (in bytes) of the source buffer, +ive means top down and -ive mean button up */ - u32 startBit, /* Mono data can start at any bit in a byte, this value should be 0 to 7 */ - u32 dBase, /* Address of destination: offset in frame buffer */ - u32 dPitch, /* Pitch value of destination surface in BYTE */ - u32 bytePerPixel, /* Color depth of destination surface */ - u32 dx, - u32 dy, /* Starting coordinate of destination surface */ - u32 width, - u32 height, /* width and height of rectangle in pixel value */ - u32 fColor, /* Foreground color (corresponding to a 1 in the monochrome data */ - u32 bColor, /* Background color (corresponding to a 0 in the monochrome data */ - u32 rop2) /* ROP value */ +/** + * sm750_hw_imageblit + * @pSrcbuf: pointer to start of source buffer in system memory + * @srcDelta: Pitch value (in bytes) of the source buffer, +ive means top down + * and -ive mean button up + * @startBit: Mono data can start at any bit in a byte, this value should be + * 0 to 7 + * @dBase: Address of destination: offset in frame buffer + * @dPitch: Pitch value of destination surface in BYTE + * @bytePerPixel: Color depth of destination surface + * @dx: Starting x coordinate of destination surface + * @dy: Starting y coordinate of destination surface + * @width: width of rectangle in pixel value + * @height: height of rectangle in pixel value + * @fColor: Foreground color (corresponding to a 1 in the monochrome data + * @bColor: Background color (corresponding to a 0 in the monochrome data + * @rop2: ROP value + */ +int sm750_hw_imageblit(struct lynx_accel *accel, const char *pSrcbuf, + u32 srcDelta, u32 startBit, u32 dBase, u32 dPitch, + u32 bytePerPixel, u32 dx, u32 dy, u32 width, + u32 height, u32 fColor, u32 bColor, u32 rop2) { unsigned int ulBytesPerScan; unsigned int ul4BytesPerScan; -- cgit v1.2.3-59-g8ed1b From 13c2059fee66f1a03ea234a0826610418192e802 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Wed, 23 Oct 2019 13:30:14 -0300 Subject: staging: sm750fb: format description of parameters in accel.h Formatting comments in file drivers/staging/sm750fb/sm750_accel.h. Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191023163016.30217-3-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.h | 75 +++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h index c4f42002a50f..c16350b5a310 100644 --- a/drivers/staging/sm750fb/sm750_accel.h +++ b/drivers/staging/sm750fb/sm750_accel.h @@ -194,33 +194,50 @@ int sm750_hw_fillrect(struct lynx_accel *accel, u32 x, u32 y, u32 width, u32 height, u32 color, u32 rop); -int sm750_hw_copyarea( -struct lynx_accel *accel, -unsigned int sBase, /* Address of source: offset in frame buffer */ -unsigned int sPitch, /* Pitch value of source surface in BYTE */ -unsigned int sx, -unsigned int sy, /* Starting coordinate of source surface */ -unsigned int dBase, /* Address of destination: offset in frame buffer */ -unsigned int dPitch, /* Pitch value of destination surface in BYTE */ -unsigned int bpp, /* Color depth of destination surface */ -unsigned int dx, -unsigned int dy, /* Starting coordinate of destination surface */ -unsigned int width, -unsigned int height, /* width and height of rectangle in pixel value */ -unsigned int rop2); - -int sm750_hw_imageblit(struct lynx_accel *accel, - const char *pSrcbuf, /* pointer to start of source buffer in system memory */ - u32 srcDelta, /* Pitch value (in bytes) of the source buffer, +ive means top down and -ive mean button up */ - u32 startBit, /* Mono data can start at any bit in a byte, this value should be 0 to 7 */ - u32 dBase, /* Address of destination: offset in frame buffer */ - u32 dPitch, /* Pitch value of destination surface in BYTE */ - u32 bytePerPixel, /* Color depth of destination surface */ - u32 dx, - u32 dy, /* Starting coordinate of destination surface */ - u32 width, - u32 height, /* width and height of rectangle in pixel value */ - u32 fColor, /* Foreground color (corresponding to a 1 in the monochrome data */ - u32 bColor, /* Background color (corresponding to a 0 in the monochrome data */ - u32 rop2); +/** + * sm750_hm_copyarea + * @sBase: Address of source: offset in frame buffer + * @sPitch: Pitch value of source surface in BYTE + * @sx: Starting x coordinate of source surface + * @sy: Starting y coordinate of source surface + * @dBase: Address of destination: offset in frame buffer + * @dPitch: Pitch value of destination surface in BYTE + * @Bpp: Color depth of destination surface + * @dx: Starting x coordinate of destination surface + * @dy: Starting y coordinate of destination surface + * @width: width of rectangle in pixel value + * @height: height of rectangle in pixel value + * @rop2: ROP value + */ +int sm750_hw_copyarea(struct lynx_accel *accel, + unsigned int sBase, unsigned int sPitch, + unsigned int sx, unsigned int sy, + unsigned int dBase, unsigned int dPitch, + unsigned int Bpp, unsigned int dx, unsigned int dy, + unsigned int width, unsigned int height, + unsigned int rop2); + +/** + * sm750_hw_imageblit + * @pSrcbuf: pointer to start of source buffer in system memory + * @srcDelta: Pitch value (in bytes) of the source buffer, +ive means top down + *>----- and -ive mean button up + * @startBit: Mono data can start at any bit in a byte, this value should be + *>----- 0 to 7 + * @dBase: Address of destination: offset in frame buffer + * @dPitch: Pitch value of destination surface in BYTE + * @bytePerPixel: Color depth of destination surface + * @dx: Starting x coordinate of destination surface + * @dy: Starting y coordinate of destination surface + * @width: width of rectangle in pixel value + * @height: height of rectangle in pixel value + * @fColor: Foreground color (corresponding to a 1 in the monochrome data + * @bColor: Background color (corresponding to a 0 in the monochrome data + * @rop2: ROP value + */ +int sm750_hw_imageblit(struct lynx_accel *accel, const char *pSrcbuf, + u32 srcDelta, u32 startBit, u32 dBase, u32 dPitch, + u32 bytePerPixel, u32 dx, u32 dy, u32 width, + u32 height, u32 fColor, u32 bColor, u32 rop2); + #endif -- cgit v1.2.3-59-g8ed1b From 836c336ebe502115d5e532a9454db7af2c208c28 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Thu, 24 Oct 2019 13:38:20 -0300 Subject: staging: sm750fb: align arguments with open parenthesis in ddk750_sii164.c Cleans up checks of "Alignment should match open parenthesis" in file ddk750_sii164.c Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191024163822.7157-2-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c index bee58edc84e7..73e0e9f41ec5 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.c +++ b/drivers/staging/sm750fb/ddk750_sii164.c @@ -141,7 +141,7 @@ long sii164InitChip(unsigned char edge_select, /* Check if SII164 Chip exists */ if ((sii164GetVendorID() == SII164_VENDOR_ID) && - (sii164GetDeviceID() == SII164_DEVICE_ID)) { + (sii164GetDeviceID() == SII164_DEVICE_ID)) { /* * Initialize SII164 controller chip. */ -- cgit v1.2.3-59-g8ed1b From 548c01d6e37695f2e05c9c79db7611f30d4a0aa2 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Thu, 24 Oct 2019 13:38:21 -0300 Subject: staging: sm750fb: align arguments with open parenthesis in file sm750_accel.h Cleans up checks of "Alignment should match open parenthesis" in file sm750_accel.h Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191024163822.7157-3-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750_accel.h b/drivers/staging/sm750fb/sm750_accel.h index c16350b5a310..2c79cb730a0a 100644 --- a/drivers/staging/sm750fb/sm750_accel.h +++ b/drivers/staging/sm750fb/sm750_accel.h @@ -190,9 +190,9 @@ void sm750_hw_set2dformat(struct lynx_accel *accel, int fmt); void sm750_hw_de_init(struct lynx_accel *accel); int sm750_hw_fillrect(struct lynx_accel *accel, - u32 base, u32 pitch, u32 Bpp, - u32 x, u32 y, u32 width, u32 height, - u32 color, u32 rop); + u32 base, u32 pitch, u32 Bpp, + u32 x, u32 y, u32 width, u32 height, + u32 color, u32 rop); /** * sm750_hm_copyarea -- cgit v1.2.3-59-g8ed1b From 6454e187244e911b0d215d6187d6167ae08b3f3b Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Thu, 24 Oct 2019 13:38:22 -0300 Subject: staging: sm750fb: align arguments with open parenthesis in file sm750_cursor.h Cleans up checks of "Alignment should match open parenthesis" in file sm750_cursor.h Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191024163822.7157-4-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_cursor.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750_cursor.h b/drivers/staging/sm750fb/sm750_cursor.h index 16ac07eb58d6..b59643dd61ed 100644 --- a/drivers/staging/sm750fb/sm750_cursor.h +++ b/drivers/staging/sm750fb/sm750_cursor.h @@ -5,14 +5,11 @@ /* hw_cursor_xxx works for voyager,718 and 750 */ void sm750_hw_cursor_enable(struct lynx_cursor *cursor); void sm750_hw_cursor_disable(struct lynx_cursor *cursor); -void sm750_hw_cursor_setSize(struct lynx_cursor *cursor, - int w, int h); -void sm750_hw_cursor_setPos(struct lynx_cursor *cursor, - int x, int y); -void sm750_hw_cursor_setColor(struct lynx_cursor *cursor, - u32 fg, u32 bg); -void sm750_hw_cursor_setData(struct lynx_cursor *cursor, - u16 rop, const u8 *data, const u8 *mask); -void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, - u16 rop, const u8 *data, const u8 *mask); +void sm750_hw_cursor_setSize(struct lynx_cursor *cursor, int w, int h); +void sm750_hw_cursor_setPos(struct lynx_cursor *cursor, int x, int y); +void sm750_hw_cursor_setColor(struct lynx_cursor *cursor, u32 fg, u32 bg); +void sm750_hw_cursor_setData(struct lynx_cursor *cursor, u16 rop, + const u8 *data, const u8 *mask); +void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, u16 rop, + const u8 *data, const u8 *mask); #endif -- cgit v1.2.3-59-g8ed1b From 76fe47940e607a4a1071dbb37073463974b89802 Mon Sep 17 00:00:00 2001 From: CristianeNaves Date: Thu, 24 Oct 2019 11:46:23 -0200 Subject: staging: gasket: Fix lines ending with a '(' Fix lines ending with a '('. Issue found by checkpatch. Signed-off-by: CristianeNaves Link: https://lore.kernel.org/r/20191024134623.GA4506@cristiane-Inspiron-5420 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 240f9bb10b71..4d086d92cddb 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -54,9 +54,9 @@ static int gasket_read_page_table_size(struct gasket_dev *gasket_dev, ibuf.size = gasket_page_table_num_entries( gasket_dev->page_table[ibuf.page_table_index]); - trace_gasket_ioctl_page_table_data( - ibuf.page_table_index, ibuf.size, ibuf.host_address, - ibuf.device_address); + trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size, + ibuf.host_address, + ibuf.device_address); if (copy_to_user(argp, &ibuf, sizeof(ibuf))) return -EFAULT; @@ -101,9 +101,9 @@ static int gasket_partition_page_table(struct gasket_dev *gasket_dev, if (copy_from_user(&ibuf, argp, sizeof(struct gasket_page_table_ioctl))) return -EFAULT; - trace_gasket_ioctl_page_table_data( - ibuf.page_table_index, ibuf.size, ibuf.host_address, - ibuf.device_address); + trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size, + ibuf.host_address, + ibuf.device_address); if (ibuf.page_table_index >= gasket_dev->num_page_tables) return -EFAULT; -- cgit v1.2.3-59-g8ed1b From 9f750a7ec1b7957053580818451ec1114d0c1132 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Wed, 23 Oct 2019 14:51:05 -0700 Subject: staging: fbtft: Fix duplicate arguments to bitwise AND Fix duplicated arguments to bitwise & operator. Issue detected by coccinelle. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/20191023215105.18049-1-jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fb_uc1611.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fb_uc1611.c b/drivers/staging/fbtft/fb_uc1611.c index 65681d0fe200..e763205e9e4f 100644 --- a/drivers/staging/fbtft/fb_uc1611.c +++ b/drivers/staging/fbtft/fb_uc1611.c @@ -91,7 +91,7 @@ static int init_display(struct fbtft_par *par) write_reg(par, 0x2C | (pump & 0x03)); /* Set inverse display */ - write_reg(par, 0xA6 | (0x01 & 0x01)); + write_reg(par, 0xA6 | 0x01); /* Set 4-bit grayscale mode */ write_reg(par, 0xD0 | (0x02 & 0x03)); @@ -157,8 +157,8 @@ static int set_var(struct fbtft_par *par) /* Set RAM address control */ write_reg(par, 0x88 | (0x0 & 0x1) << 2 /* Increment positively */ - | (0x1 & 0x1) << 1 /* Increment page first */ - | (0x1 & 0x1)); /* Wrap around (default) */ + | (0x1 << 1) /* Increment page first */ + | 0x1); /* Wrap around (default) */ /* Set LCD mapping */ write_reg(par, 0xC0 @@ -171,11 +171,11 @@ static int set_var(struct fbtft_par *par) write_reg(par, 0x88 | (0x0 & 0x1) << 2 /* Increment positively */ | (0x0 & 0x1) << 1 /* Increment column first */ - | (0x1 & 0x1)); /* Wrap around (default) */ + | 0x1); /* Wrap around (default) */ /* Set LCD mapping */ write_reg(par, 0xC0 - | (0x1 & 0x1) << 2 /* Mirror Y ON */ + | (0x1 << 2) /* Mirror Y ON */ | (0x0 & 0x1) << 1 /* Mirror X OFF */ | (0x0 & 0x1)); /* MS nibble last (default) */ break; @@ -183,13 +183,13 @@ static int set_var(struct fbtft_par *par) /* Set RAM address control */ write_reg(par, 0x88 | (0x0 & 0x1) << 2 /* Increment positively */ - | (0x1 & 0x1) << 1 /* Increment page first */ - | (0x1 & 0x1)); /* Wrap around (default) */ + | (0x1 << 1) /* Increment page first */ + | 0x1); /* Wrap around (default) */ /* Set LCD mapping */ write_reg(par, 0xC0 - | (0x1 & 0x1) << 2 /* Mirror Y ON */ - | (0x1 & 0x1) << 1 /* Mirror X ON */ + | (0x1 << 2) /* Mirror Y ON */ + | (0x1 << 1) /* Mirror X ON */ | (0x0 & 0x1)); /* MS nibble last (default) */ break; default: @@ -197,12 +197,12 @@ static int set_var(struct fbtft_par *par) write_reg(par, 0x88 | (0x0 & 0x1) << 2 /* Increment positively */ | (0x0 & 0x1) << 1 /* Increment column first */ - | (0x1 & 0x1)); /* Wrap around (default) */ + | 0x1); /* Wrap around (default) */ /* Set LCD mapping */ write_reg(par, 0xC0 | (0x0 & 0x1) << 2 /* Mirror Y OFF */ - | (0x1 & 0x1) << 1 /* Mirror X ON */ + | (0x1 << 1) /* Mirror X ON */ | (0x0 & 0x1)); /* MS nibble last (default) */ break; } -- cgit v1.2.3-59-g8ed1b From 79380bbfc3ff3d541546054e42c7a92670d728d1 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 24 Oct 2019 17:59:18 +0200 Subject: staging: rtl8188eu: remove code valid only for 5 GHz Remove code valid only for 5 GHz, according to the TODO. - find and remove remaining code valid only for 5 GHz. Most of the obvious ones have been removed, but things like channel > 14 still exist. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191024155918.13399-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++-------- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 30 +++++++------------------- 2 files changed, 11 insertions(+), 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 9aa44c921aca..88e42cc1d837 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -440,15 +440,9 @@ static void update_bmc_sta(struct adapter *padapter) tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f); } - if (pcur_network->Configuration.DSConfig > 14) { - /* force to A mode. 5G doesn't support CCK rates */ - network_type = WIRELESS_11A; - tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */ - } else { - /* force to b mode */ - network_type = WIRELESS_11B; - tx_ra_bitmap = 0xf; - } + /* force to b mode */ + network_type = WIRELESS_11B; + tx_ra_bitmap = 0xf; raid = networktype_to_raid(network_type); init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f; diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index ec5835d1aa8c..710c33fd4965 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -148,17 +148,10 @@ static char *translate_scan(struct adapter *padapter, else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pnetwork->network.Configuration.DSConfig > 14) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); - } else { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); - } + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); } start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); @@ -650,17 +643,10 @@ static int rtw_wx_get_name(struct net_device *dev, else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pcur_bss->Configuration.DSConfig > 14) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); - } else { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); - } + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); } } else { snprintf(wrqu->name, IFNAMSIZ, "unassociated"); -- cgit v1.2.3-59-g8ed1b From bfc0a0935aa4d74cd37d0b5e013ec6c4aa827a2d Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Thu, 17 Oct 2019 16:51:13 +0000 Subject: staging: wilc1000: store bss object and use cfg80211_connect_bss() In a fast disconnect/connect sequence, cfg80211_connect_result() can fail to find the bss object which the driver is connecting to. Detailed sequence of events: * Driver is connected in STA mode * Disconnect request arrives from user space. Driver disconnects and calls cfg80211_disconnected() which adds new event to the cfg80211_wq worker thread * Connect request arrives from user space. cfg80211_connect() stores ssid/ssid_len and calls rdev_connect() * __cfg80211_disconnected() runs in worker thread and zero wdev->ssid_len * Connect succeeds. Driver calls cfg80211_connect_result() which fails to find the bss because wdev->ssid_len is zero To overcome this, upon connect request, store the bss object in the driver and upon connect completion pass it to kernel using cfg80211_connect_bss(). Ref: bcdd49b074d0 ("store bss object and use cfg80211_connect_bss()") Signed-off-by: Adham Abozaeid Link: https://lore.kernel.org/r/20191017165105.27429-1-adham.abozaeid@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 20 ++++++++++++++------ drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index cc56abc2fe37..6422f6f5eadb 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -137,6 +137,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status, struct wilc *wl = vif->wilc; struct host_if_drv *wfi_drv = priv->hif_drv; struct wilc_conn_info *conn_info = &wfi_drv->conn_info; + struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; vif->connecting = false; @@ -158,12 +159,16 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status, memcpy(priv->associated_bss, conn_info->bssid, ETH_ALEN); - cfg80211_connect_result(dev, conn_info->bssid, - conn_info->req_ies, - conn_info->req_ies_len, - conn_info->resp_ies, - conn_info->resp_ies_len, connect_status, - GFP_KERNEL); + cfg80211_ref_bss(wiphy, vif->bss); + cfg80211_connect_bss(dev, conn_info->bssid, vif->bss, + conn_info->req_ies, + conn_info->req_ies_len, + conn_info->resp_ies, + conn_info->resp_ies_len, + connect_status, GFP_KERNEL, + NL80211_TIMEOUT_UNSPECIFIED); + + vif->bss = NULL; } else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) { u16 reason = 0; @@ -406,6 +411,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, goto out_put_bss; } kfree(join_params); + vif->bss = bss; cfg80211_put_bss(wiphy, bss); return 0; @@ -451,6 +457,8 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev, ret = -EINVAL; } + vif->bss = NULL; + return ret; } diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index fa41b46eb245..d94a4808bdf9 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -209,6 +209,7 @@ struct wilc_vif { bool connecting; struct wilc_priv priv; struct list_head list; + struct cfg80211_bss *bss; }; struct wilc { -- cgit v1.2.3-59-g8ed1b From d59dc92f1bccd5acde793aebdbb4f7121cf3f9af Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 17 Oct 2019 12:18:32 +0300 Subject: staging: wilc1000: potential corruption in wilc_parse_join_bss_param() The "rates_len" value needs to be capped so that the memcpy() doesn't copy beyond the end of the array. Fixes: c5c77ba18ea6 ("staging: wilc1000: Add SDIO/SPI 802.11 driver") Signed-off-by: Dan Carpenter Reviewed-by: Adham Abozaeid Link: https://lore.kernel.org/r/20191017091832.GB31278@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_hif.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_hif.c b/drivers/staging/wilc1000/wilc_hif.c index 0ac2b6ac50b0..e0a95c5cc0d5 100644 --- a/drivers/staging/wilc1000/wilc_hif.c +++ b/drivers/staging/wilc1000/wilc_hif.c @@ -479,6 +479,8 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len); if (rates_ie) { rates_len = rates_ie[1]; + if (rates_len > WILC_MAX_RATES_SUPPORTED) + rates_len = WILC_MAX_RATES_SUPPORTED; param->supp_rates[0] = rates_len; memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len); } -- cgit v1.2.3-59-g8ed1b From 3a4cffe67f2faefd498f7eea0b1dc3507c927042 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Fri, 18 Oct 2019 12:45:39 +0000 Subject: staging: wilc1000: handle mgmt frames for both interfaces during concurrent mode During concurrent mode(AP/STA + P2P), pass the mgmt frames received from firmware to appropriate interface. Iterate the complete interface list to pass frames on the interface which has registered to receive mgmt frame. Added extra time for 'remain_on_ch' timer to ensure that timeout for uncanceled remain_on_channel is not triggered & 'p2p_listen_state' is not cleared before passing the mgmt frames to p2p interface. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191018124511.22751-1-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_netdev.c | 11 ++++------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index 93c0d6e78813..2bc7e5427fa8 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -817,16 +817,13 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) list_for_each_entry_rcu(vif, &wilc->vif_list, list) { u16 type = le16_to_cpup((__le16 *)buff); - if ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) || - (type == vif->frame_reg[1].type && vif->frame_reg[1].reg)) { + if (vif->priv.p2p_listen_state && + ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) || + (type == vif->frame_reg[1].type && vif->frame_reg[1].reg))) wilc_wfi_p2p_rx(vif, buff, size); - break; - } - if (vif->monitor_flag) { + if (vif->monitor_flag) wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size); - break; - } } srcu_read_unlock(&wilc->srcu, srcu_idx); } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 6422f6f5eadb..9781f712ae3e 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1138,7 +1138,7 @@ static int remain_on_channel(struct wiphy *wiphy, cfg80211_ready_on_channel(wdev, *cookie, chan, duration, GFP_KERNEL); mod_timer(&vif->hif_drv->remain_on_ch_timer, - jiffies + msecs_to_jiffies(duration)); + jiffies + msecs_to_jiffies(duration + 1000)); return ret; } -- cgit v1.2.3-59-g8ed1b From dcad0824532fbeb25ec552965bb0775a3f87061a Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:01:53 -0500 Subject: staging: rtl8723bs: Replace string with identifier Replace the hardcoded function names with the corresponding predefined identifiers. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/b2ff6a52a7140480c9fdb6486a6ac6b4eb51203b.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index ed1d85499858..8ed6ba1cd5fa 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -303,8 +303,8 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", - crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4])); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", + __func__, crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4])); } WEP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); @@ -694,7 +694,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) return _FAIL; } */ - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo!= NULL!!!\n")); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; @@ -847,7 +847,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) TKIP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo == NULL!!!\n")); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo == NULL!!!\n", __func__)); res = _FAIL; } @@ -1536,7 +1536,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _AES_) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo!= NULL!!!\n")); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; @@ -1825,10 +1825,10 @@ static sint aes_decipher(u8 *key, uint hdrlen, /* compare the mic */ for (i = 0; i < 8; i++) { if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("aes_decipher:mic check error mic[%d]: pframe(%x) != message(%x)\n", - i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i])); - DBG_871X("aes_decipher:mic check error mic[%d]: pframe(%x) != message(%x)\n", - i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", + __func__, i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i])); + DBG_871X("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", + __func__, i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); res = _FAIL; } } @@ -1859,7 +1859,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); if (IS_MCAST(prxattrib->ra)) { static unsigned long start; @@ -1917,7 +1917,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) AES_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo == NULL!!!\n")); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo == NULL!!!\n", __func__)); res = _FAIL; } } -- cgit v1.2.3-59-g8ed1b From e52c13d6dca79608b2aa59c9b91afd6b4728f34e Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:02:19 -0500 Subject: staging: rtl8723bs: Fix lines over 80 characters Fix lines over 80 characters by wrapping arguments in function calls, improving the format for a better code readability. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/6a12577f3b95a77e060a2fb60ff17ce94774c076.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 40 +++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 8ed6ba1cd5fa..64f885fe382c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -303,8 +303,14 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", - __func__, crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4])); + RT_TRACE(_module_rtl871x_security_c_, + _drv_err_, + ("%s:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", + __func__, + crc[3], payload[length-1], + crc[2], payload[length-2], + crc[1], payload[length-3], + crc[0], payload[length-4])); } WEP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); @@ -839,9 +845,13 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + RT_TRACE(_module_rtl871x_security_c_, + _drv_err_, ("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", - crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4])); + crc[3], payload[length-1], + crc[2], payload[length-2], + crc[1], payload[length-3], + crc[0], payload[length-4])); res = _FAIL; } @@ -1825,10 +1835,18 @@ static sint aes_decipher(u8 *key, uint hdrlen, /* compare the mic */ for (i = 0; i < 8; i++) { if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", - __func__, i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i])); + RT_TRACE(_module_rtl871x_security_c_, + _drv_err_, + ("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", + __func__, + i, + pframe[hdrlen+8+plen-8+i], + message[hdrlen+8+plen-8+i])); DBG_871X("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", - __func__, i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); + __func__, + i, + pframe[hdrlen+8+plen-8+i], + message[hdrlen+8+plen-8+i]); res = _FAIL; } } @@ -1859,7 +1877,9 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); + RT_TRACE(_module_rtl871x_security_c_, + _drv_err_, + ("%s: stainfo!= NULL!!!\n", __func__)); if (IS_MCAST(prxattrib->ra)) { static unsigned long start; @@ -1917,7 +1937,9 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) AES_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo == NULL!!!\n", __func__)); + RT_TRACE(_module_rtl871x_security_c_, + _drv_err_, + ("%s: stainfo == NULL!!!\n", __func__)); res = _FAIL; } } -- cgit v1.2.3-59-g8ed1b From e25af5e3ee11df3a4dba9211b9170c193b4736f0 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:02:48 -0500 Subject: staging: rtl8723bs: Add spaces between operators Add spaces between operators for a better readability. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/4194f2f5a7ed9deeaf3c2a2f2c91081e1f1189c0.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 64f885fe382c..533fefb2788c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -307,10 +307,10 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) _drv_err_, ("%s:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", __func__, - crc[3], payload[length-1], - crc[2], payload[length-2], - crc[1], payload[length-3], - crc[0], payload[length-4])); + crc[3], payload[length - 1], + crc[2], payload[length - 2], + crc[1], payload[length - 3], + crc[0], payload[length - 4])); } WEP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); @@ -848,10 +848,10 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", - crc[3], payload[length-1], - crc[2], payload[length-2], - crc[1], payload[length-3], - crc[0], payload[length-4])); + crc[3], payload[length - 1], + crc[2], payload[length - 2], + crc[1], payload[length - 3], + crc[0], payload[length - 4])); res = _FAIL; } @@ -1615,11 +1615,11 @@ static sint aes_decipher(u8 *key, uint hdrlen, payload_remainder = (plen-8) % 16; pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) a4_exists = 0; @@ -1657,7 +1657,7 @@ static sint aes_decipher(u8 *key, uint hdrlen, qc_exists, pframe, pn_vector, - i+1, + i + 1, frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ ); @@ -1840,13 +1840,13 @@ static sint aes_decipher(u8 *key, uint hdrlen, ("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", __func__, i, - pframe[hdrlen+8+plen-8+i], - message[hdrlen+8+plen-8+i])); + pframe[hdrlen + 8 + plen - 8 + i], + message[hdrlen + 8 + plen - 8 + i])); DBG_871X("%s:mic check error mic[%d]: pframe(%x) != message(%x)\n", __func__, i, - pframe[hdrlen+8+plen-8+i], - message[hdrlen+8+plen-8+i]); + pframe[hdrlen + 8 + plen - 8 + i], + message[hdrlen + 8 + plen - 8 + i]); res = _FAIL; } } -- cgit v1.2.3-59-g8ed1b From 22b5cbd1d1d23cc20da2ef1b132e8bd4b1307c74 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:03:27 -0500 Subject: staging: rtl8723bs: Remove commented code Remove commented code for a cleaner file. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/61f9b94781eb0ca1c94a5b6b8c37a8c2d0caaca6.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 56 +++++---------------------- 1 file changed, 9 insertions(+), 47 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 533fefb2788c..66a9ab62e3a3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -665,7 +665,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; - /* struct sta_info *stainfo; */ struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -680,32 +679,12 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _TKIP_) { -/* - if (pattrib->psta) { - stainfo = pattrib->psta; - } - else - { - DBG_871X("%s, call rtw_get_stainfo()\n", __func__); - stainfo =rtw_get_stainfo(&padapter->stapriv ,&pattrib->ra[0]); - } -*/ - /* if (stainfo!= NULL) */ - { -/* - if (!(stainfo->state &_FW_LINKED)) - { - DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state); - return _FAIL; - } -*/ RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else - /* prwskey =&stainfo->dot118021x_UncstKey.skey[0]; */ prwskey = pattrib->dot118021x_UncstKey.skey; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { @@ -744,13 +723,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) TKIP_SW_ENC_CNT_INC(psecuritypriv, pattrib->ra); } -/* - else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo == NULL!!!\n")); - DBG_871X("%s, psta ==NUL\n", __func__); - res = _FAIL; - } -*/ } return res; @@ -773,7 +745,6 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) struct sta_info *stainfo; struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; -/* struct recv_priv *precvpriv =&padapter->recvpriv; */ u32 res = _SUCCESS; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; @@ -818,8 +789,6 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) no_gkey_bc_cnt = 0; no_gkey_mc_cnt = 0; - /* DBG_871X("rx bc/mc packets, to perform sw rtw_tkip_decrypt\n"); */ - /* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */ prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; @@ -1429,7 +1398,7 @@ static sint aes_cipher(u8 *key, uint hdrlen, aes128k128d(key, chain_buffer, aes_out); for (i = 0; i < num_blocks; i++) { - bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); payload_index += 16; aes128k128d(key, chain_buffer, aes_out); @@ -1440,7 +1409,7 @@ static sint aes_cipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) { - padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ + padded_buffer[j] = pframe[payload_index++]; } bitwise_xor(aes_out, padded_buffer, chain_buffer); aes128k128d(key, chain_buffer, aes_out); @@ -1452,7 +1421,7 @@ static sint aes_cipher(u8 *key, uint hdrlen, /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + pframe[payload_index+j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { @@ -1466,9 +1435,9 @@ static sint aes_cipher(u8 *key, uint hdrlen, frtype ); /* add for CONFIG_IEEE80211W, none 11w also can use */ aes128k128d(key, ctr_preload, aes_out); - bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); for (j = 0; j < 16; j++) - pframe[payload_index++] = chain_buffer[j];/* for (j = 0; j<16;j++) message[payload_index++] = chain_buffer[j]; */ + pframe[payload_index++] = chain_buffer[j]; } if (payload_remainder > 0) { @@ -1487,12 +1456,12 @@ static sint aes_cipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j];/* padded_buffer[j] = message[payload_index+j]; */ + padded_buffer[j] = pframe[payload_index+j]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) - pframe[payload_index++] = chain_buffer[j];/* for (j = 0; jattrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -/* uint offset = 0; */ u32 res = _SUCCESS; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) @@ -1551,7 +1518,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else - /* prwskey =&stainfo->dot118021x_UncstKey.skey[0]; */ prwskey = pattrib->dot118021x_UncstKey.skey; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { @@ -1593,7 +1559,6 @@ static sint aes_decipher(u8 *key, uint hdrlen, u8 mic[8]; -/* uint offset = 0; */ uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); @@ -1869,7 +1834,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) struct sta_info *stainfo; struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; -/* struct recv_priv *precvpriv =&padapter->recvpriv; */ u32 res = _SUCCESS; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; @@ -1886,8 +1850,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) static u32 no_gkey_bc_cnt; static u32 no_gkey_mc_cnt; - /* DBG_871X("rx bc/mc packets, to perform sw rtw_aes_decrypt\n"); */ - /* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */ if (psecuritypriv->binstallGrpkey == false) { res = _FAIL; -- cgit v1.2.3-59-g8ed1b From fc4776941f51968fc82a8415734826e8ef96bde1 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:03:53 -0500 Subject: staging: rtl8723bs: Fix indentation warnings Fix indentation warnings to improve the code formatting. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/166ffc747a4212f81d26b03883dbc04d64deed56.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 66a9ab62e3a3..11388a9a0dac 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1483,7 +1483,7 @@ static sint aes_cipher(u8 *key, uint hdrlen, aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < 8; j++) - pframe[payload_index++] = chain_buffer[j]; + pframe[payload_index++] = chain_buffer[j]; return _SUCCESS; } @@ -1616,7 +1616,7 @@ static sint aes_decipher(u8 *key, uint hdrlen, payload_index = hdrlen + 8; /* 8 is for extiv */ for (i = 0; i < num_blocks; i++) { - construct_ctr_preload( + construct_ctr_preload( ctr_preload, a4_exists, qc_exists, -- cgit v1.2.3-59-g8ed1b From e004d7ac7d2e280061b1e7e2446aa6f8b5f1393e Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:04:28 -0500 Subject: staging: rtl8723bs: Fix function call format Fix function call format by following the coding style guidelines for argument wrapping in function calls. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/828984012f4c58f9d10647511f98005e4d1d5184.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 11388a9a0dac..3e88340915ec 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1540,7 +1540,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) } static sint aes_decipher(u8 *key, uint hdrlen, - u8 *pframe, uint plen) + u8 *pframe, uint plen) { static u8 message[MAX_MSG_SIZE]; uint qc_exists, a4_exists, i, j, payload_remainder, @@ -1616,15 +1616,10 @@ static sint aes_decipher(u8 *key, uint hdrlen, payload_index = hdrlen + 8; /* 8 is for extiv */ for (i = 0; i < num_blocks; i++) { - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - pframe, - pn_vector, - i + 1, - frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ - ); + construct_ctr_preload(ctr_preload, a4_exists, + qc_exists, pframe, + pn_vector, i + 1, + frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); -- cgit v1.2.3-59-g8ed1b From ec9e2a0ff12c0046aa15673a1084a8d67a14bdb1 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Wed, 16 Oct 2019 23:05:05 -0500 Subject: staging: rtl8723bs: Change tabs for spaces Change tabs for spaces when they are incorrectly used as separators. Fix suggested by Julia Lawall. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/7b06c103665ab7250dded8c5dadc093228eee7b4.1571284318.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 3e88340915ec..5aa5910687d1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1543,7 +1543,7 @@ static sint aes_decipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) { static u8 message[MAX_MSG_SIZE]; - uint qc_exists, a4_exists, i, j, payload_remainder, + uint qc_exists, a4_exists, i, j, payload_remainder, num_blocks, payload_index; sint res = _SUCCESS; u8 pn_vector[6]; @@ -1559,8 +1559,8 @@ static sint aes_decipher(u8 *key, uint hdrlen, u8 mic[8]; - uint frtype = GetFrameType(pframe); - uint frsubtype = GetFrameSubType(pframe); + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); frsubtype = frsubtype>>4; -- cgit v1.2.3-59-g8ed1b From 27a6fe3b21ec80662096b2c793036b5e8c3401ed Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 17 Oct 2019 09:40:04 +0000 Subject: staging: wfx: drop module version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wfx_version.h says that this code is same same than driver 2.3.1 hosted on github: https://github.com/siliconlabs/wfx-linux-driver/tree/2.3.1-public However, it is inaccurate, driver in-tree contains multiple small patches ahead 2.3.1. I prefer to drop this confusing information. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191017093954.657-1-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/TODO | 3 --- drivers/staging/wfx/main.c | 4 ---- drivers/staging/wfx/wfx_version.h | 3 --- 3 files changed, 10 deletions(-) delete mode 100644 drivers/staging/wfx/wfx_version.h (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/TODO b/drivers/staging/wfx/TODO index be990e8f18b1..e44772289af8 100644 --- a/drivers/staging/wfx/TODO +++ b/drivers/staging/wfx/TODO @@ -1,9 +1,6 @@ This is a list of things that need to be done to get this driver out of the staging directory. - - wfx_version.h is still there in order to ensure synchronization with github. - It can be dropped as soon as development is entirely in kernel - - I have to take a decision about secure link support. I can: - drop completely - keep it in an external patch (my preferred option) diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index d2508bc950fa..157e0fc0107e 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -33,14 +33,12 @@ #include "secure_link.h" #include "hif_tx_mib.h" #include "hif_api_cmd.h" -#include "wfx_version.h" #define WFX_PDS_MAX_SIZE 1500 MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); MODULE_AUTHOR("Jérôme Pouiller "); MODULE_LICENSE("GPL"); -MODULE_VERSION(WFX_LABEL); static int gpio_wakeup = -2; module_param(gpio_wakeup, int, 0644); @@ -480,8 +478,6 @@ static int __init wfx_core_init(void) { int ret = 0; - pr_info("wfx: Silicon Labs " WFX_LABEL "\n"); - if (IS_ENABLED(CONFIG_SPI)) ret = spi_register_driver(&wfx_spi_driver); if (IS_ENABLED(CONFIG_MMC) && !ret) diff --git a/drivers/staging/wfx/wfx_version.h b/drivers/staging/wfx/wfx_version.h deleted file mode 100644 index 6e7f30207c73..000000000000 --- a/drivers/staging/wfx/wfx_version.h +++ /dev/null @@ -1,3 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT! */ -#define WFX_LABEL "2.3.1" -- cgit v1.2.3-59-g8ed1b From a374ba3dc8e81f9e61dc8139899c03c602fbd5df Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 17 Oct 2019 09:40:05 +0000 Subject: staging: wfx: relocate wfx_fill_sl_key() in secure_link.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Secure link" feature is not available in in-tree driver (because it depends on mbedtls). Thus, secure_link.h only empty functions. Module parameter "slk_key" and associated function wfx_fill_sl_key() had an unjustifiable place in main.c. This patch relocate them to secure_link.h. BTW, content of wfx_fill_sl_key() is now useless. Just keep a warning if user try to use "slk_key" attribute (unsupported by this driver). Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191017093954.657-2-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/main.c | 29 +---------------------------- drivers/staging/wfx/main.h | 1 - drivers/staging/wfx/secure_link.h | 9 +++++++++ 3 files changed, 10 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 157e0fc0107e..3a43f190d96a 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -44,10 +44,6 @@ static int gpio_wakeup = -2; module_param(gpio_wakeup, int, 0644); MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); -static char *slk_key; -module_param(slk_key, charp, 0600); -MODULE_PARM_DESC(slk_key, "secret key for secure link (expect 64 hexadecimal digits)."); - #define RATETAB_ENT(_rate, _rateid, _flags) { \ .bitrate = (_rate), \ .hw_value = (_rateid), \ @@ -194,29 +190,6 @@ struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *lab return ret; } -static void wfx_fill_sl_key(struct device *dev, struct wfx_platform_data *pdata) -{ - const char *ascii_key = NULL; - int ret = 0; - - if (slk_key) - ascii_key = slk_key; - if (!ascii_key) - ret = of_property_read_string(dev->of_node, "slk_key", &ascii_key); - if (ret == -EILSEQ || ret == -ENODATA) - dev_err(dev, "ignoring malformatted key from DT\n"); - if (!ascii_key) - return; - - ret = hex2bin(pdata->slk_key, ascii_key, sizeof(pdata->slk_key)); - if (ret) { - dev_err(dev, "ignoring malformatted key: %s\n", ascii_key); - memset(pdata->slk_key, 0, sizeof(pdata->slk_key)); - return; - } - dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n"); -} - /* NOTE: wfx_send_pds() destroy buf */ int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len) { @@ -334,7 +307,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, memcpy(&wdev->pdata, pdata, sizeof(*pdata)); of_property_read_string(dev->of_node, "config-file", &wdev->pdata.file_pds); wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); - wfx_fill_sl_key(dev, &wdev->pdata); + wfx_sl_fill_pdata(dev, &wdev->pdata); mutex_init(&wdev->conf_mutex); mutex_init(&wdev->rx_stats_lock); diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index f2b07ed1627c..875f8c227803 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -22,7 +22,6 @@ struct wfx_platform_data { /* Keyset and ".sec" extention will appended to this string */ const char *file_fw; const char *file_pds; - unsigned char slk_key[API_KEY_VALUE_SIZE]; struct gpio_desc *gpio_wakeup; /* * if true HIF D_out is sampled on the rising edge of the clock diff --git a/drivers/staging/wfx/secure_link.h b/drivers/staging/wfx/secure_link.h index e2da1c73c760..376d7bc4c0c4 100644 --- a/drivers/staging/wfx/secure_link.h +++ b/drivers/staging/wfx/secure_link.h @@ -5,6 +5,8 @@ #ifndef WFX_SECURE_LINK_H #define WFX_SECURE_LINK_H +#include + #include "hif_api_general.h" struct wfx_dev; @@ -33,6 +35,13 @@ static inline int wfx_sl_check_pubkey(struct wfx_dev *wdev, uint8_t *ncp_pubkey, return -EIO; } +static inline void wfx_sl_fill_pdata(struct device *dev, + struct wfx_platform_data *pdata) +{ + if (of_find_property(dev->of_node, "slk_key", NULL)) + dev_err(dev, "secure link is not supported by this driver, ignoring provided key\n"); +} + static inline int wfx_sl_init(struct wfx_dev *wdev) { return -EIO; -- cgit v1.2.3-59-g8ed1b From 8008d9e7ddf0b72ff0f879af0a3c48a1086b6250 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 17 Oct 2019 09:40:06 +0000 Subject: staging: wfx: fix CONFIG_MMC=m with CONFIG_WFX=y MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If CONFIG_MMC=m and CONFIG_WFX=y, compilation complains with undefined references: drivers/staging/wfx/main.o: In function `wfx_core_init': /linux/drivers/staging/wfx/main.c:488: undefined reference to `sdio_register_driver' drivers/staging/wfx/main.o: In function `wfx_core_exit': /linux/drivers/staging/wfx/main.c:496: undefined reference to `sdio_unregister_driver' drivers/staging/wfx/main.o:(.debug_addr+0x1a8): undefined reference to `sdio_register_driver' drivers/staging/wfx/main.o:(.debug_addr+0x6f0): undefined reference to `sdio_unregister_driver' Indeed, symbols sdio_* are not present in kernel image. This patch disallows CONFIG_WFX=y if CONFIG_MMC=m. This solution impacts users who want to use SPI bus with configuration: CONFIG_WFX=y + CONFIG_SPI=y + CONFIG_MMC=m. However, I think this is a twisted case. So, I think it won't be missed. Reported-by: zhong jiang Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191017093954.657-3-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/Kconfig b/drivers/staging/wfx/Kconfig index 9b8a1c7a9e90..83ee4d0ca8c6 100644 --- a/drivers/staging/wfx/Kconfig +++ b/drivers/staging/wfx/Kconfig @@ -1,6 +1,7 @@ config WFX tristate "Silicon Labs wireless chips WF200 and further" depends on MAC80211 + depends on MMC || !MMC # do not allow WFX=y if MMC=m depends on (SPI || MMC) help This is a driver for Silicons Labs WFxxx series (WF200 and further) -- cgit v1.2.3-59-g8ed1b From 4e4f5e6fef21a574b4749a0fb5e96070eb03cb19 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 17 Oct 2019 09:40:06 +0000 Subject: staging: wfx: fix Oops when CONFIG_OF_NET is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In most case, of_get_mac_address() return NULL in case of error. However, if CONFIG_OF_NET is not set, it return -ENODEV. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191017093954.657-4-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 3a43f190d96a..205b5bc8872e 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -407,7 +407,7 @@ int wfx_probe(struct wfx_dev *wdev) for (i = 0; i < ARRAY_SIZE(wdev->addresses); i++) { eth_zero_addr(wdev->addresses[i].addr); macaddr = of_get_mac_address(wdev->dev->of_node); - if (macaddr) { + if (!IS_ERR_OR_NULL(macaddr)) { ether_addr_copy(wdev->addresses[i].addr, macaddr); wdev->addresses[i].addr[ETH_ALEN - 1] += i; } -- cgit v1.2.3-59-g8ed1b From 20ed2d1608ecc389ec3df87fc228a7d487f8b07b Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 17 Oct 2019 09:40:06 +0000 Subject: staging: wfx: fix setting MAC address from DT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MAC address read from chip is unconditionally used even if a MAC address is configured in device tree. Reported-by: Marc Dorval Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191017093954.657-5-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 205b5bc8872e..18f07f7ad347 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -410,8 +410,9 @@ int wfx_probe(struct wfx_dev *wdev) if (!IS_ERR_OR_NULL(macaddr)) { ether_addr_copy(wdev->addresses[i].addr, macaddr); wdev->addresses[i].addr[ETH_ALEN - 1] += i; + } else { + ether_addr_copy(wdev->addresses[i].addr, wdev->hw_caps.mac_addr[i]); } - ether_addr_copy(wdev->addresses[i].addr, wdev->hw_caps.mac_addr[i]); if (!is_valid_ether_addr(wdev->addresses[i].addr)) { dev_warn(wdev->dev, "using random MAC address\n"); eth_random_addr(wdev->addresses[i].addr); -- cgit v1.2.3-59-g8ed1b From c22a3a9c0a87d2064cbe744b1b393569d0621474 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Thu, 17 Oct 2019 09:40:07 +0000 Subject: staging: wfx: fix number of available tx_policies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original API declares 16 tx_policies. But in fact, the 16th is used internally by the firmware. So, only 15 tx_policies are available for driver. Reported-by: Alban Jeantheau Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191017093954.657-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_api_mib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h index 3c56ef2978a2..af657555f894 100644 --- a/drivers/staging/wfx/hif_api_mib.h +++ b/drivers/staging/wfx/hif_api_mib.h @@ -507,7 +507,7 @@ struct hif_mib_tx_rate_retry_policy { uint8_t rates[12]; } __packed; -#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES 16 +#define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES 15 struct hif_mib_set_tx_rate_retry_policy { uint8_t num_tx_rate_policies; -- cgit v1.2.3-59-g8ed1b From bc9496e5b4d603b1069a49422900a6b591f4d504 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Sat, 19 Oct 2019 15:07:15 +0100 Subject: staging: wfx: fix warnings of no space is necessary Fix warnings of no space is necessary after a cast. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191019140719.2542-2-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 8 ++++---- drivers/staging/wfx/bus_sdio.c | 6 +++--- drivers/staging/wfx/bus_spi.c | 2 +- drivers/staging/wfx/data_rx.c | 8 ++++---- drivers/staging/wfx/data_tx.c | 20 ++++++++++---------- drivers/staging/wfx/data_tx.h | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 3355183fc86c..573216b08042 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -69,13 +69,13 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) if (wfx_data_read(wdev, skb->data, alloc_len)) goto err; - piggyback = le16_to_cpup((u16 *) (skb->data + alloc_len - 2)); + piggyback = le16_to_cpup((u16 *)(skb->data + alloc_len - 2)); _trace_piggyback(piggyback, false); - hif = (struct hif_msg *) skb->data; + hif = (struct hif_msg *)skb->data; WARN(hif->encrypted & 0x1, "unsupported encryption type"); if (hif->encrypted == 0x2) { - if (wfx_sl_decode(wdev, (void *) hif)) { + if (wfx_sl_decode(wdev, (void *)hif)) { dev_kfree_skb(skb); // If frame was a confirmation, expect trouble in next // exchange. However, it is harmless to fail to decode @@ -102,7 +102,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) if (!(hif->id & HIF_ID_IS_INDICATION)) { (*is_cnf)++; if (hif->id == HIF_CNF_ID_MULTI_TRANSMIT) - release_count = le32_to_cpu(((struct hif_cnf_multi_transmit *) hif->body)->num_tx_confs); + release_count = le32_to_cpu(((struct hif_cnf_multi_transmit *)hif->body)->num_tx_confs); else release_count = 1; WARN(wdev->hif.tx_buffers_used < release_count, "corrupted buffer counter"); diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index f97360513150..184e20dfdd62 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -38,7 +38,7 @@ static int wfx_sdio_copy_from_io(void *priv, unsigned int reg_id, int ret; WARN(reg_id > 7, "chip only has 7 registers"); - WARN(((uintptr_t) dst) & 3, "unaligned buffer size"); + WARN(((uintptr_t)dst) & 3, "unaligned buffer size"); WARN(count & 3, "unaligned buffer address"); /* Use queue mode buffers */ @@ -59,14 +59,14 @@ static int wfx_sdio_copy_to_io(void *priv, unsigned int reg_id, int ret; WARN(reg_id > 7, "chip only has 7 registers"); - WARN(((uintptr_t) src) & 3, "unaligned buffer size"); + WARN(((uintptr_t)src) & 3, "unaligned buffer size"); WARN(count & 3, "unaligned buffer address"); /* Use queue mode buffers */ if (reg_id == WFX_REG_IN_OUT_QUEUE) sdio_addr |= bus->buf_id_tx << 7; // FIXME: discards 'const' qualifier for src - ret = sdio_memcpy_toio(bus->func, sdio_addr, (void *) src, count); + ret = sdio_memcpy_toio(bus->func, sdio_addr, (void *)src, count); if (!ret && reg_id == WFX_REG_IN_OUT_QUEUE) bus->buf_id_tx = (bus->buf_id_tx + 1) % 32; diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index f65f7d75e731..effd07957753 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -90,7 +90,7 @@ static int wfx_spi_copy_to_io(void *priv, unsigned int addr, struct wfx_spi_priv *bus = priv; u16 regaddr = (addr << 12) | (count / 2); // FIXME: use a bounce buffer - u16 *src16 = (void *) src; + u16 *src16 = (void *)src; int ret, i; struct spi_message m; struct spi_transfer t_addr = { diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 3a79089c8501..3a79ab93e97e 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -29,7 +29,7 @@ static int wfx_handle_pspoll(struct wfx_vif *wvif, struct sk_buff *skb) rcu_read_lock(); sta = ieee80211_find_sta(wvif->vif, pspoll->ta); if (sta) - link_id = ((struct wfx_sta_priv *) &sta->drv_priv)->link_id; + link_id = ((struct wfx_sta_priv *)&sta->drv_priv)->link_id; rcu_read_unlock(); if (link_id) pspoll_mask = BIT(link_id); @@ -102,8 +102,8 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb { int link_id = arg->rx_flags.peer_sta_id; struct ieee80211_rx_status *hdr = IEEE80211_SKB_RXCB(skb); - struct ieee80211_hdr *frame = (struct ieee80211_hdr *) skb->data; - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + struct ieee80211_hdr *frame = (struct ieee80211_hdr *)skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data; struct wfx_link_entry *entry = NULL; bool early_data = false; @@ -173,7 +173,7 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb tim_ie = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); if (tim_ie) { - struct ieee80211_tim_ie *tim = (struct ieee80211_tim_ie *) &tim_ie[2]; + struct ieee80211_tim_ie *tim = (struct ieee80211_tim_ie *)&tim_ie[2]; if (wvif->dtim_period != tim->dtim_period) { wvif->dtim_period = tim->dtim_period; diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 8ed38cac19f6..cf73b83ccc9e 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -427,7 +427,7 @@ void wfx_link_id_work(struct work_struct *work) static bool ieee80211_is_action_back(struct ieee80211_hdr *hdr) { - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) hdr; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)hdr; if (!ieee80211_is_action(mgmt->frame_control)) return false; @@ -591,7 +591,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct struct wfx_tx_priv *tx_priv; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; int queue_id = tx_info->hw_queue; size_t offset = (size_t) skb->data & 3; int wmsg_len = sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + offset; @@ -602,7 +602,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct // From now tx_info->control is unusable memset(tx_info->rate_driver_data, 0, sizeof(struct wfx_tx_priv)); // Fill tx_priv - tx_priv = (struct wfx_tx_priv *) tx_info->rate_driver_data; + tx_priv = (struct wfx_tx_priv *)tx_info->rate_driver_data; tx_priv->tid = wfx_tx_get_tid(hdr); tx_priv->raw_link_id = wfx_tx_get_raw_link_id(wvif, sta, hdr); tx_priv->link_id = tx_priv->raw_link_id; @@ -619,7 +619,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct skb_put(skb, wfx_tx_get_icv_len(tx_priv->hw_key)); skb_push(skb, wmsg_len); memset(skb->data, 0, wmsg_len); - hif_msg = (struct hif_msg *) skb->data; + hif_msg = (struct hif_msg *)skb->data; hif_msg->len = cpu_to_le16(skb->len); hif_msg->id = HIF_REQ_ID_TX; hif_msg->interface = wvif->id; @@ -631,7 +631,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct } // Fill tx request - req = (struct hif_req_tx *) hif_msg->body; + req = (struct hif_req_tx *)hif_msg->body; req->packet_id = queue_id << 16 | IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); req->data_flags.fc_offset = offset; req->queue_id.peer_sta_id = tx_priv->raw_link_id; @@ -654,7 +654,7 @@ void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct wfx_vif *wvif; struct ieee80211_sta *sta = control ? control->sta : NULL; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; size_t driver_data_room = FIELD_SIZEOF(struct ieee80211_tx_info, rate_driver_data); compiletime_assert(sizeof(struct wfx_tx_priv) <= driver_data_room, @@ -662,7 +662,7 @@ void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, WARN(skb->next || skb->prev, "skb is already member of a list"); // control.vif can be NULL for injected frames if (tx_info->control.vif) - wvif = (struct wfx_vif *) tx_info->control.vif->drv_priv; + wvif = (struct wfx_vif *)tx_info->control.vif->drv_priv; else wvif = wvif_iterate(wdev, NULL); if (WARN_ON(!wvif)) @@ -762,7 +762,7 @@ static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb, struct hif_req_tx *req) { struct ieee80211_sta *sta; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; int tid = wfx_tx_get_tid(hdr); int raw_link_id = req->queue_id.peer_sta_id; u8 *buffered; @@ -787,8 +787,8 @@ static void wfx_notify_buffered_tx(struct wfx_vif *wvif, struct sk_buff *skb, void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb) { - struct hif_msg *hif = (struct hif_msg *) skb->data; - struct hif_req_tx *req = (struct hif_req_tx *) hif->body; + struct hif_msg *hif = (struct hif_msg *)skb->data; + struct hif_req_tx *req = (struct hif_req_tx *)hif->body; struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); unsigned int offset = sizeof(struct hif_req_tx) + sizeof(struct hif_msg) + req->data_flags.fc_offset; diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index 0a19ef10a4ab..f74d1988925d 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -79,12 +79,12 @@ static inline struct wfx_tx_priv *wfx_skb_tx_priv(struct sk_buff *skb) if (!skb) return NULL; tx_info = IEEE80211_SKB_CB(skb); - return (struct wfx_tx_priv *) tx_info->rate_driver_data; + return (struct wfx_tx_priv *)tx_info->rate_driver_data; } static inline struct hif_req_tx *wfx_skb_txreq(struct sk_buff *skb) { - struct hif_msg *hif = (struct hif_msg *) skb->data; + struct hif_msg *hif = (struct hif_msg *)skb->data; struct hif_req_tx *req = (struct hif_req_tx *) hif->body; return req; -- cgit v1.2.3-59-g8ed1b From 1dc3d53ef39061a8cdf2245324e4f1769c4a360a Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Sat, 19 Oct 2019 15:07:16 +0100 Subject: staging: wfx: fix warning of line over 80 characters Fix warning of lines over 80 characters. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191019140719.2542-3-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 17 ++++--- drivers/staging/wfx/bus.h | 6 ++- drivers/staging/wfx/bus_sdio.c | 3 +- drivers/staging/wfx/bus_spi.c | 9 ++-- drivers/staging/wfx/data_rx.c | 15 ++++-- drivers/staging/wfx/data_tx.c | 101 ++++++++++++++++++++++++++++------------- 6 files changed, 102 insertions(+), 49 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 573216b08042..955ed3a1dd73 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -32,7 +32,8 @@ static void device_wakeup(struct wfx_dev *wdev) // completion without consume it (a kind of // wait_for_completion_done_timeout()). So we have to emulate // it. - if (wait_for_completion_timeout(&wdev->hif.ctrl_ready, msecs_to_jiffies(2) + 1)) + if (wait_for_completion_timeout(&wdev->hif.ctrl_ready, + msecs_to_jiffies(2) + 1)) complete(&wdev->hif.ctrl_ready); else dev_err(wdev->dev, "timeout while wake up chip\n"); @@ -179,8 +180,9 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif) wdev->hif.tx_seqnum = (wdev->hif.tx_seqnum + 1) % (HIF_COUNTER_MAX + 1); if (wfx_is_secure_command(wdev, hif->id)) { - len = round_up(len - sizeof(hif->len), 16) + sizeof(hif->len) - + sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_sl_tag); + len = round_up(len - sizeof(hif->len), 16) + sizeof(hif->len) + + sizeof(struct hif_sl_msg_hdr) + + sizeof(struct hif_sl_tag); // AES support encryption in-place. However, mac80211 access to // 802.11 header after frame was sent (to get MAC addresses). // So, keep origin buffer clear. @@ -241,7 +243,8 @@ static void ack_sdio_data(struct wfx_dev *wdev) config_reg_read(wdev, &cfg_reg); if (cfg_reg & 0xFF) { - dev_warn(wdev->dev, "chip reports errors: %02x\n", cfg_reg & 0xFF); + dev_warn(wdev->dev, "chip reports errors: %02x\n", + cfg_reg & 0xFF); config_reg_write_bits(wdev, 0xFF, 0x00); } } @@ -268,11 +271,13 @@ static void bh_work(struct work_struct *work) if (last_op_is_rx) ack_sdio_data(wdev); - if (!wdev->hif.tx_buffers_used && !work_pending(work) && !atomic_read(&wdev->scan_in_progress)) { + if (!wdev->hif.tx_buffers_used && !work_pending(work) && + !atomic_read(&wdev->scan_in_progress)) { device_release(wdev); release_chip = true; } - _trace_bh_stats(stats_ind, stats_req, stats_cnf, wdev->hif.tx_buffers_used, release_chip); + _trace_bh_stats(stats_ind, stats_req, stats_cnf, + wdev->hif.tx_buffers_used, release_chip); } /* diff --git a/drivers/staging/wfx/bus.h b/drivers/staging/wfx/bus.h index eb77abc09ec2..62d6ecabe4cb 100644 --- a/drivers/staging/wfx/bus.h +++ b/drivers/staging/wfx/bus.h @@ -21,8 +21,10 @@ #define WFX_REG_FRAME_OUT 0x7 struct hwbus_ops { - int (*copy_from_io)(void *bus_priv, unsigned int addr, void *dst, size_t count); - int (*copy_to_io)(void *bus_priv, unsigned int addr, const void *src, size_t count); + int (*copy_from_io)(void *bus_priv, unsigned int addr, + void *dst, size_t count); + int (*copy_to_io)(void *bus_priv, unsigned int addr, + const void *src, size_t count); void (*lock)(void *bus_priv); void (*unlock)(void *bus_priv); size_t (*align_size)(void *bus_priv, size_t size); diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 184e20dfdd62..375e07d6d9ae 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -180,7 +180,8 @@ static int wfx_sdio_probe(struct sdio_func *func, } bus->of_irq = irq_of_parse_and_map(np, 0); } else { - dev_warn(&func->dev, "device is not declared in DT, features will be limited\n"); + dev_warn(&func->dev, + "device is not declared in DT, features will be limited\n"); // FIXME: ignore VID/PID and only rely on device tree // return -ENODEV; } diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index effd07957753..ab0cda1e124f 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -178,11 +178,14 @@ static int wfx_spi_probe(struct spi_device *func) return ret; // Trace below is also displayed by spi_setup() if compiled with DEBUG dev_dbg(&func->dev, "SPI params: CS=%d, mode=%d bits/word=%d speed=%d\n", - func->chip_select, func->mode, func->bits_per_word, func->max_speed_hz); + func->chip_select, func->mode, func->bits_per_word, + func->max_speed_hz); if (func->bits_per_word != 16 && func->bits_per_word != 8) - dev_warn(&func->dev, "unusual bits/word value: %d\n", func->bits_per_word); + dev_warn(&func->dev, "unusual bits/word value: %d\n", + func->bits_per_word); if (func->max_speed_hz > 49000000) - dev_warn(&func->dev, "%dHz is a very high speed\n", func->max_speed_hz); + dev_warn(&func->dev, "%dHz is a very high speed\n", + func->max_speed_hz); bus = devm_kzalloc(&func->dev, sizeof(*bus), GFP_KERNEL); if (!bus) diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 3a79ab93e97e..522592d71aac 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -98,7 +98,8 @@ static int wfx_drop_encrypt_data(struct wfx_dev *wdev, struct hif_ind_rx *arg, s } -void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb) +void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, + struct sk_buff *skb) { int link_id = arg->rx_flags.peer_sta_id; struct ieee80211_rx_status *hdr = IEEE80211_SKB_RXCB(skb); @@ -118,7 +119,8 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb if (link_id && link_id <= WFX_MAX_STA_IN_AP_MODE) { entry = &wvif->link_id_db[link_id - 1]; entry->timestamp = jiffies; - if (entry->status == WFX_LINK_SOFT && ieee80211_is_data(frame->frame_control)) + if (entry->status == WFX_LINK_SOFT && + ieee80211_is_data(frame->frame_control)) early_data = true; } @@ -137,7 +139,8 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb goto drop; hdr->band = NL80211_BAND_2GHZ; - hdr->freq = ieee80211_channel_to_frequency(arg->channel_number, hdr->band); + hdr->freq = ieee80211_channel_to_frequency(arg->channel_number, + hdr->band); if (arg->rxed_rate >= 14) { hdr->encoding = RX_ENC_HT; @@ -166,7 +169,8 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb goto drop; if (ieee80211_is_beacon(frame->frame_control) && !arg->status && wvif->vif - && ether_addr_equal(ieee80211_get_SA(frame), wvif->vif->bss_conf.bssid)) { + && ether_addr_equal(ieee80211_get_SA(frame), + wvif->vif->bss_conf.bssid)) { const u8 *tim_ie; u8 *ies = mgmt->u.beacon.variable; size_t ies_len = skb->len - (ies - skb->data); @@ -183,7 +187,8 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb /* Disable beacon filter once we're associated... */ if (wvif->disable_beacon_filter && - (wvif->vif->bss_conf.assoc || wvif->vif->bss_conf.ibss_joined)) { + (wvif->vif->bss_conf.assoc || + wvif->vif->bss_conf.ibss_joined)) { wvif->disable_beacon_filter = false; schedule_work(&wvif->update_filtering_work); } diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index cf73b83ccc9e..619ab2cac5fc 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -20,7 +20,8 @@ #define WFX_LINK_ID_NO_ASSOC 15 #define WFX_LINK_ID_GC_TIMEOUT ((unsigned long)(10 * HZ)) -static int wfx_get_hw_rate(struct wfx_dev *wdev, const struct ieee80211_tx_rate *rate) +static int wfx_get_hw_rate(struct wfx_dev *wdev, + const struct ieee80211_tx_rate *rate) { if (rate->idx < 0) return -1; @@ -120,12 +121,14 @@ static void wfx_tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, } } -static bool tx_policy_is_equal(const struct tx_policy *a, const struct tx_policy *b) +static bool tx_policy_is_equal(const struct tx_policy *a, + const struct tx_policy *b) { return !memcmp(a->rates, b->rates, sizeof(a->rates)); } -static int wfx_tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *wanted) +static int wfx_tx_policy_find(struct tx_policy_cache *cache, + struct tx_policy *wanted) { struct tx_policy *it; @@ -138,13 +141,15 @@ static int wfx_tx_policy_find(struct tx_policy_cache *cache, struct tx_policy *w return -1; } -static void wfx_tx_policy_use(struct tx_policy_cache *cache, struct tx_policy *entry) +static void wfx_tx_policy_use(struct tx_policy_cache *cache, + struct tx_policy *entry) { ++entry->usage_count; list_move(&entry->link, &cache->used); } -static int wfx_tx_policy_release(struct tx_policy_cache *cache, struct tx_policy *entry) +static int wfx_tx_policy_release(struct tx_policy_cache *cache, + struct tx_policy *entry) { int ret = --entry->usage_count; @@ -153,8 +158,9 @@ static int wfx_tx_policy_release(struct tx_policy_cache *cache, struct tx_policy return ret; } -static int wfx_tx_policy_get(struct wfx_vif *wvif, struct ieee80211_tx_rate *rates, - bool *renew) +static int wfx_tx_policy_get(struct wfx_vif *wvif, + struct ieee80211_tx_rate *rates, + bool *renew) { int idx; struct tx_policy_cache *cache = &wvif->tx_policy_cache; @@ -211,7 +217,10 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) int i; struct tx_policy_cache *cache = &wvif->tx_policy_cache; struct hif_mib_set_tx_rate_retry_policy *arg = - kzalloc(struct_size(arg, tx_rate_retry_policy, HIF_MIB_NUM_TX_RATE_RETRY_POLICIES), GFP_KERNEL); + kzalloc(struct_size(arg, + tx_rate_retry_policy, + HIF_MIB_NUM_TX_RATE_RETRY_POLICIES), + GFP_KERNEL); struct hif_mib_tx_rate_retry_policy *dst; spin_lock_bh(&cache->lock); @@ -220,7 +229,8 @@ static int wfx_tx_policy_upload(struct wfx_vif *wvif) struct tx_policy *src = &cache->cache[i]; if (!src->uploaded && memzcmp(src->rates, sizeof(src->rates))) { - dst = arg->tx_rate_retry_policy + arg->num_tx_rate_policies; + dst = arg->tx_rate_retry_policy + + arg->num_tx_rate_policies; dst->policy_index = i; dst->short_retry_count = 255; @@ -326,7 +336,8 @@ int wfx_find_link_id(struct wfx_vif *wvif, const u8 *mac) return ret; } -static int wfx_map_link(struct wfx_vif *wvif, struct wfx_link_entry *link_entry, int sta_id) +static int wfx_map_link(struct wfx_vif *wvif, + struct wfx_link_entry *link_entry, int sta_id) { int ret; @@ -437,7 +448,8 @@ static bool ieee80211_is_action_back(struct ieee80211_hdr *hdr) } static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, - struct wfx_tx_priv *tx_priv, struct ieee80211_sta *sta) + struct wfx_tx_priv *tx_priv, + struct ieee80211_sta *sta) { u32 mask = ~BIT(tx_priv->raw_link_id); @@ -447,7 +459,8 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, wvif->pspoll_mask &= mask; } - if (tx_priv->link_id == WFX_LINK_ID_AFTER_DTIM && !wvif->mcast_buffered) { + if (tx_priv->link_id == WFX_LINK_ID_AFTER_DTIM && + !wvif->mcast_buffered) { wvif->mcast_buffered = true; if (wvif->sta_asleep_mask) schedule_work(&wvif->mcast_start_work); @@ -464,9 +477,12 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, ieee80211_sta_set_buffered(sta, tx_priv->tid, true); } -static uint8_t wfx_tx_get_raw_link_id(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct ieee80211_hdr *hdr) +static uint8_t wfx_tx_get_raw_link_id(struct wfx_vif *wvif, + struct ieee80211_sta *sta, + struct ieee80211_hdr *hdr) { - struct wfx_sta_priv *sta_priv = sta ? (struct wfx_sta_priv *) &sta->drv_priv : NULL; + struct wfx_sta_priv *sta_priv = + sta ? (struct wfx_sta_priv *) &sta->drv_priv : NULL; const u8 *da = ieee80211_get_DA(hdr); int ret; @@ -505,8 +521,11 @@ static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates) do { finished = true; for (i = 0; i < IEEE80211_TX_MAX_RATES - 1; i++) { - if (rates[i + 1].idx == rates[i].idx && rates[i].idx != -1) { - rates[i].count = max_t(int, rates[i].count, rates[i + 1].count); + if (rates[i + 1].idx == rates[i].idx && + rates[i].idx != -1) { + rates[i].count = + max_t(int, rates[i].count, + rates[i + 1].count); rates[i + 1].idx = -1; rates[i + 1].count = 0; @@ -523,12 +542,14 @@ static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates) rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI; } -static uint8_t wfx_tx_get_rate_id(struct wfx_vif *wvif, struct ieee80211_tx_info *tx_info) +static uint8_t wfx_tx_get_rate_id(struct wfx_vif *wvif, + struct ieee80211_tx_info *tx_info) { bool tx_policy_renew = false; uint8_t rate_id; - rate_id = wfx_tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); + rate_id = wfx_tx_policy_get(wvif, + tx_info->driver_rates, &tx_policy_renew); WARN(rate_id == WFX_INVALID_RATE_ID, "unable to get a valid Tx policy"); if (tx_policy_renew) { @@ -584,7 +605,8 @@ static int wfx_tx_get_icv_len(struct ieee80211_key_conf *hw_key) return hw_key->icv_len + mic_space; } -static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct sk_buff *skb) +static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, + struct sk_buff *skb) { struct hif_msg *hif_msg; struct hif_req_tx *req; @@ -594,7 +616,8 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; int queue_id = tx_info->hw_queue; size_t offset = (size_t) skb->data & 3; - int wmsg_len = sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + offset; + int wmsg_len = sizeof(struct hif_msg) + + sizeof(struct hif_req_tx) + offset; WARN(queue_id >= IEEE80211_NUM_ACS, "unsupported queue_id"); wfx_tx_fixup_rates(tx_info->driver_rates); @@ -632,7 +655,8 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct // Fill tx request req = (struct hif_req_tx *)hif_msg->body; - req->packet_id = queue_id << 16 | IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); + req->packet_id = queue_id << 16 | + IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); req->data_flags.fc_offset = offset; req->queue_id.peer_sta_id = tx_priv->raw_link_id; // Queue index are inverted between firmware and Linux @@ -655,7 +679,8 @@ void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct ieee80211_sta *sta = control ? control->sta : NULL; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - size_t driver_data_room = FIELD_SIZEOF(struct ieee80211_tx_info, rate_driver_data); + size_t driver_data_room = FIELD_SIZEOF(struct ieee80211_tx_info, + rate_driver_data); compiletime_assert(sizeof(struct wfx_tx_priv) <= driver_data_room, "struct tx_priv is too large"); @@ -692,12 +717,15 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) skb = wfx_pending_get(wvif->wdev, arg->packet_id); if (!skb) { - dev_warn(wvif->wdev->dev, "received unknown packet_id (%#.8x) from chip\n", arg->packet_id); + dev_warn(wvif->wdev->dev, + "received unknown packet_id (%#.8x) from chip\n", + arg->packet_id); return; } tx_info = IEEE80211_SKB_CB(skb); tx_priv = wfx_skb_tx_priv(skb); - _trace_tx_stats(arg, skb, wfx_pending_get_pkt_us_delay(wvif->wdev, skb)); + _trace_tx_stats(arg, skb, + wfx_pending_get_pkt_us_delay(wvif->wdev, skb)); // You can touch to tx_priv, but don't touch to tx_info->status. tx_count = arg->ack_failures; @@ -710,9 +738,12 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) if (tx_count < rate->count && arg->status && arg->ack_failures) dev_dbg(wvif->wdev->dev, "all retries were not consumed: %d != %d\n", rate->count, tx_count); - if (tx_count <= rate->count && tx_count && arg->txed_rate != wfx_get_hw_rate(wvif->wdev, rate)) - dev_dbg(wvif->wdev->dev, "inconsistent tx_info rates: %d != %d\n", - arg->txed_rate, wfx_get_hw_rate(wvif->wdev, rate)); + if (tx_count <= rate->count && tx_count && + arg->txed_rate != wfx_get_hw_rate(wvif->wdev, rate)) + dev_dbg(wvif->wdev->dev, + "inconsistent tx_info rates: %d != %d\n", + arg->txed_rate, + wfx_get_hw_rate(wvif->wdev, rate)); if (tx_count > rate->count) { tx_count -= rate->count; } else if (!tx_count) { @@ -724,7 +755,8 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) } } if (tx_count) - dev_dbg(wvif->wdev->dev, "%d more retries than expected\n", tx_count); + dev_dbg(wvif->wdev->dev, + "%d more retries than expected\n", tx_count); skb_trim(skb, skb->len - wfx_tx_get_icv_len(tx_priv->hw_key)); // From now, you can touch to tx_info->status, but do not touch to @@ -734,9 +766,11 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) memset(tx_info->pad, 0, sizeof(tx_info->pad)); if (!arg->status) { - if (wvif->bss_loss_state && arg->packet_id == wvif->bss_loss_confirm_id) + if (wvif->bss_loss_state && + arg->packet_id == wvif->bss_loss_confirm_id) wfx_cqm_bssloss_sm(wvif, 0, 1, 0); - tx_info->status.tx_time = arg->media_delay - arg->tx_queue_delay; + tx_info->status.tx_time = + arg->media_delay - arg->tx_queue_delay; if (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) tx_info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; else @@ -752,7 +786,8 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, struct hif_cnf_tx *arg) wfx_suspend_resume(wvif, &suspend); tx_info->flags |= IEEE80211_TX_STAT_TX_FILTERED; } else { - if (wvif->bss_loss_state && arg->packet_id == wvif->bss_loss_confirm_id) + if (wvif->bss_loss_state && + arg->packet_id == wvif->bss_loss_confirm_id) wfx_cqm_bssloss_sm(wvif, 0, 0, 1); } wfx_pending_remove(wvif->wdev, skb); @@ -790,7 +825,9 @@ void wfx_skb_dtor(struct wfx_dev *wdev, struct sk_buff *skb) struct hif_msg *hif = (struct hif_msg *)skb->data; struct hif_req_tx *req = (struct hif_req_tx *)hif->body; struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); - unsigned int offset = sizeof(struct hif_req_tx) + sizeof(struct hif_msg) + req->data_flags.fc_offset; + unsigned int offset = sizeof(struct hif_req_tx) + + sizeof(struct hif_msg) + + req->data_flags.fc_offset; WARN_ON(!wvif); skb_pull(skb, offset); -- cgit v1.2.3-59-g8ed1b From 640a4db708f5b3eb878c495863cb2fb57693ea04 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Sat, 19 Oct 2019 15:07:17 +0100 Subject: staging: wfx: fix warnings of logical continuation Fix check warnings of logical continuations should be on the previous line. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191019140719.2542-4-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_rx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 522592d71aac..52fb0f255dcd 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -163,14 +163,14 @@ void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, } /* Filter block ACK negotiation: fully controlled by firmware */ - if (ieee80211_is_action(frame->frame_control) - && arg->rx_flags.match_uc_addr - && mgmt->u.action.category == WLAN_CATEGORY_BACK) + if (ieee80211_is_action(frame->frame_control) && + arg->rx_flags.match_uc_addr && + mgmt->u.action.category == WLAN_CATEGORY_BACK) goto drop; - if (ieee80211_is_beacon(frame->frame_control) - && !arg->status && wvif->vif - && ether_addr_equal(ieee80211_get_SA(frame), - wvif->vif->bss_conf.bssid)) { + if (ieee80211_is_beacon(frame->frame_control) && + !arg->status && wvif->vif && + ether_addr_equal(ieee80211_get_SA(frame), + wvif->vif->bss_conf.bssid)) { const u8 *tim_ie; u8 *ies = mgmt->u.beacon.variable; size_t ies_len = skb->len - (ies - skb->data); -- cgit v1.2.3-59-g8ed1b From 5f647dca011c094a3bd0ffb42404b77138ea9158 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Sat, 19 Oct 2019 15:07:18 +0100 Subject: staging: wfx: correct misspelled words Correct misspelled words: retrieved and auxiliary. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191019140719.2542-5-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 619ab2cac5fc..a02692f3210d 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -32,7 +32,7 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev, } return rate->idx + 14; } - // WFx only support 2GHz, else band information should be retreived + // WFx only support 2GHz, else band information should be retrieved // from ieee80211_tx_info return wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->bitrates[rate->idx].hw_value; } @@ -664,7 +664,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, req->ht_tx_parameters = wfx_tx_get_tx_parms(wvif->wdev, tx_info); req->tx_flags.retry_policy_index = wfx_tx_get_rate_id(wvif, tx_info); - // Auxilliary operations + // Auxiliary operations wfx_tx_manage_pm(wvif, hdr, tx_priv, sta); wfx_tx_queue_put(wvif->wdev, &wvif->wdev->tx_queue[queue_id], skb); wfx_bh_request_tx(wvif->wdev); -- cgit v1.2.3-59-g8ed1b From 4b1aa4ba48788bc20412b10744ba7ab36d125974 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Sat, 19 Oct 2019 15:07:19 +0100 Subject: staging: wfx: fix warnings of alignment should match open parenthesis : Fix warnings of alignment should match open parenthesis. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191019140719.2542-6-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_rx.c | 2 +- drivers/staging/wfx/data_tx.c | 2 +- drivers/staging/wfx/debug.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 52fb0f255dcd..e7fcce8d0cc4 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -77,7 +77,7 @@ static int wfx_drop_encrypt_data(struct wfx_dev *wdev, struct hif_ind_rx *arg, s break; default: dev_err(wdev->dev, "unknown encryption type %d\n", - arg->rx_flags.encryp); + arg->rx_flags.encryp); return -EIO; } diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index a02692f3210d..ea4205ac2149 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -40,7 +40,7 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev, /* TX policy cache implementation */ static void wfx_tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, - struct ieee80211_tx_rate *rates) + struct ieee80211_tx_rate *rates) { int i; size_t count; diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 761ad9b4f27e..0a9ca109039c 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -141,10 +141,11 @@ static int wfx_rx_stats_show(struct seq_file *seq, void *v) mutex_lock(&wdev->rx_stats_lock); seq_printf(seq, "Timestamp: %dus\n", st->date); seq_printf(seq, "Low power clock: frequency %uHz, external %s\n", - st->pwr_clk_freq, - st->is_ext_pwr_clk ? "yes" : "no"); - seq_printf(seq, "Num. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n", - st->nb_rx_frame, st->per_total, st->throughput); + st->pwr_clk_freq, + st->is_ext_pwr_clk ? "yes" : "no"); + seq_printf(seq, + "N. of frames: %d, PER (x10e4): %d, Throughput: %dKbps/s\n", + st->nb_rx_frame, st->per_total, st->throughput); seq_puts(seq, " Num. of PER RSSI SNR CFO\n"); seq_puts(seq, " frames (x10e4) (dBm) (dB) (kHz)\n"); for (i = 0; i < ARRAY_SIZE(channel_names); i++) { @@ -160,8 +161,9 @@ static int wfx_rx_stats_show(struct seq_file *seq, void *v) } DEFINE_SHOW_ATTRIBUTE(wfx_rx_stats); -static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t wfx_send_pds_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) { struct wfx_dev *wdev = file->private_data; char *buf; -- cgit v1.2.3-59-g8ed1b From 54c6feca8609304eb268f828c669ecd8e22c40fc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:29 +0200 Subject: staging: rtl8188eu: cleanup comments in rtw_sta_mgt.c Cleanup comments in rtw_sta_mgt.c to use kernel block comment style and not exceed 80 characters line length. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 91a30142c567..cbe970979eb0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -199,10 +199,13 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) pstapriv->asoc_sta_count++; spin_unlock_bh(&pstapriv->sta_hash_lock); -/* Commented by Albert 2009/08/13 */ -/* For the SMC router, the sequence number of first packet of WPS handshake will be 0. */ -/* In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */ -/* So, we initialize the tid_rxseq variable as the 0xffff. */ + /* Commented by Albert 2009/08/13 + * For the SMC router, the sequence number of first packet of + * WPS handshake will be 0. In this case, this packet will be + * dropped by recv_decache function if we use the 0x00 as the + * default value for tid_rxseq variable. So, we initialize the + * tid_rxseq variable as the 0xffff. + */ for (i = 0; i < 16; i++) memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); @@ -296,7 +299,9 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) del_timer_sync(&psta->addba_retry_timer); - /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ + /* for A-MPDU Rx reordering buffer control, cancel + * reordering_ctrl_timer + */ for (i = 0; i < 16; i++) { struct list_head *phead, *plist; struct recv_frame *prframe; -- cgit v1.2.3-59-g8ed1b From da3611f2fa4bcc47ed769197d93823d3a788b6e9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:30 +0200 Subject: staging: rtl8188eu: convert unsigned char array to u8 Convert array bcast_addr from unsigned char to u8. Clears a line over 80 characters checkpatch warning. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index cbe970979eb0..394b887a8bde 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -450,7 +450,7 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) { struct sta_info *psta; u32 res = _SUCCESS; - unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_alloc_stainfo(pstapriv, bcast_addr); -- cgit v1.2.3-59-g8ed1b From 62ab5b466690213a190a3ec528123029db4de7c3 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:31 +0200 Subject: staging: rtl8188eu: rename array bcast_addr Rename array bcast_addr to be more consistent in variable naming. In other places in this file buffers for broadcast addresses are named bc_addr as well. bcast_addr -> bc_addr Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 394b887a8bde..157ae2f355ff 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -450,10 +450,10 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) { struct sta_info *psta; u32 res = _SUCCESS; - u8 bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sta_priv *pstapriv = &padapter->stapriv; - psta = rtw_alloc_stainfo(pstapriv, bcast_addr); + psta = rtw_alloc_stainfo(pstapriv, bc_addr); if (!psta) { res = _FAIL; -- cgit v1.2.3-59-g8ed1b From 4e6f391fde3410fb4141261d45333217c22230d4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:32 +0200 Subject: staging: rtl8188eu: convert rtw_access_ctrl to return bool Function rtw_access_ctrl returns boolean values, so change the return type to bool. Also convert the local variables that are used for the return value from u8 to bool. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 6 +++--- drivers/staging/rtl8188eu/include/sta_info.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 157ae2f355ff..282c835a635c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -476,13 +476,13 @@ struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) return rtw_get_stainfo(pstapriv, bc_addr); } -u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) +bool rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) { - u8 res = true; + bool res = true; #ifdef CONFIG_88EU_AP_MODE struct list_head *plist, *phead; struct rtw_wlan_acl_node *paclnode; - u8 match = false; + bool match = false; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct __queue *pacl_node_q = &pacl_list->acl_node_q; diff --git a/drivers/staging/rtl8188eu/include/sta_info.h b/drivers/staging/rtl8188eu/include/sta_info.h index dc685a14aeb8..6165adafc451 100644 --- a/drivers/staging/rtl8188eu/include/sta_info.h +++ b/drivers/staging/rtl8188eu/include/sta_info.h @@ -354,6 +354,6 @@ void rtw_free_all_stainfo(struct adapter *adapt); struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr); u32 rtw_init_bcmc_stainfo(struct adapter *adapt); struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter); -u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); +bool rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); #endif /* _STA_INFO_H_ */ -- cgit v1.2.3-59-g8ed1b From dd85035172d081e7dc98d03331340e911c44a832 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:33 +0200 Subject: staging: rtl8188eu: remove ternary operator Instead of using ternary operator to set variable res, use the value of variable match (or the negation) directly to simplify the code and improve readability. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 282c835a635c..3cadc46836e1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -504,9 +504,9 @@ bool rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) spin_unlock_bh(&pacl_node_q->lock); if (pacl_list->mode == 1)/* accept unless in deny list */ - res = (match) ? false : true; + res = !match; else if (pacl_list->mode == 2)/* deny unless in accept list */ - res = (match) ? true : false; + res = match; else res = true; -- cgit v1.2.3-59-g8ed1b From 1cafe435a9a0469613b416b1cd94ed67bccf4ecc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:34 +0200 Subject: staging: rtl8188eu: cleanup long lines in rtw_sta_mgt.c Cleanup lines over 80 characters in rtw_sta_mgt.c by adding line breaks where appropriate. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-6-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 3cadc46836e1..43925b1f43ef 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -83,7 +83,8 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) INIT_LIST_HEAD(&pstapriv->sta_hash[i]); - list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); + list_add_tail(&psta->list, + get_list_head(&pstapriv->free_sta_queue)); psta++; } @@ -186,9 +187,11 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) _rtw_init_stainfo(psta); memcpy(psta->hwaddr, hwaddr, ETH_ALEN); index = wifi_mac_hash(hwaddr); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("%s: index=%x", __func__, index)); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, + ("%s: index=%x", __func__, index)); if (index >= NUM_STA) { - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => %s: index >= NUM_STA", __func__)); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, + ("ERROR => %s: index >= NUM_STA", __func__)); psta = NULL; goto exit; } @@ -208,7 +211,8 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) */ for (i = 0; i < 16; i++) - memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); + memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], + &wRxSeqInitialValue, 2); RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("alloc number_%d stainfo with hwaddr = %pM\n", @@ -457,7 +461,8 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) if (!psta) { res = _FAIL; - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, + ("rtw_alloc_stainfo fail")); goto exit; } -- cgit v1.2.3-59-g8ed1b From 48d357f0beb28e06a52493f73e0606e4b14f6ce9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 14:11:35 +0200 Subject: staging: rtl8188eu: reduce indentation level in rtw_alloc_stainfo Remove else-arm from if-else statement. Move the else code out of the if-else and skip it by adding goto exit to the if block. The exit label was directly after the else-arm, so there is no change in behaviour. Reduces indentation level and clears a line over 80 characters checkpatch warning. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191026121135.181897-7-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 101 ++++++++++++++------------- 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 43925b1f43ef..776931b8bf72 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -181,70 +181,71 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) struct sta_info, list); if (!psta) { spin_unlock_bh(&pfree_sta_queue->lock); - } else { - list_del_init(&psta->list); - spin_unlock_bh(&pfree_sta_queue->lock); - _rtw_init_stainfo(psta); - memcpy(psta->hwaddr, hwaddr, ETH_ALEN); - index = wifi_mac_hash(hwaddr); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, - ("%s: index=%x", __func__, index)); - if (index >= NUM_STA) { - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, - ("ERROR => %s: index >= NUM_STA", __func__)); - psta = NULL; - goto exit; - } - phash_list = &pstapriv->sta_hash[index]; - - spin_lock_bh(&pstapriv->sta_hash_lock); - list_add_tail(&psta->hash_list, phash_list); - pstapriv->asoc_sta_count++; - spin_unlock_bh(&pstapriv->sta_hash_lock); + goto exit; + } - /* Commented by Albert 2009/08/13 - * For the SMC router, the sequence number of first packet of - * WPS handshake will be 0. In this case, this packet will be - * dropped by recv_decache function if we use the 0x00 as the - * default value for tid_rxseq variable. So, we initialize the - * tid_rxseq variable as the 0xffff. - */ + list_del_init(&psta->list); + spin_unlock_bh(&pfree_sta_queue->lock); + _rtw_init_stainfo(psta); + memcpy(psta->hwaddr, hwaddr, ETH_ALEN); + index = wifi_mac_hash(hwaddr); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, + ("%s: index=%x", __func__, index)); + if (index >= NUM_STA) { + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, + ("ERROR => %s: index >= NUM_STA", __func__)); + psta = NULL; + goto exit; + } + phash_list = &pstapriv->sta_hash[index]; - for (i = 0; i < 16; i++) - memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], - &wRxSeqInitialValue, 2); + spin_lock_bh(&pstapriv->sta_hash_lock); + list_add_tail(&psta->hash_list, phash_list); + pstapriv->asoc_sta_count++; + spin_unlock_bh(&pstapriv->sta_hash_lock); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, - ("alloc number_%d stainfo with hwaddr = %pM\n", - pstapriv->asoc_sta_count, hwaddr)); + /* Commented by Albert 2009/08/13 + * For the SMC router, the sequence number of first packet of + * WPS handshake will be 0. In this case, this packet will be + * dropped by recv_decache function if we use the 0x00 as the + * default value for tid_rxseq variable. So, we initialize the + * tid_rxseq variable as the 0xffff. + */ - init_addba_retry_timer(pstapriv->padapter, psta); + for (i = 0; i < 16; i++) + memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], + &wRxSeqInitialValue, 2); - /* for A-MPDU Rx reordering buffer control */ - for (i = 0; i < 16; i++) { - preorder_ctrl = &psta->recvreorder_ctrl[i]; + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, + ("alloc number_%d stainfo with hwaddr = %pM\n", + pstapriv->asoc_sta_count, hwaddr)); - preorder_ctrl->padapter = pstapriv->padapter; + init_addba_retry_timer(pstapriv->padapter, psta); - preorder_ctrl->enable = false; + /* for A-MPDU Rx reordering buffer control */ + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; - preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* 64; */ + preorder_ctrl->padapter = pstapriv->padapter; - _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); + preorder_ctrl->enable = false; - rtw_init_recv_timer(preorder_ctrl); - } + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* 64; */ - /* init for DM */ - psta->rssi_stat.UndecoratedSmoothedPWDB = -1; - psta->rssi_stat.UndecoratedSmoothedCCK = -1; + _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); - /* init for the sequence number of received management frame */ - psta->RxMgmtFrameSeqNum = 0xffff; + rtw_init_recv_timer(preorder_ctrl); } + /* init for DM */ + psta->rssi_stat.UndecoratedSmoothedPWDB = -1; + psta->rssi_stat.UndecoratedSmoothedCCK = -1; + + /* init for the sequence number of received management frame */ + psta->RxMgmtFrameSeqNum = 0xffff; + exit: return psta; } -- cgit v1.2.3-59-g8ed1b From eaa4e501cf1d96977bc167fcf43059f9272e78ce Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 25 Oct 2019 09:41:22 +0100 Subject: staging: wlan-ng: remove unnecessary casts from prism2usb.c usb_get_intfdata returns a void pointer. It is not necessary to explicitly cast to the desired type and removing the casts is consistent with most use of usb_get_intfdata. Signed-off-by: Tim Collier Link: https://lore.kernel.org/r/20191025084126.9181-2-osdevtc@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index b5ba176004c1..352556f6870a 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -137,7 +137,7 @@ static void prism2sta_disconnect_usb(struct usb_interface *interface) { struct wlandevice *wlandev; - wlandev = (struct wlandevice *)usb_get_intfdata(interface); + wlandev = usb_get_intfdata(interface); if (wlandev) { LIST_HEAD(cleanlist); struct hfa384x_usbctlx *ctlx, *temp; @@ -222,7 +222,7 @@ static int prism2sta_suspend(struct usb_interface *interface, struct hfa384x *hw = NULL; struct wlandevice *wlandev; - wlandev = (struct wlandevice *)usb_get_intfdata(interface); + wlandev = usb_get_intfdata(interface); if (!wlandev) return -ENODEV; @@ -245,7 +245,7 @@ static int prism2sta_resume(struct usb_interface *interface) struct hfa384x *hw = NULL; struct wlandevice *wlandev; - wlandev = (struct wlandevice *)usb_get_intfdata(interface); + wlandev = usb_get_intfdata(interface); if (!wlandev) return -ENODEV; -- cgit v1.2.3-59-g8ed1b From 7003e01ad41d6b23c89a5bc155fbfca92d831691 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 25 Oct 2019 09:41:23 +0100 Subject: staging: wlan-ng: shorten lines over 80 characters in hfa384x.h Shorten several lines reported as over 80 characters by checkpatch.pl. Signed-off-by: Tim Collier Link: https://lore.kernel.org/r/20191025084126.9181-3-osdevtc@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 5ff740a8837d..2d3d8b1e2c1b 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1337,7 +1337,9 @@ struct hfa384x { * interface */ - struct hfa384x_caplevel cap_act_sta_mfi; /* sta f/w to modem interface */ + struct hfa384x_caplevel cap_act_sta_mfi; /* + * sta f/w to modem interface + */ struct hfa384x_caplevel cap_act_ap_cfi; /* * ap f/w to controller @@ -1359,7 +1361,9 @@ struct hfa384x { struct hfa384x_inf_frame *scanresults; - struct prism2sta_authlist authlist; /* Authenticated station list. */ + struct prism2sta_authlist authlist; /* + * Authenticated station list. + */ unsigned int accessmode; /* Access mode. */ struct prism2sta_accesslist allow; /* Allowed station list. */ struct prism2sta_accesslist deny; /* Denied station list. */ @@ -1375,7 +1379,8 @@ int hfa384x_drvr_disable(struct hfa384x *hw, u16 macport); int hfa384x_drvr_enable(struct hfa384x *hw, u16 macport); int hfa384x_drvr_flashdl_enable(struct hfa384x *hw); int hfa384x_drvr_flashdl_disable(struct hfa384x *hw); -int hfa384x_drvr_flashdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len); +int hfa384x_drvr_flashdl_write(struct hfa384x *hw, u32 daddr, void *buf, + u32 len); int hfa384x_drvr_getconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len); int hfa384x_drvr_ramdl_enable(struct hfa384x *hw, u32 exeaddr); int hfa384x_drvr_ramdl_disable(struct hfa384x *hw); @@ -1383,7 +1388,8 @@ int hfa384x_drvr_ramdl_write(struct hfa384x *hw, u32 daddr, void *buf, u32 len); int hfa384x_drvr_readpda(struct hfa384x *hw, void *buf, unsigned int len); int hfa384x_drvr_setconfig(struct hfa384x *hw, u16 rid, void *buf, u16 len); -static inline int hfa384x_drvr_getconfig16(struct hfa384x *hw, u16 rid, void *val) +static inline int +hfa384x_drvr_getconfig16(struct hfa384x *hw, u16 rid, void *val) { int result = 0; -- cgit v1.2.3-59-g8ed1b From 95d8aa5c56f6e2aa629d7ef347f0b301d094ff5d Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 25 Oct 2019 09:41:24 +0100 Subject: staging: wlan-ng: correct parameter alignment in hfa384x.h Realign parameter in function declaration to fix checkpatch.pl warning that parameter needed to be aligned with the opening parenthesis of the declaration. Signed-off-by: Tim Collier Link: https://lore.kernel.org/r/20191025084126.9181-4-osdevtc@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 2d3d8b1e2c1b..86fd3fcd8a36 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1374,7 +1374,7 @@ void hfa384x_create(struct hfa384x *hw, struct usb_device *usb); void hfa384x_destroy(struct hfa384x *hw); int hfa384x_corereset(struct hfa384x *hw, int holdtime, int settletime, - int genesis); + int genesis); int hfa384x_drvr_disable(struct hfa384x *hw, u16 macport); int hfa384x_drvr_enable(struct hfa384x *hw, u16 macport); int hfa384x_drvr_flashdl_enable(struct hfa384x *hw); -- cgit v1.2.3-59-g8ed1b From bbf358ec1bd6e57c899e6c28623da1c24ca4b951 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 25 Oct 2019 09:41:25 +0100 Subject: staging: wlan-ng: fix compilation for USB debugging Fix compilation errors (remove references to 2 undefined fields in the URB struct) when DEBUG_USB is defined for the wlan-ng driver. Signed-off-by: Tim Collier Link: https://lore.kernel.org/r/20191025084126.9181-5-osdevtc@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 28d372a0663a..b71756ab0394 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -293,13 +293,11 @@ void dbprint_urb(struct urb *urb) pr_debug("urb->transfer_buffer_length=0x%08x\n", urb->transfer_buffer_length); pr_debug("urb->actual_length=0x%08x\n", urb->actual_length); - pr_debug("urb->bandwidth=0x%08x\n", urb->bandwidth); pr_debug("urb->setup_packet(ctl)=0x%08x\n", (unsigned int)urb->setup_packet); pr_debug("urb->start_frame(iso/irq)=0x%08x\n", urb->start_frame); pr_debug("urb->interval(irq)=0x%08x\n", urb->interval); pr_debug("urb->error_count(iso)=0x%08x\n", urb->error_count); - pr_debug("urb->timeout=0x%08x\n", urb->timeout); pr_debug("urb->context=0x%08x\n", (unsigned int)urb->context); pr_debug("urb->complete=0x%08x\n", (unsigned int)urb->complete); } -- cgit v1.2.3-59-g8ed1b From 5800d1d1565a5fc61349faa9e52bd1ca6be8fe43 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Fri, 25 Oct 2019 09:41:26 +0100 Subject: staging: wlan-ng: remove unused field from struct hfa384x_usbctlx The variant field in struct hfa384x_usbctlx is not referenced anywhere in the driver, so remove it. Signed-off-by: Tim Collier Link: https://lore.kernel.org/r/20191025084126.9181-6-osdevtc@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 86fd3fcd8a36..bdd7f414fdbb 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1181,8 +1181,6 @@ struct hfa384x_usbctlx { ctlx_cmdcb_t cmdcb; /* Async command callback */ ctlx_usercb_t usercb; /* Async user callback, */ void *usercb_data; /* at CTLX completion */ - - int variant; /* Identifies cmd variant */ }; struct hfa384x_usbctlxq { -- cgit v1.2.3-59-g8ed1b From f29acb9c5d0fe438291be62a68590891ce1cad9a Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Thu, 17 Oct 2019 20:02:03 +0300 Subject: drivers/staging/fbtft/fb_seps525: New driver for SEPS525 (Syncoam) LCD Controllers The SEPS525 is a 160 RGB x 128 Dots, 262K Colors PM-OLED Display Driver and Controller. The controller can be found on the NHD-1.69-160128UGC3 (Newhaven Display International, Inc.). Datasheets: Link: https://www.newhavendisplay.com/appnotes/datasheets/OLEDs/SEPS525.pdf Signed-off-by: Michael Hennerich Co-developed-by: Beniamin Bia Signed-off-by: Beniamin Bia Link: https://lore.kernel.org/r/20191017170203.11999-1-beniamin.bia@analog.com Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 8 ++ drivers/staging/fbtft/Kconfig | 7 ++ drivers/staging/fbtft/Makefile | 1 + drivers/staging/fbtft/fb_seps525.c | 213 +++++++++++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 drivers/staging/fbtft/fb_seps525.c (limited to 'drivers/staging') diff --git a/MAINTAINERS b/MAINTAINERS index 9034b76fe1df..246ed6a0224b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15474,6 +15474,14 @@ L: linux-wireless@vger.kernel.org S: Supported F: drivers/staging/wilc1000/ +STAGING - SEPS525 LCD CONTROLLER DRIVERS +M: Michael Hennerich +M: Beniamin Bia +L: linux-fbdev@vger.kernel.org +S: Supported +F: drivers/staging/fbtft/fb_seps525.c +F: Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml + STAGING SUBSYSTEM M: Greg Kroah-Hartman T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git diff --git a/drivers/staging/fbtft/Kconfig b/drivers/staging/fbtft/Kconfig index cb61c2a772bd..d994aea84b21 100644 --- a/drivers/staging/fbtft/Kconfig +++ b/drivers/staging/fbtft/Kconfig @@ -112,6 +112,13 @@ config FB_TFT_S6D1121 help Generic Framebuffer support for S6D1121 +config FB_TFT_SEPS525 + tristate "FB driver for the SEPS525 LCD Controller" + depends on FB_TFT + help + Generic Framebuffer support for SEPS525 + Say Y if you have such a display that utilizes this controller. + config FB_TFT_SH1106 tristate "FB driver for the SH1106 OLED Controller" depends on FB_TFT diff --git a/drivers/staging/fbtft/Makefile b/drivers/staging/fbtft/Makefile index 27af43f32f81..e87193f7df14 100644 --- a/drivers/staging/fbtft/Makefile +++ b/drivers/staging/fbtft/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_FB_TFT_PCD8544) += fb_pcd8544.o obj-$(CONFIG_FB_TFT_RA8875) += fb_ra8875.o obj-$(CONFIG_FB_TFT_S6D02A1) += fb_s6d02a1.o obj-$(CONFIG_FB_TFT_S6D1121) += fb_s6d1121.o +obj-$(CONFIG_FB_TFT_SEPS525) += fb_seps525.o obj-$(CONFIG_FB_TFT_SH1106) += fb_sh1106.o obj-$(CONFIG_FB_TFT_SSD1289) += fb_ssd1289.o obj-$(CONFIG_FB_TFT_SSD1305) += fb_ssd1305.o diff --git a/drivers/staging/fbtft/fb_seps525.c b/drivers/staging/fbtft/fb_seps525.c new file mode 100644 index 000000000000..05882e2cde7f --- /dev/null +++ b/drivers/staging/fbtft/fb_seps525.c @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FB driver for the NHD-1.69-160128UGC3 (Newhaven Display International, Inc.) + * using the SEPS525 (Syncoam) LCD Controller + * + * Copyright (C) 2016 Analog Devices Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include + +#include "fbtft.h" + +#define DRVNAME "fb_seps525" +#define WIDTH 160 +#define HEIGHT 128 + +#define SEPS525_INDEX 0x00 +#define SEPS525_STATUS_RD 0x01 +#define SEPS525_OSC_CTL 0x02 +#define SEPS525_IREF 0x80 +#define SEPS525_CLOCK_DIV 0x03 +#define SEPS525_REDUCE_CURRENT 0x04 +#define SEPS525_SOFT_RST 0x05 +#define SEPS525_DISP_ONOFF 0x06 +#define SEPS525_PRECHARGE_TIME_R 0x08 +#define SEPS525_PRECHARGE_TIME_G 0x09 +#define SEPS525_PRECHARGE_TIME_B 0x0A +#define SEPS525_PRECHARGE_CURRENT_R 0x0B +#define SEPS525_PRECHARGE_CURRENT_G 0x0C +#define SEPS525_PRECHARGE_CURRENT_B 0x0D +#define SEPS525_DRIVING_CURRENT_R 0x10 +#define SEPS525_DRIVING_CURRENT_G 0x11 +#define SEPS525_DRIVING_CURRENT_B 0x12 +#define SEPS525_DISPLAYMODE_SET 0x13 +#define SEPS525_RGBIF 0x14 +#define SEPS525_RGB_POL 0x15 +#define SEPS525_MEMORY_WRITEMODE 0x16 +#define SEPS525_MX1_ADDR 0x17 +#define SEPS525_MX2_ADDR 0x18 +#define SEPS525_MY1_ADDR 0x19 +#define SEPS525_MY2_ADDR 0x1A +#define SEPS525_MEMORY_ACCESS_POINTER_X 0x20 +#define SEPS525_MEMORY_ACCESS_POINTER_Y 0x21 +#define SEPS525_DDRAM_DATA_ACCESS_PORT 0x22 +#define SEPS525_GRAY_SCALE_TABLE_INDEX 0x50 +#define SEPS525_GRAY_SCALE_TABLE_DATA 0x51 +#define SEPS525_DUTY 0x28 +#define SEPS525_DSL 0x29 +#define SEPS525_D1_DDRAM_FAC 0x2E +#define SEPS525_D1_DDRAM_FAR 0x2F +#define SEPS525_D2_DDRAM_SAC 0x31 +#define SEPS525_D2_DDRAM_SAR 0x32 +#define SEPS525_SCR1_FX1 0x33 +#define SEPS525_SCR1_FX2 0x34 +#define SEPS525_SCR1_FY1 0x35 +#define SEPS525_SCR1_FY2 0x36 +#define SEPS525_SCR2_SX1 0x37 +#define SEPS525_SCR2_SX2 0x38 +#define SEPS525_SCR2_SY1 0x39 +#define SEPS525_SCR2_SY2 0x3A +#define SEPS525_SCREEN_SAVER_CONTEROL 0x3B +#define SEPS525_SS_SLEEP_TIMER 0x3C +#define SEPS525_SCREEN_SAVER_MODE 0x3D +#define SEPS525_SS_SCR1_FU 0x3E +#define SEPS525_SS_SCR1_MXY 0x3F +#define SEPS525_SS_SCR2_FU 0x40 +#define SEPS525_SS_SCR2_MXY 0x41 +#define SEPS525_MOVING_DIRECTION 0x42 +#define SEPS525_SS_SCR2_SX1 0x47 +#define SEPS525_SS_SCR2_SX2 0x48 +#define SEPS525_SS_SCR2_SY1 0x49 +#define SEPS525_SS_SCR2_SY2 0x4A + +/* SEPS525_DISPLAYMODE_SET */ +#define MODE_SWAP_BGR BIT(7) +#define MODE_SM BIT(6) +#define MODE_RD BIT(5) +#define MODE_CD BIT(4) + +#define seps525_use_window 0 /* FBTFT doesn't really use it today */ + +/* Init sequence taken from: Arduino Library for the Adafruit 2.2" display */ +static int init_display(struct fbtft_par *par) +{ + par->fbtftops.reset(par); + + usleep_range(1000, 5000); + + /* Disable Oscillator Power Down */ + write_reg(par, SEPS525_REDUCE_CURRENT, 0x03); + usleep_range(1000, 5000); + /* Set Normal Driving Current */ + write_reg(par, SEPS525_REDUCE_CURRENT, 0x00); + usleep_range(1000, 5000); + + write_reg(par, SEPS525_SCREEN_SAVER_CONTEROL, 0x00); + /* Set EXPORT1 Pin at Internal Clock */ + write_reg(par, SEPS525_OSC_CTL, 0x01); + /* Set Clock as 120 Frames/Sec */ + write_reg(par, SEPS525_CLOCK_DIV, 0x90); + /* Set Reference Voltage Controlled by External Resister */ + write_reg(par, SEPS525_IREF, 0x01); + + /* precharge time R G B */ + write_reg(par, SEPS525_PRECHARGE_TIME_R, 0x04); + write_reg(par, SEPS525_PRECHARGE_TIME_G, 0x05); + write_reg(par, SEPS525_PRECHARGE_TIME_B, 0x05); + + /* precharge current R G B (uA) */ + write_reg(par, SEPS525_PRECHARGE_CURRENT_R, 0x9D); + write_reg(par, SEPS525_PRECHARGE_CURRENT_G, 0x8C); + write_reg(par, SEPS525_PRECHARGE_CURRENT_B, 0x57); + + /* driving current R G B (uA) */ + write_reg(par, SEPS525_DRIVING_CURRENT_R, 0x56); + write_reg(par, SEPS525_DRIVING_CURRENT_G, 0x4D); + write_reg(par, SEPS525_DRIVING_CURRENT_B, 0x46); + /* Set Color Sequence */ + write_reg(par, SEPS525_DISPLAYMODE_SET, 0xA0); + write_reg(par, SEPS525_RGBIF, 0x01); /* Set MCU Interface Mode */ + /* Set Memory Write Mode */ + write_reg(par, SEPS525_MEMORY_WRITEMODE, 0x66); + write_reg(par, SEPS525_DUTY, 0x7F); /* 1/128 Duty (0x0F~0x7F) */ + /* Set Mapping RAM Display Start Line (0x00~0x7F) */ + write_reg(par, SEPS525_DSL, 0x00); + write_reg(par, SEPS525_DISP_ONOFF, 0x01); /* Display On (0x00/0x01) */ + /* Set All Internal Register Value as Normal Mode */ + write_reg(par, SEPS525_SOFT_RST, 0x00); + /* Set RGB Interface Polarity as Active Low */ + write_reg(par, SEPS525_RGB_POL, 0x00); + + write_reg(par, SEPS525_DDRAM_DATA_ACCESS_PORT); + + return 0; +} + +static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye) +{ + if (seps525_use_window) { + /* Set Window Xs,Ys Xe,Ye*/ + write_reg(par, SEPS525_MX1_ADDR, xs); + write_reg(par, SEPS525_MX2_ADDR, xe); + write_reg(par, SEPS525_MY1_ADDR, ys); + write_reg(par, SEPS525_MY2_ADDR, ye); + } + /* start position X,Y */ + write_reg(par, SEPS525_MEMORY_ACCESS_POINTER_X, xs); + write_reg(par, SEPS525_MEMORY_ACCESS_POINTER_Y, ys); + + write_reg(par, SEPS525_DDRAM_DATA_ACCESS_PORT); +} + +static int set_var(struct fbtft_par *par) +{ + u8 val; + + switch (par->info->var.rotate) { + case 0: + val = 0; + break; + case 180: + val = MODE_RD | MODE_CD; + break; + case 90: + case 270: + + default: + return -EINVAL; + } + /* Memory Access Control */ + write_reg(par, SEPS525_DISPLAYMODE_SET, val | + (par->bgr ? MODE_SWAP_BGR : 0)); + + write_reg(par, SEPS525_DDRAM_DATA_ACCESS_PORT); + + return 0; +} + +static struct fbtft_display display = { + .regwidth = 8, + .width = WIDTH, + .height = HEIGHT, + .fbtftops = { + .init_display = init_display, + .set_addr_win = set_addr_win, + .set_var = set_var, + }, +}; + +FBTFT_REGISTER_DRIVER(DRVNAME, "syncoam,seps525", &display); + +MODULE_ALIAS("spi:" DRVNAME); +MODULE_ALIAS("platform:" DRVNAME); +MODULE_ALIAS("spi:seps525"); +MODULE_ALIAS("platform:seps525"); + +MODULE_DESCRIPTION("FB driver for the SEPS525 LCD Controller"); +MODULE_AUTHOR("Michael Hennerich "); +MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From 41e1bf811ace29bdc0df15523e3dfb3233704d1b Mon Sep 17 00:00:00 2001 From: Samuil Ivanov Date: Wed, 23 Oct 2019 23:58:55 +0300 Subject: Staging: qlge: Rewrite two while loops as simple for loops This is a task from the TODO list of qlge driver: - some "while" loops could be rewritten with simple "for" The change is in functions ql_wait_reg_rdy and ql_wait_cfg in qlge_main.c. The while loops are basically count based (they decrement on each iteration), and it makes more sense to be a for loop construction instead. Signed-off-by: Samuil Ivanov Link: https://lore.kernel.org/r/20191023205855.GA1841@samuil-ThinkCentre-M92P Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 0c381d91faa6..6f6b4c06688c 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -167,9 +167,9 @@ void ql_sem_unlock(struct ql_adapter *qdev, u32 sem_mask) int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) { u32 temp; - int count = UDELAY_COUNT; + int count; - while (count) { + for (count = 0; count < UDELAY_COUNT; count++) { temp = ql_read32(qdev, reg); /* check for errors */ @@ -181,7 +181,6 @@ int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) } else if (temp & bit) return 0; udelay(UDELAY_DELAY); - count--; } netif_alert(qdev, probe, qdev->ndev, "Timed out waiting for reg %x to come ready.\n", reg); @@ -193,17 +192,16 @@ int ql_wait_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) */ static int ql_wait_cfg(struct ql_adapter *qdev, u32 bit) { - int count = UDELAY_COUNT; + int count; u32 temp; - while (count) { + for (count = 0; count < UDELAY_COUNT; count++) { temp = ql_read32(qdev, CFG); if (temp & CFG_LE) return -EIO; if (!(temp & bit)) return 0; udelay(UDELAY_DELAY); - count--; } return -ETIMEDOUT; } -- cgit v1.2.3-59-g8ed1b From 351567d29c56ef6343f73a88e8982438481537e8 Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Sat, 26 Oct 2019 16:11:01 -0300 Subject: staging: gasket: Fix lines ending with a '(' Fix lines ending with a '('. Issue found by checkpatch. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/20191026191101.GA8973@cristiane-Inspiron-5420 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 4d086d92cddb..e3047d36d8db 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -34,8 +34,8 @@ static int gasket_set_event_fd(struct gasket_dev *gasket_dev, trace_gasket_ioctl_eventfd_data(die.interrupt, die.event_fd); - return gasket_interrupt_set_eventfd( - gasket_dev->interrupt_data, die.interrupt, die.event_fd); + return gasket_interrupt_set_eventfd(gasket_dev->interrupt_data, + die.interrupt, die.event_fd); } /* Read the size of the page table. */ -- cgit v1.2.3-59-g8ed1b From 6d7e7c31ff9d67d10ea6bd0ea3410027ce065126 Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Sat, 26 Oct 2019 19:24:53 -0300 Subject: staging: octeon: Remove unneeded variable Remove unneeded variable used to store return value. Issue found by coccicheck. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/20191026222453.GA14562@cristiane-Inspiron-5420 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index b07f5e24acbc..d53bd801f440 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -1387,9 +1387,7 @@ static inline cvmx_pko_status_t cvmx_pko_send_packet_finish(uint64_t port, uint64_t queue, union cvmx_pko_command_word0 pko_command, union cvmx_buf_ptr packet, cvmx_pko_lock_t use_locking) { - cvmx_pko_status_t ret = 0; - - return ret; + return 0; } static inline void cvmx_wqe_set_port(struct cvmx_wqe *work, int port) -- cgit v1.2.3-59-g8ed1b From 140cf83dbdc0780886ed32b792c6c88cde54dc6c Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Sat, 26 Oct 2019 20:16:19 -0300 Subject: staging: media: allegro-dvt: remove bool comparison Bool tests don't need comparisons. Issue found by coccicheck. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/20191026231619.GA14093@cristiane-Inspiron-5420 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/allegro-dvt/nal-h264.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/allegro-dvt/nal-h264.c b/drivers/staging/media/allegro-dvt/nal-h264.c index 4e14b77851e1..bd48b8883572 100644 --- a/drivers/staging/media/allegro-dvt/nal-h264.c +++ b/drivers/staging/media/allegro-dvt/nal-h264.c @@ -235,7 +235,7 @@ static inline int rbsp_write_bit(struct rbsp *rbsp, bool value) rbsp->pos++; - if (value == 1 || + if (value || (rbsp->num_consecutive_zeros < 7 && (rbsp->pos % 8 == 0))) { rbsp->num_consecutive_zeros = 0; } else { -- cgit v1.2.3-59-g8ed1b From 2a8f0e9ccb5dacd99bbe83c700bc672807fb1a58 Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Sat, 26 Oct 2019 20:52:14 -0300 Subject: staging: fieldbus: anybuss: use devm_platform_ioremap_resource helper Use devm_platform_ioremap_resource helper which wraps platform_get_resource() and devm_ioremap_resource() together. Issue found by coccicheck. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/20191026235214.GA11702@cristiane-Inspiron-5420 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/anybuss/arcx-anybus.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c b/drivers/staging/fieldbus/anybuss/arcx-anybus.c index 2ecffa42e561..5b8d0bae9ff3 100644 --- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c +++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c @@ -127,12 +127,10 @@ static const struct regmap_config arcx_regmap_cfg = { static struct regmap *create_parallel_regmap(struct platform_device *pdev, int idx) { - struct resource *res; void __iomem *base; struct device *dev = &pdev->dev; - res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1); - base = devm_ioremap_resource(dev, res); + base = devm_platform_ioremap_resource(pdev, idx + 1); if (IS_ERR(base)) return ERR_CAST(base); return devm_regmap_init_mmio(dev, base, &arcx_regmap_cfg); @@ -230,7 +228,6 @@ static int controller_probe(struct platform_device *pdev) struct regulator_config config = { }; struct regulator_dev *regulator; int err, id; - struct resource *res; struct anybuss_host *host; u8 status1, cap; @@ -244,8 +241,7 @@ static int controller_probe(struct platform_device *pdev) return PTR_ERR(cd->reset_gpiod); /* CPLD control memory, sits at index 0 */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - cd->cpld_base = devm_ioremap_resource(dev, res); + cd->cpld_base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(cd->cpld_base)) { dev_err(dev, "failed to map cpld base address\n"); -- cgit v1.2.3-59-g8ed1b From 21cc07a1c16f84da84ee7743954096a75e1974f1 Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Sat, 26 Oct 2019 17:31:26 -0300 Subject: staging: rtl8712: Remove lines before a close brace Fix Blank lines aren't necessary before a close brace '}'. Issue found by checkpatch. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/8c74dcd9afaa528a80804081f582792045bb7a7a.1572121059.git.cristianenavescardoso09@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index af12c16d6468..4e69c3dd8629 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -289,7 +289,6 @@ union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *padapter, r8712_free_recvframe(precv_frame, pfree_recv_queue); prtnframe = NULL; } - } if ((ismfrag == 0) && (fragnum != 0)) { /* the last fragment frame @@ -438,7 +437,6 @@ void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf) r8712_event_handle(padapter, (__le32 *)poffset); poffset += (cmd_len + 8);/*8 bytes alignment*/ } while (le32_to_cpu(voffset) & BIT(31)); - } static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, -- cgit v1.2.3-59-g8ed1b From 0c9f72227c76891d6cb1f2a8b70e393601fc8493 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 27 Oct 2019 14:06:01 +0100 Subject: staging: rtl8188eu: remove exit label from rtw_alloc_stainfo Remove exit label from rtw_alloc_stainfo and simply return NULL instead of goto exit. Suggested-by: Joe Perches Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191027130604.68379-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 776931b8bf72..65a824b4dfe0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -181,7 +181,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) struct sta_info, list); if (!psta) { spin_unlock_bh(&pfree_sta_queue->lock); - goto exit; + return NULL; } list_del_init(&psta->list); @@ -194,8 +194,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) if (index >= NUM_STA) { RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => %s: index >= NUM_STA", __func__)); - psta = NULL; - goto exit; + return NULL; } phash_list = &pstapriv->sta_hash[index]; @@ -246,7 +245,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) /* init for the sequence number of received management frame */ psta->RxMgmtFrameSeqNum = 0xffff; -exit: return psta; } -- cgit v1.2.3-59-g8ed1b From 6e845ddd8a554f632a561cba77d8c1811a4d86aa Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 27 Oct 2019 14:06:02 +0100 Subject: staging: rtl8188eu: reduce indentation level in _rtw_free_sta_priv Reduce indentation level in _rtw_free_sta_priv by returning early if pstapriv is NULL. Also clears a line over 80 characters checkpatch warning. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191027130604.68379-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 43 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 65a824b4dfe0..6c03068d7ed2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -135,31 +135,30 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) struct recv_reorder_ctrl *preorder_ctrl; int index; - if (pstapriv) { - /* delete all reordering_ctrl_timer */ - spin_lock_bh(&pstapriv->sta_hash_lock); - for (index = 0; index < NUM_STA; index++) { - phead = &pstapriv->sta_hash[index]; - plist = phead->next; - - while (phead != plist) { - int i; - - psta = container_of(plist, struct sta_info, - hash_list); - plist = plist->next; - - for (i = 0; i < 16; i++) { - preorder_ctrl = &psta->recvreorder_ctrl[i]; - del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); - } + if (!pstapriv) + return _SUCCESS; + + /* delete all reordering_ctrl_timer */ + spin_lock_bh(&pstapriv->sta_hash_lock); + for (index = 0; index < NUM_STA; index++) { + phead = &pstapriv->sta_hash[index]; + plist = phead->next; + + while (phead != plist) { + int i; + + psta = container_of(plist, struct sta_info, hash_list); + plist = plist->next; + + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); } } - spin_unlock_bh(&pstapriv->sta_hash_lock); - /*===============================*/ - - vfree(pstapriv->pallocated_stainfo_buf); } + spin_unlock_bh(&pstapriv->sta_hash_lock); + + vfree(pstapriv->pallocated_stainfo_buf); return _SUCCESS; } -- cgit v1.2.3-59-g8ed1b From c534472f8b4dc45d92a5f96a6ed11dbea6b4eef8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 27 Oct 2019 14:06:03 +0100 Subject: staging: rtl8188eu: remove return variable from rtw_init_bcmc_stainfo Remove variable res, that is used to store the return value, from rtw_init_bcmc_stainfo. Instead return _FAIL or _SUCCESS directly and remove the now unneeded exit label. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191027130604.68379-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 6c03068d7ed2..8b7adb9e76c2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -451,24 +451,21 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) u32 rtw_init_bcmc_stainfo(struct adapter *padapter) { struct sta_info *psta; - u32 res = _SUCCESS; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_alloc_stainfo(pstapriv, bc_addr); if (!psta) { - res = _FAIL; RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); - goto exit; + return _FAIL; } /* default broadcast & multicast use macid 1 */ psta->mac_id = 1; -exit: - return res; + return _SUCCESS; } struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) -- cgit v1.2.3-59-g8ed1b From b711acf0d1a60075ceaf67056b2693f76fb36b95 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 27 Oct 2019 14:06:04 +0100 Subject: staging: rtl8188eu: replace tabs with spaces - style Replace tabs with spaces where appropriate to cleanup whitespace. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20191027130604.68379-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 8b7adb9e76c2..73f2cb5ebaa6 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -167,7 +167,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { s32 index; struct list_head *phash_list; - struct sta_info *psta; + struct sta_info *psta; struct __queue *pfree_sta_queue; struct recv_reorder_ctrl *preorder_ctrl; int i = 0; @@ -318,7 +318,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) spin_lock_bh(&ppending_recvframe_queue->lock); - phead = get_list_head(ppending_recvframe_queue); + phead = get_list_head(ppending_recvframe_queue); plist = phead->next; while (!list_empty(phead)) { -- cgit v1.2.3-59-g8ed1b From f3a54e19d466689035276a2eb45032f396570b09 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Mon, 28 Oct 2019 04:21:11 +0000 Subject: staging: octeon-usb: Fix line ending with a '(' checkpatch.pl message: "CHECK:OPEN_ENDED_LINE: Lines should not end with a '('" Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/20191028042111.tzfhugs6f4erohir@linux-kernel-dev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index a5321cc692c5..582c9187559d 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -1836,8 +1836,7 @@ static void cvmx_usb_start_channel(struct octeon_hcd *usb, int channel, * * Returns: Pipe or NULL if none are ready */ -static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe( - struct octeon_hcd *usb, +static struct cvmx_usb_pipe *cvmx_usb_find_ready_pipe(struct octeon_hcd *usb, enum cvmx_usb_transfer xfer_type) { struct list_head *list = usb->active_pipes + xfer_type; -- cgit v1.2.3-59-g8ed1b From 62a6e25ed677c2384f4c8ea5316f561da114721d Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Mon, 28 Oct 2019 05:12:37 +0000 Subject: staging: mt7621-dma: Remove unnecessary line continuations checkpatch message: "WARNING:LINE_CONTINUATIONS: Avoid unnecessary line continuations" Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/20191028051237.3row7xnbr6pgn4bp@linux-kernel-dev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index 03c8937f80b0..94c2c708dc92 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -208,8 +208,8 @@ static void mtk_hsdma_reset_chan(struct mtk_hsdam_engine *hsdma, static void hsdma_dump_reg(struct mtk_hsdam_engine *hsdma) { - dev_dbg(hsdma->ddev.dev, "tbase %08x, tcnt %08x, " \ - "tctx %08x, tdtx: %08x, rbase %08x, " \ + dev_dbg(hsdma->ddev.dev, "tbase %08x, tcnt %08x, " + "tctx %08x, tdtx: %08x, rbase %08x, " "rcnt %08x, rctx %08x, rdtx %08x\n", mtk_hsdma_read(hsdma, HSDMA_REG_TX_BASE), mtk_hsdma_read(hsdma, HSDMA_REG_TX_CNT), @@ -220,7 +220,7 @@ static void hsdma_dump_reg(struct mtk_hsdam_engine *hsdma) mtk_hsdma_read(hsdma, HSDMA_REG_RX_CRX), mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX)); - dev_dbg(hsdma->ddev.dev, "info %08x, glo %08x, delay %08x, " \ + dev_dbg(hsdma->ddev.dev, "info %08x, glo %08x, delay %08x, " "intr_stat %08x, intr_mask %08x\n", mtk_hsdma_read(hsdma, HSDMA_REG_INFO), mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG), @@ -243,9 +243,9 @@ static void hsdma_dump_desc(struct mtk_hsdam_engine *hsdma, tx_desc = &chan->tx_ring[i]; rx_desc = &chan->rx_ring[i]; - dev_dbg(hsdma->ddev.dev, "%d tx addr0: %08x, flags %08x, " \ + dev_dbg(hsdma->ddev.dev, "%d tx addr0: %08x, flags %08x, " "tx addr1: %08x, rx addr0 %08x, flags %08x\n", - i, tx_desc->addr0, tx_desc->flags, \ + i, tx_desc->addr0, tx_desc->flags, tx_desc->addr1, rx_desc->addr0, rx_desc->flags); } } -- cgit v1.2.3-59-g8ed1b From 21c42244f21231445a25ab70ea11affde0ab5814 Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Mon, 28 Oct 2019 12:37:16 -0300 Subject: staging: rtl8712: Fix Alignment of open parenthesis Fix alignment should match open parenthesis. Issue found by checkpatch. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/2a6e8fbef7b9e72d95b7c4a7cbcce08a9e231d07.1572276208.git.cristianenavescardoso09@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 4e69c3dd8629..06de031be6a9 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -61,13 +61,13 @@ void r8712_init_recv_priv(struct recv_priv *precvpriv, precvbuf->ref_cnt = 0; precvbuf->adapter = padapter; list_add_tail(&precvbuf->list, - &(precvpriv->free_recv_buf_queue.queue)); + &(precvpriv->free_recv_buf_queue.queue)); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; tasklet_init(&precvpriv->recv_tasklet, - (void(*)(unsigned long))recv_tasklet, - (unsigned long)padapter); + (void(*)(unsigned long))recv_tasklet, + (unsigned long)padapter); skb_queue_head_init(&precvpriv->rx_skb_queue); skb_queue_head_init(&precvpriv->free_recv_skb_queue); @@ -140,7 +140,7 @@ void r8712_free_recvframe(union recv_frame *precvframe, } static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, - struct recv_stat *prxstat) + struct recv_stat *prxstat) { u16 drvinfo_sz; @@ -177,7 +177,7 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, /*perform defrag*/ static union recv_frame *recvframe_defrag(struct _adapter *adapter, - struct __queue *defrag_q) + struct __queue *defrag_q) { struct list_head *plist, *phead; u8 wlanhdr_offset; @@ -378,26 +378,26 @@ static void amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe) /* convert hdr + possible LLC headers into Ethernet header */ eth_type = (sub_skb->data[6] << 8) | sub_skb->data[7]; if (sub_skb->len >= 8 && - ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) && - eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || - !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) { + ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) && + eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || + !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) { /* remove RFC1042 or Bridge-Tunnel encapsulation and * replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, - ETH_ALEN); + ETH_ALEN); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, - ETH_ALEN); + ETH_ALEN); } else { __be16 len; /* Leave Ethernet header part of hdr and full payload */ len = htons(sub_skb->len); memcpy(skb_push(sub_skb, 2), &len, 2); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, - ETH_ALEN); + ETH_ALEN); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, - ETH_ALEN); + ETH_ALEN); } /* Indicate the packets to upper layer */ if (sub_skb) { @@ -470,7 +470,7 @@ static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, } static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, - union recv_frame *prframe) + union recv_frame *prframe) { struct list_head *phead, *plist; union recv_frame *pnextrframe; @@ -497,8 +497,8 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, } int r8712_recv_indicatepkts_in_order(struct _adapter *padapter, - struct recv_reorder_ctrl *preorder_ctrl, - int bforced) + struct recv_reorder_ctrl *preorder_ctrl, + int bforced) { struct list_head *phead, *plist; union recv_frame *prframe; @@ -528,7 +528,7 @@ int r8712_recv_indicatepkts_in_order(struct _adapter *padapter, plist = plist->next; list_del_init(&(prframe->u.hdr.list)); if (SN_EQUAL(preorder_ctrl->indicate_seq, - pattrib->seq_num)) + pattrib->seq_num)) preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) % 4096; /*indicate this recv_frame*/ @@ -553,7 +553,7 @@ int r8712_recv_indicatepkts_in_order(struct _adapter *padapter, } static int recv_indicatepkt_reorder(struct _adapter *padapter, - union recv_frame *prframe) + union recv_frame *prframe) { unsigned long irql; struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; @@ -622,7 +622,7 @@ void r8712_reordering_ctrl_timeout_handler(void *pcontext) } static int r8712_process_recv_indicatepkts(struct _adapter *padapter, - union recv_frame *prframe) + union recv_frame *prframe) { int retval = _SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -- cgit v1.2.3-59-g8ed1b From 6df6f3849bb8f317bf2d52711aacea4292237ede Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Mon, 28 Oct 2019 18:40:26 +0000 Subject: staging: wilc1000: check if device is initialzied before changing vif When killing hostapd, the interface is closed which deinitializes the device, then change virtual interface is called. This change checks if the device is initialized before sending the interface change command to the device Signed-off-by: Adham Abozaeid Link: https://lore.kernel.org/r/20191028184019.31194-1-adham.abozaeid@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 9781f712ae3e..66328ac85adc 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1413,8 +1413,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) wilc_wfi_deinit_mon_interface(wl, true); vif->iftype = WILC_STATION_MODE; - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_STATION_MODE, vif->idx); + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_STATION_MODE, vif->idx); memset(priv->assoc_stainfo.sta_associated_bss, 0, WILC_MAX_NUM_STA * ETH_ALEN); @@ -1426,8 +1428,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, priv->wdev.iftype = type; vif->monitor_flag = 0; vif->iftype = WILC_CLIENT_MODE; - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_STATION_MODE, vif->idx); + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_STATION_MODE, vif->idx); break; case NL80211_IFTYPE_AP: @@ -1444,8 +1448,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, dev->ieee80211_ptr->iftype = type; priv->wdev.iftype = type; vif->iftype = WILC_GO_MODE; - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_AP_MODE, vif->idx); + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_AP_MODE, vif->idx); break; default: -- cgit v1.2.3-59-g8ed1b From 4f83b7dd1b078ed935e1f75687b7551e55f386f3 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Mon, 28 Oct 2019 16:14:01 +0000 Subject: staging: rts5208: Fix alignment and a line ending with a '(' checkpatch messaages: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/20191028161401.sjhp6qivm6huxpxm@linux-kernel-dev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 3 ++- drivers/staging/rts5208/rtsx_transport.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index fa597953e9a0..cb95ad6fa4f9 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -873,7 +873,8 @@ static int rtsx_probe(struct pci_dev *pci, (unsigned long)(dev->addr), (unsigned long)(dev->remap_addr)); dev->rtsx_resv_buf = dmam_alloc_coherent(&pci->dev, RTSX_RESV_BUF_LEN, - &dev->rtsx_resv_buf_addr, GFP_KERNEL); + &dev->rtsx_resv_buf_addr, + GFP_KERNEL); if (!dev->rtsx_resv_buf) { dev_err(&pci->dev, "alloc dma buffer fail\n"); err = -ENXIO; diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 561851cc8780..5f1eefe80f1e 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -677,8 +677,8 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, spin_unlock_irq(&rtsx->reg_lock); /* Wait for TRANS_OK_INT */ - timeleft = wait_for_completion_interruptible_timeout( - &trans_done, msecs_to_jiffies(timeout)); + timeleft = wait_for_completion_interruptible_timeout(&trans_done, + msecs_to_jiffies(timeout)); if (timeleft <= 0) { dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n", __func__, __LINE__); -- cgit v1.2.3-59-g8ed1b From 883afa2de414604906c604c03006732c73cbda1d Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Mon, 28 Oct 2019 16:59:06 +0000 Subject: staging: emxx_udc: Fix the format of a parameter list The closing parenthesis of a multiline parameter list looks better in the same line as the last parameter. The comma that separates parameters should be at the end of the line. Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/20191028165906.tv5zxjiqwjthygnq@linux-kernel-dev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 9e0c19eb867c..e899130aedce 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -1072,9 +1072,8 @@ static int _nbu2ss_epn_in_pio(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, if (i_word_length > 0) { for (i = 0; i < i_word_length; i++) { _nbu2ss_writel( - &preg->EP_REGS[ep->epnum - 1].EP_WRITE - , p_buf_32->dw - ); + &preg->EP_REGS[ep->epnum - 1].EP_WRITE, + p_buf_32->dw); p_buf_32++; } -- cgit v1.2.3-59-g8ed1b From 9535e71e7b80f6bd7e13f7206ef60203dc496b4c Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Mon, 28 Oct 2019 13:24:03 -0700 Subject: staging: kpc2000: kpc_i2c: Fix lines over 80 chars Fix lines over 80 characters warnings. issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/8273ad9efccfb2c37ff1e9a25d5ccb26780567aa.1572293975.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 201 +++++++++++++++++++++++----------- 1 file changed, 137 insertions(+), 64 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index bc02534d8dc3..0412dab68670 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -99,7 +99,8 @@ struct i2c_device { #define SMBHSTSTS_INTR 0x02 #define SMBHSTSTS_HOST_BUSY 0x01 -#define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_FAILED | SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | SMBHSTSTS_INTR) +#define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_FAILED | \ + SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | SMBHSTSTS_INTR) /* Older devices have their ID defined in */ #define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS 0x1c22 @@ -136,7 +137,8 @@ static int i801_check_pre(struct i2c_device *priv) status = inb_p(SMBHSTSTS(priv)); if (status & SMBHSTSTS_HOST_BUSY) { - dev_err(&priv->adapter.dev, "SMBus is busy, can't use it! (status=%x)\n", status); + dev_err(&priv->adapter.dev, + "SMBus is busy, can't use it! (status=%x)\n", status); return -EBUSY; } @@ -146,7 +148,8 @@ static int i801_check_pre(struct i2c_device *priv) outb_p(status, SMBHSTSTS(priv)); status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; if (status) { - dev_err(&priv->adapter.dev, "Failed clearing status flags (%02x)\n", status); + dev_err(&priv->adapter.dev, + "Failed clearing status flags (%02x)\n", status); return -EBUSY; } } @@ -162,15 +165,20 @@ static int i801_check_post(struct i2c_device *priv, int status, int timeout) if (timeout) { dev_err(&priv->adapter.dev, "Transaction timeout\n"); /* try to stop the current command */ - dev_dbg(&priv->adapter.dev, "Terminating the current operation\n"); - outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, SMBHSTCNT(priv)); + dev_dbg(&priv->adapter.dev, + "Terminating the current operation\n"); + outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, + SMBHSTCNT(priv)); usleep_range(1000, 2000); - outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), SMBHSTCNT(priv)); + outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), + SMBHSTCNT(priv)); /* Check if it worked */ status = inb_p(SMBHSTSTS(priv)); - if ((status & SMBHSTSTS_HOST_BUSY) || !(status & SMBHSTSTS_FAILED)) - dev_err(&priv->adapter.dev, "Failed terminating the transaction\n"); + if ((status & SMBHSTSTS_HOST_BUSY) || + !(status & SMBHSTSTS_FAILED)) + dev_err(&priv->adapter.dev, + "Failed terminating the transaction\n"); outb_p(STATUS_FLAGS, SMBHSTSTS(priv)); return -ETIMEDOUT; } @@ -244,7 +252,9 @@ static void i801_wait_hwpec(struct i2c_device *priv) outb_p(status, SMBHSTSTS(priv)); } -static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_smbus_data *data, char read_write, int hwpec) +static int i801_block_transaction_by_block(struct i2c_device *priv, + union i2c_smbus_data *data, + char read_write, int hwpec) { int i, len; int status; @@ -259,7 +269,8 @@ static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_sm outb_p(data->block[i + 1], SMBBLKDAT(priv)); } - status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec); + status = i801_transaction(priv, + I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec); if (status) return status; @@ -275,7 +286,10 @@ static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_sm return 0; } -static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2c_smbus_data *data, char read_write, int command, int hwpec) +static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, + union i2c_smbus_data *data, + char read_write, int command, + int hwpec) { int i, len; int smbcmd; @@ -301,7 +315,8 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 else smbcmd = I801_BLOCK_LAST; } else { - if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_READ) + if (command == I2C_SMBUS_I2C_BLOCK_DATA && + read_write == I2C_SMBUS_READ) smbcmd = I801_I2C_BLOCK_DATA; else smbcmd = I801_BLOCK_DATA; @@ -309,25 +324,33 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv)); if (i == 1) - outb_p(inb(SMBHSTCNT(priv)) | I801_START, SMBHSTCNT(priv)); + outb_p(inb(SMBHSTCNT(priv)) | I801_START, + SMBHSTCNT(priv)); /* We will always wait for a fraction of a second! */ timeout = 0; do { usleep_range(250, 500); status = inb_p(SMBHSTSTS(priv)); - } while ((!(status & SMBHSTSTS_BYTE_DONE)) && (timeout++ < MAX_RETRIES)); + } while (!(status & SMBHSTSTS_BYTE_DONE) && + (timeout++ < MAX_RETRIES)); result = i801_check_post(priv, status, timeout > MAX_RETRIES); if (result < 0) return result; - if (i == 1 && read_write == I2C_SMBUS_READ && command != I2C_SMBUS_I2C_BLOCK_DATA) { + if (i == 1 && read_write == I2C_SMBUS_READ && + command != I2C_SMBUS_I2C_BLOCK_DATA) { len = inb_p(SMBHSTDAT0(priv)); if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { - dev_err(&priv->adapter.dev, "Illegal SMBus block read size %d\n", len); + dev_err(&priv->adapter.dev, + "Illegal SMBus block read size %d\n", + len); /* Recover */ - while (inb_p(SMBHSTSTS(priv)) & SMBHSTSTS_HOST_BUSY) - outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); - outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); + while (inb_p(SMBHSTSTS(priv)) & + SMBHSTSTS_HOST_BUSY) + outb_p(SMBHSTSTS_BYTE_DONE, + SMBHSTSTS(priv)); + outb_p(SMBHSTSTS_INTR, + SMBHSTSTS(priv)); return -EPROTO; } data->block[0] = len; @@ -354,7 +377,9 @@ static int i801_set_block_buffer_mode(struct i2c_device *priv) } /* Block transaction function */ -static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data *data, char read_write, int command, int hwpec) +static int i801_block_transaction(struct i2c_device *priv, + union i2c_smbus_data *data, char read_write, + int command, int hwpec) { int result = 0; //unsigned char hostc; @@ -366,12 +391,14 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data //pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); //pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc | SMBHSTCFG_I2C_EN); } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { - dev_err(&priv->adapter.dev, "I2C block read is unsupported!\n"); + dev_err(&priv->adapter.dev, + "I2C block read is unsupported!\n"); return -EOPNOTSUPP; } } - if (read_write == I2C_SMBUS_WRITE || command == I2C_SMBUS_I2C_BLOCK_DATA) { + if (read_write == I2C_SMBUS_WRITE || + command == I2C_SMBUS_I2C_BLOCK_DATA) { if (data->block[0] < 1) data->block[0] = 1; if (data->block[0] > I2C_SMBUS_BLOCK_MAX) @@ -384,13 +411,21 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data * SMBus (not I2C) block transactions, even though the datasheet * doesn't mention this limitation. */ - if ((priv->features & FEATURE_BLOCK_BUFFER) && command != I2C_SMBUS_I2C_BLOCK_DATA && i801_set_block_buffer_mode(priv) == 0) - result = i801_block_transaction_by_block(priv, data, read_write, hwpec); - else - result = i801_block_transaction_byte_by_byte(priv, data, read_write, command, hwpec); + if ((priv->features & FEATURE_BLOCK_BUFFER) && + command != I2C_SMBUS_I2C_BLOCK_DATA && + i801_set_block_buffer_mode(priv) == 0) { + result = i801_block_transaction_by_block(priv, data, + read_write, hwpec); + } else { + result = i801_block_transaction_byte_by_byte(priv, data, + read_write, + command, hwpec); + } + if (result == 0 && hwpec) i801_wait_hwpec(priv); - if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_WRITE) { + if (command == I2C_SMBUS_I2C_BLOCK_DATA && + read_write == I2C_SMBUS_WRITE) { /* restore saved configuration register value */ //TODO: Figure out the right thing to do here... //pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); @@ -399,32 +434,41 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data } /* Return negative errno on error. */ -static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) +static s32 i801_access(struct i2c_adapter *adap, u16 addr, + unsigned short flags, char read_write, u8 command, + int size, union i2c_smbus_data *data) { int hwpec; int block = 0; int ret, xact = 0; struct i2c_device *priv = i2c_get_adapdata(adap); - hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; + hwpec = (priv->features & FEATURE_SMBUS_PEC) && + (flags & I2C_CLIENT_PEC) && + size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; switch (size) { case I2C_SMBUS_QUICK: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_QUICK\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD(priv)); + xact = I801_QUICK; break; case I2C_SMBUS_BYTE: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD(priv)); if (read_write == I2C_SMBUS_WRITE) outb_p(command, SMBHSTCMD(priv)); xact = I801_BYTE; break; case I2C_SMBUS_BYTE_DATA: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE_DATA\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD(priv)); + outb_p(command, SMBHSTCMD(priv)); if (read_write == I2C_SMBUS_WRITE) outb_p(data->byte, SMBHSTDAT0(priv)); @@ -432,7 +476,9 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, break; case I2C_SMBUS_WORD_DATA: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_WORD_DATA\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD(priv)); + outb_p(command, SMBHSTCMD(priv)); if (read_write == I2C_SMBUS_WRITE) { outb_p(data->word & 0xff, SMBHSTDAT0(priv)); @@ -442,7 +488,9 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, break; case I2C_SMBUS_BLOCK_DATA: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BLOCK_DATA\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), + SMBHSTADD(priv)); + outb_p(command, SMBHSTCMD(priv)); block = 1; break; @@ -463,7 +511,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, block = 1; break; default: - dev_dbg(&priv->adapter.dev, " [acc] Unsupported transaction %d\n", size); + dev_dbg(&priv->adapter.dev, + " [acc] Unsupported transaction %d\n", size); return -EOPNOTSUPP; } @@ -472,13 +521,15 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv)); } else { dev_dbg(&priv->adapter.dev, " [acc] hwpec: no\n"); - outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC), SMBAUXCTL(priv)); + outb_p(inb_p(SMBAUXCTL(priv)) & + (~SMBAUXCTL_CRC), SMBAUXCTL(priv)); } if (block) { //ret = 0; dev_dbg(&priv->adapter.dev, " [acc] block: yes\n"); - ret = i801_block_transaction(priv, data, read_write, size, hwpec); + ret = i801_block_transaction(priv, data, read_write, size, + hwpec); } else { dev_dbg(&priv->adapter.dev, " [acc] block: no\n"); ret = i801_transaction(priv, xact | ENABLE_INT9); @@ -490,7 +541,8 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, */ if (hwpec || block) { dev_dbg(&priv->adapter.dev, " [acc] hwpec || block\n"); - outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); + outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | + SMBAUXCTL_E32B), SMBAUXCTL(priv)); } if (block) { dev_dbg(&priv->adapter.dev, " [acc] block\n"); @@ -501,19 +553,22 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, return ret; } if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) { - dev_dbg(&priv->adapter.dev, " [acc] I2C_SMBUS_WRITE || I801_QUICK -> ret 0\n"); + dev_dbg(&priv->adapter.dev, + " [acc] I2C_SMBUS_WRITE || I801_QUICK -> ret 0\n"); return 0; } switch (xact & 0x7f) { case I801_BYTE: /* Result put in SMBHSTDAT0 */ case I801_BYTE_DATA: - dev_dbg(&priv->adapter.dev, " [acc] I801_BYTE or I801_BYTE_DATA\n"); + dev_dbg(&priv->adapter.dev, + " [acc] I801_BYTE or I801_BYTE_DATA\n"); data->byte = inb_p(SMBHSTDAT0(priv)); break; case I801_WORD_DATA: dev_dbg(&priv->adapter.dev, " [acc] I801_WORD_DATA\n"); - data->word = inb_p(SMBHSTDAT0(priv)) + (inb_p(SMBHSTDAT1(priv)) << 8); + data->word = inb_p(SMBHSTDAT0(priv)) + + (inb_p(SMBHSTDAT1(priv)) << 8); break; } return 0; @@ -535,30 +590,47 @@ static u32 i801_func(struct i2c_adapter *adapter) // http://lxr.free-electrons.com/source/include/uapi/linux/i2c.h#L85 u32 f = - I2C_FUNC_I2C | /* 0x00000001 (I enabled this one) */ - !I2C_FUNC_10BIT_ADDR | /* 0x00000002 */ - !I2C_FUNC_PROTOCOL_MANGLING | /* 0x00000004 */ - ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | /* 0x00000008 */ - !I2C_FUNC_SMBUS_BLOCK_PROC_CALL | /* 0x00008000 */ - I2C_FUNC_SMBUS_QUICK | /* 0x00010000 */ - !I2C_FUNC_SMBUS_READ_BYTE | /* 0x00020000 */ - !I2C_FUNC_SMBUS_WRITE_BYTE | /* 0x00040000 */ - !I2C_FUNC_SMBUS_READ_BYTE_DATA | /* 0x00080000 */ - !I2C_FUNC_SMBUS_WRITE_BYTE_DATA | /* 0x00100000 */ - !I2C_FUNC_SMBUS_READ_WORD_DATA | /* 0x00200000 */ - !I2C_FUNC_SMBUS_WRITE_WORD_DATA | /* 0x00400000 */ - !I2C_FUNC_SMBUS_PROC_CALL | /* 0x00800000 */ - !I2C_FUNC_SMBUS_READ_BLOCK_DATA | /* 0x01000000 */ - !I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | /* 0x02000000 */ - ((priv->features & FEATURE_I2C_BLOCK_READ) ? I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0) | /* 0x04000000 */ - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | /* 0x08000000 */ + I2C_FUNC_I2C | /* 0x00000001(I enabled this + * one) + */ + !I2C_FUNC_10BIT_ADDR | /* 0x00000002 */ + !I2C_FUNC_PROTOCOL_MANGLING | /* 0x00000004 */ + ((priv->features & FEATURE_SMBUS_PEC) ? + I2C_FUNC_SMBUS_PEC : 0) | /* 0x00000008 */ + !I2C_FUNC_SMBUS_BLOCK_PROC_CALL | /* 0x00008000 */ + I2C_FUNC_SMBUS_QUICK | /* 0x00010000 */ + !I2C_FUNC_SMBUS_READ_BYTE | /* 0x00020000 */ + !I2C_FUNC_SMBUS_WRITE_BYTE | /* 0x00040000 */ + !I2C_FUNC_SMBUS_READ_BYTE_DATA | /* 0x00080000 */ + !I2C_FUNC_SMBUS_WRITE_BYTE_DATA | /* 0x00100000 */ + !I2C_FUNC_SMBUS_READ_WORD_DATA | /* 0x00200000 */ + !I2C_FUNC_SMBUS_WRITE_WORD_DATA | /* 0x00400000 */ + !I2C_FUNC_SMBUS_PROC_CALL | /* 0x00800000 */ + !I2C_FUNC_SMBUS_READ_BLOCK_DATA | /* 0x01000000 */ + !I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | /* 0x02000000 */ + ((priv->features & FEATURE_I2C_BLOCK_READ) ? + I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0) | /* 0x04000000 */ + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | /* 0x08000000 */ I2C_FUNC_SMBUS_BYTE | /* _READ_BYTE _WRITE_BYTE */ - I2C_FUNC_SMBUS_BYTE_DATA | /* _READ_BYTE_DATA _WRITE_BYTE_DATA */ - I2C_FUNC_SMBUS_WORD_DATA | /* _READ_WORD_DATA _WRITE_WORD_DATA */ - I2C_FUNC_SMBUS_BLOCK_DATA | /* _READ_BLOCK_DATA _WRITE_BLOCK_DATA */ - !I2C_FUNC_SMBUS_I2C_BLOCK | /* _READ_I2C_BLOCK _WRITE_I2C_BLOCK */ - !I2C_FUNC_SMBUS_EMUL; /* _QUICK _BYTE _BYTE_DATA _WORD_DATA _PROC_CALL _WRITE_BLOCK_DATA _I2C_BLOCK _PEC */ + I2C_FUNC_SMBUS_BYTE_DATA | /* _READ_BYTE_DATA + * _WRITE_BYTE_DATA + */ + I2C_FUNC_SMBUS_WORD_DATA | /* _READ_WORD_DATA + * _WRITE_WORD_DATA + */ + I2C_FUNC_SMBUS_BLOCK_DATA | /* _READ_BLOCK_DATA + * _WRITE_BLOCK_DATA + */ + !I2C_FUNC_SMBUS_I2C_BLOCK | /* _READ_I2C_BLOCK + * _WRITE_I2C_BLOCK + */ + !I2C_FUNC_SMBUS_EMUL; /* _QUICK _BYTE + * _BYTE_DATA _WORD_DATA + * _PROC_CALL + * _WRITE_BLOCK_DATA + * _I2C_BLOCK _PEC + */ return f; } @@ -611,7 +683,8 @@ static int pi2c_probe(struct platform_device *pldev) priv->adapter.retries = 3; //snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter at %04lx", priv->smba); - snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter"); + snprintf(priv->adapter.name, sizeof(priv->adapter.name), + "Fake SMBus I801 adapter"); err = i2c_add_adapter(&priv->adapter); if (err) { -- cgit v1.2.3-59-g8ed1b From 09ef6fde7d89d08f390e6cf53cf40f9623d61616 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Mon, 28 Oct 2019 13:24:04 -0700 Subject: staging: kpc2000: kpc_i2c: Remove commented code Remove some commented out code. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/c101a2ff94b3d5dcd467407bfa083679f3bbc612.1572293975.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 0412dab68670..5460bf973c9c 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -144,7 +144,6 @@ static int i801_check_pre(struct i2c_device *priv) status &= STATUS_FLAGS; if (status) { - //dev_dbg(&priv->adapter.dev, "Clearing status flags (%02x)\n", status); outb_p(status, SMBHSTSTS(priv)); status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; if (status) { @@ -526,7 +525,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, } if (block) { - //ret = 0; dev_dbg(&priv->adapter.dev, " [acc] block: yes\n"); ret = i801_block_transaction(priv, data, read_write, size, hwpec); @@ -682,7 +680,6 @@ static int pi2c_probe(struct platform_device *pldev) /* Retry up to 3 times on lost arbitration */ priv->adapter.retries = 3; - //snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter at %04lx", priv->smba); snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter"); -- cgit v1.2.3-59-g8ed1b From 67e7bd248473ede722563ae1a8d24e856a42f644 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 29 Oct 2019 22:04:19 -0500 Subject: staging: emxx_udc: Fix invalid reference error This patch fixes an invalid reference error by moving the code that is executed when a queue element is found, into the loop. Also, it removes an unnecessary test that now checks if the element is not present in the queue. Issue found by Coccinelle. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/20191030030419.mmnrzm7hr4encfai@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index e899130aedce..03929b9d3a8b 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2660,20 +2660,18 @@ static int nbu2ss_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) /* make sure it's actually queued on this endpoint */ list_for_each_entry(req, &ep->queue, queue) { - if (&req->req == _req) - break; - } - if (&req->req != _req) { - spin_unlock_irqrestore(&udc->lock, flags); - pr_debug("%s no queue(EINVAL)\n", __func__); - return -EINVAL; + if (&req->req == _req) { + _nbu2ss_ep_done(ep, req, -ECONNRESET); + spin_unlock_irqrestore(&udc->lock, flags); + return 0; + } } - _nbu2ss_ep_done(ep, req, -ECONNRESET); - spin_unlock_irqrestore(&udc->lock, flags); - return 0; + pr_debug("%s no queue(EINVAL)\n", __func__); + + return -EINVAL; } /*-------------------------------------------------------------------------*/ -- cgit v1.2.3-59-g8ed1b From 94d70f66c2945301fdb045851711cd94fbe4c3c5 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Tue, 29 Oct 2019 20:22:06 -0300 Subject: staging: sm750fb: Fix typo in comment Fixing typo in word 'and'. Signed-off-by: Gabriela Bittencourt Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20191029232207.4113-2-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 645813a87490..5925d7c7d464 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -224,7 +224,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel, /* * Note: - * DE_FOREGROUND are DE_BACKGROUND are don't care. + * DE_FOREGROUND and DE_BACKGROUND are don't care. * DE_COLOR_COMPARE and DE_COLOR_COMPARE_MAKS * are set by set deSetTransparency(). */ -- cgit v1.2.3-59-g8ed1b From 600bf7aecebdd3756bdb4f48f5a44b86c6593053 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Tue, 29 Oct 2019 20:22:07 -0300 Subject: staging: sm750fb: Replace multiple spaces with tabs when it suits Replace multiple spaces before some comments with one tab. Aligning the comment with the function below it. Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191029232207.4113-3-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 5925d7c7d464..8faa601c700b 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -243,21 +243,21 @@ int sm750_hw_copyarea(struct lynx_accel *accel, */ write_dpr(accel, DE_WINDOW_DESTINATION_BASE, dBase); /* dpr44 */ - /* - * Program pitch (distance between the 1st points of two adjacent lines). - * Note that input pitch is BYTE value, but the 2D Pitch register uses - * pixel values. Need Byte to pixel conversion. - */ + /* + * Program pitch (distance between the 1st points of two adjacent lines). + * Note that input pitch is BYTE value, but the 2D Pitch register uses + * pixel values. Need Byte to pixel conversion. + */ write_dpr(accel, DE_PITCH, ((dPitch / Bpp << DE_PITCH_DESTINATION_SHIFT) & DE_PITCH_DESTINATION_MASK) | (sPitch / Bpp & DE_PITCH_SOURCE_MASK)); /* dpr10 */ - /* - * Screen Window width in Pixels. - * 2D engine uses this value to calculate the linear address in frame buffer - * for a given point. - */ + /* + * Screen Window width in Pixels. + * 2D engine uses this value to calculate the linear address in frame buffer + * for a given point. + */ write_dpr(accel, DE_WINDOW_WIDTH, ((dPitch / Bpp << DE_WINDOW_WIDTH_DST_SHIFT) & DE_WINDOW_WIDTH_DST_MASK) | -- cgit v1.2.3-59-g8ed1b From 6e0afa355a72eef49d3ade9531672e8a65fc9e9c Mon Sep 17 00:00:00 2001 From: Cristiane Naves Date: Tue, 29 Oct 2019 18:09:17 -0300 Subject: staging: vt6655: Fix lines ending with parentheses Fix lines ending with parentheses. Issue found by checkpatch. Signed-off-by: Cristiane Naves Link: https://lore.kernel.org/r/20191029210917.GA14956@cristiane-Inspiron-5420 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index eba4ee0750dc..e65c9825ea5a 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -79,14 +79,10 @@ static void s_vCalculateOFDMRParameter(unsigned char byRate, u8 bb_type, * * Return Value: none */ -static -void -s_vCalculateOFDMRParameter( - unsigned char byRate, - u8 bb_type, - unsigned char *pbyTxRate, - unsigned char *pbyRsvTime -) +static void s_vCalculateOFDMRParameter(unsigned char byRate, + u8 bb_type, + unsigned char *pbyTxRate, + unsigned char *pbyRsvTime) { switch (byRate) { case RATE_6M: @@ -736,8 +732,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_24, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_36 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( - (void *)priv, + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_36M), bb_type, &byTxRate, @@ -745,8 +740,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_36, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_48 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( - (void *)priv, + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_48M), bb_type, &byTxRate, @@ -754,8 +748,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_48, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_54 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( - (void *)priv, + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_54M), bb_type, &byTxRate, @@ -763,8 +756,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type) VNSvOutPortW(priv->PortOffset + MAC_REG_RSPINF_A_54, MAKEWORD(byTxRate, byRsvTime)); /* RSPINF_a_72 */ - s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate( - (void *)priv, + s_vCalculateOFDMRParameter(CARDwGetOFDMControlRate((void *)priv, RATE_54M), bb_type, &byTxRate, -- cgit v1.2.3-59-g8ed1b From 25ec44ebdc1ab930965b266b2717a2e56249d7bb Mon Sep 17 00:00:00 2001 From: Chandra Annamaneni Date: Tue, 29 Oct 2019 02:16:35 -0700 Subject: staging: KPC2000: kpc2000_spi.c: Fix style issues (missing blank line) Resolved: "CHECK: Please use a blank line after.." from checkpatch.pl Signed-off-by: Chandra Annamaneni Link: https://lore.kernel.org/r/20191029091638.16101-1-chandra627@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 6ba94b0131da..5712a88c8788 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -50,6 +50,7 @@ static struct flash_platform_data p2kr0_spi0_pdata = { .nr_parts = ARRAY_SIZE(p2kr0_spi0_parts), .parts = p2kr0_spi0_parts, }; + static struct flash_platform_data p2kr0_spi1_pdata = { .name = "SPI1", .nr_parts = ARRAY_SIZE(p2kr0_spi1_parts), -- cgit v1.2.3-59-g8ed1b From c4d362420d75aff10596f876e3e66458bfdb84b5 Mon Sep 17 00:00:00 2001 From: Chandra Annamaneni Date: Tue, 29 Oct 2019 02:16:36 -0700 Subject: staging: KPC2000: kpc2000_spi.c: Fix style issues (misaligned brace) Resolved: ERROR: else should follow close brace '}' Signed-off-by: Chandra Annamaneni Link: https://lore.kernel.org/r/20191029091638.16101-2-chandra627@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 5712a88c8788..929136cdc3e1 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -226,8 +226,7 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val); processed++; } - } - else if (rx) { + } else if (rx) { for (i = 0 ; i < c ; i++) { char test = 0; -- cgit v1.2.3-59-g8ed1b From e5f26f8548f943e7c70e6136d0ecd942a912a70e Mon Sep 17 00:00:00 2001 From: Chandra Annamaneni Date: Tue, 29 Oct 2019 02:16:37 -0700 Subject: staging: KPC2000: kpc2000_spi.c: Fix style issues (alignment) Resolved: "CHECK: Alignment should match open parenthesis" from checkpatch Signed-off-by: Chandra Annamaneni Link: https://lore.kernel.org/r/20191029091638.16101-3-chandra627@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 929136cdc3e1..24de8d63f504 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -313,19 +313,19 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) if (transfer->speed_hz > KP_SPI_CLK || (len && !(rx_buf || tx_buf))) { dev_dbg(kpspi->dev, " transfer: %d Hz, %d %s%s, %d bpw\n", - transfer->speed_hz, - len, - tx_buf ? "tx" : "", - rx_buf ? "rx" : "", - transfer->bits_per_word); + transfer->speed_hz, + len, + tx_buf ? "tx" : "", + rx_buf ? "rx" : "", + transfer->bits_per_word); dev_dbg(kpspi->dev, " transfer -EINVAL\n"); return -EINVAL; } if (transfer->speed_hz && transfer->speed_hz < (KP_SPI_CLK >> 15)) { dev_dbg(kpspi->dev, "speed_hz %d below minimum %d Hz\n", - transfer->speed_hz, - KP_SPI_CLK >> 15); + transfer->speed_hz, + KP_SPI_CLK >> 15); dev_dbg(kpspi->dev, " speed_hz -EINVAL\n"); return -EINVAL; } -- cgit v1.2.3-59-g8ed1b From be1f84cf772b1598a4ed15b41e78d2967b97fbf5 Mon Sep 17 00:00:00 2001 From: Chandra Annamaneni Date: Tue, 29 Oct 2019 02:16:38 -0700 Subject: staging: KPC2000: kpc2000_spi.c: Fix style issues (Unnecessary parenthesis) Resolved: CHECK: Unnecessary parentheses around table[i] Signed-off-by: Chandra Annamaneni Link: https://lore.kernel.org/r/20191029091638.16101-4-chandra627@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 24de8d63f504..8becf972af9c 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -476,7 +476,7 @@ kp_spi_probe(struct platform_device *pldev) /* register the slave boards */ #define NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(table) \ for (i = 0 ; i < ARRAY_SIZE(table) ; i++) { \ - spi_new_device(master, &(table[i])); \ + spi_new_device(master, &table[i]); \ } switch ((drvdata->card_id & 0xFFFF0000) >> 16) { -- cgit v1.2.3-59-g8ed1b From 6853f94ad75135519e52eeda8d1fe54de48d609c Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 30 Oct 2019 02:03:23 +0100 Subject: staging: exfat: remove unnecessary parentheses Fix checkpatch.pl warning: CHECK: Unnecessary parentheses around ... Signed-off-by: Roi Martin Link: https://lore.kernel.org/r/20191030010328.10203-2-jroi.martin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 24 ++++++++++---------- drivers/staging/exfat/exfat_super.c | 44 ++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 34 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 80fd3f0d6db4..851cd366a108 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -550,7 +550,7 @@ s32 load_alloc_bitmap(struct super_block *sb) for (j = 0; j < p_fs->map_sectors; j++) { p_fs->vol_amap[j] = NULL; - ret = sector_read(sb, sector + j, &(p_fs->vol_amap[j]), 1); + ret = sector_read(sb, sector + j, &p_fs->vol_amap[j], 1); if (ret != FFS_SUCCESS) { /* release all buffers and free vol_amap */ i = 0; @@ -910,10 +910,10 @@ u32 fat_get_entry_type(struct dentry_t *p_entry) { struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - if (*(ep->name) == 0x0) + if (*ep->name == 0x0) return TYPE_UNUSED; - else if (*(ep->name) == 0xE5) + else if (*ep->name == 0xE5) return TYPE_DELETED; else if (ep->attr == ATTR_EXTEND) @@ -978,10 +978,10 @@ void fat_set_entry_type(struct dentry_t *p_entry, u32 type) struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; if (type == TYPE_UNUSED) - *(ep->name) = 0x0; + *ep->name = 0x0; else if (type == TYPE_DELETED) - *(ep->name) = 0xE5; + *ep->name = 0xE5; else if (type == TYPE_EXTEND) ep->attr = ATTR_EXTEND; @@ -1562,7 +1562,7 @@ void update_dir_checksum_with_entry_set(struct super_block *sb, u16 chksum = 0; s32 chksum_type = CS_DIR_ENTRY, i; - ep = (struct dentry_t *)&(es->__buf); + ep = (struct dentry_t *)&es->__buf; for (i = 0; i < es->num_entries; i++) { pr_debug("%s ep %p\n", __func__, ep); chksum = calc_checksum_2byte((void *)ep, DENTRY_SIZE, chksum, @@ -1571,7 +1571,7 @@ void update_dir_checksum_with_entry_set(struct super_block *sb, chksum_type = CS_DEFAULT; } - ep = (struct dentry_t *)&(es->__buf); + ep = (struct dentry_t *)&es->__buf; SET16_A(((struct file_dentry_t *)ep)->checksum, chksum); write_whole_entry_set(sb, es); } @@ -1832,7 +1832,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, } if (file_ep) - *file_ep = (struct dentry_t *)&(es->__buf); + *file_ep = (struct dentry_t *)&es->__buf; pr_debug("%s exiting es %p sec %llu offset %d flags %d, num_entries %u buf ptr %p\n", __func__, es, (unsigned long long)es->sector, es->offset, @@ -1859,7 +1859,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); u32 clu; - u8 *buf, *esbuf = (u8 *)&(es->__buf); + u8 *buf, *esbuf = (u8 *)&es->__buf; pr_debug("%s entered es %p sec %llu off %d count %d\n", __func__, es, (unsigned long long)sec, off, count); @@ -1929,7 +1929,7 @@ s32 write_partial_entries_in_entry_set(struct super_block *sb, struct chain_t dir; /* vaidity check */ - if (ep + count > ((struct dentry_t *)&(es->__buf)) + es->num_entries) + if (ep + count > ((struct dentry_t *)&es->__buf) + es->num_entries) return FFS_ERROR; dir.dir = GET_CLUSTER_FROM_SECTOR(es->sector); @@ -1938,7 +1938,7 @@ s32 write_partial_entries_in_entry_set(struct super_block *sb, byte_offset = (es->sector - START_SECTOR(dir.dir)) << p_bd->sector_size_bits; - byte_offset += ((void **)ep - &(es->__buf)) + es->offset; + byte_offset += ((void **)ep - &es->__buf) + es->offset; ret = _walk_fat_chain(sb, &dir, byte_offset, &clu); if (ret != FFS_SUCCESS) @@ -2122,7 +2122,7 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries p_fs->fs_func->set_entry_flag(ep, p_dir->flags); buf_modify(sb, sector); - update_dir_checksum(sb, &(fid->dir), + update_dir_checksum(sb, &fid->dir, fid->entry); } } diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index dcf90b5f147b..007885d140be 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -1003,13 +1003,13 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, /* (3) update the direcoty entry */ if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry, + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) goto err_out; ep2 = ep + 1; } else { - ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or); + ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) goto err_out; ep2 = ep; @@ -1142,7 +1142,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) } ep2 = ep + 1; } else { - ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or); + ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { ret = FFS_MEDIAERR; goto out; @@ -1277,7 +1277,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, update_parent_info(new_fid, new_parent_inode); - p_dir = &(new_fid->dir); + p_dir = &new_fid->dir; new_entry = new_fid->entry; ep = get_entry_in_dir(sb, p_dir, new_entry, NULL); if (!ep) @@ -1438,14 +1438,14 @@ static int ffsSetAttr(struct inode *inode, u32 attr) /* get the directory entry of given file */ if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry, + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) { ret = FFS_MEDIAERR; goto out; } } else { - ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or); + ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { ret = FFS_MEDIAERR; goto out; @@ -1554,7 +1554,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) /* get the directory entry of given file or directory */ if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry, + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_2_ENTRIES, &ep); if (!es) { ret = FFS_MEDIAERR; @@ -1562,7 +1562,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) } ep2 = ep + 1; } else { - ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or); + ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { ret = FFS_MEDIAERR; goto out; @@ -1594,11 +1594,11 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) memset((char *)&info->AccessTimestamp, 0, sizeof(struct date_time_t)); - *(uni_name.name) = 0x0; + *uni_name.name = 0x0; /* XXX this is very bad for exfat cuz name is already included in es. * API should be revised */ - p_fs->fs_func->get_uni_name_from_ext_entry(sb, &(fid->dir), fid->entry, + p_fs->fs_func->get_uni_name_from_ext_entry(sb, &fid->dir, fid->entry, uni_name.name); if (*uni_name.name == 0x0 && p_fs->vol_type != EXFAT) get_uni_name_from_dos_entry(sb, (struct dos_dentry_t *)ep, @@ -1678,7 +1678,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) /* get the directory entry of given file or directory */ if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &(fid->dir), fid->entry, + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) { ret = FFS_MEDIAERR; @@ -1687,7 +1687,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) ep2 = ep + 1; } else { /* for other than exfat */ - ep = get_entry_in_dir(sb, &(fid->dir), fid->entry, §or); + ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { ret = FFS_MEDIAERR; goto out; @@ -1845,7 +1845,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) /* (3) update directory entry */ if (modified) { if (p_fs->vol_type != EXFAT) { - ep = get_entry_in_dir(sb, &(fid->dir), + ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { ret = FFS_MEDIAERR; @@ -2058,7 +2058,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) memset((char *)&dir_entry->AccessTimestamp, 0, sizeof(struct date_time_t)); - *(uni_name.name) = 0x0; + *uni_name.name = 0x0; fs_func->get_uni_name_from_ext_entry(sb, &dir, dentry, uni_name.name); if (*uni_name.name == 0x0 && p_fs->vol_type != EXFAT) @@ -2116,7 +2116,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) } } - *(dir_entry->Name) = '\0'; + *dir_entry->Name = '\0'; fid->rwoffset = (s64)(++dentry); @@ -2202,7 +2202,7 @@ static int exfat_readdir(struct file *filp, struct dir_context *ctx) struct inode *inode = file_inode(filp); struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct fs_info_t *p_fs = &(sbi->fs_info); + struct fs_info_t *p_fs = &sbi->fs_info; struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); struct dir_entry_t de; unsigned long inum; @@ -2293,7 +2293,7 @@ static int exfat_ioctl_volume_id(struct inode *dir) { struct super_block *sb = dir->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct fs_info_t *p_fs = &(sbi->fs_info); + struct fs_info_t *p_fs = &sbi->fs_info; return p_fs->vol_id; } @@ -2895,7 +2895,7 @@ static void exfat_truncate(struct inode *inode, loff_t old_size) { struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct fs_info_t *p_fs = &(sbi->fs_info); + struct fs_info_t *p_fs = &sbi->fs_info; int err; __lock_super(sb); @@ -3073,8 +3073,8 @@ static int exfat_bmap(struct inode *inode, sector_t sector, sector_t *phys, { struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct fs_info_t *p_fs = &(sbi->fs_info); - struct bd_info_t *p_bd = &(sbi->bd_info); + struct fs_info_t *p_fs = &sbi->fs_info; + struct bd_info_t *p_bd = &sbi->bd_info; const unsigned long blocksize = sb->s_blocksize; const unsigned char blocksize_bits = sb->s_blocksize_bits; sector_t last_block; @@ -3302,7 +3302,7 @@ static struct inode *exfat_iget(struct super_block *sb, loff_t i_pos) static int exfat_fill_inode(struct inode *inode, struct file_id_t *fid) { struct exfat_sb_info *sbi = EXFAT_SB(inode->i_sb); - struct fs_info_t *p_fs = &(sbi->fs_info); + struct fs_info_t *p_fs = &sbi->fs_info; struct dir_entry_t info; memcpy(&(EXFAT_I(inode)->fid), fid, sizeof(struct file_id_t)); @@ -3787,7 +3787,7 @@ static int exfat_read_root(struct inode *inode) { struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct fs_info_t *p_fs = &(sbi->fs_info); + struct fs_info_t *p_fs = &sbi->fs_info; struct dir_entry_t info; EXFAT_I(inode)->fid.dir.dir = p_fs->root_dir; -- cgit v1.2.3-59-g8ed1b From 072429a4d6ab5335f07cfc3f95f5e9f73955be10 Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 30 Oct 2019 02:03:24 +0100 Subject: staging: exfat: make alignment match open parenthesis Fix checkpatch.pl warning: CHECK: Alignment should match open parenthesis Signed-off-by: Roi Martin Link: https://lore.kernel.org/r/20191030010328.10203-3-jroi.martin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 851cd366a108..69c14e4eec2f 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -1703,7 +1703,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, size_t bufsize; pr_debug("%s entered p_dir dir %u flags %x size %d\n", - __func__, p_dir->dir, p_dir->flags, p_dir->size); + __func__, p_dir->dir, p_dir->flags, p_dir->size); byte_offset = entry << DENTRY_SIZE_BITS; ret = _walk_fat_chain(sb, p_dir, byte_offset, &clu); @@ -1835,8 +1835,8 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, *file_ep = (struct dentry_t *)&es->__buf; pr_debug("%s exiting es %p sec %llu offset %d flags %d, num_entries %u buf ptr %p\n", - __func__, es, (unsigned long long)es->sector, es->offset, - es->alloc_flag, es->num_entries, &es->__buf); + __func__, es, (unsigned long long)es->sector, es->offset, + es->alloc_flag, es->num_entries, &es->__buf); return es; err_out: pr_debug("%s exited NULL (es %p)\n", __func__, es); @@ -1862,7 +1862,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, u8 *buf, *esbuf = (u8 *)&es->__buf; pr_debug("%s entered es %p sec %llu off %d count %d\n", - __func__, es, (unsigned long long)sec, off, count); + __func__, es, (unsigned long long)sec, off, count); num_entries = count; while (num_entries) { @@ -1876,8 +1876,8 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, goto err_out; pr_debug("es->buf %p buf_off %u\n", esbuf, buf_off); pr_debug("copying %d entries from %p to sector %llu\n", - copy_entries, (esbuf + buf_off), - (unsigned long long)sec); + copy_entries, (esbuf + buf_off), + (unsigned long long)sec); memcpy(buf + off, esbuf + buf_off, copy_entries << DENTRY_SIZE_BITS); buf_modify(sb, sec); -- cgit v1.2.3-59-g8ed1b From 487242c3dd31aca9850825a1df5a13d866509485 Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 30 Oct 2019 02:03:25 +0100 Subject: staging: exfat: remove unnecessary new line in if condition Fix checkpatch.pl warning: CHECK: Logical continuations should be on the previous line Signed-off-by: Roi Martin Link: https://lore.kernel.org/r/20191030010328.10203-4-jroi.martin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 69c14e4eec2f..493c0008617b 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -1727,8 +1727,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, ep = (struct dentry_t *)(buf + off); entry_type = p_fs->fs_func->get_entry_type(ep); - if ((entry_type != TYPE_FILE) - && (entry_type != TYPE_DIR)) + if ((entry_type != TYPE_FILE) && (entry_type != TYPE_DIR)) goto err_out; if (type == ES_ALL_ENTRIES) -- cgit v1.2.3-59-g8ed1b From 89f882db113b2c0aa46f6cbb85733bef85c754cc Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 30 Oct 2019 02:03:26 +0100 Subject: staging: exfat: replace printk(KERN_INFO ...) with pr_info() Fix checkpatch.pl warning: WARNING: Prefer [subsystem eg: netdev]_info([subsystem]dev, ... then dev_info(dev, ... then pr_info(... to printk(KERN_INFO ... Signed-off-by: Roi Martin Link: https://lore.kernel.org/r/20191030010328.10203-5-jroi.martin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 007885d140be..f4206d736f7d 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -396,7 +396,7 @@ static int ffsMountVol(struct super_block *sb) if (i < 53) { #ifdef CONFIG_EXFAT_DONT_MOUNT_VFAT ret = -EINVAL; - printk(KERN_INFO "EXFAT: Attempted to mount VFAT filesystem\n"); + pr_info("EXFAT: Attempted to mount VFAT filesystem\n"); goto out; #else if (GET16(p_pbr->bpb + 11)) /* num_fat_sectors */ -- cgit v1.2.3-59-g8ed1b From d5ca94a4bdcc0e7cf3d02992dc582e284fa3cc99 Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Wed, 30 Oct 2019 02:03:27 +0100 Subject: staging: exfat: avoid multiple assignments Fix checkpatch.pl warning: CHECK: multiple assignments should be avoided Signed-off-by: Roi Martin Link: https://lore.kernel.org/r/20191030010328.10203-6-jroi.martin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 3 +- drivers/staging/exfat/exfat_super.c | 90 +++++++++++++++++++++++++++++-------- 2 files changed, 73 insertions(+), 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 493c0008617b..f71235c6a338 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -470,7 +470,8 @@ s32 exfat_count_used_clusters(struct super_block *sb) struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - map_i = map_b = 0; + map_i = 0; + map_b = 0; for (i = 2; i < p_fs->num_clusters; i += 8) { k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index f4206d736f7d..3a7a10dbded4 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -864,7 +864,8 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, while (count > 0) { clu_offset = (s32)(fid->rwoffset >> p_fs->cluster_size_bits); - clu = last_clu = fid->start_clu; + clu = fid->start_clu; + last_clu = fid->start_clu; if (fid->flags == 0x03) { if ((clu_offset > 0) && (clu != CLUSTER_32(~0))) { @@ -2351,6 +2352,7 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) { struct super_block *sb = dir->i_sb; + struct timespec64 curtime; struct inode *inode; struct file_id_t fid; loff_t i_pos; @@ -2375,7 +2377,10 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, goto out; } INC_IVERSION(dir); - dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir); + curtime = current_time(dir); + dir->i_ctime = curtime; + dir->i_mtime = curtime; + dir->i_atime = curtime; if (IS_DIRSYNC(dir)) (void)exfat_sync_inode(dir); else @@ -2389,7 +2394,10 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, goto out; } INC_IVERSION(inode); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_atime = curtime; + inode->i_ctime = curtime; /* * timestamp is already written, so mark_inode_dirty() is unnecessary. */ @@ -2522,6 +2530,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; struct super_block *sb = dir->i_sb; + struct timespec64 curtime; int err; __lock_super(sb); @@ -2539,14 +2548,18 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) goto out; } INC_IVERSION(dir); - dir->i_mtime = dir->i_atime = current_time(dir); + curtime = current_time(dir); + dir->i_mtime = curtime; + dir->i_atime = curtime; if (IS_DIRSYNC(dir)) (void)exfat_sync_inode(dir); else mark_inode_dirty(dir); clear_nlink(inode); - inode->i_mtime = inode->i_atime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_atime = curtime; exfat_detach(inode); remove_inode_hash(inode); @@ -2560,6 +2573,7 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, const char *target) { struct super_block *sb = dir->i_sb; + struct timespec64 curtime; struct inode *inode; struct file_id_t fid; loff_t i_pos; @@ -2597,7 +2611,10 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, } INC_IVERSION(dir); - dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir); + curtime = current_time(dir); + dir->i_ctime = curtime; + dir->i_mtime = curtime; + dir->i_atime = curtime; if (IS_DIRSYNC(dir)) (void)exfat_sync_inode(dir); else @@ -2611,7 +2628,10 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, goto out; } INC_IVERSION(inode); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_atime = curtime; + inode->i_ctime = curtime; /* timestamp is already written, so mark_inode_dirty() is unneeded. */ EXFAT_I(inode)->target = kmemdup(target, len + 1, GFP_KERNEL); @@ -2632,6 +2652,7 @@ out: static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) { struct super_block *sb = dir->i_sb; + struct timespec64 curtime; struct inode *inode; struct file_id_t fid; loff_t i_pos; @@ -2656,7 +2677,10 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) goto out; } INC_IVERSION(dir); - dir->i_ctime = dir->i_mtime = dir->i_atime = current_time(dir); + curtime = current_time(dir); + dir->i_ctime = curtime; + dir->i_mtime = curtime; + dir->i_atime = curtime; if (IS_DIRSYNC(dir)) (void)exfat_sync_inode(dir); else @@ -2671,7 +2695,10 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) goto out; } INC_IVERSION(inode); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_atime = curtime; + inode->i_ctime = curtime; /* timestamp is already written, so mark_inode_dirty() is unneeded. */ dentry->d_time = GET_IVERSION(dentry->d_parent->d_inode); @@ -2687,6 +2714,7 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) { struct inode *inode = dentry->d_inode; struct super_block *sb = dir->i_sb; + struct timespec64 curtime; int err; __lock_super(sb); @@ -2710,7 +2738,9 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) goto out; } INC_IVERSION(dir); - dir->i_mtime = dir->i_atime = current_time(dir); + curtime = current_time(dir); + dir->i_mtime = curtime; + dir->i_atime = curtime; if (IS_DIRSYNC(dir)) (void)exfat_sync_inode(dir); else @@ -2718,7 +2748,9 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) drop_nlink(dir); clear_nlink(inode); - inode->i_mtime = inode->i_atime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_atime = curtime; exfat_detach(inode); remove_inode_hash(inode); @@ -2734,6 +2766,7 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, { struct inode *old_inode, *new_inode; struct super_block *sb = old_dir->i_sb; + struct timespec64 curtime; loff_t i_pos; int err; @@ -2767,8 +2800,11 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, goto out; } INC_IVERSION(new_dir); - new_dir->i_ctime = new_dir->i_mtime = new_dir->i_atime = - current_time(new_dir); + curtime = current_time(new_dir); + new_dir->i_ctime = curtime; + new_dir->i_mtime = curtime; + new_dir->i_atime = curtime; + if (IS_DIRSYNC(new_dir)) (void)exfat_sync_inode(new_dir); else @@ -2790,7 +2826,9 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, inc_nlink(new_dir); } INC_IVERSION(old_dir); - old_dir->i_ctime = old_dir->i_mtime = current_time(old_dir); + curtime = current_time(old_dir); + old_dir->i_ctime = curtime; + old_dir->i_mtime = curtime; if (IS_DIRSYNC(old_dir)) (void)exfat_sync_inode(old_dir); else @@ -2814,13 +2852,16 @@ static int exfat_cont_expand(struct inode *inode, loff_t size) { struct address_space *mapping = inode->i_mapping; loff_t start = i_size_read(inode), count = size - i_size_read(inode); + struct timespec64 curtime; int err, err2; err = generic_cont_expand_simple(inode, size); if (err != 0) return err; - inode->i_ctime = inode->i_mtime = current_time(inode); + curtime = current_time(inode); + inode->i_ctime = curtime; + inode->i_mtime = curtime; mark_inode_dirty(inode); if (IS_SYNC(inode)) { @@ -2896,6 +2937,7 @@ static void exfat_truncate(struct inode *inode, loff_t old_size) struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct fs_info_t *p_fs = &sbi->fs_info; + struct timespec64 curtime; int err; __lock_super(sb); @@ -2914,7 +2956,9 @@ static void exfat_truncate(struct inode *inode, loff_t old_size) if (err) goto out; - inode->i_ctime = inode->i_mtime = current_time(inode); + curtime = current_time(inode); + inode->i_ctime = curtime; + inode->i_mtime = curtime; if (IS_DIRSYNC(inode)) (void)exfat_sync_inode(inode); else @@ -3215,6 +3259,7 @@ static int exfat_write_end(struct file *file, struct address_space *mapping, { struct inode *inode = mapping->host; struct file_id_t *fid = &(EXFAT_I(inode)->fid); + struct timespec64 curtime; int err; err = generic_write_end(file, mapping, pos, len, copied, pagep, fsdata); @@ -3223,7 +3268,9 @@ static int exfat_write_end(struct file *file, struct address_space *mapping, exfat_write_failed(mapping, pos + len); if (!(err < 0) && !(fid->attr & ATTR_ARCHIVE)) { - inode->i_mtime = inode->i_ctime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_ctime = curtime; fid->attr |= ATTR_ARCHIVE; mark_inode_dirty(inode); } @@ -3674,7 +3721,8 @@ static int parse_options(char *options, int silent, int *debug, opts->fs_uid = current_uid(); opts->fs_gid = current_gid(); - opts->fs_fmask = opts->fs_dmask = current->fs->umask; + opts->fs_fmask = current->fs->umask; + opts->fs_dmask = current->fs->umask; opts->allow_utime = U16_MAX; opts->codepage = exfat_default_codepage; opts->iocharset = exfat_default_iocharset; @@ -3788,6 +3836,7 @@ static int exfat_read_root(struct inode *inode) struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct fs_info_t *p_fs = &sbi->fs_info; + struct timespec64 curtime; struct dir_entry_t info; EXFAT_I(inode)->fid.dir.dir = p_fs->root_dir; @@ -3818,7 +3867,10 @@ static int exfat_read_root(struct inode *inode) EXFAT_I(inode)->mmu_private = i_size_read(inode); exfat_save_attr(inode, ATTR_SUBDIR); - inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); + curtime = current_time(inode); + inode->i_mtime = curtime; + inode->i_atime = curtime; + inode->i_ctime = curtime; set_nlink(inode, info.NumSubdirs + 2); return 0; -- cgit v1.2.3-59-g8ed1b From 3ae82f449cea00de5cd894feb8e9154b2da99b4e Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Wed, 30 Oct 2019 07:49:16 -0700 Subject: drivers/staging/exfat: Replace binary semaphores for mutexes At a slight footprint cost (24 vs 32 bytes), mutexes are more optimal than semaphores; it's also a nicer interface for mutual exclusion, which is why they are encouraged over binary semaphores, when possible. For both v_sem and z_sem, their semantics imply traditional lock ownership; that is, the lock owner is the same for both lock/unlock operations. Therefore it is safe to convert. Signed-off-by: Davidlohr Bueso Acked-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191030144916.10802-1-dave@stgolabs.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 2 +- drivers/staging/exfat/exfat_super.c | 84 ++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 43 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 6142e880f682..acb73f47a253 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -610,7 +610,7 @@ struct fs_info_t { u32 dev_ejected; /* block device operation error flag */ struct fs_func *fs_func; - struct semaphore v_sem; + struct mutex v_mutex; /* FAT cache */ struct buf_cache_t FAT_cache_array[FAT_CACHE_SIZE]; diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 3a7a10dbded4..77984a73ba6e 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -284,7 +284,7 @@ static const struct dentry_operations exfat_dentry_ops = { .d_compare = exfat_cmp, }; -static DEFINE_SEMAPHORE(z_sem); +static DEFINE_MUTEX(z_mutex); static inline void fs_sync(struct super_block *sb, bool do_sync) { @@ -353,11 +353,11 @@ static int ffsMountVol(struct super_block *sb) pr_info("[EXFAT] trying to mount...\n"); - down(&z_sem); + mutex_lock(&z_mutex); buf_init(sb); - sema_init(&p_fs->v_sem, 1); + mutex_init(&p_fs->v_mutex); p_fs->dev_ejected = 0; /* open the block device */ @@ -442,7 +442,7 @@ static int ffsMountVol(struct super_block *sb) pr_info("[EXFAT] mounted successfully\n"); out: - up(&z_sem); + mutex_unlock(&z_mutex); return ret; } @@ -454,10 +454,10 @@ static int ffsUmountVol(struct super_block *sb) pr_info("[EXFAT] trying to unmount...\n"); - down(&z_sem); + mutex_lock(&z_mutex); /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); @@ -481,8 +481,8 @@ static int ffsUmountVol(struct super_block *sb) buf_shutdown(sb); /* release the lock for file system critical section */ - up(&p_fs->v_sem); - up(&z_sem); + mutex_unlock(&p_fs->v_mutex); + mutex_unlock(&z_mutex); pr_info("[EXFAT] unmounted successfully\n"); @@ -499,7 +499,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); if (p_fs->used_clusters == UINT_MAX) p_fs->used_clusters = p_fs->fs_func->count_used_clusters(sb); @@ -514,7 +514,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) err = FFS_MEDIAERR; /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return err; } @@ -525,7 +525,7 @@ static int ffsSyncVol(struct super_block *sb, bool do_sync) struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* synchronize the file system */ fs_sync(sb, do_sync); @@ -535,7 +535,7 @@ static int ffsSyncVol(struct super_block *sb, bool do_sync) err = FFS_MEDIAERR; /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return err; } @@ -562,7 +562,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* check the validity of directory name in the given pathname */ ret = resolve_path(inode, path, &dir, &uni_name); @@ -636,7 +636,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) ret = FFS_MEDIAERR; out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -655,7 +655,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* check the validity of directory name in the given pathname */ ret = resolve_path(inode, path, &dir, &uni_name); @@ -677,7 +677,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -704,7 +704,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* check if the given file ID is opened */ if (fid->type != TYPE_FILE) { @@ -801,7 +801,7 @@ err_out: out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -834,7 +834,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* check if the given file ID is opened */ if (fid->type != TYPE_FILE) { @@ -1059,7 +1059,7 @@ err_out: out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1082,7 +1082,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) new_size); /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* check if the given file ID is opened */ if (fid->type != TYPE_FILE) { @@ -1192,7 +1192,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) out: pr_debug("%s exited (%d)\n", __func__, ret); /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1240,7 +1240,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); update_parent_info(fid, old_parent_inode); @@ -1338,7 +1338,7 @@ out: ret = FFS_MEDIAERR; out2: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1357,7 +1357,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) return FFS_INVALIDFID; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); dir.dir = fid->dir.dir; dir.size = fid->dir.size; @@ -1400,7 +1400,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) ret = FFS_MEDIAERR; out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1435,7 +1435,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) } /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* get the directory entry of given file */ if (p_fs->vol_type == EXFAT) { @@ -1489,7 +1489,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) ret = FFS_MEDIAERR; out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1513,7 +1513,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) pr_debug("%s entered\n", __func__); /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); if (is_dir) { if ((fid->dir.dir == p_fs->root_dir) && @@ -1642,7 +1642,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); pr_debug("%s exited successfully\n", __func__); return ret; @@ -1663,7 +1663,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) pr_debug("%s entered (inode %p info %p\n", __func__, inode, info); /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); if (is_dir) { if ((fid->dir.dir == p_fs->root_dir) && @@ -1729,7 +1729,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); pr_debug("%s exited (%d)\n", __func__, ret); @@ -1755,7 +1755,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); fid->rwoffset = (s64)(clu_offset) << p_fs->cluster_size_bits; @@ -1883,7 +1883,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1907,7 +1907,7 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) return FFS_ERROR; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); /* check the validity of directory name in the given old pathname */ ret = resolve_path(inode, path, &dir, &uni_name); @@ -1927,7 +1927,7 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) ret = FFS_MEDIAERR; out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -1957,7 +1957,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) return -EPERM; /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); if (fid->entry == -1) { dir.dir = p_fs->root_dir; @@ -2126,7 +2126,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -2156,7 +2156,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) } /* acquire the lock for file system critical section */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); clu_to_free.dir = fid->start_clu; clu_to_free.size = (s32)((fid->size - 1) >> p_fs->cluster_size_bits) + 1; @@ -2189,7 +2189,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) out: /* release the lock for file system critical section */ - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); return ret; } @@ -4036,10 +4036,10 @@ static void exfat_debug_kill_sb(struct super_block *sb) * invalidate_bdev drops all device cache include * dirty. We use this to simulate device removal. */ - down(&p_fs->v_sem); + mutex_lock(&p_fs->v_mutex); FAT_release_all(sb); buf_release_all(sb); - up(&p_fs->v_sem); + mutex_unlock(&p_fs->v_mutex); invalidate_bdev(bdev); } -- cgit v1.2.3-59-g8ed1b From 129376c6d68617bc00e46bbfc4c21745db17b73d Mon Sep 17 00:00:00 2001 From: Roi Martin Date: Thu, 31 Oct 2019 13:31:39 +0100 Subject: staging: exfat: replace kmalloc with kmalloc_array Replace expressions of the form: kmalloc(count * size, GFP_KERNEL); With: kmalloc_array(count, size, GFP_KERNEL); Signed-off-by: Roi Martin Link: https://lore.kernel.org/r/20191031123139.32361-1-jroi.martin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index f71235c6a338..f4f82aecc05d 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -713,8 +713,8 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector, u32 checksum = 0; - upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *), - GFP_KERNEL); + upcase_table = kmalloc_array(UTBL_COL_COUNT, sizeof(u16 *), GFP_KERNEL); + p_fs->vol_utbl = upcase_table; if (!upcase_table) return -ENOMEM; memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *)); @@ -793,8 +793,8 @@ static s32 __load_default_upcase_table(struct super_block *sb) u16 uni = 0; u16 **upcase_table; - upcase_table = p_fs->vol_utbl = kmalloc(UTBL_COL_COUNT * sizeof(u16 *), - GFP_KERNEL); + upcase_table = kmalloc_array(UTBL_COL_COUNT, sizeof(u16 *), GFP_KERNEL); + p_fs->vol_utbl = upcase_table; if (!upcase_table) return -ENOMEM; memset(upcase_table, 0, UTBL_COL_COUNT * sizeof(u16 *)); -- cgit v1.2.3-59-g8ed1b From 6e653e9cac2d4b53ac2ca5442a9ec7b38f9c62c8 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Thu, 31 Oct 2019 20:02:41 -0300 Subject: staging: rts5208: Eliminate the use of Camel Case in files ms.{h, c} Cleans up checks of "Avoid CamelCase" in files ms.{h,c} Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191031230243.3462-2-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/ms.c | 86 ++++++++++++++++++++++---------------------- drivers/staging/rts5208/ms.h | 70 ++++++++++++++++++------------------ 2 files changed, 78 insertions(+), 78 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index e853fa9cc950..d53dd138a356 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -590,7 +590,7 @@ static int ms_identify_media_type(struct rtsx_chip *chip, int switch_8bit_bus) int retval, i; u8 val; - retval = ms_set_rw_reg_addr(chip, Pro_StatusReg, 6, SystemParm, 1); + retval = ms_set_rw_reg_addr(chip, PRO_STATUS_REG, 6, SYSTEM_PARAM, 1); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -840,7 +840,7 @@ static int msxc_change_power(struct rtsx_chip *chip, u8 mode) ms_cleanup_work(chip); - retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); + retval = ms_set_rw_reg_addr(chip, 0, 0, PRO_DATA_COUNT1, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -885,7 +885,7 @@ static int ms_read_attribute_info(struct rtsx_chip *chip) int found_sys_info = 0, found_model_name = 0; #endif - retval = ms_set_rw_reg_addr(chip, Pro_IntReg, 2, Pro_SystemParm, 7); + retval = ms_set_rw_reg_addr(chip, PRO_INT_REG, 2, PRO_SYSTEM_PARAM, 7); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1232,7 +1232,7 @@ static int ms_read_status_reg(struct rtsx_chip *chip) int retval; u8 val[2]; - retval = ms_set_rw_reg_addr(chip, StatusReg0, 2, 0, 0); + retval = ms_set_rw_reg_addr(chip, STATUS_REG0, 2, 0, 0); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1255,8 +1255,8 @@ static int ms_read_extra_data(struct rtsx_chip *chip, int retval, i; u8 val, data[10]; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 6); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1307,8 +1307,8 @@ static int ms_read_extra_data(struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) return STATUS_FAIL; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, + MS_EXTRA_SIZE, SYSTEM_PARAM, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1339,8 +1339,8 @@ static int ms_write_extra_data(struct rtsx_chip *chip, u16 block_addr, if (!buf || (buf_len < MS_EXTRA_SIZE)) return STATUS_FAIL; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 6 + MS_EXTRA_SIZE); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 6 + MS_EXTRA_SIZE); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1392,8 +1392,8 @@ static int ms_read_page(struct rtsx_chip *chip, u16 block_addr, u8 page_num) int retval; u8 val, data[6]; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 6); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1465,8 +1465,8 @@ static int ms_set_bad_block(struct rtsx_chip *chip, u16 phy_blk) if (retval != STATUS_SUCCESS) return STATUS_FAIL; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 7); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 7); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1519,8 +1519,8 @@ static int ms_erase_block(struct rtsx_chip *chip, u16 phy_blk) int retval, i = 0; u8 val, data[6]; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 6); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1579,7 +1579,7 @@ static void ms_set_page_status(u16 log_blk, u8 type, u8 *extra, int extra_len) memset(extra, 0xFF, MS_EXTRA_SIZE); - if (type == setPS_NG) { + if (type == set_PS_NG) { /* set page status as 1:NG,and block status keep 1:OK */ extra[0] = 0xB8; } else { @@ -1670,8 +1670,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, if (retval != STATUS_SUCCESS) return STATUS_FAIL; - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, 6); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, + MS_EXTRA_SIZE, SYSTEM_PARAM, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1725,7 +1725,7 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, return STATUS_FAIL; if (uncorrect_flag) { - ms_set_page_status(log_blk, setPS_NG, + ms_set_page_status(log_blk, set_PS_NG, extra, MS_EXTRA_SIZE); if (i == 0) @@ -1738,8 +1738,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, i, extra[0]); MS_SET_BAD_BLOCK_FLG(ms_card); - ms_set_page_status(log_blk, setPS_Error, - extra, + ms_set_page_status(log_blk, + set_PS_error, extra, MS_EXTRA_SIZE); ms_write_extra_data(chip, new_blk, i, extra, @@ -1767,8 +1767,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, } } - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, (6 + MS_EXTRA_SIZE)); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, (6 + MS_EXTRA_SIZE)); ms_set_err_code(chip, MS_NO_ERROR); @@ -1822,8 +1822,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, } if (i == 0) { - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, - MS_EXTRA_SIZE, SystemParm, + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, + MS_EXTRA_SIZE, SYSTEM_PARAM, 7); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -1980,8 +1980,8 @@ RE_SEARCH: for (reg_addr = BLOCK_SIZE_0; reg_addr <= PAGE_SIZE_1; reg_addr++) rtsx_add_cmd(chip, READ_REG_CMD, reg_addr, 0, 0); - rtsx_add_cmd(chip, READ_REG_CMD, MS_Device_Type, 0, 0); - rtsx_add_cmd(chip, READ_REG_CMD, MS_4bit_Support, 0, 0); + rtsx_add_cmd(chip, READ_REG_CMD, MS_device_type, 0, 0); + rtsx_add_cmd(chip, READ_REG_CMD, MS_4bit_support, 0, 0); retval = rtsx_send_cmd(chip, MS_CARD, 100); if (retval < 0) @@ -2057,7 +2057,7 @@ RE_SEARCH: /* Switch I/F Mode */ if (ptr[15]) { - retval = ms_set_rw_reg_addr(chip, 0, 0, SystemParm, 1); + retval = ms_set_rw_reg_addr(chip, 0, 0, SYSTEM_PARAM, 1); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -2887,7 +2887,7 @@ int mspro_format(struct scsi_cmnd *srb, struct rtsx_chip *chip, if (retval != STATUS_SUCCESS) return STATUS_FAIL; - retval = ms_set_rw_reg_addr(chip, 0x00, 0x00, Pro_TPCParm, 0x01); + retval = ms_set_rw_reg_addr(chip, 0x00, 0x00, PRO_TPC_PARM, 0x01); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -2970,8 +2970,8 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, } } - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 6); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -3026,7 +3026,7 @@ static int ms_read_multiple_pages(struct rtsx_chip *chip, u16 phy_blk, if (!(chip->card_wp & MS_CARD)) { reset_ms(chip); ms_set_page_status - (log_blk, setPS_NG, + (log_blk, set_PS_NG, extra, MS_EXTRA_SIZE); ms_write_extra_data @@ -3131,8 +3131,8 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, u8 *ptr; if (!start_page) { - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, 7); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, 7); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -3165,8 +3165,8 @@ static int ms_write_multiple_pages(struct rtsx_chip *chip, u16 old_blk, return STATUS_FAIL; } - retval = ms_set_rw_reg_addr(chip, OverwriteFlag, MS_EXTRA_SIZE, - SystemParm, (6 + MS_EXTRA_SIZE)); + retval = ms_set_rw_reg_addr(chip, OVERWRITE_FLAG, MS_EXTRA_SIZE, + SYSTEM_PARAM, (6 + MS_EXTRA_SIZE)); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -3773,9 +3773,9 @@ static int mg_set_tpc_para_sub(struct rtsx_chip *chip, int type, u8 buf[6]; if (type == 0) - retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_TPCParm, 1); + retval = ms_set_rw_reg_addr(chip, 0, 0, PRO_TPC_PARM, 1); else - retval = ms_set_rw_reg_addr(chip, 0, 0, Pro_DataCount1, 6); + retval = ms_set_rw_reg_addr(chip, 0, 0, PRO_DATA_COUNT1, 6); if (retval != STATUS_SUCCESS) return STATUS_FAIL; @@ -4154,7 +4154,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) } else { set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); } - goto SetICVFinish; + goto set_ICV_finish; } #ifdef MG_SET_ICV_SLOW @@ -4195,7 +4195,7 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) SENSE_TYPE_MG_WRITE_ERR); } retval = STATUS_FAIL; - goto SetICVFinish; + goto set_ICV_finish; } } #else @@ -4214,11 +4214,11 @@ int mg_set_ICV(struct scsi_cmnd *srb, struct rtsx_chip *chip) } else { set_sense_type(chip, lun, SENSE_TYPE_MG_WRITE_ERR); } - goto SetICVFinish; + goto set_ICV_finish; } #endif -SetICVFinish: +set_ICV_finish: kfree(buf); return retval; } diff --git a/drivers/staging/rts5208/ms.h b/drivers/staging/rts5208/ms.h index 952cc14dd079..33bda9ce36b6 100644 --- a/drivers/staging/rts5208/ms.h +++ b/drivers/staging/rts5208/ms.h @@ -92,37 +92,37 @@ #define PRO_FORMAT 0x10 #define PRO_SLEEP 0x11 -#define IntReg 0x01 -#define StatusReg0 0x02 -#define StatusReg1 0x03 - -#define SystemParm 0x10 -#define BlockAdrs 0x11 -#define CMDParm 0x14 -#define PageAdrs 0x15 - -#define OverwriteFlag 0x16 -#define ManagemenFlag 0x17 -#define LogicalAdrs 0x18 -#define ReserveArea 0x1A - -#define Pro_IntReg 0x01 -#define Pro_StatusReg 0x02 -#define Pro_TypeReg 0x04 -#define Pro_IFModeReg 0x05 -#define Pro_CatagoryReg 0x06 -#define Pro_ClassReg 0x07 - -#define Pro_SystemParm 0x10 -#define Pro_DataCount1 0x11 -#define Pro_DataCount0 0x12 -#define Pro_DataAddr3 0x13 -#define Pro_DataAddr2 0x14 -#define Pro_DataAddr1 0x15 -#define Pro_DataAddr0 0x16 - -#define Pro_TPCParm 0x17 -#define Pro_CMDParm 0x18 +#define INT_REG 0x01 +#define STATUS_REG0 0x02 +#define STATUS_REG1 0x03 + +#define SYSTEM_PARAM 0x10 +#define BLOCK_ADRS 0x11 +#define CMD_PARM 0x14 +#define PAGE_ADRS 0x15 + +#define OVERWRITE_FLAG 0x16 +#define MANAGEMEN_FLAG 0x17 +#define LOGICAL_ADRS 0x18 +#define RESERVE_AREA 0x1A + +#define PRO_INT_REG 0x01 +#define PRO_STATUS_REG 0x02 +#define PRO_TYPE_REG 0x04 +#define PRO_IF_mode_REG 0x05 +#define PRO_CATEGORY_REG 0x06 +#define PRO_CLASS_REG 0x07 + +#define PRO_SYSTEM_PARAM 0x10 +#define PRO_DATA_COUNT1 0x11 +#define PRO_DATA_COUNT0 0x12 +#define PRO_DATA_ADDR3 0x13 +#define PRO_DATA_ADDR2 0x14 +#define PRO_DATA_ADDR1 0x15 +#define PRO_DATA_ADDR0 0x16 + +#define PRO_TPC_PARM 0x17 +#define PRO_CMD_PARM 0x18 #define INT_REG_CED 0x80 #define INT_REG_ERR 0x40 @@ -152,12 +152,12 @@ #define PAGE_SIZE_0 (PPBUF_BASE2 + 0x1a0 + 8) #define PAGE_SIZE_1 (PPBUF_BASE2 + 0x1a0 + 9) -#define MS_Device_Type (PPBUF_BASE2 + 0x1D8) +#define MS_device_type (PPBUF_BASE2 + 0x1D8) -#define MS_4bit_Support (PPBUF_BASE2 + 0x1D3) +#define MS_4bit_support (PPBUF_BASE2 + 0x1D3) -#define setPS_NG 1 -#define setPS_Error 0 +#define set_PS_NG 1 +#define set_PS_error 0 #define PARALLEL_8BIT_IF 0x40 #define PARALLEL_4BIT_IF 0x00 -- cgit v1.2.3-59-g8ed1b From 1a0afbec55b8e3637682f06904ff9373b084823c Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Thu, 31 Oct 2019 20:02:42 -0300 Subject: staging: rts5208: Eliminate the use of Camel Case in files xd.{h, c} Cleans up checks of "Avoid CamelCase" in files xd.{h,c} Acked-by: Julia Lawall Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191031230243.3462-3-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/xd.c | 8 ++++---- drivers/staging/rts5208/xd.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index f3dc96a4c59d..0f369935fb6c 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -630,13 +630,13 @@ static int reset_xd(struct rtsx_chip *chip) xd_card->zone_cnt = 32; xd_card->capacity = 1024000; break; - case xD_1G_X8_512: + case XD_1G_X8_512: XD_PAGE_512(xd_card); xd_card->addr_cycle = 4; xd_card->zone_cnt = 64; xd_card->capacity = 2048000; break; - case xD_2G_X8_512: + case XD_2G_X8_512: XD_PAGE_512(xd_card); xd_card->addr_cycle = 4; xd_card->zone_cnt = 128; @@ -669,10 +669,10 @@ static int reset_xd(struct rtsx_chip *chip) return STATUS_FAIL; } - retval = xd_read_id(chip, READ_xD_ID, id_buf, 4); + retval = xd_read_id(chip, READ_XD_ID, id_buf, 4); if (retval != STATUS_SUCCESS) return STATUS_FAIL; - dev_dbg(rtsx_dev(chip), "READ_xD_ID: 0x%x 0x%x 0x%x 0x%x\n", + dev_dbg(rtsx_dev(chip), "READ_XD_ID: 0x%x 0x%x 0x%x 0x%x\n", id_buf[0], id_buf[1], id_buf[2], id_buf[3]); if (id_buf[2] != XD_ID_CODE) return STATUS_FAIL; diff --git a/drivers/staging/rts5208/xd.h b/drivers/staging/rts5208/xd.h index 57b94129b26f..98c00f268e56 100644 --- a/drivers/staging/rts5208/xd.h +++ b/drivers/staging/rts5208/xd.h @@ -36,7 +36,7 @@ #define BLK_ERASE_1 0x60 #define BLK_ERASE_2 0xD0 #define READ_STS 0x70 -#define READ_xD_ID 0x9A +#define READ_XD_ID 0x9A #define COPY_BACK_512 0x8A #define COPY_BACK_2K 0x85 #define READ1_1_2 0x30 @@ -72,8 +72,8 @@ #define XD_128M_X16_2048 0xC1 #define XD_4M_X8_512_1 0xE3 #define XD_4M_X8_512_2 0xE5 -#define xD_1G_X8_512 0xD3 -#define xD_2G_X8_512 0xD5 +#define XD_1G_X8_512 0xD3 +#define XD_2G_X8_512 0xD5 #define XD_ID_CODE 0xB5 -- cgit v1.2.3-59-g8ed1b From f8be8d1ede50a5918faeda82e1f1fb45e9431b54 Mon Sep 17 00:00:00 2001 From: Gabriela Bittencourt Date: Thu, 31 Oct 2019 20:02:43 -0300 Subject: staging: rts5208: Eliminate the use of Camel Case in file sd.h Cleans up checks of "Avoid CamelCase" in file sd.h Even though the constant "DCM_LOW_FREQUENCY_MODE_SET" is defined and never used, it's useful to keep it because it documents the device. Signed-off-by: Gabriela Bittencourt Link: https://lore.kernel.org/r/20191031230243.3462-4-gabrielabittencourt00@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/sd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/sd.h b/drivers/staging/rts5208/sd.h index dc9e8cad7a74..f4ff62653b56 100644 --- a/drivers/staging/rts5208/sd.h +++ b/drivers/staging/rts5208/sd.h @@ -232,7 +232,7 @@ #define DCM_LOW_FREQUENCY_MODE 0x01 #define DCM_HIGH_FREQUENCY_MODE_SET 0x0C -#define DCM_Low_FREQUENCY_MODE_SET 0x00 +#define DCM_LOW_FREQUENCY_MODE_SET 0x00 #define MULTIPLY_BY_1 0x00 #define MULTIPLY_BY_2 0x01 -- cgit v1.2.3-59-g8ed1b From dc7603e1fa3dd30ad9aa1489dbd84ee84c554e8f Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Fri, 1 Nov 2019 17:04:13 -0700 Subject: staging: vc04_services: Remove unused structs Removes unused opaque struct typedefs. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/acc1e07a0b2c4e67ae417086087c9ce3d7f932f4.1572652827.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi_common.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index e7955cbaf26a..1fdbe038500a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -112,12 +112,6 @@ struct vchi_msg_vector { int32_t vec_len; }; -// Opaque type for a connection API -typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T; - -// Opaque type for a message driver -typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; - // Iterator structure for reading ahead through received message queue. Allocated by client, // initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only. // Iterates over messages in queue at the instant of the call to vchi_msg_lookahead - -- cgit v1.2.3-59-g8ed1b From 8823d99080ba59598f00b7e50b281c46ddd39d56 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Fri, 1 Nov 2019 17:04:14 -0700 Subject: staging: vc04_services: Remove enum typedefs in vchi Remove enum typedefs from header files and files which include them in vchi. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/4afc7d28ef9ad249cac3bf7c3dd453bb64b13657.1572652827.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 2 +- .../staging/vc04_services/interface/vchi/vchi.h | 20 ++++----- .../vc04_services/interface/vchi/vchi_common.h | 18 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 50 ++++++++++------------ 5 files changed, 43 insertions(+), 49 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 5f6a73af57f9..84ece768854f 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -90,7 +90,7 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, } static void audio_vchi_callback(void *param, - const VCHI_CALLBACK_REASON_T reason, + const enum vchi_callback_reason reason, void *msg_handle) { struct bcm2835_audio_instance *instance = param; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 1c180ead4a20..06b7be7d8872 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -535,7 +535,7 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, /* incoming event service callback */ static void service_callback(void *param, - const VCHI_CALLBACK_REASON_T reason, + const enum vchi_callback_reason reason, void *bulk_ctx) { struct vchiq_mmal_instance *instance = param; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 0a353a468f34..75b1ab4919e3 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -105,8 +105,8 @@ extern int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle); // Routine to set a control option for a named service extern int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, - VCHI_SERVICE_OPTION_T option, - int value); + enum vchi_service_option option, + int value); /* Routine to send a message from kernel memory across a service */ extern int @@ -126,7 +126,7 @@ extern int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, void *data, uint32_t max_data_size_to_read, uint32_t *actual_msg_size, - VCHI_FLAGS_T flags); + enum vchi_flags flags); // Routine to look at a message in place. // The message is not dequeued, so a subsequent call to peek or dequeue @@ -134,7 +134,7 @@ extern int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, extern int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle, void **data, uint32_t *msg_size, - VCHI_FLAGS_T flags); + enum vchi_flags flags); // Routine to remove a message after it has been read in place with peek // The first message on the queue is dequeued. @@ -146,13 +146,13 @@ extern int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle); extern int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T - VCHI_FLAGS_T flags, + enum vchi_flags flags, struct vchi_held_msg *message_descriptor); // Initialise an iterator to look through messages in place extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle, struct vchi_msg_iter *iter, - VCHI_FLAGS_T flags); + enum vchi_flags flags); /******************************************************************************* * Global service support API - operations on held messages @@ -205,21 +205,21 @@ extern int32_t vchi_msg_iter_hold_next(struct vchi_msg_iter *iter, extern int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, void *data_dst, uint32_t data_size, - VCHI_FLAGS_T flags, + enum vchi_flags flags, void *transfer_handle); // Prepare interface for a transfer from the other side into relocatable memory. int32_t vchi_bulk_queue_receive_reloc(const VCHI_SERVICE_HANDLE_T handle, uint32_t offset, uint32_t data_size, - const VCHI_FLAGS_T flags, + const enum vchi_flags flags, void * const bulk_handle); // Routine to queue up data ready for transfer to the other (once they have signalled they are ready) extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, const void *data_src, uint32_t data_size, - VCHI_FLAGS_T flags, + enum vchi_flags flags, void *transfer_handle); /****************************************************************************** @@ -233,7 +233,7 @@ extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, extern int32_t vchi_bulk_queue_transmit_reloc(VCHI_SERVICE_HANDLE_T handle, uint32_t offset, uint32_t data_size, - VCHI_FLAGS_T flags, + enum vchi_flags flags, void *transfer_handle); #endif /* VCHI_H_ */ diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index 1fdbe038500a..c99735fc0308 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -5,7 +5,7 @@ #define VCHI_COMMON_H_ //flags used when sending messages (must be bitmapped) -typedef enum { +enum vchi_flags { VCHI_FLAGS_NONE = 0x0, VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side) VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent @@ -20,17 +20,17 @@ typedef enum { VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only VCHI_FLAGS_INTERNAL = 0xFF0000 -} VCHI_FLAGS_T; +}; // constants for vchi_crc_control() -typedef enum { +enum vchi_crc_control { VCHI_CRC_NOTHING = -1, VCHI_CRC_PER_SERVICE = 0, VCHI_CRC_EVERYTHING = 1, -} VCHI_CRC_CONTROL_T; +}; //callback reasons when an event occurs on a service -typedef enum { +enum vchi_callback_reason { VCHI_CALLBACK_REASON_MIN, //This indicates that there is data available @@ -73,21 +73,21 @@ typedef enum { VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, VCHI_CALLBACK_REASON_MAX -} VCHI_CALLBACK_REASON_T; +}; // service control options -typedef enum { +enum vchi_service_option { VCHI_SERVICE_OPTION_MIN, VCHI_SERVICE_OPTION_TRACE, VCHI_SERVICE_OPTION_SYNCHRONOUS, VCHI_SERVICE_OPTION_MAX -} VCHI_SERVICE_OPTION_T; +}; //Callback used by all services / bulk transfers typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param - VCHI_CALLBACK_REASON_T reason, + enum vchi_callback_reason reason, void *handle); //for transmitting msg's only /* diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 5e26f0abd5ee..704afd470c88 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -27,7 +27,7 @@ struct shim_service { * void **data, * uint32_t *msg_size, - * VCHI_FLAGS_T flags + * enum vchi_flags flags * * Description: Routine to return a pointer to the current message (to allow in * place processing). The message can be removed using @@ -37,9 +37,9 @@ struct shim_service { * ***********************************************************/ int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle, - void **data, - uint32_t *msg_size, - VCHI_FLAGS_T flags) + void **data, + uint32_t *msg_size, + enum vchi_flags flags) { struct shim_service *service = (struct shim_service *)handle; struct vchiq_header *header; @@ -190,7 +190,7 @@ EXPORT_SYMBOL(vchi_queue_user_message); * Arguments: VCHI_BULK_HANDLE_T handle, * void *data_dst, * const uint32_t data_size, - * VCHI_FLAGS_T flags + * enum vchi_flags flags * void *bulk_handle * * Description: Routine to setup a rcv buffer @@ -198,11 +198,9 @@ EXPORT_SYMBOL(vchi_queue_user_message); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, - void *data_dst, - uint32_t data_size, - VCHI_FLAGS_T flags, - void *bulk_handle) +int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, void *data_dst, + uint32_t data_size, enum vchi_flags flags, + void *bulk_handle) { struct shim_service *service = (struct shim_service *)handle; VCHIQ_BULK_MODE_T mode; @@ -250,7 +248,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive); * Arguments: VCHI_BULK_HANDLE_T handle, * const void *data_src, * uint32_t data_size, - * VCHI_FLAGS_T flags, + * enum vchi_flags flags, * void *bulk_handle * * Description: Routine to transmit some data @@ -259,10 +257,10 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive); * ***********************************************************/ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, - const void *data_src, - uint32_t data_size, - VCHI_FLAGS_T flags, - void *bulk_handle) + const void *data_src, + uint32_t data_size, + enum vchi_flags flags, + void *bulk_handle) { struct shim_service *service = (struct shim_service *)handle; VCHIQ_BULK_MODE_T mode; @@ -313,18 +311,16 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); * void *data, * uint32_t max_data_size_to_read, * uint32_t *actual_msg_size - * VCHI_FLAGS_T flags + * enum vchi_flags flags * * Description: Routine to dequeue a message into the supplied buffer * * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, - void *data, - uint32_t max_data_size_to_read, - uint32_t *actual_msg_size, - VCHI_FLAGS_T flags) +int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, void *data, + uint32_t max_data_size_to_read, + uint32_t *actual_msg_size, enum vchi_flags flags) { struct shim_service *service = (struct shim_service *)handle; struct vchiq_header *header; @@ -383,7 +379,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Arguments: VCHI_SERVICE_HANDLE_T handle, * void **data, * uint32_t *msg_size, - * VCHI_FLAGS_T flags, + * enum vchi_flags flags, * struct vchi_held_msg *message_handle * * Description: Routine to return a pointer to the current message (to allow @@ -394,11 +390,9 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, - void **data, - uint32_t *msg_size, - VCHI_FLAGS_T flags, - struct vchi_held_msg *message_handle) +int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, void **data, + uint32_t *msg_size, enum vchi_flags flags, + struct vchi_held_msg *message_handle) { struct shim_service *service = (struct shim_service *)handle; struct vchiq_header *header; @@ -668,7 +662,7 @@ int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle) EXPORT_SYMBOL(vchi_service_destroy); int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, - VCHI_SERVICE_OPTION_T option, + enum vchi_service_option option, int value) { int32_t ret = -1; -- cgit v1.2.3-59-g8ed1b From 74179976b085398f5ad57b5d8aec8222e08e39dc Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Fri, 1 Nov 2019 11:53:32 -0700 Subject: drivers/staging/exfat: Replace more binary semaphores with mutexes At a slight footprint cost (24 vs 32 bytes), mutexes are more optimal than semaphores; it's also a nicer interface for mutual exclusion, which is why they are encouraged over binary semaphores, when possible. There is also lockdep support. For both f_sem and b_sem, their semantics imply traditional lock ownership; that is, the lock owner is the same for both lock/unlock operations and not under irq contexts (ie for trylock/unlock scenarios). Therefore it is safe to convert. Signed-off-by: Davidlohr Bueso Link: https://lore.kernel.org/r/20191101185332.31786-1-dave@stgolabs.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_cache.c | 48 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index e1b001718709..467b93630d86 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -12,8 +12,8 @@ #define DIRTYBIT 0x02 /* Local variables */ -static DEFINE_SEMAPHORE(f_sem); -static DEFINE_SEMAPHORE(b_sem); +static DEFINE_MUTEX(f_mutex); +static DEFINE_MUTEX(b_mutex); static struct buf_cache_t *FAT_cache_find(struct super_block *sb, sector_t sec) { @@ -315,9 +315,9 @@ int FAT_read(struct super_block *sb, u32 loc, u32 *content) { s32 ret; - down(&f_sem); + mutex_lock(&f_mutex); ret = __FAT_read(sb, loc, content); - up(&f_sem); + mutex_unlock(&f_mutex); return ret; } @@ -434,9 +434,9 @@ int FAT_write(struct super_block *sb, u32 loc, u32 content) { s32 ret; - down(&f_sem); + mutex_lock(&f_mutex); ret = __FAT_write(sb, loc, content); - up(&f_sem); + mutex_unlock(&f_mutex); return ret; } @@ -490,7 +490,7 @@ void FAT_release_all(struct super_block *sb) struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - down(&f_sem); + mutex_lock(&f_mutex); bp = p_fs->FAT_cache_lru_list.next; while (bp != &p_fs->FAT_cache_lru_list) { @@ -507,7 +507,7 @@ void FAT_release_all(struct super_block *sb) bp = bp->next; } - up(&f_sem); + mutex_unlock(&f_mutex); } void FAT_sync(struct super_block *sb) @@ -515,7 +515,7 @@ void FAT_sync(struct super_block *sb) struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - down(&f_sem); + mutex_lock(&f_mutex); bp = p_fs->FAT_cache_lru_list.next; while (bp != &p_fs->FAT_cache_lru_list) { @@ -526,7 +526,7 @@ void FAT_sync(struct super_block *sb) bp = bp->next; } - up(&f_sem); + mutex_unlock(&f_mutex); } static struct buf_cache_t *buf_cache_find(struct super_block *sb, sector_t sec) @@ -600,9 +600,9 @@ u8 *buf_getblk(struct super_block *sb, sector_t sec) { u8 *buf; - down(&b_sem); + mutex_lock(&b_mutex); buf = __buf_getblk(sb, sec); - up(&b_sem); + mutex_unlock(&b_mutex); return buf; } @@ -611,7 +611,7 @@ void buf_modify(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; - down(&b_sem); + mutex_lock(&b_mutex); bp = buf_cache_find(sb, sec); if (likely(bp)) @@ -620,14 +620,14 @@ void buf_modify(struct super_block *sb, sector_t sec) WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n", (unsigned long long)sec); - up(&b_sem); + mutex_unlock(&b_mutex); } void buf_lock(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; - down(&b_sem); + mutex_lock(&b_mutex); bp = buf_cache_find(sb, sec); if (likely(bp)) @@ -636,14 +636,14 @@ void buf_lock(struct super_block *sb, sector_t sec) WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n", (unsigned long long)sec); - up(&b_sem); + mutex_unlock(&b_mutex); } void buf_unlock(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; - down(&b_sem); + mutex_lock(&b_mutex); bp = buf_cache_find(sb, sec); if (likely(bp)) @@ -652,7 +652,7 @@ void buf_unlock(struct super_block *sb, sector_t sec) WARN(!bp, "[EXFAT] failed to find buffer_cache(sector:%llu).\n", (unsigned long long)sec); - up(&b_sem); + mutex_unlock(&b_mutex); } void buf_release(struct super_block *sb, sector_t sec) @@ -660,7 +660,7 @@ void buf_release(struct super_block *sb, sector_t sec) struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - down(&b_sem); + mutex_lock(&b_mutex); bp = buf_cache_find(sb, sec); if (likely(bp)) { @@ -676,7 +676,7 @@ void buf_release(struct super_block *sb, sector_t sec) move_to_lru(bp, &p_fs->buf_cache_lru_list); } - up(&b_sem); + mutex_unlock(&b_mutex); } void buf_release_all(struct super_block *sb) @@ -684,7 +684,7 @@ void buf_release_all(struct super_block *sb) struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - down(&b_sem); + mutex_lock(&b_mutex); bp = p_fs->buf_cache_lru_list.next; while (bp != &p_fs->buf_cache_lru_list) { @@ -701,7 +701,7 @@ void buf_release_all(struct super_block *sb) bp = bp->next; } - up(&b_sem); + mutex_unlock(&b_mutex); } void buf_sync(struct super_block *sb) @@ -709,7 +709,7 @@ void buf_sync(struct super_block *sb) struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - down(&b_sem); + mutex_lock(&b_mutex); bp = p_fs->buf_cache_lru_list.next; while (bp != &p_fs->buf_cache_lru_list) { @@ -720,5 +720,5 @@ void buf_sync(struct super_block *sb) bp = bp->next; } - up(&b_sem); + mutex_unlock(&b_mutex); } -- cgit v1.2.3-59-g8ed1b From 8b3f9afcca18787c82ba1b1ffc49c9aaee851c21 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Fri, 1 Nov 2019 23:21:54 +0000 Subject: staging: vt6655: Fix parameter alignment issues Fix alignment to match open parenthesis and comply in that way with the preferred coding style for the linux kernel. Issue found by checkpatch. Suggested-by: Julia Lawall Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/df2a5f511870bd96abb9b111de83f3a1f1d82d70.1572649242.git.frank@generalsoftwareinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.h | 2 +- drivers/staging/vt6655/device_main.c | 2 +- drivers/staging/vt6655/rxtx.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 887c1692e05b..25867cb9d13d 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -45,7 +45,7 @@ void CARDvSetRSPINF(struct vnt_private *priv, u8 bb_type); void CARDvUpdateBasicTopRate(struct vnt_private *priv); bool CARDbIsOFDMinBasicRate(struct vnt_private *priv); void CARDvSetLoopbackMode(struct vnt_private *priv, - unsigned short wLoopbackMode); + unsigned short wLoopbackMode); bool CARDbSoftwareReset(struct vnt_private *priv); void CARDvSetFirstNextTBTT(struct vnt_private *priv, unsigned short wBeaconInterval); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 082302944c37..2b93bea1f574 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -373,7 +373,7 @@ static void device_init_registers(struct vnt_private *priv) priv->bRadioOff = false; priv->byRadioCtl = SROMbyReadEmbedded(priv->PortOffset, - EEP_OFS_RADIOCTL); + EEP_OFS_RADIOCTL); priv->bHWRadioOff = false; if (priv->byRadioCtl & EEP_RADIOCTL_ENABLE) { diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index a14908895b9e..37fcc42ed000 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1289,7 +1289,7 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, current_rate = rate->hw_value; if (priv->wCurrentRate != current_rate && - !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { + !(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) { priv->wCurrentRate = current_rate; RFbSetPower(priv, priv->wCurrentRate, @@ -1396,7 +1396,8 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, tx_key = info->control.hw_key; if (tx_key->keylen > 0) vnt_fill_txkey(hdr, tx_buffer_head->tx_key, - tx_key, skb, tx_body_size, td_info->mic_hdr); + tx_key, skb, tx_body_size, + td_info->mic_hdr); } return 0; -- cgit v1.2.3-59-g8ed1b From ebacc1a7654f37b95545daf4ec282518eeabbfe4 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Fri, 1 Nov 2019 23:22:46 +0000 Subject: staging: vt6655: Fix the spacing around operators Add space around operators to comply in that way with the preferred coding style for the linux kernel. Issue found by checkpatch. Suggested-by: Julia Lawall Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/0f77b97e88c28c503caf25fafb84729509969ec3.1572649242.git.frank@generalsoftwareinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 6 +++--- drivers/staging/vt6655/rf.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 2b93bea1f574..be3883f10520 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -659,12 +659,12 @@ static int device_init_td0_ring(struct vnt_private *priv) desc->td_info->buf = priv->tx0_bufs + i * PKT_BUF_SZ; desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ; - desc->next = &(priv->apTD0Rings[(i+1) % priv->opts.tx_descs[0]]); + desc->next = &(priv->apTD0Rings[(i + 1) % priv->opts.tx_descs[0]]); desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc)); } if (i > 0) - priv->apTD0Rings[i-1].next_desc = cpu_to_le32(priv->td0_pool_dma); + priv->apTD0Rings[i - 1].next_desc = cpu_to_le32(priv->td0_pool_dma); priv->apTailTD[0] = priv->apCurrTD[0] = &priv->apTD0Rings[0]; return 0; @@ -704,7 +704,7 @@ static int device_init_td1_ring(struct vnt_private *priv) } if (i > 0) - priv->apTD1Rings[i-1].next_desc = cpu_to_le32(priv->td1_pool_dma); + priv->apTD1Rings[i - 1].next_desc = cpu_to_le32(priv->td1_pool_dma); priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0]; return 0; diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index e80fed69bafe..7cbc5bc4aad2 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -436,7 +436,7 @@ static bool s_bAL7230Init(struct vnt_private *priv) ret &= IFRFbWriteEmbedded(priv, (0x3ABA8F00 + (BY_AL7230_REG_LEN << 3) + IFREGCTL_REGW)); MACvTimer0MicroSDelay(priv, 30);/* 30us */ /* TXDCOC:disable, RCK:disable */ - ret &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[CB_AL7230_INIT_SEQ-1]); + ret &= IFRFbWriteEmbedded(priv, dwAL7230InitTable[CB_AL7230_INIT_SEQ - 1]); MACvWordRegBitsOn(iobase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 | SOFTPWRCTL_SWPE2 | @@ -558,7 +558,7 @@ static bool RFbAL2230Init(struct vnt_private *priv) MACvTimer0MicroSDelay(priv, 30);/* 30us */ ret &= IFRFbWriteEmbedded(priv, (0x00780f00 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW)); MACvTimer0MicroSDelay(priv, 30);/* 30us */ - ret &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[CB_AL2230_INIT_SEQ-1]); + ret &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[CB_AL2230_INIT_SEQ - 1]); MACvWordRegBitsOn(iobase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 | SOFTPWRCTL_SWPE2 | -- cgit v1.2.3-59-g8ed1b From 31d0c9d9b77df929c127198e43f106cb1cf0d9f4 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Fri, 1 Nov 2019 23:23:49 +0000 Subject: staging: vt6655: Fix open ended lines This commit arrange function declaration in one line to avoid lines ending with '(' and comply in that way with the preferred coding style for the linux kernel. Suggested-by: Julia Lawall Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/bdbc1d472a8d90487d691e82ab8154a5733e6a0f.1572649242.git.frank@generalsoftwareinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/power.c | 10 ++-------- drivers/staging/vt6655/rf.h | 19 +++++-------------- 2 files changed, 7 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 9725de3bca6a..bfd598a93b04 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -97,10 +97,7 @@ void PSvEnablePowerSaving(struct vnt_private *priv, * */ -void -PSvDisablePowerSaving( - struct vnt_private *priv -) +void PSvDisablePowerSaving(struct vnt_private *priv) { /* disable power saving hw function */ MACbPSWakeup(priv); @@ -126,10 +123,7 @@ PSvDisablePowerSaving( * */ -bool -PSbIsNextTBTTWakeUp( - struct vnt_private *priv -) +bool PSbIsNextTBTTWakeUp(struct vnt_private *priv) { struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &hw->conf; diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index 042ac67a9709..affb70eba10f 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -61,23 +61,14 @@ bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData); bool RFbSelectChannel(struct vnt_private *priv, unsigned char byRFType, u16 byChannel); -bool RFbInit( - struct vnt_private *priv -); +bool RFbInit(struct vnt_private *priv); bool RFvWriteWakeProgSyn(struct vnt_private *priv, unsigned char byRFType, u16 uChannel); bool RFbSetPower(struct vnt_private *priv, unsigned int rate, u16 uCH); -bool RFbRawSetPower( - struct vnt_private *priv, - unsigned char byPwr, - unsigned int rate -); +bool RFbRawSetPower(struct vnt_private *priv, unsigned char byPwr, + unsigned int rate); -void -RFvRSSITodBm( - struct vnt_private *priv, - unsigned char byCurrRSSI, - long *pldBm -); +void RFvRSSITodBm(struct vnt_private *priv, unsigned char byCurrRSSI, + long *pldBm); /* {{ RobertYu: 20050104 */ bool RFbAL7230SelectChannelPostProcess(struct vnt_private *priv, u16 byOldChannel, u16 byNewChannel); -- cgit v1.2.3-59-g8ed1b From 3bce4750c97d25befd3a7be4de14d58ecd79d420 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Fri, 1 Nov 2019 23:25:22 +0000 Subject: staging: vt6655: Fix long lines Lines longer than 80 characters should be avoided because they are ugly and harder to read. Fix a few of long lines to comply with the preferred coding style for the linux kernel. Issues found by checkpatch. Suggested-by: Julia Lawall Signed-off-by: Frank A. Cancio Bello Link: https://lore.kernel.org/r/588c73f275b22f55323797706e5ceae44d7aa160.1572649242.git.frank@generalsoftwareinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 6 ++++-- drivers/staging/vt6655/rf.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index be3883f10520..f69fc687d4c3 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -295,7 +295,8 @@ static void device_init_registers(struct vnt_private *priv) /* Get Desire Power Value */ priv->byCurPwr = 0xFF; priv->byCCKPwr = SROMbyReadEmbedded(priv->PortOffset, EEP_OFS_PWR_CCK); - priv->byOFDMPwrG = SROMbyReadEmbedded(priv->PortOffset, EEP_OFS_PWR_OFDMG); + priv->byOFDMPwrG = SROMbyReadEmbedded(priv->PortOffset, + EEP_OFS_PWR_OFDMG); /* Load power Table */ for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) { @@ -660,7 +661,8 @@ static int device_init_td0_ring(struct vnt_private *priv) desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ; desc->next = &(priv->apTD0Rings[(i + 1) % priv->opts.tx_descs[0]]); - desc->next_desc = cpu_to_le32(curr + sizeof(struct vnt_tx_desc)); + desc->next_desc = cpu_to_le32(curr + + sizeof(struct vnt_tx_desc)); } if (i > 0) diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 7cbc5bc4aad2..fb2855e686a7 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -558,7 +558,8 @@ static bool RFbAL2230Init(struct vnt_private *priv) MACvTimer0MicroSDelay(priv, 30);/* 30us */ ret &= IFRFbWriteEmbedded(priv, (0x00780f00 + (BY_AL2230_REG_LEN << 3) + IFREGCTL_REGW)); MACvTimer0MicroSDelay(priv, 30);/* 30us */ - ret &= IFRFbWriteEmbedded(priv, dwAL2230InitTable[CB_AL2230_INIT_SEQ - 1]); + ret &= IFRFbWriteEmbedded(priv, + dwAL2230InitTable[CB_AL2230_INIT_SEQ - 1]); MACvWordRegBitsOn(iobase, MAC_REG_SOFTPWRCTL, (SOFTPWRCTL_SWPE3 | SOFTPWRCTL_SWPE2 | -- cgit v1.2.3-59-g8ed1b From ed6daf2b2832d9b07582a6ff884039afa9063206 Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Fri, 1 Nov 2019 21:42:50 +0000 Subject: staging: axis-fifo: avoid parsing ignored device tree properties Some properties were parsed from the device tree and then ignored by the driver. Some would return an error if absent from the device tree, then return an error if they were found because they are unsupported by the driver. Avoid parsing unused properties and clearly explain in the documentation the ignored / unsupported properties. Signed-off-by: Quentin Deslandes Link: https://lore.kernel.org/r/20191101214232.16960-2-quentin.deslandes@itdev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/axis-fifo/axis-fifo.c | 247 ++++++++------------------------ drivers/staging/axis-fifo/axis-fifo.txt | 18 ++- 2 files changed, 74 insertions(+), 191 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 805437fa249a..b436f48a9d50 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -701,6 +701,68 @@ static int get_dts_property(struct axis_fifo *fifo, return 0; } +static int axis_fifo_parse_dt(struct axis_fifo *fifo) +{ + int ret; + unsigned int value; + + ret = get_dts_property(fifo, "xlnx,axi-str-rxd-tdata-width", &value); + if (ret) { + dev_err(fifo->dt_device, "missing xlnx,axi-str-rxd-tdata-width property\n"); + goto end; + } else if (value != 32) { + dev_err(fifo->dt_device, "xlnx,axi-str-rxd-tdata-width only supports 32 bits\n"); + ret = -EIO; + goto end; + } + + ret = get_dts_property(fifo, "xlnx,axi-str-txd-tdata-width", &value); + if (ret) { + dev_err(fifo->dt_device, "missing xlnx,axi-str-txd-tdata-width property\n"); + goto end; + } else if (value != 32) { + dev_err(fifo->dt_device, "xlnx,axi-str-txd-tdata-width only supports 32 bits\n"); + ret = -EIO; + goto end; + } + + ret = get_dts_property(fifo, "xlnx,rx-fifo-depth", + &fifo->rx_fifo_depth); + if (ret) { + dev_err(fifo->dt_device, "missing xlnx,rx-fifo-depth property\n"); + ret = -EIO; + goto end; + } + + ret = get_dts_property(fifo, "xlnx,tx-fifo-depth", + &fifo->tx_fifo_depth); + if (ret) { + dev_err(fifo->dt_device, "missing xlnx,tx-fifo-depth property\n"); + ret = -EIO; + goto end; + } + + /* IP sets TDFV to fifo depth - 4 so we will do the same */ + fifo->tx_fifo_depth -= 4; + + ret = get_dts_property(fifo, "xlnx,use-rx-data", &fifo->has_rx_fifo); + if (ret) { + dev_err(fifo->dt_device, "missing xlnx,use-rx-data property\n"); + ret = -EIO; + goto end; + } + + ret = get_dts_property(fifo, "xlnx,use-tx-data", &fifo->has_tx_fifo); + if (ret) { + dev_err(fifo->dt_device, "missing xlnx,use-tx-data property\n"); + ret = -EIO; + goto end; + } + +end: + return ret; +} + static int axis_fifo_probe(struct platform_device *pdev) { struct resource *r_irq; /* interrupt resources */ @@ -712,34 +774,6 @@ static int axis_fifo_probe(struct platform_device *pdev) int rc = 0; /* error return value */ - /* IP properties from device tree */ - unsigned int rxd_tdata_width; - unsigned int txc_tdata_width; - unsigned int txd_tdata_width; - unsigned int tdest_width; - unsigned int tid_width; - unsigned int tuser_width; - unsigned int data_interface_type; - unsigned int has_tdest; - unsigned int has_tid; - unsigned int has_tkeep; - unsigned int has_tstrb; - unsigned int has_tuser; - unsigned int rx_fifo_depth; - unsigned int rx_programmable_empty_threshold; - unsigned int rx_programmable_full_threshold; - unsigned int axi_id_width; - unsigned int axi4_data_width; - unsigned int select_xpm; - unsigned int tx_fifo_depth; - unsigned int tx_programmable_empty_threshold; - unsigned int tx_programmable_full_threshold; - unsigned int use_rx_cut_through; - unsigned int use_rx_data; - unsigned int use_tx_control; - unsigned int use_tx_cut_through; - unsigned int use_tx_data; - /* ---------------------------- * init wrapper device * ---------------------------- @@ -806,164 +840,9 @@ static int axis_fifo_probe(struct platform_device *pdev) * ---------------------------- */ - /* retrieve device tree properties */ - rc = get_dts_property(fifo, "xlnx,axi-str-rxd-tdata-width", - &rxd_tdata_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,axi-str-txc-tdata-width", - &txc_tdata_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,axi-str-txd-tdata-width", - &txd_tdata_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,axis-tdest-width", &tdest_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,axis-tid-width", &tid_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,axis-tuser-width", &tuser_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,data-interface-type", - &data_interface_type); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,has-axis-tdest", &has_tdest); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,has-axis-tid", &has_tid); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,has-axis-tkeep", &has_tkeep); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,has-axis-tstrb", &has_tstrb); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,has-axis-tuser", &has_tuser); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,rx-fifo-depth", &rx_fifo_depth); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,rx-fifo-pe-threshold", - &rx_programmable_empty_threshold); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,rx-fifo-pf-threshold", - &rx_programmable_full_threshold); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,s-axi-id-width", &axi_id_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,s-axi4-data-width", &axi4_data_width); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,select-xpm", &select_xpm); + rc = axis_fifo_parse_dt(fifo); if (rc) goto err_unmap; - rc = get_dts_property(fifo, "xlnx,tx-fifo-depth", &tx_fifo_depth); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,tx-fifo-pe-threshold", - &tx_programmable_empty_threshold); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,tx-fifo-pf-threshold", - &tx_programmable_full_threshold); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,use-rx-cut-through", - &use_rx_cut_through); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,use-rx-data", &use_rx_data); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,use-tx-ctrl", &use_tx_control); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,use-tx-cut-through", - &use_tx_cut_through); - if (rc) - goto err_unmap; - rc = get_dts_property(fifo, "xlnx,use-tx-data", &use_tx_data); - if (rc) - goto err_unmap; - - /* check validity of device tree properties */ - if (rxd_tdata_width != 32) { - dev_err(fifo->dt_device, - "rxd_tdata_width width [%u] unsupported\n", - rxd_tdata_width); - rc = -EIO; - goto err_unmap; - } - if (txd_tdata_width != 32) { - dev_err(fifo->dt_device, - "txd_tdata_width width [%u] unsupported\n", - txd_tdata_width); - rc = -EIO; - goto err_unmap; - } - if (has_tdest) { - dev_err(fifo->dt_device, "tdest not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (has_tid) { - dev_err(fifo->dt_device, "tid not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (has_tkeep) { - dev_err(fifo->dt_device, "tkeep not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (has_tstrb) { - dev_err(fifo->dt_device, "tstrb not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (has_tuser) { - dev_err(fifo->dt_device, "tuser not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (use_rx_cut_through) { - dev_err(fifo->dt_device, "rx cut-through not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (use_tx_cut_through) { - dev_err(fifo->dt_device, "tx cut-through not supported\n"); - rc = -EIO; - goto err_unmap; - } - if (use_tx_control) { - dev_err(fifo->dt_device, "tx control not supported\n"); - rc = -EIO; - goto err_unmap; - } - - /* TODO - * these exist in the device tree but it's unclear what they do - * - select-xpm - * - data-interface-type - */ - - /* set device wrapper properties based on IP config */ - fifo->rx_fifo_depth = rx_fifo_depth; - /* IP sets TDFV to fifo depth - 4 so we will do the same */ - fifo->tx_fifo_depth = tx_fifo_depth - 4; - fifo->has_rx_fifo = use_rx_data; - fifo->has_tx_fifo = use_tx_data; reset_ip_core(fifo); diff --git a/drivers/staging/axis-fifo/axis-fifo.txt b/drivers/staging/axis-fifo/axis-fifo.txt index 85d88c010e72..5828e1b8e822 100644 --- a/drivers/staging/axis-fifo/axis-fifo.txt +++ b/drivers/staging/axis-fifo/axis-fifo.txt @@ -25,10 +25,10 @@ Required properties: - xlnx,axi-str-txc-tdata-width: Should be <0x20> - xlnx,axi-str-txd-protocol: Should be "XIL_AXI_STREAM_ETH_DATA" - xlnx,axi-str-txd-tdata-width: Should be <0x20> -- xlnx,axis-tdest-width: AXI-Stream TDEST width -- xlnx,axis-tid-width: AXI-Stream TID width -- xlnx,axis-tuser-width: AXI-Stream TUSER width -- xlnx,data-interface-type: Should be <0x0> +- xlnx,axis-tdest-width: AXI-Stream TDEST width (ignored by the driver) +- xlnx,axis-tid-width: AXI-Stream TID width (ignored by the driver) +- xlnx,axis-tuser-width: AXI-Stream TUSER width (ignored by the driver) +- xlnx,data-interface-type: Should be <0x0> (ignored by the driver) - xlnx,has-axis-tdest: Should be <0x0> (this feature isn't supported) - xlnx,has-axis-tid: Should be <0x0> (this feature isn't supported) - xlnx,has-axis-tkeep: Should be <0x0> (this feature isn't supported) @@ -36,13 +36,17 @@ Required properties: - xlnx,has-axis-tuser: Should be <0x0> (this feature isn't supported) - xlnx,rx-fifo-depth: Depth of RX FIFO in words - xlnx,rx-fifo-pe-threshold: RX programmable empty interrupt threshold + (ignored by the driver) - xlnx,rx-fifo-pf-threshold: RX programmable full interrupt threshold -- xlnx,s-axi-id-width: Should be <0x4> -- xlnx,s-axi4-data-width: Should be <0x20> -- xlnx,select-xpm: Should be <0x0> + (ignored by the driver) +- xlnx,s-axi-id-width: Should be <0x4> (ignored by the driver) +- xlnx,s-axi4-data-width: Should be <0x20> (ignored by the driver) +- xlnx,select-xpm: Should be <0x0> (ignored by the driver) - xlnx,tx-fifo-depth: Depth of TX FIFO in words - xlnx,tx-fifo-pe-threshold: TX programmable empty interrupt threshold + (ignored by the driver) - xlnx,tx-fifo-pf-threshold: TX programmable full interrupt threshold + (ignored by the driver) - xlnx,use-rx-cut-through: Should be <0x0> (this feature isn't supported) - xlnx,use-rx-data: <0x1> if RX FIFO is enabled, <0x0> otherwise - xlnx,use-tx-ctrl: Should be <0x0> (this feature isn't supported) -- cgit v1.2.3-59-g8ed1b From 6a20d283ed68670e9301c4a951ea84fefbb2df53 Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Fri, 1 Nov 2019 21:42:54 +0000 Subject: staging: axis-fifo: request resources using managed functions Request device's resources (memory, interrupt...) using managed function. Signed-off-by: Quentin Deslandes Link: https://lore.kernel.org/r/20191101214232.16960-3-quentin.deslandes@itdev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/axis-fifo/axis-fifo.c | 45 ++++++++++------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index b436f48a9d50..2e6e2f149a26 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -809,24 +809,13 @@ static int axis_fifo_probe(struct platform_device *pdev) fifo->mem = r_mem; /* request physical memory */ - if (!request_mem_region(fifo->mem->start, resource_size(fifo->mem), - DRIVER_NAME)) { - dev_err(fifo->dt_device, - "couldn't lock memory region at 0x%pa\n", - &fifo->mem->start); - rc = -EBUSY; + fifo->base_addr = devm_ioremap_resource(fifo->dt_device, fifo->mem); + if (IS_ERR(fifo->base_addr)) { + rc = PTR_ERR(fifo->base_addr); + dev_err(fifo->dt_device, "can't remap IO resource (%d)\n", rc); goto err_initial; } - dev_dbg(fifo->dt_device, "got memory location [0x%pa - 0x%pa]\n", - &fifo->mem->start, &fifo->mem->end); - - /* map physical memory to kernel virtual address space */ - fifo->base_addr = ioremap(fifo->mem->start, resource_size(fifo->mem)); - if (!fifo->base_addr) { - dev_err(fifo->dt_device, "couldn't map physical memory\n"); - rc = -ENOMEM; - goto err_mem; - } + dev_dbg(fifo->dt_device, "remapped memory to 0x%p\n", fifo->base_addr); /* create unique device name */ @@ -842,7 +831,7 @@ static int axis_fifo_probe(struct platform_device *pdev) rc = axis_fifo_parse_dt(fifo); if (rc) - goto err_unmap; + goto err_initial; reset_ip_core(fifo); @@ -857,16 +846,17 @@ static int axis_fifo_probe(struct platform_device *pdev) dev_err(fifo->dt_device, "no IRQ found for 0x%pa\n", &fifo->mem->start); rc = -EIO; - goto err_unmap; + goto err_initial; } /* request IRQ */ fifo->irq = r_irq->start; - rc = request_irq(fifo->irq, &axis_fifo_irq, 0, DRIVER_NAME, fifo); + rc = devm_request_irq(fifo->dt_device, fifo->irq, &axis_fifo_irq, 0, + DRIVER_NAME, fifo); if (rc) { dev_err(fifo->dt_device, "couldn't allocate interrupt %i\n", fifo->irq); - goto err_unmap; + goto err_initial; } /* ---------------------------- @@ -877,7 +867,7 @@ static int axis_fifo_probe(struct platform_device *pdev) /* allocate device number */ rc = alloc_chrdev_region(&fifo->devt, 0, 1, DRIVER_NAME); if (rc < 0) - goto err_irq; + goto err_initial; dev_dbg(fifo->dt_device, "allocated device number major %i minor %i\n", MAJOR(fifo->devt), MINOR(fifo->devt)); @@ -901,7 +891,7 @@ static int axis_fifo_probe(struct platform_device *pdev) } /* create sysfs entries */ - rc = sysfs_create_group(&fifo->device->kobj, &axis_fifo_attrs_group); + rc = devm_device_add_group(fifo->device, &axis_fifo_attrs_group); if (rc < 0) { dev_err(fifo->dt_device, "couldn't register sysfs group\n"); goto err_cdev; @@ -919,12 +909,6 @@ err_dev: device_destroy(axis_fifo_driver_class, fifo->devt); err_chrdev_region: unregister_chrdev_region(fifo->devt, 1); -err_irq: - free_irq(fifo->irq, fifo); -err_unmap: - iounmap(fifo->base_addr); -err_mem: - release_mem_region(fifo->mem->start, resource_size(fifo->mem)); err_initial: dev_set_drvdata(dev, NULL); return rc; @@ -935,15 +919,12 @@ static int axis_fifo_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; struct axis_fifo *fifo = dev_get_drvdata(dev); - sysfs_remove_group(&fifo->device->kobj, &axis_fifo_attrs_group); cdev_del(&fifo->char_device); dev_set_drvdata(fifo->device, NULL); device_destroy(axis_fifo_driver_class, fifo->devt); unregister_chrdev_region(fifo->devt, 1); - free_irq(fifo->irq, fifo); - iounmap(fifo->base_addr); - release_mem_region(fifo->mem->start, resource_size(fifo->mem)); dev_set_drvdata(dev, NULL); + return 0; } -- cgit v1.2.3-59-g8ed1b From 354e27a86b4c6479cbc51a8e9e347665a73e8d12 Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Fri, 1 Nov 2019 21:42:59 +0000 Subject: staging: axis-fifo: remove unused pointer to memory resource Remove unused resource pointer from the device's internal structure. Signed-off-by: Quentin Deslandes Link: https://lore.kernel.org/r/20191101214232.16960-4-quentin.deslandes@itdev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/axis-fifo/axis-fifo.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index 2e6e2f149a26..39e6c59df1e9 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -125,7 +125,6 @@ MODULE_PARM_DESC(write_timeout, "ms to wait before blocking write() timing out; struct axis_fifo { int irq; /* interrupt */ - struct resource *mem; /* physical memory */ void __iomem *base_addr; /* kernel space memory */ unsigned int rx_fifo_depth; /* max words in the receive fifo */ @@ -806,10 +805,8 @@ static int axis_fifo_probe(struct platform_device *pdev) goto err_initial; } - fifo->mem = r_mem; - /* request physical memory */ - fifo->base_addr = devm_ioremap_resource(fifo->dt_device, fifo->mem); + fifo->base_addr = devm_ioremap_resource(fifo->dt_device, r_mem); if (IS_ERR(fifo->base_addr)) { rc = PTR_ERR(fifo->base_addr); dev_err(fifo->dt_device, "can't remap IO resource (%d)\n", rc); @@ -820,7 +817,7 @@ static int axis_fifo_probe(struct platform_device *pdev) /* create unique device name */ snprintf(device_name, sizeof(device_name), "%s_%pa", - DRIVER_NAME, &fifo->mem->start); + DRIVER_NAME, &r_mem->start); dev_dbg(fifo->dt_device, "device name [%s]\n", device_name); @@ -844,7 +841,7 @@ static int axis_fifo_probe(struct platform_device *pdev) r_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!r_irq) { dev_err(fifo->dt_device, "no IRQ found for 0x%pa\n", - &fifo->mem->start); + &r_mem->start); rc = -EIO; goto err_initial; } @@ -898,7 +895,7 @@ static int axis_fifo_probe(struct platform_device *pdev) } dev_info(fifo->dt_device, "axis-fifo created at %pa mapped to 0x%pa, irq=%i, major=%i, minor=%i\n", - &fifo->mem->start, &fifo->base_addr, fifo->irq, + &r_mem->start, &fifo->base_addr, fifo->irq, MAJOR(fifo->devt), MINOR(fifo->devt)); return 0; -- cgit v1.2.3-59-g8ed1b From 8a4e640eb7f65dd643b77a0297ca244ef29cc1fa Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Sat, 2 Nov 2019 04:06:32 +0000 Subject: staging: exfat: Fix parameter alignment issues Fix alignment to match open parenthesis to comply in that way with the preferred coding style for the linux kernel. Issue found by checkpatch. Suggested-by: Julia Lawall Signed-off-by: Frank A. Cancio Bello Acked-by: Julia Lawall Link: https://lore.kernel.org/r/fe316e694ea9c4aa370d3a8166a3680feb342682.1572666556.git.frank@generalsoftwareinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index f4f82aecc05d..b23fbf3ebaa5 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -1503,7 +1503,7 @@ void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, } void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries) + s32 entry, s32 order, s32 num_entries) { int i; sector_t sector; @@ -1919,7 +1919,8 @@ s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) /* write back some entries in entry set */ s32 write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, struct dentry_t *ep, u32 count) + struct entry_set_cache_t *es, + struct dentry_t *ep, u32 count) { s32 ret, byte_offset, off; u32 clu = 0; -- cgit v1.2.3-59-g8ed1b From d3baf1e0b2fefa9433e8d299541cf451e59c5709 Mon Sep 17 00:00:00 2001 From: "Frank A. Cancio Bello" Date: Sat, 2 Nov 2019 04:06:54 +0000 Subject: staging: exfat: Fix logical operation continuation Operators inside a multiline logical expression should be at the end of the line not at the beginning. This patch fixes two of those cases and remove an unnecessary parenthesis too, to comply in that way with the preferred coding style for the linux kernel. Suggested-by: Julia Lawall Signed-off-by: Frank A. Cancio Bello Acked-by: Julia Lawall Link: https://lore.kernel.org/r/ace2cbd5e4c03751fb522e7bbd60149e7ed969ae.1572666556.git.frank@generalsoftwareinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 77984a73ba6e..5f972588669c 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -2980,8 +2980,8 @@ static int exfat_setattr(struct dentry *dentry, struct iattr *attr) pr_debug("%s entered\n", __func__); - if ((attr->ia_valid & ATTR_SIZE) - && (attr->ia_size > i_size_read(inode))) { + if ((attr->ia_valid & ATTR_SIZE) && + attr->ia_size > i_size_read(inode)) { error = exfat_cont_expand(inode, attr->ia_size); if (error || attr->ia_valid == ATTR_SIZE) return error; @@ -2990,8 +2990,8 @@ static int exfat_setattr(struct dentry *dentry, struct iattr *attr) ia_valid = attr->ia_valid; - if ((ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) - && exfat_allow_set_time(sbi, inode)) { + if ((ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) && + exfat_allow_set_time(sbi, inode)) { attr->ia_valid &= ~(ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET); -- cgit v1.2.3-59-g8ed1b From 1878c5b91430d38a0beefd0dc5cb6035913ebc7f Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sat, 2 Nov 2019 16:59:45 +0100 Subject: staging: wfx: Fix a memory leak in 'wfx_upload_beacon' The current code is a no-op, because all it can do is 'dev_kfree_skb(NULL)' Remove the test before 'dev_kfree_skb()' Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/20191102155945.20205-1-christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/sta.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 688586e823c0..93f3739b5f3a 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -906,8 +906,7 @@ static int wfx_upload_beacon(struct wfx_vif *wvif) wfx_fwd_probe_req(wvif, false); done: - if (!skb) - dev_kfree_skb(skb); + dev_kfree_skb(skb); return ret; } -- cgit v1.2.3-59-g8ed1b From 19c1e145a436ac316f1556ebc229f08f333bc60c Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Sat, 2 Nov 2019 17:49:28 -0500 Subject: staging: rtl8723bs: Remove unnecessary parentheses This patch removes unnecessary parentheses. Issue found by checkpatch Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/b2526b464b8afed3b2c3a3a72ae183fb63df3ae7.1572734925.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 62 +++++++++++++++---------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 6d193f137b7e..b75781841e87 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -89,7 +89,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe = (struct xmit_frame *) pxmitpriv->pxmit_frame_buf; for (i = 0; i < NR_XMITFRAME; i++) { - INIT_LIST_HEAD(&(pxframe->list)); + INIT_LIST_HEAD(&pxframe->list); pxframe->padapter = padapter; pxframe->frame_tag = NULL_FRAMETAG; @@ -99,7 +99,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; - list_add_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); + list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue); pxframe++; } @@ -150,7 +150,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->flags = XMIT_VO_QUEUE; - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue); #ifdef DBG_XMIT_BUF pxmitbuf->no = i; #endif @@ -176,7 +176,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe = (struct xmit_frame *)pxmitpriv->xframe_ext; for (i = 0; i < NR_XMIT_EXTBUFF; i++) { - INIT_LIST_HEAD(&(pxframe->list)); + INIT_LIST_HEAD(&pxframe->list); pxframe->padapter = padapter; pxframe->frame_tag = NULL_FRAMETAG; @@ -188,7 +188,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe->ext_tag = 1; - list_add_tail(&(pxframe->list), &(pxmitpriv->free_xframe_ext_queue.queue)); + list_add_tail(&pxframe->list, &pxmitpriv->free_xframe_ext_queue.queue); pxframe++; } @@ -227,7 +227,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->len = 0; pxmitbuf->pdata = pxmitbuf->ptail = pxmitbuf->phead; - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); #ifdef DBG_XMIT_BUF_EXT pxmitbuf->no = i; #endif @@ -372,8 +372,8 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * u32 sz; struct pkt_attrib *pattrib = &pxmitframe->attrib; /* struct sta_info *psta = pattrib->psta; */ - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pattrib->nr_frags != 1) sz = padapter->xmitpriv.frag_len; @@ -955,7 +955,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum =%d length =%d pattrib->icv_len =%d", curfragnum, length, pattrib->icv_len)); } } - rtw_secgetmic(&micdata, &(mic[0])); + rtw_secgetmic(&micdata, &mic[0]); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz =%d!!!\n", pattrib->last_txcmdsz)); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]= 0x%.2x , mic[1]= 0x%.2x , mic[2]= 0x%.2x , mic[3]= 0x%.2x\n\ @@ -963,7 +963,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7])); /* add mic code and add the mic code length in last_txcmdsz */ - memcpy(payload, &(mic[0]), 8); + memcpy(payload, &mic[0], 8); pattrib->last_txcmdsz += 8; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ========last pkt ========\n")); @@ -1029,7 +1029,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr SetFrameSubType(fctrl, pattrib->subtype); if (pattrib->subtype & WIFI_DATA_TYPE) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { /* to_ds = 1, fr_ds = 0; */ { @@ -1044,7 +1044,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr if (pqospriv->qos_option) qos_option = true; - } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { /* to_ds = 0, fr_ds = 1; */ SetFrDs(fctrl); memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); @@ -1409,7 +1409,7 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit pmlmeext->mgnt_80211w_IPN++; /* add MME IE with MIC all zero, MME string doesn't include element id and length */ - pframe = rtw_set_ie(pframe, _MME_IE_, 16, MME, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _MME_IE_, 16, MME, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; /* total frame length - header length */ frame_body_len = pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr); @@ -1687,7 +1687,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); - list_del_init(&(pxmitbuf->list)); + list_del_init(&pxmitbuf->list); } if (pxmitbuf) { @@ -1727,7 +1727,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue)); pxmitpriv->free_xmit_extbuf_cnt++; #ifdef DBG_XMIT_BUF_EXT DBG_871X("DBG_XMIT_BUF_EXT FREE no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt); @@ -1759,7 +1759,7 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); - list_del_init(&(pxmitbuf->list)); + list_del_init(&pxmitbuf->list); } if (pxmitbuf) { @@ -1814,7 +1814,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); + list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue)); pxmitpriv->free_xmitbuf_cnt++; /* DBG_871X("FREE, free_xmitbuf_cnt =%d\n", pxmitpriv->free_xmitbuf_cnt); */ @@ -1878,7 +1878,7 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); - list_del_init(&(pxframe->list)); + list_del_init(&pxframe->list); pxmitpriv->free_xmitframe_cnt--; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt =%d\n", pxmitpriv->free_xmitframe_cnt)); } @@ -1905,7 +1905,7 @@ struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv) plist = get_next(phead); pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); - list_del_init(&(pxframe->list)); + list_del_init(&pxframe->list); pxmitpriv->free_xframe_ext_cnt--; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe_ext():free_xmitframe_cnt =%d\n", pxmitpriv->free_xframe_ext_cnt)); } @@ -2005,7 +2005,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram struct list_head *plist, *phead; struct xmit_frame *pxmitframe; - spin_lock_bh(&(pframequeue->lock)); + spin_lock_bh(&pframequeue->lock); phead = get_list_head(pframequeue); plist = get_next(phead); @@ -2019,7 +2019,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram rtw_free_xmitframe(pxmitpriv, pxmitframe); } - spin_unlock_bh(&(pframequeue->lock)); + spin_unlock_bh(&pframequeue->lock); } s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) @@ -2042,21 +2042,21 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * switch (up) { case 1: case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); + ptxservq = &psta->sta_xmitpriv.bk_q; *(ac) = 3; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); break; case 4: case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); + ptxservq = &psta->sta_xmitpriv.vi_q; *(ac) = 1; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); break; case 6: case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); + ptxservq = &psta->sta_xmitpriv.vo_q; *(ac) = 0; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); break; @@ -2064,7 +2064,7 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * case 0: case 3: default: - ptxservq = &(psta->sta_xmitpriv.be_q); + ptxservq = &psta->sta_xmitpriv.be_q; *(ac) = 2; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); break; @@ -2600,24 +2600,24 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); - list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&pstaxmitpriv->vo_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); - list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&pstaxmitpriv->vi_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); - list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&pstaxmitpriv->bk_q.tx_pending); /* for BC/MC Frames */ pstaxmitpriv = &psta_bmc->sta_xmitpriv; dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); spin_unlock_bh(&pxmitpriv->lock); } @@ -2863,7 +2863,7 @@ void enqueue_pending_xmitbuf( list_add_tail(&pxmitbuf->list, get_list_head(pqueue)); spin_unlock_bh(&pqueue->lock); - complete(&(pri_adapter->xmitpriv.xmit_comp)); + complete(&pri_adapter->xmitpriv.xmit_comp); } void enqueue_pending_xmitbuf_to_head( -- cgit v1.2.3-59-g8ed1b From 6647e4e84501e7f935f108729da9a6fd60924d8b Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Sun, 3 Nov 2019 10:09:21 -0800 Subject: staging: exfat: Ensure we unlock upon error in ffsReadFile The call was not releasing the mutex upon error. Reported-by: kbuild test robot Reported-by: Julia Lawall Signed-off-by: Davidlohr Bueso Acked-By: Valdis Kletnieks Link: https://lore.kernel.org/r/20191103180921.2844-1-dave@stgolabs.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 5f972588669c..1ae5a7750348 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -743,8 +743,10 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, while (clu_offset > 0) { /* clu = FAT_read(sb, clu); */ - if (FAT_read(sb, clu, &clu) == -1) - return FFS_MEDIAERR; + if (FAT_read(sb, clu, &clu) == -1) { + ret = FFS_MEDIAERR; + goto out; + } clu_offset--; } -- cgit v1.2.3-59-g8ed1b From 3b525cb00c620269e07663788bfd727c07524bf9 Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Mon, 4 Nov 2019 23:54:18 -0800 Subject: staging: qlge: Avoid NULL comparison Replace NULL comparison with boolean negation. Issue found using checkpatch.pl Signed-off-by: Nachammai Karuppiah Acked-by: Julia Lawall Link: https://lore.kernel.org/r/1572940458-109252-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 4 ++-- drivers/staging/qlge/qlge_main.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 019b7e6a1b7a..83f34ca43aa4 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1649,7 +1649,7 @@ void ql_dump_wqicb(struct wqicb *wqicb) void ql_dump_tx_ring(struct tx_ring *tx_ring) { - if (tx_ring == NULL) + if (!tx_ring) return; pr_err("===================== Dumping tx_ring %d ===============\n", tx_ring->wq_id); @@ -1741,7 +1741,7 @@ static const char *qlge_rx_ring_type_name(struct rx_ring *rx_ring) void ql_dump_rx_ring(struct rx_ring *rx_ring) { - if (rx_ring == NULL) + if (!rx_ring) return; pr_err("===================== Dumping rx_ring %d ===============\n", rx_ring->cq_id); diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 6f6b4c06688c..6ad4515311f7 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1588,7 +1588,7 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, skb = sbq_desc->p.skb; /* Allocate new_skb and copy */ new_skb = netdev_alloc_skb(qdev->ndev, length + NET_IP_ALIGN); - if (new_skb == NULL) { + if (!new_skb) { rx_ring->rx_dropped++; return; } @@ -1792,7 +1792,7 @@ static struct sk_buff *ql_build_rx_skb(struct ql_adapter *qdev, */ lbq_desc = ql_get_curr_lchunk(qdev, rx_ring); skb = netdev_alloc_skb(qdev->ndev, length); - if (skb == NULL) { + if (!skb) { netif_printk(qdev, probe, KERN_DEBUG, qdev->ndev, "No skb available, drop the packet.\n"); return NULL; @@ -2663,7 +2663,7 @@ static int ql_alloc_shadow_space(struct ql_adapter *qdev) qdev->rx_ring_shadow_reg_area = pci_zalloc_consistent(qdev->pdev, PAGE_SIZE, &qdev->rx_ring_shadow_reg_dma); - if (qdev->rx_ring_shadow_reg_area == NULL) { + if (!qdev->rx_ring_shadow_reg_area) { netif_err(qdev, ifup, qdev->ndev, "Allocation of RX shadow space failed.\n"); return -ENOMEM; @@ -2672,7 +2672,7 @@ static int ql_alloc_shadow_space(struct ql_adapter *qdev) qdev->tx_ring_shadow_reg_area = pci_zalloc_consistent(qdev->pdev, PAGE_SIZE, &qdev->tx_ring_shadow_reg_dma); - if (qdev->tx_ring_shadow_reg_area == NULL) { + if (!qdev->tx_ring_shadow_reg_area) { netif_err(qdev, ifup, qdev->ndev, "Allocation of TX shadow space failed.\n"); goto err_wqp_sh_area; @@ -2724,14 +2724,14 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev, pci_alloc_consistent(qdev->pdev, tx_ring->wq_size, &tx_ring->wq_base_dma); - if ((tx_ring->wq_base == NULL) || + if (!tx_ring->wq_base || tx_ring->wq_base_dma & WQ_ADDR_ALIGN) goto pci_alloc_err; tx_ring->q = kmalloc_array(tx_ring->wq_len, sizeof(struct tx_ring_desc), GFP_KERNEL); - if (tx_ring->q == NULL) + if (!tx_ring->q) goto err; return 0; @@ -2778,7 +2778,7 @@ static void ql_free_sbq_buffers(struct ql_adapter *qdev, struct rx_ring *rx_ring for (i = 0; i < QLGE_BQ_LEN; i++) { struct qlge_bq_desc *sbq_desc = &rx_ring->sbq.queue[i]; - if (sbq_desc == NULL) { + if (!sbq_desc) { netif_err(qdev, ifup, qdev->ndev, "sbq_desc %d is NULL.\n", i); return; @@ -2899,7 +2899,7 @@ static int ql_alloc_rx_resources(struct ql_adapter *qdev, pci_alloc_consistent(qdev->pdev, rx_ring->cq_size, &rx_ring->cq_base_dma); - if (rx_ring->cq_base == NULL) { + if (!rx_ring->cq_base) { netif_err(qdev, ifup, qdev->ndev, "rx_ring alloc failed.\n"); return -ENOMEM; } @@ -4485,7 +4485,7 @@ static int ql_init_device(struct pci_dev *pdev, struct net_device *ndev, if (qlge_mpi_coredump) { qdev->mpi_coredump = vmalloc(sizeof(struct ql_mpi_coredump)); - if (qdev->mpi_coredump == NULL) { + if (!qdev->mpi_coredump) { err = -ENOMEM; goto err_out2; } -- cgit v1.2.3-59-g8ed1b From 2c1facbc437ceb00b022e4484900c831e39a773a Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Tue, 5 Nov 2019 01:03:51 +0000 Subject: staging: wfx: replace 0 by NULL Replace 0 by NULL as the return value of a pointer-returning function. Issue detected by sparse tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191105010352.222479-2-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index ef3ee55cf621..5d29bce65f71 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -565,7 +565,7 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) } if (ret) - return 0; + return NULL; queue_num = queue - wdev->tx_queue; -- cgit v1.2.3-59-g8ed1b From 168c7d76425d053ca6a311e450ac3627cffff5a7 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Tue, 5 Nov 2019 01:03:52 +0000 Subject: staging: wfx: replace 1 by true Replace 1 by true when it is stored in a boolean variable. Recommended by coccinelle tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191105010352.222479-3-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/queue.c | 2 +- drivers/staging/wfx/sta.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 5d29bce65f71..71e92744fed0 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -550,7 +550,7 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) spin_unlock_bh(&wvif->ps_state_lock); if (vif_more) { - more = 1; + more = true; tx_allowed_mask = vif_tx_allowed_mask; queue = vif_queue; ret = 0; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 93f3739b5f3a..70a00b84ac5f 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -291,7 +291,7 @@ u64 wfx_prepare_multicast(struct ieee80211_hw *hw, struct netdev_hw_addr_list *m ether_addr_copy(wvif->mcast_filter.address_list[i], ha->addr); i++; } - wvif->mcast_filter.enable = 1; + wvif->mcast_filter.enable = true; wvif->mcast_filter.num_addresses = count; } -- cgit v1.2.3-59-g8ed1b From 78ce93f3e80bf8dff320a6d084c9933e81aa4a3f Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Tue, 5 Nov 2019 01:21:31 -0800 Subject: staging: wfx: Remove local variable used only in return statement. Remove unnecessary local variable that is used in return statement and return the expression directly. Issue found using coccinelle. Signed-off-by: Nachammai Karuppiah Link: https://lore.kernel.org/r/1572945691-109992-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/sta.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 70a00b84ac5f..2ab5ba9742ad 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -114,8 +114,6 @@ end: static int wfx_set_uapsd_param(struct wfx_vif *wvif, const struct wfx_edca_params *arg) { - int ret; - /* Here's the mapping AC [queue, bit] * VO [0,3], VI [1, 2], BE [2, 1], BK [3, 0] */ @@ -148,8 +146,7 @@ static int wfx_set_uapsd_param(struct wfx_vif *wvif, wvif->uapsd_info.max_auto_trigger_interval = 0; wvif->uapsd_info.auto_trigger_step = 0; - ret = hif_set_uapsd_info(wvif, &wvif->uapsd_info); - return ret; + return hif_set_uapsd_info(wvif, &wvif->uapsd_info); } int wfx_fwd_probe_req(struct wfx_vif *wvif, bool enable) -- cgit v1.2.3-59-g8ed1b From b7aa39a2ed0112d07fc277ebd24a08a7b2368ab9 Mon Sep 17 00:00:00 2001 From: Pan Bian Date: Tue, 5 Nov 2019 22:49:11 +0800 Subject: staging: rtl8192e: fix potential use after free The variable skb is released via kfree_skb() when the return value of _rtl92e_tx is not zero. However, after that, skb is accessed again to read its length, which may result in a use after free bug. This patch fixes the bug by moving the release operation to where skb is never used later. Signed-off-by: Pan Bian Reviewed-by: Dan Carpenter Cc: stable Link: https://lore.kernel.org/r/1572965351-6745-1-git-send-email-bianpan2016@163.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index b08712a9c029..dace81a7d1ba 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1616,14 +1616,15 @@ static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); skb_push(skb, priv->rtllib->tx_headroom); ret = _rtl92e_tx(dev, skb); - if (ret != 0) - kfree_skb(skb); if (queue_index != MGNT_QUEUE) { priv->rtllib->stats.tx_bytes += (skb->len - priv->rtllib->tx_headroom); priv->rtllib->stats.tx_packets++; } + + if (ret != 0) + kfree_skb(skb); } static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) -- cgit v1.2.3-59-g8ed1b From 55238d7a468d5328a0f7b7155ea8855f158cbcc5 Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Mon, 4 Nov 2019 20:51:23 -0800 Subject: staging: rtl8723bs: os_dep: Remove unnecessary variable used in return statement Remove the variable that is used only in return statement and return the expression itself. Issue found using coccinelle. Signed-off-by: Nachammai Karuppiah Link: https://lore.kernel.org/r/1572929483-78993-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index a25c535b6b4f..52c1f6625038 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2440,7 +2440,6 @@ void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct net_device *ndev) { - int ret = 0; int rtap_len; int qos_len = 0; int dot11_hdr_len = 24; @@ -2506,9 +2505,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc DBG_8192C("should be eapol packet\n"); /* Use the real net device to transmit the packet */ - ret = _rtw_xmit_entry(skb, padapter->pnetdev); - - return ret; + return _rtw_xmit_entry(skb, padapter->pnetdev); } else if ((frame_control & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)) @@ -2815,14 +2812,11 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_beacon_data *info) { - int ret = 0; struct adapter *adapter = (struct adapter *)rtw_netdev_priv(ndev); DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); - ret = rtw_add_beacon(adapter, info->head, info->head_len, info->tail, info->tail_len); - - return ret; + return rtw_add_beacon(adapter, info->head, info->head_len, info->tail, info->tail_len); } static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) -- cgit v1.2.3-59-g8ed1b From 8888ed03237d07d8a325cf0b8e9f5473796c02f2 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Sun, 3 Nov 2019 17:44:30 -0500 Subject: staging: rtl8723bs: Fix lines over 80 characters This patch fixes the "lines over 80 characters" warnings in lines affected by a previous patch. Issue found by Checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/cb27cffda680eda05c44ee90db98c660fbf98b39.1572820893.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index b75781841e87..ab85abecfaaa 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -99,7 +99,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; - list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue); + list_add_tail(&pxframe->list, + &pxmitpriv->free_xmit_queue.queue); pxframe++; } @@ -150,7 +151,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->flags = XMIT_VO_QUEUE; - list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue); + list_add_tail(&pxmitbuf->list, + &pxmitpriv->free_xmitbuf_queue.queue); #ifdef DBG_XMIT_BUF pxmitbuf->no = i; #endif @@ -188,7 +190,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe->ext_tag = 1; - list_add_tail(&pxframe->list, &pxmitpriv->free_xframe_ext_queue.queue); + list_add_tail(&pxframe->list, + &pxmitpriv->free_xframe_ext_queue.queue); pxframe++; } @@ -227,7 +230,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->len = 0; pxmitbuf->pdata = pxmitbuf->ptail = pxmitbuf->phead; - list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); + list_add_tail(&pxmitbuf->list, + &pxmitpriv->free_xmit_extbuf_queue.queue); #ifdef DBG_XMIT_BUF_EXT pxmitbuf->no = i; #endif @@ -1409,7 +1413,8 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit pmlmeext->mgnt_80211w_IPN++; /* add MME IE with MIC all zero, MME string doesn't include element id and length */ - pframe = rtw_set_ie(pframe, _MME_IE_, 16, MME, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _MME_IE_, 16, + MME, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; /* total frame length - header length */ frame_body_len = pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr); @@ -1814,7 +1819,8 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue)); + list_add_tail(&pxmitbuf->list, + get_list_head(pfree_xmitbuf_queue)); pxmitpriv->free_xmitbuf_cnt++; /* DBG_871X("FREE, free_xmitbuf_cnt =%d\n", pxmitpriv->free_xmitbuf_cnt); */ -- cgit v1.2.3-59-g8ed1b From 5e3bafbd14b553e30234d234cb6d1fa004e292ab Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 5 Nov 2019 09:51:22 +0000 Subject: staging: wilc1000: avoid 'bool' datatype in struct sent to firmware Use 'u8' instead of 'bool' datatype for struct element sent to firmware because storage of bool datatype is not guaranteed. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191105095058.24223-2-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_hif.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wilc_hif.c b/drivers/staging/wilc1000/wilc_hif.c index e0a95c5cc0d5..59eb7600619b 100644 --- a/drivers/staging/wilc1000/wilc_hif.c +++ b/drivers/staging/wilc1000/wilc_hif.c @@ -32,7 +32,7 @@ struct wilc_op_mode { }; struct wilc_reg_frame { - bool reg; + u8 reg; u8 reg_id; __le16 frame_type; } __packed; @@ -1784,7 +1784,9 @@ void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) wid.val = (u8 *)®_frame; memset(®_frame, 0x0, sizeof(reg_frame)); - reg_frame.reg = reg; + + if (reg) + reg_frame.reg = 1; switch (frame_type) { case IEEE80211_STYPE_ACTION: -- cgit v1.2.3-59-g8ed1b From 6cecbb2c67598db47eac301a5fe09e1bb380a08d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 5 Nov 2019 09:51:25 +0000 Subject: staging: wilc1000: remove 'wilc_' prefix from filenames Remove 'wilc_' prefix from filenames, the driver is already present inside the 'wilc1000' directory so no need to add 'wilc_' in filenames. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191105095058.24223-3-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 8 +- drivers/staging/wilc1000/cfg80211.c | 1960 ++++++++++++++++++++ drivers/staging/wilc1000/cfg80211.h | 29 + drivers/staging/wilc1000/hif.c | 2043 +++++++++++++++++++++ drivers/staging/wilc1000/hif.h | 233 +++ drivers/staging/wilc1000/mon.c | 260 +++ drivers/staging/wilc1000/netdev.c | 955 ++++++++++ drivers/staging/wilc1000/netdev.h | 296 +++ drivers/staging/wilc1000/sdio.c | 1151 ++++++++++++ drivers/staging/wilc1000/spi.c | 1145 ++++++++++++ drivers/staging/wilc1000/wilc_hif.c | 2043 --------------------- drivers/staging/wilc1000/wilc_hif.h | 233 --- drivers/staging/wilc1000/wilc_mon.c | 260 --- drivers/staging/wilc1000/wilc_netdev.c | 955 ---------- drivers/staging/wilc1000/wilc_sdio.c | 1151 ------------ drivers/staging/wilc1000/wilc_spi.c | 1145 ------------ drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 1960 -------------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.h | 29 - drivers/staging/wilc1000/wilc_wfi_netdevice.h | 296 --- drivers/staging/wilc1000/wilc_wlan.c | 1269 ------------- drivers/staging/wilc1000/wilc_wlan.h | 304 --- drivers/staging/wilc1000/wilc_wlan_cfg.c | 457 ----- drivers/staging/wilc1000/wilc_wlan_cfg.h | 54 - drivers/staging/wilc1000/wilc_wlan_if.h | 802 -------- drivers/staging/wilc1000/wlan.c | 1269 +++++++++++++ drivers/staging/wilc1000/wlan.h | 304 +++ drivers/staging/wilc1000/wlan_cfg.c | 457 +++++ drivers/staging/wilc1000/wlan_cfg.h | 54 + drivers/staging/wilc1000/wlan_if.h | 802 ++++++++ 29 files changed, 10962 insertions(+), 10962 deletions(-) create mode 100644 drivers/staging/wilc1000/cfg80211.c create mode 100644 drivers/staging/wilc1000/cfg80211.h create mode 100644 drivers/staging/wilc1000/hif.c create mode 100644 drivers/staging/wilc1000/hif.h create mode 100644 drivers/staging/wilc1000/mon.c create mode 100644 drivers/staging/wilc1000/netdev.c create mode 100644 drivers/staging/wilc1000/netdev.h create mode 100644 drivers/staging/wilc1000/sdio.c create mode 100644 drivers/staging/wilc1000/spi.c delete mode 100644 drivers/staging/wilc1000/wilc_hif.c delete mode 100644 drivers/staging/wilc1000/wilc_hif.h delete mode 100644 drivers/staging/wilc1000/wilc_mon.c delete mode 100644 drivers/staging/wilc1000/wilc_netdev.c delete mode 100644 drivers/staging/wilc1000/wilc_sdio.c delete mode 100644 drivers/staging/wilc1000/wilc_spi.c delete mode 100644 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c delete mode 100644 drivers/staging/wilc1000/wilc_wfi_cfgoperations.h delete mode 100644 drivers/staging/wilc1000/wilc_wfi_netdevice.h delete mode 100644 drivers/staging/wilc1000/wilc_wlan.c delete mode 100644 drivers/staging/wilc1000/wilc_wlan.h delete mode 100644 drivers/staging/wilc1000/wilc_wlan_cfg.c delete mode 100644 drivers/staging/wilc1000/wilc_wlan_cfg.h delete mode 100644 drivers/staging/wilc1000/wilc_wlan_if.h create mode 100644 drivers/staging/wilc1000/wlan.c create mode 100644 drivers/staging/wilc1000/wlan.h create mode 100644 drivers/staging/wilc1000/wlan_cfg.c create mode 100644 drivers/staging/wilc1000/wlan_cfg.h create mode 100644 drivers/staging/wilc1000/wlan_if.h (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index a5a8e806b98e..a3305a0a888a 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -4,11 +4,11 @@ obj-$(CONFIG_WILC1000) += wilc1000.o ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" -wilc1000-objs := wilc_wfi_cfgoperations.o wilc_netdev.o wilc_mon.o \ - wilc_hif.o wilc_wlan_cfg.o wilc_wlan.o +wilc1000-objs := cfg80211.o netdev.o mon.o \ + hif.o wlan_cfg.o wlan.o obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o -wilc1000-sdio-objs += wilc_sdio.o +wilc1000-sdio-objs += sdio.o obj-$(CONFIG_WILC1000_SPI) += wilc1000-spi.o -wilc1000-spi-objs += wilc_spi.o +wilc1000-spi-objs += spi.o diff --git a/drivers/staging/wilc1000/cfg80211.c b/drivers/staging/wilc1000/cfg80211.c new file mode 100644 index 000000000000..4863e516ff13 --- /dev/null +++ b/drivers/staging/wilc1000/cfg80211.c @@ -0,0 +1,1960 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include "cfg80211.h" + +#define FRAME_TYPE_ID 0 +#define ACTION_CAT_ID 24 +#define ACTION_SUBTYPE_ID 25 +#define P2P_PUB_ACTION_SUBTYPE 30 + +#define ACTION_FRAME 0xd0 +#define GO_INTENT_ATTR_ID 0x04 +#define CHANLIST_ATTR_ID 0x0b +#define OPERCHAN_ATTR_ID 0x11 +#define PUB_ACTION_ATTR_ID 0x04 +#define P2PELEM_ATTR_ID 0xdd + +#define GO_NEG_REQ 0x00 +#define GO_NEG_RSP 0x01 +#define GO_NEG_CONF 0x02 +#define P2P_INV_REQ 0x03 +#define P2P_INV_RSP 0x04 +#define PUBLIC_ACT_VENDORSPEC 0x09 +#define GAS_INITIAL_REQ 0x0a +#define GAS_INITIAL_RSP 0x0b + +#define WILC_INVALID_CHANNEL 0 + +static const struct ieee80211_txrx_stypes + wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { + [NL80211_IFTYPE_STATION] = { + .tx = 0xffff, + .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) + }, + [NL80211_IFTYPE_AP] = { + .tx = 0xffff, + .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | + BIT(IEEE80211_STYPE_DISASSOC >> 4) | + BIT(IEEE80211_STYPE_AUTH >> 4) | + BIT(IEEE80211_STYPE_DEAUTH >> 4) | + BIT(IEEE80211_STYPE_ACTION >> 4) + }, + [NL80211_IFTYPE_P2P_CLIENT] = { + .tx = 0xffff, + .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | + BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | + BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | + BIT(IEEE80211_STYPE_DISASSOC >> 4) | + BIT(IEEE80211_STYPE_AUTH >> 4) | + BIT(IEEE80211_STYPE_DEAUTH >> 4) + } +}; + +static const struct wiphy_wowlan_support wowlan_support = { + .flags = WIPHY_WOWLAN_ANY +}; + +struct wilc_p2p_mgmt_data { + int size; + u8 *buff; +}; + +static const u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; +static const u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; + +static void cfg_scan_result(enum scan_event scan_event, + struct wilc_rcvd_net_info *info, void *user_void) +{ + struct wilc_priv *priv = user_void; + + if (!priv->cfg_scanning) + return; + + if (scan_event == SCAN_EVENT_NETWORK_FOUND) { + s32 freq; + struct ieee80211_channel *channel; + struct cfg80211_bss *bss; + struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy; + + if (!wiphy || !info) + return; + + freq = ieee80211_channel_to_frequency((s32)info->ch, + NL80211_BAND_2GHZ); + channel = ieee80211_get_channel(wiphy, freq); + if (!channel) + return; + + bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt, + info->frame_len, + (s32)info->rssi * 100, + GFP_KERNEL); + if (!bss) + cfg80211_put_bss(wiphy, bss); + } else if (scan_event == SCAN_EVENT_DONE) { + mutex_lock(&priv->scan_req_lock); + + if (priv->scan_req) { + struct cfg80211_scan_info info = { + .aborted = false, + }; + + cfg80211_scan_done(priv->scan_req, &info); + priv->cfg_scanning = false; + priv->scan_req = NULL; + } + mutex_unlock(&priv->scan_req_lock); + } else if (scan_event == SCAN_EVENT_ABORTED) { + mutex_lock(&priv->scan_req_lock); + + if (priv->scan_req) { + struct cfg80211_scan_info info = { + .aborted = false, + }; + + cfg80211_scan_done(priv->scan_req, &info); + priv->cfg_scanning = false; + priv->scan_req = NULL; + } + mutex_unlock(&priv->scan_req_lock); + } +} + +static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status, + void *priv_data) +{ + struct wilc_priv *priv = priv_data; + struct net_device *dev = priv->dev; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; + struct host_if_drv *wfi_drv = priv->hif_drv; + struct wilc_conn_info *conn_info = &wfi_drv->conn_info; + struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; + + vif->connecting = false; + + if (conn_disconn_evt == CONN_DISCONN_EVENT_CONN_RESP) { + u16 connect_status = conn_info->status; + + if (mac_status == WILC_MAC_STATUS_DISCONNECTED && + connect_status == WLAN_STATUS_SUCCESS) { + connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE; + wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); + + if (vif->iftype != WILC_CLIENT_MODE) + wl->sta_ch = WILC_INVALID_CHANNEL; + + netdev_err(dev, "Unspecified failure\n"); + } + + if (connect_status == WLAN_STATUS_SUCCESS) + memcpy(priv->associated_bss, conn_info->bssid, + ETH_ALEN); + + cfg80211_ref_bss(wiphy, vif->bss); + cfg80211_connect_bss(dev, conn_info->bssid, vif->bss, + conn_info->req_ies, + conn_info->req_ies_len, + conn_info->resp_ies, + conn_info->resp_ies_len, + connect_status, GFP_KERNEL, + NL80211_TIMEOUT_UNSPECIFIED); + + vif->bss = NULL; + } else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) { + u16 reason = 0; + + priv->p2p.local_random = 0x01; + priv->p2p.recv_random = 0x00; + priv->p2p.is_wilc_ie = false; + eth_zero_addr(priv->associated_bss); + wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); + + if (vif->iftype != WILC_CLIENT_MODE) { + wl->sta_ch = WILC_INVALID_CHANNEL; + } else { + if (wfi_drv->ifc_up) + reason = 3; + else + reason = 1; + } + + cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL); + } +} + +struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl) +{ + struct wilc_vif *vif; + + vif = list_first_or_null_rcu(&wl->vif_list, typeof(*vif), list); + if (!vif) + return ERR_PTR(-EINVAL); + + return vif; +} + +static int set_channel(struct wiphy *wiphy, + struct cfg80211_chan_def *chandef) +{ + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + u32 channelnum; + int result; + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) { + srcu_read_unlock(&wl->srcu, srcu_idx); + return PTR_ERR(vif); + } + + channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); + + wl->op_ch = channelnum; + result = wilc_set_mac_chnl_num(vif, channelnum); + if (result) + netdev_err(vif->ndev, "Error in setting channel\n"); + + srcu_read_unlock(&wl->srcu, srcu_idx); + return result; +} + +static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) +{ + struct wilc_vif *vif = netdev_priv(request->wdev->netdev); + struct wilc_priv *priv = &vif->priv; + u32 i; + int ret = 0; + u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH]; + u8 scan_type; + + if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) { + netdev_err(vif->ndev, "Requested scanned channels over\n"); + return -EINVAL; + } + + priv->scan_req = request; + priv->cfg_scanning = true; + for (i = 0; i < request->n_channels; i++) { + u16 freq = request->channels[i]->center_freq; + + scan_ch_list[i] = ieee80211_frequency_to_channel(freq); + } + + if (request->n_ssids) + scan_type = WILC_FW_ACTIVE_SCAN; + else + scan_type = WILC_FW_PASSIVE_SCAN; + + ret = wilc_scan(vif, WILC_FW_USER_SCAN, scan_type, scan_ch_list, + request->n_channels, cfg_scan_result, (void *)priv, + request); + + if (ret) { + priv->scan_req = NULL; + priv->cfg_scanning = false; + } + + return ret; +} + +static int connect(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_connect_params *sme) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *wfi_drv = priv->hif_drv; + int ret; + u32 i; + u8 security = WILC_FW_SEC_NO; + enum authtype auth_type = WILC_FW_AUTH_ANY; + u32 cipher_group; + struct cfg80211_bss *bss; + void *join_params; + u8 ch; + + vif->connecting = true; + + memset(priv->wep_key, 0, sizeof(priv->wep_key)); + memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len)); + + cipher_group = sme->crypto.cipher_group; + if (cipher_group != 0) { + if (cipher_group == WLAN_CIPHER_SUITE_WEP40) { + security = WILC_FW_SEC_WEP; + + priv->wep_key_len[sme->key_idx] = sme->key_len; + memcpy(priv->wep_key[sme->key_idx], sme->key, + sme->key_len); + + wilc_set_wep_default_keyid(vif, sme->key_idx); + wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, + sme->key_idx); + } else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) { + security = WILC_FW_SEC_WEP_EXTENDED; + + priv->wep_key_len[sme->key_idx] = sme->key_len; + memcpy(priv->wep_key[sme->key_idx], sme->key, + sme->key_len); + + wilc_set_wep_default_keyid(vif, sme->key_idx); + wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, + sme->key_idx); + } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { + if (cipher_group == WLAN_CIPHER_SUITE_TKIP) + security = WILC_FW_SEC_WPA2_TKIP; + else + security = WILC_FW_SEC_WPA2_AES; + } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { + if (cipher_group == WLAN_CIPHER_SUITE_TKIP) + security = WILC_FW_SEC_WPA_TKIP; + else + security = WILC_FW_SEC_WPA_AES; + } else { + ret = -ENOTSUPP; + netdev_err(dev, "%s: Unsupported cipher\n", + __func__); + goto out_error; + } + } + + if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) || + (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { + for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { + u32 ciphers_pairwise = sme->crypto.ciphers_pairwise[i]; + + if (ciphers_pairwise == WLAN_CIPHER_SUITE_TKIP) + security |= WILC_FW_TKIP; + else + security |= WILC_FW_AES; + } + } + + switch (sme->auth_type) { + case NL80211_AUTHTYPE_OPEN_SYSTEM: + auth_type = WILC_FW_AUTH_OPEN_SYSTEM; + break; + + case NL80211_AUTHTYPE_SHARED_KEY: + auth_type = WILC_FW_AUTH_SHARED_KEY; + break; + + default: + break; + } + + if (sme->crypto.n_akm_suites) { + if (sme->crypto.akm_suites[0] == WLAN_AKM_SUITE_8021X) + auth_type = WILC_FW_AUTH_IEEE8021; + } + + if (wfi_drv->usr_scan_req.scan_result) { + netdev_err(vif->ndev, "%s: Scan in progress\n", __func__); + ret = -EBUSY; + goto out_error; + } + + bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid, + sme->ssid_len, IEEE80211_BSS_TYPE_ANY, + IEEE80211_PRIVACY(sme->privacy)); + if (!bss) { + ret = -EINVAL; + goto out_error; + } + + if (ether_addr_equal_unaligned(vif->bssid, bss->bssid)) { + ret = -EALREADY; + goto out_put_bss; + } + + join_params = wilc_parse_join_bss_param(bss, &sme->crypto); + if (!join_params) { + netdev_err(dev, "%s: failed to construct join param\n", + __func__); + ret = -EINVAL; + goto out_put_bss; + } + + ch = ieee80211_frequency_to_channel(bss->channel->center_freq); + vif->wilc->op_ch = ch; + if (vif->iftype != WILC_CLIENT_MODE) + vif->wilc->sta_ch = ch; + + wilc_wlan_set_bssid(dev, bss->bssid, WILC_STATION_MODE); + + wfi_drv->conn_info.security = security; + wfi_drv->conn_info.auth_type = auth_type; + wfi_drv->conn_info.ch = ch; + wfi_drv->conn_info.conn_result = cfg_connect_result; + wfi_drv->conn_info.arg = priv; + wfi_drv->conn_info.param = join_params; + + ret = wilc_set_join_req(vif, bss->bssid, sme->ie, sme->ie_len); + if (ret) { + netdev_err(dev, "wilc_set_join_req(): Error\n"); + ret = -ENOENT; + if (vif->iftype != WILC_CLIENT_MODE) + vif->wilc->sta_ch = WILC_INVALID_CHANNEL; + wilc_wlan_set_bssid(dev, NULL, WILC_STATION_MODE); + wfi_drv->conn_info.conn_result = NULL; + kfree(join_params); + goto out_put_bss; + } + kfree(join_params); + vif->bss = bss; + cfg80211_put_bss(wiphy, bss); + return 0; + +out_put_bss: + cfg80211_put_bss(wiphy, bss); + +out_error: + vif->connecting = false; + return ret; +} + +static int disconnect(struct wiphy *wiphy, struct net_device *dev, + u16 reason_code) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + struct wilc *wilc = vif->wilc; + int ret; + + vif->connecting = false; + + if (!wilc) + return -EIO; + + if (wilc->close) { + /* already disconnected done */ + cfg80211_disconnected(dev, 0, NULL, 0, true, GFP_KERNEL); + return 0; + } + + if (vif->iftype != WILC_CLIENT_MODE) + wilc->sta_ch = WILC_INVALID_CHANNEL; + wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); + + priv->p2p.local_random = 0x01; + priv->p2p.recv_random = 0x00; + priv->p2p.is_wilc_ie = false; + priv->hif_drv->p2p_timeout = 0; + + ret = wilc_disconnect(vif); + if (ret != 0) { + netdev_err(priv->dev, "Error in disconnecting\n"); + ret = -EINVAL; + } + + vif->bss = NULL; + + return ret; +} + +static inline void wilc_wfi_cfg_copy_wep_info(struct wilc_priv *priv, + u8 key_index, + struct key_params *params) +{ + priv->wep_key_len[key_index] = params->key_len; + memcpy(priv->wep_key[key_index], params->key, params->key_len); +} + +static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx) +{ + if (!priv->wilc_gtk[idx]) { + priv->wilc_gtk[idx] = kzalloc(sizeof(*priv->wilc_gtk[idx]), + GFP_KERNEL); + if (!priv->wilc_gtk[idx]) + return -ENOMEM; + } + + if (!priv->wilc_ptk[idx]) { + priv->wilc_ptk[idx] = kzalloc(sizeof(*priv->wilc_ptk[idx]), + GFP_KERNEL); + if (!priv->wilc_ptk[idx]) + return -ENOMEM; + } + + return 0; +} + +static int wilc_wfi_cfg_copy_wpa_info(struct wilc_wfi_key *key_info, + struct key_params *params) +{ + kfree(key_info->key); + + key_info->key = kmemdup(params->key, params->key_len, GFP_KERNEL); + if (!key_info->key) + return -ENOMEM; + + kfree(key_info->seq); + + if (params->seq_len > 0) { + key_info->seq = kmemdup(params->seq, params->seq_len, + GFP_KERNEL); + if (!key_info->seq) + return -ENOMEM; + } + + key_info->cipher = params->cipher; + key_info->key_len = params->key_len; + key_info->seq_len = params->seq_len; + + return 0; +} + +static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, + bool pairwise, const u8 *mac_addr, struct key_params *params) + +{ + int ret = 0, keylen = params->key_len; + const u8 *rx_mic = NULL; + const u8 *tx_mic = NULL; + u8 mode = WILC_FW_SEC_NO; + u8 op_mode; + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; + + switch (params->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + if (priv->wdev.iftype == NL80211_IFTYPE_AP) { + wilc_wfi_cfg_copy_wep_info(priv, key_index, params); + + if (params->cipher == WLAN_CIPHER_SUITE_WEP40) + mode = WILC_FW_SEC_WEP; + else + mode = WILC_FW_SEC_WEP_EXTENDED; + + ret = wilc_add_wep_key_bss_ap(vif, params->key, + params->key_len, + key_index, mode, + WILC_FW_AUTH_OPEN_SYSTEM); + break; + } + if (memcmp(params->key, priv->wep_key[key_index], + params->key_len)) { + wilc_wfi_cfg_copy_wep_info(priv, key_index, params); + + ret = wilc_add_wep_key_bss_sta(vif, params->key, + params->key_len, + key_index); + } + + break; + + case WLAN_CIPHER_SUITE_TKIP: + case WLAN_CIPHER_SUITE_CCMP: + if (priv->wdev.iftype == NL80211_IFTYPE_AP || + priv->wdev.iftype == NL80211_IFTYPE_P2P_GO) { + struct wilc_wfi_key *key; + + ret = wilc_wfi_cfg_allocate_wpa_entry(priv, key_index); + if (ret) + return -ENOMEM; + + if (params->key_len > 16 && + params->cipher == WLAN_CIPHER_SUITE_TKIP) { + tx_mic = params->key + 24; + rx_mic = params->key + 16; + keylen = params->key_len - 16; + } + + if (!pairwise) { + if (params->cipher == WLAN_CIPHER_SUITE_TKIP) + mode = WILC_FW_SEC_WPA_TKIP; + else + mode = WILC_FW_SEC_WPA2_AES; + + priv->wilc_groupkey = mode; + + key = priv->wilc_gtk[key_index]; + } else { + if (params->cipher == WLAN_CIPHER_SUITE_TKIP) + mode = WILC_FW_SEC_WPA_TKIP; + else + mode = priv->wilc_groupkey | WILC_FW_AES; + + key = priv->wilc_ptk[key_index]; + } + ret = wilc_wfi_cfg_copy_wpa_info(key, params); + if (ret) + return -ENOMEM; + + op_mode = WILC_AP_MODE; + } else { + if (params->key_len > 16 && + params->cipher == WLAN_CIPHER_SUITE_TKIP) { + rx_mic = params->key + 24; + tx_mic = params->key + 16; + keylen = params->key_len - 16; + } + + op_mode = WILC_STATION_MODE; + } + + if (!pairwise) + ret = wilc_add_rx_gtk(vif, params->key, keylen, + key_index, params->seq_len, + params->seq, rx_mic, tx_mic, + op_mode, mode); + else + ret = wilc_add_ptk(vif, params->key, keylen, mac_addr, + rx_mic, tx_mic, op_mode, mode, + key_index); + + break; + + default: + netdev_err(netdev, "%s: Unsupported cipher\n", __func__); + ret = -ENOTSUPP; + } + + return ret; +} + +static int del_key(struct wiphy *wiphy, struct net_device *netdev, + u8 key_index, + bool pairwise, + const u8 *mac_addr) +{ + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; + + if (priv->wilc_gtk[key_index]) { + kfree(priv->wilc_gtk[key_index]->key); + priv->wilc_gtk[key_index]->key = NULL; + kfree(priv->wilc_gtk[key_index]->seq); + priv->wilc_gtk[key_index]->seq = NULL; + + kfree(priv->wilc_gtk[key_index]); + priv->wilc_gtk[key_index] = NULL; + } + + if (priv->wilc_ptk[key_index]) { + kfree(priv->wilc_ptk[key_index]->key); + priv->wilc_ptk[key_index]->key = NULL; + kfree(priv->wilc_ptk[key_index]->seq); + priv->wilc_ptk[key_index]->seq = NULL; + kfree(priv->wilc_ptk[key_index]); + priv->wilc_ptk[key_index] = NULL; + } + + if (key_index <= 3 && priv->wep_key_len[key_index]) { + memset(priv->wep_key[key_index], 0, + priv->wep_key_len[key_index]); + priv->wep_key_len[key_index] = 0; + wilc_remove_wep_key(vif, key_index); + } + + return 0; +} + +static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, + bool pairwise, const u8 *mac_addr, void *cookie, + void (*callback)(void *cookie, struct key_params *)) +{ + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; + struct key_params key_params; + + if (!pairwise) { + key_params.key = priv->wilc_gtk[key_index]->key; + key_params.cipher = priv->wilc_gtk[key_index]->cipher; + key_params.key_len = priv->wilc_gtk[key_index]->key_len; + key_params.seq = priv->wilc_gtk[key_index]->seq; + key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; + } else { + key_params.key = priv->wilc_ptk[key_index]->key; + key_params.cipher = priv->wilc_ptk[key_index]->cipher; + key_params.key_len = priv->wilc_ptk[key_index]->key_len; + key_params.seq = priv->wilc_ptk[key_index]->seq; + key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; + } + + callback(cookie, &key_params); + + return 0; +} + +static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, + u8 key_index, bool unicast, bool multicast) +{ + struct wilc_vif *vif = netdev_priv(netdev); + + wilc_set_wep_default_keyid(vif, key_index); + + return 0; +} + +static int get_station(struct wiphy *wiphy, struct net_device *dev, + const u8 *mac, struct station_info *sinfo) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + u32 i = 0; + u32 associatedsta = ~0; + u32 inactive_time = 0; + + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { + for (i = 0; i < NUM_STA_ASSOCIATED; i++) { + if (!(memcmp(mac, + priv->assoc_stainfo.sta_associated_bss[i], + ETH_ALEN))) { + associatedsta = i; + break; + } + } + + if (associatedsta == ~0) { + netdev_err(dev, "sta required is not associated\n"); + return -ENOENT; + } + + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME); + + wilc_get_inactive_time(vif, mac, &inactive_time); + sinfo->inactive_time = 1000 * inactive_time; + } else if (vif->iftype == WILC_STATION_MODE) { + struct rf_info stats; + + wilc_get_statistics(vif, &stats); + + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL) | + BIT_ULL(NL80211_STA_INFO_RX_PACKETS) | + BIT_ULL(NL80211_STA_INFO_TX_PACKETS) | + BIT_ULL(NL80211_STA_INFO_TX_FAILED) | + BIT_ULL(NL80211_STA_INFO_TX_BITRATE); + + sinfo->signal = stats.rssi; + sinfo->rx_packets = stats.rx_cnt; + sinfo->tx_packets = stats.tx_cnt + stats.tx_fail_cnt; + sinfo->tx_failed = stats.tx_fail_cnt; + sinfo->txrate.legacy = stats.link_speed * 10; + + if (stats.link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && + stats.link_speed != DEFAULT_LINK_SPEED) + wilc_enable_tcp_ack_filter(vif, true); + else if (stats.link_speed != DEFAULT_LINK_SPEED) + wilc_enable_tcp_ack_filter(vif, false); + } + return 0; +} + +static int change_bss(struct wiphy *wiphy, struct net_device *dev, + struct bss_parameters *params) +{ + return 0; +} + +static int set_wiphy_params(struct wiphy *wiphy, u32 changed) +{ + int ret = -EINVAL; + struct cfg_param_attr cfg_param_val; + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + struct wilc_priv *priv; + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) + goto out; + + priv = &vif->priv; + cfg_param_val.flag = 0; + + if (changed & WIPHY_PARAM_RETRY_SHORT) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_RETRY_SHORT %d\n", + wiphy->retry_short); + cfg_param_val.flag |= WILC_CFG_PARAM_RETRY_SHORT; + cfg_param_val.short_retry_limit = wiphy->retry_short; + } + if (changed & WIPHY_PARAM_RETRY_LONG) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_RETRY_LONG %d\n", + wiphy->retry_long); + cfg_param_val.flag |= WILC_CFG_PARAM_RETRY_LONG; + cfg_param_val.long_retry_limit = wiphy->retry_long; + } + if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { + if (wiphy->frag_threshold > 255 && + wiphy->frag_threshold < 7937) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", + wiphy->frag_threshold); + cfg_param_val.flag |= WILC_CFG_PARAM_FRAG_THRESHOLD; + cfg_param_val.frag_threshold = wiphy->frag_threshold; + } else { + netdev_err(vif->ndev, + "Fragmentation threshold out of range\n"); + goto out; + } + } + + if (changed & WIPHY_PARAM_RTS_THRESHOLD) { + if (wiphy->rts_threshold > 255) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", + wiphy->rts_threshold); + cfg_param_val.flag |= WILC_CFG_PARAM_RTS_THRESHOLD; + cfg_param_val.rts_threshold = wiphy->rts_threshold; + } else { + netdev_err(vif->ndev, "RTS threshold out of range\n"); + goto out; + } + } + + ret = wilc_hif_set_cfg(vif, &cfg_param_val); + if (ret) + netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n"); + +out: + srcu_read_unlock(&wl->srcu, srcu_idx); + return ret; +} + +static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_pmksa *pmksa) +{ + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; + u32 i; + int ret = 0; + u8 flag = 0; + + for (i = 0; i < priv->pmkid_list.numpmkid; i++) { + if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, + ETH_ALEN)) { + flag = PMKID_FOUND; + break; + } + } + if (i < WILC_MAX_NUM_PMKIDS) { + memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, + ETH_ALEN); + memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, + WLAN_PMKID_LEN); + if (!(flag == PMKID_FOUND)) + priv->pmkid_list.numpmkid++; + } else { + netdev_err(netdev, "Invalid PMKID index\n"); + ret = -EINVAL; + } + + if (!ret) + ret = wilc_set_pmkid_info(vif, &priv->pmkid_list); + + return ret; +} + +static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, + struct cfg80211_pmksa *pmksa) +{ + u32 i; + int ret = 0; + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; + + for (i = 0; i < priv->pmkid_list.numpmkid; i++) { + if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, + ETH_ALEN)) { + memset(&priv->pmkid_list.pmkidlist[i], 0, + sizeof(struct wilc_pmkid)); + break; + } + } + + if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { + for (; i < (priv->pmkid_list.numpmkid - 1); i++) { + memcpy(priv->pmkid_list.pmkidlist[i].bssid, + priv->pmkid_list.pmkidlist[i + 1].bssid, + ETH_ALEN); + memcpy(priv->pmkid_list.pmkidlist[i].pmkid, + priv->pmkid_list.pmkidlist[i + 1].pmkid, + WLAN_PMKID_LEN); + } + priv->pmkid_list.numpmkid--; + } else { + ret = -EINVAL; + } + + return ret; +} + +static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) +{ + struct wilc_vif *vif = netdev_priv(netdev); + + memset(&vif->priv.pmkid_list, 0, sizeof(struct wilc_pmkid_attr)); + + return 0; +} + +static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u8 ch_list_attr_idx, + u8 op_ch_attr_idx, u8 sta_ch) +{ + int i = 0; + int j = 0; + + if (ch_list_attr_idx) { + u8 limit = ch_list_attr_idx + 3 + buf[ch_list_attr_idx + 1]; + + for (i = ch_list_attr_idx + 3; i < limit; i++) { + if (buf[i] == 0x51) { + for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) + buf[j] = sta_ch; + break; + } + } + } + + if (op_ch_attr_idx) { + buf[op_ch_attr_idx + 6] = 0x51; + buf[op_ch_attr_idx + 7] = sta_ch; + } +} + +static void wilc_wfi_cfg_parse_rx_action(u8 *buf, u32 len, u8 sta_ch) +{ + u32 index = 0; + u8 op_channel_attr_index = 0; + u8 channel_list_attr_index = 0; + + while (index < len) { + if (buf[index] == GO_INTENT_ATTR_ID) + buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); + + if (buf[index] == CHANLIST_ATTR_ID) + channel_list_attr_index = index; + else if (buf[index] == OPERCHAN_ATTR_ID) + op_channel_attr_index = index; + index += buf[index + 1] + 3; + } + if (sta_ch != WILC_INVALID_CHANNEL) + wilc_wfi_cfg_parse_ch_attr(buf, channel_list_attr_index, + op_channel_attr_index, sta_ch); +} + +static void wilc_wfi_cfg_parse_tx_action(u8 *buf, u32 len, bool oper_ch, + u8 iftype, u8 sta_ch) +{ + u32 index = 0; + u8 op_channel_attr_index = 0; + u8 channel_list_attr_index = 0; + + while (index < len) { + if (buf[index] == GO_INTENT_ATTR_ID) { + buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); + + break; + } + + if (buf[index] == CHANLIST_ATTR_ID) + channel_list_attr_index = index; + else if (buf[index] == OPERCHAN_ATTR_ID) + op_channel_attr_index = index; + index += buf[index + 1] + 3; + } + if (sta_ch != WILC_INVALID_CHANNEL && oper_ch) + wilc_wfi_cfg_parse_ch_attr(buf, channel_list_attr_index, + op_channel_attr_index, sta_ch); +} + +static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff, + u32 size) +{ + int i; + u8 subtype; + struct wilc_vif *vif = netdev_priv(priv->dev); + + subtype = buff[P2P_PUB_ACTION_SUBTYPE]; + if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && + !priv->p2p.is_wilc_ie) { + for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { + if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { + priv->p2p.recv_random = buff[i + 6]; + priv->p2p.is_wilc_ie = true; + break; + } + } + } + + if (priv->p2p.local_random <= priv->p2p.recv_random) { + netdev_dbg(vif->ndev, + "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", + priv->p2p.local_random, priv->p2p.recv_random); + return; + } + + if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP || + subtype == P2P_INV_REQ || subtype == P2P_INV_RSP) { + for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { + if (buff[i] == P2PELEM_ATTR_ID && + !(memcmp(p2p_oui, &buff[i + 2], 4))) { + wilc_wfi_cfg_parse_rx_action(&buff[i + 6], + size - (i + 6), + vif->wilc->sta_ch); + break; + } + } + } +} + +void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) +{ + struct wilc *wl = vif->wilc; + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *wfi_drv = priv->hif_drv; + u32 header, pkt_offset; + s32 freq; + __le16 fc; + + header = get_unaligned_le32(buff - HOST_HDR_OFFSET); + pkt_offset = GET_PKT_OFFSET(header); + + if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { + bool ack = false; + + if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP || + pkt_offset & IS_MGMT_STATUS_SUCCES) + ack = true; + + cfg80211_mgmt_tx_status(&priv->wdev, priv->tx_cookie, buff, + size, ack, GFP_KERNEL); + return; + } + + freq = ieee80211_channel_to_frequency(wl->op_ch, NL80211_BAND_2GHZ); + + fc = ((struct ieee80211_hdr *)buff)->frame_control; + if (!ieee80211_is_action(fc)) { + cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); + return; + } + + if (priv->cfg_scanning && + time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) { + netdev_dbg(vif->ndev, "Receiving action wrong ch\n"); + return; + } + if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { + u8 subtype = buff[P2P_PUB_ACTION_SUBTYPE]; + + switch (buff[ACTION_SUBTYPE_ID]) { + case GAS_INITIAL_REQ: + case GAS_INITIAL_RSP: + break; + + case PUBLIC_ACT_VENDORSPEC: + if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) + wilc_wfi_cfg_parse_rx_vendor_spec(priv, buff, + size); + + if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && + priv->p2p.is_wilc_ie) + size -= 7; + + break; + + default: + netdev_dbg(vif->ndev, + "%s: Not handled action frame type:%x\n", + __func__, buff[ACTION_SUBTYPE_ID]); + break; + } + } + + cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); +} + +static void wilc_wfi_mgmt_tx_complete(void *priv, int status) +{ + struct wilc_p2p_mgmt_data *pv_data = priv; + + kfree(pv_data->buff); + kfree(pv_data); +} + +static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) +{ + struct wilc_vif *vif = data; + struct wilc_priv *priv = &vif->priv; + struct wilc_wfi_p2p_listen_params *params = &priv->remain_on_ch_params; + + if (cookie != params->listen_cookie) + return; + + priv->p2p_listen_state = false; + + cfg80211_remain_on_channel_expired(&priv->wdev, params->listen_cookie, + params->listen_ch, GFP_KERNEL); +} + +static int remain_on_channel(struct wiphy *wiphy, + struct wireless_dev *wdev, + struct ieee80211_channel *chan, + unsigned int duration, u64 *cookie) +{ + int ret = 0; + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; + u64 id; + + if (wdev->iftype == NL80211_IFTYPE_AP) { + netdev_dbg(vif->ndev, "Required while in AP mode\n"); + return ret; + } + + id = ++priv->inc_roc_cookie; + if (id == 0) + id = ++priv->inc_roc_cookie; + + ret = wilc_remain_on_channel(vif, id, duration, chan->hw_value, + wilc_wfi_remain_on_channel_expired, + (void *)vif); + if (ret) + return ret; + + vif->wilc->op_ch = chan->hw_value; + + priv->remain_on_ch_params.listen_ch = chan; + priv->remain_on_ch_params.listen_cookie = id; + *cookie = id; + priv->p2p_listen_state = true; + priv->remain_on_ch_params.listen_duration = duration; + + cfg80211_ready_on_channel(wdev, *cookie, chan, duration, GFP_KERNEL); + mod_timer(&vif->hif_drv->remain_on_ch_timer, + jiffies + msecs_to_jiffies(duration + 1000)); + + return ret; +} + +static int cancel_remain_on_channel(struct wiphy *wiphy, + struct wireless_dev *wdev, + u64 cookie) +{ + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; + + if (cookie != priv->remain_on_ch_params.listen_cookie) + return -ENOENT; + + return wilc_listen_state_expired(vif, cookie); +} + +static void wilc_wfi_cfg_tx_vendor_spec(struct wilc_priv *priv, + struct wilc_p2p_mgmt_data *mgmt_tx, + struct cfg80211_mgmt_tx_params *params, + u8 iftype, u32 buf_len) +{ + const u8 *buf = params->buf; + size_t len = params->len; + u32 i; + u8 subtype = buf[P2P_PUB_ACTION_SUBTYPE]; + struct wilc_vif *vif = netdev_priv(priv->dev); + + if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) { + if (priv->p2p.local_random == 1 && + priv->p2p.recv_random < priv->p2p.local_random) { + get_random_bytes(&priv->p2p.local_random, 1); + priv->p2p.local_random++; + } + } + + if (priv->p2p.local_random <= priv->p2p.recv_random || + !(subtype == GO_NEG_REQ || subtype == GO_NEG_RSP || + subtype == P2P_INV_REQ || subtype == P2P_INV_RSP)) + return; + + for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { + if (buf[i] == P2PELEM_ATTR_ID && + !memcmp(p2p_oui, &buf[i + 2], 4)) { + bool oper_ch = false; + u8 *tx_buff = &mgmt_tx->buff[i + 6]; + + if (subtype == P2P_INV_REQ || subtype == P2P_INV_RSP) + oper_ch = true; + + wilc_wfi_cfg_parse_tx_action(tx_buff, len - (i + 6), + oper_ch, iftype, + vif->wilc->sta_ch); + + break; + } + } + + if (subtype != P2P_INV_REQ && subtype != P2P_INV_RSP) { + int vendor_spec_len = sizeof(p2p_vendor_spec); + + memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, + vendor_spec_len); + mgmt_tx->buff[len + vendor_spec_len] = priv->p2p.local_random; + mgmt_tx->size = buf_len; + } +} + +static int mgmt_tx(struct wiphy *wiphy, + struct wireless_dev *wdev, + struct cfg80211_mgmt_tx_params *params, + u64 *cookie) +{ + struct ieee80211_channel *chan = params->chan; + unsigned int wait = params->wait; + const u8 *buf = params->buf; + size_t len = params->len; + const struct ieee80211_mgmt *mgmt; + struct wilc_p2p_mgmt_data *mgmt_tx; + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *wfi_drv = priv->hif_drv; + u32 buf_len = len + sizeof(p2p_vendor_spec) + + sizeof(priv->p2p.local_random); + int ret = 0; + + *cookie = prandom_u32(); + priv->tx_cookie = *cookie; + mgmt = (const struct ieee80211_mgmt *)buf; + + if (!ieee80211_is_mgmt(mgmt->frame_control)) + goto out; + + mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_KERNEL); + if (!mgmt_tx) { + ret = -ENOMEM; + goto out; + } + + mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL); + if (!mgmt_tx->buff) { + ret = -ENOMEM; + kfree(mgmt_tx); + goto out; + } + + memcpy(mgmt_tx->buff, buf, len); + mgmt_tx->size = len; + + if (ieee80211_is_probe_resp(mgmt->frame_control)) { + wilc_set_mac_chnl_num(vif, chan->hw_value); + vif->wilc->op_ch = chan->hw_value; + goto out_txq_add_pkt; + } + + if (!ieee80211_is_action(mgmt->frame_control)) + goto out_txq_add_pkt; + + if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { + if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || + buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { + wilc_set_mac_chnl_num(vif, chan->hw_value); + vif->wilc->op_ch = chan->hw_value; + } + switch (buf[ACTION_SUBTYPE_ID]) { + case GAS_INITIAL_REQ: + case GAS_INITIAL_RSP: + break; + + case PUBLIC_ACT_VENDORSPEC: + if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) + wilc_wfi_cfg_tx_vendor_spec(priv, mgmt_tx, + params, vif->iftype, + buf_len); + else + netdev_dbg(vif->ndev, + "Not a P2P public action frame\n"); + + break; + + default: + netdev_dbg(vif->ndev, + "%s: Not handled action frame type:%x\n", + __func__, buf[ACTION_SUBTYPE_ID]); + break; + } + } + + wfi_drv->p2p_timeout = (jiffies + msecs_to_jiffies(wait)); + +out_txq_add_pkt: + + wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, + mgmt_tx->buff, mgmt_tx->size, + wilc_wfi_mgmt_tx_complete); + +out: + + return ret; +} + +static int mgmt_tx_cancel_wait(struct wiphy *wiphy, + struct wireless_dev *wdev, + u64 cookie) +{ + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *wfi_drv = priv->hif_drv; + + wfi_drv->p2p_timeout = jiffies; + + if (!priv->p2p_listen_state) { + struct wilc_wfi_p2p_listen_params *params; + + params = &priv->remain_on_ch_params; + + cfg80211_remain_on_channel_expired(wdev, + params->listen_cookie, + params->listen_ch, + GFP_KERNEL); + } + + return 0; +} + +void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, + u16 frame_type, bool reg) +{ + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(wdev->netdev); + + if (!frame_type) + return; + + switch (frame_type) { + case IEEE80211_STYPE_PROBE_REQ: + vif->frame_reg[0].type = frame_type; + vif->frame_reg[0].reg = reg; + break; + + case IEEE80211_STYPE_ACTION: + vif->frame_reg[1].type = frame_type; + vif->frame_reg[1].reg = reg; + break; + + default: + break; + } + + if (!wl->initialized) + return; + wilc_frame_register(vif, frame_type, reg); +} + +static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, + s32 rssi_thold, u32 rssi_hyst) +{ + return 0; +} + +static int dump_station(struct wiphy *wiphy, struct net_device *dev, + int idx, u8 *mac, struct station_info *sinfo) +{ + struct wilc_vif *vif = netdev_priv(dev); + int ret; + + if (idx != 0) + return -ENOENT; + + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); + + ret = wilc_get_rssi(vif, &sinfo->signal); + if (ret) + return ret; + + memcpy(mac, vif->priv.associated_bss, ETH_ALEN); + return 0; +} + +static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, + bool enabled, int timeout) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + + if (!priv->hif_drv) + return -EIO; + + wilc_set_power_mgmt(vif, enabled, timeout); + + return 0; +} + +static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, + enum nl80211_iftype type, + struct vif_params *params) +{ + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + + priv->p2p.local_random = 0x01; + priv->p2p.recv_random = 0x00; + priv->p2p.is_wilc_ie = false; + + switch (type) { + case NL80211_IFTYPE_STATION: + vif->connecting = false; + dev->ieee80211_ptr->iftype = type; + priv->wdev.iftype = type; + vif->monitor_flag = 0; + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) + wilc_wfi_deinit_mon_interface(wl, true); + vif->iftype = WILC_STATION_MODE; + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_STATION_MODE, vif->idx); + + memset(priv->assoc_stainfo.sta_associated_bss, 0, + WILC_MAX_NUM_STA * ETH_ALEN); + break; + + case NL80211_IFTYPE_P2P_CLIENT: + vif->connecting = false; + dev->ieee80211_ptr->iftype = type; + priv->wdev.iftype = type; + vif->monitor_flag = 0; + vif->iftype = WILC_CLIENT_MODE; + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_STATION_MODE, vif->idx); + break; + + case NL80211_IFTYPE_AP: + dev->ieee80211_ptr->iftype = type; + priv->wdev.iftype = type; + vif->iftype = WILC_AP_MODE; + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_AP_MODE, vif->idx); + break; + + case NL80211_IFTYPE_P2P_GO: + dev->ieee80211_ptr->iftype = type; + priv->wdev.iftype = type; + vif->iftype = WILC_GO_MODE; + + if (wl->initialized) + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), + WILC_AP_MODE, vif->idx); + break; + + default: + netdev_err(dev, "Unknown interface type= %d\n", type); + return -EINVAL; + } + + return 0; +} + +static int start_ap(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ap_settings *settings) +{ + struct wilc_vif *vif = netdev_priv(dev); + int ret; + + ret = set_channel(wiphy, &settings->chandef); + if (ret != 0) + netdev_err(dev, "Error in setting channel\n"); + + wilc_wlan_set_bssid(dev, dev->dev_addr, WILC_AP_MODE); + + return wilc_add_beacon(vif, settings->beacon_interval, + settings->dtim_period, &settings->beacon); +} + +static int change_beacon(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_beacon_data *beacon) +{ + struct wilc_vif *vif = netdev_priv(dev); + + return wilc_add_beacon(vif, 0, 0, beacon); +} + +static int stop_ap(struct wiphy *wiphy, struct net_device *dev) +{ + int ret; + struct wilc_vif *vif = netdev_priv(dev); + + wilc_wlan_set_bssid(dev, NULL, WILC_AP_MODE); + + ret = wilc_del_beacon(vif); + + if (ret) + netdev_err(dev, "Host delete beacon fail\n"); + + return ret; +} + +static int add_station(struct wiphy *wiphy, struct net_device *dev, + const u8 *mac, struct station_parameters *params) +{ + int ret = 0; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { + memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac, + ETH_ALEN); + + ret = wilc_add_station(vif, mac, params); + if (ret) + netdev_err(dev, "Host add station fail\n"); + } + + return ret; +} + +static int del_station(struct wiphy *wiphy, struct net_device *dev, + struct station_del_parameters *params) +{ + const u8 *mac = params->mac; + int ret = 0; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; + struct sta_info *info; + + if (!(vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE)) + return ret; + + info = &priv->assoc_stainfo; + + if (!mac) + ret = wilc_del_allstation(vif, info->sta_associated_bss); + + ret = wilc_del_station(vif, mac); + if (ret) + netdev_err(dev, "Host delete station fail\n"); + return ret; +} + +static int change_station(struct wiphy *wiphy, struct net_device *dev, + const u8 *mac, struct station_parameters *params) +{ + int ret = 0; + struct wilc_vif *vif = netdev_priv(dev); + + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { + ret = wilc_edit_station(vif, mac, params); + if (ret) + netdev_err(dev, "Host edit station fail\n"); + } + return ret; +} + +static struct wilc_vif *wilc_get_vif_from_type(struct wilc *wl, int type) +{ + struct wilc_vif *vif; + + list_for_each_entry_rcu(vif, &wl->vif_list, list) { + if (vif->iftype == type) + return vif; + } + + return NULL; +} + +static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, + const char *name, + unsigned char name_assign_type, + enum nl80211_iftype type, + struct vif_params *params) +{ + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + struct wireless_dev *wdev; + int iftype; + + if (type == NL80211_IFTYPE_MONITOR) { + struct net_device *ndev; + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_vif_from_type(wl, WILC_AP_MODE); + if (!vif) { + vif = wilc_get_vif_from_type(wl, WILC_GO_MODE); + if (!vif) { + srcu_read_unlock(&wl->srcu, srcu_idx); + goto validate_interface; + } + } + + if (vif->monitor_flag) { + srcu_read_unlock(&wl->srcu, srcu_idx); + goto validate_interface; + } + + ndev = wilc_wfi_init_mon_interface(wl, name, vif->ndev); + if (ndev) { + vif->monitor_flag = 1; + } else { + srcu_read_unlock(&wl->srcu, srcu_idx); + return ERR_PTR(-EINVAL); + } + + wdev = &vif->priv.wdev; + srcu_read_unlock(&wl->srcu, srcu_idx); + return wdev; + } + +validate_interface: + mutex_lock(&wl->vif_mutex); + if (wl->vif_num == WILC_NUM_CONCURRENT_IFC) { + pr_err("Reached maximum number of interface\n"); + mutex_unlock(&wl->vif_mutex); + return ERR_PTR(-EINVAL); + } + mutex_unlock(&wl->vif_mutex); + + switch (type) { + case NL80211_IFTYPE_STATION: + iftype = WILC_STATION_MODE; + break; + case NL80211_IFTYPE_AP: + iftype = WILC_AP_MODE; + break; + default: + return ERR_PTR(-EOPNOTSUPP); + } + + vif = wilc_netdev_ifc_init(wl, name, iftype, type, true); + if (IS_ERR(vif)) + return ERR_CAST(vif); + + return &vif->priv.wdev; +} + +static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) +{ + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + + if (wdev->iftype == NL80211_IFTYPE_AP || + wdev->iftype == NL80211_IFTYPE_P2P_GO) + wilc_wfi_deinit_mon_interface(wl, true); + vif = netdev_priv(wdev->netdev); + cfg80211_stop_iface(wiphy, wdev, GFP_KERNEL); + unregister_netdevice(vif->ndev); + vif->monitor_flag = 0; + + wilc_set_operation_mode(vif, 0, 0, 0); + mutex_lock(&wl->vif_mutex); + list_del_rcu(&vif->list); + wl->vif_num--; + mutex_unlock(&wl->vif_mutex); + synchronize_srcu(&wl->srcu); + return 0; +} + +static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) +{ + struct wilc *wl = wiphy_priv(wiphy); + + if (!wow && wilc_wlan_get_num_conn_ifcs(wl)) + wl->suspend_event = true; + else + wl->suspend_event = false; + + return 0; +} + +static int wilc_resume(struct wiphy *wiphy) +{ + return 0; +} + +static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) +{ + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) { + srcu_read_unlock(&wl->srcu, srcu_idx); + return; + } + + netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled); + srcu_read_unlock(&wl->srcu, srcu_idx); +} + +static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, + enum nl80211_tx_power_setting type, int mbm) +{ + int ret; + int srcu_idx; + s32 tx_power = MBM_TO_DBM(mbm); + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + + if (!wl->initialized) + return -EIO; + + srcu_idx = srcu_read_lock(&wl->srcu); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) { + srcu_read_unlock(&wl->srcu, srcu_idx); + return -EINVAL; + } + + netdev_info(vif->ndev, "Setting tx power %d\n", tx_power); + if (tx_power < 0) + tx_power = 0; + else if (tx_power > 18) + tx_power = 18; + ret = wilc_set_tx_power(vif, tx_power); + if (ret) + netdev_err(vif->ndev, "Failed to set tx power\n"); + srcu_read_unlock(&wl->srcu, srcu_idx); + + return ret; +} + +static int get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, + int *dbm) +{ + int ret; + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc *wl = vif->wilc; + + /* If firmware is not started, return. */ + if (!wl->initialized) + return -EIO; + + ret = wilc_get_tx_power(vif, (u8 *)dbm); + if (ret) + netdev_err(vif->ndev, "Failed to get tx power\n"); + + return ret; +} + +static const struct cfg80211_ops wilc_cfg80211_ops = { + .set_monitor_channel = set_channel, + .scan = scan, + .connect = connect, + .disconnect = disconnect, + .add_key = add_key, + .del_key = del_key, + .get_key = get_key, + .set_default_key = set_default_key, + .add_virtual_intf = add_virtual_intf, + .del_virtual_intf = del_virtual_intf, + .change_virtual_intf = change_virtual_intf, + + .start_ap = start_ap, + .change_beacon = change_beacon, + .stop_ap = stop_ap, + .add_station = add_station, + .del_station = del_station, + .change_station = change_station, + .get_station = get_station, + .dump_station = dump_station, + .change_bss = change_bss, + .set_wiphy_params = set_wiphy_params, + + .set_pmksa = set_pmksa, + .del_pmksa = del_pmksa, + .flush_pmksa = flush_pmksa, + .remain_on_channel = remain_on_channel, + .cancel_remain_on_channel = cancel_remain_on_channel, + .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, + .mgmt_tx = mgmt_tx, + .mgmt_frame_register = wilc_mgmt_frame_register, + .set_power_mgmt = set_power_mgmt, + .set_cqm_rssi_config = set_cqm_rssi_config, + + .suspend = wilc_suspend, + .resume = wilc_resume, + .set_wakeup = wilc_set_wakeup, + .set_tx_power = set_tx_power, + .get_tx_power = get_tx_power, + +}; + +static void wlan_init_locks(struct wilc *wl) +{ + mutex_init(&wl->hif_cs); + mutex_init(&wl->rxq_cs); + mutex_init(&wl->cfg_cmd_lock); + mutex_init(&wl->vif_mutex); + + spin_lock_init(&wl->txq_spinlock); + mutex_init(&wl->txq_add_to_head_cs); + + init_completion(&wl->txq_event); + init_completion(&wl->cfg_event); + init_completion(&wl->sync_event); + init_completion(&wl->txq_thread_started); + init_srcu_struct(&wl->srcu); +} + +void wlan_deinit_locks(struct wilc *wilc) +{ + mutex_destroy(&wilc->hif_cs); + mutex_destroy(&wilc->rxq_cs); + mutex_destroy(&wilc->cfg_cmd_lock); + mutex_destroy(&wilc->txq_add_to_head_cs); + mutex_destroy(&wilc->vif_mutex); + cleanup_srcu_struct(&wilc->srcu); +} + +int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, + const struct wilc_hif_func *ops) +{ + struct wilc *wl; + struct wilc_vif *vif; + int ret; + + wl = wilc_create_wiphy(dev); + if (!wl) + return -EINVAL; + + wlan_init_locks(wl); + + ret = wilc_wlan_cfg_init(wl); + if (ret) + goto free_wl; + + *wilc = wl; + wl->io_type = io_type; + wl->hif_func = ops; + wl->chip_ps_state = WILC_CHIP_WAKEDUP; + INIT_LIST_HEAD(&wl->txq_head.list); + INIT_LIST_HEAD(&wl->rxq_head.list); + INIT_LIST_HEAD(&wl->vif_list); + + wl->hif_workqueue = create_singlethread_workqueue("WILC_wq"); + if (!wl->hif_workqueue) { + ret = -ENOMEM; + goto free_cfg; + } + vif = wilc_netdev_ifc_init(wl, "wlan%d", WILC_STATION_MODE, + NL80211_IFTYPE_STATION, false); + if (IS_ERR(vif)) { + ret = PTR_ERR(vif); + goto free_hq; + } + + return 0; + +free_hq: + destroy_workqueue(wl->hif_workqueue); + +free_cfg: + wilc_wlan_cfg_deinit(wl); + +free_wl: + wlan_deinit_locks(wl); + wiphy_unregister(wl->wiphy); + wiphy_free(wl->wiphy); + return ret; +} +EXPORT_SYMBOL_GPL(wilc_cfg80211_init); + +struct wilc *wilc_create_wiphy(struct device *dev) +{ + struct wiphy *wiphy; + struct wilc *wl; + int ret; + + wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(*wl)); + if (!wiphy) + return NULL; + + wl = wiphy_priv(wiphy); + + memcpy(wl->bitrates, wilc_bitrates, sizeof(wilc_bitrates)); + memcpy(wl->channels, wilc_2ghz_channels, sizeof(wilc_2ghz_channels)); + wl->band.bitrates = wl->bitrates; + wl->band.n_bitrates = ARRAY_SIZE(wl->bitrates); + wl->band.channels = wl->channels; + wl->band.n_channels = ARRAY_SIZE(wilc_2ghz_channels); + + wl->band.ht_cap.ht_supported = 1; + wl->band.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); + wl->band.ht_cap.mcs.rx_mask[0] = 0xff; + wl->band.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; + wl->band.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; + + wiphy->bands[NL80211_BAND_2GHZ] = &wl->band; + + wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID; +#ifdef CONFIG_PM + wiphy->wowlan = &wowlan_support; +#endif + wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; + wiphy->max_scan_ie_len = 1000; + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + memcpy(wl->cipher_suites, wilc_cipher_suites, + sizeof(wilc_cipher_suites)); + wiphy->cipher_suites = wl->cipher_suites; + wiphy->n_cipher_suites = ARRAY_SIZE(wilc_cipher_suites); + wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; + + wiphy->max_remain_on_channel_duration = 500; + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_AP) | + BIT(NL80211_IFTYPE_MONITOR) | + BIT(NL80211_IFTYPE_P2P_GO) | + BIT(NL80211_IFTYPE_P2P_CLIENT); + wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; + + set_wiphy_dev(wiphy, dev); + wl->wiphy = wiphy; + ret = wiphy_register(wiphy); + if (ret) { + wiphy_free(wiphy); + return NULL; + } + return wl; +} + +int wilc_init_host_int(struct net_device *net) +{ + int ret; + struct wilc_vif *vif = netdev_priv(net); + struct wilc_priv *priv = &vif->priv; + + priv->p2p_listen_state = false; + + mutex_init(&priv->scan_req_lock); + ret = wilc_init(net, &priv->hif_drv); + if (ret) + netdev_err(net, "Error while initializing hostinterface\n"); + + return ret; +} + +void wilc_deinit_host_int(struct net_device *net) +{ + int ret; + struct wilc_vif *vif = netdev_priv(net); + struct wilc_priv *priv = &vif->priv; + + priv->p2p_listen_state = false; + + flush_workqueue(vif->wilc->hif_workqueue); + mutex_destroy(&priv->scan_req_lock); + ret = wilc_deinit(vif); + + if (ret) + netdev_err(net, "Error while deinitializing host interface\n"); +} + diff --git a/drivers/staging/wilc1000/cfg80211.h b/drivers/staging/wilc1000/cfg80211.h new file mode 100644 index 000000000000..05c910baf095 --- /dev/null +++ b/drivers/staging/wilc1000/cfg80211.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#ifndef NM_WFI_CFGOPERATIONS +#define NM_WFI_CFGOPERATIONS +#include "netdev.h" + +struct wiphy *wilc_cfg_alloc(void); +int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, + const struct wilc_hif_func *ops); +struct wilc *wilc_create_wiphy(struct device *dev); +void wilc_deinit_host_int(struct net_device *net); +int wilc_init_host_int(struct net_device *net); +void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size); +struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name, + enum nl80211_iftype type); +void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked); +struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, + const char *name, + struct net_device *real_dev); +void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, + u16 frame_type, bool reg); +struct wilc_vif *wilc_get_interface(struct wilc *wl); +struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl); +void wlan_deinit_locks(struct wilc *wilc); +#endif diff --git a/drivers/staging/wilc1000/hif.c b/drivers/staging/wilc1000/hif.c new file mode 100644 index 000000000000..25f035c02b10 --- /dev/null +++ b/drivers/staging/wilc1000/hif.c @@ -0,0 +1,2043 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include "netdev.h" + +#define WILC_HIF_SCAN_TIMEOUT_MS 5000 +#define WILC_HIF_CONNECT_TIMEOUT_MS 9500 + +#define WILC_FALSE_FRMWR_CHANNEL 100 +#define WILC_MAX_RATES_SUPPORTED 12 + +struct wilc_rcvd_mac_info { + u8 status; +}; + +struct wilc_set_multicast { + u32 enabled; + u32 cnt; + u8 *mc_list; +}; + +struct wilc_del_all_sta { + u8 assoc_sta; + u8 mac[WILC_MAX_NUM_STA][ETH_ALEN]; +}; + +struct wilc_op_mode { + __le32 mode; +}; + +struct wilc_reg_frame { + u8 reg; + u8 reg_id; + __le16 frame_type; +} __packed; + +struct wilc_drv_handler { + __le32 handler; + u8 mode; +} __packed; + +struct wilc_wep_key { + u8 index; + u8 key_len; + u8 key[0]; +} __packed; + +struct wilc_sta_wpa_ptk { + u8 mac_addr[ETH_ALEN]; + u8 key_len; + u8 key[0]; +} __packed; + +struct wilc_ap_wpa_ptk { + u8 mac_addr[ETH_ALEN]; + u8 index; + u8 key_len; + u8 key[0]; +} __packed; + +struct wilc_gtk_key { + u8 mac_addr[ETH_ALEN]; + u8 rsc[8]; + u8 index; + u8 key_len; + u8 key[0]; +} __packed; + +union wilc_message_body { + struct wilc_rcvd_net_info net_info; + struct wilc_rcvd_mac_info mac_info; + struct wilc_set_multicast mc_info; + struct wilc_remain_ch remain_on_ch; + char *data; +}; + +struct host_if_msg { + union wilc_message_body body; + struct wilc_vif *vif; + struct work_struct work; + void (*fn)(struct work_struct *ws); + struct completion work_comp; + bool is_sync; +}; + +struct wilc_noa_opp_enable { + u8 ct_window; + u8 cnt; + __le32 duration; + __le32 interval; + __le32 start_time; +} __packed; + +struct wilc_noa_opp_disable { + u8 cnt; + __le32 duration; + __le32 interval; + __le32 start_time; +} __packed; + +struct wilc_join_bss_param { + char ssid[IEEE80211_MAX_SSID_LEN]; + u8 ssid_terminator; + u8 bss_type; + u8 ch; + __le16 cap_info; + u8 sa[ETH_ALEN]; + u8 bssid[ETH_ALEN]; + __le16 beacon_period; + u8 dtim_period; + u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1]; + u8 wmm_cap; + u8 uapsd_cap; + u8 ht_capable; + u8 rsn_found; + u8 rsn_grp_policy; + u8 mode_802_11i; + u8 p_suites[3]; + u8 akm_suites[3]; + u8 rsn_cap[2]; + u8 noa_enabled; + __le32 tsf_lo; + u8 idx; + u8 opp_enabled; + union { + struct wilc_noa_opp_disable opp_dis; + struct wilc_noa_opp_enable opp_en; + }; +} __packed; + +/* 'msg' should be free by the caller for syc */ +static struct host_if_msg* +wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *), + bool is_sync) +{ + struct host_if_msg *msg; + + if (!work_fun) + return ERR_PTR(-EINVAL); + + msg = kzalloc(sizeof(*msg), GFP_ATOMIC); + if (!msg) + return ERR_PTR(-ENOMEM); + msg->fn = work_fun; + msg->vif = vif; + msg->is_sync = is_sync; + if (is_sync) + init_completion(&msg->work_comp); + + return msg; +} + +static int wilc_enqueue_work(struct host_if_msg *msg) +{ + INIT_WORK(&msg->work, msg->fn); + + if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue) + return -EINVAL; + + if (!queue_work(msg->vif->wilc->hif_workqueue, &msg->work)) + return -EINVAL; + + return 0; +} + +/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as + * special purpose in wilc device, so we add 1 to the index to starts from 1. + * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC. + */ +int wilc_get_vif_idx(struct wilc_vif *vif) +{ + return vif->idx + 1; +} + +/* We need to minus 1 from idx which is from wilc device to get real index + * of wilc->vif[], because we add 1 when pass to wilc device in the function + * wilc_get_vif_idx. + * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1). + */ +static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) +{ + int index = idx - 1; + struct wilc_vif *vif; + + if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC) + return NULL; + + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->idx == index) + return vif; + } + + return NULL; +} + +static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) +{ + int result = 0; + u8 abort_running_scan; + struct wid wid; + struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_user_scan_req *scan_req; + + if (evt == SCAN_EVENT_ABORTED) { + abort_running_scan = 1; + wid.id = WID_ABORT_RUNNING_SCAN; + wid.type = WID_CHAR; + wid.val = (s8 *)&abort_running_scan; + wid.size = sizeof(char); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) { + netdev_err(vif->ndev, "Failed to set abort running\n"); + result = -EFAULT; + } + } + + if (!hif_drv) { + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); + return result; + } + + scan_req = &hif_drv->usr_scan_req; + if (scan_req->scan_result) { + scan_req->scan_result(evt, NULL, scan_req->arg); + scan_req->scan_result = NULL; + } + + return result; +} + +int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, + u8 *ch_freq_list, u8 ch_list_len, + void (*scan_result_fn)(enum scan_event, + struct wilc_rcvd_net_info *, void *), + void *user_arg, struct cfg80211_scan_request *request) +{ + int result = 0; + struct wid wid_list[5]; + u32 index = 0; + u32 i, scan_timeout; + u8 *buffer; + u8 valuesize = 0; + u8 *search_ssid_vals = NULL; + struct host_if_drv *hif_drv = vif->hif_drv; + + if (hif_drv->hif_state >= HOST_IF_SCANNING && + hif_drv->hif_state < HOST_IF_CONNECTED) { + netdev_err(vif->ndev, "Already scan\n"); + result = -EBUSY; + goto error; + } + + if (vif->connecting) { + netdev_err(vif->ndev, "Don't do obss scan\n"); + result = -EBUSY; + goto error; + } + + hif_drv->usr_scan_req.ch_cnt = 0; + + if (request->n_ssids) { + for (i = 0; i < request->n_ssids; i++) + valuesize += ((request->ssids[i].ssid_len) + 1); + search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL); + if (search_ssid_vals) { + wid_list[index].id = WID_SSID_PROBE_REQ; + wid_list[index].type = WID_STR; + wid_list[index].val = search_ssid_vals; + buffer = wid_list[index].val; + + *buffer++ = request->n_ssids; + + for (i = 0; i < request->n_ssids; i++) { + *buffer++ = request->ssids[i].ssid_len; + memcpy(buffer, request->ssids[i].ssid, + request->ssids[i].ssid_len); + buffer += request->ssids[i].ssid_len; + } + wid_list[index].size = (s32)(valuesize + 1); + index++; + } + } + + wid_list[index].id = WID_INFO_ELEMENT_PROBE; + wid_list[index].type = WID_BIN_DATA; + wid_list[index].val = (s8 *)request->ie; + wid_list[index].size = request->ie_len; + index++; + + wid_list[index].id = WID_SCAN_TYPE; + wid_list[index].type = WID_CHAR; + wid_list[index].size = sizeof(char); + wid_list[index].val = (s8 *)&scan_type; + index++; + + if (scan_type == WILC_FW_PASSIVE_SCAN && request->duration) { + wid_list[index].id = WID_PASSIVE_SCAN_TIME; + wid_list[index].type = WID_SHORT; + wid_list[index].size = sizeof(u16); + wid_list[index].val = (s8 *)&request->duration; + index++; + + scan_timeout = (request->duration * ch_list_len) + 500; + } else { + scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS; + } + + wid_list[index].id = WID_SCAN_CHANNEL_LIST; + wid_list[index].type = WID_BIN_DATA; + + if (ch_freq_list && ch_list_len > 0) { + for (i = 0; i < ch_list_len; i++) { + if (ch_freq_list[i] > 0) + ch_freq_list[i] -= 1; + } + } + + wid_list[index].val = ch_freq_list; + wid_list[index].size = ch_list_len; + index++; + + wid_list[index].id = WID_START_SCAN_REQ; + wid_list[index].type = WID_CHAR; + wid_list[index].size = sizeof(char); + wid_list[index].val = (s8 *)&scan_source; + index++; + + hif_drv->usr_scan_req.scan_result = scan_result_fn; + hif_drv->usr_scan_req.arg = user_arg; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index); + if (result) { + netdev_err(vif->ndev, "Failed to send scan parameters\n"); + goto error; + } + + hif_drv->scan_timer_vif = vif; + mod_timer(&hif_drv->scan_timer, + jiffies + msecs_to_jiffies(scan_timeout)); + +error: + + kfree(search_ssid_vals); + + return result; +} + +static int wilc_send_connect_wid(struct wilc_vif *vif) +{ + int result = 0; + struct wid wid_list[4]; + u32 wid_cnt = 0; + struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_conn_info *conn_attr = &hif_drv->conn_info; + struct wilc_join_bss_param *bss_param = conn_attr->param; + + wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE; + wid_list[wid_cnt].type = WID_BIN_DATA; + wid_list[wid_cnt].val = conn_attr->req_ies; + wid_list[wid_cnt].size = conn_attr->req_ies_len; + wid_cnt++; + + wid_list[wid_cnt].id = WID_11I_MODE; + wid_list[wid_cnt].type = WID_CHAR; + wid_list[wid_cnt].size = sizeof(char); + wid_list[wid_cnt].val = (s8 *)&conn_attr->security; + wid_cnt++; + + wid_list[wid_cnt].id = WID_AUTH_TYPE; + wid_list[wid_cnt].type = WID_CHAR; + wid_list[wid_cnt].size = sizeof(char); + wid_list[wid_cnt].val = (s8 *)&conn_attr->auth_type; + wid_cnt++; + + wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED; + wid_list[wid_cnt].type = WID_STR; + wid_list[wid_cnt].size = sizeof(*bss_param); + wid_list[wid_cnt].val = (u8 *)bss_param; + wid_cnt++; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, wid_cnt); + if (result) { + netdev_err(vif->ndev, "failed to send config packet\n"); + goto error; + } else { + hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; + } + + return 0; + +error: + + kfree(conn_attr->req_ies); + conn_attr->req_ies = NULL; + + return result; +} + +static void handle_connect_timeout(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + int result; + struct wid wid; + u16 dummy_reason_code = 0; + struct host_if_drv *hif_drv = vif->hif_drv; + + if (!hif_drv) { + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); + goto out; + } + + hif_drv->hif_state = HOST_IF_IDLE; + + if (hif_drv->conn_info.conn_result) { + hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_CONN_RESP, + WILC_MAC_STATUS_DISCONNECTED, + hif_drv->conn_info.arg); + + } else { + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); + } + + wid.id = WID_DISCONNECT; + wid.type = WID_CHAR; + wid.val = (s8 *)&dummy_reason_code; + wid.size = sizeof(char); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send disconnect\n"); + + hif_drv->conn_info.req_ies_len = 0; + kfree(hif_drv->conn_info.req_ies); + hif_drv->conn_info.req_ies = NULL; + +out: + kfree(msg); +} + +void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, + struct cfg80211_crypto_settings *crypto) +{ + struct wilc_join_bss_param *param; + struct ieee80211_p2p_noa_attr noa_attr; + u8 rates_len = 0; + const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie; + const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie; + int ret; + const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies); + + param = kzalloc(sizeof(*param), GFP_KERNEL); + if (!param) + return NULL; + + param->beacon_period = cpu_to_le16(bss->beacon_interval); + param->cap_info = cpu_to_le16(bss->capability); + param->bss_type = WILC_FW_BSS_TYPE_INFRA; + param->ch = ieee80211_frequency_to_channel(bss->channel->center_freq); + ether_addr_copy(param->bssid, bss->bssid); + + ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len); + if (ssid_elm) { + if (ssid_elm[1] <= IEEE80211_MAX_SSID_LEN) + memcpy(param->ssid, ssid_elm + 2, ssid_elm[1]); + } + + tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len); + if (tim_elm && tim_elm[1] >= 2) + param->dtim_period = tim_elm[3]; + + memset(param->p_suites, 0xFF, 3); + memset(param->akm_suites, 0xFF, 3); + + rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len); + if (rates_ie) { + rates_len = rates_ie[1]; + if (rates_len > WILC_MAX_RATES_SUPPORTED) + rates_len = WILC_MAX_RATES_SUPPORTED; + param->supp_rates[0] = rates_len; + memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len); + } + + supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies->data, + ies->len); + if (supp_rates_ie) { + if (supp_rates_ie[1] > (WILC_MAX_RATES_SUPPORTED - rates_len)) + param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; + else + param->supp_rates[0] += supp_rates_ie[1]; + + memcpy(¶m->supp_rates[rates_len + 1], supp_rates_ie + 2, + (param->supp_rates[0] - rates_len)); + } + + ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len); + if (ht_ie) + param->ht_capable = true; + + ret = cfg80211_get_p2p_attr(ies->data, ies->len, + IEEE80211_P2P_ATTR_ABSENCE_NOTICE, + (u8 *)&noa_attr, sizeof(noa_attr)); + if (ret > 0) { + param->tsf_lo = cpu_to_le32(ies->tsf); + param->noa_enabled = 1; + param->idx = noa_attr.index; + if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) { + param->opp_enabled = 1; + param->opp_en.ct_window = noa_attr.oppps_ctwindow; + param->opp_en.cnt = noa_attr.desc[0].count; + param->opp_en.duration = noa_attr.desc[0].duration; + param->opp_en.interval = noa_attr.desc[0].interval; + param->opp_en.start_time = noa_attr.desc[0].start_time; + } else { + param->opp_enabled = 0; + param->opp_dis.cnt = noa_attr.desc[0].count; + param->opp_dis.duration = noa_attr.desc[0].duration; + param->opp_dis.interval = noa_attr.desc[0].interval; + param->opp_dis.start_time = noa_attr.desc[0].start_time; + } + } + wmm_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WMM, + ies->data, ies->len); + if (wmm_ie) { + struct ieee80211_wmm_param_ie *ie; + + ie = (struct ieee80211_wmm_param_ie *)wmm_ie; + if ((ie->oui_subtype == 0 || ie->oui_subtype == 1) && + ie->version == 1) { + param->wmm_cap = true; + if (ie->qos_info & BIT(7)) + param->uapsd_cap = true; + } + } + + wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + ies->data, ies->len); + if (wpa_ie) { + param->mode_802_11i = 1; + param->rsn_found = true; + } + + rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies->data, ies->len); + if (rsn_ie) { + int offset = 8; + + param->mode_802_11i = 2; + param->rsn_found = true; + //extract RSN capabilities + offset += (rsn_ie[offset] * 4) + 2; + offset += (rsn_ie[offset] * 4) + 2; + memcpy(param->rsn_cap, &rsn_ie[offset], 2); + } + + if (param->rsn_found) { + int i; + + param->rsn_grp_policy = crypto->cipher_group & 0xFF; + for (i = 0; i < crypto->n_ciphers_pairwise && i < 3; i++) + param->p_suites[i] = crypto->ciphers_pairwise[i] & 0xFF; + + for (i = 0; i < crypto->n_akm_suites && i < 3; i++) + param->akm_suites[i] = crypto->akm_suites[i] & 0xFF; + } + + return (void *)param; +} + +static void handle_rcvd_ntwrk_info(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_rcvd_net_info *rcvd_info = &msg->body.net_info; + struct wilc_user_scan_req *scan_req = &msg->vif->hif_drv->usr_scan_req; + const u8 *ch_elm; + u8 *ies; + int ies_len; + size_t offset; + + if (ieee80211_is_probe_resp(rcvd_info->mgmt->frame_control)) + offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); + else if (ieee80211_is_beacon(rcvd_info->mgmt->frame_control)) + offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + else + goto done; + + ies = rcvd_info->mgmt->u.beacon.variable; + ies_len = rcvd_info->frame_len - offset; + if (ies_len <= 0) + goto done; + + ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); + if (ch_elm && ch_elm[1] > 0) + rcvd_info->ch = ch_elm[2]; + + if (scan_req->scan_result) + scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, rcvd_info, + scan_req->arg); + +done: + kfree(rcvd_info->mgmt); + kfree(msg); +} + +static void host_int_get_assoc_res_info(struct wilc_vif *vif, + u8 *assoc_resp_info, + u32 max_assoc_resp_info_len, + u32 *rcvd_assoc_resp_info_len) +{ + int result; + struct wid wid; + + wid.id = WID_ASSOC_RES_INFO; + wid.type = WID_STR; + wid.val = assoc_resp_info; + wid.size = max_assoc_resp_info_len; + + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); + if (result) { + *rcvd_assoc_resp_info_len = 0; + netdev_err(vif->ndev, "Failed to send association response\n"); + return; + } + + *rcvd_assoc_resp_info_len = wid.size; +} + +static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, + struct wilc_conn_info *ret_conn_info) +{ + u8 *ies; + u16 ies_len; + struct assoc_resp *res = (struct assoc_resp *)buffer; + + ret_conn_info->status = le16_to_cpu(res->status_code); + if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { + ies = &buffer[sizeof(*res)]; + ies_len = buffer_len - sizeof(*res); + + ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!ret_conn_info->resp_ies) + return -ENOMEM; + + ret_conn_info->resp_ies_len = ies_len; + } + + return 0; +} + +static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, + u8 mac_status) +{ + struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_conn_info *conn_info = &hif_drv->conn_info; + + if (mac_status == WILC_MAC_STATUS_CONNECTED) { + u32 assoc_resp_info_len; + + memset(hif_drv->assoc_resp, 0, WILC_MAX_ASSOC_RESP_FRAME_SIZE); + + host_int_get_assoc_res_info(vif, hif_drv->assoc_resp, + WILC_MAX_ASSOC_RESP_FRAME_SIZE, + &assoc_resp_info_len); + + if (assoc_resp_info_len != 0) { + s32 err = 0; + + err = wilc_parse_assoc_resp_info(hif_drv->assoc_resp, + assoc_resp_info_len, + conn_info); + if (err) + netdev_err(vif->ndev, + "wilc_parse_assoc_resp_info() returned error %d\n", + err); + } + } + + del_timer(&hif_drv->connect_timer); + conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status, + hif_drv->conn_info.arg); + + if (mac_status == WILC_MAC_STATUS_CONNECTED && + conn_info->status == WLAN_STATUS_SUCCESS) { + ether_addr_copy(hif_drv->assoc_bssid, conn_info->bssid); + hif_drv->hif_state = HOST_IF_CONNECTED; + } else { + hif_drv->hif_state = HOST_IF_IDLE; + } + + kfree(conn_info->resp_ies); + conn_info->resp_ies = NULL; + conn_info->resp_ies_len = 0; + + kfree(conn_info->req_ies); + conn_info->req_ies = NULL; + conn_info->req_ies_len = 0; +} + +static inline void host_int_handle_disconnect(struct wilc_vif *vif) +{ + struct host_if_drv *hif_drv = vif->hif_drv; + + if (hif_drv->usr_scan_req.scan_result) { + del_timer(&hif_drv->scan_timer); + handle_scan_done(vif, SCAN_EVENT_ABORTED); + } + + if (hif_drv->conn_info.conn_result) + hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, + 0, hif_drv->conn_info.arg); + else + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); + + eth_zero_addr(hif_drv->assoc_bssid); + + hif_drv->conn_info.req_ies_len = 0; + kfree(hif_drv->conn_info.req_ies); + hif_drv->conn_info.req_ies = NULL; + hif_drv->hif_state = HOST_IF_IDLE; +} + +static void handle_rcvd_gnrl_async_info(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct wilc_rcvd_mac_info *mac_info = &msg->body.mac_info; + struct host_if_drv *hif_drv = vif->hif_drv; + + if (!hif_drv) { + netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); + goto free_msg; + } + + if (!hif_drv->conn_info.conn_result) { + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); + goto free_msg; + } + + if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { + host_int_parse_assoc_resp_info(vif, mac_info->status); + } else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) { + if (hif_drv->hif_state == HOST_IF_CONNECTED) { + host_int_handle_disconnect(vif); + } else if (hif_drv->usr_scan_req.scan_result) { + del_timer(&hif_drv->scan_timer); + handle_scan_done(vif, SCAN_EVENT_ABORTED); + } + } + +free_msg: + kfree(msg); +} + +int wilc_disconnect(struct wilc_vif *vif) +{ + struct wid wid; + struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_user_scan_req *scan_req; + struct wilc_conn_info *conn_info; + int result; + u16 dummy_reason_code = 0; + + wid.id = WID_DISCONNECT; + wid.type = WID_CHAR; + wid.val = (s8 *)&dummy_reason_code; + wid.size = sizeof(char); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) { + netdev_err(vif->ndev, "Failed to send disconnect\n"); + return result; + } + + scan_req = &hif_drv->usr_scan_req; + conn_info = &hif_drv->conn_info; + + if (scan_req->scan_result) { + del_timer(&hif_drv->scan_timer); + scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg); + scan_req->scan_result = NULL; + } + + if (conn_info->conn_result) { + if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) + del_timer(&hif_drv->connect_timer); + + conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0, + conn_info->arg); + } else { + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); + } + + hif_drv->hif_state = HOST_IF_IDLE; + + eth_zero_addr(hif_drv->assoc_bssid); + + conn_info->req_ies_len = 0; + kfree(conn_info->req_ies); + conn_info->req_ies = NULL; + + return 0; +} + +int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) +{ + struct wid wid_list[5]; + u32 wid_cnt = 0, result; + + wid_list[wid_cnt].id = WID_LINKSPEED; + wid_list[wid_cnt].type = WID_CHAR; + wid_list[wid_cnt].size = sizeof(char); + wid_list[wid_cnt].val = (s8 *)&stats->link_speed; + wid_cnt++; + + wid_list[wid_cnt].id = WID_RSSI; + wid_list[wid_cnt].type = WID_CHAR; + wid_list[wid_cnt].size = sizeof(char); + wid_list[wid_cnt].val = (s8 *)&stats->rssi; + wid_cnt++; + + wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT; + wid_list[wid_cnt].type = WID_INT; + wid_list[wid_cnt].size = sizeof(u32); + wid_list[wid_cnt].val = (s8 *)&stats->tx_cnt; + wid_cnt++; + + wid_list[wid_cnt].id = WID_RECEIVED_FRAGMENT_COUNT; + wid_list[wid_cnt].type = WID_INT; + wid_list[wid_cnt].size = sizeof(u32); + wid_list[wid_cnt].val = (s8 *)&stats->rx_cnt; + wid_cnt++; + + wid_list[wid_cnt].id = WID_FAILED_COUNT; + wid_list[wid_cnt].type = WID_INT; + wid_list[wid_cnt].size = sizeof(u32); + wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt; + wid_cnt++; + + result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt); + if (result) { + netdev_err(vif->ndev, "Failed to send scan parameters\n"); + return result; + } + + if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && + stats->link_speed != DEFAULT_LINK_SPEED) + wilc_enable_tcp_ack_filter(vif, true); + else if (stats->link_speed != DEFAULT_LINK_SPEED) + wilc_enable_tcp_ack_filter(vif, false); + + return result; +} + +static void handle_get_statistics(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct rf_info *stats = (struct rf_info *)msg->body.data; + + wilc_get_statistics(vif, stats); + + kfree(msg); +} + +static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, + struct station_parameters *params) +{ + ether_addr_copy(cur_byte, mac); + cur_byte += ETH_ALEN; + + put_unaligned_le16(params->aid, cur_byte); + cur_byte += 2; + + *cur_byte++ = params->supported_rates_len; + if (params->supported_rates_len > 0) + memcpy(cur_byte, params->supported_rates, + params->supported_rates_len); + cur_byte += params->supported_rates_len; + + if (params->ht_capa) { + *cur_byte++ = true; + memcpy(cur_byte, ¶ms->ht_capa, + sizeof(struct ieee80211_ht_cap)); + } else { + *cur_byte++ = false; + } + cur_byte += sizeof(struct ieee80211_ht_cap); + + put_unaligned_le16(params->sta_flags_mask, cur_byte); + cur_byte += 2; + put_unaligned_le16(params->sta_flags_set, cur_byte); +} + +static int handle_remain_on_chan(struct wilc_vif *vif, + struct wilc_remain_ch *hif_remain_ch) +{ + int result; + u8 remain_on_chan_flag; + struct wid wid; + struct host_if_drv *hif_drv = vif->hif_drv; + + if (hif_drv->usr_scan_req.scan_result) + return -EBUSY; + + if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) + return -EBUSY; + + if (vif->connecting) + return -EBUSY; + + remain_on_chan_flag = true; + wid.id = WID_REMAIN_ON_CHAN; + wid.type = WID_STR; + wid.size = 2; + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + wid.val[0] = remain_on_chan_flag; + wid.val[1] = (s8)hif_remain_ch->ch; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + kfree(wid.val); + if (result) + return -EBUSY; + + hif_drv->remain_on_ch.arg = hif_remain_ch->arg; + hif_drv->remain_on_ch.expired = hif_remain_ch->expired; + hif_drv->remain_on_ch.ch = hif_remain_ch->ch; + hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie; + hif_drv->remain_on_ch_timer_vif = vif; + + return 0; +} + +static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie) +{ + u8 remain_on_chan_flag; + struct wid wid; + int result; + struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr); + + if (priv->p2p_listen_state) { + remain_on_chan_flag = false; + wid.id = WID_REMAIN_ON_CHAN; + wid.type = WID_STR; + wid.size = 2; + + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + wid.val[0] = remain_on_chan_flag; + wid.val[1] = WILC_FALSE_FRMWR_CHANNEL; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + kfree(wid.val); + if (result != 0) { + netdev_err(vif->ndev, "Failed to set remain channel\n"); + return -EINVAL; + } + + if (hif_drv->remain_on_ch.expired) { + hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg, + cookie); + } + } else { + netdev_dbg(vif->ndev, "Not in listen state\n"); + } + + return 0; +} + +static void wilc_handle_listen_state_expired(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + + wilc_handle_roc_expired(msg->vif, msg->body.remain_on_ch.cookie); + kfree(msg); +} + +static void listen_timer_cb(struct timer_list *t) +{ + struct host_if_drv *hif_drv = from_timer(hif_drv, t, + remain_on_ch_timer); + struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; + int result; + struct host_if_msg *msg; + + del_timer(&vif->hif_drv->remain_on_ch_timer); + + msg = wilc_alloc_work(vif, wilc_handle_listen_state_expired, false); + if (IS_ERR(msg)) + return; + + msg->body.remain_on_ch.cookie = vif->hif_drv->remain_on_ch.cookie; + + result = wilc_enqueue_work(msg); + if (result) { + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + kfree(msg); + } +} + +static void handle_set_mcast_filter(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct wilc_set_multicast *set_mc = &msg->body.mc_info; + int result; + struct wid wid; + u8 *cur_byte; + + wid.id = WID_SETUP_MULTICAST_FILTER; + wid.type = WID_BIN; + wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN); + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + goto error; + + cur_byte = wid.val; + put_unaligned_le32(set_mc->enabled, cur_byte); + cur_byte += 4; + + put_unaligned_le32(set_mc->cnt, cur_byte); + cur_byte += 4; + + if (set_mc->cnt > 0 && set_mc->mc_list) + memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send setup multicast\n"); + +error: + kfree(set_mc->mc_list); + kfree(wid.val); + kfree(msg); +} + +static void handle_scan_timer(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + + handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); + kfree(msg); +} + +static void handle_scan_complete(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + + del_timer(&msg->vif->hif_drv->scan_timer); + + handle_scan_done(msg->vif, SCAN_EVENT_DONE); + + kfree(msg); +} + +static void timer_scan_cb(struct timer_list *t) +{ + struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer); + struct wilc_vif *vif = hif_drv->scan_timer_vif; + struct host_if_msg *msg; + int result; + + msg = wilc_alloc_work(vif, handle_scan_timer, false); + if (IS_ERR(msg)) + return; + + result = wilc_enqueue_work(msg); + if (result) + kfree(msg); +} + +static void timer_connect_cb(struct timer_list *t) +{ + struct host_if_drv *hif_drv = from_timer(hif_drv, t, + connect_timer); + struct wilc_vif *vif = hif_drv->connect_timer_vif; + struct host_if_msg *msg; + int result; + + msg = wilc_alloc_work(vif, handle_connect_timeout, false); + if (IS_ERR(msg)) + return; + + result = wilc_enqueue_work(msg); + if (result) + kfree(msg); +} + +int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) +{ + struct wid wid; + int result; + + wid.id = WID_REMOVE_WEP_KEY; + wid.type = WID_STR; + wid.size = sizeof(char); + wid.val = &index; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, + "Failed to send remove wep key config packet\n"); + return result; +} + +int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) +{ + struct wid wid; + int result; + + wid.id = WID_KEY_ID; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = &index; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, + "Failed to send wep default key config packet\n"); + + return result; +} + +int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, + u8 index) +{ + struct wid wid; + int result; + struct wilc_wep_key *wep_key; + + wid.id = WID_ADD_WEP_KEY; + wid.type = WID_STR; + wid.size = sizeof(*wep_key) + len; + wep_key = kzalloc(wid.size, GFP_KERNEL); + if (!wep_key) + return -ENOMEM; + + wid.val = (u8 *)wep_key; + + wep_key->index = index; + wep_key->key_len = len; + memcpy(wep_key->key, key, len); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, + "Failed to add wep key config packet\n"); + + kfree(wep_key); + return result; +} + +int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, + u8 index, u8 mode, enum authtype auth_type) +{ + struct wid wid_list[3]; + int result; + struct wilc_wep_key *wep_key; + + wid_list[0].id = WID_11I_MODE; + wid_list[0].type = WID_CHAR; + wid_list[0].size = sizeof(char); + wid_list[0].val = &mode; + + wid_list[1].id = WID_AUTH_TYPE; + wid_list[1].type = WID_CHAR; + wid_list[1].size = sizeof(char); + wid_list[1].val = (s8 *)&auth_type; + + wid_list[2].id = WID_WEP_KEY_VALUE; + wid_list[2].type = WID_STR; + wid_list[2].size = sizeof(*wep_key) + len; + wep_key = kzalloc(wid_list[2].size, GFP_KERNEL); + if (!wep_key) + return -ENOMEM; + + wid_list[2].val = (u8 *)wep_key; + + wep_key->index = index; + wep_key->key_len = len; + memcpy(wep_key->key, key, len); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + ARRAY_SIZE(wid_list)); + if (result) + netdev_err(vif->ndev, + "Failed to add wep ap key config packet\n"); + + kfree(wep_key); + return result; +} + +int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, + const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, + u8 mode, u8 cipher_mode, u8 index) +{ + int result = 0; + u8 t_key_len = ptk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; + + if (mode == WILC_AP_MODE) { + struct wid wid_list[2]; + struct wilc_ap_wpa_ptk *key_buf; + + wid_list[0].id = WID_11I_MODE; + wid_list[0].type = WID_CHAR; + wid_list[0].size = sizeof(char); + wid_list[0].val = (s8 *)&cipher_mode; + + key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); + if (!key_buf) + return -ENOMEM; + + ether_addr_copy(key_buf->mac_addr, mac_addr); + key_buf->index = index; + key_buf->key_len = t_key_len; + memcpy(&key_buf->key[0], ptk, ptk_key_len); + + if (rx_mic) + memcpy(&key_buf->key[ptk_key_len], rx_mic, + WILC_RX_MIC_KEY_LEN); + + if (tx_mic) + memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], + tx_mic, WILC_TX_MIC_KEY_LEN); + + wid_list[1].id = WID_ADD_PTK; + wid_list[1].type = WID_STR; + wid_list[1].size = sizeof(*key_buf) + t_key_len; + wid_list[1].val = (u8 *)key_buf; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + ARRAY_SIZE(wid_list)); + kfree(key_buf); + } else if (mode == WILC_STATION_MODE) { + struct wid wid; + struct wilc_sta_wpa_ptk *key_buf; + + key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); + if (!key_buf) + return -ENOMEM; + + ether_addr_copy(key_buf->mac_addr, mac_addr); + key_buf->key_len = t_key_len; + memcpy(&key_buf->key[0], ptk, ptk_key_len); + + if (rx_mic) + memcpy(&key_buf->key[ptk_key_len], rx_mic, + WILC_RX_MIC_KEY_LEN); + + if (tx_mic) + memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], + tx_mic, WILC_TX_MIC_KEY_LEN); + + wid.id = WID_ADD_PTK; + wid.type = WID_STR; + wid.size = sizeof(*key_buf) + t_key_len; + wid.val = (s8 *)key_buf; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + kfree(key_buf); + } + + return result; +} + +int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, + u8 index, u32 key_rsc_len, const u8 *key_rsc, + const u8 *rx_mic, const u8 *tx_mic, u8 mode, + u8 cipher_mode) +{ + int result = 0; + struct wilc_gtk_key *gtk_key; + int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; + + gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL); + if (!gtk_key) + return -ENOMEM; + + /* fill bssid value only in station mode */ + if (mode == WILC_STATION_MODE && + vif->hif_drv->hif_state == HOST_IF_CONNECTED) + memcpy(gtk_key->mac_addr, vif->hif_drv->assoc_bssid, ETH_ALEN); + + if (key_rsc) + memcpy(gtk_key->rsc, key_rsc, 8); + gtk_key->index = index; + gtk_key->key_len = t_key_len; + memcpy(>k_key->key[0], rx_gtk, gtk_key_len); + + if (rx_mic) + memcpy(>k_key->key[gtk_key_len], rx_mic, WILC_RX_MIC_KEY_LEN); + + if (tx_mic) + memcpy(>k_key->key[gtk_key_len + WILC_RX_MIC_KEY_LEN], + tx_mic, WILC_TX_MIC_KEY_LEN); + + if (mode == WILC_AP_MODE) { + struct wid wid_list[2]; + + wid_list[0].id = WID_11I_MODE; + wid_list[0].type = WID_CHAR; + wid_list[0].size = sizeof(char); + wid_list[0].val = (s8 *)&cipher_mode; + + wid_list[1].id = WID_ADD_RX_GTK; + wid_list[1].type = WID_STR; + wid_list[1].size = sizeof(*gtk_key) + t_key_len; + wid_list[1].val = (u8 *)gtk_key; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + ARRAY_SIZE(wid_list)); + } else if (mode == WILC_STATION_MODE) { + struct wid wid; + + wid.id = WID_ADD_RX_GTK; + wid.type = WID_STR; + wid.size = sizeof(*gtk_key) + t_key_len; + wid.val = (u8 *)gtk_key; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + } + + kfree(gtk_key); + return result; +} + +int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) +{ + struct wid wid; + + wid.id = WID_PMKID_INFO; + wid.type = WID_STR; + wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1; + wid.val = (u8 *)pmkid; + + return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); +} + +int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) +{ + int result; + struct wid wid; + + wid.id = WID_MAC_ADDR; + wid.type = WID_STR; + wid.size = ETH_ALEN; + wid.val = mac_addr; + + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to get mac address\n"); + + return result; +} + +int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, + size_t ies_len) +{ + int result; + struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_conn_info *conn_info = &hif_drv->conn_info; + + if (bssid) + ether_addr_copy(conn_info->bssid, bssid); + + if (ies) { + conn_info->req_ies_len = ies_len; + conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!conn_info->req_ies) + return -ENOMEM; + } + + result = wilc_send_connect_wid(vif); + if (result) + goto free_ies; + + hif_drv->connect_timer_vif = vif; + mod_timer(&hif_drv->connect_timer, + jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS)); + + return 0; + +free_ies: + kfree(conn_info->req_ies); + + return result; +} + +int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) +{ + struct wid wid; + int result; + + wid.id = WID_CURRENT_CHANNEL; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = &channel; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to set channel\n"); + + return result; +} + +int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode, + u8 ifc_id) +{ + struct wid wid; + int result; + struct wilc_drv_handler drv; + + wid.id = WID_SET_OPERATION_MODE; + wid.type = WID_STR; + wid.size = sizeof(drv); + wid.val = (u8 *)&drv; + + drv.handler = cpu_to_le32(index); + drv.mode = (ifc_id | (mode << 1)); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to set driver handler\n"); + + return result; +} + +s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) +{ + struct wid wid; + s32 result; + + wid.id = WID_SET_STA_MAC_INACTIVE_TIME; + wid.type = WID_STR; + wid.size = ETH_ALEN; + wid.val = kzalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + ether_addr_copy(wid.val, mac); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + kfree(wid.val); + if (result) { + netdev_err(vif->ndev, "Failed to set inactive mac\n"); + return result; + } + + wid.id = WID_GET_INACTIVE_TIME; + wid.type = WID_INT; + wid.val = (s8 *)out_val; + wid.size = sizeof(u32); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to get inactive time\n"); + + return result; +} + +int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) +{ + struct wid wid; + int result; + + if (!rssi_level) { + netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__); + return -EFAULT; + } + + wid.id = WID_RSSI; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = rssi_level; + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to get RSSI value\n"); + + return result; +} + +static int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats) +{ + int result; + struct host_if_msg *msg; + + msg = wilc_alloc_work(vif, handle_get_statistics, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + msg->body.data = (char *)stats; + + result = wilc_enqueue_work(msg); + if (result) { + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + kfree(msg); + return result; + } + + return result; +} + +int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) +{ + struct wid wid_list[4]; + int i = 0; + + if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { + wid_list[i].id = WID_SHORT_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->short_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { + wid_list[i].id = WID_LONG_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->long_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { + wid_list[i].id = WID_FRAG_THRESHOLD; + wid_list[i].val = (s8 *)¶m->frag_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { + wid_list[i].id = WID_RTS_THRESHOLD; + wid_list[i].val = (s8 *)¶m->rts_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + + return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i); +} + +static void get_periodic_rssi(struct timer_list *t) +{ + struct wilc_vif *vif = from_timer(vif, t, periodic_rssi); + + if (!vif->hif_drv) { + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); + return; + } + + if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) + wilc_get_stats_async(vif, &vif->periodic_stat); + + mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); +} + +int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) +{ + struct host_if_drv *hif_drv; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); + if (!hif_drv) + return -ENOMEM; + + *hif_drv_handler = hif_drv; + + vif->hif_drv = hif_drv; + + if (wilc->clients_count == 0) + mutex_init(&wilc->deinit_lock); + + timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0); + mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); + + timer_setup(&hif_drv->scan_timer, timer_scan_cb, 0); + timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0); + timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0); + + hif_drv->hif_state = HOST_IF_IDLE; + + hif_drv->p2p_timeout = 0; + + wilc->clients_count++; + + return 0; +} + +int wilc_deinit(struct wilc_vif *vif) +{ + int result = 0; + struct host_if_drv *hif_drv = vif->hif_drv; + + if (!hif_drv) { + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); + return -EFAULT; + } + + mutex_lock(&vif->wilc->deinit_lock); + + del_timer_sync(&hif_drv->scan_timer); + del_timer_sync(&hif_drv->connect_timer); + del_timer_sync(&vif->periodic_rssi); + del_timer_sync(&hif_drv->remain_on_ch_timer); + + if (hif_drv->usr_scan_req.scan_result) { + hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, + hif_drv->usr_scan_req.arg); + hif_drv->usr_scan_req.scan_result = NULL; + } + + hif_drv->hif_state = HOST_IF_IDLE; + + kfree(hif_drv); + vif->hif_drv = NULL; + vif->wilc->clients_count--; + mutex_unlock(&vif->wilc->deinit_lock); + return result; +} + +void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) +{ + int result; + struct host_if_msg *msg; + int id; + struct host_if_drv *hif_drv; + struct wilc_vif *vif; + + id = get_unaligned_le32(&buffer[length - 4]); + vif = wilc_get_vif_from_idx(wilc, id); + if (!vif) + return; + hif_drv = vif->hif_drv; + + if (!hif_drv) { + netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); + return; + } + + msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false); + if (IS_ERR(msg)) + return; + + msg->body.net_info.frame_len = get_unaligned_le16(&buffer[6]) - 1; + msg->body.net_info.rssi = buffer[8]; + msg->body.net_info.mgmt = kmemdup(&buffer[9], + msg->body.net_info.frame_len, + GFP_KERNEL); + if (!msg->body.net_info.mgmt) { + kfree(msg); + return; + } + + result = wilc_enqueue_work(msg); + if (result) { + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + kfree(msg->body.net_info.mgmt); + kfree(msg); + } +} + +void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) +{ + int result; + struct host_if_msg *msg; + int id; + struct host_if_drv *hif_drv; + struct wilc_vif *vif; + + mutex_lock(&wilc->deinit_lock); + + id = get_unaligned_le32(&buffer[length - 4]); + vif = wilc_get_vif_from_idx(wilc, id); + if (!vif) { + mutex_unlock(&wilc->deinit_lock); + return; + } + + hif_drv = vif->hif_drv; + + if (!hif_drv) { + mutex_unlock(&wilc->deinit_lock); + return; + } + + if (!hif_drv->conn_info.conn_result) { + netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); + mutex_unlock(&wilc->deinit_lock); + return; + } + + msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false); + if (IS_ERR(msg)) { + mutex_unlock(&wilc->deinit_lock); + return; + } + + msg->body.mac_info.status = buffer[7]; + result = wilc_enqueue_work(msg); + if (result) { + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + kfree(msg); + } + + mutex_unlock(&wilc->deinit_lock); +} + +void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) +{ + int result; + int id; + struct host_if_drv *hif_drv; + struct wilc_vif *vif; + + id = get_unaligned_le32(&buffer[length - 4]); + vif = wilc_get_vif_from_idx(wilc, id); + if (!vif) + return; + hif_drv = vif->hif_drv; + + if (!hif_drv) + return; + + if (hif_drv->usr_scan_req.scan_result) { + struct host_if_msg *msg; + + msg = wilc_alloc_work(vif, handle_scan_complete, false); + if (IS_ERR(msg)) + return; + + result = wilc_enqueue_work(msg); + if (result) { + netdev_err(vif->ndev, "%s: enqueue work failed\n", + __func__); + kfree(msg); + } + } +} + +int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, + u32 duration, u16 chan, + void (*expired)(void *, u64), + void *user_arg) +{ + struct wilc_remain_ch roc; + int result; + + roc.ch = chan; + roc.expired = expired; + roc.arg = user_arg; + roc.duration = duration; + roc.cookie = cookie; + result = handle_remain_on_chan(vif, &roc); + if (result) + netdev_err(vif->ndev, "%s: failed to set remain on channel\n", + __func__); + + return result; +} + +int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie) +{ + if (!vif->hif_drv) { + netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); + return -EFAULT; + } + + del_timer(&vif->hif_drv->remain_on_ch_timer); + + return wilc_handle_roc_expired(vif, cookie); +} + +void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) +{ + struct wid wid; + int result; + struct wilc_reg_frame reg_frame; + + wid.id = WID_REGISTER_FRAME; + wid.type = WID_STR; + wid.size = sizeof(reg_frame); + wid.val = (u8 *)®_frame; + + memset(®_frame, 0x0, sizeof(reg_frame)); + + if (reg) + reg_frame.reg = 1; + + switch (frame_type) { + case IEEE80211_STYPE_ACTION: + reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; + break; + + case IEEE80211_STYPE_PROBE_REQ: + reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; + break; + + default: + break; + } + reg_frame.frame_type = cpu_to_le16(frame_type); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to frame register\n"); +} + +int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, + struct cfg80211_beacon_data *params) +{ + struct wid wid; + int result; + u8 *cur_byte; + + wid.id = WID_ADD_BEACON; + wid.type = WID_BIN; + wid.size = params->head_len + params->tail_len + 16; + wid.val = kzalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + cur_byte = wid.val; + put_unaligned_le32(interval, cur_byte); + cur_byte += 4; + put_unaligned_le32(dtim_period, cur_byte); + cur_byte += 4; + put_unaligned_le32(params->head_len, cur_byte); + cur_byte += 4; + + if (params->head_len > 0) + memcpy(cur_byte, params->head, params->head_len); + cur_byte += params->head_len; + + put_unaligned_le32(params->tail_len, cur_byte); + cur_byte += 4; + + if (params->tail_len > 0) + memcpy(cur_byte, params->tail, params->tail_len); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send add beacon\n"); + + kfree(wid.val); + + return result; +} + +int wilc_del_beacon(struct wilc_vif *vif) +{ + int result; + struct wid wid; + u8 del_beacon = 0; + + wid.id = WID_DEL_BEACON; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = &del_beacon; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send delete beacon\n"); + + return result; +} + +int wilc_add_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params) +{ + struct wid wid; + int result; + u8 *cur_byte; + + wid.id = WID_ADD_STA; + wid.type = WID_BIN; + wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + cur_byte = wid.val; + wilc_hif_pack_sta_param(cur_byte, mac, params); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result != 0) + netdev_err(vif->ndev, "Failed to send add station\n"); + + kfree(wid.val); + + return result; +} + +int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) +{ + struct wid wid; + int result; + + wid.id = WID_REMOVE_STA; + wid.type = WID_BIN; + wid.size = ETH_ALEN; + wid.val = kzalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + if (!mac_addr) + eth_broadcast_addr(wid.val); + else + ether_addr_copy(wid.val, mac_addr); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to del station\n"); + + kfree(wid.val); + + return result; +} + +int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) +{ + struct wid wid; + int result; + int i; + u8 assoc_sta = 0; + struct wilc_del_all_sta del_sta; + + memset(&del_sta, 0x0, sizeof(del_sta)); + for (i = 0; i < WILC_MAX_NUM_STA; i++) { + if (!is_zero_ether_addr(mac_addr[i])) { + assoc_sta++; + ether_addr_copy(del_sta.mac[i], mac_addr[i]); + } + } + + if (!assoc_sta) + return 0; + + del_sta.assoc_sta = assoc_sta; + + wid.id = WID_DEL_ALL_STA; + wid.type = WID_STR; + wid.size = (assoc_sta * ETH_ALEN) + 1; + wid.val = (u8 *)&del_sta; + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send delete all station\n"); + + return result; +} + +int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params) +{ + struct wid wid; + int result; + u8 *cur_byte; + + wid.id = WID_EDIT_STA; + wid.type = WID_BIN; + wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; + + cur_byte = wid.val; + wilc_hif_pack_sta_param(cur_byte, mac, params); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send edit station\n"); + + kfree(wid.val); + return result; +} + +int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) +{ + struct wid wid; + int result; + s8 power_mode; + + if (enabled) + power_mode = WILC_FW_MIN_FAST_PS; + else + power_mode = WILC_FW_NO_POWERSAVE; + + wid.id = WID_POWER_MANAGEMENT; + wid.val = &power_mode; + wid.size = sizeof(char); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); + if (result) + netdev_err(vif->ndev, "Failed to send power management\n"); + + return result; +} + +int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count, + u8 *mc_list) +{ + int result; + struct host_if_msg *msg; + + msg = wilc_alloc_work(vif, handle_set_mcast_filter, false); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + msg->body.mc_info.enabled = enabled; + msg->body.mc_info.cnt = count; + msg->body.mc_info.mc_list = mc_list; + + result = wilc_enqueue_work(msg); + if (result) { + netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + kfree(msg); + } + return result; +} + +int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) +{ + struct wid wid; + + wid.id = WID_TX_POWER; + wid.type = WID_CHAR; + wid.val = &tx_power; + wid.size = sizeof(char); + + return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); +} + +int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) +{ + struct wid wid; + + wid.id = WID_TX_POWER; + wid.type = WID_CHAR; + wid.val = tx_power; + wid.size = sizeof(char); + + return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); +} diff --git a/drivers/staging/wilc1000/hif.h b/drivers/staging/wilc1000/hif.h new file mode 100644 index 000000000000..2defe58ab194 --- /dev/null +++ b/drivers/staging/wilc1000/hif.h @@ -0,0 +1,233 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries + * All rights reserved. + */ + +#ifndef HOST_INT_H +#define HOST_INT_H +#include +#include "wlan_if.h" + +enum { + WILC_IDLE_MODE = 0x0, + WILC_AP_MODE = 0x1, + WILC_STATION_MODE = 0x2, + WILC_GO_MODE = 0x3, + WILC_CLIENT_MODE = 0x4 +}; + +#define WILC_MAX_NUM_STA 9 +#define WILC_MAX_NUM_SCANNED_CH 14 +#define WILC_MAX_NUM_PROBED_SSID 10 + +#define WILC_TX_MIC_KEY_LEN 8 +#define WILC_RX_MIC_KEY_LEN 8 + +#define WILC_MAX_NUM_PMKIDS 16 +#define WILC_ADD_STA_LENGTH 40 +#define WILC_NUM_CONCURRENT_IFC 2 + +enum { + WILC_SET_CFG = 0, + WILC_GET_CFG +}; + +#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256 + +struct assoc_resp { + __le16 capab_info; + __le16 status_code; + __le16 aid; +} __packed; + +struct rf_info { + u8 link_speed; + s8 rssi; + u32 tx_cnt; + u32 rx_cnt; + u32 tx_fail_cnt; +}; + +enum host_if_state { + HOST_IF_IDLE = 0, + HOST_IF_SCANNING = 1, + HOST_IF_CONNECTING = 2, + HOST_IF_WAITING_CONN_RESP = 3, + HOST_IF_CONNECTED = 4, + HOST_IF_P2P_LISTEN = 5, + HOST_IF_FORCE_32BIT = 0xFFFFFFFF +}; + +struct wilc_pmkid { + u8 bssid[ETH_ALEN]; + u8 pmkid[WLAN_PMKID_LEN]; +} __packed; + +struct wilc_pmkid_attr { + u8 numpmkid; + struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; +} __packed; + +struct cfg_param_attr { + u32 flag; + u16 short_retry_limit; + u16 long_retry_limit; + u16 frag_threshold; + u16 rts_threshold; +}; + +enum cfg_param { + WILC_CFG_PARAM_RETRY_SHORT = BIT(0), + WILC_CFG_PARAM_RETRY_LONG = BIT(1), + WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2), + WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3) +}; + +enum scan_event { + SCAN_EVENT_NETWORK_FOUND = 0, + SCAN_EVENT_DONE = 1, + SCAN_EVENT_ABORTED = 2, + SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF +}; + +enum conn_event { + CONN_DISCONN_EVENT_CONN_RESP = 0, + CONN_DISCONN_EVENT_DISCONN_NOTIF = 1, + CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF +}; + +enum { + WILC_HIF_SDIO = 0, + WILC_HIF_SPI = BIT(0) +}; + +enum { + WILC_MAC_STATUS_INIT = -1, + WILC_MAC_STATUS_DISCONNECTED = 0, + WILC_MAC_STATUS_CONNECTED = 1 +}; + +struct wilc_rcvd_net_info { + s8 rssi; + u8 ch; + u16 frame_len; + struct ieee80211_mgmt *mgmt; +}; + +struct wilc_user_scan_req { + void (*scan_result)(enum scan_event evt, + struct wilc_rcvd_net_info *info, void *priv); + void *arg; + u32 ch_cnt; +}; + +struct wilc_conn_info { + u8 bssid[ETH_ALEN]; + u8 security; + enum authtype auth_type; + u8 ch; + u8 *req_ies; + size_t req_ies_len; + u8 *resp_ies; + u16 resp_ies_len; + u16 status; + void (*conn_result)(enum conn_event evt, u8 status, void *priv_data); + void *arg; + void *param; +}; + +struct wilc_remain_ch { + u16 ch; + u32 duration; + void (*expired)(void *priv, u64 cookie); + void *arg; + u32 cookie; +}; + +struct wilc; +struct host_if_drv { + struct wilc_user_scan_req usr_scan_req; + struct wilc_conn_info conn_info; + struct wilc_remain_ch remain_on_ch; + u64 p2p_timeout; + + enum host_if_state hif_state; + + u8 assoc_bssid[ETH_ALEN]; + + struct timer_list scan_timer; + struct wilc_vif *scan_timer_vif; + + struct timer_list connect_timer; + struct wilc_vif *connect_timer_vif; + + struct timer_list remain_on_ch_timer; + struct wilc_vif *remain_on_ch_timer_vif; + + bool ifc_up; + u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE]; +}; + +struct wilc_vif; +int wilc_remove_wep_key(struct wilc_vif *vif, u8 index); +int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index); +int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, + u8 index); +int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, + u8 index, u8 mode, enum authtype auth_type); +int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, + const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, + u8 mode, u8 cipher_mode, u8 index); +s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, + u32 *out_val); +int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, + u8 index, u32 key_rsc_len, const u8 *key_rsc, + const u8 *rx_mic, const u8 *tx_mic, u8 mode, + u8 cipher_mode); +int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid); +int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr); +int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, + size_t ies_len); +int wilc_disconnect(struct wilc_vif *vif); +int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel); +int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level); +int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, + u8 *ch_freq_list, u8 ch_list_len, + void (*scan_result_fn)(enum scan_event, + struct wilc_rcvd_net_info *, void *), + void *user_arg, struct cfg80211_scan_request *request); +int wilc_hif_set_cfg(struct wilc_vif *vif, + struct cfg_param_attr *cfg_param); +int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); +int wilc_deinit(struct wilc_vif *vif); +int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, + struct cfg80211_beacon_data *params); +int wilc_del_beacon(struct wilc_vif *vif); +int wilc_add_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params); +int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]); +int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr); +int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params); +int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout); +int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count, + u8 *mc_list); +int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, + u32 duration, u16 chan, + void (*expired)(void *, u64), + void *user_arg); +int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie); +void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg); +int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode, + u8 ifc_id); +int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats); +int wilc_get_vif_idx(struct wilc_vif *vif); +int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); +int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power); +void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); +void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); +void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); +void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, + struct cfg80211_crypto_settings *crypto); +#endif diff --git a/drivers/staging/wilc1000/mon.c b/drivers/staging/wilc1000/mon.c new file mode 100644 index 000000000000..853fe3056a53 --- /dev/null +++ b/drivers/staging/wilc1000/mon.c @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include "cfg80211.h" + +struct wilc_wfi_radiotap_hdr { + struct ieee80211_radiotap_header hdr; + u8 rate; +} __packed; + +struct wilc_wfi_radiotap_cb_hdr { + struct ieee80211_radiotap_header hdr; + u8 rate; + u8 dump; + u16 tx_flags; +} __packed; + +#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) | \ + (1 << IEEE80211_RADIOTAP_TX_FLAGS)) + +void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size) +{ + u32 header, pkt_offset; + struct sk_buff *skb = NULL; + struct wilc_wfi_radiotap_hdr *hdr; + struct wilc_wfi_radiotap_cb_hdr *cb_hdr; + + if (!mon_dev) + return; + + if (!netif_running(mon_dev)) + return; + + /* Get WILC header */ + header = get_unaligned_le32(buff - HOST_HDR_OFFSET); + /* + * The packet offset field contain info about what type of management + * the frame we are dealing with and ack status + */ + pkt_offset = GET_PKT_OFFSET(header); + + if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { + /* hostapd callback mgmt frame */ + + skb = dev_alloc_skb(size + sizeof(*cb_hdr)); + if (!skb) + return; + + skb_put_data(skb, buff, size); + + cb_hdr = skb_push(skb, sizeof(*cb_hdr)); + memset(cb_hdr, 0, sizeof(*cb_hdr)); + + cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + + cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr)); + + cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT); + + cb_hdr->rate = 5; + + if (pkt_offset & IS_MGMT_STATUS_SUCCES) { + /* success */ + cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; + } else { + cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL; + } + + } else { + skb = dev_alloc_skb(size + sizeof(*hdr)); + + if (!skb) + return; + + skb_put_data(skb, buff, size); + hdr = skb_push(skb, sizeof(*hdr)); + memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr)); + hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); + hdr->hdr.it_present = cpu_to_le32 + (1 << IEEE80211_RADIOTAP_RATE); + hdr->rate = 5; + } + + skb->dev = mon_dev; + skb_reset_mac_header(skb); + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->pkt_type = PACKET_OTHERHOST; + skb->protocol = htons(ETH_P_802_2); + memset(skb->cb, 0, sizeof(skb->cb)); + + netif_rx(skb); +} + +struct tx_complete_mon_data { + int size; + void *buff; +}; + +static void mgmt_tx_complete(void *priv, int status) +{ + struct tx_complete_mon_data *pv_data = priv; + /* + * in case of fully hosting mode, the freeing will be done + * in response to the cfg packet + */ + kfree(pv_data->buff); + + kfree(pv_data); +} + +static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) +{ + struct tx_complete_mon_data *mgmt_tx = NULL; + + if (!dev) + return -EFAULT; + + netif_stop_queue(dev); + mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC); + if (!mgmt_tx) + return -ENOMEM; + + mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC); + if (!mgmt_tx->buff) { + kfree(mgmt_tx); + return -ENOMEM; + } + + mgmt_tx->size = len; + + wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size, + mgmt_tx_complete); + + netif_wake_queue(dev); + return 0; +} + +static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb, + struct net_device *dev) +{ + u32 rtap_len, ret = 0; + struct wilc_wfi_mon_priv *mon_priv; + struct sk_buff *skb2; + struct wilc_wfi_radiotap_cb_hdr *cb_hdr; + u8 srcadd[ETH_ALEN]; + u8 bssid[ETH_ALEN]; + + mon_priv = netdev_priv(dev); + if (!mon_priv) + return -EFAULT; + + rtap_len = ieee80211_get_radiotap_len(skb->data); + if (skb->len < rtap_len) + return -1; + + skb_pull(skb, rtap_len); + + if (skb->data[0] == 0xc0 && is_broadcast_ether_addr(&skb->data[4])) { + skb2 = dev_alloc_skb(skb->len + sizeof(*cb_hdr)); + if (!skb2) + return -ENOMEM; + + skb_put_data(skb2, skb->data, skb->len); + + cb_hdr = skb_push(skb2, sizeof(*cb_hdr)); + memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); + + cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ + + cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr)); + + cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT); + + cb_hdr->rate = 5; + cb_hdr->tx_flags = 0x0004; + + skb2->dev = dev; + skb_reset_mac_header(skb2); + skb2->ip_summed = CHECKSUM_UNNECESSARY; + skb2->pkt_type = PACKET_OTHERHOST; + skb2->protocol = htons(ETH_P_802_2); + memset(skb2->cb, 0, sizeof(skb2->cb)); + + netif_rx(skb2); + + return 0; + } + skb->dev = mon_priv->real_ndev; + + ether_addr_copy(srcadd, &skb->data[10]); + ether_addr_copy(bssid, &skb->data[16]); + /* + * Identify if data or mgmt packet, if source address and bssid + * fields are equal send it to mgmt frames handler + */ + if (!(memcmp(srcadd, bssid, 6))) { + ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); + if (ret) + netdev_err(dev, "fail to mgmt tx\n"); + dev_kfree_skb(skb); + } else { + ret = wilc_mac_xmit(skb, mon_priv->real_ndev); + } + + return ret; +} + +static const struct net_device_ops wilc_wfi_netdev_ops = { + .ndo_start_xmit = wilc_wfi_mon_xmit, + +}; + +struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, + const char *name, + struct net_device *real_dev) +{ + struct wilc_wfi_mon_priv *priv; + + /*If monitor interface is already initialized, return it*/ + if (wl->monitor_dev) + return wl->monitor_dev; + + wl->monitor_dev = alloc_etherdev(sizeof(struct wilc_wfi_mon_priv)); + if (!wl->monitor_dev) + return NULL; + + wl->monitor_dev->type = ARPHRD_IEEE80211_RADIOTAP; + strncpy(wl->monitor_dev->name, name, IFNAMSIZ); + wl->monitor_dev->name[IFNAMSIZ - 1] = 0; + wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops; + wl->monitor_dev->needs_free_netdev = true; + + if (register_netdevice(wl->monitor_dev)) { + netdev_err(real_dev, "register_netdevice failed\n"); + return NULL; + } + priv = netdev_priv(wl->monitor_dev); + if (!priv) + return NULL; + + priv->real_ndev = real_dev; + + return wl->monitor_dev; +} + +void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked) +{ + if (!wl->monitor_dev) + return; + + if (rtnl_locked) + unregister_netdevice(wl->monitor_dev); + else + unregister_netdev(wl->monitor_dev); + wl->monitor_dev = NULL; +} diff --git a/drivers/staging/wilc1000/netdev.c b/drivers/staging/wilc1000/netdev.c new file mode 100644 index 000000000000..d2c0b0f7cf63 --- /dev/null +++ b/drivers/staging/wilc1000/netdev.c @@ -0,0 +1,955 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include +#include +#include +#include +#include + +#include "cfg80211.h" +#include "wlan_cfg.h" + +#define WILC_MULTICAST_TABLE_SIZE 8 + +static irqreturn_t isr_uh_routine(int irq, void *user_data) +{ + struct net_device *dev = user_data; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + if (wilc->close) { + netdev_err(dev, "Can't handle UH interrupt\n"); + return IRQ_HANDLED; + } + return IRQ_WAKE_THREAD; +} + +static irqreturn_t isr_bh_routine(int irq, void *userdata) +{ + struct net_device *dev = userdata; + struct wilc_vif *vif = netdev_priv(userdata); + struct wilc *wilc = vif->wilc; + + if (wilc->close) { + netdev_err(dev, "Can't handle BH interrupt\n"); + return IRQ_HANDLED; + } + + wilc_handle_isr(wilc); + + return IRQ_HANDLED; +} + +static int init_irq(struct net_device *dev) +{ + int ret = 0; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; + + ret = gpiod_direction_input(wl->gpio_irq); + if (ret) { + netdev_err(dev, "could not obtain gpio for WILC_INTR\n"); + return ret; + } + + wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq); + + ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine, + isr_bh_routine, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + "WILC_IRQ", dev); + if (ret < 0) + netdev_err(dev, "Failed to request IRQ\n"); + else + netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", + wl->dev_irq_num); + + return ret; +} + +static void deinit_irq(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + /* Deinitialize IRQ */ + if (wilc->dev_irq_num) + free_irq(wilc->dev_irq_num, wilc); +} + +void wilc_mac_indicate(struct wilc *wilc) +{ + s8 status; + + wilc_wlan_cfg_get_val(wilc, WID_STATUS, &status, 1); + if (wilc->mac_status == WILC_MAC_STATUS_INIT) { + wilc->mac_status = status; + complete(&wilc->sync_event); + } else { + wilc->mac_status = status; + } +} + +static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) +{ + u8 *bssid, *bssid1; + struct net_device *ndev = NULL; + struct wilc_vif *vif; + + bssid = mac_header + 10; + bssid1 = mac_header + 4; + + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->mode == WILC_STATION_MODE) + if (ether_addr_equal_unaligned(bssid, vif->bssid)) { + ndev = vif->ndev; + goto out; + } + if (vif->mode == WILC_AP_MODE) + if (ether_addr_equal_unaligned(bssid1, vif->bssid)) { + ndev = vif->ndev; + goto out; + } + } +out: + return ndev; +} + +void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) +{ + struct wilc_vif *vif = netdev_priv(wilc_netdev); + + if (bssid) + ether_addr_copy(vif->bssid, bssid); + else + eth_zero_addr(vif->bssid); + + vif->mode = mode; +} + +int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) +{ + int srcu_idx; + u8 ret_val = 0; + struct wilc_vif *vif; + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (!is_zero_ether_addr(vif->bssid)) + ret_val++; + } + srcu_read_unlock(&wilc->srcu, srcu_idx); + return ret_val; +} + +static int wilc_txq_task(void *vp) +{ + int ret; + u32 txq_count; + struct wilc *wl = vp; + + complete(&wl->txq_thread_started); + while (1) { + wait_for_completion(&wl->txq_event); + + if (wl->close) { + complete(&wl->txq_thread_started); + + while (!kthread_should_stop()) + schedule(); + break; + } + do { + ret = wilc_wlan_handle_txq(wl, &txq_count); + if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) { + int srcu_idx; + struct wilc_vif *ifc; + + srcu_idx = srcu_read_lock(&wl->srcu); + list_for_each_entry_rcu(ifc, &wl->vif_list, + list) { + if (ifc->mac_opened && ifc->ndev) + netif_wake_queue(ifc->ndev); + } + srcu_read_unlock(&wl->srcu, srcu_idx); + } + } while (ret == -ENOBUFS && !wl->close); + } + return 0; +} + +static int wilc_wlan_get_firmware(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + int chip_id, ret = 0; + const struct firmware *wilc_firmware; + char *firmware; + + chip_id = wilc_get_chipid(wilc, false); + + if (chip_id < 0x1003a0) + firmware = FIRMWARE_1002; + else + firmware = FIRMWARE_1003; + + netdev_info(dev, "loading firmware %s\n", firmware); + + if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) { + netdev_err(dev, "%s - firmware not available\n", firmware); + ret = -1; + goto fail; + } + wilc->firmware = wilc_firmware; + +fail: + + return ret; +} + +static int wilc_start_firmware(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + int ret = 0; + + ret = wilc_wlan_start(wilc); + if (ret < 0) + return ret; + + if (!wait_for_completion_timeout(&wilc->sync_event, + msecs_to_jiffies(5000))) + return -ETIME; + + return 0; +} + +static int wilc1000_firmware_download(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + int ret = 0; + + if (!wilc->firmware) { + netdev_err(dev, "Firmware buffer is NULL\n"); + return -ENOBUFS; + } + + ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data, + wilc->firmware->size); + if (ret < 0) + return ret; + + release_firmware(wilc->firmware); + wilc->firmware = NULL; + + netdev_dbg(dev, "Download Succeeded\n"); + + return 0; +} + +static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif) +{ + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *hif_drv; + u8 b; + u16 hw; + u32 w; + + netdev_dbg(dev, "Start configuring Firmware\n"); + hif_drv = (struct host_if_drv *)priv->hif_drv; + netdev_dbg(dev, "Host = %p\n", hif_drv); + + w = vif->iftype; + cpu_to_le32s(&w); + if (!wilc_wlan_cfg_set(vif, 1, WID_SET_OPERATION_MODE, (u8 *)&w, 4, + 0, 0)) + goto fail; + + b = WILC_FW_BSS_TYPE_INFRA; + if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_TX_RATE_AUTO; + if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_OPER_MODE_G_MIXED_11B_2; + if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_PREAMBLE_SHORT; + if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_11N_PROT_AUTO; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_ACTIVE_SCAN; + if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_SITE_SURVEY_OFF; + if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, &b, 1, 0, 0)) + goto fail; + + hw = 0xffff; + cpu_to_le16s(&hw); + if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, (u8 *)&hw, 2, 0, 0)) + goto fail; + + hw = 2346; + cpu_to_le16s(&hw); + if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, (u8 *)&hw, 2, 0, 0)) + goto fail; + + b = 0; + if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, &b, 1, 0, 0)) + goto fail; + + b = 1; + if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_NO_POWERSAVE; + if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_SEC_NO; + if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_AUTH_OPEN_SYSTEM; + if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, &b, 1, 0, 0)) + goto fail; + + b = 3; + if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, &b, 1, 0, 0)) + goto fail; + + b = 3; + if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_ACK_POLICY_NORMAL; + if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, &b, 1, 0, 0)) + goto fail; + + b = 0; + if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, &b, 1, + 0, 0)) + goto fail; + + b = 48; + if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, &b, 1, 0, 0)) + goto fail; + + b = 28; + if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, &b, 1, 0, 0)) + goto fail; + + hw = 100; + cpu_to_le16s(&hw); + if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, (u8 *)&hw, 2, 0, 0)) + goto fail; + + b = WILC_FW_REKEY_POLICY_DISABLE; + if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, &b, 1, 0, 0)) + goto fail; + + w = 84600; + cpu_to_le32s(&w); + if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, (u8 *)&w, 4, 0, 0)) + goto fail; + + w = 500; + cpu_to_le32s(&w); + if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, (u8 *)&w, 4, 0, + 0)) + goto fail; + + b = 1; + if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, &b, 1, 0, + 0)) + goto fail; + + b = WILC_FW_ERP_PROT_SELF_CTS; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, &b, 1, 0, 0)) + goto fail; + + b = 1; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_11N_OP_MODE_HT_MIXED; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, &b, 1, 0, 0)) + goto fail; + + b = 1; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, &b, 1, 0, 0)) + goto fail; + + b = WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, &b, 1, + 0, 0)) + goto fail; + + b = WILC_FW_HT_PROT_RTS_CTS_NONHT; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, &b, 1, 0, 0)) + goto fail; + + b = 0; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, &b, 1, 0, + 0)) + goto fail; + + b = 7; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, &b, 1, 0, 0)) + goto fail; + + b = 1; + if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, &b, 1, + 1, 1)) + goto fail; + + return 0; + +fail: + return -1; +} + +static void wlan_deinitialize_threads(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; + + wl->close = 1; + + complete(&wl->txq_event); + + if (wl->txq_thread) { + kthread_stop(wl->txq_thread); + wl->txq_thread = NULL; + } +} + +static void wilc_wlan_deinitialize(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wl = vif->wilc; + + if (!wl) { + netdev_err(dev, "wl is NULL\n"); + return; + } + + if (wl->initialized) { + netdev_info(dev, "Deinitializing wilc1000...\n"); + + if (!wl->dev_irq_num && + wl->hif_func->disable_interrupt) { + mutex_lock(&wl->hif_cs); + wl->hif_func->disable_interrupt(wl); + mutex_unlock(&wl->hif_cs); + } + complete(&wl->txq_event); + + wlan_deinitialize_threads(dev); + deinit_irq(dev); + + wilc_wlan_stop(wl, vif); + wilc_wlan_cleanup(dev); + + wl->initialized = false; + + netdev_dbg(dev, "wilc1000 deinitialization Done\n"); + } else { + netdev_dbg(dev, "wilc1000 is not initialized\n"); + } +} + +static int wlan_initialize_threads(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + wilc->txq_thread = kthread_run(wilc_txq_task, (void *)wilc, + "K_TXQ_TASK"); + if (IS_ERR(wilc->txq_thread)) { + netdev_err(dev, "couldn't create TXQ thread\n"); + wilc->close = 0; + return PTR_ERR(wilc->txq_thread); + } + wait_for_completion(&wilc->txq_thread_started); + + return 0; +} + +static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) +{ + int ret = 0; + struct wilc *wl = vif->wilc; + + if (!wl->initialized) { + wl->mac_status = WILC_MAC_STATUS_INIT; + wl->close = 0; + + ret = wilc_wlan_init(dev); + if (ret < 0) + return -EIO; + + ret = wlan_initialize_threads(dev); + if (ret < 0) { + ret = -EIO; + goto fail_wilc_wlan; + } + + if (wl->gpio_irq && init_irq(dev)) { + ret = -EIO; + goto fail_threads; + } + + if (!wl->dev_irq_num && + wl->hif_func->enable_interrupt && + wl->hif_func->enable_interrupt(wl)) { + ret = -EIO; + goto fail_irq_init; + } + + if (wilc_wlan_get_firmware(dev)) { + ret = -EIO; + goto fail_irq_enable; + } + + ret = wilc1000_firmware_download(dev); + if (ret < 0) { + ret = -EIO; + goto fail_irq_enable; + } + + ret = wilc_start_firmware(dev); + if (ret < 0) { + ret = -EIO; + goto fail_irq_enable; + } + + if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) { + int size; + char firmware_ver[20]; + + size = wilc_wlan_cfg_get_val(wl, WID_FIRMWARE_VERSION, + firmware_ver, + sizeof(firmware_ver)); + firmware_ver[size] = '\0'; + netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver); + } + ret = wilc_init_fw_config(dev, vif); + + if (ret < 0) { + netdev_err(dev, "Failed to configure firmware\n"); + ret = -EIO; + goto fail_fw_start; + } + wl->initialized = true; + return 0; + +fail_fw_start: + wilc_wlan_stop(wl, vif); + +fail_irq_enable: + if (!wl->dev_irq_num && + wl->hif_func->disable_interrupt) + wl->hif_func->disable_interrupt(wl); +fail_irq_init: + if (wl->dev_irq_num) + deinit_irq(dev); +fail_threads: + wlan_deinitialize_threads(dev); +fail_wilc_wlan: + wilc_wlan_cleanup(dev); + netdev_err(dev, "WLAN initialization FAILED\n"); + } else { + netdev_dbg(dev, "wilc1000 already initialized\n"); + } + return ret; +} + +static int mac_init_fn(struct net_device *ndev) +{ + netif_start_queue(ndev); + netif_stop_queue(ndev); + + return 0; +} + +static int wilc_mac_open(struct net_device *ndev) +{ + struct wilc_vif *vif = netdev_priv(ndev); + struct wilc *wl = vif->wilc; + struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr); + unsigned char mac_add[ETH_ALEN] = {0}; + int ret = 0; + + if (!wl || !wl->dev) { + netdev_err(ndev, "device not ready\n"); + return -ENODEV; + } + + netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev); + + ret = wilc_init_host_int(ndev); + if (ret < 0) + return ret; + + ret = wilc_wlan_initialize(ndev, vif); + if (ret < 0) { + wilc_deinit_host_int(ndev); + return ret; + } + + wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype, + vif->idx); + wilc_get_mac_address(vif, mac_add); + netdev_dbg(ndev, "Mac address: %pM\n", mac_add); + ether_addr_copy(ndev->dev_addr, mac_add); + + if (!is_valid_ether_addr(ndev->dev_addr)) { + netdev_err(ndev, "Wrong MAC address\n"); + wilc_deinit_host_int(ndev); + wilc_wlan_deinitialize(ndev); + return -EINVAL; + } + + wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy, + vif->ndev->ieee80211_ptr, + vif->frame_reg[0].type, + vif->frame_reg[0].reg); + wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy, + vif->ndev->ieee80211_ptr, + vif->frame_reg[1].type, + vif->frame_reg[1].reg); + netif_wake_queue(ndev); + wl->open_ifcs++; + priv->p2p.local_random = 0x01; + vif->mac_opened = 1; + return 0; +} + +static struct net_device_stats *mac_stats(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + + return &vif->netstats; +} + +static void wilc_set_multicast_list(struct net_device *dev) +{ + struct netdev_hw_addr *ha; + struct wilc_vif *vif = netdev_priv(dev); + int i; + u8 *mc_list; + u8 *cur_mc; + + if (dev->flags & IFF_PROMISC) + return; + + if (dev->flags & IFF_ALLMULTI || + dev->mc.count > WILC_MULTICAST_TABLE_SIZE) { + wilc_setup_multicast_filter(vif, 0, 0, NULL); + return; + } + + if (dev->mc.count == 0) { + wilc_setup_multicast_filter(vif, 1, 0, NULL); + return; + } + + mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_ATOMIC); + if (!mc_list) + return; + + cur_mc = mc_list; + i = 0; + netdev_for_each_mc_addr(ha, dev) { + memcpy(cur_mc, ha->addr, ETH_ALEN); + netdev_dbg(dev, "Entry[%d]: %pM\n", i, cur_mc); + i++; + cur_mc += ETH_ALEN; + } + + if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list)) + kfree(mc_list); +} + +static void wilc_tx_complete(void *priv, int status) +{ + struct tx_complete_data *pv_data = priv; + + dev_kfree_skb(pv_data->skb); + kfree(pv_data); +} + +netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + struct wilc_vif *vif = netdev_priv(ndev); + struct wilc *wilc = vif->wilc; + struct tx_complete_data *tx_data = NULL; + int queue_count; + + if (skb->dev != ndev) { + netdev_err(ndev, "Packet not destined to this device\n"); + return 0; + } + + tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); + if (!tx_data) { + dev_kfree_skb(skb); + netif_wake_queue(ndev); + return 0; + } + + tx_data->buff = skb->data; + tx_data->size = skb->len; + tx_data->skb = skb; + + vif->netstats.tx_packets++; + vif->netstats.tx_bytes += tx_data->size; + queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data, + tx_data->buff, tx_data->size, + wilc_tx_complete); + + if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { + int srcu_idx; + struct wilc_vif *vif; + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->mac_opened) + netif_stop_queue(vif->ndev); + } + srcu_read_unlock(&wilc->srcu, srcu_idx); + } + + return 0; +} + +static int wilc_mac_close(struct net_device *ndev) +{ + struct wilc_vif *vif = netdev_priv(ndev); + struct wilc *wl = vif->wilc; + + netdev_dbg(ndev, "Mac close\n"); + + if (wl->open_ifcs > 0) + wl->open_ifcs--; + else + return 0; + + if (vif->ndev) { + netif_stop_queue(vif->ndev); + + wilc_deinit_host_int(vif->ndev); + } + + if (wl->open_ifcs == 0) { + netdev_dbg(ndev, "Deinitializing wilc1000\n"); + wl->close = 1; + wilc_wlan_deinitialize(ndev); + } + + vif->mac_opened = 0; + + return 0; +} + +void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, + u32 pkt_offset) +{ + unsigned int frame_len = 0; + int stats; + unsigned char *buff_to_send = NULL; + struct sk_buff *skb; + struct net_device *wilc_netdev; + struct wilc_vif *vif; + + if (!wilc) + return; + + wilc_netdev = get_if_handler(wilc, buff); + if (!wilc_netdev) + return; + + buff += pkt_offset; + vif = netdev_priv(wilc_netdev); + + if (size > 0) { + frame_len = size; + buff_to_send = buff; + + skb = dev_alloc_skb(frame_len); + if (!skb) + return; + + skb->dev = wilc_netdev; + + skb_put_data(skb, buff_to_send, frame_len); + + skb->protocol = eth_type_trans(skb, wilc_netdev); + vif->netstats.rx_packets++; + vif->netstats.rx_bytes += frame_len; + skb->ip_summed = CHECKSUM_UNNECESSARY; + stats = netif_rx(skb); + netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats); + } +} + +void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) +{ + int srcu_idx; + struct wilc_vif *vif; + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + u16 type = le16_to_cpup((__le16 *)buff); + + if (vif->priv.p2p_listen_state && + ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) || + (type == vif->frame_reg[1].type && vif->frame_reg[1].reg))) + wilc_wfi_p2p_rx(vif, buff, size); + + if (vif->monitor_flag) + wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size); + } + srcu_read_unlock(&wilc->srcu, srcu_idx); +} + +static const struct net_device_ops wilc_netdev_ops = { + .ndo_init = mac_init_fn, + .ndo_open = wilc_mac_open, + .ndo_stop = wilc_mac_close, + .ndo_start_xmit = wilc_mac_xmit, + .ndo_get_stats = mac_stats, + .ndo_set_rx_mode = wilc_set_multicast_list, +}; + +void wilc_netdev_cleanup(struct wilc *wilc) +{ + struct wilc_vif *vif; + int srcu_idx; + + if (!wilc) + return; + + if (wilc->firmware) { + release_firmware(wilc->firmware); + wilc->firmware = NULL; + } + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + if (vif->ndev) + unregister_netdev(vif->ndev); + } + srcu_read_unlock(&wilc->srcu, srcu_idx); + + wilc_wfi_deinit_mon_interface(wilc, false); + flush_workqueue(wilc->hif_workqueue); + destroy_workqueue(wilc->hif_workqueue); + + do { + mutex_lock(&wilc->vif_mutex); + if (wilc->vif_num <= 0) { + mutex_unlock(&wilc->vif_mutex); + break; + } + vif = wilc_get_wl_to_vif(wilc); + if (!IS_ERR(vif)) + list_del_rcu(&vif->list); + + wilc->vif_num--; + mutex_unlock(&wilc->vif_mutex); + synchronize_srcu(&wilc->srcu); + } while (1); + + wilc_wlan_cfg_deinit(wilc); + wlan_deinit_locks(wilc); + kfree(wilc->bus_data); + wiphy_unregister(wilc->wiphy); + wiphy_free(wilc->wiphy); +} +EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); + +static u8 wilc_get_available_idx(struct wilc *wl) +{ + int idx = 0; + struct wilc_vif *vif; + int srcu_idx; + + srcu_idx = srcu_read_lock(&wl->srcu); + list_for_each_entry_rcu(vif, &wl->vif_list, list) { + if (vif->idx == 0) + idx = 1; + else + idx = 0; + } + srcu_read_unlock(&wl->srcu, srcu_idx); + return idx; +} + +struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, + int vif_type, enum nl80211_iftype type, + bool rtnl_locked) +{ + struct net_device *ndev; + struct wilc_vif *vif; + int ret; + + ndev = alloc_etherdev(sizeof(*vif)); + if (!ndev) + return ERR_PTR(-ENOMEM); + + vif = netdev_priv(ndev); + ndev->ieee80211_ptr = &vif->priv.wdev; + strcpy(ndev->name, name); + vif->wilc = wl; + vif->ndev = ndev; + ndev->ml_priv = vif; + + ndev->netdev_ops = &wilc_netdev_ops; + + SET_NETDEV_DEV(ndev, wiphy_dev(wl->wiphy)); + + vif->priv.wdev.wiphy = wl->wiphy; + vif->priv.wdev.netdev = ndev; + vif->priv.wdev.iftype = type; + vif->priv.dev = ndev; + + if (rtnl_locked) + ret = register_netdevice(ndev); + else + ret = register_netdev(ndev); + + if (ret) { + free_netdev(ndev); + return ERR_PTR(-EFAULT); + } + + ndev->needs_free_netdev = true; + vif->iftype = vif_type; + vif->idx = wilc_get_available_idx(wl); + vif->mac_opened = 0; + mutex_lock(&wl->vif_mutex); + list_add_tail_rcu(&vif->list, &wl->vif_list); + wl->vif_num += 1; + mutex_unlock(&wl->vif_mutex); + synchronize_srcu(&wl->srcu); + + return vif; +} + +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/netdev.h b/drivers/staging/wilc1000/netdev.h new file mode 100644 index 000000000000..8bc62ce4f2f7 --- /dev/null +++ b/drivers/staging/wilc1000/netdev.h @@ -0,0 +1,296 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#ifndef WILC_WFI_NETDEVICE +#define WILC_WFI_NETDEVICE + +#include +#include +#include +#include +#include +#include + +#include "hif.h" +#include "wlan.h" +#include "wlan_cfg.h" + +#define FLOW_CONTROL_LOWER_THRESHOLD 128 +#define FLOW_CONTROL_UPPER_THRESHOLD 256 + +#define WILC_MAX_NUM_PMKIDS 16 +#define PMKID_FOUND 1 +#define NUM_STA_ASSOCIATED 8 + +#define NUM_REG_FRAME 2 + +#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 +#define DEFAULT_LINK_SPEED 72 + +#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) + +struct wilc_wfi_stats { + unsigned long rx_packets; + unsigned long tx_packets; + unsigned long rx_bytes; + unsigned long tx_bytes; + u64 rx_time; + u64 tx_time; + +}; + +struct wilc_wfi_key { + u8 *key; + u8 *seq; + int key_len; + int seq_len; + u32 cipher; +}; + +struct wilc_wfi_wep_key { + u8 *key; + u8 key_len; + u8 key_idx; +}; + +struct sta_info { + u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN]; +}; + +/*Parameters needed for host interface for remaining on channel*/ +struct wilc_wfi_p2p_listen_params { + struct ieee80211_channel *listen_ch; + u32 listen_duration; + u64 listen_cookie; +}; + +struct wilc_p2p_var { + u8 local_random; + u8 recv_random; + bool is_wilc_ie; +}; + +static const u32 wilc_cipher_suites[] = { + WLAN_CIPHER_SUITE_WEP40, + WLAN_CIPHER_SUITE_WEP104, + WLAN_CIPHER_SUITE_TKIP, + WLAN_CIPHER_SUITE_CCMP, + WLAN_CIPHER_SUITE_AES_CMAC +}; + +#define CHAN2G(_channel, _freq, _flags) { \ + .band = NL80211_BAND_2GHZ, \ + .center_freq = (_freq), \ + .hw_value = (_channel), \ + .flags = (_flags), \ + .max_antenna_gain = 0, \ + .max_power = 30, \ +} + +static const struct ieee80211_channel wilc_2ghz_channels[] = { + CHAN2G(1, 2412, 0), + CHAN2G(2, 2417, 0), + CHAN2G(3, 2422, 0), + CHAN2G(4, 2427, 0), + CHAN2G(5, 2432, 0), + CHAN2G(6, 2437, 0), + CHAN2G(7, 2442, 0), + CHAN2G(8, 2447, 0), + CHAN2G(9, 2452, 0), + CHAN2G(10, 2457, 0), + CHAN2G(11, 2462, 0), + CHAN2G(12, 2467, 0), + CHAN2G(13, 2472, 0), + CHAN2G(14, 2484, 0) +}; + +#define RATETAB_ENT(_rate, _hw_value, _flags) { \ + .bitrate = (_rate), \ + .hw_value = (_hw_value), \ + .flags = (_flags), \ +} + +static struct ieee80211_rate wilc_bitrates[] = { + RATETAB_ENT(10, 0, 0), + RATETAB_ENT(20, 1, 0), + RATETAB_ENT(55, 2, 0), + RATETAB_ENT(110, 3, 0), + RATETAB_ENT(60, 9, 0), + RATETAB_ENT(90, 6, 0), + RATETAB_ENT(120, 7, 0), + RATETAB_ENT(180, 8, 0), + RATETAB_ENT(240, 9, 0), + RATETAB_ENT(360, 10, 0), + RATETAB_ENT(480, 11, 0), + RATETAB_ENT(540, 12, 0) +}; + +struct wilc_priv { + struct wireless_dev wdev; + struct cfg80211_scan_request *scan_req; + + struct wilc_wfi_p2p_listen_params remain_on_ch_params; + u64 tx_cookie; + + bool cfg_scanning; + + u8 associated_bss[ETH_ALEN]; + struct sta_info assoc_stainfo; + struct sk_buff *skb; + struct net_device *dev; + struct host_if_drv *hif_drv; + struct wilc_pmkid_attr pmkid_list; + u8 wep_key[4][WLAN_KEY_LEN_WEP104]; + u8 wep_key_len[4]; + /* The real interface that the monitor is on */ + struct net_device *real_ndev; + struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA]; + struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA]; + u8 wilc_groupkey; + /* mutexes */ + struct mutex scan_req_lock; + bool p2p_listen_state; + int scanned_cnt; + struct wilc_p2p_var p2p; + + u64 inc_roc_cookie; +}; + +struct frame_reg { + u16 type; + bool reg; +}; + +#define MAX_TCP_SESSION 25 +#define MAX_PENDING_ACKS 256 + +struct ack_session_info { + u32 seq_num; + u32 bigger_ack_num; + u16 src_port; + u16 dst_port; + u16 status; +}; + +struct pending_acks { + u32 ack_num; + u32 session_index; + struct txq_entry_t *txqe; +}; + +struct tcp_ack_filter { + struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION]; + struct pending_acks pending_acks[MAX_PENDING_ACKS]; + u32 pending_base; + u32 tcp_session; + u32 pending_acks_idx; + bool enabled; +}; + +struct wilc_vif { + u8 idx; + u8 iftype; + int monitor_flag; + int mac_opened; + struct frame_reg frame_reg[NUM_REG_FRAME]; + struct net_device_stats netstats; + struct wilc *wilc; + u8 bssid[ETH_ALEN]; + struct host_if_drv *hif_drv; + struct net_device *ndev; + u8 mode; + struct timer_list during_ip_timer; + struct timer_list periodic_rssi; + struct rf_info periodic_stat; + struct tcp_ack_filter ack_filter; + bool connecting; + struct wilc_priv priv; + struct list_head list; + struct cfg80211_bss *bss; +}; + +struct wilc { + struct wiphy *wiphy; + const struct wilc_hif_func *hif_func; + int io_type; + s8 mac_status; + struct gpio_desc *gpio_irq; + struct clk *rtc_clk; + bool initialized; + int dev_irq_num; + int close; + u8 vif_num; + struct list_head vif_list; + /*protect vif list*/ + struct mutex vif_mutex; + struct srcu_struct srcu; + u8 open_ifcs; + /*protect head of transmit queue*/ + struct mutex txq_add_to_head_cs; + /*protect txq_entry_t transmit queue*/ + spinlock_t txq_spinlock; + /*protect rxq_entry_t receiver queue*/ + struct mutex rxq_cs; + /* lock to protect hif access */ + struct mutex hif_cs; + + struct completion cfg_event; + struct completion sync_event; + struct completion txq_event; + struct completion txq_thread_started; + + struct task_struct *txq_thread; + + int quit; + /* lock to protect issue of wid command to firmware */ + struct mutex cfg_cmd_lock; + struct wilc_cfg_frame cfg_frame; + u32 cfg_frame_offset; + u8 cfg_seq_no; + + u8 *rx_buffer; + u32 rx_buffer_offset; + u8 *tx_buffer; + + struct txq_entry_t txq_head; + int txq_entries; + + struct rxq_entry_t rxq_head; + + const struct firmware *firmware; + + struct device *dev; + bool suspend_event; + + int clients_count; + struct workqueue_struct *hif_workqueue; + enum chip_ps_states chip_ps_state; + struct wilc_cfg cfg; + void *bus_data; + struct net_device *monitor_dev; + /* deinit lock */ + struct mutex deinit_lock; + u8 sta_ch; + u8 op_ch; + struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)]; + struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)]; + struct ieee80211_supported_band band; + u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)]; +}; + +struct wilc_wfi_mon_priv { + struct net_device *real_ndev; +}; + +void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); +void wilc_mac_indicate(struct wilc *wilc); +void wilc_netdev_cleanup(struct wilc *wilc); +void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); +void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode); +struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, + int vif_type, enum nl80211_iftype type, + bool rtnl_locked); +#endif diff --git a/drivers/staging/wilc1000/sdio.c b/drivers/staging/wilc1000/sdio.c new file mode 100644 index 000000000000..319e039380b0 --- /dev/null +++ b/drivers/staging/wilc1000/sdio.c @@ -0,0 +1,1151 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include +#include +#include + +#include "netdev.h" +#include "cfg80211.h" + +#define SDIO_MODALIAS "wilc1000_sdio" + +#define SDIO_VENDOR_ID_WILC 0x0296 +#define SDIO_DEVICE_ID_WILC 0x5347 + +static const struct sdio_device_id wilc_sdio_ids[] = { + { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) }, + { }, +}; + +#define WILC_SDIO_BLOCK_SIZE 512 + +struct wilc_sdio { + bool irq_gpio; + u32 block_size; + int nint; +/* Max num interrupts allowed in registers 0xf7, 0xf8 */ +#define MAX_NUN_INT_THRPT_ENH2 (5) + int has_thrpt_enh3; +}; + +struct sdio_cmd52 { + u32 read_write: 1; + u32 function: 3; + u32 raw: 1; + u32 address: 17; + u32 data: 8; +}; + +struct sdio_cmd53 { + u32 read_write: 1; + u32 function: 3; + u32 block_mode: 1; + u32 increment: 1; + u32 address: 17; + u32 count: 9; + u8 *buffer; + u32 block_size; +}; + +static const struct wilc_hif_func wilc_hif_sdio; + +static void wilc_sdio_interrupt(struct sdio_func *func) +{ + sdio_release_host(func); + wilc_handle_isr(sdio_get_drvdata(func)); + sdio_claim_host(func); +} + +static int wilc_sdio_cmd52(struct wilc *wilc, struct sdio_cmd52 *cmd) +{ + struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev); + int ret; + u8 data; + + sdio_claim_host(func); + + func->num = cmd->function; + if (cmd->read_write) { /* write */ + if (cmd->raw) { + sdio_writeb(func, cmd->data, cmd->address, &ret); + data = sdio_readb(func, cmd->address, &ret); + cmd->data = data; + } else { + sdio_writeb(func, cmd->data, cmd->address, &ret); + } + } else { /* read */ + data = sdio_readb(func, cmd->address, &ret); + cmd->data = data; + } + + sdio_release_host(func); + + if (ret) + dev_err(&func->dev, "%s..failed, err(%d)\n", __func__, ret); + return ret; +} + +static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd) +{ + struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev); + int size, ret; + + sdio_claim_host(func); + + func->num = cmd->function; + func->cur_blksize = cmd->block_size; + if (cmd->block_mode) + size = cmd->count * cmd->block_size; + else + size = cmd->count; + + if (cmd->read_write) { /* write */ + ret = sdio_memcpy_toio(func, cmd->address, + (void *)cmd->buffer, size); + } else { /* read */ + ret = sdio_memcpy_fromio(func, (void *)cmd->buffer, + cmd->address, size); + } + + sdio_release_host(func); + + if (ret) + dev_err(&func->dev, "%s..failed, err(%d)\n", __func__, ret); + + return ret; +} + +static int wilc_sdio_probe(struct sdio_func *func, + const struct sdio_device_id *id) +{ + struct wilc *wilc; + int ret; + struct gpio_desc *gpio = NULL; + struct wilc_sdio *sdio_priv; + + sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL); + if (!sdio_priv) + return -ENOMEM; + + if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) { + gpio = gpiod_get(&func->dev, "irq", GPIOD_IN); + if (IS_ERR(gpio)) { + /* get the GPIO descriptor from hardcode GPIO number */ + gpio = gpio_to_desc(GPIO_NUM); + if (!gpio) + dev_err(&func->dev, "failed to get irq gpio\n"); + } + } + + ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO, + &wilc_hif_sdio); + if (ret) { + kfree(sdio_priv); + return ret; + } + sdio_set_drvdata(func, wilc); + wilc->bus_data = sdio_priv; + wilc->dev = &func->dev; + wilc->gpio_irq = gpio; + + wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc_clk"); + if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + else if (!IS_ERR(wilc->rtc_clk)) + clk_prepare_enable(wilc->rtc_clk); + + dev_info(&func->dev, "Driver Initializing success\n"); + return 0; +} + +static void wilc_sdio_remove(struct sdio_func *func) +{ + struct wilc *wilc = sdio_get_drvdata(func); + + /* free the GPIO in module remove */ + if (wilc->gpio_irq) + gpiod_put(wilc->gpio_irq); + + if (!IS_ERR(wilc->rtc_clk)) + clk_disable_unprepare(wilc->rtc_clk); + + wilc_netdev_cleanup(wilc); +} + +static int wilc_sdio_reset(struct wilc *wilc) +{ + struct sdio_cmd52 cmd; + int ret; + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x6; + cmd.data = 0x8; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Fail cmd 52, reset cmd ...\n"); + return ret; + } + return 0; +} + +static int wilc_sdio_suspend(struct device *dev) +{ + struct sdio_func *func = dev_to_sdio_func(dev); + struct wilc *wilc = sdio_get_drvdata(func); + int ret; + + dev_info(dev, "sdio suspend\n"); + chip_wakeup(wilc); + + if (!IS_ERR(wilc->rtc_clk)) + clk_disable_unprepare(wilc->rtc_clk); + + if (wilc->suspend_event) { + host_sleep_notify(wilc); + chip_allow_sleep(wilc); + } + + ret = wilc_sdio_reset(wilc); + if (ret) { + dev_err(&func->dev, "Fail reset sdio\n"); + return ret; + } + sdio_claim_host(func); + + return 0; +} + +static int wilc_sdio_enable_interrupt(struct wilc *dev) +{ + struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev); + int ret = 0; + + sdio_claim_host(func); + ret = sdio_claim_irq(func, wilc_sdio_interrupt); + sdio_release_host(func); + + if (ret < 0) { + dev_err(&func->dev, "can't claim sdio_irq, err(%d)\n", ret); + ret = -EIO; + } + return ret; +} + +static void wilc_sdio_disable_interrupt(struct wilc *dev) +{ + struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev); + int ret; + + sdio_claim_host(func); + ret = sdio_release_irq(func); + if (ret < 0) + dev_err(&func->dev, "can't release sdio_irq, err(%d)\n", ret); + sdio_release_host(func); +} + +/******************************************** + * + * Function 0 + * + ********************************************/ + +static int wilc_sdio_set_func0_csa_address(struct wilc *wilc, u32 adr) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct sdio_cmd52 cmd; + int ret; + + /** + * Review: BIG ENDIAN + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x10c; + cmd.data = (u8)adr; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x10c data...\n"); + goto fail; + } + + cmd.address = 0x10d; + cmd.data = (u8)(adr >> 8); + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x10d data...\n"); + goto fail; + } + + cmd.address = 0x10e; + cmd.data = (u8)(adr >> 16); + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x10e data...\n"); + goto fail; + } + + return 1; +fail: + return 0; +} + +static int wilc_sdio_set_func0_block_size(struct wilc *wilc, u32 block_size) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct sdio_cmd52 cmd; + int ret; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x10; + cmd.data = (u8)block_size; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x10 data...\n"); + goto fail; + } + + cmd.address = 0x11; + cmd.data = (u8)(block_size >> 8); + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x11 data...\n"); + goto fail; + } + + return 1; +fail: + return 0; +} + +/******************************************** + * + * Function 1 + * + ********************************************/ + +static int wilc_sdio_set_func1_block_size(struct wilc *wilc, u32 block_size) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct sdio_cmd52 cmd; + int ret; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x110; + cmd.data = (u8)block_size; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x110 data...\n"); + goto fail; + } + cmd.address = 0x111; + cmd.data = (u8)(block_size >> 8); + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed cmd52, set 0x111 data...\n"); + goto fail; + } + + return 1; +fail: + return 0; +} + +/******************************************** + * + * Sdio interfaces + * + ********************************************/ +static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + int ret; + + cpu_to_le32s(&data); + + if (addr >= 0xf0 && addr <= 0xff) { + struct sdio_cmd52 cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = addr; + cmd.data = data; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd 52, read reg (%08x) ...\n", addr); + goto fail; + } + } else { + struct sdio_cmd53 cmd; + + /** + * set the AHB address + **/ + if (!wilc_sdio_set_func0_csa_address(wilc, addr)) + goto fail; + + cmd.read_write = 1; + cmd.function = 0; + cmd.address = 0x10f; + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = 4; + cmd.buffer = (u8 *)&data; + cmd.block_size = sdio_priv->block_size; + ret = wilc_sdio_cmd53(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd53, write reg (%08x)...\n", addr); + goto fail; + } + } + + return 1; + +fail: + + return 0; +} + +static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + u32 block_size = sdio_priv->block_size; + struct sdio_cmd53 cmd; + int nblk, nleft, ret; + + cmd.read_write = 1; + if (addr > 0) { + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } + + /** + * func 0 access + **/ + cmd.function = 0; + cmd.address = 0x10f; + } else { + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } + + /** + * func 1 access + **/ + cmd.function = 1; + cmd.address = 0; + } + + nblk = size / block_size; + nleft = size % block_size; + + if (nblk > 0) { + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = nblk; + cmd.buffer = buf; + cmd.block_size = block_size; + if (addr > 0) { + if (!wilc_sdio_set_func0_csa_address(wilc, addr)) + goto fail; + } + ret = wilc_sdio_cmd53(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd53 [%x], block send...\n", addr); + goto fail; + } + if (addr > 0) + addr += nblk * block_size; + buf += nblk * block_size; + } + + if (nleft > 0) { + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = nleft; + cmd.buffer = buf; + + cmd.block_size = block_size; + + if (addr > 0) { + if (!wilc_sdio_set_func0_csa_address(wilc, addr)) + goto fail; + } + ret = wilc_sdio_cmd53(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd53 [%x], bytes send...\n", addr); + goto fail; + } + } + + return 1; + +fail: + + return 0; +} + +static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + int ret; + + if (addr >= 0xf0 && addr <= 0xff) { + struct sdio_cmd52 cmd; + + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = addr; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd 52, read reg (%08x) ...\n", addr); + goto fail; + } + *data = cmd.data; + } else { + struct sdio_cmd53 cmd; + + if (!wilc_sdio_set_func0_csa_address(wilc, addr)) + goto fail; + + cmd.read_write = 0; + cmd.function = 0; + cmd.address = 0x10f; + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = 4; + cmd.buffer = (u8 *)data; + + cmd.block_size = sdio_priv->block_size; + ret = wilc_sdio_cmd53(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd53, read reg (%08x)...\n", addr); + goto fail; + } + } + + le32_to_cpus(data); + + return 1; + +fail: + + return 0; +} + +static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + u32 block_size = sdio_priv->block_size; + struct sdio_cmd53 cmd; + int nblk, nleft, ret; + + cmd.read_write = 0; + if (addr > 0) { + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } + + /** + * func 0 access + **/ + cmd.function = 0; + cmd.address = 0x10f; + } else { + /** + * has to be word aligned... + **/ + if (size & 0x3) { + size += 4; + size &= ~0x3; + } + + /** + * func 1 access + **/ + cmd.function = 1; + cmd.address = 0; + } + + nblk = size / block_size; + nleft = size % block_size; + + if (nblk > 0) { + cmd.block_mode = 1; + cmd.increment = 1; + cmd.count = nblk; + cmd.buffer = buf; + cmd.block_size = block_size; + if (addr > 0) { + if (!wilc_sdio_set_func0_csa_address(wilc, addr)) + goto fail; + } + ret = wilc_sdio_cmd53(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd53 [%x], block read...\n", addr); + goto fail; + } + if (addr > 0) + addr += nblk * block_size; + buf += nblk * block_size; + } /* if (nblk > 0) */ + + if (nleft > 0) { + cmd.block_mode = 0; + cmd.increment = 1; + cmd.count = nleft; + cmd.buffer = buf; + + cmd.block_size = block_size; + + if (addr > 0) { + if (!wilc_sdio_set_func0_csa_address(wilc, addr)) + goto fail; + } + ret = wilc_sdio_cmd53(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd53 [%x], bytes read...\n", addr); + goto fail; + } + } + + return 1; + +fail: + + return 0; +} + +/******************************************** + * + * Bus interfaces + * + ********************************************/ + +static int wilc_sdio_deinit(struct wilc *wilc) +{ + return 1; +} + +static int wilc_sdio_init(struct wilc *wilc, bool resume) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + struct sdio_cmd52 cmd; + int loop, ret; + u32 chipid; + + if (!resume) + sdio_priv->irq_gpio = wilc->dev_irq_num; + + /** + * function 0 csa enable + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + cmd.address = 0x100; + cmd.data = 0x80; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Fail cmd 52, enable csa...\n"); + goto fail; + } + + /** + * function 0 block size + **/ + if (!wilc_sdio_set_func0_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) { + dev_err(&func->dev, "Fail cmd 52, set func 0 block size...\n"); + goto fail; + } + sdio_priv->block_size = WILC_SDIO_BLOCK_SIZE; + + /** + * enable func1 IO + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + cmd.address = 0x2; + cmd.data = 0x2; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Fail cmd 52, set IOE register...\n"); + goto fail; + } + + /** + * make sure func 1 is up + **/ + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0x3; + loop = 3; + do { + cmd.data = 0; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Fail cmd 52, get IOR register...\n"); + goto fail; + } + if (cmd.data == 0x2) + break; + } while (loop--); + + if (loop <= 0) { + dev_err(&func->dev, "Fail func 1 is not ready...\n"); + goto fail; + } + + /** + * func 1 is ready, set func 1 block size + **/ + if (!wilc_sdio_set_func1_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) { + dev_err(&func->dev, "Fail set func 1 block size...\n"); + goto fail; + } + + /** + * func 1 interrupt enable + **/ + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + cmd.address = 0x4; + cmd.data = 0x3; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Fail cmd 52, set IEN register...\n"); + goto fail; + } + + /** + * make sure can read back chip id correctly + **/ + if (!resume) { + if (!wilc_sdio_read_reg(wilc, 0x1000, &chipid)) { + dev_err(&func->dev, "Fail cmd read chip id...\n"); + goto fail; + } + dev_err(&func->dev, "chipid (%08x)\n", chipid); + if ((chipid & 0xfff) > 0x2a0) + sdio_priv->has_thrpt_enh3 = 1; + else + sdio_priv->has_thrpt_enh3 = 0; + dev_info(&func->dev, "has_thrpt_enh3 = %d...\n", + sdio_priv->has_thrpt_enh3); + } + + return 1; + +fail: + + return 0; +} + +static int wilc_sdio_read_size(struct wilc *wilc, u32 *size) +{ + u32 tmp; + struct sdio_cmd52 cmd; + + /** + * Read DMA count in words + **/ + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf2; + cmd.data = 0; + wilc_sdio_cmd52(wilc, &cmd); + tmp = cmd.data; + + cmd.address = 0xf3; + cmd.data = 0; + wilc_sdio_cmd52(wilc, &cmd); + tmp |= (cmd.data << 8); + + *size = tmp; + return 1; +} + +static int wilc_sdio_read_int(struct wilc *wilc, u32 *int_status) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + u32 tmp; + struct sdio_cmd52 cmd; + + wilc_sdio_read_size(wilc, &tmp); + + /** + * Read IRQ flags + **/ + if (!sdio_priv->irq_gpio) { + int i; + + cmd.read_write = 0; + cmd.function = 1; + cmd.address = 0x04; + cmd.data = 0; + wilc_sdio_cmd52(wilc, &cmd); + + if (cmd.data & BIT(0)) + tmp |= INT_0; + if (cmd.data & BIT(2)) + tmp |= INT_1; + if (cmd.data & BIT(3)) + tmp |= INT_2; + if (cmd.data & BIT(4)) + tmp |= INT_3; + if (cmd.data & BIT(5)) + tmp |= INT_4; + if (cmd.data & BIT(6)) + tmp |= INT_5; + for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { + if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) { + dev_err(&func->dev, + "Unexpected interrupt (1) : tmp=%x, data=%x\n", + tmp, cmd.data); + break; + } + } + } else { + u32 irq_flags; + + cmd.read_write = 0; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf7; + cmd.data = 0; + wilc_sdio_cmd52(wilc, &cmd); + irq_flags = cmd.data & 0x1f; + tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET); + } + + *int_status = tmp; + + return 1; +} + +static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + int ret; + int vmm_ctl; + + if (sdio_priv->has_thrpt_enh3) { + u32 reg; + + if (sdio_priv->irq_gpio) { + u32 flags; + + flags = val & (BIT(MAX_NUN_INT_THRPT_ENH2) - 1); + reg = flags; + } else { + reg = 0; + } + /* select VMM table 0 */ + if (val & SEL_VMM_TBL0) + reg |= BIT(5); + /* select VMM table 1 */ + if (val & SEL_VMM_TBL1) + reg |= BIT(6); + /* enable VMM */ + if (val & EN_VMM) + reg |= BIT(7); + if (reg) { + struct sdio_cmd52 cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf8; + cmd.data = reg; + + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd52, set 0xf8 data (%d) ...\n", + __LINE__); + goto fail; + } + } + return 1; + } + if (sdio_priv->irq_gpio) { + /* has_thrpt_enh2 uses register 0xf8 to clear interrupts. */ + /* + * Cannot clear multiple interrupts. + * Must clear each interrupt individually. + */ + u32 flags; + + flags = val & (BIT(MAX_NUM_INT) - 1); + if (flags) { + int i; + + ret = 1; + for (i = 0; i < sdio_priv->nint; i++) { + if (flags & 1) { + struct sdio_cmd52 cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf8; + cmd.data = BIT(i); + + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd52, set 0xf8 data (%d) ...\n", + __LINE__); + goto fail; + } + } + if (!ret) + break; + flags >>= 1; + } + if (!ret) + goto fail; + for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { + if (flags & 1) + dev_err(&func->dev, + "Unexpected interrupt cleared %d...\n", + i); + flags >>= 1; + } + } + } + + vmm_ctl = 0; + /* select VMM table 0 */ + if (val & SEL_VMM_TBL0) + vmm_ctl |= BIT(0); + /* select VMM table 1 */ + if (val & SEL_VMM_TBL1) + vmm_ctl |= BIT(1); + /* enable VMM */ + if (val & EN_VMM) + vmm_ctl |= BIT(2); + + if (vmm_ctl) { + struct sdio_cmd52 cmd; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 0; + cmd.address = 0xf6; + cmd.data = vmm_ctl; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed cmd52, set 0xf6 data (%d) ...\n", + __LINE__); + goto fail; + } + } + return 1; +fail: + return 0; +} + +static int wilc_sdio_sync_ext(struct wilc *wilc, int nint) +{ + struct sdio_func *func = dev_to_sdio_func(wilc->dev); + struct wilc_sdio *sdio_priv = wilc->bus_data; + u32 reg; + + if (nint > MAX_NUM_INT) { + dev_err(&func->dev, "Too many interrupts (%d)...\n", nint); + return 0; + } + if (nint > MAX_NUN_INT_THRPT_ENH2) { + dev_err(&func->dev, + "Cannot support more than 5 interrupts when has_thrpt_enh2=1.\n"); + return 0; + } + + sdio_priv->nint = nint; + + /** + * Disable power sequencer + **/ + if (!wilc_sdio_read_reg(wilc, WILC_MISC, ®)) { + dev_err(&func->dev, "Failed read misc reg...\n"); + return 0; + } + + reg &= ~BIT(8); + if (!wilc_sdio_write_reg(wilc, WILC_MISC, reg)) { + dev_err(&func->dev, "Failed write misc reg...\n"); + return 0; + } + + if (sdio_priv->irq_gpio) { + u32 reg; + int ret, i; + + /** + * interrupt pin mux select + **/ + ret = wilc_sdio_read_reg(wilc, WILC_PIN_MUX_0, ®); + if (!ret) { + dev_err(&func->dev, "Failed read reg (%08x)...\n", + WILC_PIN_MUX_0); + return 0; + } + reg |= BIT(8); + ret = wilc_sdio_write_reg(wilc, WILC_PIN_MUX_0, reg); + if (!ret) { + dev_err(&func->dev, "Failed write reg (%08x)...\n", + WILC_PIN_MUX_0); + return 0; + } + + /** + * interrupt enable + **/ + ret = wilc_sdio_read_reg(wilc, WILC_INTR_ENABLE, ®); + if (!ret) { + dev_err(&func->dev, "Failed read reg (%08x)...\n", + WILC_INTR_ENABLE); + return 0; + } + + for (i = 0; (i < 5) && (nint > 0); i++, nint--) + reg |= BIT((27 + i)); + ret = wilc_sdio_write_reg(wilc, WILC_INTR_ENABLE, reg); + if (!ret) { + dev_err(&func->dev, "Failed write reg (%08x)...\n", + WILC_INTR_ENABLE); + return 0; + } + if (nint) { + ret = wilc_sdio_read_reg(wilc, WILC_INTR2_ENABLE, ®); + if (!ret) { + dev_err(&func->dev, + "Failed read reg (%08x)...\n", + WILC_INTR2_ENABLE); + return 0; + } + + for (i = 0; (i < 3) && (nint > 0); i++, nint--) + reg |= BIT(i); + + ret = wilc_sdio_read_reg(wilc, WILC_INTR2_ENABLE, ®); + if (!ret) { + dev_err(&func->dev, + "Failed write reg (%08x)...\n", + WILC_INTR2_ENABLE); + return 0; + } + } + } + return 1; +} + +/* Global sdio HIF function table */ +static const struct wilc_hif_func wilc_hif_sdio = { + .hif_init = wilc_sdio_init, + .hif_deinit = wilc_sdio_deinit, + .hif_read_reg = wilc_sdio_read_reg, + .hif_write_reg = wilc_sdio_write_reg, + .hif_block_rx = wilc_sdio_read, + .hif_block_tx = wilc_sdio_write, + .hif_read_int = wilc_sdio_read_int, + .hif_clear_int_ext = wilc_sdio_clear_int_ext, + .hif_read_size = wilc_sdio_read_size, + .hif_block_tx_ext = wilc_sdio_write, + .hif_block_rx_ext = wilc_sdio_read, + .hif_sync_ext = wilc_sdio_sync_ext, + .enable_interrupt = wilc_sdio_enable_interrupt, + .disable_interrupt = wilc_sdio_disable_interrupt, +}; + +static int wilc_sdio_resume(struct device *dev) +{ + struct sdio_func *func = dev_to_sdio_func(dev); + struct wilc *wilc = sdio_get_drvdata(func); + + dev_info(dev, "sdio resume\n"); + sdio_release_host(func); + chip_wakeup(wilc); + wilc_sdio_init(wilc, true); + + if (wilc->suspend_event) + host_wakeup_notify(wilc); + + chip_allow_sleep(wilc); + + return 0; +} + +static const struct of_device_id wilc_of_match[] = { + { .compatible = "microchip,wilc1000-sdio", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, wilc_of_match); + +static const struct dev_pm_ops wilc_sdio_pm_ops = { + .suspend = wilc_sdio_suspend, + .resume = wilc_sdio_resume, +}; + +static struct sdio_driver wilc_sdio_driver = { + .name = SDIO_MODALIAS, + .id_table = wilc_sdio_ids, + .probe = wilc_sdio_probe, + .remove = wilc_sdio_remove, + .drv = { + .pm = &wilc_sdio_pm_ops, + .of_match_table = wilc_of_match, + } +}; +module_driver(wilc_sdio_driver, + sdio_register_driver, + sdio_unregister_driver); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c new file mode 100644 index 000000000000..55f8757325f0 --- /dev/null +++ b/drivers/staging/wilc1000/spi.c @@ -0,0 +1,1145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include +#include + +#include "netdev.h" +#include "cfg80211.h" + +struct wilc_spi { + int crc_off; + int nint; + int has_thrpt_enh; +}; + +static const struct wilc_hif_func wilc_hif_spi; + +/******************************************** + * + * Crc7 + * + ********************************************/ + +static const u8 crc7_syndrome_table[256] = { + 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f, + 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77, + 0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26, + 0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e, + 0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d, + 0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45, + 0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14, + 0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c, + 0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b, + 0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13, + 0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42, + 0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a, + 0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69, + 0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21, + 0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70, + 0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38, + 0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e, + 0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36, + 0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67, + 0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f, + 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c, + 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04, + 0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55, + 0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d, + 0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a, + 0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52, + 0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03, + 0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b, + 0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28, + 0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60, + 0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31, + 0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79 +}; + +static u8 crc7_byte(u8 crc, u8 data) +{ + return crc7_syndrome_table[(crc << 1) ^ data]; +} + +static u8 crc7(u8 crc, const u8 *buffer, u32 len) +{ + while (len--) + crc = crc7_byte(crc, *buffer++); + return crc; +} + +/******************************************** + * + * Spi protocol Function + * + ********************************************/ + +#define CMD_DMA_WRITE 0xc1 +#define CMD_DMA_READ 0xc2 +#define CMD_INTERNAL_WRITE 0xc3 +#define CMD_INTERNAL_READ 0xc4 +#define CMD_TERMINATE 0xc5 +#define CMD_REPEAT 0xc6 +#define CMD_DMA_EXT_WRITE 0xc7 +#define CMD_DMA_EXT_READ 0xc8 +#define CMD_SINGLE_WRITE 0xc9 +#define CMD_SINGLE_READ 0xca +#define CMD_RESET 0xcf + +#define N_OK 1 +#define N_FAIL 0 +#define N_RESET -1 +#define N_RETRY -2 + +#define DATA_PKT_SZ_256 256 +#define DATA_PKT_SZ_512 512 +#define DATA_PKT_SZ_1K 1024 +#define DATA_PKT_SZ_4K (4 * 1024) +#define DATA_PKT_SZ_8K (8 * 1024) +#define DATA_PKT_SZ DATA_PKT_SZ_8K + +#define USE_SPI_DMA 0 + +static int wilc_bus_probe(struct spi_device *spi) +{ + int ret; + struct wilc *wilc; + struct gpio_desc *gpio; + struct wilc_spi *spi_priv; + + spi_priv = kzalloc(sizeof(*spi_priv), GFP_KERNEL); + if (!spi_priv) + return -ENOMEM; + + gpio = gpiod_get(&spi->dev, "irq", GPIOD_IN); + if (IS_ERR(gpio)) { + /* get the GPIO descriptor from hardcode GPIO number */ + gpio = gpio_to_desc(GPIO_NUM); + if (!gpio) + dev_err(&spi->dev, "failed to get the irq gpio\n"); + } + + ret = wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi); + if (ret) { + kfree(spi_priv); + return ret; + } + + spi_set_drvdata(spi, wilc); + wilc->dev = &spi->dev; + wilc->bus_data = spi_priv; + wilc->gpio_irq = gpio; + + wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk"); + if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + else if (!IS_ERR(wilc->rtc_clk)) + clk_prepare_enable(wilc->rtc_clk); + + return 0; +} + +static int wilc_bus_remove(struct spi_device *spi) +{ + struct wilc *wilc = spi_get_drvdata(spi); + + /* free the GPIO in module remove */ + if (wilc->gpio_irq) + gpiod_put(wilc->gpio_irq); + + if (!IS_ERR(wilc->rtc_clk)) + clk_disable_unprepare(wilc->rtc_clk); + + wilc_netdev_cleanup(wilc); + return 0; +} + +static const struct of_device_id wilc_of_match[] = { + { .compatible = "microchip,wilc1000-spi", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, wilc_of_match); + +static struct spi_driver wilc_spi_driver = { + .driver = { + .name = MODALIAS, + .of_match_table = wilc_of_match, + }, + .probe = wilc_bus_probe, + .remove = wilc_bus_remove, +}; +module_spi_driver(wilc_spi_driver); +MODULE_LICENSE("GPL"); + +static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int ret; + struct spi_message msg; + + if (len > 0 && b) { + struct spi_transfer tr = { + .tx_buf = b, + .len = len, + .delay_usecs = 0, + }; + char *r_buffer = kzalloc(len, GFP_KERNEL); + + if (!r_buffer) + return -ENOMEM; + + tr.rx_buf = r_buffer; + dev_dbg(&spi->dev, "Request writing %d bytes\n", len); + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = spi; + msg.is_dma_mapped = USE_SPI_DMA; + spi_message_add_tail(&tr, &msg); + + ret = spi_sync(spi, &msg); + if (ret < 0) + dev_err(&spi->dev, "SPI transaction failed\n"); + + kfree(r_buffer); + } else { + dev_err(&spi->dev, + "can't write data with the following length: %d\n", + len); + ret = -EINVAL; + } + + return ret; +} + +static int wilc_spi_rx(struct wilc *wilc, u8 *rb, u32 rlen) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int ret; + + if (rlen > 0) { + struct spi_message msg; + struct spi_transfer tr = { + .rx_buf = rb, + .len = rlen, + .delay_usecs = 0, + + }; + char *t_buffer = kzalloc(rlen, GFP_KERNEL); + + if (!t_buffer) + return -ENOMEM; + + tr.tx_buf = t_buffer; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = spi; + msg.is_dma_mapped = USE_SPI_DMA; + spi_message_add_tail(&tr, &msg); + + ret = spi_sync(spi, &msg); + if (ret < 0) + dev_err(&spi->dev, "SPI transaction failed\n"); + kfree(t_buffer); + } else { + dev_err(&spi->dev, + "can't read data with the following length: %u\n", + rlen); + ret = -EINVAL; + } + + return ret; +} + +static int wilc_spi_tx_rx(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int ret; + + if (rlen > 0) { + struct spi_message msg; + struct spi_transfer tr = { + .rx_buf = rb, + .tx_buf = wb, + .len = rlen, + .bits_per_word = 8, + .delay_usecs = 0, + + }; + + memset(&msg, 0, sizeof(msg)); + spi_message_init(&msg); + msg.spi = spi; + msg.is_dma_mapped = USE_SPI_DMA; + + spi_message_add_tail(&tr, &msg); + ret = spi_sync(spi, &msg); + if (ret < 0) + dev_err(&spi->dev, "SPI transaction failed\n"); + } else { + dev_err(&spi->dev, + "can't read data with the following length: %u\n", + rlen); + ret = -EINVAL; + } + + return ret; +} + +static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, + u8 clockless) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + u8 wb[32], rb[32]; + u8 wix, rix; + u32 len2; + u8 rsp; + int len = 0; + int result = N_OK; + int retry; + u8 crc[2]; + + wb[0] = cmd; + switch (cmd) { + case CMD_SINGLE_READ: /* single word (4 bytes) read */ + wb[1] = (u8)(adr >> 16); + wb[2] = (u8)(adr >> 8); + wb[3] = (u8)adr; + len = 5; + break; + + case CMD_INTERNAL_READ: /* internal register read */ + wb[1] = (u8)(adr >> 8); + if (clockless == 1) + wb[1] |= BIT(7); + wb[2] = (u8)adr; + wb[3] = 0x00; + len = 5; + break; + + case CMD_TERMINATE: + wb[1] = 0x00; + wb[2] = 0x00; + wb[3] = 0x00; + len = 5; + break; + + case CMD_REPEAT: + wb[1] = 0x00; + wb[2] = 0x00; + wb[3] = 0x00; + len = 5; + break; + + case CMD_RESET: + wb[1] = 0xff; + wb[2] = 0xff; + wb[3] = 0xff; + len = 5; + break; + + case CMD_DMA_WRITE: /* dma write */ + case CMD_DMA_READ: /* dma read */ + wb[1] = (u8)(adr >> 16); + wb[2] = (u8)(adr >> 8); + wb[3] = (u8)adr; + wb[4] = (u8)(sz >> 8); + wb[5] = (u8)(sz); + len = 7; + break; + + case CMD_DMA_EXT_WRITE: /* dma extended write */ + case CMD_DMA_EXT_READ: /* dma extended read */ + wb[1] = (u8)(adr >> 16); + wb[2] = (u8)(adr >> 8); + wb[3] = (u8)adr; + wb[4] = (u8)(sz >> 16); + wb[5] = (u8)(sz >> 8); + wb[6] = (u8)(sz); + len = 8; + break; + + case CMD_INTERNAL_WRITE: /* internal register write */ + wb[1] = (u8)(adr >> 8); + if (clockless == 1) + wb[1] |= BIT(7); + wb[2] = (u8)(adr); + wb[3] = b[3]; + wb[4] = b[2]; + wb[5] = b[1]; + wb[6] = b[0]; + len = 8; + break; + + case CMD_SINGLE_WRITE: /* single word write */ + wb[1] = (u8)(adr >> 16); + wb[2] = (u8)(adr >> 8); + wb[3] = (u8)(adr); + wb[4] = b[3]; + wb[5] = b[2]; + wb[6] = b[1]; + wb[7] = b[0]; + len = 9; + break; + + default: + result = N_FAIL; + break; + } + + if (result != N_OK) + return result; + + if (!spi_priv->crc_off) + wb[len - 1] = (crc7(0x7f, (const u8 *)&wb[0], len - 1)) << 1; + else + len -= 1; + +#define NUM_SKIP_BYTES (1) +#define NUM_RSP_BYTES (2) +#define NUM_DATA_HDR_BYTES (1) +#define NUM_DATA_BYTES (4) +#define NUM_CRC_BYTES (2) +#define NUM_DUMMY_BYTES (3) + if (cmd == CMD_RESET || + cmd == CMD_TERMINATE || + cmd == CMD_REPEAT) { + len2 = len + (NUM_SKIP_BYTES + NUM_RSP_BYTES + NUM_DUMMY_BYTES); + } else if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ) { + int tmp = NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES + + NUM_DUMMY_BYTES; + if (!spi_priv->crc_off) + len2 = len + tmp + NUM_CRC_BYTES; + else + len2 = len + tmp; + } else { + len2 = len + (NUM_RSP_BYTES + NUM_DUMMY_BYTES); + } +#undef NUM_DUMMY_BYTES + + if (len2 > ARRAY_SIZE(wb)) { + dev_err(&spi->dev, "spi buffer size too small (%d) (%zu)\n", + len2, ARRAY_SIZE(wb)); + return N_FAIL; + } + /* zero spi write buffers. */ + for (wix = len; wix < len2; wix++) + wb[wix] = 0; + rix = len; + + if (wilc_spi_tx_rx(wilc, wb, rb, len2)) { + dev_err(&spi->dev, "Failed cmd write, bus error...\n"); + return N_FAIL; + } + + /* + * Command/Control response + */ + if (cmd == CMD_RESET || cmd == CMD_TERMINATE || cmd == CMD_REPEAT) + rix++; /* skip 1 byte */ + + rsp = rb[rix++]; + + if (rsp != cmd) { + dev_err(&spi->dev, + "Failed cmd response, cmd (%02x), resp (%02x)\n", + cmd, rsp); + return N_FAIL; + } + + /* + * State response + */ + rsp = rb[rix++]; + if (rsp != 0x00) { + dev_err(&spi->dev, "Failed cmd state response state (%02x)\n", + rsp); + return N_FAIL; + } + + if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ || + cmd == CMD_DMA_READ || cmd == CMD_DMA_EXT_READ) { + /* + * Data Respnose header + */ + retry = 100; + do { + /* + * ensure there is room in buffer later + * to read data and crc + */ + if (rix < len2) { + rsp = rb[rix++]; + } else { + retry = 0; + break; + } + if (((rsp >> 4) & 0xf) == 0xf) + break; + } while (retry--); + + if (retry <= 0) { + dev_err(&spi->dev, + "Error, data read response (%02x)\n", rsp); + return N_RESET; + } + } + + if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ) { + /* + * Read bytes + */ + if ((rix + 3) < len2) { + b[0] = rb[rix++]; + b[1] = rb[rix++]; + b[2] = rb[rix++]; + b[3] = rb[rix++]; + } else { + dev_err(&spi->dev, + "buffer overrun when reading data.\n"); + return N_FAIL; + } + + if (!spi_priv->crc_off) { + /* + * Read Crc + */ + if ((rix + 1) < len2) { + crc[0] = rb[rix++]; + crc[1] = rb[rix++]; + } else { + dev_err(&spi->dev, + "buffer overrun when reading crc.\n"); + return N_FAIL; + } + } + } else if ((cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) { + int ix; + + /* some data may be read in response to dummy bytes. */ + for (ix = 0; (rix < len2) && (ix < sz); ) + b[ix++] = rb[rix++]; + + sz -= ix; + + if (sz > 0) { + int nbytes; + + if (sz <= (DATA_PKT_SZ - ix)) + nbytes = sz; + else + nbytes = DATA_PKT_SZ - ix; + + /* + * Read bytes + */ + if (wilc_spi_rx(wilc, &b[ix], nbytes)) { + dev_err(&spi->dev, + "Failed block read, bus err\n"); + return N_FAIL; + } + + /* + * Read Crc + */ + if (!spi_priv->crc_off && wilc_spi_rx(wilc, crc, 2)) { + dev_err(&spi->dev, + "Failed block crc read, bus err\n"); + return N_FAIL; + } + + ix += nbytes; + sz -= nbytes; + } + + /* + * if any data in left unread, + * then read the rest using normal DMA code. + */ + while (sz > 0) { + int nbytes; + + if (sz <= DATA_PKT_SZ) + nbytes = sz; + else + nbytes = DATA_PKT_SZ; + + /* + * read data response only on the next DMA cycles not + * the first DMA since data response header is already + * handled above for the first DMA. + */ + /* + * Data Respnose header + */ + retry = 10; + do { + if (wilc_spi_rx(wilc, &rsp, 1)) { + dev_err(&spi->dev, + "Failed resp read, bus err\n"); + result = N_FAIL; + break; + } + if (((rsp >> 4) & 0xf) == 0xf) + break; + } while (retry--); + + if (result == N_FAIL) + break; + + /* + * Read bytes + */ + if (wilc_spi_rx(wilc, &b[ix], nbytes)) { + dev_err(&spi->dev, + "Failed block read, bus err\n"); + result = N_FAIL; + break; + } + + /* + * Read Crc + */ + if (!spi_priv->crc_off && wilc_spi_rx(wilc, crc, 2)) { + dev_err(&spi->dev, + "Failed block crc read, bus err\n"); + result = N_FAIL; + break; + } + + ix += nbytes; + sz -= nbytes; + } + } + return result; +} + +static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + int ix, nbytes; + int result = 1; + u8 cmd, order, crc[2] = {0}; + + /* + * Data + */ + ix = 0; + do { + if (sz <= DATA_PKT_SZ) { + nbytes = sz; + order = 0x3; + } else { + nbytes = DATA_PKT_SZ; + if (ix == 0) + order = 0x1; + else + order = 0x02; + } + + /* + * Write command + */ + cmd = 0xf0; + cmd |= order; + + if (wilc_spi_tx(wilc, &cmd, 1)) { + dev_err(&spi->dev, + "Failed data block cmd write, bus error...\n"); + result = N_FAIL; + break; + } + + /* + * Write data + */ + if (wilc_spi_tx(wilc, &b[ix], nbytes)) { + dev_err(&spi->dev, + "Failed data block write, bus error...\n"); + result = N_FAIL; + break; + } + + /* + * Write Crc + */ + if (!spi_priv->crc_off) { + if (wilc_spi_tx(wilc, crc, 2)) { + dev_err(&spi->dev, "Failed data block crc write, bus error...\n"); + result = N_FAIL; + break; + } + } + + /* + * No need to wait for response + */ + ix += nbytes; + sz -= nbytes; + } while (sz); + + return result; +} + +/******************************************** + * + * Spi Internal Read/Write Function + * + ********************************************/ + +static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int result; + + cpu_to_le32s(&dat); + result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4, + 0); + if (result != N_OK) + dev_err(&spi->dev, "Failed internal write cmd...\n"); + + return result; +} + +static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int result; + + result = spi_cmd_complete(wilc, CMD_INTERNAL_READ, adr, (u8 *)data, 4, + 0); + if (result != N_OK) { + dev_err(&spi->dev, "Failed internal read cmd...\n"); + return 0; + } + + le32_to_cpus(data); + + return 1; +} + +/******************************************** + * + * Spi interfaces + * + ********************************************/ + +static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int result = N_OK; + u8 cmd = CMD_SINGLE_WRITE; + u8 clockless = 0; + + cpu_to_le32s(&data); + if (addr < 0x30) { + /* Clockless register */ + cmd = CMD_INTERNAL_WRITE; + clockless = 1; + } + + result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&data, 4, clockless); + if (result != N_OK) + dev_err(&spi->dev, "Failed cmd, write reg (%08x)...\n", addr); + + return result; +} + +static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int result; + + /* + * has to be greated than 4 + */ + if (size <= 4) + return 0; + + result = spi_cmd_complete(wilc, CMD_DMA_EXT_WRITE, addr, NULL, size, 0); + if (result != N_OK) { + dev_err(&spi->dev, + "Failed cmd, write block (%08x)...\n", addr); + return 0; + } + + /* + * Data + */ + result = spi_data_write(wilc, buf, size); + if (result != N_OK) + dev_err(&spi->dev, "Failed block data write...\n"); + + return 1; +} + +static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int result = N_OK; + u8 cmd = CMD_SINGLE_READ; + u8 clockless = 0; + + if (addr < 0x30) { + /* Clockless register */ + cmd = CMD_INTERNAL_READ; + clockless = 1; + } + + result = spi_cmd_complete(wilc, cmd, addr, (u8 *)data, 4, clockless); + if (result != N_OK) { + dev_err(&spi->dev, "Failed cmd, read reg (%08x)...\n", addr); + return 0; + } + + le32_to_cpus(data); + + return 1; +} + +static int wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + int result; + + if (size <= 4) + return 0; + + result = spi_cmd_complete(wilc, CMD_DMA_EXT_READ, addr, buf, size, 0); + if (result != N_OK) { + dev_err(&spi->dev, "Failed cmd, read block (%08x)...\n", addr); + return 0; + } + + return 1; +} + +/******************************************** + * + * Bus interfaces + * + ********************************************/ + +static int wilc_spi_deinit(struct wilc *wilc) +{ + /* + * TODO: + */ + return 1; +} + +static int wilc_spi_init(struct wilc *wilc, bool resume) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + u32 reg; + u32 chipid; + static int isinit; + + if (isinit) { + if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) { + dev_err(&spi->dev, "Fail cmd read chip id...\n"); + return 0; + } + return 1; + } + + /* + * configure protocol + */ + + /* + * TODO: We can remove the CRC trials if there is a definite + * way to reset + */ + /* the SPI to it's initial value. */ + if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, ®)) { + /* + * Read failed. Try with CRC off. This might happen when module + * is removed but chip isn't reset + */ + spi_priv->crc_off = 1; + dev_err(&spi->dev, + "Failed read with CRC on, retrying with CRC off\n"); + if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, ®)) { + /* + * Read failed with both CRC on and off, + * something went bad + */ + dev_err(&spi->dev, "Failed internal read protocol\n"); + return 0; + } + } + if (spi_priv->crc_off == 0) { + reg &= ~0xc; /* disable crc checking */ + reg &= ~0x70; + reg |= (0x5 << 4); + if (!spi_internal_write(wilc, WILC_SPI_PROTOCOL_OFFSET, reg)) { + dev_err(&spi->dev, + "[wilc spi %d]: Failed internal write reg\n", + __LINE__); + return 0; + } + spi_priv->crc_off = 1; + } + + /* + * make sure can read back chip id correctly + */ + if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) { + dev_err(&spi->dev, "Fail cmd read chip id...\n"); + return 0; + } + + spi_priv->has_thrpt_enh = 1; + + isinit = 1; + + return 1; +} + +static int wilc_spi_read_size(struct wilc *wilc, u32 *size) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + int ret; + + if (spi_priv->has_thrpt_enh) { + ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, + size); + *size = *size & IRQ_DMA_WD_CNT_MASK; + } else { + u32 tmp; + u32 byte_cnt; + + ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, + &byte_cnt); + if (!ret) { + dev_err(&spi->dev, + "Failed read WILC_VMM_TO_HOST_SIZE ...\n"); + return ret; + } + tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; + *size = tmp; + } + + return ret; +} + +static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + int ret; + u32 tmp; + u32 byte_cnt; + bool unexpected_irq; + int j; + u32 unknown_mask; + u32 irq_flags; + int k = IRG_FLAGS_OFFSET + 5; + + if (spi_priv->has_thrpt_enh) + return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, + int_status); + ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, &byte_cnt); + if (!ret) { + dev_err(&spi->dev, + "Failed read WILC_VMM_TO_HOST_SIZE ...\n"); + return ret; + } + tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; + + j = 0; + do { + wilc_spi_read_reg(wilc, 0x1a90, &irq_flags); + tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET); + + if (spi_priv->nint > 5) { + wilc_spi_read_reg(wilc, 0x1a94, &irq_flags); + tmp |= (((irq_flags >> 0) & 0x7) << k); + } + + unknown_mask = ~((1ul << spi_priv->nint) - 1); + + unexpected_irq = (tmp >> IRG_FLAGS_OFFSET) & unknown_mask; + if (unexpected_irq) { + dev_err(&spi->dev, + "Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n", + j, tmp, unknown_mask); + } + + j++; + } while (unexpected_irq); + + *int_status = tmp; + + return ret; +} + +static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + int ret; + u32 flags; + u32 tbl_ctl; + + if (spi_priv->has_thrpt_enh) { + return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE, + val); + } + + flags = val & (BIT(MAX_NUM_INT) - 1); + if (flags) { + int i; + + ret = 1; + for (i = 0; i < spi_priv->nint; i++) { + /* + * No matter what you write 1 or 0, + * it will clear interrupt. + */ + if (flags & 1) + ret = wilc_spi_write_reg(wilc, + 0x10c8 + i * 4, 1); + if (!ret) + break; + flags >>= 1; + } + if (!ret) { + dev_err(&spi->dev, + "Failed wilc_spi_write_reg, set reg %x ...\n", + 0x10c8 + i * 4); + return ret; + } + for (i = spi_priv->nint; i < MAX_NUM_INT; i++) { + if (flags & 1) + dev_err(&spi->dev, + "Unexpected interrupt cleared %d...\n", + i); + flags >>= 1; + } + } + + tbl_ctl = 0; + /* select VMM table 0 */ + if (val & SEL_VMM_TBL0) + tbl_ctl |= BIT(0); + /* select VMM table 1 */ + if (val & SEL_VMM_TBL1) + tbl_ctl |= BIT(1); + + ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL, tbl_ctl); + if (!ret) { + dev_err(&spi->dev, "fail write reg vmm_tbl_ctl...\n"); + return ret; + } + + if (val & EN_VMM) { + /* + * enable vmm transfer. + */ + ret = wilc_spi_write_reg(wilc, WILC_VMM_CORE_CTL, 1); + if (!ret) { + dev_err(&spi->dev, "fail write reg vmm_core_ctl...\n"); + return ret; + } + } + + return ret; +} + +static int wilc_spi_sync_ext(struct wilc *wilc, int nint) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + u32 reg; + int ret, i; + + if (nint > MAX_NUM_INT) { + dev_err(&spi->dev, "Too many interrupts (%d)...\n", nint); + return 0; + } + + spi_priv->nint = nint; + + /* + * interrupt pin mux select + */ + ret = wilc_spi_read_reg(wilc, WILC_PIN_MUX_0, ®); + if (!ret) { + dev_err(&spi->dev, "Failed read reg (%08x)...\n", + WILC_PIN_MUX_0); + return 0; + } + reg |= BIT(8); + ret = wilc_spi_write_reg(wilc, WILC_PIN_MUX_0, reg); + if (!ret) { + dev_err(&spi->dev, "Failed write reg (%08x)...\n", + WILC_PIN_MUX_0); + return 0; + } + + /* + * interrupt enable + */ + ret = wilc_spi_read_reg(wilc, WILC_INTR_ENABLE, ®); + if (!ret) { + dev_err(&spi->dev, "Failed read reg (%08x)...\n", + WILC_INTR_ENABLE); + return 0; + } + + for (i = 0; (i < 5) && (nint > 0); i++, nint--) + reg |= (BIT((27 + i))); + + ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg); + if (!ret) { + dev_err(&spi->dev, "Failed write reg (%08x)...\n", + WILC_INTR_ENABLE); + return 0; + } + if (nint) { + ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®); + if (!ret) { + dev_err(&spi->dev, "Failed read reg (%08x)...\n", + WILC_INTR2_ENABLE); + return 0; + } + + for (i = 0; (i < 3) && (nint > 0); i++, nint--) + reg |= BIT(i); + + ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®); + if (!ret) { + dev_err(&spi->dev, "Failed write reg (%08x)...\n", + WILC_INTR2_ENABLE); + return 0; + } + } + + return 1; +} + +/* Global spi HIF function table */ +static const struct wilc_hif_func wilc_hif_spi = { + .hif_init = wilc_spi_init, + .hif_deinit = wilc_spi_deinit, + .hif_read_reg = wilc_spi_read_reg, + .hif_write_reg = wilc_spi_write_reg, + .hif_block_rx = wilc_spi_read, + .hif_block_tx = wilc_spi_write, + .hif_read_int = wilc_spi_read_int, + .hif_clear_int_ext = wilc_spi_clear_int_ext, + .hif_read_size = wilc_spi_read_size, + .hif_block_tx_ext = wilc_spi_write, + .hif_block_rx_ext = wilc_spi_read, + .hif_sync_ext = wilc_spi_sync_ext, +}; diff --git a/drivers/staging/wilc1000/wilc_hif.c b/drivers/staging/wilc1000/wilc_hif.c deleted file mode 100644 index 59eb7600619b..000000000000 --- a/drivers/staging/wilc1000/wilc_hif.c +++ /dev/null @@ -1,2043 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include "wilc_wfi_netdevice.h" - -#define WILC_HIF_SCAN_TIMEOUT_MS 5000 -#define WILC_HIF_CONNECT_TIMEOUT_MS 9500 - -#define WILC_FALSE_FRMWR_CHANNEL 100 -#define WILC_MAX_RATES_SUPPORTED 12 - -struct wilc_rcvd_mac_info { - u8 status; -}; - -struct wilc_set_multicast { - u32 enabled; - u32 cnt; - u8 *mc_list; -}; - -struct wilc_del_all_sta { - u8 assoc_sta; - u8 mac[WILC_MAX_NUM_STA][ETH_ALEN]; -}; - -struct wilc_op_mode { - __le32 mode; -}; - -struct wilc_reg_frame { - u8 reg; - u8 reg_id; - __le16 frame_type; -} __packed; - -struct wilc_drv_handler { - __le32 handler; - u8 mode; -} __packed; - -struct wilc_wep_key { - u8 index; - u8 key_len; - u8 key[0]; -} __packed; - -struct wilc_sta_wpa_ptk { - u8 mac_addr[ETH_ALEN]; - u8 key_len; - u8 key[0]; -} __packed; - -struct wilc_ap_wpa_ptk { - u8 mac_addr[ETH_ALEN]; - u8 index; - u8 key_len; - u8 key[0]; -} __packed; - -struct wilc_gtk_key { - u8 mac_addr[ETH_ALEN]; - u8 rsc[8]; - u8 index; - u8 key_len; - u8 key[0]; -} __packed; - -union wilc_message_body { - struct wilc_rcvd_net_info net_info; - struct wilc_rcvd_mac_info mac_info; - struct wilc_set_multicast mc_info; - struct wilc_remain_ch remain_on_ch; - char *data; -}; - -struct host_if_msg { - union wilc_message_body body; - struct wilc_vif *vif; - struct work_struct work; - void (*fn)(struct work_struct *ws); - struct completion work_comp; - bool is_sync; -}; - -struct wilc_noa_opp_enable { - u8 ct_window; - u8 cnt; - __le32 duration; - __le32 interval; - __le32 start_time; -} __packed; - -struct wilc_noa_opp_disable { - u8 cnt; - __le32 duration; - __le32 interval; - __le32 start_time; -} __packed; - -struct wilc_join_bss_param { - char ssid[IEEE80211_MAX_SSID_LEN]; - u8 ssid_terminator; - u8 bss_type; - u8 ch; - __le16 cap_info; - u8 sa[ETH_ALEN]; - u8 bssid[ETH_ALEN]; - __le16 beacon_period; - u8 dtim_period; - u8 supp_rates[WILC_MAX_RATES_SUPPORTED + 1]; - u8 wmm_cap; - u8 uapsd_cap; - u8 ht_capable; - u8 rsn_found; - u8 rsn_grp_policy; - u8 mode_802_11i; - u8 p_suites[3]; - u8 akm_suites[3]; - u8 rsn_cap[2]; - u8 noa_enabled; - __le32 tsf_lo; - u8 idx; - u8 opp_enabled; - union { - struct wilc_noa_opp_disable opp_dis; - struct wilc_noa_opp_enable opp_en; - }; -} __packed; - -/* 'msg' should be free by the caller for syc */ -static struct host_if_msg* -wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *), - bool is_sync) -{ - struct host_if_msg *msg; - - if (!work_fun) - return ERR_PTR(-EINVAL); - - msg = kzalloc(sizeof(*msg), GFP_ATOMIC); - if (!msg) - return ERR_PTR(-ENOMEM); - msg->fn = work_fun; - msg->vif = vif; - msg->is_sync = is_sync; - if (is_sync) - init_completion(&msg->work_comp); - - return msg; -} - -static int wilc_enqueue_work(struct host_if_msg *msg) -{ - INIT_WORK(&msg->work, msg->fn); - - if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue) - return -EINVAL; - - if (!queue_work(msg->vif->wilc->hif_workqueue, &msg->work)) - return -EINVAL; - - return 0; -} - -/* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as - * special purpose in wilc device, so we add 1 to the index to starts from 1. - * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC. - */ -int wilc_get_vif_idx(struct wilc_vif *vif) -{ - return vif->idx + 1; -} - -/* We need to minus 1 from idx which is from wilc device to get real index - * of wilc->vif[], because we add 1 when pass to wilc device in the function - * wilc_get_vif_idx. - * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1). - */ -static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) -{ - int index = idx - 1; - struct wilc_vif *vif; - - if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC) - return NULL; - - list_for_each_entry_rcu(vif, &wilc->vif_list, list) { - if (vif->idx == index) - return vif; - } - - return NULL; -} - -static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) -{ - int result = 0; - u8 abort_running_scan; - struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; - struct wilc_user_scan_req *scan_req; - - if (evt == SCAN_EVENT_ABORTED) { - abort_running_scan = 1; - wid.id = WID_ABORT_RUNNING_SCAN; - wid.type = WID_CHAR; - wid.val = (s8 *)&abort_running_scan; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) { - netdev_err(vif->ndev, "Failed to set abort running\n"); - result = -EFAULT; - } - } - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); - return result; - } - - scan_req = &hif_drv->usr_scan_req; - if (scan_req->scan_result) { - scan_req->scan_result(evt, NULL, scan_req->arg); - scan_req->scan_result = NULL; - } - - return result; -} - -int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, - u8 *ch_freq_list, u8 ch_list_len, - void (*scan_result_fn)(enum scan_event, - struct wilc_rcvd_net_info *, void *), - void *user_arg, struct cfg80211_scan_request *request) -{ - int result = 0; - struct wid wid_list[5]; - u32 index = 0; - u32 i, scan_timeout; - u8 *buffer; - u8 valuesize = 0; - u8 *search_ssid_vals = NULL; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (hif_drv->hif_state >= HOST_IF_SCANNING && - hif_drv->hif_state < HOST_IF_CONNECTED) { - netdev_err(vif->ndev, "Already scan\n"); - result = -EBUSY; - goto error; - } - - if (vif->connecting) { - netdev_err(vif->ndev, "Don't do obss scan\n"); - result = -EBUSY; - goto error; - } - - hif_drv->usr_scan_req.ch_cnt = 0; - - if (request->n_ssids) { - for (i = 0; i < request->n_ssids; i++) - valuesize += ((request->ssids[i].ssid_len) + 1); - search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL); - if (search_ssid_vals) { - wid_list[index].id = WID_SSID_PROBE_REQ; - wid_list[index].type = WID_STR; - wid_list[index].val = search_ssid_vals; - buffer = wid_list[index].val; - - *buffer++ = request->n_ssids; - - for (i = 0; i < request->n_ssids; i++) { - *buffer++ = request->ssids[i].ssid_len; - memcpy(buffer, request->ssids[i].ssid, - request->ssids[i].ssid_len); - buffer += request->ssids[i].ssid_len; - } - wid_list[index].size = (s32)(valuesize + 1); - index++; - } - } - - wid_list[index].id = WID_INFO_ELEMENT_PROBE; - wid_list[index].type = WID_BIN_DATA; - wid_list[index].val = (s8 *)request->ie; - wid_list[index].size = request->ie_len; - index++; - - wid_list[index].id = WID_SCAN_TYPE; - wid_list[index].type = WID_CHAR; - wid_list[index].size = sizeof(char); - wid_list[index].val = (s8 *)&scan_type; - index++; - - if (scan_type == WILC_FW_PASSIVE_SCAN && request->duration) { - wid_list[index].id = WID_PASSIVE_SCAN_TIME; - wid_list[index].type = WID_SHORT; - wid_list[index].size = sizeof(u16); - wid_list[index].val = (s8 *)&request->duration; - index++; - - scan_timeout = (request->duration * ch_list_len) + 500; - } else { - scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS; - } - - wid_list[index].id = WID_SCAN_CHANNEL_LIST; - wid_list[index].type = WID_BIN_DATA; - - if (ch_freq_list && ch_list_len > 0) { - for (i = 0; i < ch_list_len; i++) { - if (ch_freq_list[i] > 0) - ch_freq_list[i] -= 1; - } - } - - wid_list[index].val = ch_freq_list; - wid_list[index].size = ch_list_len; - index++; - - wid_list[index].id = WID_START_SCAN_REQ; - wid_list[index].type = WID_CHAR; - wid_list[index].size = sizeof(char); - wid_list[index].val = (s8 *)&scan_source; - index++; - - hif_drv->usr_scan_req.scan_result = scan_result_fn; - hif_drv->usr_scan_req.arg = user_arg; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index); - if (result) { - netdev_err(vif->ndev, "Failed to send scan parameters\n"); - goto error; - } - - hif_drv->scan_timer_vif = vif; - mod_timer(&hif_drv->scan_timer, - jiffies + msecs_to_jiffies(scan_timeout)); - -error: - - kfree(search_ssid_vals); - - return result; -} - -static int wilc_send_connect_wid(struct wilc_vif *vif) -{ - int result = 0; - struct wid wid_list[4]; - u32 wid_cnt = 0; - struct host_if_drv *hif_drv = vif->hif_drv; - struct wilc_conn_info *conn_attr = &hif_drv->conn_info; - struct wilc_join_bss_param *bss_param = conn_attr->param; - - wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE; - wid_list[wid_cnt].type = WID_BIN_DATA; - wid_list[wid_cnt].val = conn_attr->req_ies; - wid_list[wid_cnt].size = conn_attr->req_ies_len; - wid_cnt++; - - wid_list[wid_cnt].id = WID_11I_MODE; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - wid_list[wid_cnt].val = (s8 *)&conn_attr->security; - wid_cnt++; - - wid_list[wid_cnt].id = WID_AUTH_TYPE; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - wid_list[wid_cnt].val = (s8 *)&conn_attr->auth_type; - wid_cnt++; - - wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED; - wid_list[wid_cnt].type = WID_STR; - wid_list[wid_cnt].size = sizeof(*bss_param); - wid_list[wid_cnt].val = (u8 *)bss_param; - wid_cnt++; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, wid_cnt); - if (result) { - netdev_err(vif->ndev, "failed to send config packet\n"); - goto error; - } else { - hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; - } - - return 0; - -error: - - kfree(conn_attr->req_ies); - conn_attr->req_ies = NULL; - - return result; -} - -static void handle_connect_timeout(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - int result; - struct wid wid; - u16 dummy_reason_code = 0; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); - goto out; - } - - hif_drv->hif_state = HOST_IF_IDLE; - - if (hif_drv->conn_info.conn_result) { - hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_CONN_RESP, - WILC_MAC_STATUS_DISCONNECTED, - hif_drv->conn_info.arg); - - } else { - netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); - } - - wid.id = WID_DISCONNECT; - wid.type = WID_CHAR; - wid.val = (s8 *)&dummy_reason_code; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send disconnect\n"); - - hif_drv->conn_info.req_ies_len = 0; - kfree(hif_drv->conn_info.req_ies); - hif_drv->conn_info.req_ies = NULL; - -out: - kfree(msg); -} - -void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, - struct cfg80211_crypto_settings *crypto) -{ - struct wilc_join_bss_param *param; - struct ieee80211_p2p_noa_attr noa_attr; - u8 rates_len = 0; - const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie; - const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie; - int ret; - const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies); - - param = kzalloc(sizeof(*param), GFP_KERNEL); - if (!param) - return NULL; - - param->beacon_period = cpu_to_le16(bss->beacon_interval); - param->cap_info = cpu_to_le16(bss->capability); - param->bss_type = WILC_FW_BSS_TYPE_INFRA; - param->ch = ieee80211_frequency_to_channel(bss->channel->center_freq); - ether_addr_copy(param->bssid, bss->bssid); - - ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len); - if (ssid_elm) { - if (ssid_elm[1] <= IEEE80211_MAX_SSID_LEN) - memcpy(param->ssid, ssid_elm + 2, ssid_elm[1]); - } - - tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len); - if (tim_elm && tim_elm[1] >= 2) - param->dtim_period = tim_elm[3]; - - memset(param->p_suites, 0xFF, 3); - memset(param->akm_suites, 0xFF, 3); - - rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len); - if (rates_ie) { - rates_len = rates_ie[1]; - if (rates_len > WILC_MAX_RATES_SUPPORTED) - rates_len = WILC_MAX_RATES_SUPPORTED; - param->supp_rates[0] = rates_len; - memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len); - } - - supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies->data, - ies->len); - if (supp_rates_ie) { - if (supp_rates_ie[1] > (WILC_MAX_RATES_SUPPORTED - rates_len)) - param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; - else - param->supp_rates[0] += supp_rates_ie[1]; - - memcpy(¶m->supp_rates[rates_len + 1], supp_rates_ie + 2, - (param->supp_rates[0] - rates_len)); - } - - ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len); - if (ht_ie) - param->ht_capable = true; - - ret = cfg80211_get_p2p_attr(ies->data, ies->len, - IEEE80211_P2P_ATTR_ABSENCE_NOTICE, - (u8 *)&noa_attr, sizeof(noa_attr)); - if (ret > 0) { - param->tsf_lo = cpu_to_le32(ies->tsf); - param->noa_enabled = 1; - param->idx = noa_attr.index; - if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) { - param->opp_enabled = 1; - param->opp_en.ct_window = noa_attr.oppps_ctwindow; - param->opp_en.cnt = noa_attr.desc[0].count; - param->opp_en.duration = noa_attr.desc[0].duration; - param->opp_en.interval = noa_attr.desc[0].interval; - param->opp_en.start_time = noa_attr.desc[0].start_time; - } else { - param->opp_enabled = 0; - param->opp_dis.cnt = noa_attr.desc[0].count; - param->opp_dis.duration = noa_attr.desc[0].duration; - param->opp_dis.interval = noa_attr.desc[0].interval; - param->opp_dis.start_time = noa_attr.desc[0].start_time; - } - } - wmm_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, - WLAN_OUI_TYPE_MICROSOFT_WMM, - ies->data, ies->len); - if (wmm_ie) { - struct ieee80211_wmm_param_ie *ie; - - ie = (struct ieee80211_wmm_param_ie *)wmm_ie; - if ((ie->oui_subtype == 0 || ie->oui_subtype == 1) && - ie->version == 1) { - param->wmm_cap = true; - if (ie->qos_info & BIT(7)) - param->uapsd_cap = true; - } - } - - wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, - WLAN_OUI_TYPE_MICROSOFT_WPA, - ies->data, ies->len); - if (wpa_ie) { - param->mode_802_11i = 1; - param->rsn_found = true; - } - - rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies->data, ies->len); - if (rsn_ie) { - int offset = 8; - - param->mode_802_11i = 2; - param->rsn_found = true; - //extract RSN capabilities - offset += (rsn_ie[offset] * 4) + 2; - offset += (rsn_ie[offset] * 4) + 2; - memcpy(param->rsn_cap, &rsn_ie[offset], 2); - } - - if (param->rsn_found) { - int i; - - param->rsn_grp_policy = crypto->cipher_group & 0xFF; - for (i = 0; i < crypto->n_ciphers_pairwise && i < 3; i++) - param->p_suites[i] = crypto->ciphers_pairwise[i] & 0xFF; - - for (i = 0; i < crypto->n_akm_suites && i < 3; i++) - param->akm_suites[i] = crypto->akm_suites[i] & 0xFF; - } - - return (void *)param; -} - -static void handle_rcvd_ntwrk_info(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_rcvd_net_info *rcvd_info = &msg->body.net_info; - struct wilc_user_scan_req *scan_req = &msg->vif->hif_drv->usr_scan_req; - const u8 *ch_elm; - u8 *ies; - int ies_len; - size_t offset; - - if (ieee80211_is_probe_resp(rcvd_info->mgmt->frame_control)) - offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); - else if (ieee80211_is_beacon(rcvd_info->mgmt->frame_control)) - offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); - else - goto done; - - ies = rcvd_info->mgmt->u.beacon.variable; - ies_len = rcvd_info->frame_len - offset; - if (ies_len <= 0) - goto done; - - ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); - if (ch_elm && ch_elm[1] > 0) - rcvd_info->ch = ch_elm[2]; - - if (scan_req->scan_result) - scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, rcvd_info, - scan_req->arg); - -done: - kfree(rcvd_info->mgmt); - kfree(msg); -} - -static void host_int_get_assoc_res_info(struct wilc_vif *vif, - u8 *assoc_resp_info, - u32 max_assoc_resp_info_len, - u32 *rcvd_assoc_resp_info_len) -{ - int result; - struct wid wid; - - wid.id = WID_ASSOC_RES_INFO; - wid.type = WID_STR; - wid.val = assoc_resp_info; - wid.size = max_assoc_resp_info_len; - - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); - if (result) { - *rcvd_assoc_resp_info_len = 0; - netdev_err(vif->ndev, "Failed to send association response\n"); - return; - } - - *rcvd_assoc_resp_info_len = wid.size; -} - -static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, - struct wilc_conn_info *ret_conn_info) -{ - u8 *ies; - u16 ies_len; - struct assoc_resp *res = (struct assoc_resp *)buffer; - - ret_conn_info->status = le16_to_cpu(res->status_code); - if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { - ies = &buffer[sizeof(*res)]; - ies_len = buffer_len - sizeof(*res); - - ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!ret_conn_info->resp_ies) - return -ENOMEM; - - ret_conn_info->resp_ies_len = ies_len; - } - - return 0; -} - -static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, - u8 mac_status) -{ - struct host_if_drv *hif_drv = vif->hif_drv; - struct wilc_conn_info *conn_info = &hif_drv->conn_info; - - if (mac_status == WILC_MAC_STATUS_CONNECTED) { - u32 assoc_resp_info_len; - - memset(hif_drv->assoc_resp, 0, WILC_MAX_ASSOC_RESP_FRAME_SIZE); - - host_int_get_assoc_res_info(vif, hif_drv->assoc_resp, - WILC_MAX_ASSOC_RESP_FRAME_SIZE, - &assoc_resp_info_len); - - if (assoc_resp_info_len != 0) { - s32 err = 0; - - err = wilc_parse_assoc_resp_info(hif_drv->assoc_resp, - assoc_resp_info_len, - conn_info); - if (err) - netdev_err(vif->ndev, - "wilc_parse_assoc_resp_info() returned error %d\n", - err); - } - } - - del_timer(&hif_drv->connect_timer); - conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status, - hif_drv->conn_info.arg); - - if (mac_status == WILC_MAC_STATUS_CONNECTED && - conn_info->status == WLAN_STATUS_SUCCESS) { - ether_addr_copy(hif_drv->assoc_bssid, conn_info->bssid); - hif_drv->hif_state = HOST_IF_CONNECTED; - } else { - hif_drv->hif_state = HOST_IF_IDLE; - } - - kfree(conn_info->resp_ies); - conn_info->resp_ies = NULL; - conn_info->resp_ies_len = 0; - - kfree(conn_info->req_ies); - conn_info->req_ies = NULL; - conn_info->req_ies_len = 0; -} - -static inline void host_int_handle_disconnect(struct wilc_vif *vif) -{ - struct host_if_drv *hif_drv = vif->hif_drv; - - if (hif_drv->usr_scan_req.scan_result) { - del_timer(&hif_drv->scan_timer); - handle_scan_done(vif, SCAN_EVENT_ABORTED); - } - - if (hif_drv->conn_info.conn_result) - hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, - 0, hif_drv->conn_info.arg); - else - netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); - - eth_zero_addr(hif_drv->assoc_bssid); - - hif_drv->conn_info.req_ies_len = 0; - kfree(hif_drv->conn_info.req_ies); - hif_drv->conn_info.req_ies = NULL; - hif_drv->hif_state = HOST_IF_IDLE; -} - -static void handle_rcvd_gnrl_async_info(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct wilc_rcvd_mac_info *mac_info = &msg->body.mac_info; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); - goto free_msg; - } - - if (!hif_drv->conn_info.conn_result) { - netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); - goto free_msg; - } - - if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { - host_int_parse_assoc_resp_info(vif, mac_info->status); - } else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) { - if (hif_drv->hif_state == HOST_IF_CONNECTED) { - host_int_handle_disconnect(vif); - } else if (hif_drv->usr_scan_req.scan_result) { - del_timer(&hif_drv->scan_timer); - handle_scan_done(vif, SCAN_EVENT_ABORTED); - } - } - -free_msg: - kfree(msg); -} - -int wilc_disconnect(struct wilc_vif *vif) -{ - struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; - struct wilc_user_scan_req *scan_req; - struct wilc_conn_info *conn_info; - int result; - u16 dummy_reason_code = 0; - - wid.id = WID_DISCONNECT; - wid.type = WID_CHAR; - wid.val = (s8 *)&dummy_reason_code; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) { - netdev_err(vif->ndev, "Failed to send disconnect\n"); - return result; - } - - scan_req = &hif_drv->usr_scan_req; - conn_info = &hif_drv->conn_info; - - if (scan_req->scan_result) { - del_timer(&hif_drv->scan_timer); - scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg); - scan_req->scan_result = NULL; - } - - if (conn_info->conn_result) { - if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) - del_timer(&hif_drv->connect_timer); - - conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0, - conn_info->arg); - } else { - netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); - } - - hif_drv->hif_state = HOST_IF_IDLE; - - eth_zero_addr(hif_drv->assoc_bssid); - - conn_info->req_ies_len = 0; - kfree(conn_info->req_ies); - conn_info->req_ies = NULL; - - return 0; -} - -int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) -{ - struct wid wid_list[5]; - u32 wid_cnt = 0, result; - - wid_list[wid_cnt].id = WID_LINKSPEED; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - wid_list[wid_cnt].val = (s8 *)&stats->link_speed; - wid_cnt++; - - wid_list[wid_cnt].id = WID_RSSI; - wid_list[wid_cnt].type = WID_CHAR; - wid_list[wid_cnt].size = sizeof(char); - wid_list[wid_cnt].val = (s8 *)&stats->rssi; - wid_cnt++; - - wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT; - wid_list[wid_cnt].type = WID_INT; - wid_list[wid_cnt].size = sizeof(u32); - wid_list[wid_cnt].val = (s8 *)&stats->tx_cnt; - wid_cnt++; - - wid_list[wid_cnt].id = WID_RECEIVED_FRAGMENT_COUNT; - wid_list[wid_cnt].type = WID_INT; - wid_list[wid_cnt].size = sizeof(u32); - wid_list[wid_cnt].val = (s8 *)&stats->rx_cnt; - wid_cnt++; - - wid_list[wid_cnt].id = WID_FAILED_COUNT; - wid_list[wid_cnt].type = WID_INT; - wid_list[wid_cnt].size = sizeof(u32); - wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt; - wid_cnt++; - - result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt); - if (result) { - netdev_err(vif->ndev, "Failed to send scan parameters\n"); - return result; - } - - if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && - stats->link_speed != DEFAULT_LINK_SPEED) - wilc_enable_tcp_ack_filter(vif, true); - else if (stats->link_speed != DEFAULT_LINK_SPEED) - wilc_enable_tcp_ack_filter(vif, false); - - return result; -} - -static void handle_get_statistics(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct rf_info *stats = (struct rf_info *)msg->body.data; - - wilc_get_statistics(vif, stats); - - kfree(msg); -} - -static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, - struct station_parameters *params) -{ - ether_addr_copy(cur_byte, mac); - cur_byte += ETH_ALEN; - - put_unaligned_le16(params->aid, cur_byte); - cur_byte += 2; - - *cur_byte++ = params->supported_rates_len; - if (params->supported_rates_len > 0) - memcpy(cur_byte, params->supported_rates, - params->supported_rates_len); - cur_byte += params->supported_rates_len; - - if (params->ht_capa) { - *cur_byte++ = true; - memcpy(cur_byte, ¶ms->ht_capa, - sizeof(struct ieee80211_ht_cap)); - } else { - *cur_byte++ = false; - } - cur_byte += sizeof(struct ieee80211_ht_cap); - - put_unaligned_le16(params->sta_flags_mask, cur_byte); - cur_byte += 2; - put_unaligned_le16(params->sta_flags_set, cur_byte); -} - -static int handle_remain_on_chan(struct wilc_vif *vif, - struct wilc_remain_ch *hif_remain_ch) -{ - int result; - u8 remain_on_chan_flag; - struct wid wid; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (hif_drv->usr_scan_req.scan_result) - return -EBUSY; - - if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) - return -EBUSY; - - if (vif->connecting) - return -EBUSY; - - remain_on_chan_flag = true; - wid.id = WID_REMAIN_ON_CHAN; - wid.type = WID_STR; - wid.size = 2; - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - wid.val[0] = remain_on_chan_flag; - wid.val[1] = (s8)hif_remain_ch->ch; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - kfree(wid.val); - if (result) - return -EBUSY; - - hif_drv->remain_on_ch.arg = hif_remain_ch->arg; - hif_drv->remain_on_ch.expired = hif_remain_ch->expired; - hif_drv->remain_on_ch.ch = hif_remain_ch->ch; - hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie; - hif_drv->remain_on_ch_timer_vif = vif; - - return 0; -} - -static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie) -{ - u8 remain_on_chan_flag; - struct wid wid; - int result; - struct host_if_drv *hif_drv = vif->hif_drv; - struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr); - - if (priv->p2p_listen_state) { - remain_on_chan_flag = false; - wid.id = WID_REMAIN_ON_CHAN; - wid.type = WID_STR; - wid.size = 2; - - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - wid.val[0] = remain_on_chan_flag; - wid.val[1] = WILC_FALSE_FRMWR_CHANNEL; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - kfree(wid.val); - if (result != 0) { - netdev_err(vif->ndev, "Failed to set remain channel\n"); - return -EINVAL; - } - - if (hif_drv->remain_on_ch.expired) { - hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg, - cookie); - } - } else { - netdev_dbg(vif->ndev, "Not in listen state\n"); - } - - return 0; -} - -static void wilc_handle_listen_state_expired(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - - wilc_handle_roc_expired(msg->vif, msg->body.remain_on_ch.cookie); - kfree(msg); -} - -static void listen_timer_cb(struct timer_list *t) -{ - struct host_if_drv *hif_drv = from_timer(hif_drv, t, - remain_on_ch_timer); - struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; - int result; - struct host_if_msg *msg; - - del_timer(&vif->hif_drv->remain_on_ch_timer); - - msg = wilc_alloc_work(vif, wilc_handle_listen_state_expired, false); - if (IS_ERR(msg)) - return; - - msg->body.remain_on_ch.cookie = vif->hif_drv->remain_on_ch.cookie; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } -} - -static void handle_set_mcast_filter(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct wilc_set_multicast *set_mc = &msg->body.mc_info; - int result; - struct wid wid; - u8 *cur_byte; - - wid.id = WID_SETUP_MULTICAST_FILTER; - wid.type = WID_BIN; - wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN); - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - goto error; - - cur_byte = wid.val; - put_unaligned_le32(set_mc->enabled, cur_byte); - cur_byte += 4; - - put_unaligned_le32(set_mc->cnt, cur_byte); - cur_byte += 4; - - if (set_mc->cnt > 0 && set_mc->mc_list) - memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send setup multicast\n"); - -error: - kfree(set_mc->mc_list); - kfree(wid.val); - kfree(msg); -} - -static void handle_scan_timer(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - - handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); - kfree(msg); -} - -static void handle_scan_complete(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - - del_timer(&msg->vif->hif_drv->scan_timer); - - handle_scan_done(msg->vif, SCAN_EVENT_DONE); - - kfree(msg); -} - -static void timer_scan_cb(struct timer_list *t) -{ - struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer); - struct wilc_vif *vif = hif_drv->scan_timer_vif; - struct host_if_msg *msg; - int result; - - msg = wilc_alloc_work(vif, handle_scan_timer, false); - if (IS_ERR(msg)) - return; - - result = wilc_enqueue_work(msg); - if (result) - kfree(msg); -} - -static void timer_connect_cb(struct timer_list *t) -{ - struct host_if_drv *hif_drv = from_timer(hif_drv, t, - connect_timer); - struct wilc_vif *vif = hif_drv->connect_timer_vif; - struct host_if_msg *msg; - int result; - - msg = wilc_alloc_work(vif, handle_connect_timeout, false); - if (IS_ERR(msg)) - return; - - result = wilc_enqueue_work(msg); - if (result) - kfree(msg); -} - -int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) -{ - struct wid wid; - int result; - - wid.id = WID_REMOVE_WEP_KEY; - wid.type = WID_STR; - wid.size = sizeof(char); - wid.val = &index; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, - "Failed to send remove wep key config packet\n"); - return result; -} - -int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) -{ - struct wid wid; - int result; - - wid.id = WID_KEY_ID; - wid.type = WID_CHAR; - wid.size = sizeof(char); - wid.val = &index; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, - "Failed to send wep default key config packet\n"); - - return result; -} - -int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, - u8 index) -{ - struct wid wid; - int result; - struct wilc_wep_key *wep_key; - - wid.id = WID_ADD_WEP_KEY; - wid.type = WID_STR; - wid.size = sizeof(*wep_key) + len; - wep_key = kzalloc(wid.size, GFP_KERNEL); - if (!wep_key) - return -ENOMEM; - - wid.val = (u8 *)wep_key; - - wep_key->index = index; - wep_key->key_len = len; - memcpy(wep_key->key, key, len); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, - "Failed to add wep key config packet\n"); - - kfree(wep_key); - return result; -} - -int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, - u8 index, u8 mode, enum authtype auth_type) -{ - struct wid wid_list[3]; - int result; - struct wilc_wep_key *wep_key; - - wid_list[0].id = WID_11I_MODE; - wid_list[0].type = WID_CHAR; - wid_list[0].size = sizeof(char); - wid_list[0].val = &mode; - - wid_list[1].id = WID_AUTH_TYPE; - wid_list[1].type = WID_CHAR; - wid_list[1].size = sizeof(char); - wid_list[1].val = (s8 *)&auth_type; - - wid_list[2].id = WID_WEP_KEY_VALUE; - wid_list[2].type = WID_STR; - wid_list[2].size = sizeof(*wep_key) + len; - wep_key = kzalloc(wid_list[2].size, GFP_KERNEL); - if (!wep_key) - return -ENOMEM; - - wid_list[2].val = (u8 *)wep_key; - - wep_key->index = index; - wep_key->key_len = len; - memcpy(wep_key->key, key, len); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - ARRAY_SIZE(wid_list)); - if (result) - netdev_err(vif->ndev, - "Failed to add wep ap key config packet\n"); - - kfree(wep_key); - return result; -} - -int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, - const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, - u8 mode, u8 cipher_mode, u8 index) -{ - int result = 0; - u8 t_key_len = ptk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; - - if (mode == WILC_AP_MODE) { - struct wid wid_list[2]; - struct wilc_ap_wpa_ptk *key_buf; - - wid_list[0].id = WID_11I_MODE; - wid_list[0].type = WID_CHAR; - wid_list[0].size = sizeof(char); - wid_list[0].val = (s8 *)&cipher_mode; - - key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); - if (!key_buf) - return -ENOMEM; - - ether_addr_copy(key_buf->mac_addr, mac_addr); - key_buf->index = index; - key_buf->key_len = t_key_len; - memcpy(&key_buf->key[0], ptk, ptk_key_len); - - if (rx_mic) - memcpy(&key_buf->key[ptk_key_len], rx_mic, - WILC_RX_MIC_KEY_LEN); - - if (tx_mic) - memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], - tx_mic, WILC_TX_MIC_KEY_LEN); - - wid_list[1].id = WID_ADD_PTK; - wid_list[1].type = WID_STR; - wid_list[1].size = sizeof(*key_buf) + t_key_len; - wid_list[1].val = (u8 *)key_buf; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - ARRAY_SIZE(wid_list)); - kfree(key_buf); - } else if (mode == WILC_STATION_MODE) { - struct wid wid; - struct wilc_sta_wpa_ptk *key_buf; - - key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); - if (!key_buf) - return -ENOMEM; - - ether_addr_copy(key_buf->mac_addr, mac_addr); - key_buf->key_len = t_key_len; - memcpy(&key_buf->key[0], ptk, ptk_key_len); - - if (rx_mic) - memcpy(&key_buf->key[ptk_key_len], rx_mic, - WILC_RX_MIC_KEY_LEN); - - if (tx_mic) - memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], - tx_mic, WILC_TX_MIC_KEY_LEN); - - wid.id = WID_ADD_PTK; - wid.type = WID_STR; - wid.size = sizeof(*key_buf) + t_key_len; - wid.val = (s8 *)key_buf; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - kfree(key_buf); - } - - return result; -} - -int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, - u8 index, u32 key_rsc_len, const u8 *key_rsc, - const u8 *rx_mic, const u8 *tx_mic, u8 mode, - u8 cipher_mode) -{ - int result = 0; - struct wilc_gtk_key *gtk_key; - int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; - - gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL); - if (!gtk_key) - return -ENOMEM; - - /* fill bssid value only in station mode */ - if (mode == WILC_STATION_MODE && - vif->hif_drv->hif_state == HOST_IF_CONNECTED) - memcpy(gtk_key->mac_addr, vif->hif_drv->assoc_bssid, ETH_ALEN); - - if (key_rsc) - memcpy(gtk_key->rsc, key_rsc, 8); - gtk_key->index = index; - gtk_key->key_len = t_key_len; - memcpy(>k_key->key[0], rx_gtk, gtk_key_len); - - if (rx_mic) - memcpy(>k_key->key[gtk_key_len], rx_mic, WILC_RX_MIC_KEY_LEN); - - if (tx_mic) - memcpy(>k_key->key[gtk_key_len + WILC_RX_MIC_KEY_LEN], - tx_mic, WILC_TX_MIC_KEY_LEN); - - if (mode == WILC_AP_MODE) { - struct wid wid_list[2]; - - wid_list[0].id = WID_11I_MODE; - wid_list[0].type = WID_CHAR; - wid_list[0].size = sizeof(char); - wid_list[0].val = (s8 *)&cipher_mode; - - wid_list[1].id = WID_ADD_RX_GTK; - wid_list[1].type = WID_STR; - wid_list[1].size = sizeof(*gtk_key) + t_key_len; - wid_list[1].val = (u8 *)gtk_key; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - ARRAY_SIZE(wid_list)); - } else if (mode == WILC_STATION_MODE) { - struct wid wid; - - wid.id = WID_ADD_RX_GTK; - wid.type = WID_STR; - wid.size = sizeof(*gtk_key) + t_key_len; - wid.val = (u8 *)gtk_key; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - } - - kfree(gtk_key); - return result; -} - -int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) -{ - struct wid wid; - - wid.id = WID_PMKID_INFO; - wid.type = WID_STR; - wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1; - wid.val = (u8 *)pmkid; - - return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); -} - -int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) -{ - int result; - struct wid wid; - - wid.id = WID_MAC_ADDR; - wid.type = WID_STR; - wid.size = ETH_ALEN; - wid.val = mac_addr; - - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to get mac address\n"); - - return result; -} - -int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, - size_t ies_len) -{ - int result; - struct host_if_drv *hif_drv = vif->hif_drv; - struct wilc_conn_info *conn_info = &hif_drv->conn_info; - - if (bssid) - ether_addr_copy(conn_info->bssid, bssid); - - if (ies) { - conn_info->req_ies_len = ies_len; - conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!conn_info->req_ies) - return -ENOMEM; - } - - result = wilc_send_connect_wid(vif); - if (result) - goto free_ies; - - hif_drv->connect_timer_vif = vif; - mod_timer(&hif_drv->connect_timer, - jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS)); - - return 0; - -free_ies: - kfree(conn_info->req_ies); - - return result; -} - -int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) -{ - struct wid wid; - int result; - - wid.id = WID_CURRENT_CHANNEL; - wid.type = WID_CHAR; - wid.size = sizeof(char); - wid.val = &channel; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to set channel\n"); - - return result; -} - -int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode, - u8 ifc_id) -{ - struct wid wid; - int result; - struct wilc_drv_handler drv; - - wid.id = WID_SET_OPERATION_MODE; - wid.type = WID_STR; - wid.size = sizeof(drv); - wid.val = (u8 *)&drv; - - drv.handler = cpu_to_le32(index); - drv.mode = (ifc_id | (mode << 1)); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to set driver handler\n"); - - return result; -} - -s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) -{ - struct wid wid; - s32 result; - - wid.id = WID_SET_STA_MAC_INACTIVE_TIME; - wid.type = WID_STR; - wid.size = ETH_ALEN; - wid.val = kzalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - ether_addr_copy(wid.val, mac); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - kfree(wid.val); - if (result) { - netdev_err(vif->ndev, "Failed to set inactive mac\n"); - return result; - } - - wid.id = WID_GET_INACTIVE_TIME; - wid.type = WID_INT; - wid.val = (s8 *)out_val; - wid.size = sizeof(u32); - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to get inactive time\n"); - - return result; -} - -int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) -{ - struct wid wid; - int result; - - if (!rssi_level) { - netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__); - return -EFAULT; - } - - wid.id = WID_RSSI; - wid.type = WID_CHAR; - wid.size = sizeof(char); - wid.val = rssi_level; - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to get RSSI value\n"); - - return result; -} - -static int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats) -{ - int result; - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_get_statistics, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.data = (char *)stats; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - return result; - } - - return result; -} - -int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) -{ - struct wid wid_list[4]; - int i = 0; - - if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { - wid_list[i].id = WID_SHORT_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->short_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { - wid_list[i].id = WID_LONG_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->long_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { - wid_list[i].id = WID_FRAG_THRESHOLD; - wid_list[i].val = (s8 *)¶m->frag_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { - wid_list[i].id = WID_RTS_THRESHOLD; - wid_list[i].val = (s8 *)¶m->rts_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - - return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i); -} - -static void get_periodic_rssi(struct timer_list *t) -{ - struct wilc_vif *vif = from_timer(vif, t, periodic_rssi); - - if (!vif->hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return; - } - - if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) - wilc_get_stats_async(vif, &vif->periodic_stat); - - mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); -} - -int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) -{ - struct host_if_drv *hif_drv; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); - if (!hif_drv) - return -ENOMEM; - - *hif_drv_handler = hif_drv; - - vif->hif_drv = hif_drv; - - if (wilc->clients_count == 0) - mutex_init(&wilc->deinit_lock); - - timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0); - mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); - - timer_setup(&hif_drv->scan_timer, timer_scan_cb, 0); - timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0); - timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0); - - hif_drv->hif_state = HOST_IF_IDLE; - - hif_drv->p2p_timeout = 0; - - wilc->clients_count++; - - return 0; -} - -int wilc_deinit(struct wilc_vif *vif) -{ - int result = 0; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } - - mutex_lock(&vif->wilc->deinit_lock); - - del_timer_sync(&hif_drv->scan_timer); - del_timer_sync(&hif_drv->connect_timer); - del_timer_sync(&vif->periodic_rssi); - del_timer_sync(&hif_drv->remain_on_ch_timer); - - if (hif_drv->usr_scan_req.scan_result) { - hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, - hif_drv->usr_scan_req.arg); - hif_drv->usr_scan_req.scan_result = NULL; - } - - hif_drv->hif_state = HOST_IF_IDLE; - - kfree(hif_drv); - vif->hif_drv = NULL; - vif->wilc->clients_count--; - mutex_unlock(&vif->wilc->deinit_lock); - return result; -} - -void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) -{ - int result; - struct host_if_msg *msg; - int id; - struct host_if_drv *hif_drv; - struct wilc_vif *vif; - - id = get_unaligned_le32(&buffer[length - 4]); - vif = wilc_get_vif_from_idx(wilc, id); - if (!vif) - return; - hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); - return; - } - - msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false); - if (IS_ERR(msg)) - return; - - msg->body.net_info.frame_len = get_unaligned_le16(&buffer[6]) - 1; - msg->body.net_info.rssi = buffer[8]; - msg->body.net_info.mgmt = kmemdup(&buffer[9], - msg->body.net_info.frame_len, - GFP_KERNEL); - if (!msg->body.net_info.mgmt) { - kfree(msg); - return; - } - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg->body.net_info.mgmt); - kfree(msg); - } -} - -void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) -{ - int result; - struct host_if_msg *msg; - int id; - struct host_if_drv *hif_drv; - struct wilc_vif *vif; - - mutex_lock(&wilc->deinit_lock); - - id = get_unaligned_le32(&buffer[length - 4]); - vif = wilc_get_vif_from_idx(wilc, id); - if (!vif) { - mutex_unlock(&wilc->deinit_lock); - return; - } - - hif_drv = vif->hif_drv; - - if (!hif_drv) { - mutex_unlock(&wilc->deinit_lock); - return; - } - - if (!hif_drv->conn_info.conn_result) { - netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); - mutex_unlock(&wilc->deinit_lock); - return; - } - - msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false); - if (IS_ERR(msg)) { - mutex_unlock(&wilc->deinit_lock); - return; - } - - msg->body.mac_info.status = buffer[7]; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } - - mutex_unlock(&wilc->deinit_lock); -} - -void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) -{ - int result; - int id; - struct host_if_drv *hif_drv; - struct wilc_vif *vif; - - id = get_unaligned_le32(&buffer[length - 4]); - vif = wilc_get_vif_from_idx(wilc, id); - if (!vif) - return; - hif_drv = vif->hif_drv; - - if (!hif_drv) - return; - - if (hif_drv->usr_scan_req.scan_result) { - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_scan_complete, false); - if (IS_ERR(msg)) - return; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", - __func__); - kfree(msg); - } - } -} - -int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, - u32 duration, u16 chan, - void (*expired)(void *, u64), - void *user_arg) -{ - struct wilc_remain_ch roc; - int result; - - roc.ch = chan; - roc.expired = expired; - roc.arg = user_arg; - roc.duration = duration; - roc.cookie = cookie; - result = handle_remain_on_chan(vif, &roc); - if (result) - netdev_err(vif->ndev, "%s: failed to set remain on channel\n", - __func__); - - return result; -} - -int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie) -{ - if (!vif->hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } - - del_timer(&vif->hif_drv->remain_on_ch_timer); - - return wilc_handle_roc_expired(vif, cookie); -} - -void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) -{ - struct wid wid; - int result; - struct wilc_reg_frame reg_frame; - - wid.id = WID_REGISTER_FRAME; - wid.type = WID_STR; - wid.size = sizeof(reg_frame); - wid.val = (u8 *)®_frame; - - memset(®_frame, 0x0, sizeof(reg_frame)); - - if (reg) - reg_frame.reg = 1; - - switch (frame_type) { - case IEEE80211_STYPE_ACTION: - reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; - break; - - case IEEE80211_STYPE_PROBE_REQ: - reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; - break; - - default: - break; - } - reg_frame.frame_type = cpu_to_le16(frame_type); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to frame register\n"); -} - -int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, - struct cfg80211_beacon_data *params) -{ - struct wid wid; - int result; - u8 *cur_byte; - - wid.id = WID_ADD_BEACON; - wid.type = WID_BIN; - wid.size = params->head_len + params->tail_len + 16; - wid.val = kzalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - cur_byte = wid.val; - put_unaligned_le32(interval, cur_byte); - cur_byte += 4; - put_unaligned_le32(dtim_period, cur_byte); - cur_byte += 4; - put_unaligned_le32(params->head_len, cur_byte); - cur_byte += 4; - - if (params->head_len > 0) - memcpy(cur_byte, params->head, params->head_len); - cur_byte += params->head_len; - - put_unaligned_le32(params->tail_len, cur_byte); - cur_byte += 4; - - if (params->tail_len > 0) - memcpy(cur_byte, params->tail, params->tail_len); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send add beacon\n"); - - kfree(wid.val); - - return result; -} - -int wilc_del_beacon(struct wilc_vif *vif) -{ - int result; - struct wid wid; - u8 del_beacon = 0; - - wid.id = WID_DEL_BEACON; - wid.type = WID_CHAR; - wid.size = sizeof(char); - wid.val = &del_beacon; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send delete beacon\n"); - - return result; -} - -int wilc_add_station(struct wilc_vif *vif, const u8 *mac, - struct station_parameters *params) -{ - struct wid wid; - int result; - u8 *cur_byte; - - wid.id = WID_ADD_STA; - wid.type = WID_BIN; - wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - cur_byte = wid.val; - wilc_hif_pack_sta_param(cur_byte, mac, params); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result != 0) - netdev_err(vif->ndev, "Failed to send add station\n"); - - kfree(wid.val); - - return result; -} - -int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) -{ - struct wid wid; - int result; - - wid.id = WID_REMOVE_STA; - wid.type = WID_BIN; - wid.size = ETH_ALEN; - wid.val = kzalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - if (!mac_addr) - eth_broadcast_addr(wid.val); - else - ether_addr_copy(wid.val, mac_addr); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to del station\n"); - - kfree(wid.val); - - return result; -} - -int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) -{ - struct wid wid; - int result; - int i; - u8 assoc_sta = 0; - struct wilc_del_all_sta del_sta; - - memset(&del_sta, 0x0, sizeof(del_sta)); - for (i = 0; i < WILC_MAX_NUM_STA; i++) { - if (!is_zero_ether_addr(mac_addr[i])) { - assoc_sta++; - ether_addr_copy(del_sta.mac[i], mac_addr[i]); - } - } - - if (!assoc_sta) - return 0; - - del_sta.assoc_sta = assoc_sta; - - wid.id = WID_DEL_ALL_STA; - wid.type = WID_STR; - wid.size = (assoc_sta * ETH_ALEN) + 1; - wid.val = (u8 *)&del_sta; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send delete all station\n"); - - return result; -} - -int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, - struct station_parameters *params) -{ - struct wid wid; - int result; - u8 *cur_byte; - - wid.id = WID_EDIT_STA; - wid.type = WID_BIN; - wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - return -ENOMEM; - - cur_byte = wid.val; - wilc_hif_pack_sta_param(cur_byte, mac, params); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send edit station\n"); - - kfree(wid.val); - return result; -} - -int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) -{ - struct wid wid; - int result; - s8 power_mode; - - if (enabled) - power_mode = WILC_FW_MIN_FAST_PS; - else - power_mode = WILC_FW_NO_POWERSAVE; - - wid.id = WID_POWER_MANAGEMENT; - wid.val = &power_mode; - wid.size = sizeof(char); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); - if (result) - netdev_err(vif->ndev, "Failed to send power management\n"); - - return result; -} - -int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count, - u8 *mc_list) -{ - int result; - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_set_mcast_filter, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.mc_info.enabled = enabled; - msg->body.mc_info.cnt = count; - msg->body.mc_info.mc_list = mc_list; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } - return result; -} - -int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) -{ - struct wid wid; - - wid.id = WID_TX_POWER; - wid.type = WID_CHAR; - wid.val = &tx_power; - wid.size = sizeof(char); - - return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); -} - -int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) -{ - struct wid wid; - - wid.id = WID_TX_POWER; - wid.type = WID_CHAR; - wid.val = tx_power; - wid.size = sizeof(char); - - return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); -} diff --git a/drivers/staging/wilc1000/wilc_hif.h b/drivers/staging/wilc1000/wilc_hif.h deleted file mode 100644 index ac5fe57f872b..000000000000 --- a/drivers/staging/wilc1000/wilc_hif.h +++ /dev/null @@ -1,233 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries - * All rights reserved. - */ - -#ifndef HOST_INT_H -#define HOST_INT_H -#include -#include "wilc_wlan_if.h" - -enum { - WILC_IDLE_MODE = 0x0, - WILC_AP_MODE = 0x1, - WILC_STATION_MODE = 0x2, - WILC_GO_MODE = 0x3, - WILC_CLIENT_MODE = 0x4 -}; - -#define WILC_MAX_NUM_STA 9 -#define WILC_MAX_NUM_SCANNED_CH 14 -#define WILC_MAX_NUM_PROBED_SSID 10 - -#define WILC_TX_MIC_KEY_LEN 8 -#define WILC_RX_MIC_KEY_LEN 8 - -#define WILC_MAX_NUM_PMKIDS 16 -#define WILC_ADD_STA_LENGTH 40 -#define WILC_NUM_CONCURRENT_IFC 2 - -enum { - WILC_SET_CFG = 0, - WILC_GET_CFG -}; - -#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256 - -struct assoc_resp { - __le16 capab_info; - __le16 status_code; - __le16 aid; -} __packed; - -struct rf_info { - u8 link_speed; - s8 rssi; - u32 tx_cnt; - u32 rx_cnt; - u32 tx_fail_cnt; -}; - -enum host_if_state { - HOST_IF_IDLE = 0, - HOST_IF_SCANNING = 1, - HOST_IF_CONNECTING = 2, - HOST_IF_WAITING_CONN_RESP = 3, - HOST_IF_CONNECTED = 4, - HOST_IF_P2P_LISTEN = 5, - HOST_IF_FORCE_32BIT = 0xFFFFFFFF -}; - -struct wilc_pmkid { - u8 bssid[ETH_ALEN]; - u8 pmkid[WLAN_PMKID_LEN]; -} __packed; - -struct wilc_pmkid_attr { - u8 numpmkid; - struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; -} __packed; - -struct cfg_param_attr { - u32 flag; - u16 short_retry_limit; - u16 long_retry_limit; - u16 frag_threshold; - u16 rts_threshold; -}; - -enum cfg_param { - WILC_CFG_PARAM_RETRY_SHORT = BIT(0), - WILC_CFG_PARAM_RETRY_LONG = BIT(1), - WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2), - WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3) -}; - -enum scan_event { - SCAN_EVENT_NETWORK_FOUND = 0, - SCAN_EVENT_DONE = 1, - SCAN_EVENT_ABORTED = 2, - SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF -}; - -enum conn_event { - CONN_DISCONN_EVENT_CONN_RESP = 0, - CONN_DISCONN_EVENT_DISCONN_NOTIF = 1, - CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF -}; - -enum { - WILC_HIF_SDIO = 0, - WILC_HIF_SPI = BIT(0) -}; - -enum { - WILC_MAC_STATUS_INIT = -1, - WILC_MAC_STATUS_DISCONNECTED = 0, - WILC_MAC_STATUS_CONNECTED = 1 -}; - -struct wilc_rcvd_net_info { - s8 rssi; - u8 ch; - u16 frame_len; - struct ieee80211_mgmt *mgmt; -}; - -struct wilc_user_scan_req { - void (*scan_result)(enum scan_event evt, - struct wilc_rcvd_net_info *info, void *priv); - void *arg; - u32 ch_cnt; -}; - -struct wilc_conn_info { - u8 bssid[ETH_ALEN]; - u8 security; - enum authtype auth_type; - u8 ch; - u8 *req_ies; - size_t req_ies_len; - u8 *resp_ies; - u16 resp_ies_len; - u16 status; - void (*conn_result)(enum conn_event evt, u8 status, void *priv_data); - void *arg; - void *param; -}; - -struct wilc_remain_ch { - u16 ch; - u32 duration; - void (*expired)(void *priv, u64 cookie); - void *arg; - u32 cookie; -}; - -struct wilc; -struct host_if_drv { - struct wilc_user_scan_req usr_scan_req; - struct wilc_conn_info conn_info; - struct wilc_remain_ch remain_on_ch; - u64 p2p_timeout; - - enum host_if_state hif_state; - - u8 assoc_bssid[ETH_ALEN]; - - struct timer_list scan_timer; - struct wilc_vif *scan_timer_vif; - - struct timer_list connect_timer; - struct wilc_vif *connect_timer_vif; - - struct timer_list remain_on_ch_timer; - struct wilc_vif *remain_on_ch_timer_vif; - - bool ifc_up; - u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE]; -}; - -struct wilc_vif; -int wilc_remove_wep_key(struct wilc_vif *vif, u8 index); -int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index); -int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, - u8 index); -int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, - u8 index, u8 mode, enum authtype auth_type); -int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, - const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, - u8 mode, u8 cipher_mode, u8 index); -s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, - u32 *out_val); -int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, - u8 index, u32 key_rsc_len, const u8 *key_rsc, - const u8 *rx_mic, const u8 *tx_mic, u8 mode, - u8 cipher_mode); -int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid); -int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr); -int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, - size_t ies_len); -int wilc_disconnect(struct wilc_vif *vif); -int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel); -int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level); -int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, - u8 *ch_freq_list, u8 ch_list_len, - void (*scan_result_fn)(enum scan_event, - struct wilc_rcvd_net_info *, void *), - void *user_arg, struct cfg80211_scan_request *request); -int wilc_hif_set_cfg(struct wilc_vif *vif, - struct cfg_param_attr *cfg_param); -int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); -int wilc_deinit(struct wilc_vif *vif); -int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, - struct cfg80211_beacon_data *params); -int wilc_del_beacon(struct wilc_vif *vif); -int wilc_add_station(struct wilc_vif *vif, const u8 *mac, - struct station_parameters *params); -int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]); -int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr); -int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, - struct station_parameters *params); -int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout); -int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count, - u8 *mc_list); -int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, - u32 duration, u16 chan, - void (*expired)(void *, u64), - void *user_arg); -int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie); -void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg); -int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode, - u8 ifc_id); -int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats); -int wilc_get_vif_idx(struct wilc_vif *vif); -int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); -int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power); -void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); -void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); -void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); -void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, - struct cfg80211_crypto_settings *crypto); -#endif diff --git a/drivers/staging/wilc1000/wilc_mon.c b/drivers/staging/wilc1000/wilc_mon.c deleted file mode 100644 index d6f14f69ad64..000000000000 --- a/drivers/staging/wilc1000/wilc_mon.c +++ /dev/null @@ -1,260 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include "wilc_wfi_cfgoperations.h" - -struct wilc_wfi_radiotap_hdr { - struct ieee80211_radiotap_header hdr; - u8 rate; -} __packed; - -struct wilc_wfi_radiotap_cb_hdr { - struct ieee80211_radiotap_header hdr; - u8 rate; - u8 dump; - u16 tx_flags; -} __packed; - -#define TX_RADIOTAP_PRESENT ((1 << IEEE80211_RADIOTAP_RATE) | \ - (1 << IEEE80211_RADIOTAP_TX_FLAGS)) - -void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size) -{ - u32 header, pkt_offset; - struct sk_buff *skb = NULL; - struct wilc_wfi_radiotap_hdr *hdr; - struct wilc_wfi_radiotap_cb_hdr *cb_hdr; - - if (!mon_dev) - return; - - if (!netif_running(mon_dev)) - return; - - /* Get WILC header */ - header = get_unaligned_le32(buff - HOST_HDR_OFFSET); - /* - * The packet offset field contain info about what type of management - * the frame we are dealing with and ack status - */ - pkt_offset = GET_PKT_OFFSET(header); - - if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { - /* hostapd callback mgmt frame */ - - skb = dev_alloc_skb(size + sizeof(*cb_hdr)); - if (!skb) - return; - - skb_put_data(skb, buff, size); - - cb_hdr = skb_push(skb, sizeof(*cb_hdr)); - memset(cb_hdr, 0, sizeof(*cb_hdr)); - - cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ - - cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr)); - - cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT); - - cb_hdr->rate = 5; - - if (pkt_offset & IS_MGMT_STATUS_SUCCES) { - /* success */ - cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS; - } else { - cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL; - } - - } else { - skb = dev_alloc_skb(size + sizeof(*hdr)); - - if (!skb) - return; - - skb_put_data(skb, buff, size); - hdr = skb_push(skb, sizeof(*hdr)); - memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr)); - hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ - hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); - hdr->hdr.it_present = cpu_to_le32 - (1 << IEEE80211_RADIOTAP_RATE); - hdr->rate = 5; - } - - skb->dev = mon_dev; - skb_reset_mac_header(skb); - skb->ip_summed = CHECKSUM_UNNECESSARY; - skb->pkt_type = PACKET_OTHERHOST; - skb->protocol = htons(ETH_P_802_2); - memset(skb->cb, 0, sizeof(skb->cb)); - - netif_rx(skb); -} - -struct tx_complete_mon_data { - int size; - void *buff; -}; - -static void mgmt_tx_complete(void *priv, int status) -{ - struct tx_complete_mon_data *pv_data = priv; - /* - * in case of fully hosting mode, the freeing will be done - * in response to the cfg packet - */ - kfree(pv_data->buff); - - kfree(pv_data); -} - -static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) -{ - struct tx_complete_mon_data *mgmt_tx = NULL; - - if (!dev) - return -EFAULT; - - netif_stop_queue(dev); - mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC); - if (!mgmt_tx) - return -ENOMEM; - - mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC); - if (!mgmt_tx->buff) { - kfree(mgmt_tx); - return -ENOMEM; - } - - mgmt_tx->size = len; - - wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size, - mgmt_tx_complete); - - netif_wake_queue(dev); - return 0; -} - -static netdev_tx_t wilc_wfi_mon_xmit(struct sk_buff *skb, - struct net_device *dev) -{ - u32 rtap_len, ret = 0; - struct wilc_wfi_mon_priv *mon_priv; - struct sk_buff *skb2; - struct wilc_wfi_radiotap_cb_hdr *cb_hdr; - u8 srcadd[ETH_ALEN]; - u8 bssid[ETH_ALEN]; - - mon_priv = netdev_priv(dev); - if (!mon_priv) - return -EFAULT; - - rtap_len = ieee80211_get_radiotap_len(skb->data); - if (skb->len < rtap_len) - return -1; - - skb_pull(skb, rtap_len); - - if (skb->data[0] == 0xc0 && is_broadcast_ether_addr(&skb->data[4])) { - skb2 = dev_alloc_skb(skb->len + sizeof(*cb_hdr)); - if (!skb2) - return -ENOMEM; - - skb_put_data(skb2, skb->data, skb->len); - - cb_hdr = skb_push(skb2, sizeof(*cb_hdr)); - memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr)); - - cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */ - - cb_hdr->hdr.it_len = cpu_to_le16(sizeof(*cb_hdr)); - - cb_hdr->hdr.it_present = cpu_to_le32(TX_RADIOTAP_PRESENT); - - cb_hdr->rate = 5; - cb_hdr->tx_flags = 0x0004; - - skb2->dev = dev; - skb_reset_mac_header(skb2); - skb2->ip_summed = CHECKSUM_UNNECESSARY; - skb2->pkt_type = PACKET_OTHERHOST; - skb2->protocol = htons(ETH_P_802_2); - memset(skb2->cb, 0, sizeof(skb2->cb)); - - netif_rx(skb2); - - return 0; - } - skb->dev = mon_priv->real_ndev; - - ether_addr_copy(srcadd, &skb->data[10]); - ether_addr_copy(bssid, &skb->data[16]); - /* - * Identify if data or mgmt packet, if source address and bssid - * fields are equal send it to mgmt frames handler - */ - if (!(memcmp(srcadd, bssid, 6))) { - ret = mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len); - if (ret) - netdev_err(dev, "fail to mgmt tx\n"); - dev_kfree_skb(skb); - } else { - ret = wilc_mac_xmit(skb, mon_priv->real_ndev); - } - - return ret; -} - -static const struct net_device_ops wilc_wfi_netdev_ops = { - .ndo_start_xmit = wilc_wfi_mon_xmit, - -}; - -struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, - const char *name, - struct net_device *real_dev) -{ - struct wilc_wfi_mon_priv *priv; - - /*If monitor interface is already initialized, return it*/ - if (wl->monitor_dev) - return wl->monitor_dev; - - wl->monitor_dev = alloc_etherdev(sizeof(struct wilc_wfi_mon_priv)); - if (!wl->monitor_dev) - return NULL; - - wl->monitor_dev->type = ARPHRD_IEEE80211_RADIOTAP; - strncpy(wl->monitor_dev->name, name, IFNAMSIZ); - wl->monitor_dev->name[IFNAMSIZ - 1] = 0; - wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops; - wl->monitor_dev->needs_free_netdev = true; - - if (register_netdevice(wl->monitor_dev)) { - netdev_err(real_dev, "register_netdevice failed\n"); - return NULL; - } - priv = netdev_priv(wl->monitor_dev); - if (!priv) - return NULL; - - priv->real_ndev = real_dev; - - return wl->monitor_dev; -} - -void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked) -{ - if (!wl->monitor_dev) - return; - - if (rtnl_locked) - unregister_netdevice(wl->monitor_dev); - else - unregister_netdev(wl->monitor_dev); - wl->monitor_dev = NULL; -} diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c deleted file mode 100644 index 2bc7e5427fa8..000000000000 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ /dev/null @@ -1,955 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include -#include -#include -#include -#include - -#include "wilc_wfi_cfgoperations.h" -#include "wilc_wlan_cfg.h" - -#define WILC_MULTICAST_TABLE_SIZE 8 - -static irqreturn_t isr_uh_routine(int irq, void *user_data) -{ - struct net_device *dev = user_data; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - if (wilc->close) { - netdev_err(dev, "Can't handle UH interrupt\n"); - return IRQ_HANDLED; - } - return IRQ_WAKE_THREAD; -} - -static irqreturn_t isr_bh_routine(int irq, void *userdata) -{ - struct net_device *dev = userdata; - struct wilc_vif *vif = netdev_priv(userdata); - struct wilc *wilc = vif->wilc; - - if (wilc->close) { - netdev_err(dev, "Can't handle BH interrupt\n"); - return IRQ_HANDLED; - } - - wilc_handle_isr(wilc); - - return IRQ_HANDLED; -} - -static int init_irq(struct net_device *dev) -{ - int ret = 0; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; - - ret = gpiod_direction_input(wl->gpio_irq); - if (ret) { - netdev_err(dev, "could not obtain gpio for WILC_INTR\n"); - return ret; - } - - wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq); - - ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine, - isr_bh_routine, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "WILC_IRQ", dev); - if (ret < 0) - netdev_err(dev, "Failed to request IRQ\n"); - else - netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", - wl->dev_irq_num); - - return ret; -} - -static void deinit_irq(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - /* Deinitialize IRQ */ - if (wilc->dev_irq_num) - free_irq(wilc->dev_irq_num, wilc); -} - -void wilc_mac_indicate(struct wilc *wilc) -{ - s8 status; - - wilc_wlan_cfg_get_val(wilc, WID_STATUS, &status, 1); - if (wilc->mac_status == WILC_MAC_STATUS_INIT) { - wilc->mac_status = status; - complete(&wilc->sync_event); - } else { - wilc->mac_status = status; - } -} - -static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) -{ - u8 *bssid, *bssid1; - struct net_device *ndev = NULL; - struct wilc_vif *vif; - - bssid = mac_header + 10; - bssid1 = mac_header + 4; - - list_for_each_entry_rcu(vif, &wilc->vif_list, list) { - if (vif->mode == WILC_STATION_MODE) - if (ether_addr_equal_unaligned(bssid, vif->bssid)) { - ndev = vif->ndev; - goto out; - } - if (vif->mode == WILC_AP_MODE) - if (ether_addr_equal_unaligned(bssid1, vif->bssid)) { - ndev = vif->ndev; - goto out; - } - } -out: - return ndev; -} - -void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) -{ - struct wilc_vif *vif = netdev_priv(wilc_netdev); - - if (bssid) - ether_addr_copy(vif->bssid, bssid); - else - eth_zero_addr(vif->bssid); - - vif->mode = mode; -} - -int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) -{ - int srcu_idx; - u8 ret_val = 0; - struct wilc_vif *vif; - - srcu_idx = srcu_read_lock(&wilc->srcu); - list_for_each_entry_rcu(vif, &wilc->vif_list, list) { - if (!is_zero_ether_addr(vif->bssid)) - ret_val++; - } - srcu_read_unlock(&wilc->srcu, srcu_idx); - return ret_val; -} - -static int wilc_txq_task(void *vp) -{ - int ret; - u32 txq_count; - struct wilc *wl = vp; - - complete(&wl->txq_thread_started); - while (1) { - wait_for_completion(&wl->txq_event); - - if (wl->close) { - complete(&wl->txq_thread_started); - - while (!kthread_should_stop()) - schedule(); - break; - } - do { - ret = wilc_wlan_handle_txq(wl, &txq_count); - if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) { - int srcu_idx; - struct wilc_vif *ifc; - - srcu_idx = srcu_read_lock(&wl->srcu); - list_for_each_entry_rcu(ifc, &wl->vif_list, - list) { - if (ifc->mac_opened && ifc->ndev) - netif_wake_queue(ifc->ndev); - } - srcu_read_unlock(&wl->srcu, srcu_idx); - } - } while (ret == -ENOBUFS && !wl->close); - } - return 0; -} - -static int wilc_wlan_get_firmware(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - int chip_id, ret = 0; - const struct firmware *wilc_firmware; - char *firmware; - - chip_id = wilc_get_chipid(wilc, false); - - if (chip_id < 0x1003a0) - firmware = FIRMWARE_1002; - else - firmware = FIRMWARE_1003; - - netdev_info(dev, "loading firmware %s\n", firmware); - - if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) { - netdev_err(dev, "%s - firmware not available\n", firmware); - ret = -1; - goto fail; - } - wilc->firmware = wilc_firmware; - -fail: - - return ret; -} - -static int wilc_start_firmware(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - int ret = 0; - - ret = wilc_wlan_start(wilc); - if (ret < 0) - return ret; - - if (!wait_for_completion_timeout(&wilc->sync_event, - msecs_to_jiffies(5000))) - return -ETIME; - - return 0; -} - -static int wilc1000_firmware_download(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - int ret = 0; - - if (!wilc->firmware) { - netdev_err(dev, "Firmware buffer is NULL\n"); - return -ENOBUFS; - } - - ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data, - wilc->firmware->size); - if (ret < 0) - return ret; - - release_firmware(wilc->firmware); - wilc->firmware = NULL; - - netdev_dbg(dev, "Download Succeeded\n"); - - return 0; -} - -static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif) -{ - struct wilc_priv *priv = &vif->priv; - struct host_if_drv *hif_drv; - u8 b; - u16 hw; - u32 w; - - netdev_dbg(dev, "Start configuring Firmware\n"); - hif_drv = (struct host_if_drv *)priv->hif_drv; - netdev_dbg(dev, "Host = %p\n", hif_drv); - - w = vif->iftype; - cpu_to_le32s(&w); - if (!wilc_wlan_cfg_set(vif, 1, WID_SET_OPERATION_MODE, (u8 *)&w, 4, - 0, 0)) - goto fail; - - b = WILC_FW_BSS_TYPE_INFRA; - if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_TX_RATE_AUTO; - if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_OPER_MODE_G_MIXED_11B_2; - if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_PREAMBLE_SHORT; - if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_11N_PROT_AUTO; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_ACTIVE_SCAN; - if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_SITE_SURVEY_OFF; - if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, &b, 1, 0, 0)) - goto fail; - - hw = 0xffff; - cpu_to_le16s(&hw); - if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, (u8 *)&hw, 2, 0, 0)) - goto fail; - - hw = 2346; - cpu_to_le16s(&hw); - if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, (u8 *)&hw, 2, 0, 0)) - goto fail; - - b = 0; - if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, &b, 1, 0, 0)) - goto fail; - - b = 1; - if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_NO_POWERSAVE; - if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_SEC_NO; - if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_AUTH_OPEN_SYSTEM; - if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, &b, 1, 0, 0)) - goto fail; - - b = 3; - if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, &b, 1, 0, 0)) - goto fail; - - b = 3; - if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_ACK_POLICY_NORMAL; - if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, &b, 1, 0, 0)) - goto fail; - - b = 0; - if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, &b, 1, - 0, 0)) - goto fail; - - b = 48; - if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, &b, 1, 0, 0)) - goto fail; - - b = 28; - if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, &b, 1, 0, 0)) - goto fail; - - hw = 100; - cpu_to_le16s(&hw); - if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, (u8 *)&hw, 2, 0, 0)) - goto fail; - - b = WILC_FW_REKEY_POLICY_DISABLE; - if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, &b, 1, 0, 0)) - goto fail; - - w = 84600; - cpu_to_le32s(&w); - if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, (u8 *)&w, 4, 0, 0)) - goto fail; - - w = 500; - cpu_to_le32s(&w); - if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, (u8 *)&w, 4, 0, - 0)) - goto fail; - - b = 1; - if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, &b, 1, 0, - 0)) - goto fail; - - b = WILC_FW_ERP_PROT_SELF_CTS; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, &b, 1, 0, 0)) - goto fail; - - b = 1; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_11N_OP_MODE_HT_MIXED; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, &b, 1, 0, 0)) - goto fail; - - b = 1; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, &b, 1, 0, 0)) - goto fail; - - b = WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, &b, 1, - 0, 0)) - goto fail; - - b = WILC_FW_HT_PROT_RTS_CTS_NONHT; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, &b, 1, 0, 0)) - goto fail; - - b = 0; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, &b, 1, 0, - 0)) - goto fail; - - b = 7; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, &b, 1, 0, 0)) - goto fail; - - b = 1; - if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, &b, 1, - 1, 1)) - goto fail; - - return 0; - -fail: - return -1; -} - -static void wlan_deinitialize_threads(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; - - wl->close = 1; - - complete(&wl->txq_event); - - if (wl->txq_thread) { - kthread_stop(wl->txq_thread); - wl->txq_thread = NULL; - } -} - -static void wilc_wlan_deinitialize(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; - - if (!wl) { - netdev_err(dev, "wl is NULL\n"); - return; - } - - if (wl->initialized) { - netdev_info(dev, "Deinitializing wilc1000...\n"); - - if (!wl->dev_irq_num && - wl->hif_func->disable_interrupt) { - mutex_lock(&wl->hif_cs); - wl->hif_func->disable_interrupt(wl); - mutex_unlock(&wl->hif_cs); - } - complete(&wl->txq_event); - - wlan_deinitialize_threads(dev); - deinit_irq(dev); - - wilc_wlan_stop(wl, vif); - wilc_wlan_cleanup(dev); - - wl->initialized = false; - - netdev_dbg(dev, "wilc1000 deinitialization Done\n"); - } else { - netdev_dbg(dev, "wilc1000 is not initialized\n"); - } -} - -static int wlan_initialize_threads(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - wilc->txq_thread = kthread_run(wilc_txq_task, (void *)wilc, - "K_TXQ_TASK"); - if (IS_ERR(wilc->txq_thread)) { - netdev_err(dev, "couldn't create TXQ thread\n"); - wilc->close = 0; - return PTR_ERR(wilc->txq_thread); - } - wait_for_completion(&wilc->txq_thread_started); - - return 0; -} - -static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) -{ - int ret = 0; - struct wilc *wl = vif->wilc; - - if (!wl->initialized) { - wl->mac_status = WILC_MAC_STATUS_INIT; - wl->close = 0; - - ret = wilc_wlan_init(dev); - if (ret < 0) - return -EIO; - - ret = wlan_initialize_threads(dev); - if (ret < 0) { - ret = -EIO; - goto fail_wilc_wlan; - } - - if (wl->gpio_irq && init_irq(dev)) { - ret = -EIO; - goto fail_threads; - } - - if (!wl->dev_irq_num && - wl->hif_func->enable_interrupt && - wl->hif_func->enable_interrupt(wl)) { - ret = -EIO; - goto fail_irq_init; - } - - if (wilc_wlan_get_firmware(dev)) { - ret = -EIO; - goto fail_irq_enable; - } - - ret = wilc1000_firmware_download(dev); - if (ret < 0) { - ret = -EIO; - goto fail_irq_enable; - } - - ret = wilc_start_firmware(dev); - if (ret < 0) { - ret = -EIO; - goto fail_irq_enable; - } - - if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) { - int size; - char firmware_ver[20]; - - size = wilc_wlan_cfg_get_val(wl, WID_FIRMWARE_VERSION, - firmware_ver, - sizeof(firmware_ver)); - firmware_ver[size] = '\0'; - netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver); - } - ret = wilc_init_fw_config(dev, vif); - - if (ret < 0) { - netdev_err(dev, "Failed to configure firmware\n"); - ret = -EIO; - goto fail_fw_start; - } - wl->initialized = true; - return 0; - -fail_fw_start: - wilc_wlan_stop(wl, vif); - -fail_irq_enable: - if (!wl->dev_irq_num && - wl->hif_func->disable_interrupt) - wl->hif_func->disable_interrupt(wl); -fail_irq_init: - if (wl->dev_irq_num) - deinit_irq(dev); -fail_threads: - wlan_deinitialize_threads(dev); -fail_wilc_wlan: - wilc_wlan_cleanup(dev); - netdev_err(dev, "WLAN initialization FAILED\n"); - } else { - netdev_dbg(dev, "wilc1000 already initialized\n"); - } - return ret; -} - -static int mac_init_fn(struct net_device *ndev) -{ - netif_start_queue(ndev); - netif_stop_queue(ndev); - - return 0; -} - -static int wilc_mac_open(struct net_device *ndev) -{ - struct wilc_vif *vif = netdev_priv(ndev); - struct wilc *wl = vif->wilc; - struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr); - unsigned char mac_add[ETH_ALEN] = {0}; - int ret = 0; - - if (!wl || !wl->dev) { - netdev_err(ndev, "device not ready\n"); - return -ENODEV; - } - - netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev); - - ret = wilc_init_host_int(ndev); - if (ret < 0) - return ret; - - ret = wilc_wlan_initialize(ndev, vif); - if (ret < 0) { - wilc_deinit_host_int(ndev); - return ret; - } - - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype, - vif->idx); - wilc_get_mac_address(vif, mac_add); - netdev_dbg(ndev, "Mac address: %pM\n", mac_add); - ether_addr_copy(ndev->dev_addr, mac_add); - - if (!is_valid_ether_addr(ndev->dev_addr)) { - netdev_err(ndev, "Wrong MAC address\n"); - wilc_deinit_host_int(ndev); - wilc_wlan_deinitialize(ndev); - return -EINVAL; - } - - wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy, - vif->ndev->ieee80211_ptr, - vif->frame_reg[0].type, - vif->frame_reg[0].reg); - wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy, - vif->ndev->ieee80211_ptr, - vif->frame_reg[1].type, - vif->frame_reg[1].reg); - netif_wake_queue(ndev); - wl->open_ifcs++; - priv->p2p.local_random = 0x01; - vif->mac_opened = 1; - return 0; -} - -static struct net_device_stats *mac_stats(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - - return &vif->netstats; -} - -static void wilc_set_multicast_list(struct net_device *dev) -{ - struct netdev_hw_addr *ha; - struct wilc_vif *vif = netdev_priv(dev); - int i; - u8 *mc_list; - u8 *cur_mc; - - if (dev->flags & IFF_PROMISC) - return; - - if (dev->flags & IFF_ALLMULTI || - dev->mc.count > WILC_MULTICAST_TABLE_SIZE) { - wilc_setup_multicast_filter(vif, 0, 0, NULL); - return; - } - - if (dev->mc.count == 0) { - wilc_setup_multicast_filter(vif, 1, 0, NULL); - return; - } - - mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_ATOMIC); - if (!mc_list) - return; - - cur_mc = mc_list; - i = 0; - netdev_for_each_mc_addr(ha, dev) { - memcpy(cur_mc, ha->addr, ETH_ALEN); - netdev_dbg(dev, "Entry[%d]: %pM\n", i, cur_mc); - i++; - cur_mc += ETH_ALEN; - } - - if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list)) - kfree(mc_list); -} - -static void wilc_tx_complete(void *priv, int status) -{ - struct tx_complete_data *pv_data = priv; - - dev_kfree_skb(pv_data->skb); - kfree(pv_data); -} - -netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) -{ - struct wilc_vif *vif = netdev_priv(ndev); - struct wilc *wilc = vif->wilc; - struct tx_complete_data *tx_data = NULL; - int queue_count; - - if (skb->dev != ndev) { - netdev_err(ndev, "Packet not destined to this device\n"); - return 0; - } - - tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); - if (!tx_data) { - dev_kfree_skb(skb); - netif_wake_queue(ndev); - return 0; - } - - tx_data->buff = skb->data; - tx_data->size = skb->len; - tx_data->skb = skb; - - vif->netstats.tx_packets++; - vif->netstats.tx_bytes += tx_data->size; - queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data, - tx_data->buff, tx_data->size, - wilc_tx_complete); - - if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { - int srcu_idx; - struct wilc_vif *vif; - - srcu_idx = srcu_read_lock(&wilc->srcu); - list_for_each_entry_rcu(vif, &wilc->vif_list, list) { - if (vif->mac_opened) - netif_stop_queue(vif->ndev); - } - srcu_read_unlock(&wilc->srcu, srcu_idx); - } - - return 0; -} - -static int wilc_mac_close(struct net_device *ndev) -{ - struct wilc_vif *vif = netdev_priv(ndev); - struct wilc *wl = vif->wilc; - - netdev_dbg(ndev, "Mac close\n"); - - if (wl->open_ifcs > 0) - wl->open_ifcs--; - else - return 0; - - if (vif->ndev) { - netif_stop_queue(vif->ndev); - - wilc_deinit_host_int(vif->ndev); - } - - if (wl->open_ifcs == 0) { - netdev_dbg(ndev, "Deinitializing wilc1000\n"); - wl->close = 1; - wilc_wlan_deinitialize(ndev); - } - - vif->mac_opened = 0; - - return 0; -} - -void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, - u32 pkt_offset) -{ - unsigned int frame_len = 0; - int stats; - unsigned char *buff_to_send = NULL; - struct sk_buff *skb; - struct net_device *wilc_netdev; - struct wilc_vif *vif; - - if (!wilc) - return; - - wilc_netdev = get_if_handler(wilc, buff); - if (!wilc_netdev) - return; - - buff += pkt_offset; - vif = netdev_priv(wilc_netdev); - - if (size > 0) { - frame_len = size; - buff_to_send = buff; - - skb = dev_alloc_skb(frame_len); - if (!skb) - return; - - skb->dev = wilc_netdev; - - skb_put_data(skb, buff_to_send, frame_len); - - skb->protocol = eth_type_trans(skb, wilc_netdev); - vif->netstats.rx_packets++; - vif->netstats.rx_bytes += frame_len; - skb->ip_summed = CHECKSUM_UNNECESSARY; - stats = netif_rx(skb); - netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats); - } -} - -void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) -{ - int srcu_idx; - struct wilc_vif *vif; - - srcu_idx = srcu_read_lock(&wilc->srcu); - list_for_each_entry_rcu(vif, &wilc->vif_list, list) { - u16 type = le16_to_cpup((__le16 *)buff); - - if (vif->priv.p2p_listen_state && - ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) || - (type == vif->frame_reg[1].type && vif->frame_reg[1].reg))) - wilc_wfi_p2p_rx(vif, buff, size); - - if (vif->monitor_flag) - wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size); - } - srcu_read_unlock(&wilc->srcu, srcu_idx); -} - -static const struct net_device_ops wilc_netdev_ops = { - .ndo_init = mac_init_fn, - .ndo_open = wilc_mac_open, - .ndo_stop = wilc_mac_close, - .ndo_start_xmit = wilc_mac_xmit, - .ndo_get_stats = mac_stats, - .ndo_set_rx_mode = wilc_set_multicast_list, -}; - -void wilc_netdev_cleanup(struct wilc *wilc) -{ - struct wilc_vif *vif; - int srcu_idx; - - if (!wilc) - return; - - if (wilc->firmware) { - release_firmware(wilc->firmware); - wilc->firmware = NULL; - } - - srcu_idx = srcu_read_lock(&wilc->srcu); - list_for_each_entry_rcu(vif, &wilc->vif_list, list) { - if (vif->ndev) - unregister_netdev(vif->ndev); - } - srcu_read_unlock(&wilc->srcu, srcu_idx); - - wilc_wfi_deinit_mon_interface(wilc, false); - flush_workqueue(wilc->hif_workqueue); - destroy_workqueue(wilc->hif_workqueue); - - do { - mutex_lock(&wilc->vif_mutex); - if (wilc->vif_num <= 0) { - mutex_unlock(&wilc->vif_mutex); - break; - } - vif = wilc_get_wl_to_vif(wilc); - if (!IS_ERR(vif)) - list_del_rcu(&vif->list); - - wilc->vif_num--; - mutex_unlock(&wilc->vif_mutex); - synchronize_srcu(&wilc->srcu); - } while (1); - - wilc_wlan_cfg_deinit(wilc); - wlan_deinit_locks(wilc); - kfree(wilc->bus_data); - wiphy_unregister(wilc->wiphy); - wiphy_free(wilc->wiphy); -} -EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); - -static u8 wilc_get_available_idx(struct wilc *wl) -{ - int idx = 0; - struct wilc_vif *vif; - int srcu_idx; - - srcu_idx = srcu_read_lock(&wl->srcu); - list_for_each_entry_rcu(vif, &wl->vif_list, list) { - if (vif->idx == 0) - idx = 1; - else - idx = 0; - } - srcu_read_unlock(&wl->srcu, srcu_idx); - return idx; -} - -struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, - int vif_type, enum nl80211_iftype type, - bool rtnl_locked) -{ - struct net_device *ndev; - struct wilc_vif *vif; - int ret; - - ndev = alloc_etherdev(sizeof(*vif)); - if (!ndev) - return ERR_PTR(-ENOMEM); - - vif = netdev_priv(ndev); - ndev->ieee80211_ptr = &vif->priv.wdev; - strcpy(ndev->name, name); - vif->wilc = wl; - vif->ndev = ndev; - ndev->ml_priv = vif; - - ndev->netdev_ops = &wilc_netdev_ops; - - SET_NETDEV_DEV(ndev, wiphy_dev(wl->wiphy)); - - vif->priv.wdev.wiphy = wl->wiphy; - vif->priv.wdev.netdev = ndev; - vif->priv.wdev.iftype = type; - vif->priv.dev = ndev; - - if (rtnl_locked) - ret = register_netdevice(ndev); - else - ret = register_netdev(ndev); - - if (ret) { - free_netdev(ndev); - return ERR_PTR(-EFAULT); - } - - ndev->needs_free_netdev = true; - vif->iftype = vif_type; - vif->idx = wilc_get_available_idx(wl); - vif->mac_opened = 0; - mutex_lock(&wl->vif_mutex); - list_add_tail_rcu(&vif->list, &wl->vif_list); - wl->vif_num += 1; - mutex_unlock(&wl->vif_mutex); - synchronize_srcu(&wl->srcu); - - return vif; -} - -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c deleted file mode 100644 index c787c5da8f2b..000000000000 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ /dev/null @@ -1,1151 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include -#include -#include - -#include "wilc_wfi_netdevice.h" -#include "wilc_wfi_cfgoperations.h" - -#define SDIO_MODALIAS "wilc1000_sdio" - -#define SDIO_VENDOR_ID_WILC 0x0296 -#define SDIO_DEVICE_ID_WILC 0x5347 - -static const struct sdio_device_id wilc_sdio_ids[] = { - { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) }, - { }, -}; - -#define WILC_SDIO_BLOCK_SIZE 512 - -struct wilc_sdio { - bool irq_gpio; - u32 block_size; - int nint; -/* Max num interrupts allowed in registers 0xf7, 0xf8 */ -#define MAX_NUN_INT_THRPT_ENH2 (5) - int has_thrpt_enh3; -}; - -struct sdio_cmd52 { - u32 read_write: 1; - u32 function: 3; - u32 raw: 1; - u32 address: 17; - u32 data: 8; -}; - -struct sdio_cmd53 { - u32 read_write: 1; - u32 function: 3; - u32 block_mode: 1; - u32 increment: 1; - u32 address: 17; - u32 count: 9; - u8 *buffer; - u32 block_size; -}; - -static const struct wilc_hif_func wilc_hif_sdio; - -static void wilc_sdio_interrupt(struct sdio_func *func) -{ - sdio_release_host(func); - wilc_handle_isr(sdio_get_drvdata(func)); - sdio_claim_host(func); -} - -static int wilc_sdio_cmd52(struct wilc *wilc, struct sdio_cmd52 *cmd) -{ - struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev); - int ret; - u8 data; - - sdio_claim_host(func); - - func->num = cmd->function; - if (cmd->read_write) { /* write */ - if (cmd->raw) { - sdio_writeb(func, cmd->data, cmd->address, &ret); - data = sdio_readb(func, cmd->address, &ret); - cmd->data = data; - } else { - sdio_writeb(func, cmd->data, cmd->address, &ret); - } - } else { /* read */ - data = sdio_readb(func, cmd->address, &ret); - cmd->data = data; - } - - sdio_release_host(func); - - if (ret) - dev_err(&func->dev, "%s..failed, err(%d)\n", __func__, ret); - return ret; -} - -static int wilc_sdio_cmd53(struct wilc *wilc, struct sdio_cmd53 *cmd) -{ - struct sdio_func *func = container_of(wilc->dev, struct sdio_func, dev); - int size, ret; - - sdio_claim_host(func); - - func->num = cmd->function; - func->cur_blksize = cmd->block_size; - if (cmd->block_mode) - size = cmd->count * cmd->block_size; - else - size = cmd->count; - - if (cmd->read_write) { /* write */ - ret = sdio_memcpy_toio(func, cmd->address, - (void *)cmd->buffer, size); - } else { /* read */ - ret = sdio_memcpy_fromio(func, (void *)cmd->buffer, - cmd->address, size); - } - - sdio_release_host(func); - - if (ret) - dev_err(&func->dev, "%s..failed, err(%d)\n", __func__, ret); - - return ret; -} - -static int wilc_sdio_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - struct wilc *wilc; - int ret; - struct gpio_desc *gpio = NULL; - struct wilc_sdio *sdio_priv; - - sdio_priv = kzalloc(sizeof(*sdio_priv), GFP_KERNEL); - if (!sdio_priv) - return -ENOMEM; - - if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) { - gpio = gpiod_get(&func->dev, "irq", GPIOD_IN); - if (IS_ERR(gpio)) { - /* get the GPIO descriptor from hardcode GPIO number */ - gpio = gpio_to_desc(GPIO_NUM); - if (!gpio) - dev_err(&func->dev, "failed to get irq gpio\n"); - } - } - - ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO, - &wilc_hif_sdio); - if (ret) { - kfree(sdio_priv); - return ret; - } - sdio_set_drvdata(func, wilc); - wilc->bus_data = sdio_priv; - wilc->dev = &func->dev; - wilc->gpio_irq = gpio; - - wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc_clk"); - if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - else if (!IS_ERR(wilc->rtc_clk)) - clk_prepare_enable(wilc->rtc_clk); - - dev_info(&func->dev, "Driver Initializing success\n"); - return 0; -} - -static void wilc_sdio_remove(struct sdio_func *func) -{ - struct wilc *wilc = sdio_get_drvdata(func); - - /* free the GPIO in module remove */ - if (wilc->gpio_irq) - gpiod_put(wilc->gpio_irq); - - if (!IS_ERR(wilc->rtc_clk)) - clk_disable_unprepare(wilc->rtc_clk); - - wilc_netdev_cleanup(wilc); -} - -static int wilc_sdio_reset(struct wilc *wilc) -{ - struct sdio_cmd52 cmd; - int ret; - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0x6; - cmd.data = 0x8; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Fail cmd 52, reset cmd ...\n"); - return ret; - } - return 0; -} - -static int wilc_sdio_suspend(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - struct wilc *wilc = sdio_get_drvdata(func); - int ret; - - dev_info(dev, "sdio suspend\n"); - chip_wakeup(wilc); - - if (!IS_ERR(wilc->rtc_clk)) - clk_disable_unprepare(wilc->rtc_clk); - - if (wilc->suspend_event) { - host_sleep_notify(wilc); - chip_allow_sleep(wilc); - } - - ret = wilc_sdio_reset(wilc); - if (ret) { - dev_err(&func->dev, "Fail reset sdio\n"); - return ret; - } - sdio_claim_host(func); - - return 0; -} - -static int wilc_sdio_enable_interrupt(struct wilc *dev) -{ - struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev); - int ret = 0; - - sdio_claim_host(func); - ret = sdio_claim_irq(func, wilc_sdio_interrupt); - sdio_release_host(func); - - if (ret < 0) { - dev_err(&func->dev, "can't claim sdio_irq, err(%d)\n", ret); - ret = -EIO; - } - return ret; -} - -static void wilc_sdio_disable_interrupt(struct wilc *dev) -{ - struct sdio_func *func = container_of(dev->dev, struct sdio_func, dev); - int ret; - - sdio_claim_host(func); - ret = sdio_release_irq(func); - if (ret < 0) - dev_err(&func->dev, "can't release sdio_irq, err(%d)\n", ret); - sdio_release_host(func); -} - -/******************************************** - * - * Function 0 - * - ********************************************/ - -static int wilc_sdio_set_func0_csa_address(struct wilc *wilc, u32 adr) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct sdio_cmd52 cmd; - int ret; - - /** - * Review: BIG ENDIAN - **/ - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0x10c; - cmd.data = (u8)adr; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10c data...\n"); - goto fail; - } - - cmd.address = 0x10d; - cmd.data = (u8)(adr >> 8); - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10d data...\n"); - goto fail; - } - - cmd.address = 0x10e; - cmd.data = (u8)(adr >> 16); - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10e data...\n"); - goto fail; - } - - return 1; -fail: - return 0; -} - -static int wilc_sdio_set_func0_block_size(struct wilc *wilc, u32 block_size) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct sdio_cmd52 cmd; - int ret; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0x10; - cmd.data = (u8)block_size; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x10 data...\n"); - goto fail; - } - - cmd.address = 0x11; - cmd.data = (u8)(block_size >> 8); - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x11 data...\n"); - goto fail; - } - - return 1; -fail: - return 0; -} - -/******************************************** - * - * Function 1 - * - ********************************************/ - -static int wilc_sdio_set_func1_block_size(struct wilc *wilc, u32 block_size) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct sdio_cmd52 cmd; - int ret; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0x110; - cmd.data = (u8)block_size; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x110 data...\n"); - goto fail; - } - cmd.address = 0x111; - cmd.data = (u8)(block_size >> 8); - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Failed cmd52, set 0x111 data...\n"); - goto fail; - } - - return 1; -fail: - return 0; -} - -/******************************************** - * - * Sdio interfaces - * - ********************************************/ -static int wilc_sdio_write_reg(struct wilc *wilc, u32 addr, u32 data) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - int ret; - - cpu_to_le32s(&data); - - if (addr >= 0xf0 && addr <= 0xff) { - struct sdio_cmd52 cmd; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = addr; - cmd.data = data; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd 52, read reg (%08x) ...\n", addr); - goto fail; - } - } else { - struct sdio_cmd53 cmd; - - /** - * set the AHB address - **/ - if (!wilc_sdio_set_func0_csa_address(wilc, addr)) - goto fail; - - cmd.read_write = 1; - cmd.function = 0; - cmd.address = 0x10f; - cmd.block_mode = 0; - cmd.increment = 1; - cmd.count = 4; - cmd.buffer = (u8 *)&data; - cmd.block_size = sdio_priv->block_size; - ret = wilc_sdio_cmd53(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd53, write reg (%08x)...\n", addr); - goto fail; - } - } - - return 1; - -fail: - - return 0; -} - -static int wilc_sdio_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - u32 block_size = sdio_priv->block_size; - struct sdio_cmd53 cmd; - int nblk, nleft, ret; - - cmd.read_write = 1; - if (addr > 0) { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - - /** - * func 0 access - **/ - cmd.function = 0; - cmd.address = 0x10f; - } else { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - - /** - * func 1 access - **/ - cmd.function = 1; - cmd.address = 0; - } - - nblk = size / block_size; - nleft = size % block_size; - - if (nblk > 0) { - cmd.block_mode = 1; - cmd.increment = 1; - cmd.count = nblk; - cmd.buffer = buf; - cmd.block_size = block_size; - if (addr > 0) { - if (!wilc_sdio_set_func0_csa_address(wilc, addr)) - goto fail; - } - ret = wilc_sdio_cmd53(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd53 [%x], block send...\n", addr); - goto fail; - } - if (addr > 0) - addr += nblk * block_size; - buf += nblk * block_size; - } - - if (nleft > 0) { - cmd.block_mode = 0; - cmd.increment = 1; - cmd.count = nleft; - cmd.buffer = buf; - - cmd.block_size = block_size; - - if (addr > 0) { - if (!wilc_sdio_set_func0_csa_address(wilc, addr)) - goto fail; - } - ret = wilc_sdio_cmd53(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd53 [%x], bytes send...\n", addr); - goto fail; - } - } - - return 1; - -fail: - - return 0; -} - -static int wilc_sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - int ret; - - if (addr >= 0xf0 && addr <= 0xff) { - struct sdio_cmd52 cmd; - - cmd.read_write = 0; - cmd.function = 0; - cmd.raw = 0; - cmd.address = addr; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd 52, read reg (%08x) ...\n", addr); - goto fail; - } - *data = cmd.data; - } else { - struct sdio_cmd53 cmd; - - if (!wilc_sdio_set_func0_csa_address(wilc, addr)) - goto fail; - - cmd.read_write = 0; - cmd.function = 0; - cmd.address = 0x10f; - cmd.block_mode = 0; - cmd.increment = 1; - cmd.count = 4; - cmd.buffer = (u8 *)data; - - cmd.block_size = sdio_priv->block_size; - ret = wilc_sdio_cmd53(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd53, read reg (%08x)...\n", addr); - goto fail; - } - } - - le32_to_cpus(data); - - return 1; - -fail: - - return 0; -} - -static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - u32 block_size = sdio_priv->block_size; - struct sdio_cmd53 cmd; - int nblk, nleft, ret; - - cmd.read_write = 0; - if (addr > 0) { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - - /** - * func 0 access - **/ - cmd.function = 0; - cmd.address = 0x10f; - } else { - /** - * has to be word aligned... - **/ - if (size & 0x3) { - size += 4; - size &= ~0x3; - } - - /** - * func 1 access - **/ - cmd.function = 1; - cmd.address = 0; - } - - nblk = size / block_size; - nleft = size % block_size; - - if (nblk > 0) { - cmd.block_mode = 1; - cmd.increment = 1; - cmd.count = nblk; - cmd.buffer = buf; - cmd.block_size = block_size; - if (addr > 0) { - if (!wilc_sdio_set_func0_csa_address(wilc, addr)) - goto fail; - } - ret = wilc_sdio_cmd53(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd53 [%x], block read...\n", addr); - goto fail; - } - if (addr > 0) - addr += nblk * block_size; - buf += nblk * block_size; - } /* if (nblk > 0) */ - - if (nleft > 0) { - cmd.block_mode = 0; - cmd.increment = 1; - cmd.count = nleft; - cmd.buffer = buf; - - cmd.block_size = block_size; - - if (addr > 0) { - if (!wilc_sdio_set_func0_csa_address(wilc, addr)) - goto fail; - } - ret = wilc_sdio_cmd53(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd53 [%x], bytes read...\n", addr); - goto fail; - } - } - - return 1; - -fail: - - return 0; -} - -/******************************************** - * - * Bus interfaces - * - ********************************************/ - -static int wilc_sdio_deinit(struct wilc *wilc) -{ - return 1; -} - -static int wilc_sdio_init(struct wilc *wilc, bool resume) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - struct sdio_cmd52 cmd; - int loop, ret; - u32 chipid; - - if (!resume) - sdio_priv->irq_gpio = wilc->dev_irq_num; - - /** - * function 0 csa enable - **/ - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 1; - cmd.address = 0x100; - cmd.data = 0x80; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Fail cmd 52, enable csa...\n"); - goto fail; - } - - /** - * function 0 block size - **/ - if (!wilc_sdio_set_func0_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) { - dev_err(&func->dev, "Fail cmd 52, set func 0 block size...\n"); - goto fail; - } - sdio_priv->block_size = WILC_SDIO_BLOCK_SIZE; - - /** - * enable func1 IO - **/ - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 1; - cmd.address = 0x2; - cmd.data = 0x2; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Fail cmd 52, set IOE register...\n"); - goto fail; - } - - /** - * make sure func 1 is up - **/ - cmd.read_write = 0; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0x3; - loop = 3; - do { - cmd.data = 0; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Fail cmd 52, get IOR register...\n"); - goto fail; - } - if (cmd.data == 0x2) - break; - } while (loop--); - - if (loop <= 0) { - dev_err(&func->dev, "Fail func 1 is not ready...\n"); - goto fail; - } - - /** - * func 1 is ready, set func 1 block size - **/ - if (!wilc_sdio_set_func1_block_size(wilc, WILC_SDIO_BLOCK_SIZE)) { - dev_err(&func->dev, "Fail set func 1 block size...\n"); - goto fail; - } - - /** - * func 1 interrupt enable - **/ - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 1; - cmd.address = 0x4; - cmd.data = 0x3; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, "Fail cmd 52, set IEN register...\n"); - goto fail; - } - - /** - * make sure can read back chip id correctly - **/ - if (!resume) { - if (!wilc_sdio_read_reg(wilc, 0x1000, &chipid)) { - dev_err(&func->dev, "Fail cmd read chip id...\n"); - goto fail; - } - dev_err(&func->dev, "chipid (%08x)\n", chipid); - if ((chipid & 0xfff) > 0x2a0) - sdio_priv->has_thrpt_enh3 = 1; - else - sdio_priv->has_thrpt_enh3 = 0; - dev_info(&func->dev, "has_thrpt_enh3 = %d...\n", - sdio_priv->has_thrpt_enh3); - } - - return 1; - -fail: - - return 0; -} - -static int wilc_sdio_read_size(struct wilc *wilc, u32 *size) -{ - u32 tmp; - struct sdio_cmd52 cmd; - - /** - * Read DMA count in words - **/ - cmd.read_write = 0; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0xf2; - cmd.data = 0; - wilc_sdio_cmd52(wilc, &cmd); - tmp = cmd.data; - - cmd.address = 0xf3; - cmd.data = 0; - wilc_sdio_cmd52(wilc, &cmd); - tmp |= (cmd.data << 8); - - *size = tmp; - return 1; -} - -static int wilc_sdio_read_int(struct wilc *wilc, u32 *int_status) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - u32 tmp; - struct sdio_cmd52 cmd; - - wilc_sdio_read_size(wilc, &tmp); - - /** - * Read IRQ flags - **/ - if (!sdio_priv->irq_gpio) { - int i; - - cmd.read_write = 0; - cmd.function = 1; - cmd.address = 0x04; - cmd.data = 0; - wilc_sdio_cmd52(wilc, &cmd); - - if (cmd.data & BIT(0)) - tmp |= INT_0; - if (cmd.data & BIT(2)) - tmp |= INT_1; - if (cmd.data & BIT(3)) - tmp |= INT_2; - if (cmd.data & BIT(4)) - tmp |= INT_3; - if (cmd.data & BIT(5)) - tmp |= INT_4; - if (cmd.data & BIT(6)) - tmp |= INT_5; - for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { - if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) { - dev_err(&func->dev, - "Unexpected interrupt (1) : tmp=%x, data=%x\n", - tmp, cmd.data); - break; - } - } - } else { - u32 irq_flags; - - cmd.read_write = 0; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0xf7; - cmd.data = 0; - wilc_sdio_cmd52(wilc, &cmd); - irq_flags = cmd.data & 0x1f; - tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET); - } - - *int_status = tmp; - - return 1; -} - -static int wilc_sdio_clear_int_ext(struct wilc *wilc, u32 val) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - int ret; - int vmm_ctl; - - if (sdio_priv->has_thrpt_enh3) { - u32 reg; - - if (sdio_priv->irq_gpio) { - u32 flags; - - flags = val & (BIT(MAX_NUN_INT_THRPT_ENH2) - 1); - reg = flags; - } else { - reg = 0; - } - /* select VMM table 0 */ - if (val & SEL_VMM_TBL0) - reg |= BIT(5); - /* select VMM table 1 */ - if (val & SEL_VMM_TBL1) - reg |= BIT(6); - /* enable VMM */ - if (val & EN_VMM) - reg |= BIT(7); - if (reg) { - struct sdio_cmd52 cmd; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0xf8; - cmd.data = reg; - - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd52, set 0xf8 data (%d) ...\n", - __LINE__); - goto fail; - } - } - return 1; - } - if (sdio_priv->irq_gpio) { - /* has_thrpt_enh2 uses register 0xf8 to clear interrupts. */ - /* - * Cannot clear multiple interrupts. - * Must clear each interrupt individually. - */ - u32 flags; - - flags = val & (BIT(MAX_NUM_INT) - 1); - if (flags) { - int i; - - ret = 1; - for (i = 0; i < sdio_priv->nint; i++) { - if (flags & 1) { - struct sdio_cmd52 cmd; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0xf8; - cmd.data = BIT(i); - - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd52, set 0xf8 data (%d) ...\n", - __LINE__); - goto fail; - } - } - if (!ret) - break; - flags >>= 1; - } - if (!ret) - goto fail; - for (i = sdio_priv->nint; i < MAX_NUM_INT; i++) { - if (flags & 1) - dev_err(&func->dev, - "Unexpected interrupt cleared %d...\n", - i); - flags >>= 1; - } - } - } - - vmm_ctl = 0; - /* select VMM table 0 */ - if (val & SEL_VMM_TBL0) - vmm_ctl |= BIT(0); - /* select VMM table 1 */ - if (val & SEL_VMM_TBL1) - vmm_ctl |= BIT(1); - /* enable VMM */ - if (val & EN_VMM) - vmm_ctl |= BIT(2); - - if (vmm_ctl) { - struct sdio_cmd52 cmd; - - cmd.read_write = 1; - cmd.function = 0; - cmd.raw = 0; - cmd.address = 0xf6; - cmd.data = vmm_ctl; - ret = wilc_sdio_cmd52(wilc, &cmd); - if (ret) { - dev_err(&func->dev, - "Failed cmd52, set 0xf6 data (%d) ...\n", - __LINE__); - goto fail; - } - } - return 1; -fail: - return 0; -} - -static int wilc_sdio_sync_ext(struct wilc *wilc, int nint) -{ - struct sdio_func *func = dev_to_sdio_func(wilc->dev); - struct wilc_sdio *sdio_priv = wilc->bus_data; - u32 reg; - - if (nint > MAX_NUM_INT) { - dev_err(&func->dev, "Too many interrupts (%d)...\n", nint); - return 0; - } - if (nint > MAX_NUN_INT_THRPT_ENH2) { - dev_err(&func->dev, - "Cannot support more than 5 interrupts when has_thrpt_enh2=1.\n"); - return 0; - } - - sdio_priv->nint = nint; - - /** - * Disable power sequencer - **/ - if (!wilc_sdio_read_reg(wilc, WILC_MISC, ®)) { - dev_err(&func->dev, "Failed read misc reg...\n"); - return 0; - } - - reg &= ~BIT(8); - if (!wilc_sdio_write_reg(wilc, WILC_MISC, reg)) { - dev_err(&func->dev, "Failed write misc reg...\n"); - return 0; - } - - if (sdio_priv->irq_gpio) { - u32 reg; - int ret, i; - - /** - * interrupt pin mux select - **/ - ret = wilc_sdio_read_reg(wilc, WILC_PIN_MUX_0, ®); - if (!ret) { - dev_err(&func->dev, "Failed read reg (%08x)...\n", - WILC_PIN_MUX_0); - return 0; - } - reg |= BIT(8); - ret = wilc_sdio_write_reg(wilc, WILC_PIN_MUX_0, reg); - if (!ret) { - dev_err(&func->dev, "Failed write reg (%08x)...\n", - WILC_PIN_MUX_0); - return 0; - } - - /** - * interrupt enable - **/ - ret = wilc_sdio_read_reg(wilc, WILC_INTR_ENABLE, ®); - if (!ret) { - dev_err(&func->dev, "Failed read reg (%08x)...\n", - WILC_INTR_ENABLE); - return 0; - } - - for (i = 0; (i < 5) && (nint > 0); i++, nint--) - reg |= BIT((27 + i)); - ret = wilc_sdio_write_reg(wilc, WILC_INTR_ENABLE, reg); - if (!ret) { - dev_err(&func->dev, "Failed write reg (%08x)...\n", - WILC_INTR_ENABLE); - return 0; - } - if (nint) { - ret = wilc_sdio_read_reg(wilc, WILC_INTR2_ENABLE, ®); - if (!ret) { - dev_err(&func->dev, - "Failed read reg (%08x)...\n", - WILC_INTR2_ENABLE); - return 0; - } - - for (i = 0; (i < 3) && (nint > 0); i++, nint--) - reg |= BIT(i); - - ret = wilc_sdio_read_reg(wilc, WILC_INTR2_ENABLE, ®); - if (!ret) { - dev_err(&func->dev, - "Failed write reg (%08x)...\n", - WILC_INTR2_ENABLE); - return 0; - } - } - } - return 1; -} - -/* Global sdio HIF function table */ -static const struct wilc_hif_func wilc_hif_sdio = { - .hif_init = wilc_sdio_init, - .hif_deinit = wilc_sdio_deinit, - .hif_read_reg = wilc_sdio_read_reg, - .hif_write_reg = wilc_sdio_write_reg, - .hif_block_rx = wilc_sdio_read, - .hif_block_tx = wilc_sdio_write, - .hif_read_int = wilc_sdio_read_int, - .hif_clear_int_ext = wilc_sdio_clear_int_ext, - .hif_read_size = wilc_sdio_read_size, - .hif_block_tx_ext = wilc_sdio_write, - .hif_block_rx_ext = wilc_sdio_read, - .hif_sync_ext = wilc_sdio_sync_ext, - .enable_interrupt = wilc_sdio_enable_interrupt, - .disable_interrupt = wilc_sdio_disable_interrupt, -}; - -static int wilc_sdio_resume(struct device *dev) -{ - struct sdio_func *func = dev_to_sdio_func(dev); - struct wilc *wilc = sdio_get_drvdata(func); - - dev_info(dev, "sdio resume\n"); - sdio_release_host(func); - chip_wakeup(wilc); - wilc_sdio_init(wilc, true); - - if (wilc->suspend_event) - host_wakeup_notify(wilc); - - chip_allow_sleep(wilc); - - return 0; -} - -static const struct of_device_id wilc_of_match[] = { - { .compatible = "microchip,wilc1000-sdio", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, wilc_of_match); - -static const struct dev_pm_ops wilc_sdio_pm_ops = { - .suspend = wilc_sdio_suspend, - .resume = wilc_sdio_resume, -}; - -static struct sdio_driver wilc_sdio_driver = { - .name = SDIO_MODALIAS, - .id_table = wilc_sdio_ids, - .probe = wilc_sdio_probe, - .remove = wilc_sdio_remove, - .drv = { - .pm = &wilc_sdio_pm_ops, - .of_match_table = wilc_of_match, - } -}; -module_driver(wilc_sdio_driver, - sdio_register_driver, - sdio_unregister_driver); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c deleted file mode 100644 index 166455a969bf..000000000000 --- a/drivers/staging/wilc1000/wilc_spi.c +++ /dev/null @@ -1,1145 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include -#include - -#include "wilc_wfi_netdevice.h" -#include "wilc_wfi_cfgoperations.h" - -struct wilc_spi { - int crc_off; - int nint; - int has_thrpt_enh; -}; - -static const struct wilc_hif_func wilc_hif_spi; - -/******************************************** - * - * Crc7 - * - ********************************************/ - -static const u8 crc7_syndrome_table[256] = { - 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f, - 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77, - 0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26, - 0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e, - 0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d, - 0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45, - 0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14, - 0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c, - 0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b, - 0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13, - 0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42, - 0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a, - 0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69, - 0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21, - 0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70, - 0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38, - 0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e, - 0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36, - 0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67, - 0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f, - 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c, - 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04, - 0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55, - 0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d, - 0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a, - 0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52, - 0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03, - 0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b, - 0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28, - 0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60, - 0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31, - 0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79 -}; - -static u8 crc7_byte(u8 crc, u8 data) -{ - return crc7_syndrome_table[(crc << 1) ^ data]; -} - -static u8 crc7(u8 crc, const u8 *buffer, u32 len) -{ - while (len--) - crc = crc7_byte(crc, *buffer++); - return crc; -} - -/******************************************** - * - * Spi protocol Function - * - ********************************************/ - -#define CMD_DMA_WRITE 0xc1 -#define CMD_DMA_READ 0xc2 -#define CMD_INTERNAL_WRITE 0xc3 -#define CMD_INTERNAL_READ 0xc4 -#define CMD_TERMINATE 0xc5 -#define CMD_REPEAT 0xc6 -#define CMD_DMA_EXT_WRITE 0xc7 -#define CMD_DMA_EXT_READ 0xc8 -#define CMD_SINGLE_WRITE 0xc9 -#define CMD_SINGLE_READ 0xca -#define CMD_RESET 0xcf - -#define N_OK 1 -#define N_FAIL 0 -#define N_RESET -1 -#define N_RETRY -2 - -#define DATA_PKT_SZ_256 256 -#define DATA_PKT_SZ_512 512 -#define DATA_PKT_SZ_1K 1024 -#define DATA_PKT_SZ_4K (4 * 1024) -#define DATA_PKT_SZ_8K (8 * 1024) -#define DATA_PKT_SZ DATA_PKT_SZ_8K - -#define USE_SPI_DMA 0 - -static int wilc_bus_probe(struct spi_device *spi) -{ - int ret; - struct wilc *wilc; - struct gpio_desc *gpio; - struct wilc_spi *spi_priv; - - spi_priv = kzalloc(sizeof(*spi_priv), GFP_KERNEL); - if (!spi_priv) - return -ENOMEM; - - gpio = gpiod_get(&spi->dev, "irq", GPIOD_IN); - if (IS_ERR(gpio)) { - /* get the GPIO descriptor from hardcode GPIO number */ - gpio = gpio_to_desc(GPIO_NUM); - if (!gpio) - dev_err(&spi->dev, "failed to get the irq gpio\n"); - } - - ret = wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi); - if (ret) { - kfree(spi_priv); - return ret; - } - - spi_set_drvdata(spi, wilc); - wilc->dev = &spi->dev; - wilc->bus_data = spi_priv; - wilc->gpio_irq = gpio; - - wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc_clk"); - if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - else if (!IS_ERR(wilc->rtc_clk)) - clk_prepare_enable(wilc->rtc_clk); - - return 0; -} - -static int wilc_bus_remove(struct spi_device *spi) -{ - struct wilc *wilc = spi_get_drvdata(spi); - - /* free the GPIO in module remove */ - if (wilc->gpio_irq) - gpiod_put(wilc->gpio_irq); - - if (!IS_ERR(wilc->rtc_clk)) - clk_disable_unprepare(wilc->rtc_clk); - - wilc_netdev_cleanup(wilc); - return 0; -} - -static const struct of_device_id wilc_of_match[] = { - { .compatible = "microchip,wilc1000-spi", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, wilc_of_match); - -static struct spi_driver wilc_spi_driver = { - .driver = { - .name = MODALIAS, - .of_match_table = wilc_of_match, - }, - .probe = wilc_bus_probe, - .remove = wilc_bus_remove, -}; -module_spi_driver(wilc_spi_driver); -MODULE_LICENSE("GPL"); - -static int wilc_spi_tx(struct wilc *wilc, u8 *b, u32 len) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int ret; - struct spi_message msg; - - if (len > 0 && b) { - struct spi_transfer tr = { - .tx_buf = b, - .len = len, - .delay_usecs = 0, - }; - char *r_buffer = kzalloc(len, GFP_KERNEL); - - if (!r_buffer) - return -ENOMEM; - - tr.rx_buf = r_buffer; - dev_dbg(&spi->dev, "Request writing %d bytes\n", len); - - memset(&msg, 0, sizeof(msg)); - spi_message_init(&msg); - msg.spi = spi; - msg.is_dma_mapped = USE_SPI_DMA; - spi_message_add_tail(&tr, &msg); - - ret = spi_sync(spi, &msg); - if (ret < 0) - dev_err(&spi->dev, "SPI transaction failed\n"); - - kfree(r_buffer); - } else { - dev_err(&spi->dev, - "can't write data with the following length: %d\n", - len); - ret = -EINVAL; - } - - return ret; -} - -static int wilc_spi_rx(struct wilc *wilc, u8 *rb, u32 rlen) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int ret; - - if (rlen > 0) { - struct spi_message msg; - struct spi_transfer tr = { - .rx_buf = rb, - .len = rlen, - .delay_usecs = 0, - - }; - char *t_buffer = kzalloc(rlen, GFP_KERNEL); - - if (!t_buffer) - return -ENOMEM; - - tr.tx_buf = t_buffer; - - memset(&msg, 0, sizeof(msg)); - spi_message_init(&msg); - msg.spi = spi; - msg.is_dma_mapped = USE_SPI_DMA; - spi_message_add_tail(&tr, &msg); - - ret = spi_sync(spi, &msg); - if (ret < 0) - dev_err(&spi->dev, "SPI transaction failed\n"); - kfree(t_buffer); - } else { - dev_err(&spi->dev, - "can't read data with the following length: %u\n", - rlen); - ret = -EINVAL; - } - - return ret; -} - -static int wilc_spi_tx_rx(struct wilc *wilc, u8 *wb, u8 *rb, u32 rlen) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int ret; - - if (rlen > 0) { - struct spi_message msg; - struct spi_transfer tr = { - .rx_buf = rb, - .tx_buf = wb, - .len = rlen, - .bits_per_word = 8, - .delay_usecs = 0, - - }; - - memset(&msg, 0, sizeof(msg)); - spi_message_init(&msg); - msg.spi = spi; - msg.is_dma_mapped = USE_SPI_DMA; - - spi_message_add_tail(&tr, &msg); - ret = spi_sync(spi, &msg); - if (ret < 0) - dev_err(&spi->dev, "SPI transaction failed\n"); - } else { - dev_err(&spi->dev, - "can't read data with the following length: %u\n", - rlen); - ret = -EINVAL; - } - - return ret; -} - -static int spi_cmd_complete(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz, - u8 clockless) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - u8 wb[32], rb[32]; - u8 wix, rix; - u32 len2; - u8 rsp; - int len = 0; - int result = N_OK; - int retry; - u8 crc[2]; - - wb[0] = cmd; - switch (cmd) { - case CMD_SINGLE_READ: /* single word (4 bytes) read */ - wb[1] = (u8)(adr >> 16); - wb[2] = (u8)(adr >> 8); - wb[3] = (u8)adr; - len = 5; - break; - - case CMD_INTERNAL_READ: /* internal register read */ - wb[1] = (u8)(adr >> 8); - if (clockless == 1) - wb[1] |= BIT(7); - wb[2] = (u8)adr; - wb[3] = 0x00; - len = 5; - break; - - case CMD_TERMINATE: - wb[1] = 0x00; - wb[2] = 0x00; - wb[3] = 0x00; - len = 5; - break; - - case CMD_REPEAT: - wb[1] = 0x00; - wb[2] = 0x00; - wb[3] = 0x00; - len = 5; - break; - - case CMD_RESET: - wb[1] = 0xff; - wb[2] = 0xff; - wb[3] = 0xff; - len = 5; - break; - - case CMD_DMA_WRITE: /* dma write */ - case CMD_DMA_READ: /* dma read */ - wb[1] = (u8)(adr >> 16); - wb[2] = (u8)(adr >> 8); - wb[3] = (u8)adr; - wb[4] = (u8)(sz >> 8); - wb[5] = (u8)(sz); - len = 7; - break; - - case CMD_DMA_EXT_WRITE: /* dma extended write */ - case CMD_DMA_EXT_READ: /* dma extended read */ - wb[1] = (u8)(adr >> 16); - wb[2] = (u8)(adr >> 8); - wb[3] = (u8)adr; - wb[4] = (u8)(sz >> 16); - wb[5] = (u8)(sz >> 8); - wb[6] = (u8)(sz); - len = 8; - break; - - case CMD_INTERNAL_WRITE: /* internal register write */ - wb[1] = (u8)(adr >> 8); - if (clockless == 1) - wb[1] |= BIT(7); - wb[2] = (u8)(adr); - wb[3] = b[3]; - wb[4] = b[2]; - wb[5] = b[1]; - wb[6] = b[0]; - len = 8; - break; - - case CMD_SINGLE_WRITE: /* single word write */ - wb[1] = (u8)(adr >> 16); - wb[2] = (u8)(adr >> 8); - wb[3] = (u8)(adr); - wb[4] = b[3]; - wb[5] = b[2]; - wb[6] = b[1]; - wb[7] = b[0]; - len = 9; - break; - - default: - result = N_FAIL; - break; - } - - if (result != N_OK) - return result; - - if (!spi_priv->crc_off) - wb[len - 1] = (crc7(0x7f, (const u8 *)&wb[0], len - 1)) << 1; - else - len -= 1; - -#define NUM_SKIP_BYTES (1) -#define NUM_RSP_BYTES (2) -#define NUM_DATA_HDR_BYTES (1) -#define NUM_DATA_BYTES (4) -#define NUM_CRC_BYTES (2) -#define NUM_DUMMY_BYTES (3) - if (cmd == CMD_RESET || - cmd == CMD_TERMINATE || - cmd == CMD_REPEAT) { - len2 = len + (NUM_SKIP_BYTES + NUM_RSP_BYTES + NUM_DUMMY_BYTES); - } else if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ) { - int tmp = NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES - + NUM_DUMMY_BYTES; - if (!spi_priv->crc_off) - len2 = len + tmp + NUM_CRC_BYTES; - else - len2 = len + tmp; - } else { - len2 = len + (NUM_RSP_BYTES + NUM_DUMMY_BYTES); - } -#undef NUM_DUMMY_BYTES - - if (len2 > ARRAY_SIZE(wb)) { - dev_err(&spi->dev, "spi buffer size too small (%d) (%zu)\n", - len2, ARRAY_SIZE(wb)); - return N_FAIL; - } - /* zero spi write buffers. */ - for (wix = len; wix < len2; wix++) - wb[wix] = 0; - rix = len; - - if (wilc_spi_tx_rx(wilc, wb, rb, len2)) { - dev_err(&spi->dev, "Failed cmd write, bus error...\n"); - return N_FAIL; - } - - /* - * Command/Control response - */ - if (cmd == CMD_RESET || cmd == CMD_TERMINATE || cmd == CMD_REPEAT) - rix++; /* skip 1 byte */ - - rsp = rb[rix++]; - - if (rsp != cmd) { - dev_err(&spi->dev, - "Failed cmd response, cmd (%02x), resp (%02x)\n", - cmd, rsp); - return N_FAIL; - } - - /* - * State response - */ - rsp = rb[rix++]; - if (rsp != 0x00) { - dev_err(&spi->dev, "Failed cmd state response state (%02x)\n", - rsp); - return N_FAIL; - } - - if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ || - cmd == CMD_DMA_READ || cmd == CMD_DMA_EXT_READ) { - /* - * Data Respnose header - */ - retry = 100; - do { - /* - * ensure there is room in buffer later - * to read data and crc - */ - if (rix < len2) { - rsp = rb[rix++]; - } else { - retry = 0; - break; - } - if (((rsp >> 4) & 0xf) == 0xf) - break; - } while (retry--); - - if (retry <= 0) { - dev_err(&spi->dev, - "Error, data read response (%02x)\n", rsp); - return N_RESET; - } - } - - if (cmd == CMD_INTERNAL_READ || cmd == CMD_SINGLE_READ) { - /* - * Read bytes - */ - if ((rix + 3) < len2) { - b[0] = rb[rix++]; - b[1] = rb[rix++]; - b[2] = rb[rix++]; - b[3] = rb[rix++]; - } else { - dev_err(&spi->dev, - "buffer overrun when reading data.\n"); - return N_FAIL; - } - - if (!spi_priv->crc_off) { - /* - * Read Crc - */ - if ((rix + 1) < len2) { - crc[0] = rb[rix++]; - crc[1] = rb[rix++]; - } else { - dev_err(&spi->dev, - "buffer overrun when reading crc.\n"); - return N_FAIL; - } - } - } else if ((cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) { - int ix; - - /* some data may be read in response to dummy bytes. */ - for (ix = 0; (rix < len2) && (ix < sz); ) - b[ix++] = rb[rix++]; - - sz -= ix; - - if (sz > 0) { - int nbytes; - - if (sz <= (DATA_PKT_SZ - ix)) - nbytes = sz; - else - nbytes = DATA_PKT_SZ - ix; - - /* - * Read bytes - */ - if (wilc_spi_rx(wilc, &b[ix], nbytes)) { - dev_err(&spi->dev, - "Failed block read, bus err\n"); - return N_FAIL; - } - - /* - * Read Crc - */ - if (!spi_priv->crc_off && wilc_spi_rx(wilc, crc, 2)) { - dev_err(&spi->dev, - "Failed block crc read, bus err\n"); - return N_FAIL; - } - - ix += nbytes; - sz -= nbytes; - } - - /* - * if any data in left unread, - * then read the rest using normal DMA code. - */ - while (sz > 0) { - int nbytes; - - if (sz <= DATA_PKT_SZ) - nbytes = sz; - else - nbytes = DATA_PKT_SZ; - - /* - * read data response only on the next DMA cycles not - * the first DMA since data response header is already - * handled above for the first DMA. - */ - /* - * Data Respnose header - */ - retry = 10; - do { - if (wilc_spi_rx(wilc, &rsp, 1)) { - dev_err(&spi->dev, - "Failed resp read, bus err\n"); - result = N_FAIL; - break; - } - if (((rsp >> 4) & 0xf) == 0xf) - break; - } while (retry--); - - if (result == N_FAIL) - break; - - /* - * Read bytes - */ - if (wilc_spi_rx(wilc, &b[ix], nbytes)) { - dev_err(&spi->dev, - "Failed block read, bus err\n"); - result = N_FAIL; - break; - } - - /* - * Read Crc - */ - if (!spi_priv->crc_off && wilc_spi_rx(wilc, crc, 2)) { - dev_err(&spi->dev, - "Failed block crc read, bus err\n"); - result = N_FAIL; - break; - } - - ix += nbytes; - sz -= nbytes; - } - } - return result; -} - -static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - int ix, nbytes; - int result = 1; - u8 cmd, order, crc[2] = {0}; - - /* - * Data - */ - ix = 0; - do { - if (sz <= DATA_PKT_SZ) { - nbytes = sz; - order = 0x3; - } else { - nbytes = DATA_PKT_SZ; - if (ix == 0) - order = 0x1; - else - order = 0x02; - } - - /* - * Write command - */ - cmd = 0xf0; - cmd |= order; - - if (wilc_spi_tx(wilc, &cmd, 1)) { - dev_err(&spi->dev, - "Failed data block cmd write, bus error...\n"); - result = N_FAIL; - break; - } - - /* - * Write data - */ - if (wilc_spi_tx(wilc, &b[ix], nbytes)) { - dev_err(&spi->dev, - "Failed data block write, bus error...\n"); - result = N_FAIL; - break; - } - - /* - * Write Crc - */ - if (!spi_priv->crc_off) { - if (wilc_spi_tx(wilc, crc, 2)) { - dev_err(&spi->dev, "Failed data block crc write, bus error...\n"); - result = N_FAIL; - break; - } - } - - /* - * No need to wait for response - */ - ix += nbytes; - sz -= nbytes; - } while (sz); - - return result; -} - -/******************************************** - * - * Spi Internal Read/Write Function - * - ********************************************/ - -static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int result; - - cpu_to_le32s(&dat); - result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4, - 0); - if (result != N_OK) - dev_err(&spi->dev, "Failed internal write cmd...\n"); - - return result; -} - -static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int result; - - result = spi_cmd_complete(wilc, CMD_INTERNAL_READ, adr, (u8 *)data, 4, - 0); - if (result != N_OK) { - dev_err(&spi->dev, "Failed internal read cmd...\n"); - return 0; - } - - le32_to_cpus(data); - - return 1; -} - -/******************************************** - * - * Spi interfaces - * - ********************************************/ - -static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int result = N_OK; - u8 cmd = CMD_SINGLE_WRITE; - u8 clockless = 0; - - cpu_to_le32s(&data); - if (addr < 0x30) { - /* Clockless register */ - cmd = CMD_INTERNAL_WRITE; - clockless = 1; - } - - result = spi_cmd_complete(wilc, cmd, addr, (u8 *)&data, 4, clockless); - if (result != N_OK) - dev_err(&spi->dev, "Failed cmd, write reg (%08x)...\n", addr); - - return result; -} - -static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int result; - - /* - * has to be greated than 4 - */ - if (size <= 4) - return 0; - - result = spi_cmd_complete(wilc, CMD_DMA_EXT_WRITE, addr, NULL, size, 0); - if (result != N_OK) { - dev_err(&spi->dev, - "Failed cmd, write block (%08x)...\n", addr); - return 0; - } - - /* - * Data - */ - result = spi_data_write(wilc, buf, size); - if (result != N_OK) - dev_err(&spi->dev, "Failed block data write...\n"); - - return 1; -} - -static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int result = N_OK; - u8 cmd = CMD_SINGLE_READ; - u8 clockless = 0; - - if (addr < 0x30) { - /* Clockless register */ - cmd = CMD_INTERNAL_READ; - clockless = 1; - } - - result = spi_cmd_complete(wilc, cmd, addr, (u8 *)data, 4, clockless); - if (result != N_OK) { - dev_err(&spi->dev, "Failed cmd, read reg (%08x)...\n", addr); - return 0; - } - - le32_to_cpus(data); - - return 1; -} - -static int wilc_spi_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - int result; - - if (size <= 4) - return 0; - - result = spi_cmd_complete(wilc, CMD_DMA_EXT_READ, addr, buf, size, 0); - if (result != N_OK) { - dev_err(&spi->dev, "Failed cmd, read block (%08x)...\n", addr); - return 0; - } - - return 1; -} - -/******************************************** - * - * Bus interfaces - * - ********************************************/ - -static int wilc_spi_deinit(struct wilc *wilc) -{ - /* - * TODO: - */ - return 1; -} - -static int wilc_spi_init(struct wilc *wilc, bool resume) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - u32 reg; - u32 chipid; - static int isinit; - - if (isinit) { - if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) { - dev_err(&spi->dev, "Fail cmd read chip id...\n"); - return 0; - } - return 1; - } - - /* - * configure protocol - */ - - /* - * TODO: We can remove the CRC trials if there is a definite - * way to reset - */ - /* the SPI to it's initial value. */ - if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, ®)) { - /* - * Read failed. Try with CRC off. This might happen when module - * is removed but chip isn't reset - */ - spi_priv->crc_off = 1; - dev_err(&spi->dev, - "Failed read with CRC on, retrying with CRC off\n"); - if (!spi_internal_read(wilc, WILC_SPI_PROTOCOL_OFFSET, ®)) { - /* - * Read failed with both CRC on and off, - * something went bad - */ - dev_err(&spi->dev, "Failed internal read protocol\n"); - return 0; - } - } - if (spi_priv->crc_off == 0) { - reg &= ~0xc; /* disable crc checking */ - reg &= ~0x70; - reg |= (0x5 << 4); - if (!spi_internal_write(wilc, WILC_SPI_PROTOCOL_OFFSET, reg)) { - dev_err(&spi->dev, - "[wilc spi %d]: Failed internal write reg\n", - __LINE__); - return 0; - } - spi_priv->crc_off = 1; - } - - /* - * make sure can read back chip id correctly - */ - if (!wilc_spi_read_reg(wilc, 0x1000, &chipid)) { - dev_err(&spi->dev, "Fail cmd read chip id...\n"); - return 0; - } - - spi_priv->has_thrpt_enh = 1; - - isinit = 1; - - return 1; -} - -static int wilc_spi_read_size(struct wilc *wilc, u32 *size) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - int ret; - - if (spi_priv->has_thrpt_enh) { - ret = spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, - size); - *size = *size & IRQ_DMA_WD_CNT_MASK; - } else { - u32 tmp; - u32 byte_cnt; - - ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, - &byte_cnt); - if (!ret) { - dev_err(&spi->dev, - "Failed read WILC_VMM_TO_HOST_SIZE ...\n"); - return ret; - } - tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; - *size = tmp; - } - - return ret; -} - -static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - int ret; - u32 tmp; - u32 byte_cnt; - bool unexpected_irq; - int j; - u32 unknown_mask; - u32 irq_flags; - int k = IRG_FLAGS_OFFSET + 5; - - if (spi_priv->has_thrpt_enh) - return spi_internal_read(wilc, 0xe840 - WILC_SPI_REG_BASE, - int_status); - ret = wilc_spi_read_reg(wilc, WILC_VMM_TO_HOST_SIZE, &byte_cnt); - if (!ret) { - dev_err(&spi->dev, - "Failed read WILC_VMM_TO_HOST_SIZE ...\n"); - return ret; - } - tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK; - - j = 0; - do { - wilc_spi_read_reg(wilc, 0x1a90, &irq_flags); - tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET); - - if (spi_priv->nint > 5) { - wilc_spi_read_reg(wilc, 0x1a94, &irq_flags); - tmp |= (((irq_flags >> 0) & 0x7) << k); - } - - unknown_mask = ~((1ul << spi_priv->nint) - 1); - - unexpected_irq = (tmp >> IRG_FLAGS_OFFSET) & unknown_mask; - if (unexpected_irq) { - dev_err(&spi->dev, - "Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n", - j, tmp, unknown_mask); - } - - j++; - } while (unexpected_irq); - - *int_status = tmp; - - return ret; -} - -static int wilc_spi_clear_int_ext(struct wilc *wilc, u32 val) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - int ret; - u32 flags; - u32 tbl_ctl; - - if (spi_priv->has_thrpt_enh) { - return spi_internal_write(wilc, 0xe844 - WILC_SPI_REG_BASE, - val); - } - - flags = val & (BIT(MAX_NUM_INT) - 1); - if (flags) { - int i; - - ret = 1; - for (i = 0; i < spi_priv->nint; i++) { - /* - * No matter what you write 1 or 0, - * it will clear interrupt. - */ - if (flags & 1) - ret = wilc_spi_write_reg(wilc, - 0x10c8 + i * 4, 1); - if (!ret) - break; - flags >>= 1; - } - if (!ret) { - dev_err(&spi->dev, - "Failed wilc_spi_write_reg, set reg %x ...\n", - 0x10c8 + i * 4); - return ret; - } - for (i = spi_priv->nint; i < MAX_NUM_INT; i++) { - if (flags & 1) - dev_err(&spi->dev, - "Unexpected interrupt cleared %d...\n", - i); - flags >>= 1; - } - } - - tbl_ctl = 0; - /* select VMM table 0 */ - if (val & SEL_VMM_TBL0) - tbl_ctl |= BIT(0); - /* select VMM table 1 */ - if (val & SEL_VMM_TBL1) - tbl_ctl |= BIT(1); - - ret = wilc_spi_write_reg(wilc, WILC_VMM_TBL_CTL, tbl_ctl); - if (!ret) { - dev_err(&spi->dev, "fail write reg vmm_tbl_ctl...\n"); - return ret; - } - - if (val & EN_VMM) { - /* - * enable vmm transfer. - */ - ret = wilc_spi_write_reg(wilc, WILC_VMM_CORE_CTL, 1); - if (!ret) { - dev_err(&spi->dev, "fail write reg vmm_core_ctl...\n"); - return ret; - } - } - - return ret; -} - -static int wilc_spi_sync_ext(struct wilc *wilc, int nint) -{ - struct spi_device *spi = to_spi_device(wilc->dev); - struct wilc_spi *spi_priv = wilc->bus_data; - u32 reg; - int ret, i; - - if (nint > MAX_NUM_INT) { - dev_err(&spi->dev, "Too many interrupts (%d)...\n", nint); - return 0; - } - - spi_priv->nint = nint; - - /* - * interrupt pin mux select - */ - ret = wilc_spi_read_reg(wilc, WILC_PIN_MUX_0, ®); - if (!ret) { - dev_err(&spi->dev, "Failed read reg (%08x)...\n", - WILC_PIN_MUX_0); - return 0; - } - reg |= BIT(8); - ret = wilc_spi_write_reg(wilc, WILC_PIN_MUX_0, reg); - if (!ret) { - dev_err(&spi->dev, "Failed write reg (%08x)...\n", - WILC_PIN_MUX_0); - return 0; - } - - /* - * interrupt enable - */ - ret = wilc_spi_read_reg(wilc, WILC_INTR_ENABLE, ®); - if (!ret) { - dev_err(&spi->dev, "Failed read reg (%08x)...\n", - WILC_INTR_ENABLE); - return 0; - } - - for (i = 0; (i < 5) && (nint > 0); i++, nint--) - reg |= (BIT((27 + i))); - - ret = wilc_spi_write_reg(wilc, WILC_INTR_ENABLE, reg); - if (!ret) { - dev_err(&spi->dev, "Failed write reg (%08x)...\n", - WILC_INTR_ENABLE); - return 0; - } - if (nint) { - ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®); - if (!ret) { - dev_err(&spi->dev, "Failed read reg (%08x)...\n", - WILC_INTR2_ENABLE); - return 0; - } - - for (i = 0; (i < 3) && (nint > 0); i++, nint--) - reg |= BIT(i); - - ret = wilc_spi_read_reg(wilc, WILC_INTR2_ENABLE, ®); - if (!ret) { - dev_err(&spi->dev, "Failed write reg (%08x)...\n", - WILC_INTR2_ENABLE); - return 0; - } - } - - return 1; -} - -/* Global spi HIF function table */ -static const struct wilc_hif_func wilc_hif_spi = { - .hif_init = wilc_spi_init, - .hif_deinit = wilc_spi_deinit, - .hif_read_reg = wilc_spi_read_reg, - .hif_write_reg = wilc_spi_write_reg, - .hif_block_rx = wilc_spi_read, - .hif_block_tx = wilc_spi_write, - .hif_read_int = wilc_spi_read_int, - .hif_clear_int_ext = wilc_spi_clear_int_ext, - .hif_read_size = wilc_spi_read_size, - .hif_block_tx_ext = wilc_spi_write, - .hif_block_rx_ext = wilc_spi_read, - .hif_sync_ext = wilc_spi_sync_ext, -}; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c deleted file mode 100644 index 66328ac85adc..000000000000 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ /dev/null @@ -1,1960 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include "wilc_wfi_cfgoperations.h" - -#define FRAME_TYPE_ID 0 -#define ACTION_CAT_ID 24 -#define ACTION_SUBTYPE_ID 25 -#define P2P_PUB_ACTION_SUBTYPE 30 - -#define ACTION_FRAME 0xd0 -#define GO_INTENT_ATTR_ID 0x04 -#define CHANLIST_ATTR_ID 0x0b -#define OPERCHAN_ATTR_ID 0x11 -#define PUB_ACTION_ATTR_ID 0x04 -#define P2PELEM_ATTR_ID 0xdd - -#define GO_NEG_REQ 0x00 -#define GO_NEG_RSP 0x01 -#define GO_NEG_CONF 0x02 -#define P2P_INV_REQ 0x03 -#define P2P_INV_RSP 0x04 -#define PUBLIC_ACT_VENDORSPEC 0x09 -#define GAS_INITIAL_REQ 0x0a -#define GAS_INITIAL_RSP 0x0b - -#define WILC_INVALID_CHANNEL 0 - -static const struct ieee80211_txrx_stypes - wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { - [NL80211_IFTYPE_STATION] = { - .tx = 0xffff, - .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | - BIT(IEEE80211_STYPE_PROBE_REQ >> 4) - }, - [NL80211_IFTYPE_AP] = { - .tx = 0xffff, - .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | - BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | - BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | - BIT(IEEE80211_STYPE_DISASSOC >> 4) | - BIT(IEEE80211_STYPE_AUTH >> 4) | - BIT(IEEE80211_STYPE_DEAUTH >> 4) | - BIT(IEEE80211_STYPE_ACTION >> 4) - }, - [NL80211_IFTYPE_P2P_CLIENT] = { - .tx = 0xffff, - .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | - BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | - BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | - BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | - BIT(IEEE80211_STYPE_DISASSOC >> 4) | - BIT(IEEE80211_STYPE_AUTH >> 4) | - BIT(IEEE80211_STYPE_DEAUTH >> 4) - } -}; - -static const struct wiphy_wowlan_support wowlan_support = { - .flags = WIPHY_WOWLAN_ANY -}; - -struct wilc_p2p_mgmt_data { - int size; - u8 *buff; -}; - -static const u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; -static const u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; - -static void cfg_scan_result(enum scan_event scan_event, - struct wilc_rcvd_net_info *info, void *user_void) -{ - struct wilc_priv *priv = user_void; - - if (!priv->cfg_scanning) - return; - - if (scan_event == SCAN_EVENT_NETWORK_FOUND) { - s32 freq; - struct ieee80211_channel *channel; - struct cfg80211_bss *bss; - struct wiphy *wiphy = priv->dev->ieee80211_ptr->wiphy; - - if (!wiphy || !info) - return; - - freq = ieee80211_channel_to_frequency((s32)info->ch, - NL80211_BAND_2GHZ); - channel = ieee80211_get_channel(wiphy, freq); - if (!channel) - return; - - bss = cfg80211_inform_bss_frame(wiphy, channel, info->mgmt, - info->frame_len, - (s32)info->rssi * 100, - GFP_KERNEL); - if (!bss) - cfg80211_put_bss(wiphy, bss); - } else if (scan_event == SCAN_EVENT_DONE) { - mutex_lock(&priv->scan_req_lock); - - if (priv->scan_req) { - struct cfg80211_scan_info info = { - .aborted = false, - }; - - cfg80211_scan_done(priv->scan_req, &info); - priv->cfg_scanning = false; - priv->scan_req = NULL; - } - mutex_unlock(&priv->scan_req_lock); - } else if (scan_event == SCAN_EVENT_ABORTED) { - mutex_lock(&priv->scan_req_lock); - - if (priv->scan_req) { - struct cfg80211_scan_info info = { - .aborted = false, - }; - - cfg80211_scan_done(priv->scan_req, &info); - priv->cfg_scanning = false; - priv->scan_req = NULL; - } - mutex_unlock(&priv->scan_req_lock); - } -} - -static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status, - void *priv_data) -{ - struct wilc_priv *priv = priv_data; - struct net_device *dev = priv->dev; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; - struct host_if_drv *wfi_drv = priv->hif_drv; - struct wilc_conn_info *conn_info = &wfi_drv->conn_info; - struct wiphy *wiphy = dev->ieee80211_ptr->wiphy; - - vif->connecting = false; - - if (conn_disconn_evt == CONN_DISCONN_EVENT_CONN_RESP) { - u16 connect_status = conn_info->status; - - if (mac_status == WILC_MAC_STATUS_DISCONNECTED && - connect_status == WLAN_STATUS_SUCCESS) { - connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE; - wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); - - if (vif->iftype != WILC_CLIENT_MODE) - wl->sta_ch = WILC_INVALID_CHANNEL; - - netdev_err(dev, "Unspecified failure\n"); - } - - if (connect_status == WLAN_STATUS_SUCCESS) - memcpy(priv->associated_bss, conn_info->bssid, - ETH_ALEN); - - cfg80211_ref_bss(wiphy, vif->bss); - cfg80211_connect_bss(dev, conn_info->bssid, vif->bss, - conn_info->req_ies, - conn_info->req_ies_len, - conn_info->resp_ies, - conn_info->resp_ies_len, - connect_status, GFP_KERNEL, - NL80211_TIMEOUT_UNSPECIFIED); - - vif->bss = NULL; - } else if (conn_disconn_evt == CONN_DISCONN_EVENT_DISCONN_NOTIF) { - u16 reason = 0; - - priv->p2p.local_random = 0x01; - priv->p2p.recv_random = 0x00; - priv->p2p.is_wilc_ie = false; - eth_zero_addr(priv->associated_bss); - wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); - - if (vif->iftype != WILC_CLIENT_MODE) { - wl->sta_ch = WILC_INVALID_CHANNEL; - } else { - if (wfi_drv->ifc_up) - reason = 3; - else - reason = 1; - } - - cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL); - } -} - -struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl) -{ - struct wilc_vif *vif; - - vif = list_first_or_null_rcu(&wl->vif_list, typeof(*vif), list); - if (!vif) - return ERR_PTR(-EINVAL); - - return vif; -} - -static int set_channel(struct wiphy *wiphy, - struct cfg80211_chan_def *chandef) -{ - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif; - u32 channelnum; - int result; - int srcu_idx; - - srcu_idx = srcu_read_lock(&wl->srcu); - vif = wilc_get_wl_to_vif(wl); - if (IS_ERR(vif)) { - srcu_read_unlock(&wl->srcu, srcu_idx); - return PTR_ERR(vif); - } - - channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); - - wl->op_ch = channelnum; - result = wilc_set_mac_chnl_num(vif, channelnum); - if (result) - netdev_err(vif->ndev, "Error in setting channel\n"); - - srcu_read_unlock(&wl->srcu, srcu_idx); - return result; -} - -static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) -{ - struct wilc_vif *vif = netdev_priv(request->wdev->netdev); - struct wilc_priv *priv = &vif->priv; - u32 i; - int ret = 0; - u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH]; - u8 scan_type; - - if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) { - netdev_err(vif->ndev, "Requested scanned channels over\n"); - return -EINVAL; - } - - priv->scan_req = request; - priv->cfg_scanning = true; - for (i = 0; i < request->n_channels; i++) { - u16 freq = request->channels[i]->center_freq; - - scan_ch_list[i] = ieee80211_frequency_to_channel(freq); - } - - if (request->n_ssids) - scan_type = WILC_FW_ACTIVE_SCAN; - else - scan_type = WILC_FW_PASSIVE_SCAN; - - ret = wilc_scan(vif, WILC_FW_USER_SCAN, scan_type, scan_ch_list, - request->n_channels, cfg_scan_result, (void *)priv, - request); - - if (ret) { - priv->scan_req = NULL; - priv->cfg_scanning = false; - } - - return ret; -} - -static int connect(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_connect_params *sme) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - struct host_if_drv *wfi_drv = priv->hif_drv; - int ret; - u32 i; - u8 security = WILC_FW_SEC_NO; - enum authtype auth_type = WILC_FW_AUTH_ANY; - u32 cipher_group; - struct cfg80211_bss *bss; - void *join_params; - u8 ch; - - vif->connecting = true; - - memset(priv->wep_key, 0, sizeof(priv->wep_key)); - memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len)); - - cipher_group = sme->crypto.cipher_group; - if (cipher_group != 0) { - if (cipher_group == WLAN_CIPHER_SUITE_WEP40) { - security = WILC_FW_SEC_WEP; - - priv->wep_key_len[sme->key_idx] = sme->key_len; - memcpy(priv->wep_key[sme->key_idx], sme->key, - sme->key_len); - - wilc_set_wep_default_keyid(vif, sme->key_idx); - wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, - sme->key_idx); - } else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) { - security = WILC_FW_SEC_WEP_EXTENDED; - - priv->wep_key_len[sme->key_idx] = sme->key_len; - memcpy(priv->wep_key[sme->key_idx], sme->key, - sme->key_len); - - wilc_set_wep_default_keyid(vif, sme->key_idx); - wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, - sme->key_idx); - } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { - if (cipher_group == WLAN_CIPHER_SUITE_TKIP) - security = WILC_FW_SEC_WPA2_TKIP; - else - security = WILC_FW_SEC_WPA2_AES; - } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { - if (cipher_group == WLAN_CIPHER_SUITE_TKIP) - security = WILC_FW_SEC_WPA_TKIP; - else - security = WILC_FW_SEC_WPA_AES; - } else { - ret = -ENOTSUPP; - netdev_err(dev, "%s: Unsupported cipher\n", - __func__); - goto out_error; - } - } - - if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) || - (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { - for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { - u32 ciphers_pairwise = sme->crypto.ciphers_pairwise[i]; - - if (ciphers_pairwise == WLAN_CIPHER_SUITE_TKIP) - security |= WILC_FW_TKIP; - else - security |= WILC_FW_AES; - } - } - - switch (sme->auth_type) { - case NL80211_AUTHTYPE_OPEN_SYSTEM: - auth_type = WILC_FW_AUTH_OPEN_SYSTEM; - break; - - case NL80211_AUTHTYPE_SHARED_KEY: - auth_type = WILC_FW_AUTH_SHARED_KEY; - break; - - default: - break; - } - - if (sme->crypto.n_akm_suites) { - if (sme->crypto.akm_suites[0] == WLAN_AKM_SUITE_8021X) - auth_type = WILC_FW_AUTH_IEEE8021; - } - - if (wfi_drv->usr_scan_req.scan_result) { - netdev_err(vif->ndev, "%s: Scan in progress\n", __func__); - ret = -EBUSY; - goto out_error; - } - - bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, sme->ssid, - sme->ssid_len, IEEE80211_BSS_TYPE_ANY, - IEEE80211_PRIVACY(sme->privacy)); - if (!bss) { - ret = -EINVAL; - goto out_error; - } - - if (ether_addr_equal_unaligned(vif->bssid, bss->bssid)) { - ret = -EALREADY; - goto out_put_bss; - } - - join_params = wilc_parse_join_bss_param(bss, &sme->crypto); - if (!join_params) { - netdev_err(dev, "%s: failed to construct join param\n", - __func__); - ret = -EINVAL; - goto out_put_bss; - } - - ch = ieee80211_frequency_to_channel(bss->channel->center_freq); - vif->wilc->op_ch = ch; - if (vif->iftype != WILC_CLIENT_MODE) - vif->wilc->sta_ch = ch; - - wilc_wlan_set_bssid(dev, bss->bssid, WILC_STATION_MODE); - - wfi_drv->conn_info.security = security; - wfi_drv->conn_info.auth_type = auth_type; - wfi_drv->conn_info.ch = ch; - wfi_drv->conn_info.conn_result = cfg_connect_result; - wfi_drv->conn_info.arg = priv; - wfi_drv->conn_info.param = join_params; - - ret = wilc_set_join_req(vif, bss->bssid, sme->ie, sme->ie_len); - if (ret) { - netdev_err(dev, "wilc_set_join_req(): Error\n"); - ret = -ENOENT; - if (vif->iftype != WILC_CLIENT_MODE) - vif->wilc->sta_ch = WILC_INVALID_CHANNEL; - wilc_wlan_set_bssid(dev, NULL, WILC_STATION_MODE); - wfi_drv->conn_info.conn_result = NULL; - kfree(join_params); - goto out_put_bss; - } - kfree(join_params); - vif->bss = bss; - cfg80211_put_bss(wiphy, bss); - return 0; - -out_put_bss: - cfg80211_put_bss(wiphy, bss); - -out_error: - vif->connecting = false; - return ret; -} - -static int disconnect(struct wiphy *wiphy, struct net_device *dev, - u16 reason_code) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - struct wilc *wilc = vif->wilc; - int ret; - - vif->connecting = false; - - if (!wilc) - return -EIO; - - if (wilc->close) { - /* already disconnected done */ - cfg80211_disconnected(dev, 0, NULL, 0, true, GFP_KERNEL); - return 0; - } - - if (vif->iftype != WILC_CLIENT_MODE) - wilc->sta_ch = WILC_INVALID_CHANNEL; - wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); - - priv->p2p.local_random = 0x01; - priv->p2p.recv_random = 0x00; - priv->p2p.is_wilc_ie = false; - priv->hif_drv->p2p_timeout = 0; - - ret = wilc_disconnect(vif); - if (ret != 0) { - netdev_err(priv->dev, "Error in disconnecting\n"); - ret = -EINVAL; - } - - vif->bss = NULL; - - return ret; -} - -static inline void wilc_wfi_cfg_copy_wep_info(struct wilc_priv *priv, - u8 key_index, - struct key_params *params) -{ - priv->wep_key_len[key_index] = params->key_len; - memcpy(priv->wep_key[key_index], params->key, params->key_len); -} - -static int wilc_wfi_cfg_allocate_wpa_entry(struct wilc_priv *priv, u8 idx) -{ - if (!priv->wilc_gtk[idx]) { - priv->wilc_gtk[idx] = kzalloc(sizeof(*priv->wilc_gtk[idx]), - GFP_KERNEL); - if (!priv->wilc_gtk[idx]) - return -ENOMEM; - } - - if (!priv->wilc_ptk[idx]) { - priv->wilc_ptk[idx] = kzalloc(sizeof(*priv->wilc_ptk[idx]), - GFP_KERNEL); - if (!priv->wilc_ptk[idx]) - return -ENOMEM; - } - - return 0; -} - -static int wilc_wfi_cfg_copy_wpa_info(struct wilc_wfi_key *key_info, - struct key_params *params) -{ - kfree(key_info->key); - - key_info->key = kmemdup(params->key, params->key_len, GFP_KERNEL); - if (!key_info->key) - return -ENOMEM; - - kfree(key_info->seq); - - if (params->seq_len > 0) { - key_info->seq = kmemdup(params->seq, params->seq_len, - GFP_KERNEL); - if (!key_info->seq) - return -ENOMEM; - } - - key_info->cipher = params->cipher; - key_info->key_len = params->key_len; - key_info->seq_len = params->seq_len; - - return 0; -} - -static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, - bool pairwise, const u8 *mac_addr, struct key_params *params) - -{ - int ret = 0, keylen = params->key_len; - const u8 *rx_mic = NULL; - const u8 *tx_mic = NULL; - u8 mode = WILC_FW_SEC_NO; - u8 op_mode; - struct wilc_vif *vif = netdev_priv(netdev); - struct wilc_priv *priv = &vif->priv; - - switch (params->cipher) { - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - if (priv->wdev.iftype == NL80211_IFTYPE_AP) { - wilc_wfi_cfg_copy_wep_info(priv, key_index, params); - - if (params->cipher == WLAN_CIPHER_SUITE_WEP40) - mode = WILC_FW_SEC_WEP; - else - mode = WILC_FW_SEC_WEP_EXTENDED; - - ret = wilc_add_wep_key_bss_ap(vif, params->key, - params->key_len, - key_index, mode, - WILC_FW_AUTH_OPEN_SYSTEM); - break; - } - if (memcmp(params->key, priv->wep_key[key_index], - params->key_len)) { - wilc_wfi_cfg_copy_wep_info(priv, key_index, params); - - ret = wilc_add_wep_key_bss_sta(vif, params->key, - params->key_len, - key_index); - } - - break; - - case WLAN_CIPHER_SUITE_TKIP: - case WLAN_CIPHER_SUITE_CCMP: - if (priv->wdev.iftype == NL80211_IFTYPE_AP || - priv->wdev.iftype == NL80211_IFTYPE_P2P_GO) { - struct wilc_wfi_key *key; - - ret = wilc_wfi_cfg_allocate_wpa_entry(priv, key_index); - if (ret) - return -ENOMEM; - - if (params->key_len > 16 && - params->cipher == WLAN_CIPHER_SUITE_TKIP) { - tx_mic = params->key + 24; - rx_mic = params->key + 16; - keylen = params->key_len - 16; - } - - if (!pairwise) { - if (params->cipher == WLAN_CIPHER_SUITE_TKIP) - mode = WILC_FW_SEC_WPA_TKIP; - else - mode = WILC_FW_SEC_WPA2_AES; - - priv->wilc_groupkey = mode; - - key = priv->wilc_gtk[key_index]; - } else { - if (params->cipher == WLAN_CIPHER_SUITE_TKIP) - mode = WILC_FW_SEC_WPA_TKIP; - else - mode = priv->wilc_groupkey | WILC_FW_AES; - - key = priv->wilc_ptk[key_index]; - } - ret = wilc_wfi_cfg_copy_wpa_info(key, params); - if (ret) - return -ENOMEM; - - op_mode = WILC_AP_MODE; - } else { - if (params->key_len > 16 && - params->cipher == WLAN_CIPHER_SUITE_TKIP) { - rx_mic = params->key + 24; - tx_mic = params->key + 16; - keylen = params->key_len - 16; - } - - op_mode = WILC_STATION_MODE; - } - - if (!pairwise) - ret = wilc_add_rx_gtk(vif, params->key, keylen, - key_index, params->seq_len, - params->seq, rx_mic, tx_mic, - op_mode, mode); - else - ret = wilc_add_ptk(vif, params->key, keylen, mac_addr, - rx_mic, tx_mic, op_mode, mode, - key_index); - - break; - - default: - netdev_err(netdev, "%s: Unsupported cipher\n", __func__); - ret = -ENOTSUPP; - } - - return ret; -} - -static int del_key(struct wiphy *wiphy, struct net_device *netdev, - u8 key_index, - bool pairwise, - const u8 *mac_addr) -{ - struct wilc_vif *vif = netdev_priv(netdev); - struct wilc_priv *priv = &vif->priv; - - if (priv->wilc_gtk[key_index]) { - kfree(priv->wilc_gtk[key_index]->key); - priv->wilc_gtk[key_index]->key = NULL; - kfree(priv->wilc_gtk[key_index]->seq); - priv->wilc_gtk[key_index]->seq = NULL; - - kfree(priv->wilc_gtk[key_index]); - priv->wilc_gtk[key_index] = NULL; - } - - if (priv->wilc_ptk[key_index]) { - kfree(priv->wilc_ptk[key_index]->key); - priv->wilc_ptk[key_index]->key = NULL; - kfree(priv->wilc_ptk[key_index]->seq); - priv->wilc_ptk[key_index]->seq = NULL; - kfree(priv->wilc_ptk[key_index]); - priv->wilc_ptk[key_index] = NULL; - } - - if (key_index <= 3 && priv->wep_key_len[key_index]) { - memset(priv->wep_key[key_index], 0, - priv->wep_key_len[key_index]); - priv->wep_key_len[key_index] = 0; - wilc_remove_wep_key(vif, key_index); - } - - return 0; -} - -static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, - bool pairwise, const u8 *mac_addr, void *cookie, - void (*callback)(void *cookie, struct key_params *)) -{ - struct wilc_vif *vif = netdev_priv(netdev); - struct wilc_priv *priv = &vif->priv; - struct key_params key_params; - - if (!pairwise) { - key_params.key = priv->wilc_gtk[key_index]->key; - key_params.cipher = priv->wilc_gtk[key_index]->cipher; - key_params.key_len = priv->wilc_gtk[key_index]->key_len; - key_params.seq = priv->wilc_gtk[key_index]->seq; - key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; - } else { - key_params.key = priv->wilc_ptk[key_index]->key; - key_params.cipher = priv->wilc_ptk[key_index]->cipher; - key_params.key_len = priv->wilc_ptk[key_index]->key_len; - key_params.seq = priv->wilc_ptk[key_index]->seq; - key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; - } - - callback(cookie, &key_params); - - return 0; -} - -static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, - u8 key_index, bool unicast, bool multicast) -{ - struct wilc_vif *vif = netdev_priv(netdev); - - wilc_set_wep_default_keyid(vif, key_index); - - return 0; -} - -static int get_station(struct wiphy *wiphy, struct net_device *dev, - const u8 *mac, struct station_info *sinfo) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - u32 i = 0; - u32 associatedsta = ~0; - u32 inactive_time = 0; - - if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { - for (i = 0; i < NUM_STA_ASSOCIATED; i++) { - if (!(memcmp(mac, - priv->assoc_stainfo.sta_associated_bss[i], - ETH_ALEN))) { - associatedsta = i; - break; - } - } - - if (associatedsta == ~0) { - netdev_err(dev, "sta required is not associated\n"); - return -ENOENT; - } - - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME); - - wilc_get_inactive_time(vif, mac, &inactive_time); - sinfo->inactive_time = 1000 * inactive_time; - } else if (vif->iftype == WILC_STATION_MODE) { - struct rf_info stats; - - wilc_get_statistics(vif, &stats); - - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL) | - BIT_ULL(NL80211_STA_INFO_RX_PACKETS) | - BIT_ULL(NL80211_STA_INFO_TX_PACKETS) | - BIT_ULL(NL80211_STA_INFO_TX_FAILED) | - BIT_ULL(NL80211_STA_INFO_TX_BITRATE); - - sinfo->signal = stats.rssi; - sinfo->rx_packets = stats.rx_cnt; - sinfo->tx_packets = stats.tx_cnt + stats.tx_fail_cnt; - sinfo->tx_failed = stats.tx_fail_cnt; - sinfo->txrate.legacy = stats.link_speed * 10; - - if (stats.link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && - stats.link_speed != DEFAULT_LINK_SPEED) - wilc_enable_tcp_ack_filter(vif, true); - else if (stats.link_speed != DEFAULT_LINK_SPEED) - wilc_enable_tcp_ack_filter(vif, false); - } - return 0; -} - -static int change_bss(struct wiphy *wiphy, struct net_device *dev, - struct bss_parameters *params) -{ - return 0; -} - -static int set_wiphy_params(struct wiphy *wiphy, u32 changed) -{ - int ret = -EINVAL; - struct cfg_param_attr cfg_param_val; - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif; - struct wilc_priv *priv; - int srcu_idx; - - srcu_idx = srcu_read_lock(&wl->srcu); - vif = wilc_get_wl_to_vif(wl); - if (IS_ERR(vif)) - goto out; - - priv = &vif->priv; - cfg_param_val.flag = 0; - - if (changed & WIPHY_PARAM_RETRY_SHORT) { - netdev_dbg(vif->ndev, - "Setting WIPHY_PARAM_RETRY_SHORT %d\n", - wiphy->retry_short); - cfg_param_val.flag |= WILC_CFG_PARAM_RETRY_SHORT; - cfg_param_val.short_retry_limit = wiphy->retry_short; - } - if (changed & WIPHY_PARAM_RETRY_LONG) { - netdev_dbg(vif->ndev, - "Setting WIPHY_PARAM_RETRY_LONG %d\n", - wiphy->retry_long); - cfg_param_val.flag |= WILC_CFG_PARAM_RETRY_LONG; - cfg_param_val.long_retry_limit = wiphy->retry_long; - } - if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { - if (wiphy->frag_threshold > 255 && - wiphy->frag_threshold < 7937) { - netdev_dbg(vif->ndev, - "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", - wiphy->frag_threshold); - cfg_param_val.flag |= WILC_CFG_PARAM_FRAG_THRESHOLD; - cfg_param_val.frag_threshold = wiphy->frag_threshold; - } else { - netdev_err(vif->ndev, - "Fragmentation threshold out of range\n"); - goto out; - } - } - - if (changed & WIPHY_PARAM_RTS_THRESHOLD) { - if (wiphy->rts_threshold > 255) { - netdev_dbg(vif->ndev, - "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", - wiphy->rts_threshold); - cfg_param_val.flag |= WILC_CFG_PARAM_RTS_THRESHOLD; - cfg_param_val.rts_threshold = wiphy->rts_threshold; - } else { - netdev_err(vif->ndev, "RTS threshold out of range\n"); - goto out; - } - } - - ret = wilc_hif_set_cfg(vif, &cfg_param_val); - if (ret) - netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n"); - -out: - srcu_read_unlock(&wl->srcu, srcu_idx); - return ret; -} - -static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, - struct cfg80211_pmksa *pmksa) -{ - struct wilc_vif *vif = netdev_priv(netdev); - struct wilc_priv *priv = &vif->priv; - u32 i; - int ret = 0; - u8 flag = 0; - - for (i = 0; i < priv->pmkid_list.numpmkid; i++) { - if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, - ETH_ALEN)) { - flag = PMKID_FOUND; - break; - } - } - if (i < WILC_MAX_NUM_PMKIDS) { - memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, - ETH_ALEN); - memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, - WLAN_PMKID_LEN); - if (!(flag == PMKID_FOUND)) - priv->pmkid_list.numpmkid++; - } else { - netdev_err(netdev, "Invalid PMKID index\n"); - ret = -EINVAL; - } - - if (!ret) - ret = wilc_set_pmkid_info(vif, &priv->pmkid_list); - - return ret; -} - -static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, - struct cfg80211_pmksa *pmksa) -{ - u32 i; - int ret = 0; - struct wilc_vif *vif = netdev_priv(netdev); - struct wilc_priv *priv = &vif->priv; - - for (i = 0; i < priv->pmkid_list.numpmkid; i++) { - if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, - ETH_ALEN)) { - memset(&priv->pmkid_list.pmkidlist[i], 0, - sizeof(struct wilc_pmkid)); - break; - } - } - - if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { - for (; i < (priv->pmkid_list.numpmkid - 1); i++) { - memcpy(priv->pmkid_list.pmkidlist[i].bssid, - priv->pmkid_list.pmkidlist[i + 1].bssid, - ETH_ALEN); - memcpy(priv->pmkid_list.pmkidlist[i].pmkid, - priv->pmkid_list.pmkidlist[i + 1].pmkid, - WLAN_PMKID_LEN); - } - priv->pmkid_list.numpmkid--; - } else { - ret = -EINVAL; - } - - return ret; -} - -static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) -{ - struct wilc_vif *vif = netdev_priv(netdev); - - memset(&vif->priv.pmkid_list, 0, sizeof(struct wilc_pmkid_attr)); - - return 0; -} - -static inline void wilc_wfi_cfg_parse_ch_attr(u8 *buf, u8 ch_list_attr_idx, - u8 op_ch_attr_idx, u8 sta_ch) -{ - int i = 0; - int j = 0; - - if (ch_list_attr_idx) { - u8 limit = ch_list_attr_idx + 3 + buf[ch_list_attr_idx + 1]; - - for (i = ch_list_attr_idx + 3; i < limit; i++) { - if (buf[i] == 0x51) { - for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) - buf[j] = sta_ch; - break; - } - } - } - - if (op_ch_attr_idx) { - buf[op_ch_attr_idx + 6] = 0x51; - buf[op_ch_attr_idx + 7] = sta_ch; - } -} - -static void wilc_wfi_cfg_parse_rx_action(u8 *buf, u32 len, u8 sta_ch) -{ - u32 index = 0; - u8 op_channel_attr_index = 0; - u8 channel_list_attr_index = 0; - - while (index < len) { - if (buf[index] == GO_INTENT_ATTR_ID) - buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); - - if (buf[index] == CHANLIST_ATTR_ID) - channel_list_attr_index = index; - else if (buf[index] == OPERCHAN_ATTR_ID) - op_channel_attr_index = index; - index += buf[index + 1] + 3; - } - if (sta_ch != WILC_INVALID_CHANNEL) - wilc_wfi_cfg_parse_ch_attr(buf, channel_list_attr_index, - op_channel_attr_index, sta_ch); -} - -static void wilc_wfi_cfg_parse_tx_action(u8 *buf, u32 len, bool oper_ch, - u8 iftype, u8 sta_ch) -{ - u32 index = 0; - u8 op_channel_attr_index = 0; - u8 channel_list_attr_index = 0; - - while (index < len) { - if (buf[index] == GO_INTENT_ATTR_ID) { - buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); - - break; - } - - if (buf[index] == CHANLIST_ATTR_ID) - channel_list_attr_index = index; - else if (buf[index] == OPERCHAN_ATTR_ID) - op_channel_attr_index = index; - index += buf[index + 1] + 3; - } - if (sta_ch != WILC_INVALID_CHANNEL && oper_ch) - wilc_wfi_cfg_parse_ch_attr(buf, channel_list_attr_index, - op_channel_attr_index, sta_ch); -} - -static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff, - u32 size) -{ - int i; - u8 subtype; - struct wilc_vif *vif = netdev_priv(priv->dev); - - subtype = buff[P2P_PUB_ACTION_SUBTYPE]; - if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && - !priv->p2p.is_wilc_ie) { - for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { - if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { - priv->p2p.recv_random = buff[i + 6]; - priv->p2p.is_wilc_ie = true; - break; - } - } - } - - if (priv->p2p.local_random <= priv->p2p.recv_random) { - netdev_dbg(vif->ndev, - "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", - priv->p2p.local_random, priv->p2p.recv_random); - return; - } - - if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP || - subtype == P2P_INV_REQ || subtype == P2P_INV_RSP) { - for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { - if (buff[i] == P2PELEM_ATTR_ID && - !(memcmp(p2p_oui, &buff[i + 2], 4))) { - wilc_wfi_cfg_parse_rx_action(&buff[i + 6], - size - (i + 6), - vif->wilc->sta_ch); - break; - } - } - } -} - -void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) -{ - struct wilc *wl = vif->wilc; - struct wilc_priv *priv = &vif->priv; - struct host_if_drv *wfi_drv = priv->hif_drv; - u32 header, pkt_offset; - s32 freq; - __le16 fc; - - header = get_unaligned_le32(buff - HOST_HDR_OFFSET); - pkt_offset = GET_PKT_OFFSET(header); - - if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { - bool ack = false; - - if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP || - pkt_offset & IS_MGMT_STATUS_SUCCES) - ack = true; - - cfg80211_mgmt_tx_status(&priv->wdev, priv->tx_cookie, buff, - size, ack, GFP_KERNEL); - return; - } - - freq = ieee80211_channel_to_frequency(wl->op_ch, NL80211_BAND_2GHZ); - - fc = ((struct ieee80211_hdr *)buff)->frame_control; - if (!ieee80211_is_action(fc)) { - cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); - return; - } - - if (priv->cfg_scanning && - time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) { - netdev_dbg(vif->ndev, "Receiving action wrong ch\n"); - return; - } - if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { - u8 subtype = buff[P2P_PUB_ACTION_SUBTYPE]; - - switch (buff[ACTION_SUBTYPE_ID]) { - case GAS_INITIAL_REQ: - case GAS_INITIAL_RSP: - break; - - case PUBLIC_ACT_VENDORSPEC: - if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) - wilc_wfi_cfg_parse_rx_vendor_spec(priv, buff, - size); - - if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && - priv->p2p.is_wilc_ie) - size -= 7; - - break; - - default: - netdev_dbg(vif->ndev, - "%s: Not handled action frame type:%x\n", - __func__, buff[ACTION_SUBTYPE_ID]); - break; - } - } - - cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); -} - -static void wilc_wfi_mgmt_tx_complete(void *priv, int status) -{ - struct wilc_p2p_mgmt_data *pv_data = priv; - - kfree(pv_data->buff); - kfree(pv_data); -} - -static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) -{ - struct wilc_vif *vif = data; - struct wilc_priv *priv = &vif->priv; - struct wilc_wfi_p2p_listen_params *params = &priv->remain_on_ch_params; - - if (cookie != params->listen_cookie) - return; - - priv->p2p_listen_state = false; - - cfg80211_remain_on_channel_expired(&priv->wdev, params->listen_cookie, - params->listen_ch, GFP_KERNEL); -} - -static int remain_on_channel(struct wiphy *wiphy, - struct wireless_dev *wdev, - struct ieee80211_channel *chan, - unsigned int duration, u64 *cookie) -{ - int ret = 0; - struct wilc_vif *vif = netdev_priv(wdev->netdev); - struct wilc_priv *priv = &vif->priv; - u64 id; - - if (wdev->iftype == NL80211_IFTYPE_AP) { - netdev_dbg(vif->ndev, "Required while in AP mode\n"); - return ret; - } - - id = ++priv->inc_roc_cookie; - if (id == 0) - id = ++priv->inc_roc_cookie; - - ret = wilc_remain_on_channel(vif, id, duration, chan->hw_value, - wilc_wfi_remain_on_channel_expired, - (void *)vif); - if (ret) - return ret; - - vif->wilc->op_ch = chan->hw_value; - - priv->remain_on_ch_params.listen_ch = chan; - priv->remain_on_ch_params.listen_cookie = id; - *cookie = id; - priv->p2p_listen_state = true; - priv->remain_on_ch_params.listen_duration = duration; - - cfg80211_ready_on_channel(wdev, *cookie, chan, duration, GFP_KERNEL); - mod_timer(&vif->hif_drv->remain_on_ch_timer, - jiffies + msecs_to_jiffies(duration + 1000)); - - return ret; -} - -static int cancel_remain_on_channel(struct wiphy *wiphy, - struct wireless_dev *wdev, - u64 cookie) -{ - struct wilc_vif *vif = netdev_priv(wdev->netdev); - struct wilc_priv *priv = &vif->priv; - - if (cookie != priv->remain_on_ch_params.listen_cookie) - return -ENOENT; - - return wilc_listen_state_expired(vif, cookie); -} - -static void wilc_wfi_cfg_tx_vendor_spec(struct wilc_priv *priv, - struct wilc_p2p_mgmt_data *mgmt_tx, - struct cfg80211_mgmt_tx_params *params, - u8 iftype, u32 buf_len) -{ - const u8 *buf = params->buf; - size_t len = params->len; - u32 i; - u8 subtype = buf[P2P_PUB_ACTION_SUBTYPE]; - struct wilc_vif *vif = netdev_priv(priv->dev); - - if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) { - if (priv->p2p.local_random == 1 && - priv->p2p.recv_random < priv->p2p.local_random) { - get_random_bytes(&priv->p2p.local_random, 1); - priv->p2p.local_random++; - } - } - - if (priv->p2p.local_random <= priv->p2p.recv_random || - !(subtype == GO_NEG_REQ || subtype == GO_NEG_RSP || - subtype == P2P_INV_REQ || subtype == P2P_INV_RSP)) - return; - - for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { - if (buf[i] == P2PELEM_ATTR_ID && - !memcmp(p2p_oui, &buf[i + 2], 4)) { - bool oper_ch = false; - u8 *tx_buff = &mgmt_tx->buff[i + 6]; - - if (subtype == P2P_INV_REQ || subtype == P2P_INV_RSP) - oper_ch = true; - - wilc_wfi_cfg_parse_tx_action(tx_buff, len - (i + 6), - oper_ch, iftype, - vif->wilc->sta_ch); - - break; - } - } - - if (subtype != P2P_INV_REQ && subtype != P2P_INV_RSP) { - int vendor_spec_len = sizeof(p2p_vendor_spec); - - memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, - vendor_spec_len); - mgmt_tx->buff[len + vendor_spec_len] = priv->p2p.local_random; - mgmt_tx->size = buf_len; - } -} - -static int mgmt_tx(struct wiphy *wiphy, - struct wireless_dev *wdev, - struct cfg80211_mgmt_tx_params *params, - u64 *cookie) -{ - struct ieee80211_channel *chan = params->chan; - unsigned int wait = params->wait; - const u8 *buf = params->buf; - size_t len = params->len; - const struct ieee80211_mgmt *mgmt; - struct wilc_p2p_mgmt_data *mgmt_tx; - struct wilc_vif *vif = netdev_priv(wdev->netdev); - struct wilc_priv *priv = &vif->priv; - struct host_if_drv *wfi_drv = priv->hif_drv; - u32 buf_len = len + sizeof(p2p_vendor_spec) + - sizeof(priv->p2p.local_random); - int ret = 0; - - *cookie = prandom_u32(); - priv->tx_cookie = *cookie; - mgmt = (const struct ieee80211_mgmt *)buf; - - if (!ieee80211_is_mgmt(mgmt->frame_control)) - goto out; - - mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_KERNEL); - if (!mgmt_tx) { - ret = -ENOMEM; - goto out; - } - - mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL); - if (!mgmt_tx->buff) { - ret = -ENOMEM; - kfree(mgmt_tx); - goto out; - } - - memcpy(mgmt_tx->buff, buf, len); - mgmt_tx->size = len; - - if (ieee80211_is_probe_resp(mgmt->frame_control)) { - wilc_set_mac_chnl_num(vif, chan->hw_value); - vif->wilc->op_ch = chan->hw_value; - goto out_txq_add_pkt; - } - - if (!ieee80211_is_action(mgmt->frame_control)) - goto out_txq_add_pkt; - - if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { - if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || - buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { - wilc_set_mac_chnl_num(vif, chan->hw_value); - vif->wilc->op_ch = chan->hw_value; - } - switch (buf[ACTION_SUBTYPE_ID]) { - case GAS_INITIAL_REQ: - case GAS_INITIAL_RSP: - break; - - case PUBLIC_ACT_VENDORSPEC: - if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) - wilc_wfi_cfg_tx_vendor_spec(priv, mgmt_tx, - params, vif->iftype, - buf_len); - else - netdev_dbg(vif->ndev, - "Not a P2P public action frame\n"); - - break; - - default: - netdev_dbg(vif->ndev, - "%s: Not handled action frame type:%x\n", - __func__, buf[ACTION_SUBTYPE_ID]); - break; - } - } - - wfi_drv->p2p_timeout = (jiffies + msecs_to_jiffies(wait)); - -out_txq_add_pkt: - - wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, - mgmt_tx->buff, mgmt_tx->size, - wilc_wfi_mgmt_tx_complete); - -out: - - return ret; -} - -static int mgmt_tx_cancel_wait(struct wiphy *wiphy, - struct wireless_dev *wdev, - u64 cookie) -{ - struct wilc_vif *vif = netdev_priv(wdev->netdev); - struct wilc_priv *priv = &vif->priv; - struct host_if_drv *wfi_drv = priv->hif_drv; - - wfi_drv->p2p_timeout = jiffies; - - if (!priv->p2p_listen_state) { - struct wilc_wfi_p2p_listen_params *params; - - params = &priv->remain_on_ch_params; - - cfg80211_remain_on_channel_expired(wdev, - params->listen_cookie, - params->listen_ch, - GFP_KERNEL); - } - - return 0; -} - -void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, - u16 frame_type, bool reg) -{ - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(wdev->netdev); - - if (!frame_type) - return; - - switch (frame_type) { - case IEEE80211_STYPE_PROBE_REQ: - vif->frame_reg[0].type = frame_type; - vif->frame_reg[0].reg = reg; - break; - - case IEEE80211_STYPE_ACTION: - vif->frame_reg[1].type = frame_type; - vif->frame_reg[1].reg = reg; - break; - - default: - break; - } - - if (!wl->initialized) - return; - wilc_frame_register(vif, frame_type, reg); -} - -static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, - s32 rssi_thold, u32 rssi_hyst) -{ - return 0; -} - -static int dump_station(struct wiphy *wiphy, struct net_device *dev, - int idx, u8 *mac, struct station_info *sinfo) -{ - struct wilc_vif *vif = netdev_priv(dev); - int ret; - - if (idx != 0) - return -ENOENT; - - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); - - ret = wilc_get_rssi(vif, &sinfo->signal); - if (ret) - return ret; - - memcpy(mac, vif->priv.associated_bss, ETH_ALEN); - return 0; -} - -static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, - bool enabled, int timeout) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - - if (!priv->hif_drv) - return -EIO; - - wilc_set_power_mgmt(vif, enabled, timeout); - - return 0; -} - -static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, - enum nl80211_iftype type, - struct vif_params *params) -{ - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - - priv->p2p.local_random = 0x01; - priv->p2p.recv_random = 0x00; - priv->p2p.is_wilc_ie = false; - - switch (type) { - case NL80211_IFTYPE_STATION: - vif->connecting = false; - dev->ieee80211_ptr->iftype = type; - priv->wdev.iftype = type; - vif->monitor_flag = 0; - if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) - wilc_wfi_deinit_mon_interface(wl, true); - vif->iftype = WILC_STATION_MODE; - - if (wl->initialized) - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_STATION_MODE, vif->idx); - - memset(priv->assoc_stainfo.sta_associated_bss, 0, - WILC_MAX_NUM_STA * ETH_ALEN); - break; - - case NL80211_IFTYPE_P2P_CLIENT: - vif->connecting = false; - dev->ieee80211_ptr->iftype = type; - priv->wdev.iftype = type; - vif->monitor_flag = 0; - vif->iftype = WILC_CLIENT_MODE; - - if (wl->initialized) - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_STATION_MODE, vif->idx); - break; - - case NL80211_IFTYPE_AP: - dev->ieee80211_ptr->iftype = type; - priv->wdev.iftype = type; - vif->iftype = WILC_AP_MODE; - - if (wl->initialized) - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_AP_MODE, vif->idx); - break; - - case NL80211_IFTYPE_P2P_GO: - dev->ieee80211_ptr->iftype = type; - priv->wdev.iftype = type; - vif->iftype = WILC_GO_MODE; - - if (wl->initialized) - wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), - WILC_AP_MODE, vif->idx); - break; - - default: - netdev_err(dev, "Unknown interface type= %d\n", type); - return -EINVAL; - } - - return 0; -} - -static int start_ap(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_ap_settings *settings) -{ - struct wilc_vif *vif = netdev_priv(dev); - int ret; - - ret = set_channel(wiphy, &settings->chandef); - if (ret != 0) - netdev_err(dev, "Error in setting channel\n"); - - wilc_wlan_set_bssid(dev, dev->dev_addr, WILC_AP_MODE); - - return wilc_add_beacon(vif, settings->beacon_interval, - settings->dtim_period, &settings->beacon); -} - -static int change_beacon(struct wiphy *wiphy, struct net_device *dev, - struct cfg80211_beacon_data *beacon) -{ - struct wilc_vif *vif = netdev_priv(dev); - - return wilc_add_beacon(vif, 0, 0, beacon); -} - -static int stop_ap(struct wiphy *wiphy, struct net_device *dev) -{ - int ret; - struct wilc_vif *vif = netdev_priv(dev); - - wilc_wlan_set_bssid(dev, NULL, WILC_AP_MODE); - - ret = wilc_del_beacon(vif); - - if (ret) - netdev_err(dev, "Host delete beacon fail\n"); - - return ret; -} - -static int add_station(struct wiphy *wiphy, struct net_device *dev, - const u8 *mac, struct station_parameters *params) -{ - int ret = 0; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - - if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { - memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac, - ETH_ALEN); - - ret = wilc_add_station(vif, mac, params); - if (ret) - netdev_err(dev, "Host add station fail\n"); - } - - return ret; -} - -static int del_station(struct wiphy *wiphy, struct net_device *dev, - struct station_del_parameters *params) -{ - const u8 *mac = params->mac; - int ret = 0; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc_priv *priv = &vif->priv; - struct sta_info *info; - - if (!(vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE)) - return ret; - - info = &priv->assoc_stainfo; - - if (!mac) - ret = wilc_del_allstation(vif, info->sta_associated_bss); - - ret = wilc_del_station(vif, mac); - if (ret) - netdev_err(dev, "Host delete station fail\n"); - return ret; -} - -static int change_station(struct wiphy *wiphy, struct net_device *dev, - const u8 *mac, struct station_parameters *params) -{ - int ret = 0; - struct wilc_vif *vif = netdev_priv(dev); - - if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { - ret = wilc_edit_station(vif, mac, params); - if (ret) - netdev_err(dev, "Host edit station fail\n"); - } - return ret; -} - -static struct wilc_vif *wilc_get_vif_from_type(struct wilc *wl, int type) -{ - struct wilc_vif *vif; - - list_for_each_entry_rcu(vif, &wl->vif_list, list) { - if (vif->iftype == type) - return vif; - } - - return NULL; -} - -static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, - const char *name, - unsigned char name_assign_type, - enum nl80211_iftype type, - struct vif_params *params) -{ - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif; - struct wireless_dev *wdev; - int iftype; - - if (type == NL80211_IFTYPE_MONITOR) { - struct net_device *ndev; - int srcu_idx; - - srcu_idx = srcu_read_lock(&wl->srcu); - vif = wilc_get_vif_from_type(wl, WILC_AP_MODE); - if (!vif) { - vif = wilc_get_vif_from_type(wl, WILC_GO_MODE); - if (!vif) { - srcu_read_unlock(&wl->srcu, srcu_idx); - goto validate_interface; - } - } - - if (vif->monitor_flag) { - srcu_read_unlock(&wl->srcu, srcu_idx); - goto validate_interface; - } - - ndev = wilc_wfi_init_mon_interface(wl, name, vif->ndev); - if (ndev) { - vif->monitor_flag = 1; - } else { - srcu_read_unlock(&wl->srcu, srcu_idx); - return ERR_PTR(-EINVAL); - } - - wdev = &vif->priv.wdev; - srcu_read_unlock(&wl->srcu, srcu_idx); - return wdev; - } - -validate_interface: - mutex_lock(&wl->vif_mutex); - if (wl->vif_num == WILC_NUM_CONCURRENT_IFC) { - pr_err("Reached maximum number of interface\n"); - mutex_unlock(&wl->vif_mutex); - return ERR_PTR(-EINVAL); - } - mutex_unlock(&wl->vif_mutex); - - switch (type) { - case NL80211_IFTYPE_STATION: - iftype = WILC_STATION_MODE; - break; - case NL80211_IFTYPE_AP: - iftype = WILC_AP_MODE; - break; - default: - return ERR_PTR(-EOPNOTSUPP); - } - - vif = wilc_netdev_ifc_init(wl, name, iftype, type, true); - if (IS_ERR(vif)) - return ERR_CAST(vif); - - return &vif->priv.wdev; -} - -static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) -{ - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif; - - if (wdev->iftype == NL80211_IFTYPE_AP || - wdev->iftype == NL80211_IFTYPE_P2P_GO) - wilc_wfi_deinit_mon_interface(wl, true); - vif = netdev_priv(wdev->netdev); - cfg80211_stop_iface(wiphy, wdev, GFP_KERNEL); - unregister_netdevice(vif->ndev); - vif->monitor_flag = 0; - - wilc_set_operation_mode(vif, 0, 0, 0); - mutex_lock(&wl->vif_mutex); - list_del_rcu(&vif->list); - wl->vif_num--; - mutex_unlock(&wl->vif_mutex); - synchronize_srcu(&wl->srcu); - return 0; -} - -static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) -{ - struct wilc *wl = wiphy_priv(wiphy); - - if (!wow && wilc_wlan_get_num_conn_ifcs(wl)) - wl->suspend_event = true; - else - wl->suspend_event = false; - - return 0; -} - -static int wilc_resume(struct wiphy *wiphy) -{ - return 0; -} - -static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) -{ - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif; - int srcu_idx; - - srcu_idx = srcu_read_lock(&wl->srcu); - vif = wilc_get_wl_to_vif(wl); - if (IS_ERR(vif)) { - srcu_read_unlock(&wl->srcu, srcu_idx); - return; - } - - netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled); - srcu_read_unlock(&wl->srcu, srcu_idx); -} - -static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, - enum nl80211_tx_power_setting type, int mbm) -{ - int ret; - int srcu_idx; - s32 tx_power = MBM_TO_DBM(mbm); - struct wilc *wl = wiphy_priv(wiphy); - struct wilc_vif *vif; - - if (!wl->initialized) - return -EIO; - - srcu_idx = srcu_read_lock(&wl->srcu); - vif = wilc_get_wl_to_vif(wl); - if (IS_ERR(vif)) { - srcu_read_unlock(&wl->srcu, srcu_idx); - return -EINVAL; - } - - netdev_info(vif->ndev, "Setting tx power %d\n", tx_power); - if (tx_power < 0) - tx_power = 0; - else if (tx_power > 18) - tx_power = 18; - ret = wilc_set_tx_power(vif, tx_power); - if (ret) - netdev_err(vif->ndev, "Failed to set tx power\n"); - srcu_read_unlock(&wl->srcu, srcu_idx); - - return ret; -} - -static int get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, - int *dbm) -{ - int ret; - struct wilc_vif *vif = netdev_priv(wdev->netdev); - struct wilc *wl = vif->wilc; - - /* If firmware is not started, return. */ - if (!wl->initialized) - return -EIO; - - ret = wilc_get_tx_power(vif, (u8 *)dbm); - if (ret) - netdev_err(vif->ndev, "Failed to get tx power\n"); - - return ret; -} - -static const struct cfg80211_ops wilc_cfg80211_ops = { - .set_monitor_channel = set_channel, - .scan = scan, - .connect = connect, - .disconnect = disconnect, - .add_key = add_key, - .del_key = del_key, - .get_key = get_key, - .set_default_key = set_default_key, - .add_virtual_intf = add_virtual_intf, - .del_virtual_intf = del_virtual_intf, - .change_virtual_intf = change_virtual_intf, - - .start_ap = start_ap, - .change_beacon = change_beacon, - .stop_ap = stop_ap, - .add_station = add_station, - .del_station = del_station, - .change_station = change_station, - .get_station = get_station, - .dump_station = dump_station, - .change_bss = change_bss, - .set_wiphy_params = set_wiphy_params, - - .set_pmksa = set_pmksa, - .del_pmksa = del_pmksa, - .flush_pmksa = flush_pmksa, - .remain_on_channel = remain_on_channel, - .cancel_remain_on_channel = cancel_remain_on_channel, - .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, - .mgmt_tx = mgmt_tx, - .mgmt_frame_register = wilc_mgmt_frame_register, - .set_power_mgmt = set_power_mgmt, - .set_cqm_rssi_config = set_cqm_rssi_config, - - .suspend = wilc_suspend, - .resume = wilc_resume, - .set_wakeup = wilc_set_wakeup, - .set_tx_power = set_tx_power, - .get_tx_power = get_tx_power, - -}; - -static void wlan_init_locks(struct wilc *wl) -{ - mutex_init(&wl->hif_cs); - mutex_init(&wl->rxq_cs); - mutex_init(&wl->cfg_cmd_lock); - mutex_init(&wl->vif_mutex); - - spin_lock_init(&wl->txq_spinlock); - mutex_init(&wl->txq_add_to_head_cs); - - init_completion(&wl->txq_event); - init_completion(&wl->cfg_event); - init_completion(&wl->sync_event); - init_completion(&wl->txq_thread_started); - init_srcu_struct(&wl->srcu); -} - -void wlan_deinit_locks(struct wilc *wilc) -{ - mutex_destroy(&wilc->hif_cs); - mutex_destroy(&wilc->rxq_cs); - mutex_destroy(&wilc->cfg_cmd_lock); - mutex_destroy(&wilc->txq_add_to_head_cs); - mutex_destroy(&wilc->vif_mutex); - cleanup_srcu_struct(&wilc->srcu); -} - -int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, - const struct wilc_hif_func *ops) -{ - struct wilc *wl; - struct wilc_vif *vif; - int ret; - - wl = wilc_create_wiphy(dev); - if (!wl) - return -EINVAL; - - wlan_init_locks(wl); - - ret = wilc_wlan_cfg_init(wl); - if (ret) - goto free_wl; - - *wilc = wl; - wl->io_type = io_type; - wl->hif_func = ops; - wl->chip_ps_state = WILC_CHIP_WAKEDUP; - INIT_LIST_HEAD(&wl->txq_head.list); - INIT_LIST_HEAD(&wl->rxq_head.list); - INIT_LIST_HEAD(&wl->vif_list); - - wl->hif_workqueue = create_singlethread_workqueue("WILC_wq"); - if (!wl->hif_workqueue) { - ret = -ENOMEM; - goto free_cfg; - } - vif = wilc_netdev_ifc_init(wl, "wlan%d", WILC_STATION_MODE, - NL80211_IFTYPE_STATION, false); - if (IS_ERR(vif)) { - ret = PTR_ERR(vif); - goto free_hq; - } - - return 0; - -free_hq: - destroy_workqueue(wl->hif_workqueue); - -free_cfg: - wilc_wlan_cfg_deinit(wl); - -free_wl: - wlan_deinit_locks(wl); - wiphy_unregister(wl->wiphy); - wiphy_free(wl->wiphy); - return ret; -} -EXPORT_SYMBOL_GPL(wilc_cfg80211_init); - -struct wilc *wilc_create_wiphy(struct device *dev) -{ - struct wiphy *wiphy; - struct wilc *wl; - int ret; - - wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(*wl)); - if (!wiphy) - return NULL; - - wl = wiphy_priv(wiphy); - - memcpy(wl->bitrates, wilc_bitrates, sizeof(wilc_bitrates)); - memcpy(wl->channels, wilc_2ghz_channels, sizeof(wilc_2ghz_channels)); - wl->band.bitrates = wl->bitrates; - wl->band.n_bitrates = ARRAY_SIZE(wl->bitrates); - wl->band.channels = wl->channels; - wl->band.n_channels = ARRAY_SIZE(wilc_2ghz_channels); - - wl->band.ht_cap.ht_supported = 1; - wl->band.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); - wl->band.ht_cap.mcs.rx_mask[0] = 0xff; - wl->band.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; - wl->band.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; - - wiphy->bands[NL80211_BAND_2GHZ] = &wl->band; - - wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID; -#ifdef CONFIG_PM - wiphy->wowlan = &wowlan_support; -#endif - wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; - wiphy->max_scan_ie_len = 1000; - wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - memcpy(wl->cipher_suites, wilc_cipher_suites, - sizeof(wilc_cipher_suites)); - wiphy->cipher_suites = wl->cipher_suites; - wiphy->n_cipher_suites = ARRAY_SIZE(wilc_cipher_suites); - wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; - - wiphy->max_remain_on_channel_duration = 500; - wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_AP) | - BIT(NL80211_IFTYPE_MONITOR) | - BIT(NL80211_IFTYPE_P2P_GO) | - BIT(NL80211_IFTYPE_P2P_CLIENT); - wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; - - set_wiphy_dev(wiphy, dev); - wl->wiphy = wiphy; - ret = wiphy_register(wiphy); - if (ret) { - wiphy_free(wiphy); - return NULL; - } - return wl; -} - -int wilc_init_host_int(struct net_device *net) -{ - int ret; - struct wilc_vif *vif = netdev_priv(net); - struct wilc_priv *priv = &vif->priv; - - priv->p2p_listen_state = false; - - mutex_init(&priv->scan_req_lock); - ret = wilc_init(net, &priv->hif_drv); - if (ret) - netdev_err(net, "Error while initializing hostinterface\n"); - - return ret; -} - -void wilc_deinit_host_int(struct net_device *net) -{ - int ret; - struct wilc_vif *vif = netdev_priv(net); - struct wilc_priv *priv = &vif->priv; - - priv->p2p_listen_state = false; - - flush_workqueue(vif->wilc->hif_workqueue); - mutex_destroy(&priv->scan_req_lock); - ret = wilc_deinit(vif); - - if (ret) - netdev_err(net, "Error while deinitializing host interface\n"); -} - diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h deleted file mode 100644 index 7206b6162a8c..000000000000 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#ifndef NM_WFI_CFGOPERATIONS -#define NM_WFI_CFGOPERATIONS -#include "wilc_wfi_netdevice.h" - -struct wiphy *wilc_cfg_alloc(void); -int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, - const struct wilc_hif_func *ops); -struct wilc *wilc_create_wiphy(struct device *dev); -void wilc_deinit_host_int(struct net_device *net); -int wilc_init_host_int(struct net_device *net); -void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size); -struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name, - enum nl80211_iftype type); -void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked); -struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, - const char *name, - struct net_device *real_dev); -void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, - u16 frame_type, bool reg); -struct wilc_vif *wilc_get_interface(struct wilc *wl); -struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl); -void wlan_deinit_locks(struct wilc *wilc); -#endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h deleted file mode 100644 index d94a4808bdf9..000000000000 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ /dev/null @@ -1,296 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#ifndef WILC_WFI_NETDEVICE -#define WILC_WFI_NETDEVICE - -#include -#include -#include -#include -#include -#include - -#include "wilc_hif.h" -#include "wilc_wlan.h" -#include "wilc_wlan_cfg.h" - -#define FLOW_CONTROL_LOWER_THRESHOLD 128 -#define FLOW_CONTROL_UPPER_THRESHOLD 256 - -#define WILC_MAX_NUM_PMKIDS 16 -#define PMKID_FOUND 1 -#define NUM_STA_ASSOCIATED 8 - -#define NUM_REG_FRAME 2 - -#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 -#define DEFAULT_LINK_SPEED 72 - -#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) - -struct wilc_wfi_stats { - unsigned long rx_packets; - unsigned long tx_packets; - unsigned long rx_bytes; - unsigned long tx_bytes; - u64 rx_time; - u64 tx_time; - -}; - -struct wilc_wfi_key { - u8 *key; - u8 *seq; - int key_len; - int seq_len; - u32 cipher; -}; - -struct wilc_wfi_wep_key { - u8 *key; - u8 key_len; - u8 key_idx; -}; - -struct sta_info { - u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN]; -}; - -/*Parameters needed for host interface for remaining on channel*/ -struct wilc_wfi_p2p_listen_params { - struct ieee80211_channel *listen_ch; - u32 listen_duration; - u64 listen_cookie; -}; - -struct wilc_p2p_var { - u8 local_random; - u8 recv_random; - bool is_wilc_ie; -}; - -static const u32 wilc_cipher_suites[] = { - WLAN_CIPHER_SUITE_WEP40, - WLAN_CIPHER_SUITE_WEP104, - WLAN_CIPHER_SUITE_TKIP, - WLAN_CIPHER_SUITE_CCMP, - WLAN_CIPHER_SUITE_AES_CMAC -}; - -#define CHAN2G(_channel, _freq, _flags) { \ - .band = NL80211_BAND_2GHZ, \ - .center_freq = (_freq), \ - .hw_value = (_channel), \ - .flags = (_flags), \ - .max_antenna_gain = 0, \ - .max_power = 30, \ -} - -static const struct ieee80211_channel wilc_2ghz_channels[] = { - CHAN2G(1, 2412, 0), - CHAN2G(2, 2417, 0), - CHAN2G(3, 2422, 0), - CHAN2G(4, 2427, 0), - CHAN2G(5, 2432, 0), - CHAN2G(6, 2437, 0), - CHAN2G(7, 2442, 0), - CHAN2G(8, 2447, 0), - CHAN2G(9, 2452, 0), - CHAN2G(10, 2457, 0), - CHAN2G(11, 2462, 0), - CHAN2G(12, 2467, 0), - CHAN2G(13, 2472, 0), - CHAN2G(14, 2484, 0) -}; - -#define RATETAB_ENT(_rate, _hw_value, _flags) { \ - .bitrate = (_rate), \ - .hw_value = (_hw_value), \ - .flags = (_flags), \ -} - -static struct ieee80211_rate wilc_bitrates[] = { - RATETAB_ENT(10, 0, 0), - RATETAB_ENT(20, 1, 0), - RATETAB_ENT(55, 2, 0), - RATETAB_ENT(110, 3, 0), - RATETAB_ENT(60, 9, 0), - RATETAB_ENT(90, 6, 0), - RATETAB_ENT(120, 7, 0), - RATETAB_ENT(180, 8, 0), - RATETAB_ENT(240, 9, 0), - RATETAB_ENT(360, 10, 0), - RATETAB_ENT(480, 11, 0), - RATETAB_ENT(540, 12, 0) -}; - -struct wilc_priv { - struct wireless_dev wdev; - struct cfg80211_scan_request *scan_req; - - struct wilc_wfi_p2p_listen_params remain_on_ch_params; - u64 tx_cookie; - - bool cfg_scanning; - - u8 associated_bss[ETH_ALEN]; - struct sta_info assoc_stainfo; - struct sk_buff *skb; - struct net_device *dev; - struct host_if_drv *hif_drv; - struct wilc_pmkid_attr pmkid_list; - u8 wep_key[4][WLAN_KEY_LEN_WEP104]; - u8 wep_key_len[4]; - /* The real interface that the monitor is on */ - struct net_device *real_ndev; - struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA]; - struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA]; - u8 wilc_groupkey; - /* mutexes */ - struct mutex scan_req_lock; - bool p2p_listen_state; - int scanned_cnt; - struct wilc_p2p_var p2p; - - u64 inc_roc_cookie; -}; - -struct frame_reg { - u16 type; - bool reg; -}; - -#define MAX_TCP_SESSION 25 -#define MAX_PENDING_ACKS 256 - -struct ack_session_info { - u32 seq_num; - u32 bigger_ack_num; - u16 src_port; - u16 dst_port; - u16 status; -}; - -struct pending_acks { - u32 ack_num; - u32 session_index; - struct txq_entry_t *txqe; -}; - -struct tcp_ack_filter { - struct ack_session_info ack_session_info[2 * MAX_TCP_SESSION]; - struct pending_acks pending_acks[MAX_PENDING_ACKS]; - u32 pending_base; - u32 tcp_session; - u32 pending_acks_idx; - bool enabled; -}; - -struct wilc_vif { - u8 idx; - u8 iftype; - int monitor_flag; - int mac_opened; - struct frame_reg frame_reg[NUM_REG_FRAME]; - struct net_device_stats netstats; - struct wilc *wilc; - u8 bssid[ETH_ALEN]; - struct host_if_drv *hif_drv; - struct net_device *ndev; - u8 mode; - struct timer_list during_ip_timer; - struct timer_list periodic_rssi; - struct rf_info periodic_stat; - struct tcp_ack_filter ack_filter; - bool connecting; - struct wilc_priv priv; - struct list_head list; - struct cfg80211_bss *bss; -}; - -struct wilc { - struct wiphy *wiphy; - const struct wilc_hif_func *hif_func; - int io_type; - s8 mac_status; - struct gpio_desc *gpio_irq; - struct clk *rtc_clk; - bool initialized; - int dev_irq_num; - int close; - u8 vif_num; - struct list_head vif_list; - /*protect vif list*/ - struct mutex vif_mutex; - struct srcu_struct srcu; - u8 open_ifcs; - /*protect head of transmit queue*/ - struct mutex txq_add_to_head_cs; - /*protect txq_entry_t transmit queue*/ - spinlock_t txq_spinlock; - /*protect rxq_entry_t receiver queue*/ - struct mutex rxq_cs; - /* lock to protect hif access */ - struct mutex hif_cs; - - struct completion cfg_event; - struct completion sync_event; - struct completion txq_event; - struct completion txq_thread_started; - - struct task_struct *txq_thread; - - int quit; - /* lock to protect issue of wid command to firmware */ - struct mutex cfg_cmd_lock; - struct wilc_cfg_frame cfg_frame; - u32 cfg_frame_offset; - u8 cfg_seq_no; - - u8 *rx_buffer; - u32 rx_buffer_offset; - u8 *tx_buffer; - - struct txq_entry_t txq_head; - int txq_entries; - - struct rxq_entry_t rxq_head; - - const struct firmware *firmware; - - struct device *dev; - bool suspend_event; - - int clients_count; - struct workqueue_struct *hif_workqueue; - enum chip_ps_states chip_ps_state; - struct wilc_cfg cfg; - void *bus_data; - struct net_device *monitor_dev; - /* deinit lock */ - struct mutex deinit_lock; - u8 sta_ch; - u8 op_ch; - struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)]; - struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)]; - struct ieee80211_supported_band band; - u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)]; -}; - -struct wilc_wfi_mon_priv { - struct net_device *real_ndev; -}; - -void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); -void wilc_mac_indicate(struct wilc *wilc); -void wilc_netdev_cleanup(struct wilc *wilc); -void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); -void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode); -struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, - int vif_type, enum nl80211_iftype type, - bool rtnl_locked); -#endif diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c deleted file mode 100644 index 771d8cb68dc1..000000000000 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ /dev/null @@ -1,1269 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include -#include -#include "wilc_wfi_cfgoperations.h" -#include "wilc_wlan_cfg.h" - -static inline bool is_wilc1000(u32 id) -{ - return (id & 0xfffff000) == 0x100000; -} - -static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) -{ - mutex_lock(&wilc->hif_cs); - if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP) - chip_wakeup(wilc); -} - -static inline void release_bus(struct wilc *wilc, enum bus_release release) -{ - if (release == WILC_BUS_RELEASE_ALLOW_SLEEP) - chip_allow_sleep(wilc); - mutex_unlock(&wilc->hif_cs); -} - -static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe) -{ - list_del(&tqe->list); - wilc->txq_entries -= 1; -} - -static struct txq_entry_t * -wilc_wlan_txq_remove_from_head(struct net_device *dev) -{ - struct txq_entry_t *tqe = NULL; - unsigned long flags; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq_head.list)) { - tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, - list); - list_del(&tqe->list); - wilc->txq_entries -= 1; - } - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - return tqe; -} - -static void wilc_wlan_txq_add_to_tail(struct net_device *dev, - struct txq_entry_t *tqe) -{ - unsigned long flags; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - list_add_tail(&tqe->list, &wilc->txq_head.list); - wilc->txq_entries += 1; - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - complete(&wilc->txq_event); -} - -static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, - struct txq_entry_t *tqe) -{ - unsigned long flags; - struct wilc *wilc = vif->wilc; - - mutex_lock(&wilc->txq_add_to_head_cs); - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - list_add(&tqe->list, &wilc->txq_head.list); - wilc->txq_entries += 1; - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - mutex_unlock(&wilc->txq_add_to_head_cs); - complete(&wilc->txq_event); -} - -#define NOT_TCP_ACK (-1) - -static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt, - u32 dst_prt, u32 seq) -{ - struct tcp_ack_filter *f = &vif->ack_filter; - - if (f->tcp_session < 2 * MAX_TCP_SESSION) { - f->ack_session_info[f->tcp_session].seq_num = seq; - f->ack_session_info[f->tcp_session].bigger_ack_num = 0; - f->ack_session_info[f->tcp_session].src_port = src_prt; - f->ack_session_info[f->tcp_session].dst_port = dst_prt; - f->tcp_session++; - } -} - -static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack) -{ - struct tcp_ack_filter *f = &vif->ack_filter; - - if (index < 2 * MAX_TCP_SESSION && - ack > f->ack_session_info[index].bigger_ack_num) - f->ack_session_info[index].bigger_ack_num = ack; -} - -static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, - u32 session_index, - struct txq_entry_t *txqe) -{ - struct tcp_ack_filter *f = &vif->ack_filter; - u32 i = f->pending_base + f->pending_acks_idx; - - if (i < MAX_PENDING_ACKS) { - f->pending_acks[i].ack_num = ack; - f->pending_acks[i].txqe = txqe; - f->pending_acks[i].session_index = session_index; - txqe->ack_idx = i; - f->pending_acks_idx++; - } -} - -static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) -{ - void *buffer = tqe->buffer; - const struct ethhdr *eth_hdr_ptr = buffer; - int i; - unsigned long flags; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - struct tcp_ack_filter *f = &vif->ack_filter; - const struct iphdr *ip_hdr_ptr; - const struct tcphdr *tcp_hdr_ptr; - u32 ihl, total_length, data_offset; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (eth_hdr_ptr->h_proto != htons(ETH_P_IP)) - goto out; - - ip_hdr_ptr = buffer + ETH_HLEN; - - if (ip_hdr_ptr->protocol != IPPROTO_TCP) - goto out; - - ihl = ip_hdr_ptr->ihl << 2; - tcp_hdr_ptr = buffer + ETH_HLEN + ihl; - total_length = ntohs(ip_hdr_ptr->tot_len); - - data_offset = tcp_hdr_ptr->doff << 2; - if (total_length == (ihl + data_offset)) { - u32 seq_no, ack_no; - - seq_no = ntohl(tcp_hdr_ptr->seq); - ack_no = ntohl(tcp_hdr_ptr->ack_seq); - for (i = 0; i < f->tcp_session; i++) { - u32 j = f->ack_session_info[i].seq_num; - - if (i < 2 * MAX_TCP_SESSION && - j == seq_no) { - update_tcp_session(vif, i, ack_no); - break; - } - } - if (i == f->tcp_session) - add_tcp_session(vif, 0, 0, seq_no); - - add_tcp_pending_ack(vif, ack_no, i, tqe); - } - -out: - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); -} - -static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - struct tcp_ack_filter *f = &vif->ack_filter; - u32 i = 0; - u32 dropped = 0; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - for (i = f->pending_base; - i < (f->pending_base + f->pending_acks_idx); i++) { - u32 index; - u32 bigger_ack_num; - - if (i >= MAX_PENDING_ACKS) - break; - - index = f->pending_acks[i].session_index; - - if (index >= 2 * MAX_TCP_SESSION) - break; - - bigger_ack_num = f->ack_session_info[index].bigger_ack_num; - - if (f->pending_acks[i].ack_num < bigger_ack_num) { - struct txq_entry_t *tqe; - - tqe = f->pending_acks[i].txqe; - if (tqe) { - wilc_wlan_txq_remove(wilc, tqe); - tqe->status = 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, - tqe->status); - kfree(tqe); - dropped++; - } - } - } - f->pending_acks_idx = 0; - f->tcp_session = 0; - - if (f->pending_base == 0) - f->pending_base = MAX_TCP_SESSION; - else - f->pending_base = 0; - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - while (dropped > 0) { - wait_for_completion_timeout(&wilc->txq_event, - msecs_to_jiffies(1)); - dropped--; - } -} - -void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) -{ - vif->ack_filter.enabled = value; -} - -static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, - u32 buffer_size) -{ - struct txq_entry_t *tqe; - struct wilc *wilc = vif->wilc; - - netdev_dbg(vif->ndev, "Adding config packet ...\n"); - if (wilc->quit) { - netdev_dbg(vif->ndev, "Return due to clear function\n"); - complete(&wilc->cfg_event); - return 0; - } - - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) - return 0; - - tqe->type = WILC_CFG_PKT; - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = NULL; - tqe->priv = NULL; - tqe->ack_idx = NOT_TCP_ACK; - tqe->vif = vif; - - wilc_wlan_txq_add_to_head(vif, tqe); - - return 1; -} - -int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)) -{ - struct txq_entry_t *tqe; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc; - - wilc = vif->wilc; - - if (wilc->quit) - return 0; - - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) - return 0; - tqe->type = WILC_NET_PKT; - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = tx_complete_fn; - tqe->priv = priv; - tqe->vif = vif; - - tqe->ack_idx = NOT_TCP_ACK; - if (vif->ack_filter.enabled) - tcp_process(dev, tqe); - wilc_wlan_txq_add_to_tail(dev, tqe); - return wilc->txq_entries; -} - -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)) -{ - struct txq_entry_t *tqe; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc; - - wilc = vif->wilc; - - if (wilc->quit) - return 0; - - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) - return 0; - tqe->type = WILC_MGMT_PKT; - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = tx_complete_fn; - tqe->priv = priv; - tqe->ack_idx = NOT_TCP_ACK; - tqe->vif = vif; - wilc_wlan_txq_add_to_tail(dev, tqe); - return 1; -} - -static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc) -{ - struct txq_entry_t *tqe = NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq_head.list)) - tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, - list); - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - return tqe; -} - -static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, - struct txq_entry_t *tqe) -{ - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_is_last(&tqe->list, &wilc->txq_head.list)) - tqe = list_next_entry(tqe, list); - else - tqe = NULL; - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - return tqe; -} - -static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) -{ - if (wilc->quit) - return; - - mutex_lock(&wilc->rxq_cs); - list_add_tail(&rqe->list, &wilc->rxq_head.list); - mutex_unlock(&wilc->rxq_cs); -} - -static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) -{ - struct rxq_entry_t *rqe = NULL; - - mutex_lock(&wilc->rxq_cs); - if (!list_empty(&wilc->rxq_head.list)) { - rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t, - list); - list_del(&rqe->list); - } - mutex_unlock(&wilc->rxq_cs); - return rqe; -} - -void chip_allow_sleep(struct wilc *wilc) -{ - u32 reg = 0; - - wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); - - wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); - wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); -} -EXPORT_SYMBOL_GPL(chip_allow_sleep); - -void chip_wakeup(struct wilc *wilc) -{ - u32 reg, clk_status_reg; - - if ((wilc->io_type & 0x1) == WILC_HIF_SPI) { - do { - wilc->hif_func->hif_read_reg(wilc, 1, ®); - wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1)); - wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1)); - - do { - usleep_range(2000, 2500); - wilc_get_chipid(wilc, true); - } while (wilc_get_chipid(wilc, true) == 0); - } while (wilc_get_chipid(wilc, true) == 0); - } else if ((wilc->io_type & 0x1) == WILC_HIF_SDIO) { - wilc->hif_func->hif_write_reg(wilc, 0xfa, 1); - usleep_range(200, 400); - wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); - do { - wilc->hif_func->hif_write_reg(wilc, 0xf0, - reg | BIT(0)); - wilc->hif_func->hif_read_reg(wilc, 0xf1, - &clk_status_reg); - - while ((clk_status_reg & 0x1) == 0) { - usleep_range(2000, 2500); - - wilc->hif_func->hif_read_reg(wilc, 0xf1, - &clk_status_reg); - } - if ((clk_status_reg & 0x1) == 0) { - wilc->hif_func->hif_write_reg(wilc, 0xf0, - reg & (~BIT(0))); - } - } while ((clk_status_reg & 0x1) == 0); - } - - if (wilc->chip_ps_state == WILC_CHIP_SLEEPING_MANUAL) { - if (wilc_get_chipid(wilc, false) < 0x1002b0) { - u32 val32; - - wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32); - val32 |= BIT(6); - wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32); - - wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32); - val32 |= BIT(6); - wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32); - } - } - wilc->chip_ps_state = WILC_CHIP_WAKEDUP; -} -EXPORT_SYMBOL_GPL(chip_wakeup); - -void host_wakeup_notify(struct wilc *wilc) -{ - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); - release_bus(wilc, WILC_BUS_RELEASE_ONLY); -} -EXPORT_SYMBOL_GPL(host_wakeup_notify); - -void host_sleep_notify(struct wilc *wilc) -{ - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); - release_bus(wilc, WILC_BUS_RELEASE_ONLY); -} -EXPORT_SYMBOL_GPL(host_sleep_notify); - -int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) -{ - int i, entries = 0; - u32 sum; - u32 reg; - u32 offset = 0; - int vmm_sz = 0; - struct txq_entry_t *tqe; - int ret = 0; - int counter; - int timeout; - u32 vmm_table[WILC_VMM_TBL_SIZE]; - const struct wilc_hif_func *func; - u8 *txb = wilc->tx_buffer; - struct net_device *dev; - struct wilc_vif *vif; - - if (wilc->quit) - goto out; - - mutex_lock(&wilc->txq_add_to_head_cs); - tqe = wilc_wlan_txq_get_first(wilc); - if (!tqe) - goto out; - dev = tqe->vif->ndev; - wilc_wlan_txq_filter_dup_tcp_ack(dev); - i = 0; - sum = 0; - do { - if (tqe && (i < (WILC_VMM_TBL_SIZE - 1))) { - if (tqe->type == WILC_CFG_PKT) - vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; - - else if (tqe->type == WILC_NET_PKT) - vmm_sz = ETH_ETHERNET_HDR_OFFSET; - - else - vmm_sz = HOST_HDR_OFFSET; - - vmm_sz += tqe->buffer_size; - - if (vmm_sz & 0x3) - vmm_sz = (vmm_sz + 4) & ~0x3; - - if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) - break; - - vmm_table[i] = vmm_sz / 4; - if (tqe->type == WILC_CFG_PKT) - vmm_table[i] |= BIT(10); - cpu_to_le32s(&vmm_table[i]); - - i++; - sum += vmm_sz; - tqe = wilc_wlan_txq_get_next(wilc, tqe); - } else { - break; - } - } while (1); - - if (i == 0) - goto out; - vmm_table[i] = 0x0; - - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - counter = 0; - func = wilc->hif_func; - do { - ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); - if (!ret) - break; - - if ((reg & 0x1) == 0) - break; - - counter++; - if (counter > 200) { - counter = 0; - ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0); - break; - } - } while (!wilc->quit); - - if (!ret) - goto out_release_bus; - - timeout = 200; - do { - ret = func->hif_block_tx(wilc, - WILC_VMM_TBL_RX_SHADOW_BASE, - (u8 *)vmm_table, - ((i + 1) * 4)); - if (!ret) - break; - - ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2); - if (!ret) - break; - - do { - ret = func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®); - if (!ret) - break; - if ((reg >> 2) & 0x1) { - entries = ((reg >> 3) & 0x3f); - break; - } - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - } while (--timeout); - if (timeout <= 0) { - ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0); - break; - } - - if (!ret) - break; - - if (entries == 0) { - ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); - if (!ret) - break; - reg &= ~BIT(0); - ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); - if (!ret) - break; - break; - } - break; - } while (1); - - if (!ret) - goto out_release_bus; - - if (entries == 0) { - ret = -ENOBUFS; - goto out_release_bus; - } - - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - - offset = 0; - i = 0; - do { - u32 header, buffer_offset; - char *bssid; - - tqe = wilc_wlan_txq_remove_from_head(dev); - if (!tqe) - break; - - vif = tqe->vif; - if (vmm_table[i] == 0) - break; - - le32_to_cpus(&vmm_table[i]); - vmm_sz = (vmm_table[i] & 0x3ff); - vmm_sz *= 4; - header = (tqe->type << 31) | - (tqe->buffer_size << 15) | - vmm_sz; - if (tqe->type == WILC_MGMT_PKT) - header |= BIT(30); - else - header &= ~BIT(30); - - cpu_to_le32s(&header); - memcpy(&txb[offset], &header, 4); - if (tqe->type == WILC_CFG_PKT) { - buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; - } else if (tqe->type == WILC_NET_PKT) { - bssid = tqe->vif->bssid; - buffer_offset = ETH_ETHERNET_HDR_OFFSET; - memcpy(&txb[offset + 8], bssid, 6); - } else { - buffer_offset = HOST_HDR_OFFSET; - } - - memcpy(&txb[offset + buffer_offset], - tqe->buffer, tqe->buffer_size); - offset += vmm_sz; - i++; - tqe->status = 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx != NOT_TCP_ACK && - tqe->ack_idx < MAX_PENDING_ACKS) - vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; - kfree(tqe); - } while (--entries); - - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - - ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); - if (!ret) - goto out_release_bus; - - ret = func->hif_block_tx_ext(wilc, 0, txb, offset); - -out_release_bus: - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - -out: - mutex_unlock(&wilc->txq_add_to_head_cs); - - *txq_count = wilc->txq_entries; - return ret; -} - -static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size) -{ - int offset = 0; - u32 header; - u32 pkt_len, pkt_offset, tp_len; - int is_cfg_packet; - u8 *buff_ptr; - - do { - buff_ptr = buffer + offset; - header = get_unaligned_le32(buff_ptr); - - is_cfg_packet = (header >> 31) & 0x1; - pkt_offset = (header >> 22) & 0x1ff; - tp_len = (header >> 11) & 0x7ff; - pkt_len = header & 0x7ff; - - if (pkt_len == 0 || tp_len == 0) - break; - - if (pkt_offset & IS_MANAGMEMENT) { - buff_ptr += HOST_HDR_OFFSET; - wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len); - } else { - if (!is_cfg_packet) { - if (pkt_len > 0) { - wilc_frmw_to_host(wilc, buff_ptr, - pkt_len, pkt_offset); - } - } else { - struct wilc_cfg_rsp rsp; - - buff_ptr += pkt_offset; - - wilc_wlan_cfg_indicate_rx(wilc, buff_ptr, - pkt_len, - &rsp); - if (rsp.type == WILC_CFG_RSP) { - if (wilc->cfg_seq_no == rsp.seq_no) - complete(&wilc->cfg_event); - } else if (rsp.type == WILC_CFG_RSP_STATUS) { - wilc_mac_indicate(wilc); - } - } - } - offset += tp_len; - if (offset >= size) - break; - } while (1); -} - -static void wilc_wlan_handle_rxq(struct wilc *wilc) -{ - int size; - u8 *buffer; - struct rxq_entry_t *rqe; - - do { - if (wilc->quit) { - complete(&wilc->cfg_event); - break; - } - rqe = wilc_wlan_rxq_remove(wilc); - if (!rqe) - break; - - buffer = rqe->buffer; - size = rqe->buffer_size; - wilc_wlan_handle_rx_buff(wilc, buffer, size); - - kfree(rqe); - } while (1); -} - -static void wilc_unknown_isr_ext(struct wilc *wilc) -{ - wilc->hif_func->hif_clear_int_ext(wilc, 0); -} - -static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status) -{ - u32 offset = wilc->rx_buffer_offset; - u8 *buffer = NULL; - u32 size; - u32 retries = 0; - int ret = 0; - struct rxq_entry_t *rqe; - - size = (int_status & 0x7fff) << 2; - - while (!size && retries < 10) { - wilc->hif_func->hif_read_size(wilc, &size); - size = (size & 0x7fff) << 2; - retries++; - } - - if (size <= 0) - return; - - if (WILC_RX_BUFF_SIZE - offset < size) - offset = 0; - - buffer = &wilc->rx_buffer[offset]; - - wilc->hif_func->hif_clear_int_ext(wilc, DATA_INT_CLR | ENABLE_RX_VMM); - ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size); - if (!ret) - return; - - offset += size; - wilc->rx_buffer_offset = offset; - rqe = kmalloc(sizeof(*rqe), GFP_KERNEL); - if (!rqe) - return; - - rqe->buffer = buffer; - rqe->buffer_size = size; - wilc_wlan_rxq_add(wilc, rqe); - wilc_wlan_handle_rxq(wilc); -} - -void wilc_handle_isr(struct wilc *wilc) -{ - u32 int_status; - - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - wilc->hif_func->hif_read_int(wilc, &int_status); - - if (int_status & DATA_INT_EXT) - wilc_wlan_handle_isr_ext(wilc, int_status); - - if (!(int_status & (ALL_INT_EXT))) - wilc_unknown_isr_ext(wilc); - - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); -} -EXPORT_SYMBOL_GPL(wilc_handle_isr); - -int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, - u32 buffer_size) -{ - u32 offset; - u32 addr, size, size2, blksz; - u8 *dma_buffer; - int ret = 0; - - blksz = BIT(12); - - dma_buffer = kmalloc(blksz, GFP_KERNEL); - if (!dma_buffer) - return -EIO; - - offset = 0; - do { - addr = get_unaligned_le32(&buffer[offset]); - size = get_unaligned_le32(&buffer[offset + 4]); - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - offset += 8; - while (((int)size) && (offset < buffer_size)) { - if (size <= blksz) - size2 = size; - else - size2 = blksz; - - memcpy(dma_buffer, &buffer[offset], size2); - ret = wilc->hif_func->hif_block_tx(wilc, addr, - dma_buffer, size2); - if (!ret) - break; - - addr += size2; - offset += size2; - size -= size2; - } - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - - if (!ret) { - ret = -EIO; - goto fail; - } - } while (offset < buffer_size); - -fail: - - kfree(dma_buffer); - - return (ret < 0) ? ret : 0; -} - -int wilc_wlan_start(struct wilc *wilc) -{ - u32 reg = 0; - int ret; - u32 chipid; - - if (wilc->io_type == WILC_HIF_SDIO) { - reg = 0; - reg |= BIT(3); - } else if (wilc->io_type == WILC_HIF_SPI) { - reg = 1; - } - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg); - if (!ret) { - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - return -EIO; - } - reg = 0; - if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num) - reg |= WILC_HAVE_SDIO_IRQ_GPIO; - -#ifdef WILC_DISABLE_PMU -#else - reg |= WILC_HAVE_USE_PMU; -#endif - -#ifdef WILC_SLEEP_CLK_SRC_XO - reg |= WILC_HAVE_SLEEP_CLK_SRC_XO; -#elif defined WILC_SLEEP_CLK_SRC_RTC - reg |= WILC_HAVE_SLEEP_CLK_SRC_RTC; -#endif - -#ifdef WILC_EXT_PA_INV_TX_RX - reg |= WILC_HAVE_EXT_PA_INV_TX_RX; -#endif - reg |= WILC_HAVE_USE_IRQ_AS_HOST_WAKE; - reg |= WILC_HAVE_LEGACY_RF_SETTINGS; -#ifdef XTAL_24 - reg |= WILC_HAVE_XTAL_24; -#endif -#ifdef DISABLE_WILC_UART - reg |= WILC_HAVE_DISABLE_WILC_UART; -#endif - - ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg); - if (!ret) { - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - return -EIO; - } - - wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT); - - ret = wilc->hif_func->hif_read_reg(wilc, 0x1000, &chipid); - if (!ret) { - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - return -EIO; - } - - wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); - if ((reg & BIT(10)) == BIT(10)) { - reg &= ~BIT(10); - wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); - wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); - } - - reg |= BIT(10); - ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); - wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - - return (ret < 0) ? ret : 0; -} - -int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) -{ - u32 reg = 0; - int ret; - - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - - ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®); - if (!ret) { - netdev_err(vif->ndev, "Error while reading reg\n"); - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - return -EIO; - } - - ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, - (reg | WILC_ABORT_REQ_BIT)); - if (!ret) { - netdev_err(vif->ndev, "Error while writing reg\n"); - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - return -EIO; - } - - ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, ®); - if (!ret) { - netdev_err(vif->ndev, "Error while reading reg\n"); - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - return -EIO; - } - reg = BIT(0); - - ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg); - if (!ret) { - netdev_err(vif->ndev, "Error while writing reg\n"); - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - return -EIO; - } - - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - - return 0; -} - -void wilc_wlan_cleanup(struct net_device *dev) -{ - struct txq_entry_t *tqe; - struct rxq_entry_t *rqe; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - wilc->quit = 1; - do { - tqe = wilc_wlan_txq_remove_from_head(dev); - if (!tqe) - break; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, 0); - kfree(tqe); - } while (1); - - do { - rqe = wilc_wlan_rxq_remove(wilc); - if (!rqe) - break; - kfree(rqe); - } while (1); - - kfree(wilc->rx_buffer); - wilc->rx_buffer = NULL; - kfree(wilc->tx_buffer); - wilc->tx_buffer = NULL; - wilc->hif_func->hif_deinit(NULL); -} - -static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, - u32 drv_handler) -{ - struct wilc *wilc = vif->wilc; - struct wilc_cfg_frame *cfg = &wilc->cfg_frame; - int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); - - if (type == WILC_CFG_SET) - cfg->hdr.cmd_type = 'W'; - else - cfg->hdr.cmd_type = 'Q'; - - cfg->hdr.seq_no = wilc->cfg_seq_no % 256; - cfg->hdr.total_len = cpu_to_le16(t_len); - cfg->hdr.driver_handler = cpu_to_le32(drv_handler); - wilc->cfg_seq_no = cfg->hdr.seq_no; - - if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) - return -1; - - return 0; -} - -int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, - u32 buffer_size, int commit, u32 drv_handler) -{ - u32 offset; - int ret_size; - struct wilc *wilc = vif->wilc; - - mutex_lock(&wilc->cfg_cmd_lock); - - if (start) - wilc->cfg_frame_offset = 0; - - offset = wilc->cfg_frame_offset; - ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, - wid, buffer, buffer_size); - offset += ret_size; - wilc->cfg_frame_offset = offset; - - if (!commit) { - mutex_unlock(&wilc->cfg_cmd_lock); - return ret_size; - } - - netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no); - - if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) - ret_size = 0; - - if (!wait_for_completion_timeout(&wilc->cfg_event, - WILC_CFG_PKTS_TIMEOUT)) { - netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); - ret_size = 0; - } - - wilc->cfg_frame_offset = 0; - wilc->cfg_seq_no += 1; - mutex_unlock(&wilc->cfg_cmd_lock); - - return ret_size; -} - -int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, - u32 drv_handler) -{ - u32 offset; - int ret_size; - struct wilc *wilc = vif->wilc; - - mutex_lock(&wilc->cfg_cmd_lock); - - if (start) - wilc->cfg_frame_offset = 0; - - offset = wilc->cfg_frame_offset; - ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, wid); - offset += ret_size; - wilc->cfg_frame_offset = offset; - - if (!commit) { - mutex_unlock(&wilc->cfg_cmd_lock); - return ret_size; - } - - if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler)) - ret_size = 0; - - if (!wait_for_completion_timeout(&wilc->cfg_event, - WILC_CFG_PKTS_TIMEOUT)) { - netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); - ret_size = 0; - } - wilc->cfg_frame_offset = 0; - wilc->cfg_seq_no += 1; - mutex_unlock(&wilc->cfg_cmd_lock); - - return ret_size; -} - -int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, - u32 count) -{ - int i; - int ret = 0; - u32 drv = wilc_get_vif_idx(vif); - - if (mode == WILC_GET_CFG) { - for (i = 0; i < count; i++) { - if (!wilc_wlan_cfg_get(vif, !i, - wids[i].id, - (i == count - 1), - drv)) { - ret = -ETIMEDOUT; - break; - } - } - for (i = 0; i < count; i++) { - wids[i].size = wilc_wlan_cfg_get_val(vif->wilc, - wids[i].id, - wids[i].val, - wids[i].size); - } - } else if (mode == WILC_SET_CFG) { - for (i = 0; i < count; i++) { - if (!wilc_wlan_cfg_set(vif, !i, - wids[i].id, - wids[i].val, - wids[i].size, - (i == count - 1), - drv)) { - ret = -ETIMEDOUT; - break; - } - } - } - - return ret; -} - -static u32 init_chip(struct net_device *dev) -{ - u32 chipid; - u32 reg, ret = 0; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; - - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - - chipid = wilc_get_chipid(wilc, true); - - if ((chipid & 0xfff) != 0xa0) { - ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®); - if (!ret) { - netdev_err(dev, "fail read reg 0x1118\n"); - goto release; - } - reg |= BIT(0); - ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg); - if (!ret) { - netdev_err(dev, "fail write reg 0x1118\n"); - goto release; - } - ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71); - if (!ret) { - netdev_err(dev, "fail write reg 0xc0000\n"); - goto release; - } - } - -release: - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - - return ret; -} - -u32 wilc_get_chipid(struct wilc *wilc, bool update) -{ - static u32 chipid; - u32 tempchipid = 0; - u32 rfrevid = 0; - - if (chipid == 0 || update) { - wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid); - wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid); - if (!is_wilc1000(tempchipid)) { - chipid = 0; - return chipid; - } - if (tempchipid == 0x1002a0) { - if (rfrevid != 0x1) - tempchipid = 0x1002a1; - } else if (tempchipid == 0x1002b0) { - if (rfrevid == 0x4) - tempchipid = 0x1002b1; - else if (rfrevid != 0x3) - tempchipid = 0x1002b2; - } - - chipid = tempchipid; - } - return chipid; -} - -int wilc_wlan_init(struct net_device *dev) -{ - int ret = 0; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc; - - wilc = vif->wilc; - - wilc->quit = 0; - - if (!wilc->hif_func->hif_init(wilc, false)) { - ret = -EIO; - goto fail; - } - - if (!wilc->tx_buffer) - wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); - - if (!wilc->tx_buffer) { - ret = -ENOBUFS; - goto fail; - } - - if (!wilc->rx_buffer) - wilc->rx_buffer = kmalloc(WILC_RX_BUFF_SIZE, GFP_KERNEL); - - if (!wilc->rx_buffer) { - ret = -ENOBUFS; - goto fail; - } - - if (!init_chip(dev)) { - ret = -EIO; - goto fail; - } - - return 1; - -fail: - - kfree(wilc->rx_buffer); - wilc->rx_buffer = NULL; - kfree(wilc->tx_buffer); - wilc->tx_buffer = NULL; - - return ret; -} diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h deleted file mode 100644 index 7469fa47d588..000000000000 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ /dev/null @@ -1,304 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#ifndef WILC_WLAN_H -#define WILC_WLAN_H - -#include - -/******************************************** - * - * Mac eth header length - * - ********************************************/ -#define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */ -#define SUB_MSDU_HEADER_LENGTH 14 -#define SNAP_HDR_LEN 8 -#define ETHERNET_HDR_LEN 14 -#define WORD_ALIGNMENT_PAD 0 - -#define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + \ - SUB_MSDU_HEADER_LENGTH + \ - SNAP_HDR_LEN - \ - ETHERNET_HDR_LEN + \ - WORD_ALIGNMENT_PAD) - -#define HOST_HDR_OFFSET 4 -#define ETHERNET_HDR_LEN 14 -#define IP_HDR_LEN 20 -#define IP_HDR_OFFSET ETHERNET_HDR_LEN -#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET) -#define UDP_HDR_LEN 8 -#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN) -#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET - -#define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \ - ETH_CONFIG_PKT_HDR_LEN) - -/******************************************** - * - * Register Defines - * - ********************************************/ -#define WILC_PERIPH_REG_BASE 0x1000 -#define WILC_CHANGING_VIR_IF 0x108c -#define WILC_CHIPID WILC_PERIPH_REG_BASE -#define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400) -#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408) -#define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c) -#define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70) -#define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74) -#define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78) -#define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) -#define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) -#define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) -#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) -#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) -#define WILC_INTR_ENABLE WILC_INTR_REG_BASE -#define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4) - -#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10) -#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20) -#define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30) -#define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40) - -#define WILC_VMM_TBL_SIZE 64 -#define WILC_VMM_TX_TBL_BASE 0x150400 -#define WILC_VMM_RX_TBL_BASE 0x150500 - -#define WILC_VMM_BASE 0x150000 -#define WILC_VMM_CORE_CTL WILC_VMM_BASE -#define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4) -#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8) -#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc) -#define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10) -#define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14) -#define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040) -#define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44) - -#define WILC_SPI_REG_BASE 0xe800 -#define WILC_SPI_CTL WILC_SPI_REG_BASE -#define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4) -#define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8) -#define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc) -#define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10) -#define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20) -#define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24) -#define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c) - -#define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - \ - WILC_SPI_REG_BASE) - -#define WILC_AHB_DATA_MEM_BASE 0x30000 -#define WILC_AHB_SHARE_MEM_BASE 0xd0000 - -#define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE -#define WILC_VMM_TBL_RX_SHADOW_SIZE 256 - -#define WILC_FW_HOST_COMM 0x13c0 -#define WILC_GP_REG_0 0x149c -#define WILC_GP_REG_1 0x14a0 - -#define WILC_HAVE_SDIO_IRQ_GPIO BIT(0) -#define WILC_HAVE_USE_PMU BIT(1) -#define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2) -#define WILC_HAVE_SLEEP_CLK_SRC_XO BIT(3) -#define WILC_HAVE_EXT_PA_INV_TX_RX BIT(4) -#define WILC_HAVE_LEGACY_RF_SETTINGS BIT(5) -#define WILC_HAVE_XTAL_24 BIT(6) -#define WILC_HAVE_DISABLE_WILC_UART BIT(7) -#define WILC_HAVE_USE_IRQ_AS_HOST_WAKE BIT(8) - -/******************************************** - * - * Wlan Defines - * - ********************************************/ -#define WILC_CFG_PKT 1 -#define WILC_NET_PKT 0 -#define WILC_MGMT_PKT 2 - -#define WILC_CFG_SET 1 -#define WILC_CFG_QUERY 0 - -#define WILC_CFG_RSP 1 -#define WILC_CFG_RSP_STATUS 2 -#define WILC_CFG_RSP_SCAN 3 - -#define WILC_ABORT_REQ_BIT BIT(31) - -#define WILC_RX_BUFF_SIZE (96 * 1024) -#define WILC_TX_BUFF_SIZE (64 * 1024) - -#define MODALIAS "WILC_SPI" -#define GPIO_NUM 0x44 -/*******************************************/ -/* E0 and later Interrupt flags. */ -/*******************************************/ -/*******************************************/ -/* E0 and later Interrupt flags. */ -/* IRQ Status word */ -/* 15:0 = DMA count in words. */ -/* 16: INT0 flag */ -/* 17: INT1 flag */ -/* 18: INT2 flag */ -/* 19: INT3 flag */ -/* 20: INT4 flag */ -/* 21: INT5 flag */ -/*******************************************/ -#define IRG_FLAGS_OFFSET 16 -#define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1) -#define INT_0 BIT(IRG_FLAGS_OFFSET) -#define INT_1 BIT(IRG_FLAGS_OFFSET + 1) -#define INT_2 BIT(IRG_FLAGS_OFFSET + 2) -#define INT_3 BIT(IRG_FLAGS_OFFSET + 3) -#define INT_4 BIT(IRG_FLAGS_OFFSET + 4) -#define INT_5 BIT(IRG_FLAGS_OFFSET + 5) -#define MAX_NUM_INT 6 - -/*******************************************/ -/* E0 and later Interrupt flags. */ -/* IRQ Clear word */ -/* 0: Clear INT0 */ -/* 1: Clear INT1 */ -/* 2: Clear INT2 */ -/* 3: Clear INT3 */ -/* 4: Clear INT4 */ -/* 5: Clear INT5 */ -/* 6: Select VMM table 1 */ -/* 7: Select VMM table 2 */ -/* 8: Enable VMM */ -/*******************************************/ -#define CLR_INT0 BIT(0) -#define CLR_INT1 BIT(1) -#define CLR_INT2 BIT(2) -#define CLR_INT3 BIT(3) -#define CLR_INT4 BIT(4) -#define CLR_INT5 BIT(5) -#define SEL_VMM_TBL0 BIT(6) -#define SEL_VMM_TBL1 BIT(7) -#define EN_VMM BIT(8) - -#define DATA_INT_EXT INT_0 -#define ALL_INT_EXT DATA_INT_EXT -#define NUM_INT_EXT 1 - -#define DATA_INT_CLR CLR_INT0 - -#define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM) -#define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM) -/*time for expiring the completion of cfg packets*/ -#define WILC_CFG_PKTS_TIMEOUT msecs_to_jiffies(2000) - -#define IS_MANAGMEMENT 0x100 -#define IS_MANAGMEMENT_CALLBACK 0x080 -#define IS_MGMT_STATUS_SUCCES 0x040 - -/******************************************** - * - * Tx/Rx Queue Structure - * - ********************************************/ - -struct txq_entry_t { - struct list_head list; - int type; - int ack_idx; - u8 *buffer; - int buffer_size; - void *priv; - int status; - struct wilc_vif *vif; - void (*tx_complete_func)(void *priv, int status); -}; - -struct rxq_entry_t { - struct list_head list; - u8 *buffer; - int buffer_size; -}; - -/******************************************** - * - * Host IF Structure - * - ********************************************/ -struct wilc; -struct wilc_hif_func { - int (*hif_init)(struct wilc *wilc, bool resume); - int (*hif_deinit)(struct wilc *wilc); - int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data); - int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data); - int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); - int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); - int (*hif_read_int)(struct wilc *wilc, u32 *int_status); - int (*hif_clear_int_ext)(struct wilc *wilc, u32 val); - int (*hif_read_size)(struct wilc *wilc, u32 *size); - int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); - int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); - int (*hif_sync_ext)(struct wilc *wilc, int nint); - int (*enable_interrupt)(struct wilc *nic); - void (*disable_interrupt)(struct wilc *nic); -}; - -#define WILC_MAX_CFG_FRAME_SIZE 1468 - -struct tx_complete_data { - int size; - void *buff; - struct sk_buff *skb; -}; - -struct wilc_cfg_cmd_hdr { - u8 cmd_type; - u8 seq_no; - __le16 total_len; - __le32 driver_handler; -}; - -struct wilc_cfg_frame { - struct wilc_cfg_cmd_hdr hdr; - u8 frame[WILC_MAX_CFG_FRAME_SIZE]; -}; - -struct wilc_cfg_rsp { - u8 type; - u8 seq_no; -}; - -struct wilc; -struct wilc_vif; - -int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, - u32 buffer_size); -int wilc_wlan_start(struct wilc *wilc); -int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif); -int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)); -int wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count); -void wilc_handle_isr(struct wilc *wilc); -void wilc_wlan_cleanup(struct net_device *dev); -int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, - u32 buffer_size, int commit, u32 drv_handler); -int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, - u32 drv_handler); -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, void (*func)(void *, int)); -void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value); -int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc); -netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); - -void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size); -void host_wakeup_notify(struct wilc *wilc); -void host_sleep_notify(struct wilc *wilc); -void chip_allow_sleep(struct wilc *wilc); -void chip_wakeup(struct wilc *wilc); -int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, - u32 count); -int wilc_wlan_init(struct net_device *dev); -u32 wilc_get_chipid(struct wilc *wilc, bool update); -#endif diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c deleted file mode 100644 index 3f53807cee0f..000000000000 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ /dev/null @@ -1,457 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include "wilc_wlan_if.h" -#include "wilc_wlan.h" -#include "wilc_wlan_cfg.h" -#include "wilc_wfi_netdevice.h" - -enum cfg_cmd_type { - CFG_BYTE_CMD = 0, - CFG_HWORD_CMD = 1, - CFG_WORD_CMD = 2, - CFG_STR_CMD = 3, - CFG_BIN_CMD = 4 -}; - -static const struct wilc_cfg_byte g_cfg_byte[] = { - {WID_STATUS, 0}, - {WID_RSSI, 0}, - {WID_LINKSPEED, 0}, - {WID_NIL, 0} -}; - -static const struct wilc_cfg_hword g_cfg_hword[] = { - {WID_NIL, 0} -}; - -static const struct wilc_cfg_word g_cfg_word[] = { - {WID_FAILED_COUNT, 0}, - {WID_RECEIVED_FRAGMENT_COUNT, 0}, - {WID_SUCCESS_FRAME_COUNT, 0}, - {WID_GET_INACTIVE_TIME, 0}, - {WID_NIL, 0} - -}; - -static const struct wilc_cfg_str g_cfg_str[] = { - {WID_FIRMWARE_VERSION, NULL}, - {WID_MAC_ADDR, NULL}, - {WID_ASSOC_RES_INFO, NULL}, - {WID_NIL, NULL} -}; - -/******************************************** - * - * Configuration Functions - * - ********************************************/ - -static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8) -{ - if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE) - return 0; - - put_unaligned_le16(id, &frame[offset]); - put_unaligned_le16(1, &frame[offset + 2]); - frame[offset + 4] = val8; - return 5; -} - -static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16) -{ - if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE) - return 0; - - put_unaligned_le16(id, &frame[offset]); - put_unaligned_le16(2, &frame[offset + 2]); - put_unaligned_le16(val16, &frame[offset + 4]); - - return 6; -} - -static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32) -{ - if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE) - return 0; - - put_unaligned_le16(id, &frame[offset]); - put_unaligned_le16(4, &frame[offset + 2]); - put_unaligned_le32(val32, &frame[offset + 4]); - - return 8; -} - -static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str, - u32 size) -{ - if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE) - return 0; - - put_unaligned_le16(id, &frame[offset]); - put_unaligned_le16(size, &frame[offset + 2]); - if (str && size != 0) - memcpy(&frame[offset + 4], str, size); - - return (size + 4); -} - -static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size) -{ - u32 i; - u8 checksum = 0; - - if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE) - return 0; - - put_unaligned_le16(id, &frame[offset]); - put_unaligned_le16(size, &frame[offset + 2]); - - if ((b) && size != 0) { - memcpy(&frame[offset + 4], b, size); - for (i = 0; i < size; i++) - checksum += frame[offset + i + 4]; - } - - frame[offset + size + 4] = checksum; - - return (size + 5); -} - -/******************************************** - * - * Configuration Response Functions - * - ********************************************/ - -#define GET_WID_TYPE(wid) (((wid) >> 12) & 0x7) -static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size) -{ - u16 wid; - u32 len = 0, i = 0; - - while (size > 0) { - i = 0; - wid = get_unaligned_le16(info); - - switch (GET_WID_TYPE(wid)) { - case WID_CHAR: - do { - if (wl->cfg.b[i].id == WID_NIL) - break; - - if (wl->cfg.b[i].id == wid) { - wl->cfg.b[i].val = info[4]; - break; - } - i++; - } while (1); - len = 3; - break; - - case WID_SHORT: - do { - struct wilc_cfg_hword *hw = &wl->cfg.hw[i]; - - if (hw->id == WID_NIL) - break; - - if (hw->id == wid) { - hw->val = get_unaligned_le16(&info[4]); - break; - } - i++; - } while (1); - len = 4; - break; - - case WID_INT: - do { - struct wilc_cfg_word *w = &wl->cfg.w[i]; - - if (w->id == WID_NIL) - break; - - if (w->id == wid) { - w->val = get_unaligned_le32(&info[4]); - break; - } - i++; - } while (1); - len = 6; - break; - - case WID_STR: - do { - if (wl->cfg.s[i].id == WID_NIL) - break; - - if (wl->cfg.s[i].id == wid) { - memcpy(wl->cfg.s[i].str, &info[2], - (info[2] + 2)); - break; - } - i++; - } while (1); - len = 2 + info[2]; - break; - - default: - break; - } - size -= (2 + len); - info += (2 + len); - } -} - -static void wilc_wlan_parse_info_frame(struct wilc *wl, u8 *info) -{ - u32 wid, len; - - wid = get_unaligned_le16(info); - - len = info[2]; - - if (len == 1 && wid == WID_STATUS) { - int i = 0; - - do { - if (wl->cfg.b[i].id == WID_NIL) - break; - - if (wl->cfg.b[i].id == wid) { - wl->cfg.b[i].val = info[3]; - break; - } - i++; - } while (1); - } -} - -/******************************************** - * - * Configuration Exported Functions - * - ********************************************/ - -int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size) -{ - u8 type = (id >> 12) & 0xf; - int ret = 0; - - switch (type) { - case CFG_BYTE_CMD: - if (size >= 1) - ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf); - break; - - case CFG_HWORD_CMD: - if (size >= 2) - ret = wilc_wlan_cfg_set_hword(frame, offset, id, - *((u16 *)buf)); - break; - - case CFG_WORD_CMD: - if (size >= 4) - ret = wilc_wlan_cfg_set_word(frame, offset, id, - *((u32 *)buf)); - break; - - case CFG_STR_CMD: - ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); - break; - - case CFG_BIN_CMD: - ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); - break; - } - - return ret; -} - -int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id) -{ - if ((offset + 2) >= WILC_MAX_CFG_FRAME_SIZE) - return 0; - - put_unaligned_le16(id, &frame[offset]); - - return 2; -} - -int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer, - u32 buffer_size) -{ - u32 type = (wid >> 12) & 0xf; - int i, ret = 0; - - i = 0; - if (type == CFG_BYTE_CMD) { - do { - if (wl->cfg.b[i].id == WID_NIL) - break; - - if (wl->cfg.b[i].id == wid) { - memcpy(buffer, &wl->cfg.b[i].val, 1); - ret = 1; - break; - } - i++; - } while (1); - } else if (type == CFG_HWORD_CMD) { - do { - if (wl->cfg.hw[i].id == WID_NIL) - break; - - if (wl->cfg.hw[i].id == wid) { - memcpy(buffer, &wl->cfg.hw[i].val, 2); - ret = 2; - break; - } - i++; - } while (1); - } else if (type == CFG_WORD_CMD) { - do { - if (wl->cfg.w[i].id == WID_NIL) - break; - - if (wl->cfg.w[i].id == wid) { - memcpy(buffer, &wl->cfg.w[i].val, 4); - ret = 4; - break; - } - i++; - } while (1); - } else if (type == CFG_STR_CMD) { - do { - u32 id = wl->cfg.s[i].id; - - if (id == WID_NIL) - break; - - if (id == wid) { - u16 size = get_unaligned_le16(wl->cfg.s[i].str); - - if (buffer_size >= size) { - memcpy(buffer, &wl->cfg.s[i].str[2], - size); - ret = size; - } - break; - } - i++; - } while (1); - } - return ret; -} - -void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, - struct wilc_cfg_rsp *rsp) -{ - u8 msg_type; - u8 msg_id; - - msg_type = frame[0]; - msg_id = frame[1]; /* seq no */ - frame += 4; - size -= 4; - rsp->type = 0; - - /* - * The valid types of response messages are - * 'R' (Response), - * 'I' (Information), and - * 'N' (Network Information) - */ - - switch (msg_type) { - case 'R': - wilc_wlan_parse_response_frame(wilc, frame, size); - rsp->type = WILC_CFG_RSP; - rsp->seq_no = msg_id; - break; - - case 'I': - wilc_wlan_parse_info_frame(wilc, frame); - rsp->type = WILC_CFG_RSP_STATUS; - rsp->seq_no = msg_id; - /*call host interface info parse as well*/ - wilc_gnrl_async_info_received(wilc, frame - 4, size + 4); - break; - - case 'N': - wilc_network_info_received(wilc, frame - 4, size + 4); - break; - - case 'S': - wilc_scan_complete_received(wilc, frame - 4, size + 4); - break; - - default: - rsp->seq_no = msg_id; - break; - } -} - -int wilc_wlan_cfg_init(struct wilc *wl) -{ - struct wilc_cfg_str_vals *str_vals; - int i = 0; - - wl->cfg.b = kmemdup(g_cfg_byte, sizeof(g_cfg_byte), GFP_KERNEL); - if (!wl->cfg.b) - return -ENOMEM; - - wl->cfg.hw = kmemdup(g_cfg_hword, sizeof(g_cfg_hword), GFP_KERNEL); - if (!wl->cfg.hw) - goto out_b; - - wl->cfg.w = kmemdup(g_cfg_word, sizeof(g_cfg_word), GFP_KERNEL); - if (!wl->cfg.w) - goto out_hw; - - wl->cfg.s = kmemdup(g_cfg_str, sizeof(g_cfg_str), GFP_KERNEL); - if (!wl->cfg.s) - goto out_w; - - str_vals = kzalloc(sizeof(*str_vals), GFP_KERNEL); - if (!str_vals) - goto out_s; - - wl->cfg.str_vals = str_vals; - /* store the string cfg parameters */ - wl->cfg.s[i].id = WID_FIRMWARE_VERSION; - wl->cfg.s[i].str = str_vals->firmware_version; - i++; - wl->cfg.s[i].id = WID_MAC_ADDR; - wl->cfg.s[i].str = str_vals->mac_address; - i++; - wl->cfg.s[i].id = WID_ASSOC_RES_INFO; - wl->cfg.s[i].str = str_vals->assoc_rsp; - i++; - wl->cfg.s[i].id = WID_NIL; - wl->cfg.s[i].str = NULL; - return 0; - -out_s: - kfree(wl->cfg.s); -out_w: - kfree(wl->cfg.w); -out_hw: - kfree(wl->cfg.hw); -out_b: - kfree(wl->cfg.b); - return -ENOMEM; -} - -void wilc_wlan_cfg_deinit(struct wilc *wl) -{ - kfree(wl->cfg.b); - kfree(wl->cfg.hw); - kfree(wl->cfg.w); - kfree(wl->cfg.s); - kfree(wl->cfg.str_vals); -} diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h deleted file mode 100644 index 614c5673f232..000000000000 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.h +++ /dev/null @@ -1,54 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#ifndef WILC_WLAN_CFG_H -#define WILC_WLAN_CFG_H - -struct wilc_cfg_byte { - u16 id; - u8 val; -}; - -struct wilc_cfg_hword { - u16 id; - u16 val; -}; - -struct wilc_cfg_word { - u16 id; - u32 val; -}; - -struct wilc_cfg_str { - u16 id; - u8 *str; -}; - -struct wilc_cfg_str_vals { - u8 mac_address[7]; - u8 firmware_version[129]; - u8 assoc_rsp[256]; -}; - -struct wilc_cfg { - struct wilc_cfg_byte *b; - struct wilc_cfg_hword *hw; - struct wilc_cfg_word *w; - struct wilc_cfg_str *s; - struct wilc_cfg_str_vals *str_vals; -}; - -struct wilc; -int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size); -int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id); -int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer, - u32 buffer_size); -void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, - struct wilc_cfg_rsp *rsp); -int wilc_wlan_cfg_init(struct wilc *wl); -void wilc_wlan_cfg_deinit(struct wilc *wl); - -#endif diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h deleted file mode 100644 index 70eac586f80c..000000000000 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ /dev/null @@ -1,802 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#ifndef WILC_WLAN_IF_H -#define WILC_WLAN_IF_H - -#include - -/******************************************** - * - * Wlan Configuration ID - * - ********************************************/ - -enum bss_types { - WILC_FW_BSS_TYPE_INFRA = 0, - WILC_FW_BSS_TYPE_INDEPENDENT, - WILC_FW_BSS_TYPE_AP, -}; - -enum { - WILC_FW_OPER_MODE_B_ONLY = 0, /* 1, 2 M, otherwise 5, 11 M */ - WILC_FW_OPER_MODE_G_ONLY, /* 6,12,24 otherwise 9,18,36,48,54 */ - WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */ - WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */ -}; - -enum { - WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */ - WILC_FW_PREAMBLE_LONG = 1, /* Long Preamble */ - WILC_FW_PREAMBLE_AUTO = 2, /* Auto Preamble Selection */ -}; - -enum { - WILC_FW_PASSIVE_SCAN = 0, - WILC_FW_ACTIVE_SCAN = 1, -}; - -enum { - WILC_FW_NO_POWERSAVE = 0, - WILC_FW_MIN_FAST_PS = 1, - WILC_FW_MAX_FAST_PS = 2, - WILC_FW_MIN_PSPOLL_PS = 3, - WILC_FW_MAX_PSPOLL_PS = 4 -}; - -enum chip_ps_states { - WILC_CHIP_WAKEDUP = 0, - WILC_CHIP_SLEEPING_AUTO = 1, - WILC_CHIP_SLEEPING_MANUAL = 2 -}; - -enum bus_acquire { - WILC_BUS_ACQUIRE_ONLY = 0, - WILC_BUS_ACQUIRE_AND_WAKEUP = 1, -}; - -enum bus_release { - WILC_BUS_RELEASE_ONLY = 0, - WILC_BUS_RELEASE_ALLOW_SLEEP = 1, -}; - -enum { - WILC_FW_NO_ENCRYPT = 0, - WILC_FW_ENCRYPT_ENABLED = BIT(0), - WILC_FW_WEP = BIT(1), - WILC_FW_WEP_EXTENDED = BIT(2), - WILC_FW_WPA = BIT(3), - WILC_FW_WPA2 = BIT(4), - WILC_FW_AES = BIT(5), - WILC_FW_TKIP = BIT(6) -}; - -enum { - WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT, - WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED, - WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP, - WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED, - WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA, - WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA, - WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED, - WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2, - WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2 -}; - -enum authtype { - WILC_FW_AUTH_OPEN_SYSTEM = 1, - WILC_FW_AUTH_SHARED_KEY = 2, - WILC_FW_AUTH_ANY = 3, - WILC_FW_AUTH_IEEE8021 = 5 -}; - -enum site_survey { - WILC_FW_SITE_SURVEY_1CH = 0, - WILC_FW_SITE_SURVEY_ALL_CH = 1, - WILC_FW_SITE_SURVEY_OFF = 2 -}; - -enum { - WILC_FW_ACK_POLICY_NORMAL = 0, - WILC_FW_ACK_NO_POLICY, -}; - -enum { - WILC_FW_REKEY_POLICY_DISABLE = 1, - WILC_FW_REKEY_POLICY_TIME_BASE, - WILC_FW_REKEY_POLICY_PKT_BASE, - WILC_FW_REKEY_POLICY_TIME_PKT_BASE -}; - -enum { - WILC_FW_FILTER_NO = 0x00, - WILC_FW_FILTER_AP_ONLY = 0x01, - WILC_FW_FILTER_STA_ONLY = 0x02 -}; - -enum { - WILC_FW_11N_PROT_AUTO = 0, /* Auto */ - WILC_FW_11N_NO_PROT, /* Do not use any protection */ - WILC_FW_11N_PROT_ERP, /* Protect all ERP frame exchanges */ - WILC_FW_11N_PROT_HT, /* Protect all HT frame exchanges */ - WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges */ -}; - -enum { - WILC_FW_ERP_PROT_SELF_CTS, - WILC_FW_ERP_PROT_RTS_CTS, -}; - -enum { - WILC_FW_11N_OP_MODE_HT_MIXED = 1, - WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ, - WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ, -}; - -enum { - WILC_FW_OBBS_NONHT_NO_DETECT = 0, - WILC_FW_OBBS_NONHT_DETECT_ONLY = 1, - WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2, - WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3, -}; - -enum { - WILC_FW_HT_PROT_RTS_CTS_NONHT = 0, /* RTS-CTS at non-HT rate */ - WILC_FW_HT_PROT_FIRST_FRAME_NONHT, /* First frame at non-HT rate */ - WILC_FW_HT_PROT_LSIG_TXOP, /* LSIG TXOP Protection */ - WILC_FW_HT_PROT_FIRST_FRAME_MIXED, /* First frame at Mixed format */ -}; - -enum { - WILC_FW_SMPS_MODE_STATIC = 1, - WILC_FW_SMPS_MODE_DYNAMIC = 2, - WILC_FW_SMPS_MODE_MIMO = 3, /* power save disable */ -}; - -enum { - WILC_FW_TX_RATE_AUTO = 0, - WILC_FW_TX_RATE_MBPS_1 = 1, - WILC_FW_TX_RATE_MBPS_2 = 2, - WILC_FW_TX_RATE_MBPS_5_5 = 5, - WILC_FW_TX_RATE_MBPS_11 = 11, - WILC_FW_TX_RATE_MBPS_6 = 6, - WILC_FW_TX_RATE_MBPS_9 = 9, - WILC_FW_TX_RATE_MBPS_12 = 12, - WILC_FW_TX_RATE_MBPS_18 = 18, - WILC_FW_TX_RATE_MBPS_24 = 24, - WILC_FW_TX_RATE_MBPS_36 = 36, - WILC_FW_TX_RATE_MBPS_48 = 48, - WILC_FW_TX_RATE_MBPS_54 = 54 -}; - -enum { - WILC_FW_DEFAULT_SCAN = 0, - WILC_FW_USER_SCAN = BIT(0), - WILC_FW_OBSS_PERIODIC_SCAN = BIT(1), - WILC_FW_OBSS_ONETIME_SCAN = BIT(2) -}; - -enum { - WILC_FW_ACTION_FRM_IDX = 0, - WILC_FW_PROBE_REQ_IDX = 1 -}; - -enum wid_type { - WID_CHAR = 0, - WID_SHORT = 1, - WID_INT = 2, - WID_STR = 3, - WID_BIN_DATA = 4, - WID_BIN = 5, -}; - -struct wid { - u16 id; - enum wid_type type; - s32 size; - s8 *val; -}; - -enum { - WID_NIL = 0xffff, - - /* - * BSS Type - * ----------------------------------------------------------- - * Configuration : Infrastructure Independent Access Point - * Values to set : 0 1 2 - * ----------------------------------------------------------- - */ - WID_BSS_TYPE = 0x0000, - - /* - * Transmit Rate - * ----------------------------------------------------------- - * Configuration : 1 2 5.5 11 6 9 12 18 24 36 48 54 - * Values to set : 1 2 5 11 6 9 12 18 24 36 48 54 - * ----------------------------------------------------------- - */ - WID_CURRENT_TX_RATE = 0x0001, - - /* - * Channel - * ----------------------------------------------------------- - * Configuration(g) : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - * Values to set : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - * ----------------------------------------------------------- - */ - WID_CURRENT_CHANNEL = 0x0002, - - /* - * Preamble - * ----------------------------------------------------------- - * Configuration : short long Auto - * Values to set : 0 1 2 - * ----------------------------------------------------------- - */ - WID_PREAMBLE = 0x0003, - - /* - * 11g operating mode (ignored if 11g not present) - * ----------------------------------------------------------- - * Configuration : HighPerf Compat(RSet #1) Compat(RSet #2) - * Values to set : 1 2 3 - * ----------------------------------------------------------- - */ - WID_11G_OPERATING_MODE = 0x0004, - - /* - * Mac status (response only) - * ----------------------------------------------------------- - * Configuration : disconnect connect - * Values to get : 0 1 - * ----------------------------------------------------------- - */ - WID_STATUS = 0x0005, - - /* - * Scan type - * ----------------------------------------------------------- - * Configuration : Passive Scanning Active Scanning - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_SCAN_TYPE = 0x0007, - - /* - * Key Id (WEP default key Id) - * ----------------------------------------------------------- - * Configuration : Any value between 0 to 3 - * Values to set : Same value. Default is 0 - * ----------------------------------------------------------- - */ - WID_KEY_ID = 0x0009, - - /* - * QoS Enable - * ----------------------------------------------------------- - * Configuration : QoS Disable WMM Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_QOS_ENABLE = 0x000A, - - /* - * Power Management - * ----------------------------------------------------------- - * Configuration : NO_POWERSAVE MIN_POWERSAVE MAX_POWERSAVE - * Values to set : 0 1 2 - * ----------------------------------------------------------- - */ - WID_POWER_MANAGEMENT = 0x000B, - - /* - * WEP/802 11I Configuration - * ----------------------------------------------------------- - * Configuration:Disable WP40 WP104 WPA-AES WPA-TKIP RSN-AES RSN-TKIP - * Values (0x) : 00 03 07 29 49 31 51 - * Configuration:WPA-AES+TKIP RSN-AES+TKIP - * Values (0x) : 69 71 - * ----------------------------------------------------------- - */ - WID_11I_MODE = 0x000C, - - /* - * WEP Configuration: Used in BSS STA mode only when WEP is enabled - * ----------------------------------------------------------- - * Configuration : Open System Shared Key Any Type | 802.1x Auth - * Values (0x) : 01 02 03 | BIT2 - * ----------------------------------------------------------- - */ - WID_AUTH_TYPE = 0x000D, - - /* - * Site Survey Type - * ----------------------------------------------------------- - * Configuration : Values to set - * Survey 1 Channel : 0 - * survey all Channels : 1 - * Disable Site Survey : 2 - * ----------------------------------------------------------- - */ - WID_SITE_SURVEY = 0x000E, - - /* - * Listen Interval - * ----------------------------------------------------------- - * Configuration : Any value between 1 to 255 - * Values to set : Same value. Default is 3 - * ----------------------------------------------------------- - */ - WID_LISTEN_INTERVAL = 0x000F, - - /* - * DTIM Period - * ----------------------------------------------------------- - * Configuration : Any value between 1 to 255 - * Values to set : Same value. Default is 3 - * ----------------------------------------------------------- - */ - WID_DTIM_PERIOD = 0x0010, - - /* - * ACK Policy - * ----------------------------------------------------------- - * Configuration : Normal Ack No Ack - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_ACK_POLICY = 0x0011, - - /* - * Reset MAC (Set only) - * ----------------------------------------------------------- - * Configuration : Don't Reset Reset No Request - * Values to set : 0 1 2 - * ----------------------------------------------------------- - */ - WID_RESET = 0x0012, - - /* - * Broadcast SSID Option: Setting this will adhere to "" SSID element - * ----------------------------------------------------------- - * Configuration : Enable Disable - * Values to set : 1 0 - * ----------------------------------------------------------- - */ - WID_BCAST_SSID = 0x0015, - - /* - * Disconnect (Station) - * ----------------------------------------------------------- - * Configuration : Association ID - * Values to set : Association ID - * ----------------------------------------------------------- - */ - WID_DISCONNECT = 0x0016, - - /* - * 11a Tx Power Level - * ----------------------------------------------------------- - * Configuration : Sets TX Power (Higher the value greater the power) - * Values to set : Any value between 0 and 63 (inclusive Default 48) - * ----------------------------------------------------------- - */ - WID_TX_POWER_LEVEL_11A = 0x0018, - - /* - * Group Key Update Policy Selection - * ----------------------------------------------------------- - * Configuration : Disabled timeBased packetBased timePacketBased - * Values to set : 1 2 3 4 - * ----------------------------------------------------------- - */ - WID_REKEY_POLICY = 0x0019, - - /* - * Allow Short Slot - * ----------------------------------------------------------- - * Configuration : Disallow Short Slot Allow Short Slot - * (Enable Only Long Slot) (Enable Short Slot if applicable) - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_SHORT_SLOT_ALLOWED = 0x001A, - - WID_PHY_ACTIVE_REG = 0x001B, - - /* - * 11b Tx Power Level - * ----------------------------------------------------------- - * Configuration : Sets TX Power (Higher the value greater the power) - * Values to set : Any value between 0 and 63 (inclusive Default 48) - * ----------------------------------------------------------- - */ - WID_TX_POWER_LEVEL_11B = 0x001D, - - /* - * Scan Request - * ----------------------------------------------------------- - * Configuration : Request default scan - * Values to set : 0 - * ----------------------------------------------------------- - */ - WID_START_SCAN_REQ = 0x001E, - - /* - * Rssi (get only) - * ----------------------------------------------------------- - * Configuration : - * Values to get : Rssi value - * ----------------------------------------------------------- - */ - WID_RSSI = 0x001F, - - /* - * Join Request - * ----------------------------------------------------------- - * Configuration : Request to join - * Values to set : index of scan result - * ----------------------------------------------------------- - */ - WID_JOIN_REQ = 0x0020, - - WID_LINKSPEED = 0x0026, - - /* - * Enable User Control of TX Power - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_USER_CONTROL_ON_TX_POWER = 0x0027, - - WID_MEMORY_ACCESS_8BIT = 0x0029, - - /* - * Enable Auto RX Sensitivity feature - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_AUTO_RX_SENSITIVITY = 0x0032, - - /* - * Receive Buffer Based Ack - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_DATAFLOW_CONTROL = 0x0033, - - /* - * Scan Filter - * ----------------------------------------------------------- - * Configuration : Class No filter AP only Station Only - * Values to set : 0 1 2 - * Configuration : Priority High Rssi Low Rssi Detect - * Values to set : 0 0x4 0x0 - * Configuration : Channel filter off filter on - * Values to set : 0 0x10 - * ----------------------------------------------------------- - */ - WID_SCAN_FILTER = 0x0036, - - /* - * Link Loss Threshold (measure in the beacon period) - * ----------------------------------------------------------- - * Configuration : Any value between 10 and 254(Set to 255 disable) - * Values to set : Same value. Default is 10 - * ----------------------------------------------------------- - */ - WID_LINK_LOSS_THRESHOLD = 0x0037, - - WID_ABORT_RUNNING_SCAN = 0x003E, - - /* NMAC Character WID list */ - WID_WPS_START = 0x0043, - - /* - * Protection mode for MAC - * ----------------------------------------------------------- - * Configuration : Auto No protection ERP HT GF - * Values to set : 0 1 2 3 4 - * ----------------------------------------------------------- - */ - WID_11N_PROT_MECH = 0x0080, - - /* - * ERP Protection type for MAC - * ----------------------------------------------------------- - * Configuration : Self-CTS RTS-CTS - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_11N_ERP_PROT_TYPE = 0x0081, - - /* - * HT Option Enable - * ----------------------------------------------------------- - * Configuration : HT Enable HT Disable - * Values to set : 1 0 - * ----------------------------------------------------------- - */ - WID_11N_ENABLE = 0x0082, - - /* - * 11n Operating mode (Note that 11g operating mode will also be - * used in addition to this, if this is set to HT Mixed mode) - * ----------------------------------------------------------- - * Configuration : HT Mixed HT Only-20MHz HT Only-20/40MHz - * Values to set : 1 2 3 - * ----------------------------------------------------------- - */ - WID_11N_OPERATING_MODE = 0x0083, - - /* - * 11n OBSS non-HT STA Detection flag - * ----------------------------------------------------------- - * Configuration : Do not detect - * Values to set : 0 - * Configuration : Detect, do not protect or report - * Values to set : 1 - * Configuration : Detect, protect and do not report - * Values to set : 2 - * Configuration : Detect, protect and report to other BSS - * Values to set : 3 - * ----------------------------------------------------------- - */ - WID_11N_OBSS_NONHT_DETECTION = 0x0084, - - /* - * 11n HT Protection Type - * ----------------------------------------------------------- - * Configuration : RTS-CTS First Frame Exchange at non-HT-rate - * Values to set : 0 1 - * Configuration : LSIG TXOP First Frame Exchange in Mixed Fmt - * Values to set : 2 3 - * ----------------------------------------------------------- - */ - WID_11N_HT_PROT_TYPE = 0x0085, - - /* - * 11n RIFS Protection Enable Flag - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_11N_RIFS_PROT_ENABLE = 0x0086, - - /* - * SMPS Mode - * ----------------------------------------------------------- - * Configuration : Static Dynamic MIMO (Power Save Disabled) - * Values to set : 1 2 3 - * ----------------------------------------------------------- - */ - WID_11N_SMPS_MODE = 0x0087, - - /* - * Current transmit MCS - * ----------------------------------------------------------- - * Configuration : MCS Index for data rate - * Values to set : 0 to 7 - * ----------------------------------------------------------- - */ - WID_11N_CURRENT_TX_MCS = 0x0088, - - WID_11N_PRINT_STATS = 0x0089, - - /* - * 11n Short GI Enable Flag - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_11N_SHORT_GI_ENABLE = 0x008D, - - /* - * 11n RIFS Enable Flag - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_RIFS_MODE = 0x0094, - - /* - * TX Abort Feature - * ----------------------------------------------------------- - * Configuration : Disable Self CTS Enable Self CTS - * Values to set : 0 1 - * Configuration : Disable TX Abort Enable TX Abort - * Values to set : 2 3 - * Configuration : Enable HW TX Abort Enable SW TX Abort - * Values to set : 4 5 - * ----------------------------------------------------------- - */ - WID_TX_ABORT_CONFIG = 0x00A1, - - WID_REG_TSSI_11B_VALUE = 0x00A6, - WID_REG_TSSI_11G_VALUE = 0x00A7, - WID_REG_TSSI_11N_VALUE = 0x00A8, - WID_TX_CALIBRATION = 0x00A9, - WID_DSCR_TSSI_11B_VALUE = 0x00AA, - WID_DSCR_TSSI_11G_VALUE = 0x00AB, - WID_DSCR_TSSI_11N_VALUE = 0x00AC, - - /* - * Immediate Block-Ack Support - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 0 1 - * ----------------------------------------------------------- - */ - WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF, - - /* - * TXOP Disable Flag - * ----------------------------------------------------------- - * Configuration : Disable Enable - * Values to set : 1 0 - * ----------------------------------------------------------- - */ - WID_11N_TXOP_PROT_DISABLE = 0x00B0, - - WID_TX_POWER_LEVEL_11N = 0x00B1, - - /* Custom Character WID list */ - /* SCAN Complete notification WID*/ - WID_SCAN_COMPLETE = 0x00C9, - - WID_DEL_BEACON = 0x00CA, - - WID_LOG_TERMINAL_SWITCH = 0x00CD, - WID_TX_POWER = 0x00CE, - /* EMAC Short WID list */ - /* RTS Threshold */ - /* - * ----------------------------------------------------------- - * Configuration : Any value between 256 to 2347 - * Values to set : Same value. Default is 2347 - * ----------------------------------------------------------- - */ - WID_RTS_THRESHOLD = 0x1000, - - /* - * Fragmentation Threshold - * ----------------------------------------------------------- - * Configuration : Any value between 256 to 2346 - * Values to set : Same value. Default is 2346 - * ----------------------------------------------------------- - */ - WID_FRAG_THRESHOLD = 0x1001, - - WID_SHORT_RETRY_LIMIT = 0x1002, - WID_LONG_RETRY_LIMIT = 0x1003, - WID_BEACON_INTERVAL = 0x1006, - WID_MEMORY_ACCESS_16BIT = 0x1008, - WID_PASSIVE_SCAN_TIME = 0x100D, - WID_JOIN_START_TIMEOUT = 0x100F, - WID_ASOC_TIMEOUT = 0x1011, - WID_11I_PROTOCOL_TIMEOUT = 0x1012, - WID_EAPOL_RESPONSE_TIMEOUT = 0x1013, - - /* NMAC Short WID list */ - WID_11N_SIG_QUAL_VAL = 0x1085, - WID_CCA_THRESHOLD = 0x1087, - - /* Custom Short WID list */ - - /* EMAC Integer WID list */ - WID_FAILED_COUNT = 0x2000, - WID_RETRY_COUNT = 0x2001, - WID_MULTIPLE_RETRY_COUNT = 0x2002, - WID_FRAME_DUPLICATE_COUNT = 0x2003, - WID_ACK_FAILURE_COUNT = 0x2004, - WID_RECEIVED_FRAGMENT_COUNT = 0x2005, - WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006, - WID_FCS_ERROR_COUNT = 0x2007, - WID_SUCCESS_FRAME_COUNT = 0x2008, - WID_HUT_TX_COUNT = 0x200A, - WID_TX_FRAGMENT_COUNT = 0x200B, - WID_TX_MULTICAST_FRAME_COUNT = 0x200C, - WID_RTS_SUCCESS_COUNT = 0x200D, - WID_RTS_FAILURE_COUNT = 0x200E, - WID_WEP_UNDECRYPTABLE_COUNT = 0x200F, - WID_REKEY_PERIOD = 0x2010, - WID_REKEY_PACKET_COUNT = 0x2011, - WID_1X_SERV_ADDR = 0x2012, - WID_STACK_IP_ADDR = 0x2013, - WID_STACK_NETMASK_ADDR = 0x2014, - WID_HW_RX_COUNT = 0x2015, - WID_MEMORY_ADDRESS = 0x201E, - WID_MEMORY_ACCESS_32BIT = 0x201F, - - /* NMAC Integer WID list */ - /* Custom Integer WID list */ - WID_GET_INACTIVE_TIME = 0x2084, - /* EMAC String WID list */ - WID_SSID = 0x3000, - WID_FIRMWARE_VERSION = 0x3001, - WID_OPERATIONAL_RATE_SET = 0x3002, - WID_BSSID = 0x3003, - WID_WEP_KEY_VALUE = 0x3004, - WID_11I_PSK = 0x3008, - WID_11E_P_ACTION_REQ = 0x3009, - WID_1X_KEY = 0x300A, - WID_HARDWARE_VERSION = 0x300B, - WID_MAC_ADDR = 0x300C, - WID_HUT_DEST_ADDR = 0x300D, - WID_PHY_VERSION = 0x300F, - WID_SUPP_USERNAME = 0x3010, - WID_SUPP_PASSWORD = 0x3011, - WID_SITE_SURVEY_RESULTS = 0x3012, - WID_RX_POWER_LEVEL = 0x3013, - WID_SET_STA_MAC_INACTIVE_TIME = 0x3017, - WID_ADD_WEP_KEY = 0x3019, - WID_REMOVE_WEP_KEY = 0x301A, - WID_ADD_PTK = 0x301B, - WID_ADD_RX_GTK = 0x301C, - WID_ADD_TX_GTK = 0x301D, - WID_REMOVE_KEY = 0x301E, - WID_ASSOC_REQ_INFO = 0x301F, - WID_ASSOC_RES_INFO = 0x3020, - WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ - WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ - WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ - WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ - - /* NMAC String WID list */ - WID_SET_OPERATION_MODE = 0x3079, - WID_11N_P_ACTION_REQ = 0x3080, - WID_HUT_TEST_ID = 0x3081, - WID_PMKID_INFO = 0x3082, - WID_FIRMWARE_INFO = 0x3083, - WID_REGISTER_FRAME = 0x3084, - WID_DEL_ALL_STA = 0x3085, - WID_REMAIN_ON_CHAN = 0x3996, - WID_SSID_PROBE_REQ = 0x3997, - WID_JOIN_REQ_EXTENDED = 0x3998, - - WID_IP_ADDRESS = 0x3999, - - /* Custom String WID list */ - - /* EMAC Binary WID list */ - WID_UAPSD_CONFIG = 0x4001, - WID_UAPSD_STATUS = 0x4002, - WID_WMM_AP_AC_PARAMS = 0x4003, - WID_WMM_STA_AC_PARAMS = 0x4004, - WID_NETWORK_INFO = 0x4005, - WID_STA_JOIN_INFO = 0x4006, - WID_CONNECTED_STA_LIST = 0x4007, - - /* NMAC Binary WID list */ - WID_11N_AUTORATE_TABLE = 0x4080, - - WID_SCAN_CHANNEL_LIST = 0x4084, - - WID_INFO_ELEMENT_PROBE = 0x4085, - WID_INFO_ELEMENT_ASSOCIATE = 0x4086, - WID_ADD_STA = 0X4087, - WID_REMOVE_STA = 0X4088, - WID_EDIT_STA = 0X4089, - WID_ADD_BEACON = 0x408a, - - WID_SETUP_MULTICAST_FILTER = 0x408b, - - /* Miscellaneous WIDs */ - WID_ALL = 0x7FFE, - WID_MAX = 0xFFFF -}; - -#endif diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c new file mode 100644 index 000000000000..d3de76126b78 --- /dev/null +++ b/drivers/staging/wilc1000/wlan.c @@ -0,0 +1,1269 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include +#include +#include "cfg80211.h" +#include "wlan_cfg.h" + +static inline bool is_wilc1000(u32 id) +{ + return (id & 0xfffff000) == 0x100000; +} + +static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) +{ + mutex_lock(&wilc->hif_cs); + if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP) + chip_wakeup(wilc); +} + +static inline void release_bus(struct wilc *wilc, enum bus_release release) +{ + if (release == WILC_BUS_RELEASE_ALLOW_SLEEP) + chip_allow_sleep(wilc); + mutex_unlock(&wilc->hif_cs); +} + +static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe) +{ + list_del(&tqe->list); + wilc->txq_entries -= 1; +} + +static struct txq_entry_t * +wilc_wlan_txq_remove_from_head(struct net_device *dev) +{ + struct txq_entry_t *tqe = NULL; + unsigned long flags; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + + if (!list_empty(&wilc->txq_head.list)) { + tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, + list); + list_del(&tqe->list); + wilc->txq_entries -= 1; + } + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + return tqe; +} + +static void wilc_wlan_txq_add_to_tail(struct net_device *dev, + struct txq_entry_t *tqe) +{ + unsigned long flags; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + + list_add_tail(&tqe->list, &wilc->txq_head.list); + wilc->txq_entries += 1; + + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + + complete(&wilc->txq_event); +} + +static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, + struct txq_entry_t *tqe) +{ + unsigned long flags; + struct wilc *wilc = vif->wilc; + + mutex_lock(&wilc->txq_add_to_head_cs); + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + + list_add(&tqe->list, &wilc->txq_head.list); + wilc->txq_entries += 1; + + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + mutex_unlock(&wilc->txq_add_to_head_cs); + complete(&wilc->txq_event); +} + +#define NOT_TCP_ACK (-1) + +static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt, + u32 dst_prt, u32 seq) +{ + struct tcp_ack_filter *f = &vif->ack_filter; + + if (f->tcp_session < 2 * MAX_TCP_SESSION) { + f->ack_session_info[f->tcp_session].seq_num = seq; + f->ack_session_info[f->tcp_session].bigger_ack_num = 0; + f->ack_session_info[f->tcp_session].src_port = src_prt; + f->ack_session_info[f->tcp_session].dst_port = dst_prt; + f->tcp_session++; + } +} + +static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack) +{ + struct tcp_ack_filter *f = &vif->ack_filter; + + if (index < 2 * MAX_TCP_SESSION && + ack > f->ack_session_info[index].bigger_ack_num) + f->ack_session_info[index].bigger_ack_num = ack; +} + +static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, + u32 session_index, + struct txq_entry_t *txqe) +{ + struct tcp_ack_filter *f = &vif->ack_filter; + u32 i = f->pending_base + f->pending_acks_idx; + + if (i < MAX_PENDING_ACKS) { + f->pending_acks[i].ack_num = ack; + f->pending_acks[i].txqe = txqe; + f->pending_acks[i].session_index = session_index; + txqe->ack_idx = i; + f->pending_acks_idx++; + } +} + +static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) +{ + void *buffer = tqe->buffer; + const struct ethhdr *eth_hdr_ptr = buffer; + int i; + unsigned long flags; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + struct tcp_ack_filter *f = &vif->ack_filter; + const struct iphdr *ip_hdr_ptr; + const struct tcphdr *tcp_hdr_ptr; + u32 ihl, total_length, data_offset; + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + + if (eth_hdr_ptr->h_proto != htons(ETH_P_IP)) + goto out; + + ip_hdr_ptr = buffer + ETH_HLEN; + + if (ip_hdr_ptr->protocol != IPPROTO_TCP) + goto out; + + ihl = ip_hdr_ptr->ihl << 2; + tcp_hdr_ptr = buffer + ETH_HLEN + ihl; + total_length = ntohs(ip_hdr_ptr->tot_len); + + data_offset = tcp_hdr_ptr->doff << 2; + if (total_length == (ihl + data_offset)) { + u32 seq_no, ack_no; + + seq_no = ntohl(tcp_hdr_ptr->seq); + ack_no = ntohl(tcp_hdr_ptr->ack_seq); + for (i = 0; i < f->tcp_session; i++) { + u32 j = f->ack_session_info[i].seq_num; + + if (i < 2 * MAX_TCP_SESSION && + j == seq_no) { + update_tcp_session(vif, i, ack_no); + break; + } + } + if (i == f->tcp_session) + add_tcp_session(vif, 0, 0, seq_no); + + add_tcp_pending_ack(vif, ack_no, i, tqe); + } + +out: + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); +} + +static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) +{ + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + struct tcp_ack_filter *f = &vif->ack_filter; + u32 i = 0; + u32 dropped = 0; + unsigned long flags; + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + for (i = f->pending_base; + i < (f->pending_base + f->pending_acks_idx); i++) { + u32 index; + u32 bigger_ack_num; + + if (i >= MAX_PENDING_ACKS) + break; + + index = f->pending_acks[i].session_index; + + if (index >= 2 * MAX_TCP_SESSION) + break; + + bigger_ack_num = f->ack_session_info[index].bigger_ack_num; + + if (f->pending_acks[i].ack_num < bigger_ack_num) { + struct txq_entry_t *tqe; + + tqe = f->pending_acks[i].txqe; + if (tqe) { + wilc_wlan_txq_remove(wilc, tqe); + tqe->status = 1; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, + tqe->status); + kfree(tqe); + dropped++; + } + } + } + f->pending_acks_idx = 0; + f->tcp_session = 0; + + if (f->pending_base == 0) + f->pending_base = MAX_TCP_SESSION; + else + f->pending_base = 0; + + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + + while (dropped > 0) { + wait_for_completion_timeout(&wilc->txq_event, + msecs_to_jiffies(1)); + dropped--; + } +} + +void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) +{ + vif->ack_filter.enabled = value; +} + +static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, + u32 buffer_size) +{ + struct txq_entry_t *tqe; + struct wilc *wilc = vif->wilc; + + netdev_dbg(vif->ndev, "Adding config packet ...\n"); + if (wilc->quit) { + netdev_dbg(vif->ndev, "Return due to clear function\n"); + complete(&wilc->cfg_event); + return 0; + } + + tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); + if (!tqe) + return 0; + + tqe->type = WILC_CFG_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = NULL; + tqe->priv = NULL; + tqe->ack_idx = NOT_TCP_ACK; + tqe->vif = vif; + + wilc_wlan_txq_add_to_head(vif, tqe); + + return 1; +} + +int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, + u32 buffer_size, + void (*tx_complete_fn)(void *, int)) +{ + struct txq_entry_t *tqe; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc; + + wilc = vif->wilc; + + if (wilc->quit) + return 0; + + tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); + + if (!tqe) + return 0; + tqe->type = WILC_NET_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = tx_complete_fn; + tqe->priv = priv; + tqe->vif = vif; + + tqe->ack_idx = NOT_TCP_ACK; + if (vif->ack_filter.enabled) + tcp_process(dev, tqe); + wilc_wlan_txq_add_to_tail(dev, tqe); + return wilc->txq_entries; +} + +int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, + u32 buffer_size, + void (*tx_complete_fn)(void *, int)) +{ + struct txq_entry_t *tqe; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc; + + wilc = vif->wilc; + + if (wilc->quit) + return 0; + + tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); + + if (!tqe) + return 0; + tqe->type = WILC_MGMT_PKT; + tqe->buffer = buffer; + tqe->buffer_size = buffer_size; + tqe->tx_complete_func = tx_complete_fn; + tqe->priv = priv; + tqe->ack_idx = NOT_TCP_ACK; + tqe->vif = vif; + wilc_wlan_txq_add_to_tail(dev, tqe); + return 1; +} + +static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc) +{ + struct txq_entry_t *tqe = NULL; + unsigned long flags; + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + + if (!list_empty(&wilc->txq_head.list)) + tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t, + list); + + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + + return tqe; +} + +static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, + struct txq_entry_t *tqe) +{ + unsigned long flags; + + spin_lock_irqsave(&wilc->txq_spinlock, flags); + + if (!list_is_last(&tqe->list, &wilc->txq_head.list)) + tqe = list_next_entry(tqe, list); + else + tqe = NULL; + spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + + return tqe; +} + +static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) +{ + if (wilc->quit) + return; + + mutex_lock(&wilc->rxq_cs); + list_add_tail(&rqe->list, &wilc->rxq_head.list); + mutex_unlock(&wilc->rxq_cs); +} + +static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc) +{ + struct rxq_entry_t *rqe = NULL; + + mutex_lock(&wilc->rxq_cs); + if (!list_empty(&wilc->rxq_head.list)) { + rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t, + list); + list_del(&rqe->list); + } + mutex_unlock(&wilc->rxq_cs); + return rqe; +} + +void chip_allow_sleep(struct wilc *wilc) +{ + u32 reg = 0; + + wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); + + wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); + wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); +} +EXPORT_SYMBOL_GPL(chip_allow_sleep); + +void chip_wakeup(struct wilc *wilc) +{ + u32 reg, clk_status_reg; + + if ((wilc->io_type & 0x1) == WILC_HIF_SPI) { + do { + wilc->hif_func->hif_read_reg(wilc, 1, ®); + wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1)); + wilc->hif_func->hif_write_reg(wilc, 1, reg & ~BIT(1)); + + do { + usleep_range(2000, 2500); + wilc_get_chipid(wilc, true); + } while (wilc_get_chipid(wilc, true) == 0); + } while (wilc_get_chipid(wilc, true) == 0); + } else if ((wilc->io_type & 0x1) == WILC_HIF_SDIO) { + wilc->hif_func->hif_write_reg(wilc, 0xfa, 1); + usleep_range(200, 400); + wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); + do { + wilc->hif_func->hif_write_reg(wilc, 0xf0, + reg | BIT(0)); + wilc->hif_func->hif_read_reg(wilc, 0xf1, + &clk_status_reg); + + while ((clk_status_reg & 0x1) == 0) { + usleep_range(2000, 2500); + + wilc->hif_func->hif_read_reg(wilc, 0xf1, + &clk_status_reg); + } + if ((clk_status_reg & 0x1) == 0) { + wilc->hif_func->hif_write_reg(wilc, 0xf0, + reg & (~BIT(0))); + } + } while ((clk_status_reg & 0x1) == 0); + } + + if (wilc->chip_ps_state == WILC_CHIP_SLEEPING_MANUAL) { + if (wilc_get_chipid(wilc, false) < 0x1002b0) { + u32 val32; + + wilc->hif_func->hif_read_reg(wilc, 0x1e1c, &val32); + val32 |= BIT(6); + wilc->hif_func->hif_write_reg(wilc, 0x1e1c, val32); + + wilc->hif_func->hif_read_reg(wilc, 0x1e9c, &val32); + val32 |= BIT(6); + wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32); + } + } + wilc->chip_ps_state = WILC_CHIP_WAKEDUP; +} +EXPORT_SYMBOL_GPL(chip_wakeup); + +void host_wakeup_notify(struct wilc *wilc) +{ + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); +} +EXPORT_SYMBOL_GPL(host_wakeup_notify); + +void host_sleep_notify(struct wilc *wilc) +{ + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); +} +EXPORT_SYMBOL_GPL(host_sleep_notify); + +int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) +{ + int i, entries = 0; + u32 sum; + u32 reg; + u32 offset = 0; + int vmm_sz = 0; + struct txq_entry_t *tqe; + int ret = 0; + int counter; + int timeout; + u32 vmm_table[WILC_VMM_TBL_SIZE]; + const struct wilc_hif_func *func; + u8 *txb = wilc->tx_buffer; + struct net_device *dev; + struct wilc_vif *vif; + + if (wilc->quit) + goto out; + + mutex_lock(&wilc->txq_add_to_head_cs); + tqe = wilc_wlan_txq_get_first(wilc); + if (!tqe) + goto out; + dev = tqe->vif->ndev; + wilc_wlan_txq_filter_dup_tcp_ack(dev); + i = 0; + sum = 0; + do { + if (tqe && (i < (WILC_VMM_TBL_SIZE - 1))) { + if (tqe->type == WILC_CFG_PKT) + vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; + + else if (tqe->type == WILC_NET_PKT) + vmm_sz = ETH_ETHERNET_HDR_OFFSET; + + else + vmm_sz = HOST_HDR_OFFSET; + + vmm_sz += tqe->buffer_size; + + if (vmm_sz & 0x3) + vmm_sz = (vmm_sz + 4) & ~0x3; + + if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) + break; + + vmm_table[i] = vmm_sz / 4; + if (tqe->type == WILC_CFG_PKT) + vmm_table[i] |= BIT(10); + cpu_to_le32s(&vmm_table[i]); + + i++; + sum += vmm_sz; + tqe = wilc_wlan_txq_get_next(wilc, tqe); + } else { + break; + } + } while (1); + + if (i == 0) + goto out; + vmm_table[i] = 0x0; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + counter = 0; + func = wilc->hif_func; + do { + ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); + if (!ret) + break; + + if ((reg & 0x1) == 0) + break; + + counter++; + if (counter > 200) { + counter = 0; + ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, 0); + break; + } + } while (!wilc->quit); + + if (!ret) + goto out_release_bus; + + timeout = 200; + do { + ret = func->hif_block_tx(wilc, + WILC_VMM_TBL_RX_SHADOW_BASE, + (u8 *)vmm_table, + ((i + 1) * 4)); + if (!ret) + break; + + ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2); + if (!ret) + break; + + do { + ret = func->hif_read_reg(wilc, WILC_HOST_VMM_CTL, ®); + if (!ret) + break; + if ((reg >> 2) & 0x1) { + entries = ((reg >> 3) & 0x3f); + break; + } + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + } while (--timeout); + if (timeout <= 0) { + ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0); + break; + } + + if (!ret) + break; + + if (entries == 0) { + ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); + if (!ret) + break; + reg &= ~BIT(0); + ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); + if (!ret) + break; + break; + } + break; + } while (1); + + if (!ret) + goto out_release_bus; + + if (entries == 0) { + ret = -ENOBUFS; + goto out_release_bus; + } + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + offset = 0; + i = 0; + do { + u32 header, buffer_offset; + char *bssid; + + tqe = wilc_wlan_txq_remove_from_head(dev); + if (!tqe) + break; + + vif = tqe->vif; + if (vmm_table[i] == 0) + break; + + le32_to_cpus(&vmm_table[i]); + vmm_sz = (vmm_table[i] & 0x3ff); + vmm_sz *= 4; + header = (tqe->type << 31) | + (tqe->buffer_size << 15) | + vmm_sz; + if (tqe->type == WILC_MGMT_PKT) + header |= BIT(30); + else + header &= ~BIT(30); + + cpu_to_le32s(&header); + memcpy(&txb[offset], &header, 4); + if (tqe->type == WILC_CFG_PKT) { + buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; + } else if (tqe->type == WILC_NET_PKT) { + bssid = tqe->vif->bssid; + buffer_offset = ETH_ETHERNET_HDR_OFFSET; + memcpy(&txb[offset + 8], bssid, 6); + } else { + buffer_offset = HOST_HDR_OFFSET; + } + + memcpy(&txb[offset + buffer_offset], + tqe->buffer, tqe->buffer_size); + offset += vmm_sz; + i++; + tqe->status = 1; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, tqe->status); + if (tqe->ack_idx != NOT_TCP_ACK && + tqe->ack_idx < MAX_PENDING_ACKS) + vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; + kfree(tqe); + } while (--entries); + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + + ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); + if (!ret) + goto out_release_bus; + + ret = func->hif_block_tx_ext(wilc, 0, txb, offset); + +out_release_bus: + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + +out: + mutex_unlock(&wilc->txq_add_to_head_cs); + + *txq_count = wilc->txq_entries; + return ret; +} + +static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size) +{ + int offset = 0; + u32 header; + u32 pkt_len, pkt_offset, tp_len; + int is_cfg_packet; + u8 *buff_ptr; + + do { + buff_ptr = buffer + offset; + header = get_unaligned_le32(buff_ptr); + + is_cfg_packet = (header >> 31) & 0x1; + pkt_offset = (header >> 22) & 0x1ff; + tp_len = (header >> 11) & 0x7ff; + pkt_len = header & 0x7ff; + + if (pkt_len == 0 || tp_len == 0) + break; + + if (pkt_offset & IS_MANAGMEMENT) { + buff_ptr += HOST_HDR_OFFSET; + wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len); + } else { + if (!is_cfg_packet) { + if (pkt_len > 0) { + wilc_frmw_to_host(wilc, buff_ptr, + pkt_len, pkt_offset); + } + } else { + struct wilc_cfg_rsp rsp; + + buff_ptr += pkt_offset; + + wilc_wlan_cfg_indicate_rx(wilc, buff_ptr, + pkt_len, + &rsp); + if (rsp.type == WILC_CFG_RSP) { + if (wilc->cfg_seq_no == rsp.seq_no) + complete(&wilc->cfg_event); + } else if (rsp.type == WILC_CFG_RSP_STATUS) { + wilc_mac_indicate(wilc); + } + } + } + offset += tp_len; + if (offset >= size) + break; + } while (1); +} + +static void wilc_wlan_handle_rxq(struct wilc *wilc) +{ + int size; + u8 *buffer; + struct rxq_entry_t *rqe; + + do { + if (wilc->quit) { + complete(&wilc->cfg_event); + break; + } + rqe = wilc_wlan_rxq_remove(wilc); + if (!rqe) + break; + + buffer = rqe->buffer; + size = rqe->buffer_size; + wilc_wlan_handle_rx_buff(wilc, buffer, size); + + kfree(rqe); + } while (1); +} + +static void wilc_unknown_isr_ext(struct wilc *wilc) +{ + wilc->hif_func->hif_clear_int_ext(wilc, 0); +} + +static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status) +{ + u32 offset = wilc->rx_buffer_offset; + u8 *buffer = NULL; + u32 size; + u32 retries = 0; + int ret = 0; + struct rxq_entry_t *rqe; + + size = (int_status & 0x7fff) << 2; + + while (!size && retries < 10) { + wilc->hif_func->hif_read_size(wilc, &size); + size = (size & 0x7fff) << 2; + retries++; + } + + if (size <= 0) + return; + + if (WILC_RX_BUFF_SIZE - offset < size) + offset = 0; + + buffer = &wilc->rx_buffer[offset]; + + wilc->hif_func->hif_clear_int_ext(wilc, DATA_INT_CLR | ENABLE_RX_VMM); + ret = wilc->hif_func->hif_block_rx_ext(wilc, 0, buffer, size); + if (!ret) + return; + + offset += size; + wilc->rx_buffer_offset = offset; + rqe = kmalloc(sizeof(*rqe), GFP_KERNEL); + if (!rqe) + return; + + rqe->buffer = buffer; + rqe->buffer_size = size; + wilc_wlan_rxq_add(wilc, rqe); + wilc_wlan_handle_rxq(wilc); +} + +void wilc_handle_isr(struct wilc *wilc) +{ + u32 int_status; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + wilc->hif_func->hif_read_int(wilc, &int_status); + + if (int_status & DATA_INT_EXT) + wilc_wlan_handle_isr_ext(wilc, int_status); + + if (!(int_status & (ALL_INT_EXT))) + wilc_unknown_isr_ext(wilc); + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); +} +EXPORT_SYMBOL_GPL(wilc_handle_isr); + +int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, + u32 buffer_size) +{ + u32 offset; + u32 addr, size, size2, blksz; + u8 *dma_buffer; + int ret = 0; + + blksz = BIT(12); + + dma_buffer = kmalloc(blksz, GFP_KERNEL); + if (!dma_buffer) + return -EIO; + + offset = 0; + do { + addr = get_unaligned_le32(&buffer[offset]); + size = get_unaligned_le32(&buffer[offset + 4]); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + offset += 8; + while (((int)size) && (offset < buffer_size)) { + if (size <= blksz) + size2 = size; + else + size2 = blksz; + + memcpy(dma_buffer, &buffer[offset], size2); + ret = wilc->hif_func->hif_block_tx(wilc, addr, + dma_buffer, size2); + if (!ret) + break; + + addr += size2; + offset += size2; + size -= size2; + } + release_bus(wilc, WILC_BUS_RELEASE_ONLY); + + if (!ret) { + ret = -EIO; + goto fail; + } + } while (offset < buffer_size); + +fail: + + kfree(dma_buffer); + + return (ret < 0) ? ret : 0; +} + +int wilc_wlan_start(struct wilc *wilc) +{ + u32 reg = 0; + int ret; + u32 chipid; + + if (wilc->io_type == WILC_HIF_SDIO) { + reg = 0; + reg |= BIT(3); + } else if (wilc->io_type == WILC_HIF_SPI) { + reg = 1; + } + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg); + if (!ret) { + release_bus(wilc, WILC_BUS_RELEASE_ONLY); + return -EIO; + } + reg = 0; + if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num) + reg |= WILC_HAVE_SDIO_IRQ_GPIO; + +#ifdef WILC_DISABLE_PMU +#else + reg |= WILC_HAVE_USE_PMU; +#endif + +#ifdef WILC_SLEEP_CLK_SRC_XO + reg |= WILC_HAVE_SLEEP_CLK_SRC_XO; +#elif defined WILC_SLEEP_CLK_SRC_RTC + reg |= WILC_HAVE_SLEEP_CLK_SRC_RTC; +#endif + +#ifdef WILC_EXT_PA_INV_TX_RX + reg |= WILC_HAVE_EXT_PA_INV_TX_RX; +#endif + reg |= WILC_HAVE_USE_IRQ_AS_HOST_WAKE; + reg |= WILC_HAVE_LEGACY_RF_SETTINGS; +#ifdef XTAL_24 + reg |= WILC_HAVE_XTAL_24; +#endif +#ifdef DISABLE_WILC_UART + reg |= WILC_HAVE_DISABLE_WILC_UART; +#endif + + ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg); + if (!ret) { + release_bus(wilc, WILC_BUS_RELEASE_ONLY); + return -EIO; + } + + wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT); + + ret = wilc->hif_func->hif_read_reg(wilc, 0x1000, &chipid); + if (!ret) { + release_bus(wilc, WILC_BUS_RELEASE_ONLY); + return -EIO; + } + + wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); + if ((reg & BIT(10)) == BIT(10)) { + reg &= ~BIT(10); + wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); + wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); + } + + reg |= BIT(10); + ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); + wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); + + return (ret < 0) ? ret : 0; +} + +int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) +{ + u32 reg = 0; + int ret; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + + ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®); + if (!ret) { + netdev_err(vif->ndev, "Error while reading reg\n"); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + return -EIO; + } + + ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, + (reg | WILC_ABORT_REQ_BIT)); + if (!ret) { + netdev_err(vif->ndev, "Error while writing reg\n"); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + return -EIO; + } + + ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, ®); + if (!ret) { + netdev_err(vif->ndev, "Error while reading reg\n"); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + return -EIO; + } + reg = BIT(0); + + ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg); + if (!ret) { + netdev_err(vif->ndev, "Error while writing reg\n"); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + return -EIO; + } + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + return 0; +} + +void wilc_wlan_cleanup(struct net_device *dev) +{ + struct txq_entry_t *tqe; + struct rxq_entry_t *rqe; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + wilc->quit = 1; + do { + tqe = wilc_wlan_txq_remove_from_head(dev); + if (!tqe) + break; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, 0); + kfree(tqe); + } while (1); + + do { + rqe = wilc_wlan_rxq_remove(wilc); + if (!rqe) + break; + kfree(rqe); + } while (1); + + kfree(wilc->rx_buffer); + wilc->rx_buffer = NULL; + kfree(wilc->tx_buffer); + wilc->tx_buffer = NULL; + wilc->hif_func->hif_deinit(NULL); +} + +static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, + u32 drv_handler) +{ + struct wilc *wilc = vif->wilc; + struct wilc_cfg_frame *cfg = &wilc->cfg_frame; + int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); + + if (type == WILC_CFG_SET) + cfg->hdr.cmd_type = 'W'; + else + cfg->hdr.cmd_type = 'Q'; + + cfg->hdr.seq_no = wilc->cfg_seq_no % 256; + cfg->hdr.total_len = cpu_to_le16(t_len); + cfg->hdr.driver_handler = cpu_to_le32(drv_handler); + wilc->cfg_seq_no = cfg->hdr.seq_no; + + if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) + return -1; + + return 0; +} + +int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, + u32 buffer_size, int commit, u32 drv_handler) +{ + u32 offset; + int ret_size; + struct wilc *wilc = vif->wilc; + + mutex_lock(&wilc->cfg_cmd_lock); + + if (start) + wilc->cfg_frame_offset = 0; + + offset = wilc->cfg_frame_offset; + ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + wid, buffer, buffer_size); + offset += ret_size; + wilc->cfg_frame_offset = offset; + + if (!commit) { + mutex_unlock(&wilc->cfg_cmd_lock); + return ret_size; + } + + netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no); + + if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) + ret_size = 0; + + if (!wait_for_completion_timeout(&wilc->cfg_event, + WILC_CFG_PKTS_TIMEOUT)) { + netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); + ret_size = 0; + } + + wilc->cfg_frame_offset = 0; + wilc->cfg_seq_no += 1; + mutex_unlock(&wilc->cfg_cmd_lock); + + return ret_size; +} + +int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, + u32 drv_handler) +{ + u32 offset; + int ret_size; + struct wilc *wilc = vif->wilc; + + mutex_lock(&wilc->cfg_cmd_lock); + + if (start) + wilc->cfg_frame_offset = 0; + + offset = wilc->cfg_frame_offset; + ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, wid); + offset += ret_size; + wilc->cfg_frame_offset = offset; + + if (!commit) { + mutex_unlock(&wilc->cfg_cmd_lock); + return ret_size; + } + + if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler)) + ret_size = 0; + + if (!wait_for_completion_timeout(&wilc->cfg_event, + WILC_CFG_PKTS_TIMEOUT)) { + netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); + ret_size = 0; + } + wilc->cfg_frame_offset = 0; + wilc->cfg_seq_no += 1; + mutex_unlock(&wilc->cfg_cmd_lock); + + return ret_size; +} + +int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, + u32 count) +{ + int i; + int ret = 0; + u32 drv = wilc_get_vif_idx(vif); + + if (mode == WILC_GET_CFG) { + for (i = 0; i < count; i++) { + if (!wilc_wlan_cfg_get(vif, !i, + wids[i].id, + (i == count - 1), + drv)) { + ret = -ETIMEDOUT; + break; + } + } + for (i = 0; i < count; i++) { + wids[i].size = wilc_wlan_cfg_get_val(vif->wilc, + wids[i].id, + wids[i].val, + wids[i].size); + } + } else if (mode == WILC_SET_CFG) { + for (i = 0; i < count; i++) { + if (!wilc_wlan_cfg_set(vif, !i, + wids[i].id, + wids[i].val, + wids[i].size, + (i == count - 1), + drv)) { + ret = -ETIMEDOUT; + break; + } + } + } + + return ret; +} + +static u32 init_chip(struct net_device *dev) +{ + u32 chipid; + u32 reg, ret = 0; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc = vif->wilc; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + + chipid = wilc_get_chipid(wilc, true); + + if ((chipid & 0xfff) != 0xa0) { + ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®); + if (!ret) { + netdev_err(dev, "fail read reg 0x1118\n"); + goto release; + } + reg |= BIT(0); + ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg); + if (!ret) { + netdev_err(dev, "fail write reg 0x1118\n"); + goto release; + } + ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71); + if (!ret) { + netdev_err(dev, "fail write reg 0xc0000\n"); + goto release; + } + } + +release: + release_bus(wilc, WILC_BUS_RELEASE_ONLY); + + return ret; +} + +u32 wilc_get_chipid(struct wilc *wilc, bool update) +{ + static u32 chipid; + u32 tempchipid = 0; + u32 rfrevid = 0; + + if (chipid == 0 || update) { + wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid); + wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid); + if (!is_wilc1000(tempchipid)) { + chipid = 0; + return chipid; + } + if (tempchipid == 0x1002a0) { + if (rfrevid != 0x1) + tempchipid = 0x1002a1; + } else if (tempchipid == 0x1002b0) { + if (rfrevid == 0x4) + tempchipid = 0x1002b1; + else if (rfrevid != 0x3) + tempchipid = 0x1002b2; + } + + chipid = tempchipid; + } + return chipid; +} + +int wilc_wlan_init(struct net_device *dev) +{ + int ret = 0; + struct wilc_vif *vif = netdev_priv(dev); + struct wilc *wilc; + + wilc = vif->wilc; + + wilc->quit = 0; + + if (!wilc->hif_func->hif_init(wilc, false)) { + ret = -EIO; + goto fail; + } + + if (!wilc->tx_buffer) + wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); + + if (!wilc->tx_buffer) { + ret = -ENOBUFS; + goto fail; + } + + if (!wilc->rx_buffer) + wilc->rx_buffer = kmalloc(WILC_RX_BUFF_SIZE, GFP_KERNEL); + + if (!wilc->rx_buffer) { + ret = -ENOBUFS; + goto fail; + } + + if (!init_chip(dev)) { + ret = -EIO; + goto fail; + } + + return 1; + +fail: + + kfree(wilc->rx_buffer); + wilc->rx_buffer = NULL; + kfree(wilc->tx_buffer); + wilc->tx_buffer = NULL; + + return ret; +} diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h new file mode 100644 index 000000000000..7469fa47d588 --- /dev/null +++ b/drivers/staging/wilc1000/wlan.h @@ -0,0 +1,304 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#ifndef WILC_WLAN_H +#define WILC_WLAN_H + +#include + +/******************************************** + * + * Mac eth header length + * + ********************************************/ +#define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */ +#define SUB_MSDU_HEADER_LENGTH 14 +#define SNAP_HDR_LEN 8 +#define ETHERNET_HDR_LEN 14 +#define WORD_ALIGNMENT_PAD 0 + +#define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + \ + SUB_MSDU_HEADER_LENGTH + \ + SNAP_HDR_LEN - \ + ETHERNET_HDR_LEN + \ + WORD_ALIGNMENT_PAD) + +#define HOST_HDR_OFFSET 4 +#define ETHERNET_HDR_LEN 14 +#define IP_HDR_LEN 20 +#define IP_HDR_OFFSET ETHERNET_HDR_LEN +#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET) +#define UDP_HDR_LEN 8 +#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN) +#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET + +#define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \ + ETH_CONFIG_PKT_HDR_LEN) + +/******************************************** + * + * Register Defines + * + ********************************************/ +#define WILC_PERIPH_REG_BASE 0x1000 +#define WILC_CHANGING_VIR_IF 0x108c +#define WILC_CHIPID WILC_PERIPH_REG_BASE +#define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400) +#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408) +#define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c) +#define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70) +#define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74) +#define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78) +#define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80) +#define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84) +#define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88) +#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428) +#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00) +#define WILC_INTR_ENABLE WILC_INTR_REG_BASE +#define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4) + +#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10) +#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20) +#define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30) +#define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40) + +#define WILC_VMM_TBL_SIZE 64 +#define WILC_VMM_TX_TBL_BASE 0x150400 +#define WILC_VMM_RX_TBL_BASE 0x150500 + +#define WILC_VMM_BASE 0x150000 +#define WILC_VMM_CORE_CTL WILC_VMM_BASE +#define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4) +#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8) +#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc) +#define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10) +#define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14) +#define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040) +#define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44) + +#define WILC_SPI_REG_BASE 0xe800 +#define WILC_SPI_CTL WILC_SPI_REG_BASE +#define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4) +#define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8) +#define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc) +#define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10) +#define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20) +#define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24) +#define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c) + +#define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - \ + WILC_SPI_REG_BASE) + +#define WILC_AHB_DATA_MEM_BASE 0x30000 +#define WILC_AHB_SHARE_MEM_BASE 0xd0000 + +#define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE +#define WILC_VMM_TBL_RX_SHADOW_SIZE 256 + +#define WILC_FW_HOST_COMM 0x13c0 +#define WILC_GP_REG_0 0x149c +#define WILC_GP_REG_1 0x14a0 + +#define WILC_HAVE_SDIO_IRQ_GPIO BIT(0) +#define WILC_HAVE_USE_PMU BIT(1) +#define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2) +#define WILC_HAVE_SLEEP_CLK_SRC_XO BIT(3) +#define WILC_HAVE_EXT_PA_INV_TX_RX BIT(4) +#define WILC_HAVE_LEGACY_RF_SETTINGS BIT(5) +#define WILC_HAVE_XTAL_24 BIT(6) +#define WILC_HAVE_DISABLE_WILC_UART BIT(7) +#define WILC_HAVE_USE_IRQ_AS_HOST_WAKE BIT(8) + +/******************************************** + * + * Wlan Defines + * + ********************************************/ +#define WILC_CFG_PKT 1 +#define WILC_NET_PKT 0 +#define WILC_MGMT_PKT 2 + +#define WILC_CFG_SET 1 +#define WILC_CFG_QUERY 0 + +#define WILC_CFG_RSP 1 +#define WILC_CFG_RSP_STATUS 2 +#define WILC_CFG_RSP_SCAN 3 + +#define WILC_ABORT_REQ_BIT BIT(31) + +#define WILC_RX_BUFF_SIZE (96 * 1024) +#define WILC_TX_BUFF_SIZE (64 * 1024) + +#define MODALIAS "WILC_SPI" +#define GPIO_NUM 0x44 +/*******************************************/ +/* E0 and later Interrupt flags. */ +/*******************************************/ +/*******************************************/ +/* E0 and later Interrupt flags. */ +/* IRQ Status word */ +/* 15:0 = DMA count in words. */ +/* 16: INT0 flag */ +/* 17: INT1 flag */ +/* 18: INT2 flag */ +/* 19: INT3 flag */ +/* 20: INT4 flag */ +/* 21: INT5 flag */ +/*******************************************/ +#define IRG_FLAGS_OFFSET 16 +#define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1) +#define INT_0 BIT(IRG_FLAGS_OFFSET) +#define INT_1 BIT(IRG_FLAGS_OFFSET + 1) +#define INT_2 BIT(IRG_FLAGS_OFFSET + 2) +#define INT_3 BIT(IRG_FLAGS_OFFSET + 3) +#define INT_4 BIT(IRG_FLAGS_OFFSET + 4) +#define INT_5 BIT(IRG_FLAGS_OFFSET + 5) +#define MAX_NUM_INT 6 + +/*******************************************/ +/* E0 and later Interrupt flags. */ +/* IRQ Clear word */ +/* 0: Clear INT0 */ +/* 1: Clear INT1 */ +/* 2: Clear INT2 */ +/* 3: Clear INT3 */ +/* 4: Clear INT4 */ +/* 5: Clear INT5 */ +/* 6: Select VMM table 1 */ +/* 7: Select VMM table 2 */ +/* 8: Enable VMM */ +/*******************************************/ +#define CLR_INT0 BIT(0) +#define CLR_INT1 BIT(1) +#define CLR_INT2 BIT(2) +#define CLR_INT3 BIT(3) +#define CLR_INT4 BIT(4) +#define CLR_INT5 BIT(5) +#define SEL_VMM_TBL0 BIT(6) +#define SEL_VMM_TBL1 BIT(7) +#define EN_VMM BIT(8) + +#define DATA_INT_EXT INT_0 +#define ALL_INT_EXT DATA_INT_EXT +#define NUM_INT_EXT 1 + +#define DATA_INT_CLR CLR_INT0 + +#define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM) +#define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM) +/*time for expiring the completion of cfg packets*/ +#define WILC_CFG_PKTS_TIMEOUT msecs_to_jiffies(2000) + +#define IS_MANAGMEMENT 0x100 +#define IS_MANAGMEMENT_CALLBACK 0x080 +#define IS_MGMT_STATUS_SUCCES 0x040 + +/******************************************** + * + * Tx/Rx Queue Structure + * + ********************************************/ + +struct txq_entry_t { + struct list_head list; + int type; + int ack_idx; + u8 *buffer; + int buffer_size; + void *priv; + int status; + struct wilc_vif *vif; + void (*tx_complete_func)(void *priv, int status); +}; + +struct rxq_entry_t { + struct list_head list; + u8 *buffer; + int buffer_size; +}; + +/******************************************** + * + * Host IF Structure + * + ********************************************/ +struct wilc; +struct wilc_hif_func { + int (*hif_init)(struct wilc *wilc, bool resume); + int (*hif_deinit)(struct wilc *wilc); + int (*hif_read_reg)(struct wilc *wilc, u32 addr, u32 *data); + int (*hif_write_reg)(struct wilc *wilc, u32 addr, u32 data); + int (*hif_block_rx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); + int (*hif_block_tx)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); + int (*hif_read_int)(struct wilc *wilc, u32 *int_status); + int (*hif_clear_int_ext)(struct wilc *wilc, u32 val); + int (*hif_read_size)(struct wilc *wilc, u32 *size); + int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); + int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); + int (*hif_sync_ext)(struct wilc *wilc, int nint); + int (*enable_interrupt)(struct wilc *nic); + void (*disable_interrupt)(struct wilc *nic); +}; + +#define WILC_MAX_CFG_FRAME_SIZE 1468 + +struct tx_complete_data { + int size; + void *buff; + struct sk_buff *skb; +}; + +struct wilc_cfg_cmd_hdr { + u8 cmd_type; + u8 seq_no; + __le16 total_len; + __le32 driver_handler; +}; + +struct wilc_cfg_frame { + struct wilc_cfg_cmd_hdr hdr; + u8 frame[WILC_MAX_CFG_FRAME_SIZE]; +}; + +struct wilc_cfg_rsp { + u8 type; + u8 seq_no; +}; + +struct wilc; +struct wilc_vif; + +int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, + u32 buffer_size); +int wilc_wlan_start(struct wilc *wilc); +int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif); +int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, + u32 buffer_size, + void (*tx_complete_fn)(void *, int)); +int wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count); +void wilc_handle_isr(struct wilc *wilc); +void wilc_wlan_cleanup(struct net_device *dev); +int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, + u32 buffer_size, int commit, u32 drv_handler); +int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, + u32 drv_handler); +int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, + u32 buffer_size, void (*func)(void *, int)); +void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value); +int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc); +netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); + +void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size); +void host_wakeup_notify(struct wilc *wilc); +void host_sleep_notify(struct wilc *wilc); +void chip_allow_sleep(struct wilc *wilc); +void chip_wakeup(struct wilc *wilc); +int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, + u32 count); +int wilc_wlan_init(struct net_device *dev); +u32 wilc_get_chipid(struct wilc *wilc, bool update); +#endif diff --git a/drivers/staging/wilc1000/wlan_cfg.c b/drivers/staging/wilc1000/wlan_cfg.c new file mode 100644 index 000000000000..904f84077ff7 --- /dev/null +++ b/drivers/staging/wilc1000/wlan_cfg.c @@ -0,0 +1,457 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#include "wlan_if.h" +#include "wlan.h" +#include "wlan_cfg.h" +#include "netdev.h" + +enum cfg_cmd_type { + CFG_BYTE_CMD = 0, + CFG_HWORD_CMD = 1, + CFG_WORD_CMD = 2, + CFG_STR_CMD = 3, + CFG_BIN_CMD = 4 +}; + +static const struct wilc_cfg_byte g_cfg_byte[] = { + {WID_STATUS, 0}, + {WID_RSSI, 0}, + {WID_LINKSPEED, 0}, + {WID_NIL, 0} +}; + +static const struct wilc_cfg_hword g_cfg_hword[] = { + {WID_NIL, 0} +}; + +static const struct wilc_cfg_word g_cfg_word[] = { + {WID_FAILED_COUNT, 0}, + {WID_RECEIVED_FRAGMENT_COUNT, 0}, + {WID_SUCCESS_FRAME_COUNT, 0}, + {WID_GET_INACTIVE_TIME, 0}, + {WID_NIL, 0} + +}; + +static const struct wilc_cfg_str g_cfg_str[] = { + {WID_FIRMWARE_VERSION, NULL}, + {WID_MAC_ADDR, NULL}, + {WID_ASSOC_RES_INFO, NULL}, + {WID_NIL, NULL} +}; + +/******************************************** + * + * Configuration Functions + * + ********************************************/ + +static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8) +{ + if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE) + return 0; + + put_unaligned_le16(id, &frame[offset]); + put_unaligned_le16(1, &frame[offset + 2]); + frame[offset + 4] = val8; + return 5; +} + +static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16) +{ + if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE) + return 0; + + put_unaligned_le16(id, &frame[offset]); + put_unaligned_le16(2, &frame[offset + 2]); + put_unaligned_le16(val16, &frame[offset + 4]); + + return 6; +} + +static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32) +{ + if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE) + return 0; + + put_unaligned_le16(id, &frame[offset]); + put_unaligned_le16(4, &frame[offset + 2]); + put_unaligned_le32(val32, &frame[offset + 4]); + + return 8; +} + +static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str, + u32 size) +{ + if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE) + return 0; + + put_unaligned_le16(id, &frame[offset]); + put_unaligned_le16(size, &frame[offset + 2]); + if (str && size != 0) + memcpy(&frame[offset + 4], str, size); + + return (size + 4); +} + +static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size) +{ + u32 i; + u8 checksum = 0; + + if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE) + return 0; + + put_unaligned_le16(id, &frame[offset]); + put_unaligned_le16(size, &frame[offset + 2]); + + if ((b) && size != 0) { + memcpy(&frame[offset + 4], b, size); + for (i = 0; i < size; i++) + checksum += frame[offset + i + 4]; + } + + frame[offset + size + 4] = checksum; + + return (size + 5); +} + +/******************************************** + * + * Configuration Response Functions + * + ********************************************/ + +#define GET_WID_TYPE(wid) (((wid) >> 12) & 0x7) +static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size) +{ + u16 wid; + u32 len = 0, i = 0; + + while (size > 0) { + i = 0; + wid = get_unaligned_le16(info); + + switch (GET_WID_TYPE(wid)) { + case WID_CHAR: + do { + if (wl->cfg.b[i].id == WID_NIL) + break; + + if (wl->cfg.b[i].id == wid) { + wl->cfg.b[i].val = info[4]; + break; + } + i++; + } while (1); + len = 3; + break; + + case WID_SHORT: + do { + struct wilc_cfg_hword *hw = &wl->cfg.hw[i]; + + if (hw->id == WID_NIL) + break; + + if (hw->id == wid) { + hw->val = get_unaligned_le16(&info[4]); + break; + } + i++; + } while (1); + len = 4; + break; + + case WID_INT: + do { + struct wilc_cfg_word *w = &wl->cfg.w[i]; + + if (w->id == WID_NIL) + break; + + if (w->id == wid) { + w->val = get_unaligned_le32(&info[4]); + break; + } + i++; + } while (1); + len = 6; + break; + + case WID_STR: + do { + if (wl->cfg.s[i].id == WID_NIL) + break; + + if (wl->cfg.s[i].id == wid) { + memcpy(wl->cfg.s[i].str, &info[2], + (info[2] + 2)); + break; + } + i++; + } while (1); + len = 2 + info[2]; + break; + + default: + break; + } + size -= (2 + len); + info += (2 + len); + } +} + +static void wilc_wlan_parse_info_frame(struct wilc *wl, u8 *info) +{ + u32 wid, len; + + wid = get_unaligned_le16(info); + + len = info[2]; + + if (len == 1 && wid == WID_STATUS) { + int i = 0; + + do { + if (wl->cfg.b[i].id == WID_NIL) + break; + + if (wl->cfg.b[i].id == wid) { + wl->cfg.b[i].val = info[3]; + break; + } + i++; + } while (1); + } +} + +/******************************************** + * + * Configuration Exported Functions + * + ********************************************/ + +int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size) +{ + u8 type = (id >> 12) & 0xf; + int ret = 0; + + switch (type) { + case CFG_BYTE_CMD: + if (size >= 1) + ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf); + break; + + case CFG_HWORD_CMD: + if (size >= 2) + ret = wilc_wlan_cfg_set_hword(frame, offset, id, + *((u16 *)buf)); + break; + + case CFG_WORD_CMD: + if (size >= 4) + ret = wilc_wlan_cfg_set_word(frame, offset, id, + *((u32 *)buf)); + break; + + case CFG_STR_CMD: + ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size); + break; + + case CFG_BIN_CMD: + ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size); + break; + } + + return ret; +} + +int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id) +{ + if ((offset + 2) >= WILC_MAX_CFG_FRAME_SIZE) + return 0; + + put_unaligned_le16(id, &frame[offset]); + + return 2; +} + +int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer, + u32 buffer_size) +{ + u32 type = (wid >> 12) & 0xf; + int i, ret = 0; + + i = 0; + if (type == CFG_BYTE_CMD) { + do { + if (wl->cfg.b[i].id == WID_NIL) + break; + + if (wl->cfg.b[i].id == wid) { + memcpy(buffer, &wl->cfg.b[i].val, 1); + ret = 1; + break; + } + i++; + } while (1); + } else if (type == CFG_HWORD_CMD) { + do { + if (wl->cfg.hw[i].id == WID_NIL) + break; + + if (wl->cfg.hw[i].id == wid) { + memcpy(buffer, &wl->cfg.hw[i].val, 2); + ret = 2; + break; + } + i++; + } while (1); + } else if (type == CFG_WORD_CMD) { + do { + if (wl->cfg.w[i].id == WID_NIL) + break; + + if (wl->cfg.w[i].id == wid) { + memcpy(buffer, &wl->cfg.w[i].val, 4); + ret = 4; + break; + } + i++; + } while (1); + } else if (type == CFG_STR_CMD) { + do { + u32 id = wl->cfg.s[i].id; + + if (id == WID_NIL) + break; + + if (id == wid) { + u16 size = get_unaligned_le16(wl->cfg.s[i].str); + + if (buffer_size >= size) { + memcpy(buffer, &wl->cfg.s[i].str[2], + size); + ret = size; + } + break; + } + i++; + } while (1); + } + return ret; +} + +void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, + struct wilc_cfg_rsp *rsp) +{ + u8 msg_type; + u8 msg_id; + + msg_type = frame[0]; + msg_id = frame[1]; /* seq no */ + frame += 4; + size -= 4; + rsp->type = 0; + + /* + * The valid types of response messages are + * 'R' (Response), + * 'I' (Information), and + * 'N' (Network Information) + */ + + switch (msg_type) { + case 'R': + wilc_wlan_parse_response_frame(wilc, frame, size); + rsp->type = WILC_CFG_RSP; + rsp->seq_no = msg_id; + break; + + case 'I': + wilc_wlan_parse_info_frame(wilc, frame); + rsp->type = WILC_CFG_RSP_STATUS; + rsp->seq_no = msg_id; + /*call host interface info parse as well*/ + wilc_gnrl_async_info_received(wilc, frame - 4, size + 4); + break; + + case 'N': + wilc_network_info_received(wilc, frame - 4, size + 4); + break; + + case 'S': + wilc_scan_complete_received(wilc, frame - 4, size + 4); + break; + + default: + rsp->seq_no = msg_id; + break; + } +} + +int wilc_wlan_cfg_init(struct wilc *wl) +{ + struct wilc_cfg_str_vals *str_vals; + int i = 0; + + wl->cfg.b = kmemdup(g_cfg_byte, sizeof(g_cfg_byte), GFP_KERNEL); + if (!wl->cfg.b) + return -ENOMEM; + + wl->cfg.hw = kmemdup(g_cfg_hword, sizeof(g_cfg_hword), GFP_KERNEL); + if (!wl->cfg.hw) + goto out_b; + + wl->cfg.w = kmemdup(g_cfg_word, sizeof(g_cfg_word), GFP_KERNEL); + if (!wl->cfg.w) + goto out_hw; + + wl->cfg.s = kmemdup(g_cfg_str, sizeof(g_cfg_str), GFP_KERNEL); + if (!wl->cfg.s) + goto out_w; + + str_vals = kzalloc(sizeof(*str_vals), GFP_KERNEL); + if (!str_vals) + goto out_s; + + wl->cfg.str_vals = str_vals; + /* store the string cfg parameters */ + wl->cfg.s[i].id = WID_FIRMWARE_VERSION; + wl->cfg.s[i].str = str_vals->firmware_version; + i++; + wl->cfg.s[i].id = WID_MAC_ADDR; + wl->cfg.s[i].str = str_vals->mac_address; + i++; + wl->cfg.s[i].id = WID_ASSOC_RES_INFO; + wl->cfg.s[i].str = str_vals->assoc_rsp; + i++; + wl->cfg.s[i].id = WID_NIL; + wl->cfg.s[i].str = NULL; + return 0; + +out_s: + kfree(wl->cfg.s); +out_w: + kfree(wl->cfg.w); +out_hw: + kfree(wl->cfg.hw); +out_b: + kfree(wl->cfg.b); + return -ENOMEM; +} + +void wilc_wlan_cfg_deinit(struct wilc *wl) +{ + kfree(wl->cfg.b); + kfree(wl->cfg.hw); + kfree(wl->cfg.w); + kfree(wl->cfg.s); + kfree(wl->cfg.str_vals); +} diff --git a/drivers/staging/wilc1000/wlan_cfg.h b/drivers/staging/wilc1000/wlan_cfg.h new file mode 100644 index 000000000000..614c5673f232 --- /dev/null +++ b/drivers/staging/wilc1000/wlan_cfg.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#ifndef WILC_WLAN_CFG_H +#define WILC_WLAN_CFG_H + +struct wilc_cfg_byte { + u16 id; + u8 val; +}; + +struct wilc_cfg_hword { + u16 id; + u16 val; +}; + +struct wilc_cfg_word { + u16 id; + u32 val; +}; + +struct wilc_cfg_str { + u16 id; + u8 *str; +}; + +struct wilc_cfg_str_vals { + u8 mac_address[7]; + u8 firmware_version[129]; + u8 assoc_rsp[256]; +}; + +struct wilc_cfg { + struct wilc_cfg_byte *b; + struct wilc_cfg_hword *hw; + struct wilc_cfg_word *w; + struct wilc_cfg_str *s; + struct wilc_cfg_str_vals *str_vals; +}; + +struct wilc; +int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size); +int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id); +int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer, + u32 buffer_size); +void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, + struct wilc_cfg_rsp *rsp); +int wilc_wlan_cfg_init(struct wilc *wl); +void wilc_wlan_cfg_deinit(struct wilc *wl); + +#endif diff --git a/drivers/staging/wilc1000/wlan_if.h b/drivers/staging/wilc1000/wlan_if.h new file mode 100644 index 000000000000..70eac586f80c --- /dev/null +++ b/drivers/staging/wilc1000/wlan_if.h @@ -0,0 +1,802 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. + * All rights reserved. + */ + +#ifndef WILC_WLAN_IF_H +#define WILC_WLAN_IF_H + +#include + +/******************************************** + * + * Wlan Configuration ID + * + ********************************************/ + +enum bss_types { + WILC_FW_BSS_TYPE_INFRA = 0, + WILC_FW_BSS_TYPE_INDEPENDENT, + WILC_FW_BSS_TYPE_AP, +}; + +enum { + WILC_FW_OPER_MODE_B_ONLY = 0, /* 1, 2 M, otherwise 5, 11 M */ + WILC_FW_OPER_MODE_G_ONLY, /* 6,12,24 otherwise 9,18,36,48,54 */ + WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */ + WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */ +}; + +enum { + WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */ + WILC_FW_PREAMBLE_LONG = 1, /* Long Preamble */ + WILC_FW_PREAMBLE_AUTO = 2, /* Auto Preamble Selection */ +}; + +enum { + WILC_FW_PASSIVE_SCAN = 0, + WILC_FW_ACTIVE_SCAN = 1, +}; + +enum { + WILC_FW_NO_POWERSAVE = 0, + WILC_FW_MIN_FAST_PS = 1, + WILC_FW_MAX_FAST_PS = 2, + WILC_FW_MIN_PSPOLL_PS = 3, + WILC_FW_MAX_PSPOLL_PS = 4 +}; + +enum chip_ps_states { + WILC_CHIP_WAKEDUP = 0, + WILC_CHIP_SLEEPING_AUTO = 1, + WILC_CHIP_SLEEPING_MANUAL = 2 +}; + +enum bus_acquire { + WILC_BUS_ACQUIRE_ONLY = 0, + WILC_BUS_ACQUIRE_AND_WAKEUP = 1, +}; + +enum bus_release { + WILC_BUS_RELEASE_ONLY = 0, + WILC_BUS_RELEASE_ALLOW_SLEEP = 1, +}; + +enum { + WILC_FW_NO_ENCRYPT = 0, + WILC_FW_ENCRYPT_ENABLED = BIT(0), + WILC_FW_WEP = BIT(1), + WILC_FW_WEP_EXTENDED = BIT(2), + WILC_FW_WPA = BIT(3), + WILC_FW_WPA2 = BIT(4), + WILC_FW_AES = BIT(5), + WILC_FW_TKIP = BIT(6) +}; + +enum { + WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT, + WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED, + WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP, + WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED, + WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA, + WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA, + WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED, + WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2, + WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2 +}; + +enum authtype { + WILC_FW_AUTH_OPEN_SYSTEM = 1, + WILC_FW_AUTH_SHARED_KEY = 2, + WILC_FW_AUTH_ANY = 3, + WILC_FW_AUTH_IEEE8021 = 5 +}; + +enum site_survey { + WILC_FW_SITE_SURVEY_1CH = 0, + WILC_FW_SITE_SURVEY_ALL_CH = 1, + WILC_FW_SITE_SURVEY_OFF = 2 +}; + +enum { + WILC_FW_ACK_POLICY_NORMAL = 0, + WILC_FW_ACK_NO_POLICY, +}; + +enum { + WILC_FW_REKEY_POLICY_DISABLE = 1, + WILC_FW_REKEY_POLICY_TIME_BASE, + WILC_FW_REKEY_POLICY_PKT_BASE, + WILC_FW_REKEY_POLICY_TIME_PKT_BASE +}; + +enum { + WILC_FW_FILTER_NO = 0x00, + WILC_FW_FILTER_AP_ONLY = 0x01, + WILC_FW_FILTER_STA_ONLY = 0x02 +}; + +enum { + WILC_FW_11N_PROT_AUTO = 0, /* Auto */ + WILC_FW_11N_NO_PROT, /* Do not use any protection */ + WILC_FW_11N_PROT_ERP, /* Protect all ERP frame exchanges */ + WILC_FW_11N_PROT_HT, /* Protect all HT frame exchanges */ + WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges */ +}; + +enum { + WILC_FW_ERP_PROT_SELF_CTS, + WILC_FW_ERP_PROT_RTS_CTS, +}; + +enum { + WILC_FW_11N_OP_MODE_HT_MIXED = 1, + WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ, + WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ, +}; + +enum { + WILC_FW_OBBS_NONHT_NO_DETECT = 0, + WILC_FW_OBBS_NONHT_DETECT_ONLY = 1, + WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2, + WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3, +}; + +enum { + WILC_FW_HT_PROT_RTS_CTS_NONHT = 0, /* RTS-CTS at non-HT rate */ + WILC_FW_HT_PROT_FIRST_FRAME_NONHT, /* First frame at non-HT rate */ + WILC_FW_HT_PROT_LSIG_TXOP, /* LSIG TXOP Protection */ + WILC_FW_HT_PROT_FIRST_FRAME_MIXED, /* First frame at Mixed format */ +}; + +enum { + WILC_FW_SMPS_MODE_STATIC = 1, + WILC_FW_SMPS_MODE_DYNAMIC = 2, + WILC_FW_SMPS_MODE_MIMO = 3, /* power save disable */ +}; + +enum { + WILC_FW_TX_RATE_AUTO = 0, + WILC_FW_TX_RATE_MBPS_1 = 1, + WILC_FW_TX_RATE_MBPS_2 = 2, + WILC_FW_TX_RATE_MBPS_5_5 = 5, + WILC_FW_TX_RATE_MBPS_11 = 11, + WILC_FW_TX_RATE_MBPS_6 = 6, + WILC_FW_TX_RATE_MBPS_9 = 9, + WILC_FW_TX_RATE_MBPS_12 = 12, + WILC_FW_TX_RATE_MBPS_18 = 18, + WILC_FW_TX_RATE_MBPS_24 = 24, + WILC_FW_TX_RATE_MBPS_36 = 36, + WILC_FW_TX_RATE_MBPS_48 = 48, + WILC_FW_TX_RATE_MBPS_54 = 54 +}; + +enum { + WILC_FW_DEFAULT_SCAN = 0, + WILC_FW_USER_SCAN = BIT(0), + WILC_FW_OBSS_PERIODIC_SCAN = BIT(1), + WILC_FW_OBSS_ONETIME_SCAN = BIT(2) +}; + +enum { + WILC_FW_ACTION_FRM_IDX = 0, + WILC_FW_PROBE_REQ_IDX = 1 +}; + +enum wid_type { + WID_CHAR = 0, + WID_SHORT = 1, + WID_INT = 2, + WID_STR = 3, + WID_BIN_DATA = 4, + WID_BIN = 5, +}; + +struct wid { + u16 id; + enum wid_type type; + s32 size; + s8 *val; +}; + +enum { + WID_NIL = 0xffff, + + /* + * BSS Type + * ----------------------------------------------------------- + * Configuration : Infrastructure Independent Access Point + * Values to set : 0 1 2 + * ----------------------------------------------------------- + */ + WID_BSS_TYPE = 0x0000, + + /* + * Transmit Rate + * ----------------------------------------------------------- + * Configuration : 1 2 5.5 11 6 9 12 18 24 36 48 54 + * Values to set : 1 2 5 11 6 9 12 18 24 36 48 54 + * ----------------------------------------------------------- + */ + WID_CURRENT_TX_RATE = 0x0001, + + /* + * Channel + * ----------------------------------------------------------- + * Configuration(g) : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + * Values to set : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + * ----------------------------------------------------------- + */ + WID_CURRENT_CHANNEL = 0x0002, + + /* + * Preamble + * ----------------------------------------------------------- + * Configuration : short long Auto + * Values to set : 0 1 2 + * ----------------------------------------------------------- + */ + WID_PREAMBLE = 0x0003, + + /* + * 11g operating mode (ignored if 11g not present) + * ----------------------------------------------------------- + * Configuration : HighPerf Compat(RSet #1) Compat(RSet #2) + * Values to set : 1 2 3 + * ----------------------------------------------------------- + */ + WID_11G_OPERATING_MODE = 0x0004, + + /* + * Mac status (response only) + * ----------------------------------------------------------- + * Configuration : disconnect connect + * Values to get : 0 1 + * ----------------------------------------------------------- + */ + WID_STATUS = 0x0005, + + /* + * Scan type + * ----------------------------------------------------------- + * Configuration : Passive Scanning Active Scanning + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_SCAN_TYPE = 0x0007, + + /* + * Key Id (WEP default key Id) + * ----------------------------------------------------------- + * Configuration : Any value between 0 to 3 + * Values to set : Same value. Default is 0 + * ----------------------------------------------------------- + */ + WID_KEY_ID = 0x0009, + + /* + * QoS Enable + * ----------------------------------------------------------- + * Configuration : QoS Disable WMM Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_QOS_ENABLE = 0x000A, + + /* + * Power Management + * ----------------------------------------------------------- + * Configuration : NO_POWERSAVE MIN_POWERSAVE MAX_POWERSAVE + * Values to set : 0 1 2 + * ----------------------------------------------------------- + */ + WID_POWER_MANAGEMENT = 0x000B, + + /* + * WEP/802 11I Configuration + * ----------------------------------------------------------- + * Configuration:Disable WP40 WP104 WPA-AES WPA-TKIP RSN-AES RSN-TKIP + * Values (0x) : 00 03 07 29 49 31 51 + * Configuration:WPA-AES+TKIP RSN-AES+TKIP + * Values (0x) : 69 71 + * ----------------------------------------------------------- + */ + WID_11I_MODE = 0x000C, + + /* + * WEP Configuration: Used in BSS STA mode only when WEP is enabled + * ----------------------------------------------------------- + * Configuration : Open System Shared Key Any Type | 802.1x Auth + * Values (0x) : 01 02 03 | BIT2 + * ----------------------------------------------------------- + */ + WID_AUTH_TYPE = 0x000D, + + /* + * Site Survey Type + * ----------------------------------------------------------- + * Configuration : Values to set + * Survey 1 Channel : 0 + * survey all Channels : 1 + * Disable Site Survey : 2 + * ----------------------------------------------------------- + */ + WID_SITE_SURVEY = 0x000E, + + /* + * Listen Interval + * ----------------------------------------------------------- + * Configuration : Any value between 1 to 255 + * Values to set : Same value. Default is 3 + * ----------------------------------------------------------- + */ + WID_LISTEN_INTERVAL = 0x000F, + + /* + * DTIM Period + * ----------------------------------------------------------- + * Configuration : Any value between 1 to 255 + * Values to set : Same value. Default is 3 + * ----------------------------------------------------------- + */ + WID_DTIM_PERIOD = 0x0010, + + /* + * ACK Policy + * ----------------------------------------------------------- + * Configuration : Normal Ack No Ack + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_ACK_POLICY = 0x0011, + + /* + * Reset MAC (Set only) + * ----------------------------------------------------------- + * Configuration : Don't Reset Reset No Request + * Values to set : 0 1 2 + * ----------------------------------------------------------- + */ + WID_RESET = 0x0012, + + /* + * Broadcast SSID Option: Setting this will adhere to "" SSID element + * ----------------------------------------------------------- + * Configuration : Enable Disable + * Values to set : 1 0 + * ----------------------------------------------------------- + */ + WID_BCAST_SSID = 0x0015, + + /* + * Disconnect (Station) + * ----------------------------------------------------------- + * Configuration : Association ID + * Values to set : Association ID + * ----------------------------------------------------------- + */ + WID_DISCONNECT = 0x0016, + + /* + * 11a Tx Power Level + * ----------------------------------------------------------- + * Configuration : Sets TX Power (Higher the value greater the power) + * Values to set : Any value between 0 and 63 (inclusive Default 48) + * ----------------------------------------------------------- + */ + WID_TX_POWER_LEVEL_11A = 0x0018, + + /* + * Group Key Update Policy Selection + * ----------------------------------------------------------- + * Configuration : Disabled timeBased packetBased timePacketBased + * Values to set : 1 2 3 4 + * ----------------------------------------------------------- + */ + WID_REKEY_POLICY = 0x0019, + + /* + * Allow Short Slot + * ----------------------------------------------------------- + * Configuration : Disallow Short Slot Allow Short Slot + * (Enable Only Long Slot) (Enable Short Slot if applicable) + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_SHORT_SLOT_ALLOWED = 0x001A, + + WID_PHY_ACTIVE_REG = 0x001B, + + /* + * 11b Tx Power Level + * ----------------------------------------------------------- + * Configuration : Sets TX Power (Higher the value greater the power) + * Values to set : Any value between 0 and 63 (inclusive Default 48) + * ----------------------------------------------------------- + */ + WID_TX_POWER_LEVEL_11B = 0x001D, + + /* + * Scan Request + * ----------------------------------------------------------- + * Configuration : Request default scan + * Values to set : 0 + * ----------------------------------------------------------- + */ + WID_START_SCAN_REQ = 0x001E, + + /* + * Rssi (get only) + * ----------------------------------------------------------- + * Configuration : + * Values to get : Rssi value + * ----------------------------------------------------------- + */ + WID_RSSI = 0x001F, + + /* + * Join Request + * ----------------------------------------------------------- + * Configuration : Request to join + * Values to set : index of scan result + * ----------------------------------------------------------- + */ + WID_JOIN_REQ = 0x0020, + + WID_LINKSPEED = 0x0026, + + /* + * Enable User Control of TX Power + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_USER_CONTROL_ON_TX_POWER = 0x0027, + + WID_MEMORY_ACCESS_8BIT = 0x0029, + + /* + * Enable Auto RX Sensitivity feature + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_AUTO_RX_SENSITIVITY = 0x0032, + + /* + * Receive Buffer Based Ack + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_DATAFLOW_CONTROL = 0x0033, + + /* + * Scan Filter + * ----------------------------------------------------------- + * Configuration : Class No filter AP only Station Only + * Values to set : 0 1 2 + * Configuration : Priority High Rssi Low Rssi Detect + * Values to set : 0 0x4 0x0 + * Configuration : Channel filter off filter on + * Values to set : 0 0x10 + * ----------------------------------------------------------- + */ + WID_SCAN_FILTER = 0x0036, + + /* + * Link Loss Threshold (measure in the beacon period) + * ----------------------------------------------------------- + * Configuration : Any value between 10 and 254(Set to 255 disable) + * Values to set : Same value. Default is 10 + * ----------------------------------------------------------- + */ + WID_LINK_LOSS_THRESHOLD = 0x0037, + + WID_ABORT_RUNNING_SCAN = 0x003E, + + /* NMAC Character WID list */ + WID_WPS_START = 0x0043, + + /* + * Protection mode for MAC + * ----------------------------------------------------------- + * Configuration : Auto No protection ERP HT GF + * Values to set : 0 1 2 3 4 + * ----------------------------------------------------------- + */ + WID_11N_PROT_MECH = 0x0080, + + /* + * ERP Protection type for MAC + * ----------------------------------------------------------- + * Configuration : Self-CTS RTS-CTS + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_11N_ERP_PROT_TYPE = 0x0081, + + /* + * HT Option Enable + * ----------------------------------------------------------- + * Configuration : HT Enable HT Disable + * Values to set : 1 0 + * ----------------------------------------------------------- + */ + WID_11N_ENABLE = 0x0082, + + /* + * 11n Operating mode (Note that 11g operating mode will also be + * used in addition to this, if this is set to HT Mixed mode) + * ----------------------------------------------------------- + * Configuration : HT Mixed HT Only-20MHz HT Only-20/40MHz + * Values to set : 1 2 3 + * ----------------------------------------------------------- + */ + WID_11N_OPERATING_MODE = 0x0083, + + /* + * 11n OBSS non-HT STA Detection flag + * ----------------------------------------------------------- + * Configuration : Do not detect + * Values to set : 0 + * Configuration : Detect, do not protect or report + * Values to set : 1 + * Configuration : Detect, protect and do not report + * Values to set : 2 + * Configuration : Detect, protect and report to other BSS + * Values to set : 3 + * ----------------------------------------------------------- + */ + WID_11N_OBSS_NONHT_DETECTION = 0x0084, + + /* + * 11n HT Protection Type + * ----------------------------------------------------------- + * Configuration : RTS-CTS First Frame Exchange at non-HT-rate + * Values to set : 0 1 + * Configuration : LSIG TXOP First Frame Exchange in Mixed Fmt + * Values to set : 2 3 + * ----------------------------------------------------------- + */ + WID_11N_HT_PROT_TYPE = 0x0085, + + /* + * 11n RIFS Protection Enable Flag + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_11N_RIFS_PROT_ENABLE = 0x0086, + + /* + * SMPS Mode + * ----------------------------------------------------------- + * Configuration : Static Dynamic MIMO (Power Save Disabled) + * Values to set : 1 2 3 + * ----------------------------------------------------------- + */ + WID_11N_SMPS_MODE = 0x0087, + + /* + * Current transmit MCS + * ----------------------------------------------------------- + * Configuration : MCS Index for data rate + * Values to set : 0 to 7 + * ----------------------------------------------------------- + */ + WID_11N_CURRENT_TX_MCS = 0x0088, + + WID_11N_PRINT_STATS = 0x0089, + + /* + * 11n Short GI Enable Flag + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_11N_SHORT_GI_ENABLE = 0x008D, + + /* + * 11n RIFS Enable Flag + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_RIFS_MODE = 0x0094, + + /* + * TX Abort Feature + * ----------------------------------------------------------- + * Configuration : Disable Self CTS Enable Self CTS + * Values to set : 0 1 + * Configuration : Disable TX Abort Enable TX Abort + * Values to set : 2 3 + * Configuration : Enable HW TX Abort Enable SW TX Abort + * Values to set : 4 5 + * ----------------------------------------------------------- + */ + WID_TX_ABORT_CONFIG = 0x00A1, + + WID_REG_TSSI_11B_VALUE = 0x00A6, + WID_REG_TSSI_11G_VALUE = 0x00A7, + WID_REG_TSSI_11N_VALUE = 0x00A8, + WID_TX_CALIBRATION = 0x00A9, + WID_DSCR_TSSI_11B_VALUE = 0x00AA, + WID_DSCR_TSSI_11G_VALUE = 0x00AB, + WID_DSCR_TSSI_11N_VALUE = 0x00AC, + + /* + * Immediate Block-Ack Support + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 0 1 + * ----------------------------------------------------------- + */ + WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF, + + /* + * TXOP Disable Flag + * ----------------------------------------------------------- + * Configuration : Disable Enable + * Values to set : 1 0 + * ----------------------------------------------------------- + */ + WID_11N_TXOP_PROT_DISABLE = 0x00B0, + + WID_TX_POWER_LEVEL_11N = 0x00B1, + + /* Custom Character WID list */ + /* SCAN Complete notification WID*/ + WID_SCAN_COMPLETE = 0x00C9, + + WID_DEL_BEACON = 0x00CA, + + WID_LOG_TERMINAL_SWITCH = 0x00CD, + WID_TX_POWER = 0x00CE, + /* EMAC Short WID list */ + /* RTS Threshold */ + /* + * ----------------------------------------------------------- + * Configuration : Any value between 256 to 2347 + * Values to set : Same value. Default is 2347 + * ----------------------------------------------------------- + */ + WID_RTS_THRESHOLD = 0x1000, + + /* + * Fragmentation Threshold + * ----------------------------------------------------------- + * Configuration : Any value between 256 to 2346 + * Values to set : Same value. Default is 2346 + * ----------------------------------------------------------- + */ + WID_FRAG_THRESHOLD = 0x1001, + + WID_SHORT_RETRY_LIMIT = 0x1002, + WID_LONG_RETRY_LIMIT = 0x1003, + WID_BEACON_INTERVAL = 0x1006, + WID_MEMORY_ACCESS_16BIT = 0x1008, + WID_PASSIVE_SCAN_TIME = 0x100D, + WID_JOIN_START_TIMEOUT = 0x100F, + WID_ASOC_TIMEOUT = 0x1011, + WID_11I_PROTOCOL_TIMEOUT = 0x1012, + WID_EAPOL_RESPONSE_TIMEOUT = 0x1013, + + /* NMAC Short WID list */ + WID_11N_SIG_QUAL_VAL = 0x1085, + WID_CCA_THRESHOLD = 0x1087, + + /* Custom Short WID list */ + + /* EMAC Integer WID list */ + WID_FAILED_COUNT = 0x2000, + WID_RETRY_COUNT = 0x2001, + WID_MULTIPLE_RETRY_COUNT = 0x2002, + WID_FRAME_DUPLICATE_COUNT = 0x2003, + WID_ACK_FAILURE_COUNT = 0x2004, + WID_RECEIVED_FRAGMENT_COUNT = 0x2005, + WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006, + WID_FCS_ERROR_COUNT = 0x2007, + WID_SUCCESS_FRAME_COUNT = 0x2008, + WID_HUT_TX_COUNT = 0x200A, + WID_TX_FRAGMENT_COUNT = 0x200B, + WID_TX_MULTICAST_FRAME_COUNT = 0x200C, + WID_RTS_SUCCESS_COUNT = 0x200D, + WID_RTS_FAILURE_COUNT = 0x200E, + WID_WEP_UNDECRYPTABLE_COUNT = 0x200F, + WID_REKEY_PERIOD = 0x2010, + WID_REKEY_PACKET_COUNT = 0x2011, + WID_1X_SERV_ADDR = 0x2012, + WID_STACK_IP_ADDR = 0x2013, + WID_STACK_NETMASK_ADDR = 0x2014, + WID_HW_RX_COUNT = 0x2015, + WID_MEMORY_ADDRESS = 0x201E, + WID_MEMORY_ACCESS_32BIT = 0x201F, + + /* NMAC Integer WID list */ + /* Custom Integer WID list */ + WID_GET_INACTIVE_TIME = 0x2084, + /* EMAC String WID list */ + WID_SSID = 0x3000, + WID_FIRMWARE_VERSION = 0x3001, + WID_OPERATIONAL_RATE_SET = 0x3002, + WID_BSSID = 0x3003, + WID_WEP_KEY_VALUE = 0x3004, + WID_11I_PSK = 0x3008, + WID_11E_P_ACTION_REQ = 0x3009, + WID_1X_KEY = 0x300A, + WID_HARDWARE_VERSION = 0x300B, + WID_MAC_ADDR = 0x300C, + WID_HUT_DEST_ADDR = 0x300D, + WID_PHY_VERSION = 0x300F, + WID_SUPP_USERNAME = 0x3010, + WID_SUPP_PASSWORD = 0x3011, + WID_SITE_SURVEY_RESULTS = 0x3012, + WID_RX_POWER_LEVEL = 0x3013, + WID_SET_STA_MAC_INACTIVE_TIME = 0x3017, + WID_ADD_WEP_KEY = 0x3019, + WID_REMOVE_WEP_KEY = 0x301A, + WID_ADD_PTK = 0x301B, + WID_ADD_RX_GTK = 0x301C, + WID_ADD_TX_GTK = 0x301D, + WID_REMOVE_KEY = 0x301E, + WID_ASSOC_REQ_INFO = 0x301F, + WID_ASSOC_RES_INFO = 0x3020, + WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ + WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ + WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ + WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ + + /* NMAC String WID list */ + WID_SET_OPERATION_MODE = 0x3079, + WID_11N_P_ACTION_REQ = 0x3080, + WID_HUT_TEST_ID = 0x3081, + WID_PMKID_INFO = 0x3082, + WID_FIRMWARE_INFO = 0x3083, + WID_REGISTER_FRAME = 0x3084, + WID_DEL_ALL_STA = 0x3085, + WID_REMAIN_ON_CHAN = 0x3996, + WID_SSID_PROBE_REQ = 0x3997, + WID_JOIN_REQ_EXTENDED = 0x3998, + + WID_IP_ADDRESS = 0x3999, + + /* Custom String WID list */ + + /* EMAC Binary WID list */ + WID_UAPSD_CONFIG = 0x4001, + WID_UAPSD_STATUS = 0x4002, + WID_WMM_AP_AC_PARAMS = 0x4003, + WID_WMM_STA_AC_PARAMS = 0x4004, + WID_NETWORK_INFO = 0x4005, + WID_STA_JOIN_INFO = 0x4006, + WID_CONNECTED_STA_LIST = 0x4007, + + /* NMAC Binary WID list */ + WID_11N_AUTORATE_TABLE = 0x4080, + + WID_SCAN_CHANNEL_LIST = 0x4084, + + WID_INFO_ELEMENT_PROBE = 0x4085, + WID_INFO_ELEMENT_ASSOCIATE = 0x4086, + WID_ADD_STA = 0X4087, + WID_REMOVE_STA = 0X4088, + WID_EDIT_STA = 0X4089, + WID_ADD_BEACON = 0x408a, + + WID_SETUP_MULTICAST_FILTER = 0x408b, + + /* Miscellaneous WIDs */ + WID_ALL = 0x7FFE, + WID_MAX = 0xFFFF +}; + +#endif -- cgit v1.2.3-59-g8ed1b From 664578d581a9699623255d6a7effbf563ff7cd79 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 5 Nov 2019 09:51:28 +0000 Subject: staging: wilc1000: added 'WILC_' prefix in header guard macro Use 'WILC_' prefix in header guard to follow the proper naming convention for macro name. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191105095058.24223-4-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/cfg80211.h | 4 ++-- drivers/staging/wilc1000/hif.h | 4 ++-- drivers/staging/wilc1000/netdev.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/cfg80211.h b/drivers/staging/wilc1000/cfg80211.h index 05c910baf095..5e5d63f70df2 100644 --- a/drivers/staging/wilc1000/cfg80211.h +++ b/drivers/staging/wilc1000/cfg80211.h @@ -4,8 +4,8 @@ * All rights reserved. */ -#ifndef NM_WFI_CFGOPERATIONS -#define NM_WFI_CFGOPERATIONS +#ifndef WILC_CFG80211_H +#define WILC_CFG80211_H #include "netdev.h" struct wiphy *wilc_cfg_alloc(void); diff --git a/drivers/staging/wilc1000/hif.h b/drivers/staging/wilc1000/hif.h index 2defe58ab194..22ee6fffd599 100644 --- a/drivers/staging/wilc1000/hif.h +++ b/drivers/staging/wilc1000/hif.h @@ -4,8 +4,8 @@ * All rights reserved. */ -#ifndef HOST_INT_H -#define HOST_INT_H +#ifndef WILC_HIF_H +#define WILC_HIF_H #include #include "wlan_if.h" diff --git a/drivers/staging/wilc1000/netdev.h b/drivers/staging/wilc1000/netdev.h index 8bc62ce4f2f7..42e0eb192b86 100644 --- a/drivers/staging/wilc1000/netdev.h +++ b/drivers/staging/wilc1000/netdev.h @@ -4,8 +4,8 @@ * All rights reserved. */ -#ifndef WILC_WFI_NETDEVICE -#define WILC_WFI_NETDEVICE +#ifndef WILC_NETDEV_H +#define WILC_NETDEV_H #include #include -- cgit v1.2.3-59-g8ed1b From f1f24260fc25adb8b563d14dc7d5cd628b448c2a Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 5 Nov 2019 09:51:30 +0000 Subject: staging: wilc1000: avoid use of C++ style comments Replace C++ style comment with C style. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191105095058.24223-5-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/hif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/hif.c b/drivers/staging/wilc1000/hif.c index 25f035c02b10..5f6706bcedf6 100644 --- a/drivers/staging/wilc1000/hif.c +++ b/drivers/staging/wilc1000/hif.c @@ -552,7 +552,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, param->mode_802_11i = 2; param->rsn_found = true; - //extract RSN capabilities + /* extract RSN capabilities */ offset += (rsn_ie[offset] * 4) + 2; offset += (rsn_ie[offset] * 4) + 2; memcpy(param->rsn_cap, &rsn_ie[offset], 2); -- cgit v1.2.3-59-g8ed1b From 027caaab0de784c57535d794459cf34cf6f12592 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 5 Nov 2019 09:51:33 +0000 Subject: staging: wilc1000: added proper spacing for comments Added proper space for the comments and added newline before the comments inside a struct. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191105095058.24223-6-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/mon.c | 2 +- drivers/staging/wilc1000/netdev.h | 19 ++++++++++++++----- drivers/staging/wilc1000/wlan.h | 2 +- drivers/staging/wilc1000/wlan_cfg.c | 2 +- drivers/staging/wilc1000/wlan_if.h | 8 ++++---- 5 files changed, 21 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/mon.c b/drivers/staging/wilc1000/mon.c index 853fe3056a53..48ac33f06f63 100644 --- a/drivers/staging/wilc1000/mon.c +++ b/drivers/staging/wilc1000/mon.c @@ -220,7 +220,7 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, { struct wilc_wfi_mon_priv *priv; - /*If monitor interface is already initialized, return it*/ + /* If monitor interface is already initialized, return it */ if (wl->monitor_dev) return wl->monitor_dev; diff --git a/drivers/staging/wilc1000/netdev.h b/drivers/staging/wilc1000/netdev.h index 42e0eb192b86..cd8f0d72caaa 100644 --- a/drivers/staging/wilc1000/netdev.h +++ b/drivers/staging/wilc1000/netdev.h @@ -60,7 +60,7 @@ struct sta_info { u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN]; }; -/*Parameters needed for host interface for remaining on channel*/ +/* Parameters needed for host interface for remaining on channel */ struct wilc_wfi_p2p_listen_params { struct ieee80211_channel *listen_ch; u32 listen_duration; @@ -145,11 +145,13 @@ struct wilc_priv { struct wilc_pmkid_attr pmkid_list; u8 wep_key[4][WLAN_KEY_LEN_WEP104]; u8 wep_key_len[4]; + /* The real interface that the monitor is on */ struct net_device *real_ndev; struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA]; struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA]; u8 wilc_groupkey; + /* mutexes */ struct mutex scan_req_lock; bool p2p_listen_state; @@ -224,16 +226,21 @@ struct wilc { int close; u8 vif_num; struct list_head vif_list; - /*protect vif list*/ + + /* protect vif list */ struct mutex vif_mutex; struct srcu_struct srcu; u8 open_ifcs; - /*protect head of transmit queue*/ + + /* protect head of transmit queue */ struct mutex txq_add_to_head_cs; - /*protect txq_entry_t transmit queue*/ + + /* protect txq_entry_t transmit queue */ spinlock_t txq_spinlock; - /*protect rxq_entry_t receiver queue*/ + + /* protect rxq_entry_t receiver queue */ struct mutex rxq_cs; + /* lock to protect hif access */ struct mutex hif_cs; @@ -245,6 +252,7 @@ struct wilc { struct task_struct *txq_thread; int quit; + /* lock to protect issue of wid command to firmware */ struct mutex cfg_cmd_lock; struct wilc_cfg_frame cfg_frame; @@ -271,6 +279,7 @@ struct wilc { struct wilc_cfg cfg; void *bus_data; struct net_device *monitor_dev; + /* deinit lock */ struct mutex deinit_lock; u8 sta_ch; diff --git a/drivers/staging/wilc1000/wlan.h b/drivers/staging/wilc1000/wlan.h index 7469fa47d588..1f6957cf2e9c 100644 --- a/drivers/staging/wilc1000/wlan.h +++ b/drivers/staging/wilc1000/wlan.h @@ -190,7 +190,7 @@ #define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM) #define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM) -/*time for expiring the completion of cfg packets*/ +/* time for expiring the completion of cfg packets */ #define WILC_CFG_PKTS_TIMEOUT msecs_to_jiffies(2000) #define IS_MANAGMEMENT 0x100 diff --git a/drivers/staging/wilc1000/wlan_cfg.c b/drivers/staging/wilc1000/wlan_cfg.c index 904f84077ff7..c5b1678c7b5e 100644 --- a/drivers/staging/wilc1000/wlan_cfg.c +++ b/drivers/staging/wilc1000/wlan_cfg.c @@ -378,7 +378,7 @@ void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, wilc_wlan_parse_info_frame(wilc, frame); rsp->type = WILC_CFG_RSP_STATUS; rsp->seq_no = msg_id; - /*call host interface info parse as well*/ + /* call host interface info parse as well */ wilc_gnrl_async_info_received(wilc, frame - 4, size + 4); break; diff --git a/drivers/staging/wilc1000/wlan_if.h b/drivers/staging/wilc1000/wlan_if.h index 70eac586f80c..7c7ee66c35f5 100644 --- a/drivers/staging/wilc1000/wlan_if.h +++ b/drivers/staging/wilc1000/wlan_if.h @@ -750,10 +750,10 @@ enum { WID_REMOVE_KEY = 0x301E, WID_ASSOC_REQ_INFO = 0x301F, WID_ASSOC_RES_INFO = 0x3020, - WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */ - WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */ - WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */ - WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */ + WID_MANUFACTURER = 0x3026, /* Added for CAPI tool */ + WID_MODEL_NAME = 0x3027, /* Added for CAPI tool */ + WID_MODEL_NUM = 0x3028, /* Added for CAPI tool */ + WID_DEVICE_NAME = 0x3029, /* Added for CAPI tool */ /* NMAC String WID list */ WID_SET_OPERATION_MODE = 0x3079, -- cgit v1.2.3-59-g8ed1b From 156aafd2bec0b707dc50cffb846e43cbc8258e80 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Tue, 5 Nov 2019 09:51:36 +0000 Subject: staging: wilc1000: use defines for msg types received from firmware Added defines for different types of messages received from firmware. Removed the unnecessary comments because after the addition of macros the message types are self-explanatory. Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191105095058.24223-7-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wlan_cfg.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/wlan_cfg.c b/drivers/staging/wilc1000/wlan_cfg.c index c5b1678c7b5e..6f6b286788d1 100644 --- a/drivers/staging/wilc1000/wlan_cfg.c +++ b/drivers/staging/wilc1000/wlan_cfg.c @@ -44,6 +44,11 @@ static const struct wilc_cfg_str g_cfg_str[] = { {WID_NIL, NULL} }; +#define WILC_RESP_MSG_TYPE_CONFIG_REPLY 'R' +#define WILC_RESP_MSG_TYPE_STATUS_INFO 'I' +#define WILC_RESP_MSG_TYPE_NETWORK_INFO 'N' +#define WILC_RESP_MSG_TYPE_SCAN_COMPLETE 'S' + /******************************************** * * Configuration Functions @@ -360,21 +365,14 @@ void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, size -= 4; rsp->type = 0; - /* - * The valid types of response messages are - * 'R' (Response), - * 'I' (Information), and - * 'N' (Network Information) - */ - switch (msg_type) { - case 'R': + case WILC_RESP_MSG_TYPE_CONFIG_REPLY: wilc_wlan_parse_response_frame(wilc, frame, size); rsp->type = WILC_CFG_RSP; rsp->seq_no = msg_id; break; - case 'I': + case WILC_RESP_MSG_TYPE_STATUS_INFO: wilc_wlan_parse_info_frame(wilc, frame); rsp->type = WILC_CFG_RSP_STATUS; rsp->seq_no = msg_id; @@ -382,11 +380,11 @@ void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size, wilc_gnrl_async_info_received(wilc, frame - 4, size + 4); break; - case 'N': + case WILC_RESP_MSG_TYPE_NETWORK_INFO: wilc_network_info_received(wilc, frame - 4, size + 4); break; - case 'S': + case WILC_RESP_MSG_TYPE_SCAN_COMPLETE: wilc_scan_complete_received(wilc, frame - 4, size + 4); break; -- cgit v1.2.3-59-g8ed1b From e1955fcdc71eb1c3572851dc0c94ff51f9fb495b Mon Sep 17 00:00:00 2001 From: Nachammai Karuppiah Date: Tue, 5 Nov 2019 09:06:31 -0800 Subject: staging: rtl8723bs: hal: Remove unnecessary typecast in kfree. Remove typecast in the call to kfree as it is not needed. Issue fixed using Coccinelle. Signed-off-by: Nachammai Karuppiah Link: https://lore.kernel.org/r/1572973591-12892-1-git-send-email-nachukannan@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 5ecd1c873871..b6b4adb5a28a 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -986,7 +986,7 @@ void sd_int_dpc(struct adapter *adapter) if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) { /* Handle CCX report here */ rtw_hal_c2h_handler(adapter, (u8 *)c2h_evt); - kfree((u8 *)c2h_evt); + kfree(c2h_evt); } else { rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); } -- cgit v1.2.3-59-g8ed1b From e71903106721dc53923e90aa484d78bc86c039a9 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Tue, 5 Nov 2019 22:03:20 +0000 Subject: staging: mt7621-dma: align to match open parenthesis Align to match open parenthesis. "CHECK: Alignment should match open parenthesis". Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191105220320.50180-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index 94c2c708dc92..20b898954416 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -548,7 +548,8 @@ static int mtk_hsdam_alloc_desc(struct mtk_hsdam_engine *hsdma, int i; chan->tx_ring = dma_alloc_coherent(hsdma->ddev.dev, - 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), + 2 * HSDMA_DESCS_NUM * + sizeof(*chan->tx_ring), &chan->desc_addr, GFP_ATOMIC | __GFP_ZERO); if (!chan->tx_ring) goto no_mem; @@ -569,8 +570,8 @@ static void mtk_hsdam_free_desc(struct mtk_hsdam_engine *hsdma, { if (chan->tx_ring) { dma_free_coherent(hsdma->ddev.dev, - 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), - chan->tx_ring, chan->desc_addr); + 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), + chan->tx_ring, chan->desc_addr); chan->tx_ring = NULL; chan->rx_ring = NULL; } -- cgit v1.2.3-59-g8ed1b From a8fa78b8f49752896aa208400519555e01512e47 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 5 Nov 2019 14:13:48 -0500 Subject: staging: rtl8723bs: Fix line over 80 characters Fix line over 80 characters by wrapping arguments in function call. Suggested-by: Julia Lawall . Signed-off-by: Javier F. Arias -- Changes in V4: - Changed the number of arguments before wrapping to make the code more readable. Changes in V3: - Edit the commit message to properly use the Suggested-by tag. Changes in V2: - Edit the commit message to use the Suggested-by tag. drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) Link: https://lore.kernel.org/r/61967dc169db6d343b9183361cd6c1ad7ad149fd.1572640293.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index c514cb735afd..a94462a48692 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -188,7 +188,8 @@ void rtl8723b_HalDmWatchDog(struct adapter *Adapter) bBtDisabled = hal_btcoex_IsBtDisabled(Adapter); - ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, ((bBtDisabled == true)?false:true)); + ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, + ((bBtDisabled == true)?false:true)); ODM_DMWatchdog(&pHalData->odmpriv); } -- cgit v1.2.3-59-g8ed1b From c3a12cc1ec4c9cb52a82d3691f35019816bda0a7 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 5 Nov 2019 14:14:19 -0500 Subject: staging: rtl8723bs: Simplify boolean expression Simplify expression that it's inverting a boolean value. Issue found by Coccinelle. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/9799bed4370f8cc1bd6a1735721fcd91fac30e09.1572640293.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index a94462a48692..650fbedd34e8 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -189,7 +189,7 @@ void rtl8723b_HalDmWatchDog(struct adapter *Adapter) bBtDisabled = hal_btcoex_IsBtDisabled(Adapter); ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, - ((bBtDisabled == true)?false:true)); + !bBtDisabled); ODM_DMWatchdog(&pHalData->odmpriv); } -- cgit v1.2.3-59-g8ed1b From fb22360db6517e2392d432737e4859ee07c43533 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:18 -0800 Subject: staging: vc04_services: Replace VCHI_INSTANCE_T with struct vhci_instance_handle Replaces VCHI_INSTANCE_T typedef with struct vchi_instance_handle to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/0b481a90b8a2b9cd6718e972dab681854ff312d7.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- drivers/staging/vc04_services/bcm2835-audio/bcm2835.h | 2 +- .../staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 2 +- drivers/staging/vc04_services/interface/vchi/vchi.h | 12 ++++++------ .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 18 +++++++++--------- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 84ece768854f..2022ff2388dc 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -122,7 +122,7 @@ static void audio_vchi_callback(void *param, } static int -vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, +vc_vchi_audio_init(struct vchi_instance_handle *vchi_instance, struct bcm2835_audio_instance *instance) { struct service_creation params = { diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index ed0feb34b6c8..d2fe8d36ab7d 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -44,7 +44,7 @@ enum snd_bcm2835_ctrl { }; struct bcm2835_vchi_ctx { - VCHI_INSTANCE_T vchi_instance; + struct vchi_instance_handle *vchi_instance; }; /* definition of the chip-specific record */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 06b7be7d8872..0f4db2f24944 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1814,7 +1814,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) { int status; struct vchiq_mmal_instance *instance; - static VCHI_INSTANCE_T vchi_instance; + static struct vchi_instance_handle *vchi_instance; struct service_creation params = { .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER), .service_id = VC_MMAL_SERVER_NAME, diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 75b1ab4919e3..5c8842114607 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -50,7 +50,7 @@ struct service_creation { }; // Opaque handle for a VCHI instance -typedef struct opaque_vchi_instance_handle_t *VCHI_INSTANCE_T; +struct vchi_instance_handle; // Opaque handle for a server or client typedef struct opaque_vchi_service_handle_t *VCHI_SERVICE_HANDLE_T; @@ -65,20 +65,20 @@ extern "C" { #endif // Routine used to initialise the vchi on both local + remote connections -extern int32_t vchi_initialise(VCHI_INSTANCE_T *instance_handle); +extern int32_t vchi_initialise(struct vchi_instance_handle **instance_handle); extern int32_t vchi_exit(void); -extern int32_t vchi_connect(VCHI_INSTANCE_T instance_handle); +extern int32_t vchi_connect(struct vchi_instance_handle *instance_handle); //When this is called, ensure that all services have no data pending. //Bulk transfers can remain 'queued' -extern int32_t vchi_disconnect(VCHI_INSTANCE_T instance_handle); +extern int32_t vchi_disconnect(struct vchi_instance_handle *instance_handle); // helper functions extern void *vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length); extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address); -extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle); +extern uint32_t vchi_current_time(struct vchi_instance_handle *instance_handle); /****************************************************************************** * Global service API @@ -87,7 +87,7 @@ extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle); extern int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle); // Routine to open a named service -extern int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, +extern int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, struct service_creation *setup, VCHI_SERVICE_HANDLE_T *handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 704afd470c88..0227c3f27697 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -428,7 +428,7 @@ EXPORT_SYMBOL(vchi_msg_hold); /*********************************************************** * Name: vchi_initialise * - * Arguments: VCHI_INSTANCE_T *instance_handle + * Arguments: struct vchi_instance_handle **instance_handle * * Description: Initialises the hardware but does not transmit anything * When run as a Host App this will be called twice hence the need @@ -438,14 +438,14 @@ EXPORT_SYMBOL(vchi_msg_hold); * ***********************************************************/ -int32_t vchi_initialise(VCHI_INSTANCE_T *instance_handle) +int32_t vchi_initialise(struct vchi_instance_handle **instance_handle) { VCHIQ_INSTANCE_T instance; VCHIQ_STATUS_T status; status = vchiq_initialise(&instance); - *instance_handle = (VCHI_INSTANCE_T)instance; + *instance_handle = (struct vchi_instance_handle *)instance; return vchiq_status_to_vchi(status); } @@ -454,7 +454,7 @@ EXPORT_SYMBOL(vchi_initialise); /*********************************************************** * Name: vchi_connect * - * Arguments: VCHI_INSTANCE_T instance_handle + * Arguments: struct vchi_instance_handle *instance_handle * * Description: Starts the command service on each connection, * causing INIT messages to be pinged back and forth @@ -462,7 +462,7 @@ EXPORT_SYMBOL(vchi_initialise); * Returns: 0 if successful, failure otherwise * ***********************************************************/ -int32_t vchi_connect(VCHI_INSTANCE_T instance_handle) +int32_t vchi_connect(struct vchi_instance_handle *instance_handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; @@ -473,7 +473,7 @@ EXPORT_SYMBOL(vchi_connect); /*********************************************************** * Name: vchi_disconnect * - * Arguments: VCHI_INSTANCE_T instance_handle + * Arguments: struct vchi_instance_handle *instance_handle * * Description: Stops the command service on each connection, * causing DE-INIT messages to be pinged back and forth @@ -481,7 +481,7 @@ EXPORT_SYMBOL(vchi_connect); * Returns: 0 if successful, failure otherwise * ***********************************************************/ -int32_t vchi_disconnect(VCHI_INSTANCE_T instance_handle) +int32_t vchi_disconnect(struct vchi_instance_handle *instance_handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; @@ -493,7 +493,7 @@ EXPORT_SYMBOL(vchi_disconnect); * Name: vchi_service_open * Name: vchi_service_create * - * Arguments: VCHI_INSTANCE_T *instance_handle + * Arguments: struct vchi_instance_handle *instance_handle * struct service_creation *setup, * VCHI_SERVICE_HANDLE_T *handle * @@ -593,7 +593,7 @@ static void service_free(struct shim_service *service) } } -int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, +int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, struct service_creation *setup, VCHI_SERVICE_HANDLE_T *handle) { -- cgit v1.2.3-59-g8ed1b From 29ebf64f741e7f40d6c0e5d187fa0cd0a0ddd4f1 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:19 -0800 Subject: staging: vc04_services: Replace VCHI_SERVICE_HANDLE_T typedef with struct vchi_service_handle Replaces VCHI_SERVICE_HANDLE_T typedef with vchi_service_handle struct to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/ec9a1a4bdd87ff008e48835cf7c39847d999b147.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 2 +- .../staging/vc04_services/interface/vchi/vchi.h | 42 +++++++++--------- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 50 +++++++++++----------- 4 files changed, 48 insertions(+), 48 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 2022ff2388dc..73144f1ce45e 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -9,7 +9,7 @@ struct bcm2835_audio_instance { struct device *dev; - VCHI_SERVICE_HANDLE_T vchi_handle; + struct vchi_service_handle *vchi_handle; struct completion msg_avail_comp; struct mutex vchi_mutex; struct bcm2835_alsa_stream *alsa_stream; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 0f4db2f24944..de03b90021a8 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -155,7 +155,7 @@ struct mmal_msg_context { }; struct vchiq_mmal_instance { - VCHI_SERVICE_HANDLE_T handle; + struct vchi_service_handle *handle; /* ensure serialised access to service */ struct mutex vchiq_mutex; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 5c8842114607..05fb5c3e8ba0 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -53,7 +53,7 @@ struct service_creation { struct vchi_instance_handle; // Opaque handle for a server or client -typedef struct opaque_vchi_service_handle_t *VCHI_SERVICE_HANDLE_T; +struct vchi_service_handle; /****************************************************************************** * Global funcs - implementation is specific to which side you are on @@ -76,53 +76,53 @@ extern int32_t vchi_connect(struct vchi_instance_handle *instance_handle); extern int32_t vchi_disconnect(struct vchi_instance_handle *instance_handle); // helper functions -extern void *vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length); -extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address); +extern void *vchi_allocate_buffer(struct vchi_service_handle *handle, uint32_t *length); +extern void vchi_free_buffer(struct vchi_service_handle *handle, void *address); extern uint32_t vchi_current_time(struct vchi_instance_handle *instance_handle); /****************************************************************************** * Global service API *****************************************************************************/ // Routine to destroy a service -extern int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle); +extern int32_t vchi_service_destroy(const struct vchi_service_handle *handle); // Routine to open a named service extern int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, struct service_creation *setup, - VCHI_SERVICE_HANDLE_T *handle); + struct vchi_service_handle **handle); -extern int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_get_peer_version(const struct vchi_service_handle *handle, short *peer_version); // Routine to close a named service -extern int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle); +extern int32_t vchi_service_close(const struct vchi_service_handle *handle); // Routine to increment ref count on a named service -extern int32_t vchi_service_use(const VCHI_SERVICE_HANDLE_T handle); +extern int32_t vchi_service_use(const struct vchi_service_handle *handle); // Routine to decrement ref count on a named service -extern int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle); +extern int32_t vchi_service_release(const struct vchi_service_handle *handle); // Routine to set a control option for a named service -extern int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_service_set_option(const struct vchi_service_handle *handle, enum vchi_service_option option, int value); /* Routine to send a message from kernel memory across a service */ extern int -vchi_queue_kernel_message(VCHI_SERVICE_HANDLE_T handle, +vchi_queue_kernel_message(struct vchi_service_handle *handle, void *data, unsigned int size); /* Routine to send a message from user memory across a service */ extern int -vchi_queue_user_message(VCHI_SERVICE_HANDLE_T handle, +vchi_queue_user_message(struct vchi_service_handle *handle, void __user *data, unsigned int size); // Routine to receive a msg from a service // Dequeue is equivalent to hold, copy into client buffer, release -extern int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_msg_dequeue(struct vchi_service_handle *handle, void *data, uint32_t max_data_size_to_read, uint32_t *actual_msg_size, @@ -131,26 +131,26 @@ extern int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, // Routine to look at a message in place. // The message is not dequeued, so a subsequent call to peek or dequeue // will return the same message. -extern int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_msg_peek(struct vchi_service_handle *handle, void **data, uint32_t *msg_size, enum vchi_flags flags); // Routine to remove a message after it has been read in place with peek // The first message on the queue is dequeued. -extern int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle); +extern int32_t vchi_msg_remove(struct vchi_service_handle *handle); // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. -extern int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_msg_hold(struct vchi_service_handle *handle, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T enum vchi_flags flags, struct vchi_held_msg *message_descriptor); // Initialise an iterator to look through messages in place -extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_msg_look_ahead(struct vchi_service_handle *handle, struct vchi_msg_iter *iter, enum vchi_flags flags); @@ -202,21 +202,21 @@ extern int32_t vchi_msg_iter_hold_next(struct vchi_msg_iter *iter, *****************************************************************************/ // Routine to prepare interface for a transfer from the other side -extern int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_bulk_queue_receive(struct vchi_service_handle *handle, void *data_dst, uint32_t data_size, enum vchi_flags flags, void *transfer_handle); // Prepare interface for a transfer from the other side into relocatable memory. -int32_t vchi_bulk_queue_receive_reloc(const VCHI_SERVICE_HANDLE_T handle, +int32_t vchi_bulk_queue_receive_reloc(const struct vchi_service_handle *handle, uint32_t offset, uint32_t data_size, const enum vchi_flags flags, void * const bulk_handle); // Routine to queue up data ready for transfer to the other (once they have signalled they are ready) -extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_bulk_queue_transmit(struct vchi_service_handle *handle, const void *data_src, uint32_t data_size, enum vchi_flags flags, @@ -230,7 +230,7 @@ extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, } #endif -extern int32_t vchi_bulk_queue_transmit_reloc(VCHI_SERVICE_HANDLE_T handle, +extern int32_t vchi_bulk_queue_transmit_reloc(struct vchi_service_handle *handle, uint32_t offset, uint32_t data_size, enum vchi_flags flags, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 0227c3f27697..fe2bb49815ae 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -23,7 +23,7 @@ struct shim_service { /*********************************************************** * Name: vchi_msg_peek * - * Arguments: const VCHI_SERVICE_HANDLE_T handle, + * Arguments: struct vchi_service_handle *handle, * void **data, * uint32_t *msg_size, @@ -36,7 +36,7 @@ struct shim_service { * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle, +int32_t vchi_msg_peek(struct vchi_service_handle *handle, void **data, uint32_t *msg_size, enum vchi_flags flags) @@ -63,7 +63,7 @@ EXPORT_SYMBOL(vchi_msg_peek); /*********************************************************** * Name: vchi_msg_remove * - * Arguments: const VCHI_SERVICE_HANDLE_T handle, + * Arguments: struct vchi_service_handle *handle, * * Description: Routine to remove a message (after it has been read with * vchi_msg_peek) @@ -71,7 +71,7 @@ EXPORT_SYMBOL(vchi_msg_peek); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle) +int32_t vchi_msg_remove(struct vchi_service_handle *handle) { struct shim_service *service = (struct shim_service *)handle; struct vchiq_header *header; @@ -87,7 +87,7 @@ EXPORT_SYMBOL(vchi_msg_remove); /*********************************************************** * Name: vchi_msg_queue * - * Arguments: VCHI_SERVICE_HANDLE_T handle, + * Arguments: struct vchi_service_handle *handle, * ssize_t (*copy_callback)(void *context, void *dest, * size_t offset, size_t maxsize), * void *context, @@ -99,7 +99,7 @@ EXPORT_SYMBOL(vchi_msg_remove); * ***********************************************************/ static -int32_t vchi_msg_queue(VCHI_SERVICE_HANDLE_T handle, +int32_t vchi_msg_queue(struct vchi_service_handle *handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), void *context, @@ -139,7 +139,7 @@ vchi_queue_kernel_message_callback(void *context, } int -vchi_queue_kernel_message(VCHI_SERVICE_HANDLE_T handle, +vchi_queue_kernel_message(struct vchi_service_handle *handle, void *data, unsigned int size) { @@ -169,7 +169,7 @@ vchi_queue_user_message_callback(void *context, } int -vchi_queue_user_message(VCHI_SERVICE_HANDLE_T handle, +vchi_queue_user_message(struct vchi_service_handle *handle, void __user *data, unsigned int size) { @@ -198,7 +198,7 @@ EXPORT_SYMBOL(vchi_queue_user_message); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, void *data_dst, +int32_t vchi_bulk_queue_receive(struct vchi_service_handle *handle, void *data_dst, uint32_t data_size, enum vchi_flags flags, void *bulk_handle) { @@ -256,7 +256,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, +int32_t vchi_bulk_queue_transmit(struct vchi_service_handle *handle, const void *data_src, uint32_t data_size, enum vchi_flags flags, @@ -307,7 +307,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); /*********************************************************** * Name: vchi_msg_dequeue * - * Arguments: VCHI_SERVICE_HANDLE_T handle, + * Arguments: struct vchi_service_handle *handle, * void *data, * uint32_t max_data_size_to_read, * uint32_t *actual_msg_size @@ -318,7 +318,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, void *data, +int32_t vchi_msg_dequeue(struct vchi_service_handle *handle, void *data, uint32_t max_data_size_to_read, uint32_t *actual_msg_size, enum vchi_flags flags) { @@ -376,7 +376,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); /*********************************************************** * Name: vchi_msg_hold * - * Arguments: VCHI_SERVICE_HANDLE_T handle, + * Arguments: struct vchi_service_handle *handle, * void **data, * uint32_t *msg_size, * enum vchi_flags flags, @@ -390,7 +390,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, void **data, +int32_t vchi_msg_hold(struct vchi_service_handle *handle, void **data, uint32_t *msg_size, enum vchi_flags flags, struct vchi_held_msg *message_handle) { @@ -495,7 +495,7 @@ EXPORT_SYMBOL(vchi_disconnect); * * Arguments: struct vchi_instance_handle *instance_handle * struct service_creation *setup, - * VCHI_SERVICE_HANDLE_T *handle + * struct vchi_service_handle **handle * * Description: Routine to open a service * @@ -595,12 +595,12 @@ static void service_free(struct shim_service *service) int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, struct service_creation *setup, - VCHI_SERVICE_HANDLE_T *handle) + struct vchi_service_handle **handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; struct shim_service *service = service_alloc(instance, setup); - *handle = (VCHI_SERVICE_HANDLE_T)service; + *handle = (struct vchi_service_handle *)service; if (service) { struct vchiq_service_params params; @@ -626,7 +626,7 @@ int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, } EXPORT_SYMBOL(vchi_service_open); -int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) +int32_t vchi_service_close(const struct vchi_service_handle *handle) { int32_t ret = -1; struct shim_service *service = (struct shim_service *)handle; @@ -642,7 +642,7 @@ int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) } EXPORT_SYMBOL(vchi_service_close); -int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle) +int32_t vchi_service_destroy(const struct vchi_service_handle *handle) { int32_t ret = -1; struct shim_service *service = (struct shim_service *)handle; @@ -661,7 +661,7 @@ int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle) } EXPORT_SYMBOL(vchi_service_destroy); -int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, +int32_t vchi_service_set_option(const struct vchi_service_handle *handle, enum vchi_service_option option, int value) { @@ -692,7 +692,7 @@ int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, } EXPORT_SYMBOL(vchi_service_set_option); -int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, short *peer_version) +int32_t vchi_get_peer_version(const struct vchi_service_handle *handle, short *peer_version) { int32_t ret = -1; struct shim_service *service = (struct shim_service *)handle; @@ -710,14 +710,14 @@ EXPORT_SYMBOL(vchi_get_peer_version); /*********************************************************** * Name: vchi_service_use * - * Arguments: const VCHI_SERVICE_HANDLE_T handle + * Arguments: const struct vchi_service_handle *handle * * Description: Routine to increment refcount on a service * * Returns: void * ***********************************************************/ -int32_t vchi_service_use(const VCHI_SERVICE_HANDLE_T handle) +int32_t vchi_service_use(const struct vchi_service_handle *handle) { int32_t ret = -1; @@ -731,14 +731,14 @@ EXPORT_SYMBOL(vchi_service_use); /*********************************************************** * Name: vchi_service_release * - * Arguments: const VCHI_SERVICE_HANDLE_T handle + * Arguments: const struct vchi_service_handle *handle * * Description: Routine to decrement refcount on a service * * Returns: void * ***********************************************************/ -int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle) +int32_t vchi_service_release(const struct vchi_service_handle *handle) { int32_t ret = -1; -- cgit v1.2.3-59-g8ed1b From 0ff3c366a7eb53f1c12f6d6ddb08b68c89841dcb Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:20 -0800 Subject: staging: vc04_services: Rename callback VCHI_CALLBACK_T to vchi_callback Renames callback function pointer typedef VCHI_CALLBACK_T to vchi_callback to better match kernel code style. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/0b0f85060b38e6195fe2d58989621e7b09eafe51.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 2 +- drivers/staging/vc04_services/interface/vchi/vchi_common.h | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 05fb5c3e8ba0..56b1037d8e25 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -45,7 +45,7 @@ struct vchi_held_msg { struct service_creation { struct vchi_version version; int32_t service_id; - VCHI_CALLBACK_T callback; + vchi_callback callback; void *callback_param; }; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index c99735fc0308..141af16ce031 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -86,9 +86,9 @@ enum vchi_service_option { }; //Callback used by all services / bulk transfers -typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param - enum vchi_callback_reason reason, - void *handle); //for transmitting msg's only +typedef void (*vchi_callback)(void *callback_param, //my service local param + enum vchi_callback_reason reason, + void *handle); //for transmitting msg's only /* * Define vector struct for scatter-gather (vector) operations diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index fe2bb49815ae..dd35147df3ac 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -16,7 +16,7 @@ struct shim_service { struct vchiu_queue queue; - VCHI_CALLBACK_T callback; + vchi_callback callback; void *callback_param; }; -- cgit v1.2.3-59-g8ed1b From 00d36494dee9e5020250e9bb5afd54362795847e Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:21 -0800 Subject: staging: vc04_services: Replace VCHIQ_STATUS_T enum typedef with enum vchiq_status Replaces VCHIQ_STATUS_T enum typedef with enum vchiq_status to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/7509cfa679c6d383ad979282f3d33b227d4d7f87.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_2835_arm.c | 10 +-- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 80 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 18 ++--- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 66 +++++++++--------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 28 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 44 ++++++------ .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 20 +++--- 7 files changed, 133 insertions(+), 133 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index b86d7e436357..e568e9e6eb95 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -168,10 +168,10 @@ int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) return 0; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_platform_init_state(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; struct vchiq_2835_state *platform_state; state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); @@ -214,7 +214,7 @@ remote_event_signal(struct remote_event *event) writel(0, g_regs + BELL2); /* trigger vc interrupt */ } -VCHIQ_STATUS_T +enum vchiq_status vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, int size, int dir) { @@ -258,13 +258,13 @@ vchiq_dump_platform_state(void *dump_context) vchiq_dump(dump_context, buf, len + 1); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_platform_suspend(struct vchiq_state *state) { return VCHIQ_ERROR; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_platform_resume(struct vchiq_state *state) { return VCHIQ_SUCCESS; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index dc54f443ef3d..edc77280585e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -172,14 +172,14 @@ static const char *const ioctl_names[] = { vchiq_static_assert(ARRAY_SIZE(ioctl_names) == (VCHIQ_IOC_MAX + 1)); -static VCHIQ_STATUS_T +static enum vchiq_status vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, unsigned int size, VCHIQ_BULK_DIR_T dir); #define VCHIQ_INIT_RETRIES 10 -VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) +enum vchiq_status vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_state *state; VCHIQ_INSTANCE_T instance = NULL; int i; @@ -230,9 +230,9 @@ failed: } EXPORT_SYMBOL(vchiq_initialise); -VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) +enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance) { - VCHIQ_STATUS_T status; + enum vchiq_status status; struct vchiq_state *state = instance->state; vchiq_log_trace(vchiq_core_log_level, @@ -272,9 +272,9 @@ static int vchiq_is_connected(VCHIQ_INSTANCE_T instance) return instance->connected; } -VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance) +enum vchiq_status vchiq_connect(VCHIQ_INSTANCE_T instance) { - VCHIQ_STATUS_T status; + enum vchiq_status status; struct vchiq_state *state = instance->state; vchiq_log_trace(vchiq_core_log_level, @@ -301,12 +301,12 @@ failed: } EXPORT_SYMBOL(vchiq_connect); -VCHIQ_STATUS_T vchiq_add_service( +enum vchiq_status vchiq_add_service( VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *phandle) { - VCHIQ_STATUS_T status; + enum vchiq_status status; struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; int srvstate; @@ -340,12 +340,12 @@ VCHIQ_STATUS_T vchiq_add_service( } EXPORT_SYMBOL(vchiq_add_service); -VCHIQ_STATUS_T vchiq_open_service( +enum vchiq_status vchiq_open_service( VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *phandle) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; @@ -380,11 +380,11 @@ failed: } EXPORT_SYMBOL(vchiq_open_service); -VCHIQ_STATUS_T +enum vchiq_status vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode) { - VCHIQ_STATUS_T status; + enum vchiq_status status; switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: @@ -405,11 +405,11 @@ vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, } EXPORT_SYMBOL(vchiq_bulk_transmit); -VCHIQ_STATUS_T +enum vchiq_status vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode) { - VCHIQ_STATUS_T status; + enum vchiq_status status; switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: @@ -429,13 +429,13 @@ vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, } EXPORT_SYMBOL(vchiq_bulk_receive); -static VCHIQ_STATUS_T +static enum vchiq_status vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, unsigned int size, VCHIQ_BULK_DIR_T dir) { VCHIQ_INSTANCE_T instance; struct vchiq_service *service; - VCHIQ_STATUS_T status; + enum vchiq_status status; struct bulk_waiter_node *waiter = NULL; service = find_service_by_handle(handle); @@ -515,7 +515,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, * ***************************************************************************/ -static VCHIQ_STATUS_T +static enum vchiq_status add_completion(VCHIQ_INSTANCE_T instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, void *bulk_userdata) @@ -582,7 +582,7 @@ add_completion(VCHIQ_INSTANCE_T instance, enum vchiq_reason reason, * ***************************************************************************/ -static VCHIQ_STATUS_T +static enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) { @@ -630,7 +630,7 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, */ if ((user_service->message_available_pos - instance->completion_remove) < 0) { - VCHIQ_STATUS_T status; + enum vchiq_status status; vchiq_log_info(vchiq_arm_log_level, "Inserting extra MESSAGE_AVAILABLE"); @@ -772,7 +772,7 @@ static ssize_t vchiq_ioc_copy_element_data(void *context, void *dest, * vchiq_ioc_queue_message * **************************************************************************/ -static VCHIQ_STATUS_T +static enum vchiq_status vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle, struct vchiq_element *elements, unsigned long count) @@ -805,7 +805,7 @@ static long vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { VCHIQ_INSTANCE_T instance = file->private_data; - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; struct vchiq_service *service = NULL; long ret = 0; int i, rc; @@ -2270,7 +2270,7 @@ vchiq_videocore_wanted(struct vchiq_state *state) return 1; } -static VCHIQ_STATUS_T +static enum vchiq_status vchiq_keepalive_vchiq_callback(enum vchiq_reason reason, struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T service_user, @@ -2287,7 +2287,7 @@ vchiq_keepalive_thread_func(void *v) struct vchiq_state *state = (struct vchiq_state *)v; struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T status; + enum vchiq_status status; VCHIQ_INSTANCE_T instance; VCHIQ_SERVICE_HANDLE_T ka_handle; @@ -2361,7 +2361,7 @@ exit: return 0; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_arm_init_state(struct vchiq_state *state, struct vchiq_arm_state *arm_state) { @@ -2563,10 +2563,10 @@ unblock_resume(struct vchiq_arm_state *arm_state) /* Initiate suspend via slot handler. Should be called with the write lock * held */ -VCHIQ_STATUS_T +enum vchiq_status vchiq_arm_vcsuspend(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); if (!arm_state) @@ -2684,12 +2684,12 @@ out: return resume; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, enum USE_TYPE_E use_type) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; + enum vchiq_status ret = VCHIQ_SUCCESS; char entity[16]; int *entity_uc; int local_uc, local_entity_uc; @@ -2798,7 +2798,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, } if (ret == VCHIQ_SUCCESS) { - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; long ack_cnt = atomic_xchg(&arm_state->ka_use_ack_count, 0); while (ack_cnt && (status == VCHIQ_SUCCESS)) { @@ -2817,11 +2817,11 @@ out: return ret; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; + enum vchiq_status ret = VCHIQ_SUCCESS; char entity[16]; int *entity_uc; @@ -2898,13 +2898,13 @@ vchiq_on_remote_release(struct vchiq_state *state) complete(&arm_state->ka_evt); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_use_service_internal(struct vchiq_service *service) { return vchiq_use_internal(service->state, service, USE_TYPE_SERVICE); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_release_service_internal(struct vchiq_service *service) { return vchiq_release_internal(service->state, service); @@ -2969,10 +2969,10 @@ static void suspend_timer_callback(struct timer_list *t) vchiq_check_suspend(state); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_STATUS_T ret = VCHIQ_ERROR; + enum vchiq_status ret = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); if (service) { @@ -2983,10 +2983,10 @@ vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) return ret; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_STATUS_T ret = VCHIQ_ERROR; + enum vchiq_status ret = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); if (service) { @@ -3088,11 +3088,11 @@ vchiq_dump_service_use_state(struct vchiq_state *state) vchiq_dump_platform_use_state(state); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_check_service(struct vchiq_service *service) { struct vchiq_arm_state *arm_state; - VCHIQ_STATUS_T ret = VCHIQ_ERROR; + enum vchiq_status ret = VCHIQ_ERROR; if (!service || !service->state) goto out; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index b424323e9613..ebab08b567fa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -109,13 +109,13 @@ int vchiq_platform_init(struct platform_device *pdev, extern struct vchiq_state * vchiq_get_state(void); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_arm_vcsuspend(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_arm_vcresume(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_arm_init_state(struct vchiq_state *state, struct vchiq_arm_state *arm_state); @@ -124,16 +124,16 @@ vchiq_check_resume(struct vchiq_state *state); extern void vchiq_check_suspend(struct vchiq_state *state); -VCHIQ_STATUS_T +enum vchiq_status vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_check_service(struct vchiq_service *service); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_platform_suspend(struct vchiq_state *state); extern int @@ -154,10 +154,10 @@ vchiq_platform_get_arm_state(struct vchiq_state *state); extern int vchiq_videocore_wanted(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, enum USE_TYPE_E use_type); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index e1898cfa5e91..55caf0f1ae98 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -354,11 +354,11 @@ mark_service_closing(struct vchiq_service *service) mark_service_closing_internal(service, 0); } -static inline VCHIQ_STATUS_T +static inline enum vchiq_status make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, struct vchiq_header *header, void *bulk_userdata) { - VCHIQ_STATUS_T status; + enum vchiq_status status; vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)", service->state->id, service->localport, reason_names[reason], @@ -779,7 +779,7 @@ copy_message_data( } /* Called by the slot handler and application threads */ -static VCHIQ_STATUS_T +static enum vchiq_status queue_message(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1027,7 +1027,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, } /* Called by the slot handler and application threads */ -static VCHIQ_STATUS_T +static enum vchiq_status queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1178,11 +1178,11 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, } /* Called by the slot handler - don't hold the bulk mutex */ -static VCHIQ_STATUS_T +static enum vchiq_status notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, int retry_poll) { - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=%x rn=%x r=%x", @@ -2123,12 +2123,12 @@ vchiq_init_slots(void *mem_base, int mem_size) return slot_zero; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) { struct vchiq_shared_state *local; struct vchiq_shared_state *remote; - VCHIQ_STATUS_T status; + enum vchiq_status status; char threadname[16]; int i; @@ -2409,7 +2409,7 @@ vchiq_add_service_internal(struct vchiq_state *state, return service; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_open_service_internal(struct vchiq_service *service, int client_id) { struct vchiq_open_payload payload = { @@ -2418,7 +2418,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) service->version, service->version_min }; - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; service->client_id = client_id; vchiq_use_service_internal(service); @@ -2516,7 +2516,7 @@ release_service_messages(struct vchiq_service *service) static int do_abort_bulks(struct vchiq_service *service) { - VCHIQ_STATUS_T status; + enum vchiq_status status; /* Abort any outstanding bulk transfers */ if (mutex_lock_killable(&service->bulk_mutex)) @@ -2532,10 +2532,10 @@ do_abort_bulks(struct vchiq_service *service) return (status == VCHIQ_SUCCESS); } -static VCHIQ_STATUS_T +static enum vchiq_status close_service_complete(struct vchiq_service *service, int failstate) { - VCHIQ_STATUS_T status; + enum vchiq_status status; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); int newstate; @@ -2594,11 +2594,11 @@ close_service_complete(struct vchiq_service *service, int failstate) } /* Called by the slot handler */ -VCHIQ_STATUS_T +enum vchiq_status vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) { struct vchiq_state *state = service->state; - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); vchiq_log_info(vchiq_core_log_level, "%d: csi:%d,%d (%s)", @@ -2774,7 +2774,7 @@ vchiq_free_service_internal(struct vchiq_service *service) unlock_service(service); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) { struct vchiq_service *service; @@ -2810,7 +2810,7 @@ vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) { struct vchiq_service *service; @@ -2827,12 +2827,12 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; if (!service) return VCHIQ_ERROR; @@ -2886,12 +2886,12 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) return status; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; + enum vchiq_status status = VCHIQ_SUCCESS; if (!service) return VCHIQ_ERROR; @@ -2952,7 +2952,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, +enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, void *userdata, VCHIQ_BULK_MODE_T mode, VCHIQ_BULK_DIR_T dir) @@ -2965,7 +2965,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ? VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; int payload[2]; if (!service || service->srvstate != VCHIQ_SRVSTATE_OPEN || @@ -3100,7 +3100,7 @@ error_exit: return status; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -3108,7 +3108,7 @@ vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, size_t size) { struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; if (!service || (vchiq_check_service(service) != VCHIQ_SUCCESS)) @@ -3192,10 +3192,10 @@ release_message_sync(struct vchiq_state *state, struct vchiq_header *header) remote_event_signal(&state->remote->sync_release); } -VCHIQ_STATUS_T +enum vchiq_status vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, short *peer_version) { - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); if (!service || @@ -3221,12 +3221,12 @@ void vchiq_get_config(struct vchiq_config *config) config->version_min = VCHIQ_VERSION_MIN; } -VCHIQ_STATUS_T +enum vchiq_status vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_SERVICE_OPTION_T option, int value) { struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_STATUS_T status = VCHIQ_ERROR; + enum vchiq_status status = VCHIQ_ERROR; if (service) { switch (option) { @@ -3524,9 +3524,9 @@ vchiq_loud_error_footer(void) "================"); } -VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) +enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_RETRY; + enum vchiq_status status = VCHIQ_RETRY; if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) status = queue_message(state, NULL, @@ -3535,9 +3535,9 @@ VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state) +enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state) { - VCHIQ_STATUS_T status = VCHIQ_RETRY; + enum vchiq_status status = VCHIQ_RETRY; if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) status = queue_message(state, NULL, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 75104986201b..bfee311e6410 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -491,10 +491,10 @@ get_conn_state_name(VCHIQ_CONNSTATE_T conn_state); extern struct vchiq_slot_zero * vchiq_init_slots(void *mem_base, int mem_size); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); extern struct vchiq_service * @@ -503,10 +503,10 @@ vchiq_add_service_internal(struct vchiq_state *state, int srvstate, VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_open_service_internal(struct vchiq_service *service, int client_id); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_close_service_internal(struct vchiq_service *service, int close_recvd); extern void @@ -515,13 +515,13 @@ vchiq_terminate_service_internal(struct vchiq_service *service); extern void vchiq_free_service_internal(struct vchiq_service *service); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); extern void remote_event_pollall(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, void *userdata, VCHIQ_BULK_MODE_T mode, VCHIQ_BULK_DIR_T dir); @@ -580,7 +580,7 @@ unlock_service(struct vchiq_service *service); /* The following functions are called from vchiq_core, and external ** implementations must be provided. */ -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, int size, int dir); @@ -596,7 +596,7 @@ vchiq_platform_check_suspend(struct vchiq_state *state); extern void vchiq_platform_paused(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_platform_resume(struct vchiq_state *state); extern void @@ -615,10 +615,10 @@ extern void vchiq_dump_platform_service_state(void *dump_context, struct vchiq_service *service); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_use_service_internal(struct vchiq_service *service); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_release_service_internal(struct vchiq_service *service); extern void @@ -627,19 +627,19 @@ vchiq_on_remote_use(struct vchiq_state *state); extern void vchiq_on_remote_release(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_platform_init_state(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_check_service(struct vchiq_service *service); extern void vchiq_on_remote_use_active(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state); extern void diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index f911612a6a54..89646d281898 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -25,11 +25,11 @@ enum vchiq_reason { VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ }; -typedef enum { +enum vchiq_status { VCHIQ_ERROR = -1, VCHIQ_SUCCESS = 0, VCHIQ_RETRY = 1 -} VCHIQ_STATUS_T; +}; typedef enum { VCHIQ_BULK_MODE_CALLBACK, @@ -63,7 +63,7 @@ struct vchiq_element { typedef unsigned int VCHIQ_SERVICE_HANDLE_T; -typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(enum vchiq_reason, +typedef enum vchiq_status (*VCHIQ_CALLBACK_T)(enum vchiq_reason, struct vchiq_header *, VCHIQ_SERVICE_HANDLE_T, void *); @@ -95,20 +95,20 @@ struct vchiq_config { typedef struct vchiq_instance_struct *VCHIQ_INSTANCE_T; typedef void (*VCHIQ_REMOTE_USE_CALLBACK_T)(void *cb_arg); -extern VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); -extern VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T vchiq_add_service(VCHIQ_INSTANCE_T instance, +extern enum vchiq_status vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); +extern enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance); +extern enum vchiq_status vchiq_connect(VCHIQ_INSTANCE_T instance); +extern enum vchiq_status vchiq_add_service(VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *pservice); -extern VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance, +extern enum vchiq_status vchiq_open_service(VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *pservice); -extern VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T +extern enum vchiq_status vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); +extern enum vchiq_status vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); +extern enum vchiq_status vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service); +extern enum vchiq_status vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service); +extern enum vchiq_status vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -116,33 +116,33 @@ vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, size_t size); extern void vchiq_release_message(VCHIQ_SERVICE_HANDLE_T service, struct vchiq_header *header); -extern VCHIQ_STATUS_T vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, const void *data, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); -extern VCHIQ_STATUS_T vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, void *data, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); -extern VCHIQ_STATUS_T vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service, const void *offset, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); -extern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, void *offset, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); extern void vchiq_get_config(struct vchiq_config *config); -extern VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, VCHIQ_SERVICE_OPTION_T option, int value); -extern VCHIQ_STATUS_T vchiq_remote_use(VCHIQ_INSTANCE_T instance, +extern enum vchiq_status vchiq_remote_use(VCHIQ_INSTANCE_T instance, VCHIQ_REMOTE_USE_CALLBACK_T callback, void *cb_arg); -extern VCHIQ_STATUS_T vchiq_remote_release(VCHIQ_INSTANCE_T instance); +extern enum vchiq_status vchiq_remote_release(VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T vchiq_dump_phys_mem(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_dump_phys_mem(VCHIQ_SERVICE_HANDLE_T service, void *ptr, size_t num_bytes); -extern VCHIQ_STATUS_T vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, +extern enum vchiq_status vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, short *peer_version); #endif /* VCHIQ_IF_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index dd35147df3ac..d186c38a43cc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -106,7 +106,7 @@ int32_t vchi_msg_queue(struct vchi_service_handle *handle, uint32_t data_size) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_STATUS_T status; + enum vchiq_status status; while (1) { status = vchiq_queue_message(service->handle, @@ -204,7 +204,7 @@ int32_t vchi_bulk_queue_receive(struct vchi_service_handle *handle, void *data_d { struct shim_service *service = (struct shim_service *)handle; VCHIQ_BULK_MODE_T mode; - VCHIQ_STATUS_T status; + enum vchiq_status status; switch ((int)flags) { case VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE @@ -264,7 +264,7 @@ int32_t vchi_bulk_queue_transmit(struct vchi_service_handle *handle, { struct shim_service *service = (struct shim_service *)handle; VCHIQ_BULK_MODE_T mode; - VCHIQ_STATUS_T status; + enum vchiq_status status; switch ((int)flags) { case VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE @@ -441,7 +441,7 @@ EXPORT_SYMBOL(vchi_msg_hold); int32_t vchi_initialise(struct vchi_instance_handle **instance_handle) { VCHIQ_INSTANCE_T instance; - VCHIQ_STATUS_T status; + enum vchiq_status status; status = vchiq_initialise(&instance); @@ -503,7 +503,7 @@ EXPORT_SYMBOL(vchi_disconnect); * ***********************************************************/ -static VCHIQ_STATUS_T shim_callback(enum vchiq_reason reason, +static enum vchiq_status shim_callback(enum vchiq_reason reason, struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_user) @@ -604,7 +604,7 @@ int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, if (service) { struct vchiq_service_params params; - VCHIQ_STATUS_T status; + enum vchiq_status status; memset(¶ms, 0, sizeof(params)); params.fourcc = setup->service_id; @@ -632,7 +632,7 @@ int32_t vchi_service_close(const struct vchi_service_handle *handle) struct shim_service *service = (struct shim_service *)handle; if (service) { - VCHIQ_STATUS_T status = vchiq_close_service(service->handle); + enum vchiq_status status = vchiq_close_service(service->handle); if (status == VCHIQ_SUCCESS) service_free(service); @@ -648,7 +648,7 @@ int32_t vchi_service_destroy(const struct vchi_service_handle *handle) struct shim_service *service = (struct shim_service *)handle; if (service) { - VCHIQ_STATUS_T status = vchiq_remove_service(service->handle); + enum vchiq_status status = vchiq_remove_service(service->handle); if (status == VCHIQ_SUCCESS) { service_free(service); @@ -681,7 +681,7 @@ int32_t vchi_service_set_option(const struct vchi_service_handle *handle, break; } if (service) { - VCHIQ_STATUS_T status = + enum vchiq_status status = vchiq_set_service_option(service->handle, vchiq_option, value); @@ -698,7 +698,7 @@ int32_t vchi_get_peer_version(const struct vchi_service_handle *handle, short *p struct shim_service *service = (struct shim_service *)handle; if (service) { - VCHIQ_STATUS_T status; + enum vchiq_status status; status = vchiq_get_peer_version(service->handle, peer_version); ret = vchiq_status_to_vchi(status); -- cgit v1.2.3-59-g8ed1b From c6ac64b1e81c95a2e9a8927dd730081331670e30 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:22 -0800 Subject: staging: vc04_services: Replace VCHIQ_BULK_MODE_T enum typedef with enum vchiq_bulk_mode Replaces VCHIQ_BULK_MODE_T enum typedef with enum vchiq_bulk_mode to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/667037e1810921e30371dbeb52c1ae489bf31f8c.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++---- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 12 ++++++------ .../staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- .../staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index edc77280585e..8c791e9d5c6a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -382,7 +382,7 @@ EXPORT_SYMBOL(vchiq_open_service); enum vchiq_status vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, - unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode) + unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { enum vchiq_status status; @@ -407,7 +407,7 @@ EXPORT_SYMBOL(vchiq_bulk_transmit); enum vchiq_status vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, - unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode) + unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { enum vchiq_status status; @@ -1107,7 +1107,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } kfree(waiter); } else { - const VCHIQ_BULK_MODE_T mode_waiting = + const enum vchiq_bulk_mode mode_waiting = VCHIQ_BULK_MODE_WAITING; waiter->pid = current->pid; mutex_lock(&instance->bulk_waiter_list_mutex); @@ -1611,7 +1611,7 @@ struct vchiq_queue_bulk_transfer32 { compat_uptr_t data; unsigned int size; compat_uptr_t userdata; - VCHIQ_BULK_MODE_T mode; + enum vchiq_bulk_mode mode; }; #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT32 \ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 55caf0f1ae98..380f93a6c107 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2954,7 +2954,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) */ enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, void *userdata, - VCHIQ_BULK_MODE_T mode, + enum vchiq_bulk_mode mode, VCHIQ_BULK_DIR_T dir) { struct vchiq_service *service = find_service_by_handle(handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index bfee311e6410..6a6ae0c01061 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -523,7 +523,7 @@ remote_event_pollall(struct vchiq_state *state); extern enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, - void *userdata, VCHIQ_BULK_MODE_T mode, + void *userdata, enum vchiq_bulk_mode mode, VCHIQ_BULK_DIR_T dir); extern void diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 89646d281898..5404e51f04a1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -31,12 +31,12 @@ enum vchiq_status { VCHIQ_RETRY = 1 }; -typedef enum { +enum vchiq_bulk_mode { VCHIQ_BULK_MODE_CALLBACK, VCHIQ_BULK_MODE_BLOCKING, VCHIQ_BULK_MODE_NOCALLBACK, VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ -} VCHIQ_BULK_MODE_T; +}; typedef enum { VCHIQ_SERVICE_OPTION_AUTOCLOSE, @@ -118,16 +118,16 @@ extern void vchiq_release_message(VCHIQ_SERVICE_HANDLE_T service, struct vchiq_header *header); extern enum vchiq_status vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, const void *data, unsigned int size, void *userdata, - VCHIQ_BULK_MODE_T mode); + enum vchiq_bulk_mode mode); extern enum vchiq_status vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, void *data, unsigned int size, void *userdata, - VCHIQ_BULK_MODE_T mode); + enum vchiq_bulk_mode mode); extern enum vchiq_status vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service, const void *offset, unsigned int size, - void *userdata, VCHIQ_BULK_MODE_T mode); + void *userdata, enum vchiq_bulk_mode mode); extern enum vchiq_status vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, void *offset, unsigned int size, void *userdata, - VCHIQ_BULK_MODE_T mode); + enum vchiq_bulk_mode mode); extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index c2343a1a3a6a..b991ce353a63 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -28,7 +28,7 @@ struct vchiq_queue_bulk_transfer { void *data; unsigned int size; void *userdata; - VCHIQ_BULK_MODE_T mode; + enum vchiq_bulk_mode mode; }; struct vchiq_completion_data { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index d186c38a43cc..ed6e42e3fa8d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -203,7 +203,7 @@ int32_t vchi_bulk_queue_receive(struct vchi_service_handle *handle, void *data_d void *bulk_handle) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_BULK_MODE_T mode; + enum vchiq_bulk_mode mode; enum vchiq_status status; switch ((int)flags) { @@ -263,7 +263,7 @@ int32_t vchi_bulk_queue_transmit(struct vchi_service_handle *handle, void *bulk_handle) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_BULK_MODE_T mode; + enum vchiq_bulk_mode mode; enum vchiq_status status; switch ((int)flags) { -- cgit v1.2.3-59-g8ed1b From 27c53ee865bab3ac94461c6a6dbaec435262c629 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:23 -0800 Subject: staging: vc04_services: Replace VCHIQ_SERVICE_OPTION_T enum typedef with enum vchiq_service_option Replaces VCHIQ_SERVICE_OPTION_T enum typedef with enum vchiq_service_option to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/f8e9c9170ed008043186dda99d40b60fb16c1d85.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 380f93a6c107..d72d160c32f8 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3223,7 +3223,7 @@ void vchiq_get_config(struct vchiq_config *config) enum vchiq_status vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, - VCHIQ_SERVICE_OPTION_T option, int value) + enum vchiq_service_option option, int value) { struct vchiq_service *service = find_service_by_handle(handle); enum vchiq_status status = VCHIQ_ERROR; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 5404e51f04a1..91cfb1cfafa7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -38,13 +38,13 @@ enum vchiq_bulk_mode { VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ }; -typedef enum { +enum vchiq_service_option { VCHIQ_SERVICE_OPTION_AUTOCLOSE, VCHIQ_SERVICE_OPTION_SLOT_QUOTA, VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, VCHIQ_SERVICE_OPTION_SYNCHRONOUS, VCHIQ_SERVICE_OPTION_TRACE -} VCHIQ_SERVICE_OPTION_T; +}; struct vchiq_header { /* The message identifier - opaque to applications. */ @@ -133,7 +133,7 @@ extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); extern void vchiq_get_config(struct vchiq_config *config); extern enum vchiq_status vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, - VCHIQ_SERVICE_OPTION_T option, int value); + enum vchiq_service_option option, int value); extern enum vchiq_status vchiq_remote_use(VCHIQ_INSTANCE_T instance, VCHIQ_REMOTE_USE_CALLBACK_T callback, void *cb_arg); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index b991ce353a63..202889b3774f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -60,7 +60,7 @@ struct vchiq_get_config { struct vchiq_set_service_option { unsigned int handle; - VCHIQ_SERVICE_OPTION_T option; + enum vchiq_service_option option; int value; }; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index ed6e42e3fa8d..ce11b9adbfa3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -667,7 +667,7 @@ int32_t vchi_service_set_option(const struct vchi_service_handle *handle, { int32_t ret = -1; struct shim_service *service = (struct shim_service *)handle; - VCHIQ_SERVICE_OPTION_T vchiq_option; + enum vchiq_service_option vchiq_option; switch (option) { case VCHI_SERVICE_OPTION_TRACE: -- cgit v1.2.3-59-g8ed1b From 051fbf4739bddb7e22255b67029e083b37f68586 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:24 -0800 Subject: staging: vc04_services: Replace VCHIQ_CONNSTATE_T enum typedef with enum vchiq_connstate Replaces VCHIQ_CONNSTATE_T enum typedef with enum vchiq_connstate to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/7e64765a55193413e9668dc53f751c435369ed80.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 6 +++--- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 8c791e9d5c6a..6991db873e02 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3128,8 +3128,8 @@ void vchiq_on_remote_use_active(struct vchiq_state *state) } void vchiq_platform_conn_state_changed(struct vchiq_state *state, - VCHIQ_CONNSTATE_T oldstate, - VCHIQ_CONNSTATE_T newstate) + enum vchiq_connstate oldstate, + enum vchiq_connstate newstate) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index d72d160c32f8..326a1906c75e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -375,9 +375,9 @@ make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, } inline void -vchiq_set_conn_state(struct vchiq_state *state, VCHIQ_CONNSTATE_T newstate) +vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) { - VCHIQ_CONNSTATE_T oldstate = state->conn_state; + enum vchiq_connstate oldstate = state->conn_state; vchiq_log_info(vchiq_core_log_level, "%d: %s->%s", state->id, conn_state_names[oldstate], @@ -2078,7 +2078,7 @@ init_bulk_queue(struct vchiq_bulk_queue *queue) } inline const char * -get_conn_state_name(VCHIQ_CONNSTATE_T conn_state) +get_conn_state_name(enum vchiq_connstate conn_state) { return conn_state_names[conn_state]; } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 6a6ae0c01061..8e064047abae 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -169,7 +169,7 @@ enum { #endif /* VCHIQ_ENABLE_DEBUG */ -typedef enum { +enum vchiq_connstate { VCHIQ_CONNSTATE_DISCONNECTED, VCHIQ_CONNSTATE_CONNECTING, VCHIQ_CONNSTATE_CONNECTED, @@ -179,7 +179,7 @@ typedef enum { VCHIQ_CONNSTATE_RESUMING, VCHIQ_CONNSTATE_PAUSE_TIMEOUT, VCHIQ_CONNSTATE_RESUME_TIMEOUT -} VCHIQ_CONNSTATE_T; +}; enum { VCHIQ_SRVSTATE_FREE, @@ -367,7 +367,7 @@ struct vchiq_slot_zero { struct vchiq_state { int id; int initialised; - VCHIQ_CONNSTATE_T conn_state; + enum vchiq_connstate conn_state; short version_common; struct vchiq_shared_state *local; @@ -486,7 +486,7 @@ extern int vchiq_sync_log_level; extern struct vchiq_state *vchiq_states[VCHIQ_MAX_STATES]; extern const char * -get_conn_state_name(VCHIQ_CONNSTATE_T conn_state); +get_conn_state_name(enum vchiq_connstate conn_state); extern struct vchiq_slot_zero * vchiq_init_slots(void *mem_base, int mem_size); @@ -644,14 +644,14 @@ vchiq_send_remote_use_active(struct vchiq_state *state); extern void vchiq_platform_conn_state_changed(struct vchiq_state *state, - VCHIQ_CONNSTATE_T oldstate, - VCHIQ_CONNSTATE_T newstate); + enum vchiq_connstate oldstate, + enum vchiq_connstate newstate); extern void vchiq_platform_handle_timeout(struct vchiq_state *state); extern void -vchiq_set_conn_state(struct vchiq_state *state, VCHIQ_CONNSTATE_T newstate); +vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate); extern void vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem, -- cgit v1.2.3-59-g8ed1b From d2684ce853cf275c724d14f5df5cdfac9064d2bd Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:25 -0800 Subject: staging: vc04_services: Replace VCHIQ_BULK_DIR_T enum typedef with enum vchiq_bulk_dir Replaces VCHIQ_BULK_DIR_T enum typedef with enum vchiq_bulk_dir to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/344e01e371aa7fbf670ba118be174e391e078e6a.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6991db873e02..1edfaa80f7c1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -174,7 +174,7 @@ vchiq_static_assert(ARRAY_SIZE(ioctl_names) == static enum vchiq_status vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, - unsigned int size, VCHIQ_BULK_DIR_T dir); + unsigned int size, enum vchiq_bulk_dir dir); #define VCHIQ_INIT_RETRIES 10 enum vchiq_status vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) @@ -431,7 +431,7 @@ EXPORT_SYMBOL(vchiq_bulk_receive); static enum vchiq_status vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, - unsigned int size, VCHIQ_BULK_DIR_T dir) + unsigned int size, enum vchiq_bulk_dir dir) { VCHIQ_INSTANCE_T instance; struct vchiq_service *service; @@ -1042,7 +1042,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_queue_bulk_transfer args; struct bulk_waiter_node *waiter = NULL; - VCHIQ_BULK_DIR_T dir = + enum vchiq_bulk_dir dir = (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT) ? VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 326a1906c75e..4392dad352da 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2955,7 +2955,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, void *userdata, enum vchiq_bulk_mode mode, - VCHIQ_BULK_DIR_T dir) + enum vchiq_bulk_dir dir) { struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_bulk_queue *queue; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 8e064047abae..d8ecc2fd1677 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -202,10 +202,10 @@ enum { VCHIQ_POLL_COUNT }; -typedef enum { +enum vchiq_bulk_dir { VCHIQ_BULK_TRANSMIT, VCHIQ_BULK_RECEIVE -} VCHIQ_BULK_DIR_T; +}; typedef void (*VCHIQ_USERDATA_TERM_T)(void *userdata); @@ -524,7 +524,7 @@ remote_event_pollall(struct vchiq_state *state); extern enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, void *userdata, enum vchiq_bulk_mode mode, - VCHIQ_BULK_DIR_T dir); + enum vchiq_bulk_dir dir); extern void vchiq_dump_state(void *dump_context, struct vchiq_state *state); -- cgit v1.2.3-59-g8ed1b From e661ad496a6fdd18c07de66f1d6c2aa1246619aa Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:26 -0800 Subject: staging: vc04_services: Rename callback VCHIQ_USERDATA_TERM_T to vchiq_userdata_term Renames callback VCHIQ_USERDATA_TERM_T to vchiq_userdata_term to match kernel code style. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/478914a1e756f78c3277acb3852c1ccdcb2d5750.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 4392dad352da..bb2645b9ba00 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2281,7 +2281,7 @@ struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, const struct vchiq_service_params *params, int srvstate, VCHIQ_INSTANCE_T instance, - VCHIQ_USERDATA_TERM_T userdata_term) + vchiq_userdata_term userdata_term) { struct vchiq_service *service; struct vchiq_service **pservice = NULL; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index d8ecc2fd1677..d56ee1b99e9c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -207,7 +207,7 @@ enum vchiq_bulk_dir { VCHIQ_BULK_RECEIVE }; -typedef void (*VCHIQ_USERDATA_TERM_T)(void *userdata); +typedef void (*vchiq_userdata_term)(void *userdata); struct vchiq_bulk { short mode; @@ -253,7 +253,7 @@ struct vchiq_service { VCHIQ_SERVICE_HANDLE_T handle; unsigned int ref_count; int srvstate; - VCHIQ_USERDATA_TERM_T userdata_term; + vchiq_userdata_term userdata_term; unsigned int localport; unsigned int remoteport; int public_fourcc; @@ -501,7 +501,7 @@ extern struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, const struct vchiq_service_params *params, int srvstate, VCHIQ_INSTANCE_T instance, - VCHIQ_USERDATA_TERM_T userdata_term); + vchiq_userdata_term userdata_term); extern enum vchiq_status vchiq_open_service_internal(struct vchiq_service *service, int client_id); -- cgit v1.2.3-59-g8ed1b From 80be64b2bf6dd67fc201377beedecb6f8011301e Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:27 -0800 Subject: staging: vc04_services: Rename VCHIQ_CALLBACK_T to vchiq_callback Renames VCHIQ_CALLBACK_T to vchiq_callback to match kernel code style. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/6abe37fb39f896b257d7b370e1c2ad861ed8b675.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 91cfb1cfafa7..a6f17b91ff78 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -63,19 +63,19 @@ struct vchiq_element { typedef unsigned int VCHIQ_SERVICE_HANDLE_T; -typedef enum vchiq_status (*VCHIQ_CALLBACK_T)(enum vchiq_reason, - struct vchiq_header *, - VCHIQ_SERVICE_HANDLE_T, void *); +typedef enum vchiq_status (*vchiq_callback)(enum vchiq_reason, + struct vchiq_header *, + VCHIQ_SERVICE_HANDLE_T, void *); struct vchiq_service_base { int fourcc; - VCHIQ_CALLBACK_T callback; + vchiq_callback callback; void *userdata; }; struct vchiq_service_params { int fourcc; - VCHIQ_CALLBACK_T callback; + vchiq_callback callback; void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ -- cgit v1.2.3-59-g8ed1b From c8bf4d3db9ef3a0ed8b53b622ffa1aca7559a352 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:28 -0800 Subject: staging: vc04_services: Rename VCHIQ_REMOTE_USE_CALLBACK_T to vchiq_remote_callback Renames VCHIQ_REMOTE_USE_CALLBACK_T to vchiq_remote_callback to match kernel code style. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/dacc944e3981290d3e5b81aa600f4c19be8e6f10.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index a6f17b91ff78..d9b23af25671 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -93,7 +93,7 @@ struct vchiq_config { }; typedef struct vchiq_instance_struct *VCHIQ_INSTANCE_T; -typedef void (*VCHIQ_REMOTE_USE_CALLBACK_T)(void *cb_arg); +typedef void (*vchiq_remote_callback)(void *cb_arg); extern enum vchiq_status vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); extern enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance); @@ -136,7 +136,7 @@ extern enum vchiq_status vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service enum vchiq_service_option option, int value); extern enum vchiq_status vchiq_remote_use(VCHIQ_INSTANCE_T instance, - VCHIQ_REMOTE_USE_CALLBACK_T callback, void *cb_arg); + vchiq_remote_callback callback, void *cb_arg); extern enum vchiq_status vchiq_remote_release(VCHIQ_INSTANCE_T instance); extern enum vchiq_status vchiq_dump_phys_mem(VCHIQ_SERVICE_HANDLE_T service, -- cgit v1.2.3-59-g8ed1b From 9ce46d55510fae690f3104dda591c3a9b0085f38 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:29 -0800 Subject: staging: vc04_services: Replace VCHIQ_SERVICE_HANDLE_T typedef with unsigned int Replaces VCHIQ_SERVICE_HANDLE_T typedef with unsigned int to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/9d35b9fea684d18cc1e989621808d77eef3081c6.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 32 ++++++++--------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 4 +-- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 26 +++++++------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 12 +++---- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 40 ++++++++++------------ .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 10 +++--- 6 files changed, 61 insertions(+), 63 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 1edfaa80f7c1..add552226eaa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -173,7 +173,7 @@ vchiq_static_assert(ARRAY_SIZE(ioctl_names) == (VCHIQ_IOC_MAX + 1)); static enum vchiq_status -vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, +vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir); #define VCHIQ_INIT_RETRIES 10 @@ -304,7 +304,7 @@ EXPORT_SYMBOL(vchiq_connect); enum vchiq_status vchiq_add_service( VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, - VCHIQ_SERVICE_HANDLE_T *phandle) + unsigned int *phandle) { enum vchiq_status status; struct vchiq_state *state = instance->state; @@ -343,7 +343,7 @@ EXPORT_SYMBOL(vchiq_add_service); enum vchiq_status vchiq_open_service( VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, - VCHIQ_SERVICE_HANDLE_T *phandle) + unsigned int *phandle) { enum vchiq_status status = VCHIQ_ERROR; struct vchiq_state *state = instance->state; @@ -381,7 +381,7 @@ failed: EXPORT_SYMBOL(vchiq_open_service); enum vchiq_status -vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, +vchiq_bulk_transmit(unsigned int handle, const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { enum vchiq_status status; @@ -406,7 +406,7 @@ vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, EXPORT_SYMBOL(vchiq_bulk_transmit); enum vchiq_status -vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, +vchiq_bulk_receive(unsigned int handle, void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { enum vchiq_status status; @@ -430,7 +430,7 @@ vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, EXPORT_SYMBOL(vchiq_bulk_receive); static enum vchiq_status -vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, +vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir) { VCHIQ_INSTANCE_T instance; @@ -584,7 +584,7 @@ add_completion(VCHIQ_INSTANCE_T instance, enum vchiq_reason reason, static enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, - VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) + unsigned int handle, void *bulk_userdata) { /* How do we ensure the callback goes to the right client? ** The service_user data points to a user_service record @@ -773,7 +773,7 @@ static ssize_t vchiq_ioc_copy_element_data(void *context, void *dest, * **************************************************************************/ static enum vchiq_status -vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle, +vchiq_ioc_queue_message(unsigned int handle, struct vchiq_element *elements, unsigned long count) { @@ -952,7 +952,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_CLOSE_SERVICE: case VCHIQ_IOC_REMOVE_SERVICE: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; struct user_service *user_service; service = find_service_for_instance(instance, handle); @@ -985,7 +985,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_USE_SERVICE: case VCHIQ_IOC_RELEASE_SERVICE: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; service = find_service_for_instance(instance, handle); if (service) { @@ -1368,7 +1368,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_GET_CLIENT_ID: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; ret = vchiq_get_client_id(handle); } break; @@ -1423,7 +1423,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_CLOSE_DELIVERED: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + unsigned int handle = (unsigned int)arg; service = find_closed_service_for_instance(instance, handle); if (service) { @@ -2273,7 +2273,7 @@ vchiq_videocore_wanted(struct vchiq_state *state) static enum vchiq_status vchiq_keepalive_vchiq_callback(enum vchiq_reason reason, struct vchiq_header *header, - VCHIQ_SERVICE_HANDLE_T service_user, + unsigned int service_user, void *bulk_user) { vchiq_log_error(vchiq_susp_log_level, @@ -2289,7 +2289,7 @@ vchiq_keepalive_thread_func(void *v) enum vchiq_status status; VCHIQ_INSTANCE_T instance; - VCHIQ_SERVICE_HANDLE_T ka_handle; + unsigned int ka_handle; struct vchiq_service_params params = { .fourcc = VCHIQ_MAKE_FOURCC('K', 'E', 'E', 'P'), @@ -2970,7 +2970,7 @@ static void suspend_timer_callback(struct timer_list *t) } enum vchiq_status -vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_use_service(unsigned int handle) { enum vchiq_status ret = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); @@ -2984,7 +2984,7 @@ vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) } enum vchiq_status -vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_release_service(unsigned int handle) { enum vchiq_status ret = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index ebab08b567fa..229dd262ec7d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -125,10 +125,10 @@ vchiq_check_resume(struct vchiq_state *state); extern void vchiq_check_suspend(struct vchiq_state *state); enum vchiq_status -vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle); +vchiq_use_service(unsigned int handle); extern enum vchiq_status -vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle); +vchiq_release_service(unsigned int handle); extern enum vchiq_status vchiq_check_service(struct vchiq_service *service); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index bb2645b9ba00..7cdb5d50fb4e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -132,7 +132,7 @@ vchiq_set_service_state(struct vchiq_service *service, int newstate) } struct vchiq_service * -find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle) +find_service_by_handle(unsigned int handle) { struct vchiq_service *service; @@ -178,7 +178,7 @@ find_service_by_port(struct vchiq_state *state, int localport) struct vchiq_service * find_service_for_instance(VCHIQ_INSTANCE_T instance, - VCHIQ_SERVICE_HANDLE_T handle) + unsigned int handle) { struct vchiq_service *service; @@ -202,7 +202,7 @@ find_service_for_instance(VCHIQ_INSTANCE_T instance, struct vchiq_service * find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, - VCHIQ_SERVICE_HANDLE_T handle) + unsigned int handle) { struct vchiq_service *service; @@ -295,7 +295,7 @@ unlock: } int -vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_get_client_id(unsigned int handle) { struct vchiq_service *service = find_service_by_handle(handle); int id; @@ -308,7 +308,7 @@ vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T handle) } void * -vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_get_service_userdata(unsigned int handle) { struct vchiq_service *service = handle_to_service(handle); @@ -316,7 +316,7 @@ vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T handle) } int -vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_get_service_fourcc(unsigned int handle) { struct vchiq_service *service = handle_to_service(handle); @@ -2828,7 +2828,7 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) } enum vchiq_status -vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_close_service(unsigned int handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(handle); @@ -2887,7 +2887,7 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) } enum vchiq_status -vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) +vchiq_remove_service(unsigned int handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(handle); @@ -2952,7 +2952,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -enum vchiq_status vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, +enum vchiq_status vchiq_bulk_transfer(unsigned int handle, void *offset, int size, void *userdata, enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir) @@ -3101,7 +3101,7 @@ error_exit: } enum vchiq_status -vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, +vchiq_queue_message(unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), void *context, @@ -3153,7 +3153,7 @@ error_exit: } void -vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, +vchiq_release_message(unsigned int handle, struct vchiq_header *header) { struct vchiq_service *service = find_service_by_handle(handle); @@ -3193,7 +3193,7 @@ release_message_sync(struct vchiq_state *state, struct vchiq_header *header) } enum vchiq_status -vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, short *peer_version) +vchiq_get_peer_version(unsigned int handle, short *peer_version) { enum vchiq_status status = VCHIQ_ERROR; struct vchiq_service *service = find_service_by_handle(handle); @@ -3222,7 +3222,7 @@ void vchiq_get_config(struct vchiq_config *config) } enum vchiq_status -vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, +vchiq_set_service_option(unsigned int handle, enum vchiq_service_option option, int value) { struct vchiq_service *service = find_service_by_handle(handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index d56ee1b99e9c..0339503d57d7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -250,7 +250,7 @@ struct vchiq_slot_info { struct vchiq_service { struct vchiq_service_base base; - VCHIQ_SERVICE_HANDLE_T handle; + unsigned int handle; unsigned int ref_count; int srvstate; vchiq_userdata_term userdata_term; @@ -522,7 +522,7 @@ extern void remote_event_pollall(struct vchiq_state *state); extern enum vchiq_status -vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, +vchiq_bulk_transfer(unsigned int handle, void *offset, int size, void *userdata, enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir); @@ -543,7 +543,7 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service, int poll_type); static inline struct vchiq_service * -handle_to_service(VCHIQ_SERVICE_HANDLE_T handle) +handle_to_service(unsigned int handle) { struct vchiq_state *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) & (VCHIQ_MAX_STATES - 1)]; @@ -554,18 +554,18 @@ handle_to_service(VCHIQ_SERVICE_HANDLE_T handle) } extern struct vchiq_service * -find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle); +find_service_by_handle(unsigned int handle); extern struct vchiq_service * find_service_by_port(struct vchiq_state *state, int localport); extern struct vchiq_service * find_service_for_instance(VCHIQ_INSTANCE_T instance, - VCHIQ_SERVICE_HANDLE_T handle); + unsigned int handle); extern struct vchiq_service * find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, - VCHIQ_SERVICE_HANDLE_T handle); + unsigned int handle); extern struct vchiq_service * next_service_by_instance(struct vchiq_state *state, VCHIQ_INSTANCE_T instance, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index d9b23af25671..dc3d204e7698 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -61,11 +61,9 @@ struct vchiq_element { unsigned int size; }; -typedef unsigned int VCHIQ_SERVICE_HANDLE_T; - typedef enum vchiq_status (*vchiq_callback)(enum vchiq_reason, struct vchiq_header *, - VCHIQ_SERVICE_HANDLE_T, void *); + unsigned int, void *); struct vchiq_service_base { int fourcc; @@ -100,49 +98,49 @@ extern enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance); extern enum vchiq_status vchiq_connect(VCHIQ_INSTANCE_T instance); extern enum vchiq_status vchiq_add_service(VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, - VCHIQ_SERVICE_HANDLE_T *pservice); + unsigned int *pservice); extern enum vchiq_status vchiq_open_service(VCHIQ_INSTANCE_T instance, const struct vchiq_service_params *params, - VCHIQ_SERVICE_HANDLE_T *pservice); -extern enum vchiq_status vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); -extern enum vchiq_status vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); -extern enum vchiq_status vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service); -extern enum vchiq_status vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service); + unsigned int *pservice); +extern enum vchiq_status vchiq_close_service(unsigned int service); +extern enum vchiq_status vchiq_remove_service(unsigned int service); +extern enum vchiq_status vchiq_use_service(unsigned int service); +extern enum vchiq_status vchiq_release_service(unsigned int service); extern enum vchiq_status -vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, +vchiq_queue_message(unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), void *context, size_t size); -extern void vchiq_release_message(VCHIQ_SERVICE_HANDLE_T service, +extern void vchiq_release_message(unsigned int service, struct vchiq_header *header); -extern enum vchiq_status vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_receive(unsigned int service, void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_transmit_handle(unsigned int service, const void *offset, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_bulk_receive_handle(unsigned int service, void *offset, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); -extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); -extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); -extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); +extern int vchiq_get_client_id(unsigned int service); +extern void *vchiq_get_service_userdata(unsigned int service); +extern int vchiq_get_service_fourcc(unsigned int service); extern void vchiq_get_config(struct vchiq_config *config); -extern enum vchiq_status vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_set_service_option(unsigned int service, enum vchiq_service_option option, int value); extern enum vchiq_status vchiq_remote_use(VCHIQ_INSTANCE_T instance, vchiq_remote_callback callback, void *cb_arg); extern enum vchiq_status vchiq_remote_release(VCHIQ_INSTANCE_T instance); -extern enum vchiq_status vchiq_dump_phys_mem(VCHIQ_SERVICE_HANDLE_T service, +extern enum vchiq_status vchiq_dump_phys_mem(unsigned int service, void *ptr, size_t num_bytes); -extern enum vchiq_status vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, +extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, short *peer_version); #endif /* VCHIQ_IF_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index ce11b9adbfa3..3f052cae5bb7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -12,7 +12,7 @@ #define vchiq_status_to_vchi(status) ((int32_t)status) struct shim_service { - VCHIQ_SERVICE_HANDLE_T handle; + unsigned int handle; struct vchiu_queue queue; @@ -360,13 +360,13 @@ int32_t vchi_held_msg_release(struct vchi_held_msg *message) { /* * Convert the service field pointer back to an - * VCHIQ_SERVICE_HANDLE_T which is an int. + * unsigned int which is an int. * This pointer is opaque to everything except * vchi_msg_hold which simply upcasted the int * to a pointer. */ - vchiq_release_message((VCHIQ_SERVICE_HANDLE_T)(long)message->service, + vchiq_release_message((unsigned int)(long)message->service, (struct vchiq_header *)message->message); return 0; @@ -410,7 +410,7 @@ int32_t vchi_msg_hold(struct vchi_service_handle *handle, void **data, *msg_size = header->size; /* - * upcast the VCHIQ_SERVICE_HANDLE_T which is an int + * upcast the unsigned int which is an int * to a pointer and stuff it in the held message. * This pointer is opaque to everything except * vchi_held_msg_release which simply downcasts it back @@ -505,7 +505,7 @@ EXPORT_SYMBOL(vchi_disconnect); static enum vchiq_status shim_callback(enum vchiq_reason reason, struct vchiq_header *header, - VCHIQ_SERVICE_HANDLE_T handle, + unsigned int handle, void *bulk_user) { struct shim_service *service = -- cgit v1.2.3-59-g8ed1b From 4ddf9a2555caf210f60fdcec35d8081aa4135ea0 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:30 -0800 Subject: staging: vc04_services: Replace VCHIQ_INSTANCE_T typedef with struct vchiq_instance Replaces VCHIQ_INSTANCE_T typedef with struct vchiq_instance to match kernel code style. Issue found by checkpatch. Additionally, as part of the process renames "struct vchiq_instance_struct" to "struct vchiq_instance". Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/ed2b3076f93a920149716687b48e0c5e3ddf0569.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 46 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 10 ++--- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 12 +++--- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 16 ++++---- .../interface/vchiq_arm/vchiq_debugfs.c | 14 +++---- .../interface/vchiq_arm/vchiq_debugfs.h | 4 +- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 16 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 10 ++--- 8 files changed, 64 insertions(+), 64 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index add552226eaa..be8b2a71da2d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -84,7 +84,7 @@ static void suspend_timer_callback(struct timer_list *t); struct user_service { struct vchiq_service *service; void *userdata; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; char is_vchi; char dequeue_pending; char close_pending; @@ -103,7 +103,7 @@ struct bulk_waiter_node { struct list_head list; }; -struct vchiq_instance_struct { +struct vchiq_instance { struct vchiq_state *state; struct vchiq_completion_data completions[MAX_COMPLETIONS]; int completion_insert; @@ -177,11 +177,11 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir); #define VCHIQ_INIT_RETRIES 10 -enum vchiq_status vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) +enum vchiq_status vchiq_initialise(struct vchiq_instance **instance_out) { enum vchiq_status status = VCHIQ_ERROR; struct vchiq_state *state; - VCHIQ_INSTANCE_T instance = NULL; + struct vchiq_instance *instance = NULL; int i; vchiq_log_trace(vchiq_core_log_level, "%s called", __func__); @@ -230,7 +230,7 @@ failed: } EXPORT_SYMBOL(vchiq_initialise); -enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance) +enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance) { enum vchiq_status status; struct vchiq_state *state = instance->state; @@ -267,12 +267,12 @@ enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance) } EXPORT_SYMBOL(vchiq_shutdown); -static int vchiq_is_connected(VCHIQ_INSTANCE_T instance) +static int vchiq_is_connected(struct vchiq_instance *instance) { return instance->connected; } -enum vchiq_status vchiq_connect(VCHIQ_INSTANCE_T instance) +enum vchiq_status vchiq_connect(struct vchiq_instance *instance) { enum vchiq_status status; struct vchiq_state *state = instance->state; @@ -302,7 +302,7 @@ failed: EXPORT_SYMBOL(vchiq_connect); enum vchiq_status vchiq_add_service( - VCHIQ_INSTANCE_T instance, + struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *phandle) { @@ -341,7 +341,7 @@ enum vchiq_status vchiq_add_service( EXPORT_SYMBOL(vchiq_add_service); enum vchiq_status vchiq_open_service( - VCHIQ_INSTANCE_T instance, + struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *phandle) { @@ -433,7 +433,7 @@ static enum vchiq_status vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir) { - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; struct vchiq_service *service; enum vchiq_status status; struct bulk_waiter_node *waiter = NULL; @@ -516,7 +516,7 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, ***************************************************************************/ static enum vchiq_status -add_completion(VCHIQ_INSTANCE_T instance, enum vchiq_reason reason, +add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, void *bulk_userdata) { @@ -593,7 +593,7 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, */ struct user_service *user_service; struct vchiq_service *service; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; bool skip_completion = false; DEBUG_INITIALISE(g_state.local) @@ -804,7 +804,7 @@ vchiq_ioc_queue_message(unsigned int handle, static long vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_INSTANCE_T instance = file->private_data; + struct vchiq_instance *instance = file->private_data; enum vchiq_status status = VCHIQ_SUCCESS; struct vchiq_service *service = NULL; long ret = 0; @@ -1919,7 +1919,7 @@ vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static int vchiq_open(struct inode *inode, struct file *file) { struct vchiq_state *state = vchiq_get_state(); - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); @@ -1951,7 +1951,7 @@ static int vchiq_open(struct inode *inode, struct file *file) static int vchiq_release(struct inode *inode, struct file *file) { - VCHIQ_INSTANCE_T instance = file->private_data; + struct vchiq_instance *instance = file->private_data; struct vchiq_state *state = vchiq_get_state(); struct vchiq_service *service; int ret = 0; @@ -2130,7 +2130,7 @@ vchiq_dump_platform_instances(void *dump_context) for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service = state->services[i]; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; if (service && (service->base.callback == service_callback)) { instance = service->instance; @@ -2141,7 +2141,7 @@ vchiq_dump_platform_instances(void *dump_context) for (i = 0; i < state->unused_service; i++) { struct vchiq_service *service = state->services[i]; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; if (service && (service->base.callback == service_callback)) { instance = service->instance; @@ -2288,7 +2288,7 @@ vchiq_keepalive_thread_func(void *v) struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); enum vchiq_status status; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; unsigned int ka_handle; struct vchiq_service_params params = { @@ -2911,13 +2911,13 @@ vchiq_release_service_internal(struct vchiq_service *service) } struct vchiq_debugfs_node * -vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_debugfs_node(struct vchiq_instance *instance) { return &instance->debugfs_node; } int -vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_use_count(struct vchiq_instance *instance) { struct vchiq_service *service; int use_count = 0, i; @@ -2932,19 +2932,19 @@ vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance) } int -vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_pid(struct vchiq_instance *instance) { return instance->pid; } int -vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance) +vchiq_instance_get_trace(struct vchiq_instance *instance) { return instance->trace; } void -vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace) +vchiq_instance_set_trace(struct vchiq_instance *instance, int trace) { struct vchiq_service *service; int i; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 229dd262ec7d..19d2a2eefb6a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -162,19 +162,19 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service); extern struct vchiq_debugfs_node * -vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance); +vchiq_instance_get_debugfs_node(struct vchiq_instance *instance); extern int -vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance); +vchiq_instance_get_use_count(struct vchiq_instance *instance); extern int -vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance); +vchiq_instance_get_pid(struct vchiq_instance *instance); extern int -vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance); +vchiq_instance_get_trace(struct vchiq_instance *instance); extern void -vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace); +vchiq_instance_set_trace(struct vchiq_instance *instance, int trace); extern void set_suspend_state(struct vchiq_arm_state *arm_state, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 7cdb5d50fb4e..b9d94f6b9bef 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -177,7 +177,7 @@ find_service_by_port(struct vchiq_state *state, int localport) } struct vchiq_service * -find_service_for_instance(VCHIQ_INSTANCE_T instance, +find_service_for_instance(struct vchiq_instance *instance, unsigned int handle) { struct vchiq_service *service; @@ -201,7 +201,7 @@ find_service_for_instance(VCHIQ_INSTANCE_T instance, } struct vchiq_service * -find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, +find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int handle) { struct vchiq_service *service; @@ -227,7 +227,7 @@ find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, } struct vchiq_service * -next_service_by_instance(struct vchiq_state *state, VCHIQ_INSTANCE_T instance, +next_service_by_instance(struct vchiq_state *state, struct vchiq_instance *instance, int *pidx) { struct vchiq_service *service = NULL; @@ -2280,7 +2280,7 @@ fail_free_handler_thread: struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, const struct vchiq_service_params *params, - int srvstate, VCHIQ_INSTANCE_T instance, + int srvstate, struct vchiq_instance *instance, vchiq_userdata_term userdata_term) { struct vchiq_service *service; @@ -2775,7 +2775,7 @@ vchiq_free_service_internal(struct vchiq_service *service) } enum vchiq_status -vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) +vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instance) { struct vchiq_service *service; int i; @@ -2811,7 +2811,7 @@ vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) } enum vchiq_status -vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) +vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instance) { struct vchiq_service *service; int i; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 0339503d57d7..05b39c3564f6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -268,7 +268,7 @@ struct vchiq_service { short peer_version; struct vchiq_state *state; - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; int service_use_count; @@ -382,7 +382,7 @@ struct vchiq_state { /* Mutex protecting services */ struct mutex mutex; - VCHIQ_INSTANCE_T *instance; + struct vchiq_instance **instance; /* Processes incoming messages */ struct task_struct *slot_handler_thread; @@ -495,12 +495,12 @@ extern enum vchiq_status vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero); extern enum vchiq_status -vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); +vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instance); extern struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, const struct vchiq_service_params *params, - int srvstate, VCHIQ_INSTANCE_T instance, + int srvstate, struct vchiq_instance *instance, vchiq_userdata_term userdata_term); extern enum vchiq_status @@ -516,7 +516,7 @@ extern void vchiq_free_service_internal(struct vchiq_service *service); extern enum vchiq_status -vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); +vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instance); extern void remote_event_pollall(struct vchiq_state *state); @@ -560,15 +560,15 @@ extern struct vchiq_service * find_service_by_port(struct vchiq_state *state, int localport); extern struct vchiq_service * -find_service_for_instance(VCHIQ_INSTANCE_T instance, +find_service_for_instance(struct vchiq_instance *instance, unsigned int handle); extern struct vchiq_service * -find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, +find_closed_service_for_instance(struct vchiq_instance *instance, unsigned int handle); extern struct vchiq_service * -next_service_by_instance(struct vchiq_state *state, VCHIQ_INSTANCE_T instance, +next_service_by_instance(struct vchiq_state *state, struct vchiq_instance *instance, int *pidx); extern void diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index f217b78d95a0..89cc52211de4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -117,7 +117,7 @@ static const struct file_operations debugfs_log_fops = { static int debugfs_usecount_show(struct seq_file *f, void *offset) { - VCHIQ_INSTANCE_T instance = f->private; + struct vchiq_instance *instance = f->private; int use_count; use_count = vchiq_instance_get_use_count(instance); @@ -129,7 +129,7 @@ DEFINE_SHOW_ATTRIBUTE(debugfs_usecount); static int debugfs_trace_show(struct seq_file *f, void *offset) { - VCHIQ_INSTANCE_T instance = f->private; + struct vchiq_instance *instance = f->private; int trace; trace = vchiq_instance_get_trace(instance); @@ -148,7 +148,7 @@ static ssize_t debugfs_trace_write(struct file *file, size_t count, loff_t *ppos) { struct seq_file *f = (struct seq_file *)file->private_data; - VCHIQ_INSTANCE_T instance = f->private; + struct vchiq_instance *instance = f->private; char firstchar; if (copy_from_user(&firstchar, buffer, 1)) @@ -184,7 +184,7 @@ static const struct file_operations debugfs_trace_fops = { }; /* add an instance (process) to the debugfs entries */ -void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance) +void vchiq_debugfs_add_instance(struct vchiq_instance *instance) { char pidstr[16]; struct dentry *top; @@ -201,7 +201,7 @@ void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance) vchiq_instance_get_debugfs_node(instance)->dentry = top; } -void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) +void vchiq_debugfs_remove_instance(struct vchiq_instance *instance) { struct vchiq_debugfs_node *node = vchiq_instance_get_debugfs_node(instance); @@ -242,11 +242,11 @@ void vchiq_debugfs_deinit(void) { } -void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance) +void vchiq_debugfs_add_instance(struct vchiq_instance *instance) { } -void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) +void vchiq_debugfs_remove_instance(struct vchiq_instance *instance) { } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h index 9b563d105fdb..ec2f033cdf32 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h @@ -14,8 +14,8 @@ void vchiq_debugfs_init(void); void vchiq_debugfs_deinit(void); -void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance); +void vchiq_debugfs_add_instance(struct vchiq_instance *instance); -void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance); +void vchiq_debugfs_remove_instance(struct vchiq_instance *instance); #endif /* VCHIQ_DEBUGFS_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index dc3d204e7698..07c6a3db5ab6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -90,16 +90,16 @@ struct vchiq_config { short version_min; /* The minimum compatible version of VCHIQ */ }; -typedef struct vchiq_instance_struct *VCHIQ_INSTANCE_T; +struct vchiq_instance; typedef void (*vchiq_remote_callback)(void *cb_arg); -extern enum vchiq_status vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); -extern enum vchiq_status vchiq_shutdown(VCHIQ_INSTANCE_T instance); -extern enum vchiq_status vchiq_connect(VCHIQ_INSTANCE_T instance); -extern enum vchiq_status vchiq_add_service(VCHIQ_INSTANCE_T instance, +extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); +extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); +extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); +extern enum vchiq_status vchiq_add_service(struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *pservice); -extern enum vchiq_status vchiq_open_service(VCHIQ_INSTANCE_T instance, +extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *pservice); extern enum vchiq_status vchiq_close_service(unsigned int service); @@ -133,9 +133,9 @@ extern void vchiq_get_config(struct vchiq_config *config); extern enum vchiq_status vchiq_set_service_option(unsigned int service, enum vchiq_service_option option, int value); -extern enum vchiq_status vchiq_remote_use(VCHIQ_INSTANCE_T instance, +extern enum vchiq_status vchiq_remote_use(struct vchiq_instance *instance, vchiq_remote_callback callback, void *cb_arg); -extern enum vchiq_status vchiq_remote_release(VCHIQ_INSTANCE_T instance); +extern enum vchiq_status vchiq_remote_release(struct vchiq_instance *instance); extern enum vchiq_status vchiq_dump_phys_mem(unsigned int service, void *ptr, size_t num_bytes); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 3f052cae5bb7..3055e94a53da 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -440,7 +440,7 @@ EXPORT_SYMBOL(vchi_msg_hold); int32_t vchi_initialise(struct vchi_instance_handle **instance_handle) { - VCHIQ_INSTANCE_T instance; + struct vchiq_instance *instance; enum vchiq_status status; status = vchiq_initialise(&instance); @@ -464,7 +464,7 @@ EXPORT_SYMBOL(vchi_initialise); ***********************************************************/ int32_t vchi_connect(struct vchi_instance_handle *instance_handle) { - VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; + struct vchiq_instance *instance = (struct vchiq_instance *)instance_handle; return vchiq_connect(instance); } @@ -483,7 +483,7 @@ EXPORT_SYMBOL(vchi_connect); ***********************************************************/ int32_t vchi_disconnect(struct vchi_instance_handle *instance_handle) { - VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; + struct vchiq_instance *instance = (struct vchiq_instance *)instance_handle; return vchiq_status_to_vchi(vchiq_shutdown(instance)); } @@ -565,7 +565,7 @@ done: return VCHIQ_SUCCESS; } -static struct shim_service *service_alloc(VCHIQ_INSTANCE_T instance, +static struct shim_service *service_alloc(struct vchiq_instance *instance, struct service_creation *setup) { struct shim_service *service = kzalloc(sizeof(struct shim_service), GFP_KERNEL); @@ -597,7 +597,7 @@ int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, struct service_creation *setup, struct vchi_service_handle **handle) { - VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; + struct vchiq_instance *instance = (struct vchiq_instance *)instance_handle; struct shim_service *service = service_alloc(instance, setup); *handle = (struct vchi_service_handle *)service; -- cgit v1.2.3-59-g8ed1b From 885961fed45dca0de605a94aa6d12d694acfb787 Mon Sep 17 00:00:00 2001 From: Jamal Shareef Date: Tue, 5 Nov 2019 14:55:31 -0800 Subject: staging: vc04_services: Replace VCHIQ_PLATFORM_STATE_T typedef with struct opaque_platform_state Replace VCHIQ_PLATFORM_STATE_T typedef with struct opaque_platform_state to match kernel code style. Issue found by checkpatch. Signed-off-by: Jamal Shareef Link: https://lore.kernel.org/r/ed1a877637a53881ed65dc232da04dc40fbd9fc3.1572994235.git.jamal.k.shareef@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 05b39c3564f6..419bcdd165b4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -236,7 +236,7 @@ struct remote_event { u32 __unused; }; -typedef struct opaque_platform_state_t *VCHIQ_PLATFORM_STATE_T; +struct opaque_platform_state; struct vchiq_slot { char data[VCHIQ_SLOT_SIZE]; @@ -468,7 +468,7 @@ struct vchiq_state { struct vchiq_service_quota service_quotas[VCHIQ_MAX_SERVICES]; struct vchiq_slot_info slot_info[VCHIQ_MAX_SLOTS]; - VCHIQ_PLATFORM_STATE_T platform_state; + struct opaque_platform_state *platform_state; }; struct bulk_waiter { -- cgit v1.2.3-59-g8ed1b From 4df0991b0c92c74c5e81bf55fd156ce92d812d01 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Thu, 7 Nov 2019 15:49:28 +0100 Subject: staging: most: remove string termination dependency from user space data This patch removes the constraint that user space data has to be terminated with a new line character. It is needed to let the user choose how the data is formatted. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1573138169-27562-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/configfs.c | 4 ++++ drivers/staging/most/core.c | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c index 64c65c217d07..c06cf849c04d 100644 --- a/drivers/staging/most/configfs.c +++ b/drivers/staging/most/configfs.c @@ -164,6 +164,7 @@ static ssize_t mdev_link_direction_store(struct config_item *item, !sysfs_streq(page, "dir_tx") && !sysfs_streq(page, "tx")) return -EINVAL; strcpy(mdev_link->direction, page); + strim(mdev_link->direction); return count; } @@ -182,6 +183,7 @@ static ssize_t mdev_link_datatype_store(struct config_item *item, !sysfs_streq(page, "isoc_avp")) return -EINVAL; strcpy(mdev_link->datatype, page); + strim(mdev_link->datatype); return count; } @@ -196,6 +198,7 @@ static ssize_t mdev_link_device_store(struct config_item *item, struct mdev_link *mdev_link = to_mdev_link(item); strcpy(mdev_link->device, page); + strim(mdev_link->device); return count; } @@ -210,6 +213,7 @@ static ssize_t mdev_link_channel_store(struct config_item *item, struct mdev_link *mdev_link = to_mdev_link(item); strcpy(mdev_link->channel, page); + strim(mdev_link->channel); return count; } diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c index 8e9a0b67c6ed..f7d2c7850cf5 100644 --- a/drivers/staging/most/core.c +++ b/drivers/staging/most/core.c @@ -84,11 +84,11 @@ static const struct { int most_ch_data_type; const char *name; } ch_data_type[] = { - { MOST_CH_CONTROL, "control\n" }, - { MOST_CH_ASYNC, "async\n" }, - { MOST_CH_SYNC, "sync\n" }, - { MOST_CH_ISOC, "isoc\n"}, - { MOST_CH_ISOC, "isoc_avp\n"}, + { MOST_CH_CONTROL, "control" }, + { MOST_CH_ASYNC, "async" }, + { MOST_CH_SYNC, "sync" }, + { MOST_CH_ISOC, "isoc"}, + { MOST_CH_ISOC, "isoc_avp"}, }; /** @@ -675,13 +675,13 @@ int most_set_cfg_direction(char *mdev, char *mdev_ch, char *buf) if (!c) return -ENODEV; - if (!strcmp(buf, "dir_rx\n")) { + if (!strcmp(buf, "dir_rx")) { c->cfg.direction = MOST_CH_RX; - } else if (!strcmp(buf, "rx\n")) { + } else if (!strcmp(buf, "rx")) { c->cfg.direction = MOST_CH_RX; - } else if (!strcmp(buf, "dir_tx\n")) { + } else if (!strcmp(buf, "dir_tx")) { c->cfg.direction = MOST_CH_TX; - } else if (!strcmp(buf, "tx\n")) { + } else if (!strcmp(buf, "tx")) { c->cfg.direction = MOST_CH_TX; } else { pr_info("Invalid direction\n"); -- cgit v1.2.3-59-g8ed1b From b79967a27f347d39a6e0b85b49bd11963cacf5c1 Mon Sep 17 00:00:00 2001 From: Marcelo Diop-Gonzalez Date: Tue, 5 Nov 2019 17:27:56 -0500 Subject: staging: vchiq: Have vchiu_queue_init() return 0 on success. It could be confusing to return 1 on success and 0 on error given the style elswhere. Signed-off-by: Marcelo Diop-Gonzalez Link: https://lore.kernel.org/r/20191105222756.25369-1-marcgonzalez@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 3055e94a53da..0ce3b08b3441 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -573,7 +573,7 @@ static struct shim_service *service_alloc(struct vchiq_instance *instance, (void)instance; if (service) { - if (vchiu_queue_init(&service->queue, 64)) { + if (!vchiu_queue_init(&service->queue, 64)) { service->callback = setup->callback; service->callback_param = setup->callback_param; } else { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 5e6d3035dc05..644844d88fed 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -24,9 +24,9 @@ int vchiu_queue_init(struct vchiu_queue *queue, int size) GFP_KERNEL); if (!queue->storage) { vchiu_queue_delete(queue); - return 0; + return -ENOMEM; } - return 1; + return 0; } void vchiu_queue_delete(struct vchiu_queue *queue) -- cgit v1.2.3-59-g8ed1b From 5cd382b2693358be99b9ae1c524854f5715b5dc2 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Mon, 11 Nov 2019 13:30:53 +0000 Subject: staging: wfx: replace uintXX_t to uXX and intXX_t to sXX Replace uint8_t to u8, uint16_t to u16, uint32_t to u32 int8_t to s8,int16_t to s16 and int32_t to s32 As per recommendation of checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191111133055.214410-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 2 +- drivers/staging/wfx/data_tx.c | 10 +- drivers/staging/wfx/data_tx.h | 18 +- drivers/staging/wfx/hif_api_cmd.h | 498 +++++++++++++++++----------------- drivers/staging/wfx/hif_api_general.h | 212 +++++++-------- drivers/staging/wfx/hif_api_mib.h | 477 ++++++++++++++++---------------- drivers/staging/wfx/hif_tx.c | 3 +- drivers/staging/wfx/hif_tx.h | 7 +- drivers/staging/wfx/hif_tx_mib.h | 2 +- drivers/staging/wfx/key.c | 32 ++- drivers/staging/wfx/secure_link.h | 6 +- drivers/staging/wfx/sta.c | 13 +- drivers/staging/wfx/sta.h | 2 +- drivers/staging/wfx/wfx.h | 10 +- 14 files changed, 649 insertions(+), 643 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 955ed3a1dd73..2432ba95c2f5 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -239,7 +239,7 @@ static int bh_work_tx(struct wfx_dev *wdev, int max_msg) */ static void ack_sdio_data(struct wfx_dev *wdev) { - uint32_t cfg_reg; + u32 cfg_reg; config_reg_read(wdev, &cfg_reg); if (cfg_reg & 0xFF) { diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index ea4205ac2149..b722e9773232 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -107,7 +107,7 @@ static void wfx_tx_policy_build(struct wfx_vif *wvif, struct tx_policy *policy, for (i = 0; i < IEEE80211_TX_MAX_RATES; ++i) { int rateid; - uint8_t count; + u8 count; if (rates[i].idx < 0) break; @@ -477,7 +477,7 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, ieee80211_sta_set_buffered(sta, tx_priv->tid, true); } -static uint8_t wfx_tx_get_raw_link_id(struct wfx_vif *wvif, +static u8 wfx_tx_get_raw_link_id(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct ieee80211_hdr *hdr) { @@ -542,11 +542,11 @@ static void wfx_tx_fixup_rates(struct ieee80211_tx_rate *rates) rates[i].flags &= ~IEEE80211_TX_RC_SHORT_GI; } -static uint8_t wfx_tx_get_rate_id(struct wfx_vif *wvif, +static u8 wfx_tx_get_rate_id(struct wfx_vif *wvif, struct ieee80211_tx_info *tx_info) { bool tx_policy_renew = false; - uint8_t rate_id; + u8 rate_id; rate_id = wfx_tx_policy_get(wvif, tx_info->driver_rates, &tx_policy_renew); @@ -584,7 +584,7 @@ static struct hif_ht_tx_parameters wfx_tx_get_tx_parms(struct wfx_dev *wdev, str return ret; } -static uint8_t wfx_tx_get_tid(struct ieee80211_hdr *hdr) +static u8 wfx_tx_get_tid(struct ieee80211_hdr *hdr) { // FIXME: ieee80211_get_tid(hdr) should be sufficient for all cases. if (!ieee80211_is_data(hdr->frame_control)) diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index f74d1988925d..29faa5640516 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -31,17 +31,17 @@ enum wfx_link_status { struct wfx_link_entry { unsigned long timestamp; enum wfx_link_status status; - uint8_t mac[ETH_ALEN]; - uint8_t old_mac[ETH_ALEN]; - uint8_t buffered[WFX_MAX_TID]; + u8 mac[ETH_ALEN]; + u8 old_mac[ETH_ALEN]; + u8 buffered[WFX_MAX_TID]; struct sk_buff_head rx_queue; }; struct tx_policy { struct list_head link; - uint8_t rates[12]; - uint8_t usage_count; - uint8_t uploaded; + u8 rates[12]; + u8 usage_count; + u8 uploaded; }; struct tx_policy_cache { @@ -55,9 +55,9 @@ struct tx_policy_cache { struct wfx_tx_priv { ktime_t xmit_timestamp; struct ieee80211_key_conf *hw_key; - uint8_t link_id; - uint8_t raw_link_id; - uint8_t tid; + u8 link_id; + u8 raw_link_id; + u8 tid; } __packed; void wfx_tx_policy_init(struct wfx_vif *wvif); diff --git a/drivers/staging/wfx/hif_api_cmd.h b/drivers/staging/wfx/hif_api_cmd.h index 7c5d1ea6098d..c15831de4ff4 100644 --- a/drivers/staging/wfx/hif_api_cmd.h +++ b/drivers/staging/wfx/hif_api_cmd.h @@ -85,10 +85,10 @@ enum hif_status { }; struct hif_reset_flags { - uint8_t reset_stat:1; - uint8_t reset_all_int:1; - uint8_t reserved1:6; - uint8_t reserved2[3]; + u8 reset_stat:1; + u8 reset_all_int:1; + u8 reserved1:6; + u8 reserved2[3]; } __packed; struct hif_req_reset { @@ -96,121 +96,121 @@ struct hif_req_reset { } __packed; struct hif_cnf_reset { - uint32_t status; + u32 status; } __packed; struct hif_req_read_mib { - uint16_t mib_id; - uint16_t reserved; + u16 mib_id; + u16 reserved; } __packed; struct hif_cnf_read_mib { - uint32_t status; - uint16_t mib_id; - uint16_t length; - uint8_t mib_data[]; + u32 status; + u16 mib_id; + u16 length; + u8 mib_data[]; } __packed; struct hif_req_write_mib { - uint16_t mib_id; - uint16_t length; - uint8_t mib_data[]; + u16 mib_id; + u16 length; + u8 mib_data[]; } __packed; struct hif_cnf_write_mib { - uint32_t status; + u32 status; } __packed; struct hif_ie_flags { - uint8_t beacon:1; - uint8_t probe_resp:1; - uint8_t probe_req:1; - uint8_t reserved1:5; - uint8_t reserved2; + u8 beacon:1; + u8 probe_resp:1; + u8 probe_req:1; + u8 reserved1:5; + u8 reserved2; } __packed; struct hif_ie_tlv { - uint8_t type; - uint8_t length; - uint8_t data[]; + u8 type; + u8 length; + u8 data[]; } __packed; struct hif_req_update_ie { struct hif_ie_flags ie_flags; - uint16_t num_i_es; + u16 num_i_es; struct hif_ie_tlv ie[]; } __packed; struct hif_cnf_update_ie { - uint32_t status; + u32 status; } __packed; struct hif_scan_type { - uint8_t type:1; - uint8_t mode:1; - uint8_t reserved:6; + u8 type:1; + u8 mode:1; + u8 reserved:6; } __packed; struct hif_scan_flags { - uint8_t fbg:1; - uint8_t reserved1:1; - uint8_t pre:1; - uint8_t reserved2:5; + u8 fbg:1; + u8 reserved1:1; + u8 pre:1; + u8 reserved2:5; } __packed; struct hif_auto_scan_param { - uint16_t interval; - uint8_t reserved; - int8_t rssi_thr; + u16 interval; + u8 reserved; + s8 rssi_thr; } __packed; struct hif_ssid_def { - uint32_t ssid_length; - uint8_t ssid[HIF_API_SSID_SIZE]; + u32 ssid_length; + u8 ssid[HIF_API_SSID_SIZE]; } __packed; #define HIF_API_MAX_NB_SSIDS 2 #define HIF_API_MAX_NB_CHANNELS 14 struct hif_req_start_scan { - uint8_t band; + u8 band; struct hif_scan_type scan_type; struct hif_scan_flags scan_flags; - uint8_t max_transmit_rate; + u8 max_transmit_rate; struct hif_auto_scan_param auto_scan_param; - uint8_t num_of_probe_requests; - uint8_t probe_delay; - uint8_t num_of_ssi_ds; - uint8_t num_of_channels; - uint32_t min_channel_time; - uint32_t max_channel_time; - int32_t tx_power_level; - uint8_t ssid_and_channel_lists[]; + u8 num_of_probe_requests; + u8 probe_delay; + u8 num_of_ssi_ds; + u8 num_of_channels; + u32 min_channel_time; + u32 max_channel_time; + s32 tx_power_level; + u8 ssid_and_channel_lists[]; } __packed; struct hif_start_scan_req_cstnbssid_body { - uint8_t band; + u8 band; struct hif_scan_type scan_type; struct hif_scan_flags scan_flags; - uint8_t max_transmit_rate; + u8 max_transmit_rate; struct hif_auto_scan_param auto_scan_param; - uint8_t num_of_probe_requests; - uint8_t probe_delay; - uint8_t num_of_ssi_ds; - uint8_t num_of_channels; - uint32_t min_channel_time; - uint32_t max_channel_time; - int32_t tx_power_level; + u8 num_of_probe_requests; + u8 probe_delay; + u8 num_of_ssi_ds; + u8 num_of_channels; + u32 min_channel_time; + u32 max_channel_time; + s32 tx_power_level; struct hif_ssid_def ssid_def[HIF_API_MAX_NB_SSIDS]; - uint8_t channel_list[]; + u8 channel_list[]; } __packed; struct hif_cnf_start_scan { - uint32_t status; + u32 status; } __packed; struct hif_cnf_stop_scan { - uint32_t status; + u32 status; } __packed; enum hif_pm_mode_status { @@ -220,10 +220,10 @@ enum hif_pm_mode_status { }; struct hif_ind_scan_cmpl { - uint32_t status; - uint8_t pm_mode; - uint8_t num_channels_completed; - uint16_t reserved; + u32 status; + u8 pm_mode; + u8 num_channels_completed; + u16 reserved; } __packed; enum hif_queue_id { @@ -245,45 +245,45 @@ enum hif_stbc { }; struct hif_queue { - uint8_t queue_id:2; - uint8_t peer_sta_id:4; - uint8_t reserved:2; + u8 queue_id:2; + u8 peer_sta_id:4; + u8 reserved:2; } __packed; struct hif_data_flags { - uint8_t more:1; - uint8_t fc_offset:3; - uint8_t reserved:4; + u8 more:1; + u8 fc_offset:3; + u8 reserved:4; } __packed; struct hif_tx_flags { - uint8_t start_exp:1; - uint8_t reserved:3; - uint8_t retry_policy_index:4; + u8 start_exp:1; + u8 reserved:3; + u8 retry_policy_index:4; } __packed; struct hif_ht_tx_parameters { - uint8_t frame_format:4; - uint8_t fec_coding:1; - uint8_t short_gi:1; - uint8_t reserved1:1; - uint8_t stbc:1; - uint8_t reserved2; - uint8_t aggregation:1; - uint8_t reserved3:7; - uint8_t reserved4; + u8 frame_format:4; + u8 fec_coding:1; + u8 short_gi:1; + u8 reserved1:1; + u8 stbc:1; + u8 reserved2; + u8 aggregation:1; + u8 reserved3:7; + u8 reserved4; } __packed; struct hif_req_tx { - uint32_t packet_id; - uint8_t max_tx_rate; + u32 packet_id; + u8 max_tx_rate; struct hif_queue queue_id; struct hif_data_flags data_flags; struct hif_tx_flags tx_flags; - uint32_t reserved; - uint32_t expire_time; + u32 reserved; + u32 expire_time; struct hif_ht_tx_parameters ht_tx_parameters; - uint8_t frame[]; + u8 frame[]; } __packed; enum hif_qos_ackplcy { @@ -294,26 +294,26 @@ enum hif_qos_ackplcy { }; struct hif_tx_result_flags { - uint8_t aggr:1; - uint8_t requeue:1; - uint8_t ack_policy:2; - uint8_t txop_limit:1; - uint8_t reserved1:3; - uint8_t reserved2; + u8 aggr:1; + u8 requeue:1; + u8 ack_policy:2; + u8 txop_limit:1; + u8 reserved1:3; + u8 reserved2; } __packed; struct hif_cnf_tx { - uint32_t status; - uint32_t packet_id; - uint8_t txed_rate; - uint8_t ack_failures; + u32 status; + u32 packet_id; + u8 txed_rate; + u8 ack_failures; struct hif_tx_result_flags tx_result_flags; - uint32_t media_delay; - uint32_t tx_queue_delay; + u32 media_delay; + u32 tx_queue_delay; } __packed; struct hif_cnf_multi_transmit { - uint32_t num_tx_confs; + u32 num_tx_confs; struct hif_cnf_tx tx_conf_payload[]; } __packed; @@ -326,55 +326,55 @@ enum hif_ri_flags_encrypt { }; struct hif_rx_flags { - uint8_t encryp:3; - uint8_t in_aggr:1; - uint8_t first_aggr:1; - uint8_t last_aggr:1; - uint8_t defrag:1; - uint8_t beacon:1; - uint8_t tim:1; - uint8_t bitmap:1; - uint8_t match_ssid:1; - uint8_t match_bssid:1; - uint8_t more:1; - uint8_t reserved1:1; - uint8_t ht:1; - uint8_t stbc:1; - uint8_t match_uc_addr:1; - uint8_t match_mc_addr:1; - uint8_t match_bc_addr:1; - uint8_t key_type:1; - uint8_t key_index:4; - uint8_t reserved2:1; - uint8_t peer_sta_id:4; - uint8_t reserved3:2; - uint8_t reserved4:1; + u8 encryp:3; + u8 in_aggr:1; + u8 first_aggr:1; + u8 last_aggr:1; + u8 defrag:1; + u8 beacon:1; + u8 tim:1; + u8 bitmap:1; + u8 match_ssid:1; + u8 match_bssid:1; + u8 more:1; + u8 reserved1:1; + u8 ht:1; + u8 stbc:1; + u8 match_uc_addr:1; + u8 match_mc_addr:1; + u8 match_bc_addr:1; + u8 key_type:1; + u8 key_index:4; + u8 reserved2:1; + u8 peer_sta_id:4; + u8 reserved3:2; + u8 reserved4:1; } __packed; struct hif_ind_rx { - uint32_t status; - uint16_t channel_number; - uint8_t rxed_rate; - uint8_t rcpi_rssi; + u32 status; + u16 channel_number; + u8 rxed_rate; + u8 rcpi_rssi; struct hif_rx_flags rx_flags; - uint8_t frame[]; + u8 frame[]; } __packed; struct hif_req_edca_queue_params { - uint8_t queue_id; - uint8_t reserved1; - uint8_t aifsn; - uint8_t reserved2; - uint16_t cw_min; - uint16_t cw_max; - uint16_t tx_op_limit; - uint16_t allowed_medium_time; - uint32_t reserved3; + u8 queue_id; + u8 reserved1; + u8 aifsn; + u8 reserved2; + u16 cw_min; + u16 cw_max; + u16 tx_op_limit; + u16 allowed_medium_time; + u32 reserved3; } __packed; struct hif_cnf_edca_queue_params { - uint32_t status; + u32 status; } __packed; enum hif_ap_mode { @@ -389,92 +389,92 @@ enum hif_preamble { }; struct hif_join_flags { - uint8_t reserved1:2; - uint8_t force_no_beacon:1; - uint8_t force_with_ind:1; - uint8_t reserved2:4; + u8 reserved1:2; + u8 force_no_beacon:1; + u8 force_with_ind:1; + u8 reserved2:4; } __packed; struct hif_req_join { - uint8_t mode; - uint8_t band; - uint16_t channel_number; - uint8_t bssid[ETH_ALEN]; - uint16_t atim_window; - uint8_t preamble_type; - uint8_t probe_for_join; - uint8_t reserved; + u8 mode; + u8 band; + u16 channel_number; + u8 bssid[ETH_ALEN]; + u16 atim_window; + u8 preamble_type; + u8 probe_for_join; + u8 reserved; struct hif_join_flags join_flags; - uint32_t ssid_length; - uint8_t ssid[HIF_API_SSID_SIZE]; - uint32_t beacon_interval; - uint32_t basic_rate_set; + u32 ssid_length; + u8 ssid[HIF_API_SSID_SIZE]; + u32 beacon_interval; + u32 basic_rate_set; } __packed; struct hif_cnf_join { - uint32_t status; + u32 status; } __packed; struct hif_ind_join_complete { - uint32_t status; + u32 status; } __packed; struct hif_bss_flags { - uint8_t lost_count_only:1; - uint8_t reserved:7; + u8 lost_count_only:1; + u8 reserved:7; } __packed; struct hif_req_set_bss_params { struct hif_bss_flags bss_flags; - uint8_t beacon_lost_count; - uint16_t aid; - uint32_t operational_rate_set; + u8 beacon_lost_count; + u16 aid; + u32 operational_rate_set; } __packed; struct hif_cnf_set_bss_params { - uint32_t status; + u32 status; } __packed; struct hif_pm_mode { - uint8_t enter_psm:1; - uint8_t reserved:6; - uint8_t fast_psm:1; + u8 enter_psm:1; + u8 reserved:6; + u8 fast_psm:1; } __packed; struct hif_req_set_pm_mode { struct hif_pm_mode pm_mode; - uint8_t fast_psm_idle_period; - uint8_t ap_psm_change_period; - uint8_t min_auto_ps_poll_period; + u8 fast_psm_idle_period; + u8 ap_psm_change_period; + u8 min_auto_ps_poll_period; } __packed; struct hif_cnf_set_pm_mode { - uint32_t status; + u32 status; } __packed; struct hif_ind_set_pm_mode_cmpl { - uint32_t status; - uint8_t pm_mode; - uint8_t reserved[3]; + u32 status; + u8 pm_mode; + u8 reserved[3]; } __packed; struct hif_req_start { - uint8_t mode; - uint8_t band; - uint16_t channel_number; - uint32_t reserved1; - uint32_t beacon_interval; - uint8_t dtim_period; - uint8_t preamble_type; - uint8_t reserved2; - uint8_t ssid_length; - uint8_t ssid[HIF_API_SSID_SIZE]; - uint32_t basic_rate_set; + u8 mode; + u8 band; + u16 channel_number; + u32 reserved1; + u32 beacon_interval; + u8 dtim_period; + u8 preamble_type; + u8 reserved2; + u8 ssid_length; + u8 ssid[HIF_API_SSID_SIZE]; + u32 basic_rate_set; } __packed; struct hif_cnf_start { - uint32_t status; + u32 status; } __packed; enum hif_beacon { @@ -483,12 +483,12 @@ enum hif_beacon { }; struct hif_req_beacon_transmit { - uint8_t enable_beaconing; - uint8_t reserved[3]; + u8 enable_beaconing; + u8 reserved[3]; } __packed; struct hif_cnf_beacon_transmit { - uint32_t status; + u32 status; } __packed; enum hif_sta_map_direction { @@ -497,32 +497,32 @@ enum hif_sta_map_direction { }; struct hif_map_link_flags { - uint8_t map_direction:1; - uint8_t mfpc:1; - uint8_t reserved:6; + u8 map_direction:1; + u8 mfpc:1; + u8 reserved:6; } __packed; struct hif_req_map_link { - uint8_t mac_addr[ETH_ALEN]; + u8 mac_addr[ETH_ALEN]; struct hif_map_link_flags map_link_flags; - uint8_t peer_sta_id; + u8 peer_sta_id; } __packed; struct hif_cnf_map_link { - uint32_t status; + u32 status; } __packed; struct hif_suspend_resume_flags { - uint8_t resume:1; - uint8_t reserved1:2; - uint8_t bc_mc_only:1; - uint8_t reserved2:4; - uint8_t reserved3; + u8 resume:1; + u8 reserved1:2; + u8 bc_mc_only:1; + u8 reserved2:4; + u8 reserved3; } __packed; struct hif_ind_suspend_resume_tx { struct hif_suspend_resume_flags suspend_resume_flags; - uint16_t peer_sta_set; + u16 peer_sta_set; } __packed; @@ -552,68 +552,68 @@ enum hif_key_type { }; struct hif_wep_pairwise_key { - uint8_t peer_address[ETH_ALEN]; - uint8_t reserved; - uint8_t key_length; - uint8_t key_data[HIF_API_WEP_KEY_DATA_SIZE]; + u8 peer_address[ETH_ALEN]; + u8 reserved; + u8 key_length; + u8 key_data[HIF_API_WEP_KEY_DATA_SIZE]; } __packed; struct hif_wep_group_key { - uint8_t key_id; - uint8_t key_length; - uint8_t reserved[2]; - uint8_t key_data[HIF_API_WEP_KEY_DATA_SIZE]; + u8 key_id; + u8 key_length; + u8 reserved[2]; + u8 key_data[HIF_API_WEP_KEY_DATA_SIZE]; } __packed; struct hif_tkip_pairwise_key { - uint8_t peer_address[ETH_ALEN]; - uint8_t reserved[2]; - uint8_t tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE]; - uint8_t rx_mic_key[HIF_API_RX_MIC_KEY_SIZE]; - uint8_t tx_mic_key[HIF_API_TX_MIC_KEY_SIZE]; + u8 peer_address[ETH_ALEN]; + u8 reserved[2]; + u8 tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE]; + u8 rx_mic_key[HIF_API_RX_MIC_KEY_SIZE]; + u8 tx_mic_key[HIF_API_TX_MIC_KEY_SIZE]; } __packed; struct hif_tkip_group_key { - uint8_t tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE]; - uint8_t rx_mic_key[HIF_API_RX_MIC_KEY_SIZE]; - uint8_t key_id; - uint8_t reserved[3]; - uint8_t rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE]; + u8 tkip_key_data[HIF_API_TKIP_KEY_DATA_SIZE]; + u8 rx_mic_key[HIF_API_RX_MIC_KEY_SIZE]; + u8 key_id; + u8 reserved[3]; + u8 rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE]; } __packed; struct hif_aes_pairwise_key { - uint8_t peer_address[ETH_ALEN]; - uint8_t reserved[2]; - uint8_t aes_key_data[HIF_API_AES_KEY_DATA_SIZE]; + u8 peer_address[ETH_ALEN]; + u8 reserved[2]; + u8 aes_key_data[HIF_API_AES_KEY_DATA_SIZE]; } __packed; struct hif_aes_group_key { - uint8_t aes_key_data[HIF_API_AES_KEY_DATA_SIZE]; - uint8_t key_id; - uint8_t reserved[3]; - uint8_t rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE]; + u8 aes_key_data[HIF_API_AES_KEY_DATA_SIZE]; + u8 key_id; + u8 reserved[3]; + u8 rx_sequence_counter[HIF_API_RX_SEQUENCE_COUNTER_SIZE]; } __packed; struct hif_wapi_pairwise_key { - uint8_t peer_address[ETH_ALEN]; - uint8_t key_id; - uint8_t reserved; - uint8_t wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE]; - uint8_t mic_key_data[HIF_API_MIC_KEY_DATA_SIZE]; + u8 peer_address[ETH_ALEN]; + u8 key_id; + u8 reserved; + u8 wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE]; + u8 mic_key_data[HIF_API_MIC_KEY_DATA_SIZE]; } __packed; struct hif_wapi_group_key { - uint8_t wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE]; - uint8_t mic_key_data[HIF_API_MIC_KEY_DATA_SIZE]; - uint8_t key_id; - uint8_t reserved[3]; + u8 wapi_key_data[HIF_API_WAPI_KEY_DATA_SIZE]; + u8 mic_key_data[HIF_API_MIC_KEY_DATA_SIZE]; + u8 key_id; + u8 reserved[3]; } __packed; struct hif_igtk_group_key { - uint8_t igtk_key_data[HIF_API_IGTK_KEY_DATA_SIZE]; - uint8_t key_id; - uint8_t reserved[3]; - uint8_t ipn[HIF_API_IPN_SIZE]; + u8 igtk_key_data[HIF_API_IGTK_KEY_DATA_SIZE]; + u8 key_id; + u8 reserved[3]; + u8 ipn[HIF_API_IPN_SIZE]; } __packed; union hif_privacy_key_data { @@ -629,25 +629,25 @@ union hif_privacy_key_data { }; struct hif_req_add_key { - uint8_t type; - uint8_t entry_index; - uint8_t int_id:2; - uint8_t reserved1:6; - uint8_t reserved2; + u8 type; + u8 entry_index; + u8 int_id:2; + u8 reserved1:6; + u8 reserved2; union hif_privacy_key_data key; } __packed; struct hif_cnf_add_key { - uint32_t status; + u32 status; } __packed; struct hif_req_remove_key { - uint8_t entry_index; - uint8_t reserved[3]; + u8 entry_index; + u8 reserved[3]; } __packed; struct hif_cnf_remove_key { - uint32_t status; + u32 status; } __packed; enum hif_event_ind { @@ -667,13 +667,13 @@ enum hif_ps_mode_error { }; union hif_event_data { - uint8_t rcpi_rssi; - uint32_t ps_mode_error; - uint32_t peer_sta_set; + u8 rcpi_rssi; + u32 ps_mode_error; + u32 peer_sta_set; }; struct hif_ind_event { - uint32_t event_id; + u32 event_id; union hif_event_data event_data; } __packed; diff --git a/drivers/staging/wfx/hif_api_general.h b/drivers/staging/wfx/hif_api_general.h index d885b55d2882..a069c3a21b4d 100644 --- a/drivers/staging/wfx/hif_api_general.h +++ b/drivers/staging/wfx/hif_api_general.h @@ -23,13 +23,13 @@ #define HIF_COUNTER_MAX 7 struct hif_msg { - uint16_t len; - uint8_t id; - uint8_t reserved:1; - uint8_t interface:2; - uint8_t seqnum:3; - uint8_t encrypted:2; - uint8_t body[]; + u16 len; + u8 id; + u8 reserved:1; + u8 interface:2; + u8 seqnum:3; + u8 encrypted:2; + u8 body[]; } __packed; enum hif_general_requests_ids { @@ -117,22 +117,22 @@ enum hif_fw_type { }; struct hif_capabilities { - uint8_t link_mode:2; - uint8_t reserved1:6; - uint8_t reserved2; - uint8_t reserved3; - uint8_t reserved4; + u8 link_mode:2; + u8 reserved1:6; + u8 reserved2; + u8 reserved3; + u8 reserved4; } __packed; struct hif_otp_regul_sel_mode_info { - uint8_t region_sel_mode:4; - uint8_t reserved:4; + u8 region_sel_mode:4; + u8 reserved:4; } __packed; struct hif_otp_phy_info { - uint8_t phy1_region:3; - uint8_t phy0_region:3; - uint8_t otp_phy_ver:2; + u8 phy1_region:3; + u8 phy0_region:3; + u8 otp_phy_ver:2; } __packed; #define API_OPN_SIZE 14 @@ -141,39 +141,39 @@ struct hif_otp_phy_info { #define API_FIRMWARE_LABEL_SIZE 128 struct hif_ind_startup { - uint32_t status; - uint16_t hardware_id; - uint8_t opn[API_OPN_SIZE]; - uint8_t uid[API_UID_SIZE]; - uint16_t num_inp_ch_bufs; - uint16_t size_inp_ch_buf; - uint8_t num_links_ap; - uint8_t num_interfaces; - uint8_t mac_addr[2][ETH_ALEN]; - uint8_t api_version_minor; - uint8_t api_version_major; + u32 status; + u16 hardware_id; + u8 opn[API_OPN_SIZE]; + u8 uid[API_UID_SIZE]; + u16 num_inp_ch_bufs; + u16 size_inp_ch_buf; + u8 num_links_ap; + u8 num_interfaces; + u8 mac_addr[2][ETH_ALEN]; + u8 api_version_minor; + u8 api_version_major; struct hif_capabilities capabilities; - uint8_t firmware_build; - uint8_t firmware_minor; - uint8_t firmware_major; - uint8_t firmware_type; - uint8_t disabled_channel_list[API_DISABLED_CHANNEL_LIST_SIZE]; + u8 firmware_build; + u8 firmware_minor; + u8 firmware_major; + u8 firmware_type; + u8 disabled_channel_list[API_DISABLED_CHANNEL_LIST_SIZE]; struct hif_otp_regul_sel_mode_info regul_sel_mode_info; struct hif_otp_phy_info otp_phy_info; - uint32_t supported_rate_mask; - uint8_t firmware_label[API_FIRMWARE_LABEL_SIZE]; + u32 supported_rate_mask; + u8 firmware_label[API_FIRMWARE_LABEL_SIZE]; } __packed; struct hif_ind_wakeup { } __packed; struct hif_req_configuration { - uint16_t length; - uint8_t pds_data[]; + u16 length; + u8 pds_data[]; } __packed; struct hif_cnf_configuration { - uint32_t status; + u32 status; } __packed; enum hif_gpio_mode { @@ -187,8 +187,8 @@ enum hif_gpio_mode { }; struct hif_req_control_gpio { - uint8_t gpio_label; - uint8_t gpio_mode; + u8 gpio_label; + u8 gpio_mode; } __packed; enum hif_gpio_error { @@ -198,8 +198,8 @@ enum hif_gpio_error { }; struct hif_cnf_control_gpio { - uint32_t status; - uint32_t value; + u32 status; + u32 value; } __packed; enum hif_generic_indication_type { @@ -209,28 +209,28 @@ enum hif_generic_indication_type { }; struct hif_rx_stats { - uint32_t nb_rx_frame; - uint32_t nb_crc_frame; - uint32_t per_total; - uint32_t throughput; - uint32_t nb_rx_by_rate[API_RATE_NUM_ENTRIES]; - uint16_t per[API_RATE_NUM_ENTRIES]; - int16_t snr[API_RATE_NUM_ENTRIES]; - int16_t rssi[API_RATE_NUM_ENTRIES]; - int16_t cfo[API_RATE_NUM_ENTRIES]; - uint32_t date; - uint32_t pwr_clk_freq; - uint8_t is_ext_pwr_clk; - int8_t current_temp; + u32 nb_rx_frame; + u32 nb_crc_frame; + u32 per_total; + u32 throughput; + u32 nb_rx_by_rate[API_RATE_NUM_ENTRIES]; + u16 per[API_RATE_NUM_ENTRIES]; + s16 snr[API_RATE_NUM_ENTRIES]; + s16 rssi[API_RATE_NUM_ENTRIES]; + s16 cfo[API_RATE_NUM_ENTRIES]; + u32 date; + u32 pwr_clk_freq; + u8 is_ext_pwr_clk; + s8 current_temp; } __packed; union hif_indication_data { struct hif_rx_stats rx_stats; - uint8_t raw_data[1]; + u8 raw_data[1]; }; struct hif_ind_generic { - uint32_t indication_type; + u32 indication_type; union hif_indication_data indication_data; } __packed; @@ -238,7 +238,7 @@ struct hif_ind_generic { #define HIF_EXCEPTION_DATA_SIZE 124 struct hif_ind_exception { - uint8_t data[HIF_EXCEPTION_DATA_SIZE]; + u8 data[HIF_EXCEPTION_DATA_SIZE]; } __packed; @@ -257,8 +257,8 @@ enum hif_error { }; struct hif_ind_error { - uint32_t type; - uint8_t data[]; + u32 type; + u8 data[]; } __packed; enum hif_secure_link_state { @@ -276,20 +276,20 @@ enum hif_sl_encryption_type { }; struct hif_sl_msg_hdr { - uint32_t seqnum:30; - uint32_t encrypted:2; + u32 seqnum:30; + u32 encrypted:2; } __packed; struct hif_sl_msg { struct hif_sl_msg_hdr hdr; - uint16_t len; - uint8_t payload[]; + u16 len; + u8 payload[]; } __packed; #define AES_CCM_TAG_SIZE 16 struct hif_sl_tag { - uint8_t tag[16]; + u8 tag[16]; } __packed; enum hif_sl_mac_key_dest { @@ -300,12 +300,12 @@ enum hif_sl_mac_key_dest { #define API_KEY_VALUE_SIZE 32 struct hif_req_set_sl_mac_key { - uint8_t otp_or_ram; - uint8_t key_value[API_KEY_VALUE_SIZE]; + u8 otp_or_ram; + u8 key_value[API_KEY_VALUE_SIZE]; } __packed; struct hif_cnf_set_sl_mac_key { - uint32_t status; + u32 status; } __packed; #define API_HOST_PUB_KEY_SIZE 32 @@ -317,45 +317,45 @@ enum hif_sl_session_key_alg { }; struct hif_req_sl_exchange_pub_keys { - uint8_t algorithm:2; - uint8_t reserved1:6; - uint8_t reserved2[3]; - uint8_t host_pub_key[API_HOST_PUB_KEY_SIZE]; - uint8_t host_pub_key_mac[API_HOST_PUB_KEY_MAC_SIZE]; + u8 algorithm:2; + u8 reserved1:6; + u8 reserved2[3]; + u8 host_pub_key[API_HOST_PUB_KEY_SIZE]; + u8 host_pub_key_mac[API_HOST_PUB_KEY_MAC_SIZE]; } __packed; struct hif_cnf_sl_exchange_pub_keys { - uint32_t status; + u32 status; } __packed; #define API_NCP_PUB_KEY_SIZE 32 #define API_NCP_PUB_KEY_MAC_SIZE 64 struct hif_ind_sl_exchange_pub_keys { - uint32_t status; - uint8_t ncp_pub_key[API_NCP_PUB_KEY_SIZE]; - uint8_t ncp_pub_key_mac[API_NCP_PUB_KEY_MAC_SIZE]; + u32 status; + u8 ncp_pub_key[API_NCP_PUB_KEY_SIZE]; + u8 ncp_pub_key_mac[API_NCP_PUB_KEY_MAC_SIZE]; } __packed; #define API_ENCR_BMP_SIZE 32 struct hif_req_sl_configure { - uint8_t encr_bmp[API_ENCR_BMP_SIZE]; - uint8_t disable_session_key_protection:1; - uint8_t reserved1:7; - uint8_t reserved2[3]; + u8 encr_bmp[API_ENCR_BMP_SIZE]; + u8 disable_session_key_protection:1; + u8 reserved1:7; + u8 reserved2[3]; } __packed; struct hif_cnf_sl_configure { - uint32_t status; + u32 status; } __packed; struct hif_req_prevent_rollback { - uint32_t magic_word; + u32 magic_word; } __packed; struct hif_cnf_prevent_rollback { - uint32_t status; + u32 status; } __packed; enum hif_pta_mode { @@ -382,27 +382,27 @@ enum hif_grant_state { }; struct hif_req_pta_settings { - uint8_t pta_mode; - uint8_t request_signal_active_level; - uint8_t priority_signal_active_level; - uint8_t freq_signal_active_level; - uint8_t grant_signal_active_level; - uint8_t coex_type; - uint8_t default_grant_state; - uint8_t simultaneous_rx_accesses; - uint8_t priority_sampling_time; - uint8_t tx_rx_sampling_time; - uint8_t freq_sampling_time; - uint8_t grant_valid_time; - uint8_t fem_control_time; - uint8_t first_slot_time; - uint16_t periodic_tx_rx_sampling_time; - uint16_t coex_quota; - uint16_t wlan_quota; + u8 pta_mode; + u8 request_signal_active_level; + u8 priority_signal_active_level; + u8 freq_signal_active_level; + u8 grant_signal_active_level; + u8 coex_type; + u8 default_grant_state; + u8 simultaneous_rx_accesses; + u8 priority_sampling_time; + u8 tx_rx_sampling_time; + u8 freq_sampling_time; + u8 grant_valid_time; + u8 fem_control_time; + u8 first_slot_time; + u16 periodic_tx_rx_sampling_time; + u16 coex_quota; + u16 wlan_quota; } __packed; struct hif_cnf_pta_settings { - uint32_t status; + u32 status; } __packed; enum hif_pta_priority { @@ -414,11 +414,11 @@ enum hif_pta_priority { }; struct hif_req_pta_priority { - uint32_t priority; + u32 priority; } __packed; struct hif_cnf_pta_priority { - uint32_t status; + u32 status; } __packed; enum hif_pta_state { @@ -427,11 +427,11 @@ enum hif_pta_state { }; struct hif_req_pta_state { - uint32_t pta_state; + u32 pta_state; } __packed; struct hif_cnf_pta_state { - uint32_t status; + u32 status; } __packed; #endif diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h index af657555f894..94b789ceb4ff 100644 --- a/drivers/staging/wfx/hif_api_mib.h +++ b/drivers/staging/wfx/hif_api_mib.h @@ -72,23 +72,23 @@ enum hif_op_power_mode { }; struct hif_mib_gl_operational_power_mode { - uint8_t power_mode:4; - uint8_t reserved1:3; - uint8_t wup_ind_activation:1; - uint8_t reserved2[3]; + u8 power_mode:4; + u8 reserved1:3; + u8 wup_ind_activation:1; + u8 reserved2[3]; } __packed; struct hif_mib_gl_block_ack_info { - uint8_t rx_buffer_size; - uint8_t rx_max_num_agreements; - uint8_t tx_buffer_size; - uint8_t tx_max_num_agreements; + u8 rx_buffer_size; + u8 rx_max_num_agreements; + u8 tx_buffer_size; + u8 tx_max_num_agreements; } __packed; struct hif_mib_gl_set_multi_msg { - uint8_t enable_multi_tx_conf:1; - uint8_t reserved1:7; - uint8_t reserved2[3]; + u8 enable_multi_tx_conf:1; + u8 reserved1:7; + u8 reserved2[3]; } __packed; enum hif_cca_thr_mode { @@ -97,8 +97,8 @@ enum hif_cca_thr_mode { }; struct hif_mib_gl_cca_config { - uint8_t cca_thr_mode; - uint8_t reserved[3]; + u8 cca_thr_mode; + u8 reserved[3]; } __packed; #define MAX_NUMBER_DATA_FILTERS 0xA @@ -114,9 +114,9 @@ struct hif_mib_gl_cca_config { #define MAX_NUMBER_NS_CONDITIONS 0x2 struct hif_mib_ethertype_data_frame_condition { - uint8_t condition_idx; - uint8_t reserved; - uint16_t ether_type; + u8 condition_idx; + u8 reserved; + u16 ether_type; } __packed; enum hif_udp_tcp_protocol { @@ -132,22 +132,22 @@ enum hif_which_port { }; struct hif_mib_ports_data_frame_condition { - uint8_t condition_idx; - uint8_t protocol; - uint8_t which_port; - uint8_t reserved1; - uint16_t port_number; - uint8_t reserved2[2]; + u8 condition_idx; + u8 protocol; + u8 which_port; + u8 reserved1; + u16 port_number; + u8 reserved2[2]; } __packed; #define HIF_API_MAGIC_PATTERN_SIZE 32 struct hif_mib_magic_data_frame_condition { - uint8_t condition_idx; - uint8_t offset; - uint8_t magic_pattern_length; - uint8_t reserved; - uint8_t magic_pattern[HIF_API_MAGIC_PATTERN_SIZE]; + u8 condition_idx; + u8 offset; + u8 magic_pattern_length; + u8 reserved; + u8 magic_pattern[HIF_API_MAGIC_PATTERN_SIZE]; } __packed; enum hif_mac_addr_type { @@ -157,9 +157,9 @@ enum hif_mac_addr_type { }; struct hif_mib_mac_addr_data_frame_condition { - uint8_t condition_idx; - uint8_t address_type; - uint8_t mac_address[ETH_ALEN]; + u8 condition_idx; + u8 address_type; + u8 mac_address[ETH_ALEN]; } __packed; enum hif_ip_addr_mode { @@ -168,53 +168,53 @@ enum hif_ip_addr_mode { }; struct hif_mib_ipv4_addr_data_frame_condition { - uint8_t condition_idx; - uint8_t address_mode; - uint8_t reserved[2]; - uint8_t i_pv4_address[HIF_API_IPV4_ADDRESS_SIZE]; + u8 condition_idx; + u8 address_mode; + u8 reserved[2]; + u8 i_pv4_address[HIF_API_IPV4_ADDRESS_SIZE]; } __packed; struct hif_mib_ipv6_addr_data_frame_condition { - uint8_t condition_idx; - uint8_t address_mode; - uint8_t reserved[2]; - uint8_t i_pv6_address[HIF_API_IPV6_ADDRESS_SIZE]; + u8 condition_idx; + u8 address_mode; + u8 reserved[2]; + u8 i_pv6_address[HIF_API_IPV6_ADDRESS_SIZE]; } __packed; union hif_addr_type { - uint8_t value; + u8 value; struct { - uint8_t type_unicast:1; - uint8_t type_multicast:1; - uint8_t type_broadcast:1; - uint8_t reserved:5; + u8 type_unicast:1; + u8 type_multicast:1; + u8 type_broadcast:1; + u8 reserved:5; } bits; }; struct hif_mib_uc_mc_bc_data_frame_condition { - uint8_t condition_idx; + u8 condition_idx; union hif_addr_type param; - uint8_t reserved[2]; + u8 reserved[2]; } __packed; struct hif_mib_config_data_filter { - uint8_t filter_idx; - uint8_t enable; - uint8_t reserved1[2]; - uint8_t eth_type_cond; - uint8_t port_cond; - uint8_t magic_cond; - uint8_t mac_cond; - uint8_t ipv4_cond; - uint8_t ipv6_cond; - uint8_t uc_mc_bc_cond; - uint8_t reserved2; + u8 filter_idx; + u8 enable; + u8 reserved1[2]; + u8 eth_type_cond; + u8 port_cond; + u8 magic_cond; + u8 mac_cond; + u8 ipv4_cond; + u8 ipv6_cond; + u8 uc_mc_bc_cond; + u8 reserved2; } __packed; struct hif_mib_set_data_filtering { - uint8_t default_filter; - uint8_t enable; - uint8_t reserved[2]; + u8 default_filter; + u8 enable; + u8 reserved[2]; } __packed; enum hif_arp_ns_frame_treatment { @@ -224,45 +224,45 @@ enum hif_arp_ns_frame_treatment { }; struct hif_mib_arp_ip_addr_table { - uint8_t condition_idx; - uint8_t arp_enable; - uint8_t reserved[2]; - uint8_t ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; + u8 condition_idx; + u8 arp_enable; + u8 reserved[2]; + u8 ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; } __packed; struct hif_mib_ns_ip_addr_table { - uint8_t condition_idx; - uint8_t ns_enable; - uint8_t reserved[2]; - uint8_t ipv6_address[HIF_API_IPV6_ADDRESS_SIZE]; + u8 condition_idx; + u8 ns_enable; + u8 reserved[2]; + u8 ipv6_address[HIF_API_IPV6_ADDRESS_SIZE]; } __packed; struct hif_mib_rx_filter { - uint8_t reserved1:1; - uint8_t bssid_filter:1; - uint8_t reserved2:1; - uint8_t fwd_probe_req:1; - uint8_t keep_alive_filter:1; - uint8_t reserved3:3; - uint8_t reserved4[3]; + u8 reserved1:1; + u8 bssid_filter:1; + u8 reserved2:1; + u8 fwd_probe_req:1; + u8 keep_alive_filter:1; + u8 reserved3:3; + u8 reserved4[3]; } __packed; #define HIF_API_OUI_SIZE 3 #define HIF_API_MATCH_DATA_SIZE 3 struct hif_ie_table_entry { - uint8_t ie_id; - uint8_t has_changed:1; - uint8_t no_longer:1; - uint8_t has_appeared:1; - uint8_t reserved:1; - uint8_t num_match_data:4; - uint8_t oui[HIF_API_OUI_SIZE]; - uint8_t match_data[HIF_API_MATCH_DATA_SIZE]; + u8 ie_id; + u8 has_changed:1; + u8 no_longer:1; + u8 has_appeared:1; + u8 reserved:1; + u8 num_match_data:4; + u8 oui[HIF_API_OUI_SIZE]; + u8 match_data[HIF_API_MATCH_DATA_SIZE]; } __packed; struct hif_mib_bcn_filter_table { - uint32_t num_of_info_elmts; + u32 num_of_info_elmts; struct hif_ie_table_entry ie_table[]; } __packed; @@ -273,126 +273,126 @@ enum hif_beacon_filter { }; struct hif_mib_bcn_filter_enable { - uint32_t enable; - uint32_t bcn_count; + u32 enable; + u32 bcn_count; } __packed; struct hif_mib_group_seq_counter { - uint32_t bits4716; - uint16_t bits1500; - uint16_t reserved; + u32 bits4716; + u16 bits1500; + u16 reserved; } __packed; struct hif_mib_tsf_counter { - uint32_t tsf_counterlo; - uint32_t tsf_counterhi; + u32 tsf_counterlo; + u32 tsf_counterhi; } __packed; struct hif_mib_stats_table { - int16_t latest_snr; - uint8_t latest_rcpi; - int8_t latest_rssi; + s16 latest_snr; + u8 latest_rcpi; + s8 latest_rssi; } __packed; struct hif_mib_extended_count_table { - uint32_t count_plcp_errors; - uint32_t count_fcs_errors; - uint32_t count_tx_packets; - uint32_t count_rx_packets; - uint32_t count_rx_packet_errors; - uint32_t count_rx_decryption_failures; - uint32_t count_rx_mic_failures; - uint32_t count_rx_no_key_failures; - uint32_t count_tx_multicast_frames; - uint32_t count_tx_frames_success; - uint32_t count_tx_frame_failures; - uint32_t count_tx_frames_retried; - uint32_t count_tx_frames_multi_retried; - uint32_t count_rx_frame_duplicates; - uint32_t count_rts_success; - uint32_t count_rts_failures; - uint32_t count_ack_failures; - uint32_t count_rx_multicast_frames; - uint32_t count_rx_frames_success; - uint32_t count_rx_cmacicv_errors; - uint32_t count_rx_cmac_replays; - uint32_t count_rx_mgmt_ccmp_replays; - uint32_t count_rx_bipmic_errors; - uint32_t count_rx_beacon; - uint32_t count_miss_beacon; - uint32_t reserved[15]; + u32 count_plcp_errors; + u32 count_fcs_errors; + u32 count_tx_packets; + u32 count_rx_packets; + u32 count_rx_packet_errors; + u32 count_rx_decryption_failures; + u32 count_rx_mic_failures; + u32 count_rx_no_key_failures; + u32 count_tx_multicast_frames; + u32 count_tx_frames_success; + u32 count_tx_frame_failures; + u32 count_tx_frames_retried; + u32 count_tx_frames_multi_retried; + u32 count_rx_frame_duplicates; + u32 count_rts_success; + u32 count_rts_failures; + u32 count_ack_failures; + u32 count_rx_multicast_frames; + u32 count_rx_frames_success; + u32 count_rx_cmacicv_errors; + u32 count_rx_cmac_replays; + u32 count_rx_mgmt_ccmp_replays; + u32 count_rx_bipmic_errors; + u32 count_rx_beacon; + u32 count_miss_beacon; + u32 reserved[15]; } __packed; struct hif_mib_count_table { - uint32_t count_plcp_errors; - uint32_t count_fcs_errors; - uint32_t count_tx_packets; - uint32_t count_rx_packets; - uint32_t count_rx_packet_errors; - uint32_t count_rx_decryption_failures; - uint32_t count_rx_mic_failures; - uint32_t count_rx_no_key_failures; - uint32_t count_tx_multicast_frames; - uint32_t count_tx_frames_success; - uint32_t count_tx_frame_failures; - uint32_t count_tx_frames_retried; - uint32_t count_tx_frames_multi_retried; - uint32_t count_rx_frame_duplicates; - uint32_t count_rts_success; - uint32_t count_rts_failures; - uint32_t count_ack_failures; - uint32_t count_rx_multicast_frames; - uint32_t count_rx_frames_success; - uint32_t count_rx_cmacicv_errors; - uint32_t count_rx_cmac_replays; - uint32_t count_rx_mgmt_ccmp_replays; - uint32_t count_rx_bipmic_errors; + u32 count_plcp_errors; + u32 count_fcs_errors; + u32 count_tx_packets; + u32 count_rx_packets; + u32 count_rx_packet_errors; + u32 count_rx_decryption_failures; + u32 count_rx_mic_failures; + u32 count_rx_no_key_failures; + u32 count_tx_multicast_frames; + u32 count_tx_frames_success; + u32 count_tx_frame_failures; + u32 count_tx_frames_retried; + u32 count_tx_frames_multi_retried; + u32 count_rx_frame_duplicates; + u32 count_rts_success; + u32 count_rts_failures; + u32 count_ack_failures; + u32 count_rx_multicast_frames; + u32 count_rx_frames_success; + u32 count_rx_cmacicv_errors; + u32 count_rx_cmac_replays; + u32 count_rx_mgmt_ccmp_replays; + u32 count_rx_bipmic_errors; } __packed; struct hif_mib_max_tx_power_level { - int32_t max_tx_power_level_rf_port1; - int32_t max_tx_power_level_rf_port2; + s32 max_tx_power_level_rf_port1; + s32 max_tx_power_level_rf_port2; } __packed; struct hif_mib_beacon_stats { - int32_t latest_tbtt_diff; - uint32_t reserved[4]; + s32 latest_tbtt_diff; + u32 reserved[4]; } __packed; struct hif_mib_mac_address { - uint8_t mac_addr[ETH_ALEN]; - uint16_t reserved; + u8 mac_addr[ETH_ALEN]; + u16 reserved; } __packed; struct hif_mib_dot11_max_transmit_msdu_lifetime { - uint32_t max_life_time; + u32 max_life_time; } __packed; struct hif_mib_dot11_max_receive_lifetime { - uint32_t max_life_time; + u32 max_life_time; } __packed; struct hif_mib_wep_default_key_id { - uint8_t wep_default_key_id; - uint8_t reserved[3]; + u8 wep_default_key_id; + u8 reserved[3]; } __packed; struct hif_mib_dot11_rts_threshold { - uint32_t threshold; + u32 threshold; } __packed; struct hif_mib_slot_time { - uint32_t slot_time; + u32 slot_time; } __packed; struct hif_mib_current_tx_power_level { - int32_t power_level; + s32 power_level; } __packed; struct hif_mib_non_erp_protection { - uint8_t use_cts_to_self:1; - uint8_t reserved1:7; - uint8_t reserved2[3]; + u8 use_cts_to_self:1; + u8 reserved1:7; + u8 reserved2[3]; } __packed; enum hif_tx_mode { @@ -414,45 +414,45 @@ enum hif_tmplt { #define HIF_API_MAX_TEMPLATE_FRAME_SIZE 700 struct hif_mib_template_frame { - uint8_t frame_type; - uint8_t init_rate:7; - uint8_t mode:1; - uint16_t frame_length; - uint8_t frame[HIF_API_MAX_TEMPLATE_FRAME_SIZE]; + u8 frame_type; + u8 init_rate:7; + u8 mode:1; + u16 frame_length; + u8 frame[HIF_API_MAX_TEMPLATE_FRAME_SIZE]; } __packed; struct hif_mib_beacon_wake_up_period { - uint8_t wakeup_period_min; - uint8_t receive_dtim:1; - uint8_t reserved1:7; - uint8_t wakeup_period_max; - uint8_t reserved2; + u8 wakeup_period_min; + u8 receive_dtim:1; + u8 reserved1:7; + u8 wakeup_period_max; + u8 reserved2; } __packed; struct hif_mib_rcpi_rssi_threshold { - uint8_t detection:1; - uint8_t rcpi_rssi:1; - uint8_t upperthresh:1; - uint8_t lowerthresh:1; - uint8_t reserved:4; - uint8_t lower_threshold; - uint8_t upper_threshold; - uint8_t rolling_average_count; + u8 detection:1; + u8 rcpi_rssi:1; + u8 upperthresh:1; + u8 lowerthresh:1; + u8 reserved:4; + u8 lower_threshold; + u8 upper_threshold; + u8 rolling_average_count; } __packed; #define DEFAULT_BA_MAX_RX_BUFFER_SIZE 16 struct hif_mib_block_ack_policy { - uint8_t block_ack_tx_tid_policy; - uint8_t reserved1; - uint8_t block_ack_rx_tid_policy; - uint8_t block_ack_rx_max_buffer_size; + u8 block_ack_tx_tid_policy; + u8 reserved1; + u8 block_ack_rx_tid_policy; + u8 block_ack_rx_max_buffer_size; } __packed; struct hif_mib_override_int_rate { - uint8_t internal_tx_rate; - uint8_t non_erp_internal_tx_rate; - uint8_t reserved[2]; + u8 internal_tx_rate; + u8 non_erp_internal_tx_rate; + u8 reserved[2]; } __packed; enum hif_mpdu_start_spacing { @@ -467,92 +467,91 @@ enum hif_mpdu_start_spacing { }; struct hif_mib_set_association_mode { - uint8_t preambtype_use:1; - uint8_t mode:1; - uint8_t rateset:1; - uint8_t spacing:1; - uint8_t reserved:4; - uint8_t preamble_type; - uint8_t mixed_or_greenfield_type; - uint8_t mpdu_start_spacing; - uint32_t basic_rate_set; + u8 preambtype_use:1; + u8 mode:1; + u8 rateset:1; + u8 spacing:1; + u8 reserved:4; + u8 preamble_type; + u8 mixed_or_greenfield_type; + u8 mpdu_start_spacing; + u32 basic_rate_set; } __packed; struct hif_mib_set_uapsd_information { - uint8_t trig_bckgrnd:1; - uint8_t trig_be:1; - uint8_t trig_video:1; - uint8_t trig_voice:1; - uint8_t reserved1:4; - uint8_t deliv_bckgrnd:1; - uint8_t deliv_be:1; - uint8_t deliv_video:1; - uint8_t deliv_voice:1; - uint8_t reserved2:4; - uint16_t min_auto_trigger_interval; - uint16_t max_auto_trigger_interval; - uint16_t auto_trigger_step; + u8 trig_bckgrnd:1; + u8 trig_be:1; + u8 trig_video:1; + u8 trig_voice:1; + u8 reserved1:4; + u8 deliv_bckgrnd:1; + u8 deliv_be:1; + u8 deliv_video:1; + u8 deliv_voice:1; + u8 reserved2:4; + u16 min_auto_trigger_interval; + u16 max_auto_trigger_interval; + u16 auto_trigger_step; } __packed; struct hif_mib_tx_rate_retry_policy { - uint8_t policy_index; - uint8_t short_retry_count; - uint8_t long_retry_count; - uint8_t first_rate_sel:2; - uint8_t terminate:1; - uint8_t count_init:1; - uint8_t reserved1:4; - uint8_t rate_recovery_count; - uint8_t reserved2[3]; - uint8_t rates[12]; + u8 policy_index; + u8 short_retry_count; + u8 long_retry_count; + u8 first_rate_sel:2; + u8 terminate:1; + u8 count_init:1; + u8 reserved1:4; + u8 rate_recovery_count; + u8 reserved2[3]; + u8 rates[12]; } __packed; #define HIF_MIB_NUM_TX_RATE_RETRY_POLICIES 15 struct hif_mib_set_tx_rate_retry_policy { - uint8_t num_tx_rate_policies; - uint8_t reserved[3]; + u8 num_tx_rate_policies; + u8 reserved[3]; struct hif_mib_tx_rate_retry_policy tx_rate_retry_policy[]; } __packed; struct hif_mib_protected_mgmt_policy { - uint8_t pmf_enable:1; - uint8_t unpmf_allowed:1; - uint8_t host_enc_auth_frames:1; - uint8_t reserved1:5; - uint8_t reserved2[3]; + u8 pmf_enable:1; + u8 unpmf_allowed:1; + u8 host_enc_auth_frames:1; + u8 reserved1:5; + u8 reserved2[3]; } __packed; struct hif_mib_set_ht_protection { - uint8_t dual_cts_prot:1; - uint8_t reserved1:7; - uint8_t reserved2[3]; + u8 dual_cts_prot:1; + u8 reserved1:7; + u8 reserved2[3]; } __packed; struct hif_mib_keep_alive_period { - uint16_t keep_alive_period; - uint8_t reserved[2]; + u16 keep_alive_period; + u8 reserved[2]; } __packed; struct hif_mib_arp_keep_alive_period { - uint16_t arp_keep_alive_period; - uint8_t encr_type; - uint8_t reserved; - uint8_t sender_ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; - uint8_t target_ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; + u16 arp_keep_alive_period; + u8 encr_type; + u8 reserved; + u8 sender_ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; + u8 target_ipv4_address[HIF_API_IPV4_ADDRESS_SIZE]; } __packed; struct hif_mib_inactivity_timer { - uint8_t min_active_time; - uint8_t max_active_time; - uint16_t reserved; + u8 min_active_time; + u8 max_active_time; + u16 reserved; } __packed; struct hif_mib_interface_protection { - uint8_t use_cts_prot:1; - uint8_t reserved1:7; - uint8_t reserved2[3]; + u8 use_cts_prot:1; + u8 reserved1:7; + u8 reserved2[3]; } __packed; - #endif diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 2d40225a0fce..2f5dadff0660 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -452,7 +452,8 @@ int hif_sl_config(struct wfx_dev *wdev, const unsigned long *bitmap) return ret; } -int hif_sl_set_mac_key(struct wfx_dev *wdev, const uint8_t *slk_key, int destination) +int hif_sl_set_mac_key(struct wfx_dev *wdev, const u8 *slk_key, + int destination) { int ret; struct hif_msg *hif; diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h index 6f2ea2f3a77d..f61ae7b0d41c 100644 --- a/drivers/staging/wfx/hif_tx.h +++ b/drivers/staging/wfx/hif_tx.h @@ -18,7 +18,7 @@ struct wfx_vif; struct wfx_scan_params { struct hif_req_start_scan scan_req; struct hif_ssid_def *ssids; - uint8_t *ch; + u8 *ch; }; struct wfx_hif_cmd { @@ -59,9 +59,10 @@ int hif_beacon_transmit(struct wfx_vif *wvif, bool enable); int hif_map_link(struct wfx_vif *wvif, u8 *mac_addr, int flags, int sta_id); int hif_update_ie(struct wfx_vif *wvif, const struct hif_ie_flags *target_frame, const u8 *ies, size_t ies_len); -int hif_sl_set_mac_key(struct wfx_dev *wdev, const uint8_t *slk_key, int destination); +int hif_sl_set_mac_key(struct wfx_dev *wdev, const u8 *slk_key, + int destination); int hif_sl_config(struct wfx_dev *wdev, const unsigned long *bitmap); int hif_sl_send_pub_keys(struct wfx_dev *wdev, - const uint8_t *pubkey, const uint8_t *pubkey_hmac); + const u8 *pubkey, const u8 *pubkey_hmac); #endif diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index 3339ad95f732..d1cabd697205 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -145,7 +145,7 @@ static inline int hif_set_mfp(struct wfx_vif *wvif, bool capable, bool required) } if (!required) val.unpmf_allowed = 1; - cpu_to_le32s((uint32_t *) &val); + cpu_to_le32s((u32 *) &val); return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_PROTECTED_MGMT_POLICY, &val, sizeof(val)); diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c index 6d03abec20e4..caea6d959b0e 100644 --- a/drivers/staging/wfx/key.c +++ b/drivers/staging/wfx/key.c @@ -31,7 +31,7 @@ static void wfx_free_key(struct wfx_dev *wdev, int idx) wdev->key_map &= ~BIT(idx); } -static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, +static u8 fill_wep_pair(struct hif_wep_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { WARN(key->keylen > sizeof(msg->key_data), "inconsistent data"); @@ -41,7 +41,7 @@ static uint8_t fill_wep_pair(struct hif_wep_pairwise_key *msg, return HIF_KEY_TYPE_WEP_PAIRWISE; } -static uint8_t fill_wep_group(struct hif_wep_group_key *msg, +static u8 fill_wep_group(struct hif_wep_group_key *msg, struct ieee80211_key_conf *key) { WARN(key->keylen > sizeof(msg->key_data), "inconsistent data"); @@ -51,10 +51,10 @@ static uint8_t fill_wep_group(struct hif_wep_group_key *msg, return HIF_KEY_TYPE_WEP_DEFAULT; } -static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, +static u8 fill_tkip_pair(struct hif_tkip_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { - uint8_t *keybuf = key->key; + u8 *keybuf = key->key; WARN(key->keylen != sizeof(msg->tkip_key_data) + sizeof(msg->tx_mic_key) @@ -68,18 +68,20 @@ static uint8_t fill_tkip_pair(struct hif_tkip_pairwise_key *msg, return HIF_KEY_TYPE_TKIP_PAIRWISE; } -static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, +static u8 fill_tkip_group(struct hif_tkip_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq, enum nl80211_iftype iftype) { - uint8_t *keybuf = key->key; + u8 *keybuf = key->key; WARN(key->keylen != sizeof(msg->tkip_key_data) + 2 * sizeof(msg->rx_mic_key), "inconsistent data"); msg->key_id = key->keyidx; - memcpy(msg->rx_sequence_counter, &seq->tkip.iv16, sizeof(seq->tkip.iv16)); - memcpy(msg->rx_sequence_counter + sizeof(uint16_t), &seq->tkip.iv32, sizeof(seq->tkip.iv32)); + memcpy(msg->rx_sequence_counter, + &seq->tkip.iv16, sizeof(seq->tkip.iv16)); + memcpy(msg->rx_sequence_counter + sizeof(u16), + &seq->tkip.iv32, sizeof(seq->tkip.iv32)); memcpy(msg->tkip_key_data, keybuf, sizeof(msg->tkip_key_data)); keybuf += sizeof(msg->tkip_key_data); if (iftype == NL80211_IFTYPE_AP) @@ -91,7 +93,7 @@ static uint8_t fill_tkip_group(struct hif_tkip_group_key *msg, return HIF_KEY_TYPE_TKIP_GROUP; } -static uint8_t fill_ccmp_pair(struct hif_aes_pairwise_key *msg, +static u8 fill_ccmp_pair(struct hif_aes_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { WARN(key->keylen != sizeof(msg->aes_key_data), "inconsistent data"); @@ -100,7 +102,7 @@ static uint8_t fill_ccmp_pair(struct hif_aes_pairwise_key *msg, return HIF_KEY_TYPE_AES_PAIRWISE; } -static uint8_t fill_ccmp_group(struct hif_aes_group_key *msg, +static u8 fill_ccmp_group(struct hif_aes_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { @@ -112,10 +114,10 @@ static uint8_t fill_ccmp_group(struct hif_aes_group_key *msg, return HIF_KEY_TYPE_AES_GROUP; } -static uint8_t fill_sms4_pair(struct hif_wapi_pairwise_key *msg, +static u8 fill_sms4_pair(struct hif_wapi_pairwise_key *msg, struct ieee80211_key_conf *key, u8 *peer_addr) { - uint8_t *keybuf = key->key; + u8 *keybuf = key->key; WARN(key->keylen != sizeof(msg->wapi_key_data) + sizeof(msg->mic_key_data), "inconsistent data"); @@ -127,10 +129,10 @@ static uint8_t fill_sms4_pair(struct hif_wapi_pairwise_key *msg, return HIF_KEY_TYPE_WAPI_PAIRWISE; } -static uint8_t fill_sms4_group(struct hif_wapi_group_key *msg, +static u8 fill_sms4_group(struct hif_wapi_group_key *msg, struct ieee80211_key_conf *key) { - uint8_t *keybuf = key->key; + u8 *keybuf = key->key; WARN(key->keylen != sizeof(msg->wapi_key_data) + sizeof(msg->mic_key_data), "inconsistent data"); @@ -141,7 +143,7 @@ static uint8_t fill_sms4_group(struct hif_wapi_group_key *msg, return HIF_KEY_TYPE_WAPI_GROUP; } -static uint8_t fill_aes_cmac_group(struct hif_igtk_group_key *msg, +static u8 fill_aes_cmac_group(struct hif_igtk_group_key *msg, struct ieee80211_key_conf *key, struct ieee80211_key_seq *seq) { diff --git a/drivers/staging/wfx/secure_link.h b/drivers/staging/wfx/secure_link.h index 376d7bc4c0c4..666b26e5308d 100644 --- a/drivers/staging/wfx/secure_link.h +++ b/drivers/staging/wfx/secure_link.h @@ -25,12 +25,14 @@ static inline int wfx_sl_decode(struct wfx_dev *wdev, struct hif_sl_msg *m) return -EIO; } -static inline int wfx_sl_encode(struct wfx_dev *wdev, struct hif_msg *input, struct hif_sl_msg *output) +static inline int wfx_sl_encode(struct wfx_dev *wdev, struct hif_msg *input, + struct hif_sl_msg *output) { return -EIO; } -static inline int wfx_sl_check_pubkey(struct wfx_dev *wdev, uint8_t *ncp_pubkey, uint8_t *ncp_pubmac) +static inline int wfx_sl_check_pubkey(struct wfx_dev *wdev, u8 *ncp_pubkey, + u8 *ncp_pubmac) { return -EIO; } diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 2ab5ba9742ad..1cdfa88ffee7 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -453,7 +453,7 @@ void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, /* WSM callbacks */ -static void wfx_event_report_rssi(struct wfx_vif *wvif, uint8_t raw_rcpi_rssi) +static void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi) { /* RSSI: signed Q8.0, RCPI: unsigned Q7.1 * RSSI = RCPI / 2 - 110 @@ -590,10 +590,10 @@ done: static void wfx_set_mfp(struct wfx_vif *wvif, struct cfg80211_bss *bss) { - const int pairwise_cipher_suite_count_offset = 8 / sizeof(uint16_t); - const int pairwise_cipher_suite_size = 4 / sizeof(uint16_t); - const int akm_suite_size = 4 / sizeof(uint16_t); - const uint16_t *ptr = NULL; + const int pairwise_cipher_suite_count_offset = 8 / sizeof(u16); + const int pairwise_cipher_suite_size = 4 / sizeof(u16); + const int akm_suite_size = 4 / sizeof(u16); + const u16 *ptr = NULL; bool mfpc = false; bool mfpr = false; @@ -603,7 +603,8 @@ static void wfx_set_mfp(struct wfx_vif *wvif, struct cfg80211_bss *bss) rcu_read_lock(); if (bss) - ptr = (const uint16_t *) ieee80211_bss_get_ie(bss, WLAN_EID_RSN); + ptr = (const u16 *) ieee80211_bss_get_ie(bss, + WLAN_EID_RSN); if (ptr) { ptr += pairwise_cipher_suite_count_offset; diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 307ed0196110..57c46bd4e650 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -26,7 +26,7 @@ enum wfx_state { struct wfx_ht_info { struct ieee80211_sta_ht_cap ht_cap; enum nl80211_channel_type channel_type; - uint16_t operation_mode; + u16 operation_mode; }; struct wfx_hif_event { diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index d678b5a08873..44e580a07c91 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -179,11 +179,11 @@ static inline int wvif_count(struct wfx_dev *wdev) return ret; } -static inline void memreverse(uint8_t *src, uint8_t length) +static inline void memreverse(u8 *src, u8 length) { - uint8_t *lo = src; - uint8_t *hi = src + length - 1; - uint8_t swap; + u8 *lo = src; + u8 *hi = src + length - 1; + u8 swap; while (lo < hi) { swap = *lo; @@ -194,7 +194,7 @@ static inline void memreverse(uint8_t *src, uint8_t length) static inline int memzcmp(void *src, unsigned int size) { - uint8_t *buf = src; + u8 *buf = src; if (!size) return 0; -- cgit v1.2.3-59-g8ed1b From 1fa489b14dbc4968284711874ed35566fcdf712b Mon Sep 17 00:00:00 2001 From: Valery Ivanov Date: Fri, 8 Nov 2019 14:23:29 +0000 Subject: staging: octeon: fix missing a blank line after declaration This patch fixes "WARNING: Missing a blank line after declarations" Issue found by checkpatch.pl Signed-off-by: Valery Ivanov Link: https://lore.kernel.org/r/20191108142329.GA3192@hwsrv-485799.hostwindsdns.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index d53bd801f440..ed9d44ff148b 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -1375,6 +1375,7 @@ static inline union cvmx_gmxx_rxx_rx_inbnd cvmx_spi4000_check_speed( int port) { union cvmx_gmxx_rxx_rx_inbnd r; + r.u64 = 0; return r; } -- cgit v1.2.3-59-g8ed1b From a46e810975b8bde22e612c12331e1c5207797435 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 8 Nov 2019 22:32:39 +0100 Subject: staging: exfat: use prandom_u32() for i_generation Similar to commit 46c9a946d766 ("shmem: use monotonic time for i_generation") we should not use the deprecated get_seconds() interface for i_generation. prandom_u32() is the replacement used in other file systems. Signed-off-by: Arnd Bergmann Acked-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191108213257.3097633-2-arnd@arndb.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 1ae5a7750348..ee3d64178069 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -26,7 +26,7 @@ #include #include #include - +#include #include #include #include @@ -3363,7 +3363,7 @@ static int exfat_fill_inode(struct inode *inode, struct file_id_t *fid) inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; INC_IVERSION(inode); - inode->i_generation = get_seconds(); + inode->i_generation = prandom_u32(); if (info.Attr & ATTR_SUBDIR) { /* directory */ inode->i_generation &= ~1; -- cgit v1.2.3-59-g8ed1b From c7e621bb981b76d3bfd8a595070ee8282ac4a32b Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 7 Nov 2019 15:58:54 +0000 Subject: staging: wilc1000: fix illegal memory access in wilc_parse_join_bss_param() Do not copy the extended supported rates in 'param->supp_rates' if the array is already full with basic rates values. The array size check helped to avoid possible illegal memory access [1] while copying to 'param->supp_rates' array. 1. https://marc.info/?l=linux-next&m=157301720517456&w=2 Reported-by: coverity-bot Addresses-Coverity-ID: 1487400 ("Memory - illegal accesses") Fixes: 4e0b0f42c9c7 ("staging: wilc1000: use struct to pack join parameters for FW") Cc: stable@vger.kernel.org Signed-off-by: Ajay Singh Link: https://lore.kernel.org/r/20191106062127.3165-1-ajay.kathat@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/hif.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/hif.c b/drivers/staging/wilc1000/hif.c index 5f6706bcedf6..349e45d58ec9 100644 --- a/drivers/staging/wilc1000/hif.c +++ b/drivers/staging/wilc1000/hif.c @@ -485,16 +485,21 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len); } - supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, ies->data, - ies->len); - if (supp_rates_ie) { - if (supp_rates_ie[1] > (WILC_MAX_RATES_SUPPORTED - rates_len)) - param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; - else - param->supp_rates[0] += supp_rates_ie[1]; - - memcpy(¶m->supp_rates[rates_len + 1], supp_rates_ie + 2, - (param->supp_rates[0] - rates_len)); + if (rates_len < WILC_MAX_RATES_SUPPORTED) { + supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, + ies->data, ies->len); + if (supp_rates_ie) { + u8 ext_rates = supp_rates_ie[1]; + + if (ext_rates > (WILC_MAX_RATES_SUPPORTED - rates_len)) + param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; + else + param->supp_rates[0] += ext_rates; + + memcpy(¶m->supp_rates[rates_len + 1], + supp_rates_ie + 2, + (param->supp_rates[0] - rates_len)); + } } ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len); -- cgit v1.2.3-59-g8ed1b From ff8292f78bcfb05828d3fe61c4cbc66a7ef1f57b Mon Sep 17 00:00:00 2001 From: Xianting Tian Date: Sat, 9 Nov 2019 08:36:54 -0500 Subject: staging: rtl8192u: Fix typo in comment Fix the typo "cheked" -> "checked" in comment Signed-off-by: Xianting Tian Link: https://lore.kernel.org/r/1573306614-21490-1-git-send-email-xianting_tian@126.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 33a6af7aad22..bd5b554787d1 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2331,7 +2331,7 @@ void ieee80211_start_bss(struct ieee80211_device *ieee) /* ensure no-one start an associating process (thus setting * the ieee->state to ieee80211_ASSOCIATING) while we - * have just cheked it and we are going to enable scan. + * have just checked it and we are going to enable scan. * The ieee80211_new_net function is always called with * lock held (from both ieee80211_softmac_check_all_nets and * the rx path), so we cannot be in the middle of such function -- cgit v1.2.3-59-g8ed1b From 3d5f1eedbfd22ceea94b39989d6021b1958181f4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 11 Nov 2019 12:38:45 +0100 Subject: staging: rtl8723bs: Add 024c:0525 to the list of SDIO device-ids Add 024c:0525 to the list of SDIO device-ids, based on a patch found in the Android X86 kernels. According to that patch this device id is used on the Alcatel Plus 10 device. Reported-and-tested-by: youling257 Signed-off-by: Hans de Goede Cc: stable Link: https://lore.kernel.org/r/20191111113846.24940-1-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 12f683e2e0e2..c48d2df97285 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -18,6 +18,7 @@ static const struct sdio_device_id sdio_ids[] = { { SDIO_DEVICE(0x024c, 0x0523), }, + { SDIO_DEVICE(0x024c, 0x0525), }, { SDIO_DEVICE(0x024c, 0x0623), }, { SDIO_DEVICE(0x024c, 0x0626), }, { SDIO_DEVICE(0x024c, 0xb723), }, -- cgit v1.2.3-59-g8ed1b From 2d9d2491530a156b9a5614adf9dc79285e35d55e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 11 Nov 2019 12:38:46 +0100 Subject: staging: rtl8723bs: Drop ACPI device ids The driver only binds by SDIO device-ids, all the ACPI device-id does is causing the driver to load unnecessarily on devices where the DSDT contains a bogus OBDA8723 device. Signed-off-by: Hans de Goede Cc: stable Link: https://lore.kernel.org/r/20191111113846.24940-2-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index c48d2df97285..859f4a0afb95 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -24,13 +24,7 @@ static const struct sdio_device_id sdio_ids[] = { SDIO_DEVICE(0x024c, 0xb723), }, { /* end: all zeroes */ }, }; -static const struct acpi_device_id acpi_ids[] = { - {"OBDA8723", 0x0000}, - {} -}; - MODULE_DEVICE_TABLE(sdio, sdio_ids); -MODULE_DEVICE_TABLE(acpi, acpi_ids); static int rtw_drv_init(struct sdio_func *func, const struct sdio_device_id *id); static void rtw_dev_remove(struct sdio_func *func); -- cgit v1.2.3-59-g8ed1b From 4845b3c8c8d221441605a1eff8aab7f1622dce93 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Fri, 8 Nov 2019 17:21:07 +0100 Subject: staging: most: configfs: move configfs subsystems to container struct This patch moves the declarations of the configfs subsystems to a superordinate container structure. This is done to get access to private subsystem data. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1573230068-27658-2-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/configfs.c | 80 +++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c index c06cf849c04d..c292dd306bb8 100644 --- a/drivers/staging/most/configfs.c +++ b/drivers/staging/most/configfs.c @@ -395,11 +395,12 @@ static const struct config_item_type mdev_link_type = { struct most_common { struct config_group group; + struct configfs_subsystem subsys; }; -static struct most_common *to_most_common(struct config_item *item) +static struct most_common *to_most_common(struct configfs_subsystem *subsys) { - return container_of(to_config_group(item), struct most_common, group); + return container_of(subsys, struct most_common, subsys); } static struct config_item *most_common_make_item(struct config_group *group, @@ -426,7 +427,9 @@ static struct config_item *most_common_make_item(struct config_group *group, static void most_common_release(struct config_item *item) { - kfree(to_most_common(item)); + struct config_group *group = to_config_group(item); + + kfree(to_most_common(group->cg_subsys)); } static struct configfs_item_operations most_common_item_ops = { @@ -443,29 +446,35 @@ static const struct config_item_type most_common_type = { .ct_owner = THIS_MODULE, }; -static struct configfs_subsystem most_cdev_subsys = { - .su_group = { - .cg_item = { - .ci_namebuf = "most_cdev", - .ci_type = &most_common_type, +static struct most_common most_cdev = { + .subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "most_cdev", + .ci_type = &most_common_type, + }, }, }, }; -static struct configfs_subsystem most_net_subsys = { - .su_group = { - .cg_item = { - .ci_namebuf = "most_net", - .ci_type = &most_common_type, +static struct most_common most_net = { + .subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "most_net", + .ci_type = &most_common_type, + }, }, }, }; -static struct configfs_subsystem most_video_subsys = { - .su_group = { - .cg_item = { - .ci_namebuf = "most_video", - .ci_type = &most_common_type, +static struct most_common most_video = { + .subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "most_video", + .ci_type = &most_common_type, + }, }, }, }; @@ -597,16 +606,17 @@ int most_register_configfs_subsys(struct core_component *c) { int ret; - if (!strcmp(c->name, "cdev")) - ret = configfs_register_subsystem(&most_cdev_subsys); - else if (!strcmp(c->name, "net")) - ret = configfs_register_subsystem(&most_net_subsys); - else if (!strcmp(c->name, "video")) - ret = configfs_register_subsystem(&most_video_subsys); - else if (!strcmp(c->name, "sound")) + if (!strcmp(c->name, "cdev")) { + ret = configfs_register_subsystem(&most_cdev.subsys); + } else if (!strcmp(c->name, "net")) { + ret = configfs_register_subsystem(&most_net.subsys); + } else if (!strcmp(c->name, "video")) { + ret = configfs_register_subsystem(&most_video.subsys); + } else if (!strcmp(c->name, "sound")) { ret = configfs_register_subsystem(&most_sound_subsys.subsys); - else + } else { return -ENODEV; + } if (ret) { pr_err("Error %d while registering subsystem %s\n", @@ -635,11 +645,11 @@ void most_interface_register_notify(const char *mdev) void most_deregister_configfs_subsys(struct core_component *c) { if (!strcmp(c->name, "cdev")) - configfs_unregister_subsystem(&most_cdev_subsys); + configfs_unregister_subsystem(&most_cdev.subsys); else if (!strcmp(c->name, "net")) - configfs_unregister_subsystem(&most_net_subsys); + configfs_unregister_subsystem(&most_net.subsys); else if (!strcmp(c->name, "video")) - configfs_unregister_subsystem(&most_video_subsys); + configfs_unregister_subsystem(&most_video.subsys); else if (!strcmp(c->name, "sound")) configfs_unregister_subsystem(&most_sound_subsys.subsys); } @@ -647,14 +657,14 @@ EXPORT_SYMBOL_GPL(most_deregister_configfs_subsys); int __init configfs_init(void) { - config_group_init(&most_cdev_subsys.su_group); - mutex_init(&most_cdev_subsys.su_mutex); + config_group_init(&most_cdev.subsys.su_group); + mutex_init(&most_cdev.subsys.su_mutex); - config_group_init(&most_net_subsys.su_group); - mutex_init(&most_net_subsys.su_mutex); + config_group_init(&most_net.subsys.su_group); + mutex_init(&most_net.subsys.su_mutex); - config_group_init(&most_video_subsys.su_group); - mutex_init(&most_video_subsys.su_mutex); + config_group_init(&most_video.subsys.su_group); + mutex_init(&most_video.subsys.su_mutex); config_group_init(&most_sound_subsys.subsys.su_group); mutex_init(&most_sound_subsys.subsys.su_mutex); -- cgit v1.2.3-59-g8ed1b From 08283d30744434d8f30d386622372e8f5b03bcf2 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Fri, 8 Nov 2019 17:21:08 +0100 Subject: staging: most: block module removal while having active configfs items This patch avoids that core component modules are being unloaded while the related configfs interface has active items in its directories. It is needed to prevent the situation where the core module cannot be unloaded anymore, because the reference count 'used by' indicates that the module is still being used and the usage count cannot be decreased by calling rmdir, as the configfs directory has already been removed. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1573230068-27658-3-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 1 + drivers/staging/most/configfs.c | 38 +++++++++++++++++++++++++++++++++++--- drivers/staging/most/core.h | 1 + drivers/staging/most/net/net.c | 1 + drivers/staging/most/sound/sound.c | 1 + drivers/staging/most/video/video.c | 1 + 6 files changed, 40 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index 724d098aeef0..f880147c82fd 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -494,6 +494,7 @@ err_remove_ida: static struct cdev_component comp = { .cc = { + .mod = THIS_MODULE, .name = "cdev", .probe_channel = comp_probe, .disconnect_channel = comp_disconnect_channel, diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c index c292dd306bb8..34a9fb53985c 100644 --- a/drivers/staging/most/configfs.c +++ b/drivers/staging/most/configfs.c @@ -395,6 +395,7 @@ static const struct config_item_type mdev_link_type = { struct most_common { struct config_group group; + struct module *mod; struct configfs_subsystem subsys; }; @@ -407,11 +408,16 @@ static struct config_item *most_common_make_item(struct config_group *group, const char *name) { struct mdev_link *mdev_link; + struct most_common *mc = to_most_common(group->cg_subsys); mdev_link = kzalloc(sizeof(*mdev_link), GFP_KERNEL); if (!mdev_link) return ERR_PTR(-ENOMEM); + if (!try_module_get(mc->mod)) { + kfree(mdev_link); + return ERR_PTR(-ENOLCK); + } config_item_init_type_name(&mdev_link->item, name, &mdev_link_type); @@ -436,8 +442,17 @@ static struct configfs_item_operations most_common_item_ops = { .release = most_common_release, }; +static void most_common_disconnect(struct config_group *group, + struct config_item *item) +{ + struct most_common *mc = to_most_common(group->cg_subsys); + + module_put(mc->mod); +} + static struct configfs_group_operations most_common_group_ops = { .make_item = most_common_make_item, + .disconnect_notify = most_common_disconnect, }; static const struct config_item_type most_common_type = { @@ -558,13 +573,14 @@ static const struct config_item_type most_snd_grp_type = { struct most_sound { struct configfs_subsystem subsys; struct list_head soundcard_list; + struct module *mod; }; static struct config_group *most_sound_make_group(struct config_group *group, const char *name) { struct most_snd_grp *most; - struct most_sound *ms = container_of(to_configfs_subsystem(group), + struct most_sound *ms = container_of(group->cg_subsys, struct most_sound, subsys); list_for_each_entry(most, &ms->soundcard_list, list) { @@ -573,17 +589,29 @@ static struct config_group *most_sound_make_group(struct config_group *group, return ERR_PTR(-EPROTO); } } + if (!try_module_get(ms->mod)) + return ERR_PTR(-ENOLCK); most = kzalloc(sizeof(*most), GFP_KERNEL); - if (!most) + if (!most) { + module_put(ms->mod); return ERR_PTR(-ENOMEM); - + } config_group_init_type_name(&most->group, name, &most_snd_grp_type); list_add_tail(&most->list, &ms->soundcard_list); return &most->group; } +static void most_sound_disconnect(struct config_group *group, + struct config_item *item) +{ + struct most_sound *ms = container_of(group->cg_subsys, + struct most_sound, subsys); + module_put(ms->mod); +} + static struct configfs_group_operations most_sound_group_ops = { .make_group = most_sound_make_group, + .disconnect_notify = most_sound_disconnect, }; static const struct config_item_type most_sound_type = { @@ -607,12 +635,16 @@ int most_register_configfs_subsys(struct core_component *c) int ret; if (!strcmp(c->name, "cdev")) { + most_cdev.mod = c->mod; ret = configfs_register_subsystem(&most_cdev.subsys); } else if (!strcmp(c->name, "net")) { + most_net.mod = c->mod; ret = configfs_register_subsystem(&most_net.subsys); } else if (!strcmp(c->name, "video")) { + most_video.mod = c->mod; ret = configfs_register_subsystem(&most_video.subsys); } else if (!strcmp(c->name, "sound")) { + most_sound_subsys.mod = c->mod; ret = configfs_register_subsystem(&most_sound_subsys.subsys); } else { return -ENODEV; diff --git a/drivers/staging/most/core.h b/drivers/staging/most/core.h index 652aaa771029..49859aef98df 100644 --- a/drivers/staging/most/core.h +++ b/drivers/staging/most/core.h @@ -265,6 +265,7 @@ struct most_interface { struct core_component { struct list_head list; const char *name; + struct module *mod; int (*probe_channel)(struct most_interface *iface, int channel_idx, struct most_channel_config *cfg, char *name, char *param); diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c index 26a31854c636..6cab1bb8956e 100644 --- a/drivers/staging/most/net/net.c +++ b/drivers/staging/most/net/net.c @@ -498,6 +498,7 @@ put_nd: } static struct core_component comp = { + .mod = THIS_MODULE, .name = "net", .probe_channel = comp_probe_channel, .disconnect_channel = comp_disconnect_channel, diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 79817061fcfa..1359f289ffd5 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -782,6 +782,7 @@ static int audio_tx_completion(struct most_interface *iface, int channel_id) * Initialization of the struct core_component */ static struct core_component comp = { + .mod = THIS_MODULE, .name = DRIVER_NAME, .probe_channel = audio_probe_channel, .disconnect_channel = audio_disconnect_channel, diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index 250af9fb704d..10c1ef7e3a3e 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -528,6 +528,7 @@ static int comp_disconnect_channel(struct most_interface *iface, } static struct core_component comp = { + .mod = THIS_MODULE, .name = "video", .probe_channel = comp_probe_channel, .disconnect_channel = comp_disconnect_channel, -- cgit v1.2.3-59-g8ed1b From e11898460e8908482d0e0a3c0e529ee9455cd376 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Fri, 8 Nov 2019 08:30:38 -0500 Subject: staging: rtl8723bs: Remove commented code This patch removes unnecessary commented code. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/1dfda6d22e4a972b9c91c6f56d2dc76603007626.1573219728.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 177 +----------------------------- 1 file changed, 2 insertions(+), 175 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index ab85abecfaaa..a4eec81a2fde 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -25,8 +25,6 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) spin_lock_init(&psta_xmitpriv->lock); - /* for (i = 0 ; i < MAX_NUMBLKS; i++) */ - /* _init_txservq(&(psta_xmitpriv->blk_q[i])); */ _init_txservq(&psta_xmitpriv->be_q); _init_txservq(&psta_xmitpriv->bk_q); @@ -54,8 +52,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->adapter = padapter; - /* for (i = 0 ; i < MAX_NUMBLKS; i++) */ - /* _rtw_init_queue(&pxmitpriv->blk_strms[i]); */ _rtw_init_queue(&pxmitpriv->be_pending); _rtw_init_queue(&pxmitpriv->bk_pending); @@ -63,8 +59,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) _rtw_init_queue(&pxmitpriv->vo_pending); _rtw_init_queue(&pxmitpriv->bm_pending); - /* _rtw_init_queue(&pxmitpriv->legacy_dz_queue); */ - /* _rtw_init_queue(&pxmitpriv->apsd_queue); */ _rtw_init_queue(&pxmitpriv->free_xmit_queue); @@ -83,8 +77,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) goto exit; } pxmitpriv->pxmit_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_frame_buf), 4); - /* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */ - /* ((SIZE_PTR) (pxmitpriv->pallocated_frame_buf) &3); */ pxframe = (struct xmit_frame *) pxmitpriv->pxmit_frame_buf; @@ -123,8 +115,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) } pxmitpriv->pxmitbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_xmitbuf), 4); - /* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */ - /* ((SIZE_PTR) (pxmitpriv->pallocated_xmitbuf) &3); */ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; @@ -489,11 +479,6 @@ static void update_attrib_phy_info(struct adapter *padapter, struct pkt_attrib * else pattrib->ampdu_spacing = psta->htpriv.rx_ampdu_min_spacing; - /* if (pattrib->ht_en && psta->htpriv.ampdu_enable) */ - /* */ - /* if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) */ - /* pattrib->ampdu_en = true; */ - /* */ pattrib->retry_ctrl = false; @@ -669,7 +654,6 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) /* get UserPriority from IP hdr */ if (pattrib->ether_type == 0x0800) { _rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); -/* UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ UserPriority = ip_hdr.tos >> 5; } pattrib->priority = UserPriority; @@ -818,7 +802,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib update_attrib_phy_info(padapter, pattrib, psta); - /* DBG_8192C("%s ==> mac_id(%d)\n", __func__, pattrib->mac_id); */ pattrib->psta = psta; /* TODO:_unlock */ @@ -857,7 +840,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr sint curfragnum, length; u8 *pframe, *payload, mic[8]; struct mic_data micdata; - /* struct sta_info *stainfo; */ struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -865,35 +847,11 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr u8 hw_hdr_offset = 0; sint bmcst = IS_MCAST(pattrib->ra); -/* - if (pattrib->psta) - { - stainfo = pattrib->psta; - } - else - { - DBG_871X("%s, call rtw_get_stainfo()\n", __func__); - stainfo =rtw_get_stainfo(&padapter->stapriv ,&pattrib->ra[0]); - } - - if (stainfo == NULL) - { - DBG_871X("%s, psta ==NUL\n", __func__); - return _FAIL; - } - - if (!(stainfo->state &_FW_LINKED)) - { - DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state); - return _FAIL; - } -*/ hw_hdr_offset = TXDESC_OFFSET; - if (pattrib->encrypt == _TKIP_) { /* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ + if (pattrib->encrypt == _TKIP_) { /* encode mic code */ - /* if (stainfo!= NULL) */ { u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; @@ -901,16 +859,12 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr if (bmcst) { if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) { - /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ - /* msleep(10); */ return _FAIL; } /* start to calculate the mic code */ rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { if (!memcmp(&pattrib->dot11tkiptxmickey.skey[0], null_key, 16)) { - /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ - /* msleep(10); */ return _FAIL; } /* start to calculate the mic code */ @@ -932,7 +886,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr } - /* if (pqospriv->qos_option == 1) */ if (pattrib->qos_en) priority[0] = (u8)pxmitframe->attrib.priority; @@ -978,9 +931,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr *(payload+curfragnum+4), *(payload+curfragnum+5), *(payload+curfragnum+6), *(payload+curfragnum+7))); } /* - else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo == NULL!!!\n")); - } */ } return _SUCCESS; @@ -990,11 +940,8 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi { struct pkt_attrib *pattrib = &pxmitframe->attrib; - /* struct security_priv *psecuritypriv =&padapter->securitypriv; */ - /* if ((psecuritypriv->sw_encrypt)||(pattrib->bswenc)) */ if (pattrib->bswenc) { - /* DBG_871X("start xmitframe_swencrypt\n"); */ RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); switch (pattrib->encrypt) { case _WEP40_: @@ -1131,14 +1078,12 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr /* check BA_starting_seqctrl */ if (SN_LESS(pattrib->seqnum, tx_seq)) { - /* DBG_871X("tx ampdu seqnum(%d) < tx_seq(%d)\n", pattrib->seqnum, tx_seq); */ pattrib->ampdu_en = false;/* AGG BK */ } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; pattrib->ampdu_en = true;/* AGG EN */ } else { - /* DBG_871X("tx ampdu over run\n"); */ psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; pattrib->ampdu_en = true;/* AGG EN */ } @@ -1206,9 +1151,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram u8 *pframe, *mem_start; u8 hw_hdr_offset; - /* struct sta_info *psta; */ - /* struct sta_priv *pstapriv = &padapter->stapriv; */ - /* struct mlme_priv *pmlmepriv = &padapter->mlmepriv; */ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; @@ -1218,30 +1160,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram s32 bmcst = IS_MCAST(pattrib->ra); s32 res = _SUCCESS; -/* - if (pattrib->psta) - { - psta = pattrib->psta; - } else - { - DBG_871X("%s, call rtw_get_stainfo()\n", __func__); - psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - } - - if (psta == NULL) - { - - DBG_871X("%s, psta ==NUL\n", __func__); - return _FAIL; - } - - - if (!(psta->state &_FW_LINKED)) - { - DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); - return _FAIL; - } -*/ if (!pxmitframe->buf_addr) { DBG_8192C("==> %s buf_addr == NULL\n", __func__); return _FAIL; @@ -1455,7 +1373,6 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit goto xmitframe_coalesce_fail; } - /* DBG_871X("%s, action frame category =%d\n", __func__, pframe[WLAN_HDR_A3_LEN]); */ /* according 802.11-2012 standard, these five types are not robust types */ if (subtype == WIFI_ACTION && (pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_PUBLIC || @@ -1750,7 +1667,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) struct list_head *plist, *phead; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; - /* DBG_871X("+rtw_alloc_xmitbuf\n"); */ spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL); @@ -1772,7 +1688,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) #ifdef DBG_XMIT_BUF DBG_871X("DBG_XMIT_BUF ALLOC no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt); #endif - /* DBG_871X("alloc, free_xmitbuf_cnt =%d\n", pxmitpriv->free_xmitbuf_cnt); */ pxmitbuf->priv_data = NULL; @@ -1801,7 +1716,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) _irqL irqL; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; - /* DBG_871X("+rtw_free_xmitbuf\n"); */ if (!pxmitbuf) return _FAIL; @@ -1823,7 +1737,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) get_list_head(pfree_xmitbuf_queue)); pxmitpriv->free_xmitbuf_cnt++; - /* DBG_871X("FREE, free_xmitbuf_cnt =%d\n", pxmitpriv->free_xmitbuf_cnt); */ #ifdef DBG_XMIT_BUF DBG_871X("DBG_XMIT_BUF FREE no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt); #endif @@ -1839,7 +1752,6 @@ static void rtw_init_xmitframe(struct xmit_frame *pxframe) pxframe->pxmitbuf = NULL; memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); - /* pxframe->attrib.psta = NULL; */ pxframe->frame_tag = DATA_FRAMETAG; @@ -2034,7 +1946,6 @@ s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitfram if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n")); -/* pxmitframe->pkt = NULL; */ return _FAIL; } @@ -2086,7 +1997,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * */ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) { - /* _irqL irqL0; */ u8 ac_index; struct sta_info *psta; struct tx_servq *ptxservq; @@ -2096,14 +2006,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class); -/* - if (pattrib->psta) { - psta = pattrib->psta; - } else { - DBG_871X("%s, call rtw_get_stainfo()\n", __func__); - psta = rtw_get_stainfo(pstapriv, pattrib->ra); - } -*/ psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); if (pattrib->psta != psta) { @@ -2128,21 +2030,17 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); - /* spin_lock_irqsave(&pstapending->lock, irqL0); */ if (list_empty(&ptxservq->tx_pending)) { list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); } - /* spin_lock_irqsave(&ptxservq->sta_pending.lock, irqL1); */ list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); ptxservq->qcnt++; phwxmits[ac_index].accnt++; - /* spin_unlock_irqrestore(&ptxservq->sta_pending.lock, irqL1); */ - /* spin_unlock_irqrestore(&pstapending->lock, irqL0); */ exit: @@ -2166,42 +2064,24 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter) hwxmits = pxmitpriv->hwxmits; if (pxmitpriv->hwxmit_entry == 5) { - /* pxmitpriv->bmc_txqueue.head = 0; */ - /* hwxmits[0] .phwtxqueue = &pxmitpriv->bmc_txqueue; */ hwxmits[0] .sta_queue = &pxmitpriv->bm_pending; - /* pxmitpriv->vo_txqueue.head = 0; */ - /* hwxmits[1] .phwtxqueue = &pxmitpriv->vo_txqueue; */ hwxmits[1] .sta_queue = &pxmitpriv->vo_pending; - /* pxmitpriv->vi_txqueue.head = 0; */ - /* hwxmits[2] .phwtxqueue = &pxmitpriv->vi_txqueue; */ hwxmits[2] .sta_queue = &pxmitpriv->vi_pending; - /* pxmitpriv->bk_txqueue.head = 0; */ - /* hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue; */ hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; - /* pxmitpriv->be_txqueue.head = 0; */ - /* hwxmits[4] .phwtxqueue = &pxmitpriv->be_txqueue; */ hwxmits[4] .sta_queue = &pxmitpriv->be_pending; } else if (pxmitpriv->hwxmit_entry == 4) { - /* pxmitpriv->vo_txqueue.head = 0; */ - /* hwxmits[0] .phwtxqueue = &pxmitpriv->vo_txqueue; */ hwxmits[0] .sta_queue = &pxmitpriv->vo_pending; - /* pxmitpriv->vi_txqueue.head = 0; */ - /* hwxmits[1] .phwtxqueue = &pxmitpriv->vi_txqueue; */ hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; - /* pxmitpriv->be_txqueue.head = 0; */ - /* hwxmits[2] .phwtxqueue = &pxmitpriv->be_txqueue; */ hwxmits[2] .sta_queue = &pxmitpriv->be_pending; - /* pxmitpriv->bk_txqueue.head = 0; */ - /* hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue; */ hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; } else { @@ -2222,9 +2102,6 @@ void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry) sint i; for (i = 0; i < entry; i++, phwxmit++) { - /* spin_lock_init(&phwxmit->xmit_lock); */ - /* INIT_LIST_HEAD(&phwxmit->pending); */ - /* phwxmit->txcmdcnt = 0; */ phwxmit->accnt = 0; } } @@ -2391,17 +2268,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_fwstate); return ret; } -/* - if (pattrib->psta) - { - psta = pattrib->psta; - } - else - { - DBG_871X("%s, call rtw_get_stainfo()\n", __func__); - psta =rtw_get_stainfo(pstapriv, pattrib->ra); - } -*/ psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); if (pattrib->psta != psta) { DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_sta); @@ -2423,9 +2289,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr if (pattrib->triggered == 1) { DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_trigger); - /* DBG_871X("directly xmit pspoll_triggered packet\n"); */ - /* pattrib->triggered = 0; */ if (bmcst && xmitframe_hiq_filter(pxmitframe)) pattrib->qsel = 0x11;/* HIQ */ @@ -2441,7 +2305,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr list_del_init(&pxmitframe->list); - /* spin_lock_bh(&psta->sleep_q.lock); */ list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); @@ -2450,10 +2313,9 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr if (!(pstapriv->tim_bitmap & BIT(0))) update_tim = true; - pstapriv->tim_bitmap |= BIT(0);/* */ + pstapriv->tim_bitmap |= BIT(0); pstapriv->sta_dz_bitmap |= BIT(0); - /* DBG_871X("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ if (update_tim) { update_beacon(padapter, _TIM_IE_, NULL, true); @@ -2461,7 +2323,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr chk_bmc_sleepq_cmd(padapter); } - /* spin_unlock_bh(&psta->sleep_q.lock); */ ret = true; @@ -2484,7 +2345,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) { list_del_init(&pxmitframe->list); - /* spin_lock_bh(&psta->sleep_q.lock); */ list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); @@ -2519,20 +2379,13 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr pstapriv->tim_bitmap |= BIT(psta->aid); - /* DBG_871X("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ if (update_tim) - /* DBG_871X("sleepq_len == 1, update BCNTIM\n"); */ /* upate BCN for TIM IE */ update_beacon(padapter, _TIM_IE_, NULL, true); } - /* spin_unlock_bh(&psta->sleep_q.lock); */ - /* if (psta->sleepq_len > (NR_XMITFRAME>>3)) */ - /* */ - /* wakeup_sta_to_xmit(padapter, psta); */ - /* */ ret = true; @@ -2577,7 +2430,6 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc ptxservq->qcnt--; phwxmits[ac_index].accnt--; } else { - /* DBG_871X("xmitframe_enqueue_for_sleeping_sta return false\n"); */ } } @@ -2640,7 +2492,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) psta_bmc = rtw_get_bcmc_stainfo(padapter); - /* spin_lock_bh(&psta->sleep_q.lock); */ spin_lock_bh(&pxmitpriv->lock); xmitframe_phead = get_list_head(&psta->sleep_q); @@ -2699,9 +2550,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) if (psta->sleepq_len == 0) { if (pstapriv->tim_bitmap & BIT(psta->aid)) { - /* DBG_871X("wakeup to xmit, qlen == 0, update_BCNTIM, tim =%x\n", pstapriv->tim_bitmap); */ - /* upate BCN for TIM IE */ - /* update_BCNTIM(padapter); */ update_mask = BIT(0); } @@ -2742,24 +2590,12 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; -/* - spin_unlock_bh(&psta_bmc->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe) == true) - { - rtw_os_xmit_complete(padapter, pxmitframe); - } - spin_lock_bh(&psta_bmc->sleep_q.lock); - -*/ rtw_hal_xmitframe_enqueue(padapter, pxmitframe); } if (psta_bmc->sleepq_len == 0) { if (pstapriv->tim_bitmap & BIT(0)) { - /* DBG_871X("wakeup to xmit, qlen == 0, update_BCNTIM, tim =%x\n", pstapriv->tim_bitmap); */ - /* upate BCN for TIM IE */ - /* update_BCNTIM(padapter); */ update_mask |= BIT(1); } pstapriv->tim_bitmap &= ~BIT(0); @@ -2770,12 +2606,9 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) _exit: - /* spin_unlock_bh(&psta_bmc->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); if (update_mask) - /* update_BCNTIM(padapter); */ - /* printk("%s => call update_beacon\n", __func__); */ update_beacon(padapter, _TIM_IE_, NULL, true); } @@ -2789,7 +2622,6 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - /* spin_lock_bh(&psta->sleep_q.lock); */ spin_lock_bh(&pxmitpriv->lock); xmitframe_phead = get_list_head(&psta->sleep_q); @@ -2842,16 +2674,11 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { pstapriv->tim_bitmap &= ~BIT(psta->aid); - /* DBG_871X("wakeup to xmit, qlen == 0, update_BCNTIM, tim =%x\n", pstapriv->tim_bitmap); */ - /* upate BCN for TIM IE */ - /* update_BCNTIM(padapter); */ update_beacon(padapter, _TIM_IE_, NULL, true); - /* update_mask = BIT(0); */ } } - /* spin_unlock_bh(&psta->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); } -- cgit v1.2.3-59-g8ed1b From af96ce03218eead79f8925e6fe21dd93863affbd Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 12 Nov 2019 14:40:36 +0100 Subject: staging: most: core: add comments to mutex and spinlock definitions This patch adds a comment to the start_mutex and fifo_lock fields of the most_channel structure definition. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1573566036-2279-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c index f7d2c7850cf5..79e66eb396b8 100644 --- a/drivers/staging/most/core.c +++ b/drivers/staging/most/core.c @@ -52,7 +52,7 @@ struct most_channel { u16 channel_id; char name[STRING_SIZE]; bool is_poisoned; - struct mutex start_mutex; + struct mutex start_mutex; /* channel activation synchronization */ struct mutex nq_mutex; /* nq thread synchronization */ int is_starving; struct most_interface *iface; @@ -60,7 +60,7 @@ struct most_channel { bool keep_mbo; bool enqueue_halt; struct list_head fifo; - spinlock_t fifo_lock; + spinlock_t fifo_lock; /* fifo access synchronization */ struct list_head halt_fifo; struct list_head list; struct pipe pipe0; -- cgit v1.2.3-59-g8ed1b From c3cc574f2bcd6185f78302ffbd21120b04b22028 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 12 Nov 2019 11:53:01 -0500 Subject: staging: rtl8723bs: Remove multiple blank lines This patch removes multiple blank lines to solve the warning found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/257b08ad13aa23c2ee53fc333ea3c3f7e3105791.1573577309.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 51 ------------------------------- 1 file changed, 51 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index a4eec81a2fde..e10e2d74cffd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -25,7 +25,6 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) spin_lock_init(&psta_xmitpriv->lock); - _init_txservq(&psta_xmitpriv->be_q); _init_txservq(&psta_xmitpriv->bk_q); _init_txservq(&psta_xmitpriv->vi_q); @@ -52,14 +51,12 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->adapter = padapter; - _rtw_init_queue(&pxmitpriv->be_pending); _rtw_init_queue(&pxmitpriv->bk_pending); _rtw_init_queue(&pxmitpriv->vi_pending); _rtw_init_queue(&pxmitpriv->vo_pending); _rtw_init_queue(&pxmitpriv->bm_pending); - _rtw_init_queue(&pxmitpriv->free_xmit_queue); /* @@ -101,7 +98,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; - /* init xmit_buf */ _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); @@ -300,7 +296,6 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) if (pxmitpriv->pallocated_frame_buf) vfree(pxmitpriv->pallocated_frame_buf); - if (pxmitpriv->pallocated_xmitbuf) vfree(pxmitpriv->pallocated_xmitbuf); @@ -398,7 +393,6 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * break; } - /* check ERP protection */ if (pattrib->rtsen || pattrib->cts2self) { if (pattrib->rtsen) @@ -479,8 +473,6 @@ static void update_attrib_phy_info(struct adapter *padapter, struct pkt_attrib * else pattrib->ampdu_spacing = psta->htpriv.rx_ampdu_min_spacing; - - pattrib->retry_ctrl = false; #ifdef CONFIG_AUTO_AP_MODE @@ -565,7 +557,6 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p else TKIP_IV(pattrib->iv, psta->dot11txpn, 0); - memcpy(pattrib->dot11tkiptxmickey.skey, psta->dot11tkiptxmickey.skey, 16); break; @@ -647,7 +638,6 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) struct iphdr ip_hdr; s32 UserPriority = 0; - _rtw_open_pktfile(ppktfile->pkt, ppktfile); _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); @@ -680,11 +670,9 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib pattrib->ether_type = ntohs(etherhdr.h_proto); - memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); @@ -736,7 +724,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib } } - } else if (0x888e == pattrib->ether_type) { DBG_871X_LEVEL(_drv_always_, "send eapol packet\n"); } @@ -791,8 +778,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib return _FAIL; } - - /* TODO:_lock */ if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) { DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_sec); @@ -802,7 +787,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib update_attrib_phy_info(padapter, pattrib, psta); - pattrib->psta = psta; /* TODO:_unlock */ @@ -847,7 +831,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr u8 hw_hdr_offset = 0; sint bmcst = IS_MCAST(pattrib->ra); - hw_hdr_offset = TXDESC_OFFSET; if (pattrib->encrypt == _TKIP_) { @@ -889,7 +872,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr if (pattrib->qos_en) priority[0] = (u8)pxmitframe->attrib.priority; - rtw_secmicappend(&micdata, &priority[0], 4); payload = pframe; @@ -1056,7 +1038,6 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr return _FAIL; } - if (psta) { psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; @@ -1069,7 +1050,6 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) pattrib->ampdu_en = true; - /* re-check if enable ampdu by BA_starting_seqctrl */ if (pattrib->ampdu_en == true) { u16 tx_seq; @@ -1218,7 +1198,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram mpdu_len -= pattrib->icv_len; } - if (bmcst) { /* don't do fragment to broadcat/multicast packets */ mem_sz = _rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen); @@ -1618,7 +1597,6 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) DBG_871X("DBG_XMIT_BUF_EXT ALLOC no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt); #endif - pxmitbuf->priv_data = NULL; pxmitbuf->len = 0; @@ -1667,7 +1645,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) struct list_head *plist, *phead; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; - spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL); if (list_empty(&pfree_xmitbuf_queue->queue)) { @@ -1716,7 +1693,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) _irqL irqL; struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; - if (!pxmitbuf) return _FAIL; @@ -2006,7 +1982,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class); - psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); if (pattrib->psta != psta) { DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_sta); @@ -2030,18 +2005,14 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); - if (list_empty(&ptxservq->tx_pending)) { list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); } - list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); ptxservq->qcnt++; phwxmits[ac_index].accnt++; - - exit: return res; @@ -2296,7 +2267,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr return ret; } - if (bmcst) { spin_lock_bh(&psta->sleep_q.lock); @@ -2305,7 +2275,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr list_del_init(&pxmitframe->list); - list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); psta->sleepq_len++; @@ -2316,14 +2285,12 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr pstapriv->tim_bitmap |= BIT(0); pstapriv->sta_dz_bitmap |= BIT(0); - if (update_tim) { update_beacon(padapter, _TIM_IE_, NULL, true); } else { chk_bmc_sleepq_cmd(padapter); } - ret = true; DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_mcast); @@ -2336,7 +2303,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr } - spin_lock_bh(&psta->sleep_q.lock); if (psta->state&WIFI_SLEEP_STATE) { @@ -2345,7 +2311,6 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) { list_del_init(&pxmitframe->list); - list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); psta->sleepq_len++; @@ -2379,14 +2344,11 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr pstapriv->tim_bitmap |= BIT(psta->aid); - if (update_tim) /* upate BCN for TIM IE */ update_beacon(padapter, _TIM_IE_, NULL, true); } - - ret = true; DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_ucast); @@ -2448,27 +2410,21 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) /* for BC/MC Frames */ psta_bmc = rtw_get_bcmc_stainfo(padapter); - spin_lock_bh(&pxmitpriv->lock); psta->state |= WIFI_SLEEP_STATE; pstapriv->sta_dz_bitmap |= BIT(psta->aid); - - dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); list_del_init(&pstaxmitpriv->vo_q.tx_pending); - dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); list_del_init(&pstaxmitpriv->vi_q.tx_pending); - dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); list_del_init(&pstaxmitpriv->be_q.tx_pending); - dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); list_del_init(&pstaxmitpriv->bk_q.tx_pending); @@ -2491,7 +2447,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) psta_bmc = rtw_get_bcmc_stainfo(padapter); - spin_lock_bh(&pxmitpriv->lock); xmitframe_phead = get_list_head(&psta->sleep_q); @@ -2545,7 +2500,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) rtw_hal_xmitframe_enqueue(padapter, pxmitframe); - } if (psta->sleepq_len == 0) { @@ -2588,7 +2542,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) else pxmitframe->attrib.mdata = 0; - pxmitframe->attrib.triggered = 1; rtw_hal_xmitframe_enqueue(padapter, pxmitframe); @@ -2621,7 +2574,6 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst struct sta_priv *pstapriv = &padapter->stapriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - spin_lock_bh(&pxmitpriv->lock); xmitframe_phead = get_list_head(&psta->sleep_q); @@ -2719,7 +2671,6 @@ struct xmit_buf *dequeue_pending_xmitbuf( struct xmit_buf *pxmitbuf; struct __queue *pqueue; - pxmitbuf = NULL; pqueue = &pxmitpriv->pending_xmitbuf_queue; @@ -2745,7 +2696,6 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey( struct xmit_buf *pxmitbuf; struct __queue *pqueue; - pxmitbuf = NULL; pqueue = &pxmitpriv->pending_xmitbuf_queue; @@ -2804,7 +2754,6 @@ int rtw_xmit_thread(void *context) s32 err; struct adapter *padapter; - err = _SUCCESS; padapter = context; -- cgit v1.2.3-59-g8ed1b From 839e18aa1ef6d0098ceb3ca69972faadbc6dc79b Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 12 Nov 2019 11:53:28 -0500 Subject: staging: rtl8723bs: Remove blank lines before a close brace This patch removes blank lines before a close brase. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/369fa1068078d98d658fe5e8fc335df1b22f5238.1573577309.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 35 ------------------------------- 1 file changed, 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index e10e2d74cffd..7f88f433345d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -144,7 +144,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) #endif pxmitbuf++; - } pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; @@ -222,7 +221,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->no = i; #endif pxmitbuf++; - } pxmitpriv->free_xmit_extbuf_cnt = NR_XMIT_EXTBUFF; @@ -479,7 +477,6 @@ static void update_attrib_phy_info(struct adapter *padapter, struct pkt_attrib * if (psta->isrc && psta->pid > 0) pattrib->pctrl = true; #endif - } static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *pattrib, struct sta_info *psta) @@ -529,7 +526,6 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p /* For WPS 1.0 WEP, driver should not encrypt EAPOL Packet for WPS handshake. */ if (((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) && (pattrib->ether_type == 0x888e)) pattrib->encrypt = _NO_PRIVACY_; - } switch (pattrib->encrypt) { @@ -600,7 +596,6 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p exit: return res; - } u8 qos_acm(u8 acm_mask, u8 priority) @@ -723,7 +718,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_icmp); } } - } else if (0x888e == pattrib->ether_type) { DBG_871X_LEVEL(_drv_always_, "send eapol packet\n"); } @@ -809,7 +803,6 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib if (pmlmepriv->acm_mask != 0) pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority); - } } @@ -866,7 +859,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr rtw_secmicappend(&micdata, &pframe[16], 6); else rtw_secmicappend(&micdata, &pframe[10], 6); - } if (pattrib->qos_en) @@ -939,7 +931,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi default: break; } - } else RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); @@ -976,7 +967,6 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr if (pqospriv->qos_option) qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { /* to_ds = 0, fr_ds = 1; */ SetFrDs(fctrl); @@ -1067,13 +1057,10 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; pattrib->ampdu_en = true;/* AGG EN */ } - } } } - } else { - } exit: @@ -1230,7 +1217,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset; memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); - } if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { @@ -1482,7 +1468,6 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) } break; - } } @@ -1566,7 +1551,6 @@ struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv, pxmitbuf->priv_data = pcmdframe; return pcmdframe; - } struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) @@ -1607,7 +1591,6 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__); rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); } - } spin_unlock_irqrestore(&pfree_queue->lock, irqL); @@ -1867,7 +1850,6 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram else if (pxmitframe->ext_tag == 1) queue = &pxmitpriv->free_xframe_ext_queue; else { - } spin_lock_bh(&queue->lock); @@ -1911,7 +1893,6 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram plist = get_next(plist); rtw_free_xmitframe(pxmitpriv, pxmitframe); - } spin_unlock_bh(&pframequeue->lock); } @@ -1961,7 +1942,6 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * *(ac) = 2; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); break; - } return ptxservq; @@ -2044,7 +2024,6 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter) hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; hwxmits[4] .sta_queue = &pxmitpriv->be_pending; - } else if (pxmitpriv->hwxmit_entry == 4) { hwxmits[0] .sta_queue = &pxmitpriv->vo_pending; @@ -2055,7 +2034,6 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter) hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; } else { - } return _SUCCESS; @@ -2109,11 +2087,9 @@ u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) default: addr = MGT_QUEUE_INX; break; - } return addr; - } static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib) @@ -2294,13 +2270,11 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr ret = true; DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_mcast); - } spin_unlock_bh(&psta->sleep_q.lock); return ret; - } spin_lock_bh(&psta->sleep_q.lock); @@ -2353,13 +2327,11 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_ucast); } - } spin_unlock_bh(&psta->sleep_q.lock); return ret; - } static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue) @@ -2393,9 +2365,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc phwxmits[ac_index].accnt--; } else { } - } - } void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) @@ -2499,7 +2469,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; rtw_hal_xmitframe_enqueue(padapter, pxmitframe); - } if (psta->sleepq_len == 0) { @@ -2544,7 +2513,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pxmitframe->attrib.triggered = 1; rtw_hal_xmitframe_enqueue(padapter, pxmitframe); - } if (psta_bmc->sleepq_len == 0) { @@ -2554,7 +2522,6 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) pstapriv->tim_bitmap &= ~BIT(0); pstapriv->sta_dz_bitmap &= ~BIT(0); } - } _exit: @@ -2563,7 +2530,6 @@ _exit: if (update_mask) update_beacon(padapter, _TIM_IE_, NULL, true); - } void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) @@ -2628,7 +2594,6 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst update_beacon(padapter, _TIM_IE_, NULL, true); } - } spin_unlock_bh(&pxmitpriv->lock); -- cgit v1.2.3-59-g8ed1b From 309e05f5f91f63b0ee387b2bf4d595cef25ad76d Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 12 Nov 2019 11:53:53 -0500 Subject: staging: rtl8723bs: Remove blank lines after an open brace This patch removes blank lines after an open brace. Issue found by checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/847ce59f8429afaac1299794987779d0db54d0be.1573577309.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 7f88f433345d..60e639690fc3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -912,7 +912,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { - struct pkt_attrib *pattrib = &pxmitframe->attrib; if (pattrib->bswenc) { @@ -1328,7 +1327,6 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); if (!psta) { - DBG_871X("%s, psta ==NUL\n", __func__); goto xmitframe_coalesce_fail; } @@ -1436,7 +1434,6 @@ s32 rtw_put_snap(u8 *data, u16 h_proto) void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) { - uint protection; u8 *perp; sint erp_len; @@ -1565,7 +1562,6 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) if (list_empty(&pfree_queue->queue)) { pxmitbuf = NULL; } else { - phead = get_list_head(pfree_queue); plist = get_next(phead); @@ -1633,7 +1629,6 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) if (list_empty(&pfree_xmitbuf_queue->queue)) { pxmitbuf = NULL; } else { - phead = get_list_head(pfree_xmitbuf_queue); plist = get_next(phead); @@ -1887,7 +1882,6 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram plist = get_next(phead); while (phead != plist) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); plist = get_next(plist); @@ -2025,7 +2019,6 @@ s32 rtw_alloc_hwxmits(struct adapter *padapter) hwxmits[4] .sta_queue = &pxmitpriv->be_pending; } else if (pxmitpriv->hwxmit_entry == 4) { - hwxmits[0] .sta_queue = &pxmitpriv->vo_pending; hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; @@ -2181,7 +2174,6 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe) struct registry_priv *registry = &adapter->registrypriv; if (registry->hiq_filter == RTW_HIQ_FILTER_ALLOW_SPECIAL) { - struct pkt_attrib *attrib = &xmitframe->attrib; if (attrib->ether_type == 0x0806 -- cgit v1.2.3-59-g8ed1b From 7db57ca4b1340ca8cc3cf864d5e1acdb66919ab4 Mon Sep 17 00:00:00 2001 From: "Javier F. Arias" Date: Tue, 12 Nov 2019 11:54:11 -0500 Subject: staging: rtl8723bs: Remove unnecessary braces This patch removes unnecessary braces on single statement blocks or that aren't necessary in any arm of the statement. Issue found by Checkpatch. Signed-off-by: Javier F. Arias Link: https://lore.kernel.org/r/041503946a1c58111e69579838b184359745d8c1.1573577309.git.jarias.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 33 +++++++++++-------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 60e639690fc3..fdb585ff5925 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -253,9 +253,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) goto exit; rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) pxmitpriv->wmm_para_seq[i] = i; - } pxmitpriv->ack_tx = false; mutex_init(&pxmitpriv->ack_tx_mutex); @@ -316,9 +315,8 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_xmit_extbuf) { + if (pxmitpriv->pallocated_xmit_extbuf) vfree(pxmitpriv->pallocated_xmit_extbuf); - } for (i = 0; i < CMDBUF_MAX; i++) { pxmitbuf = &pxmitpriv->pcmd_xmitbuf[i]; @@ -834,15 +832,13 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr pframe = pxmitframe->buf_addr + hw_hdr_offset; if (bmcst) { - if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) { + if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) return _FAIL; - } /* start to calculate the mic code */ rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { - if (!memcmp(&pattrib->dot11tkiptxmickey.skey[0], null_key, 16)) { + if (!memcmp(&pattrib->dot11tkiptxmickey.skey[0], null_key, 16)) return _FAIL; - } /* start to calculate the mic code */ rtw_secmicsetkey(&micdata, &pattrib->dot11tkiptxmickey.skey[0]); } @@ -1180,9 +1176,8 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram mpdu_len -= llc_sz; } - if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + if ((pattrib->icv_len > 0) && (pattrib->bswenc)) mpdu_len -= pattrib->icv_len; - } if (bmcst) { /* don't do fragment to broadcat/multicast packets */ @@ -1979,9 +1974,8 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); - if (list_empty(&ptxservq->tx_pending)) { + if (list_empty(&ptxservq->tx_pending)) list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); - } list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); ptxservq->qcnt++; @@ -2043,9 +2037,8 @@ void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry) { sint i; - for (i = 0; i < entry; i++, phwxmit++) { + for (i = 0; i < entry; i++, phwxmit++) phwxmit->accnt = 0; - } } u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) @@ -2253,11 +2246,10 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr pstapriv->tim_bitmap |= BIT(0); pstapriv->sta_dz_bitmap |= BIT(0); - if (update_tim) { + if (update_tim) update_beacon(padapter, _TIM_IE_, NULL, true); - } else { + else chk_bmc_sleepq_cmd(padapter); - } ret = true; @@ -2464,9 +2456,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) } if (psta->sleepq_len == 0) { - if (pstapriv->tim_bitmap & BIT(psta->aid)) { + if (pstapriv->tim_bitmap & BIT(psta->aid)) update_mask = BIT(0); - } pstapriv->tim_bitmap &= ~BIT(psta->aid); @@ -2508,9 +2499,9 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) } if (psta_bmc->sleepq_len == 0) { - if (pstapriv->tim_bitmap & BIT(0)) { + if (pstapriv->tim_bitmap & BIT(0)) update_mask |= BIT(1); - } + pstapriv->tim_bitmap &= ~BIT(0); pstapriv->sta_dz_bitmap &= ~BIT(0); } -- cgit v1.2.3-59-g8ed1b From c5e648f8574d4644fe3efd46c4d34b5fceea2781 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Mon, 11 Nov 2019 18:50:55 +0200 Subject: staging: dpaa2-ethsw: move port notifier per ethsw Register a different net_device notifier block per ethsw instance. When probing multiple dpaa2-ethsw instances, without this the register will fail. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/1573491058-24766-2-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 13 ++++++------- drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 14a9eebf687e..b25520173fec 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1174,10 +1174,6 @@ static int port_netdevice_event(struct notifier_block *unused, return notifier_from_errno(err); } -static struct notifier_block port_nb __read_mostly = { - .notifier_call = port_netdevice_event, -}; - struct ethsw_switchdev_event_work { struct work_struct work; struct switchdev_notifier_fdb_info fdb_info; @@ -1328,9 +1324,11 @@ static struct notifier_block port_switchdev_blocking_nb = { static int ethsw_register_notifier(struct device *dev) { + struct ethsw_core *ethsw = dev_get_drvdata(dev); int err; - err = register_netdevice_notifier(&port_nb); + ethsw->port_nb.notifier_call = port_netdevice_event; + err = register_netdevice_notifier(ðsw->port_nb); if (err) { dev_err(dev, "Failed to register netdev notifier\n"); return err; @@ -1353,7 +1351,7 @@ static int ethsw_register_notifier(struct device *dev) err_switchdev_blocking_nb: unregister_switchdev_notifier(&port_switchdev_nb); err_switchdev_nb: - unregister_netdevice_notifier(&port_nb); + unregister_netdevice_notifier(ðsw->port_nb); return err; } @@ -1491,6 +1489,7 @@ static int ethsw_port_init(struct ethsw_port_priv *port_priv, u16 port) static void ethsw_unregister_notifier(struct device *dev) { + struct ethsw_core *ethsw = dev_get_drvdata(dev); struct notifier_block *nb; int err; @@ -1505,7 +1504,7 @@ static void ethsw_unregister_notifier(struct device *dev) dev_err(dev, "Failed to unregister switchdev notifier (%d)\n", err); - err = unregister_netdevice_notifier(&port_nb); + err = unregister_netdevice_notifier(ðsw->port_nb); if (err) dev_err(dev, "Failed to unregister netdev notifier (%d)\n", err); diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index 3ea8a0ad8c10..39a3f542c8ee 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -66,6 +66,8 @@ struct ethsw_core { u8 vlans[VLAN_VID_MASK + 1]; bool learning; + + struct notifier_block port_nb; }; #endif /* __ETHSW_H */ -- cgit v1.2.3-59-g8ed1b From a3c6345e9f04510bcca88f0faefbcd2399dbca47 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Mon, 11 Nov 2019 18:50:56 +0200 Subject: staging: dpaa2-ethsw: move port switchdev notifier per ethsw Register a different switchdev notifier block per ethsw instance. When probing multiple dpaa2-ethsw instances, without this the register will fail. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/1573491058-24766-3-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 11 ++++------- drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index b25520173fec..abbfcbf81241 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1314,10 +1314,6 @@ static int port_switchdev_blocking_event(struct notifier_block *unused, return NOTIFY_DONE; } -static struct notifier_block port_switchdev_nb = { - .notifier_call = port_switchdev_event, -}; - static struct notifier_block port_switchdev_blocking_nb = { .notifier_call = port_switchdev_blocking_event, }; @@ -1334,7 +1330,8 @@ static int ethsw_register_notifier(struct device *dev) return err; } - err = register_switchdev_notifier(&port_switchdev_nb); + ethsw->port_switchdev_nb.notifier_call = port_switchdev_event; + err = register_switchdev_notifier(ðsw->port_switchdev_nb); if (err) { dev_err(dev, "Failed to register switchdev notifier\n"); goto err_switchdev_nb; @@ -1349,7 +1346,7 @@ static int ethsw_register_notifier(struct device *dev) return 0; err_switchdev_blocking_nb: - unregister_switchdev_notifier(&port_switchdev_nb); + unregister_switchdev_notifier(ðsw->port_switchdev_nb); err_switchdev_nb: unregister_netdevice_notifier(ðsw->port_nb); return err; @@ -1499,7 +1496,7 @@ static void ethsw_unregister_notifier(struct device *dev) dev_err(dev, "Failed to unregister switchdev blocking notifier (%d)\n", err); - err = unregister_switchdev_notifier(&port_switchdev_nb); + err = unregister_switchdev_notifier(ðsw->port_switchdev_nb); if (err) dev_err(dev, "Failed to unregister switchdev notifier (%d)\n", err); diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index 39a3f542c8ee..e050589758b1 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -68,6 +68,7 @@ struct ethsw_core { bool learning; struct notifier_block port_nb; + struct notifier_block port_switchdev_nb; }; #endif /* __ETHSW_H */ -- cgit v1.2.3-59-g8ed1b From 910f30917cdffedff5663f5ac451424bd7176ce7 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Mon, 11 Nov 2019 18:50:57 +0200 Subject: staging: dpaa2-ethsw: move port switchdev blocking notifier per ethsw Register a different switchdev blocking notifier block per ethsw instance. When probing multiple dpaa2-ethsw instances, without this the register will fail. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/1573491058-24766-4-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 9 +++------ drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index abbfcbf81241..37ee9b0aa326 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1314,10 +1314,6 @@ static int port_switchdev_blocking_event(struct notifier_block *unused, return NOTIFY_DONE; } -static struct notifier_block port_switchdev_blocking_nb = { - .notifier_call = port_switchdev_blocking_event, -}; - static int ethsw_register_notifier(struct device *dev) { struct ethsw_core *ethsw = dev_get_drvdata(dev); @@ -1337,7 +1333,8 @@ static int ethsw_register_notifier(struct device *dev) goto err_switchdev_nb; } - err = register_switchdev_blocking_notifier(&port_switchdev_blocking_nb); + ethsw->port_switchdevb_nb.notifier_call = port_switchdev_blocking_event; + err = register_switchdev_blocking_notifier(ðsw->port_switchdevb_nb); if (err) { dev_err(dev, "Failed to register switchdev blocking notifier\n"); goto err_switchdev_blocking_nb; @@ -1490,7 +1487,7 @@ static void ethsw_unregister_notifier(struct device *dev) struct notifier_block *nb; int err; - nb = &port_switchdev_blocking_nb; + nb = ðsw->port_switchdevb_nb; err = unregister_switchdev_blocking_notifier(nb); if (err) dev_err(dev, diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index e050589758b1..db7eef134230 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -69,6 +69,7 @@ struct ethsw_core { struct notifier_block port_nb; struct notifier_block port_switchdev_nb; + struct notifier_block port_switchdevb_nb; }; #endif /* __ETHSW_H */ -- cgit v1.2.3-59-g8ed1b From b8f64757bad8278f03c918b573687925ff55cd84 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Mon, 11 Nov 2019 18:50:58 +0200 Subject: staging: dpaa2-ethsw: ordered workqueue should be per ethsw Create a different ordered workqueue per dpaa2-ethsw instance. Without this change, we overwrite the global queue and leak memory when probing multiple instances of the driver. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/1573491058-24766-5-git-send-email-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 17 +++++++++-------- drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 37ee9b0aa326..39c0fe347188 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -18,8 +18,6 @@ #include "ethsw.h" -static struct workqueue_struct *ethsw_owq; - /* Minimal supported DPSW version */ #define DPSW_MIN_VER_MAJOR 8 #define DPSW_MIN_VER_MINOR 1 @@ -1229,8 +1227,10 @@ static int port_switchdev_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + struct ethsw_port_priv *port_priv = netdev_priv(dev); struct ethsw_switchdev_event_work *switchdev_work; struct switchdev_notifier_fdb_info *fdb_info = ptr; + struct ethsw_core *ethsw = port_priv->ethsw_data; if (!ethsw_port_dev_check(dev)) return NOTIFY_DONE; @@ -1266,7 +1266,7 @@ static int port_switchdev_event(struct notifier_block *unused, return NOTIFY_DONE; } - queue_work(ethsw_owq, &switchdev_work->work); + queue_work(ethsw->workqueue, &switchdev_work->work); return NOTIFY_DONE; @@ -1427,9 +1427,10 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) } } - ethsw_owq = alloc_ordered_workqueue("%s_ordered", WQ_MEM_RECLAIM, - "ethsw"); - if (!ethsw_owq) { + ethsw->workqueue = alloc_ordered_workqueue("%s_%d_ordered", + WQ_MEM_RECLAIM, "ethsw", + ethsw->sw_attr.id); + if (!ethsw->workqueue) { err = -ENOMEM; goto err_close; } @@ -1441,7 +1442,7 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) return 0; err_destroy_ordered_workqueue: - destroy_workqueue(ethsw_owq); + destroy_workqueue(ethsw->workqueue); err_close: dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle); @@ -1529,7 +1530,7 @@ static int ethsw_remove(struct fsl_mc_device *sw_dev) ethsw_teardown_irqs(sw_dev); - destroy_workqueue(ethsw_owq); + destroy_workqueue(ethsw->workqueue); dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index db7eef134230..a0244f7d5003 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -70,6 +70,7 @@ struct ethsw_core { struct notifier_block port_nb; struct notifier_block port_switchdev_nb; struct notifier_block port_switchdevb_nb; + struct workqueue_struct *workqueue; }; #endif /* __ETHSW_H */ -- cgit v1.2.3-59-g8ed1b From 133c887424712b50f184731b1cfe26ed7201cd6b Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:49 -0500 Subject: staging: exfat: Clean up return codes - FFS_FORMATERR Convert FFS_FORMATERR to -EFSCORRUPTED Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-2-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 3 ++- drivers/staging/exfat/exfat_core.c | 8 ++++---- drivers/staging/exfat/exfat_super.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index acb73f47a253..4f9ba235d967 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -30,6 +30,8 @@ #undef DEBUG #endif +#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ + #define DENTRY_SIZE 32 /* dir entry size */ #define DENTRY_SIZE_BITS 5 @@ -209,7 +211,6 @@ static inline u16 get_row_index(u16 i) /* return values */ #define FFS_SUCCESS 0 #define FFS_MEDIAERR 1 -#define FFS_FORMATERR 2 #define FFS_MOUNTED 3 #define FFS_NOTMOUNTED 4 #define FFS_ALIGNMENTERR 5 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index b23fbf3ebaa5..e90b54a17150 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -573,7 +573,7 @@ s32 load_alloc_bitmap(struct super_block *sb) return FFS_MEDIAERR; } - return FFS_FORMATERR; + return -EFSCORRUPTED; } void free_alloc_bitmap(struct super_block *sb) @@ -3016,7 +3016,7 @@ s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); if (p_bpb->num_fats == 0) - return FFS_FORMATERR; + return -EFSCORRUPTED; num_root_sectors = GET16(p_bpb->num_root_entries) << DENTRY_SIZE_BITS; num_root_sectors = ((num_root_sectors - 1) >> @@ -3078,7 +3078,7 @@ s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); if (p_bpb->num_fats == 0) - return FFS_FORMATERR; + return -EFSCORRUPTED; p_fs->sectors_per_clu = p_bpb->sectors_per_clu; p_fs->sectors_per_clu_bits = ilog2(p_bpb->sectors_per_clu); @@ -3157,7 +3157,7 @@ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); if (p_bpb->num_fats == 0) - return FFS_FORMATERR; + return -EFSCORRUPTED; p_fs->sectors_per_clu = 1 << p_bpb->sectors_per_clu_bits; p_fs->sectors_per_clu_bits = p_bpb->sectors_per_clu_bits; diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index ee3d64178069..9337fd4caaae 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -384,7 +384,7 @@ static int ffsMountVol(struct super_block *sb) if (GET16_A(p_pbr->signature) != PBR_SIGNATURE) { brelse(tmp_bh); bdev_close(sb); - ret = FFS_FORMATERR; + ret = -EFSCORRUPTED; goto out; } -- cgit v1.2.3-59-g8ed1b From a75500c5d3106d1b8f967b26edfcb9f945871516 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:50 -0500 Subject: staging: exfat: Clean up return codes - FFS_MEDIAERR Convert FFS_MEDIAERR to (mostly) -ENOENT and -EIO. Some additional code surgery needed to propogate correct error codes upwards. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-3-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_blkdev.c | 18 +++--- drivers/staging/exfat/exfat_core.c | 80 ++++++++++++------------ drivers/staging/exfat/exfat_super.c | 115 ++++++++++++++++++----------------- 4 files changed, 107 insertions(+), 107 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 4f9ba235d967..286605262345 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -210,7 +210,6 @@ static inline u16 get_row_index(u16 i) /* return values */ #define FFS_SUCCESS 0 -#define FFS_MEDIAERR 1 #define FFS_MOUNTED 3 #define FFS_NOTMOUNTED 4 #define FFS_ALIGNMENTERR 5 diff --git a/drivers/staging/exfat/exfat_blkdev.c b/drivers/staging/exfat/exfat_blkdev.c index 81d20e6241c6..0abae041f632 100644 --- a/drivers/staging/exfat/exfat_blkdev.c +++ b/drivers/staging/exfat/exfat_blkdev.c @@ -40,11 +40,11 @@ int bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, long flags = sbi->debug_flags; if (flags & EXFAT_DEBUGFLAGS_ERROR_RW) - return FFS_MEDIAERR; + return -EIO; #endif /* CONFIG_EXFAT_KERNEL_DEBUG */ if (!p_bd->opened) - return FFS_MEDIAERR; + return -ENODEV; if (*bh) __brelse(*bh); @@ -62,7 +62,7 @@ int bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, WARN(!p_fs->dev_ejected, "[EXFAT] No bh, device seems wrong or to be ejected.\n"); - return FFS_MEDIAERR; + return -EIO; } int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, @@ -77,11 +77,11 @@ int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, long flags = sbi->debug_flags; if (flags & EXFAT_DEBUGFLAGS_ERROR_RW) - return FFS_MEDIAERR; + return -EIO; #endif /* CONFIG_EXFAT_KERNEL_DEBUG */ if (!p_bd->opened) - return FFS_MEDIAERR; + return -ENODEV; if (secno == bh->b_blocknr) { lock_buffer(bh); @@ -89,7 +89,7 @@ int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, mark_buffer_dirty(bh); unlock_buffer(bh); if (sync && (sync_dirty_buffer(bh) != 0)) - return FFS_MEDIAERR; + return -EIO; } else { count = num_secs << p_bd->sector_size_bits; @@ -115,7 +115,7 @@ no_bh: WARN(!p_fs->dev_ejected, "[EXFAT] No bh, device seems wrong or to be ejected.\n"); - return FFS_MEDIAERR; + return -EIO; } int bdev_sync(struct super_block *sb) @@ -126,11 +126,11 @@ int bdev_sync(struct super_block *sb) long flags = sbi->debug_flags; if (flags & EXFAT_DEBUGFLAGS_ERROR_RW) - return FFS_MEDIAERR; + return -EIO; #endif /* CONFIG_EXFAT_KERNEL_DEBUG */ if (!p_bd->opened) - return FFS_MEDIAERR; + return -ENODEV; return sync_blockdev(sb->s_bdev); } diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index e90b54a17150..2f6e9d724625 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -252,13 +252,13 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, } if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS) - return -1; + return -EIO; num_clusters++; if (p_chain->flags == 0x01) { if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0) - return -1; + return -EIO; } if (p_chain->dir == CLUSTER_32(~0)) { @@ -266,7 +266,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, } else { if (p_chain->flags == 0x01) { if (FAT_write(sb, last_clu, new_clu) < 0) - return -1; + return -EIO; } } last_clu = new_clu; @@ -526,7 +526,7 @@ s32 load_alloc_bitmap(struct super_block *sb) ep = (struct bmap_dentry_t *)get_entry_in_dir(sb, &clu, i, NULL); if (!ep) - return FFS_MEDIAERR; + return -ENOENT; type = p_fs->fs_func->get_entry_type((struct dentry_t *)ep); @@ -570,7 +570,7 @@ s32 load_alloc_bitmap(struct super_block *sb) } if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return FFS_MEDIAERR; + return -EIO; } return -EFSCORRUPTED; @@ -856,14 +856,14 @@ s32 load_upcase_table(struct super_block *sb) clu.flags = 0x01; if (p_fs->dev_ejected) - return FFS_MEDIAERR; + return -EIO; while (clu.dir != CLUSTER_32(~0)) { for (i = 0; i < p_fs->dentries_per_clu; i++) { ep = (struct case_dentry_t *)get_entry_in_dir(sb, &clu, i, NULL); if (!ep) - return FFS_MEDIAERR; + return -ENOENT; type = p_fs->fs_func->get_entry_type((struct dentry_t *)ep); @@ -883,7 +883,7 @@ s32 load_upcase_table(struct super_block *sb) return FFS_SUCCESS; } if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return FFS_MEDIAERR; + return -EIO; } /* load default upcase table */ return __load_default_upcase_table(sb); @@ -1246,7 +1246,7 @@ s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, dos_ep = (struct dos_dentry_t *)get_entry_in_dir(sb, p_dir, entry, §or); if (!dos_ep) - return FFS_MEDIAERR; + return -EIO; init_dos_entry(dos_ep, type, start_clu); buf_modify(sb, sector); @@ -1268,12 +1268,12 @@ s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, file_ep = (struct file_dentry_t *)get_entry_in_dir(sb, p_dir, entry, §or); if (!file_ep) - return FFS_MEDIAERR; + return -ENOENT; strm_ep = (struct strm_dentry_t *)get_entry_in_dir(sb, p_dir, entry + 1, §or); if (!strm_ep) - return FFS_MEDIAERR; + return -ENOENT; init_file_entry(file_ep, type); buf_modify(sb, sector); @@ -1299,7 +1299,7 @@ static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, dos_ep = (struct dos_dentry_t *)get_entry_in_dir(sb, p_dir, entry, §or); if (!dos_ep) - return FFS_MEDIAERR; + return -EIO; dos_ep->lcase = p_dosname->name_case; memcpy(dos_ep->name, p_dosname->name, DOS_NAME_LENGTH); @@ -1315,7 +1315,7 @@ static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, entry - i, §or); if (!ext_ep) - return FFS_MEDIAERR; + return -EIO; init_ext_entry(ext_ep, i, chksum, uniname); buf_modify(sb, sector); @@ -1326,7 +1326,7 @@ static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, entry - i, §or); if (!ext_ep) - return FFS_MEDIAERR; + return -EIO; init_ext_entry(ext_ep, i + 0x40, chksum, uniname); buf_modify(sb, sector); @@ -1350,7 +1350,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, file_ep = (struct file_dentry_t *)get_entry_in_dir(sb, p_dir, entry, §or); if (!file_ep) - return FFS_MEDIAERR; + return -ENOENT; file_ep->num_ext = (u8)(num_entries - 1); buf_modify(sb, sector); @@ -1358,7 +1358,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, strm_ep = (struct strm_dentry_t *)get_entry_in_dir(sb, p_dir, entry + 1, §or); if (!strm_ep) - return FFS_MEDIAERR; + return -ENOENT; strm_ep->name_len = p_uniname->name_len; SET16_A(strm_ep->name_hash, p_uniname->name_hash); @@ -1369,7 +1369,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, entry + i, §or); if (!name_ep) - return FFS_MEDIAERR; + return -ENOENT; init_name_entry(name_ep, uniname); buf_modify(sb, sector); @@ -1592,7 +1592,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir, } else { while (clu_offset > 0) { if (FAT_read(sb, cur_clu, &cur_clu) == -1) - return FFS_MEDIAERR; + return -EIO; clu_offset--; } } @@ -2084,10 +2084,10 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries /* (1) allocate a cluster */ ret = p_fs->fs_func->alloc_cluster(sb, 1, &clu); if (ret < 1) - return -1; + return -EIO; if (clear_cluster(sb, clu.dir) != FFS_SUCCESS) - return -1; + return -EIO; /* (2) append to the FAT chain */ if (clu.flags != p_dir->flags) { @@ -2097,7 +2097,7 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries } if (clu.flags == 0x01) if (FAT_write(sb, last_clu, clu.dir) < 0) - return -1; + return -EIO; if (p_fs->hint_uentry.entry == -1) { p_fs->hint_uentry.dir = p_dir->dir; @@ -2118,7 +2118,7 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries ep = get_entry_in_dir(sb, &fid->dir, fid->entry + 1, §or); if (!ep) - return -1; + return -ENOENT; p_fs->fs_func->set_entry_size(ep, size); p_fs->fs_func->set_entry_flag(ep, p_dir->flags); buf_modify(sb, sector); @@ -2464,7 +2464,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, for (i = 0; i < dentries_per_clu; i++) { ep = get_entry_in_dir(sb, &clu, i, NULL); if (!ep) - return -1; + return -ENOENT; entry_type = p_fs->fs_func->get_entry_type(ep); @@ -2488,7 +2488,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, clu.dir = CLUSTER_32(~0); } else { if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return -1; + return -EIO; } } @@ -2772,7 +2772,7 @@ s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, ep = (struct dos_dentry_t *)get_entry_in_dir(sb, &clu, i, NULL); if (!ep) - return FFS_MEDIAERR; + return -ENOENT; type = p_fs->fs_func->get_entry_type((struct dentry_t *) ep); @@ -2811,7 +2811,7 @@ s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, break; /* FAT16 root_dir */ if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return FFS_MEDIAERR; + return -EIO; } count = 0; @@ -3226,7 +3226,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, /* (1) allocate a cluster */ ret = fs_func->alloc_cluster(sb, 1, &clu); if (ret < 0) - return FFS_MEDIAERR; + return ret; else if (ret == 0) return -ENOSPC; @@ -3395,7 +3395,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, epold = get_entry_in_dir(sb, p_dir, oldentry, §or_old); if (!epold) - return FFS_MEDIAERR; + return -ENOENT; buf_lock(sb, sector_old); @@ -3404,7 +3404,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, epold); if (num_old_entries < 0) { buf_unlock(sb, sector_old); - return FFS_MEDIAERR; + return -ENOENT; } num_old_entries++; @@ -3425,7 +3425,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, epnew = get_entry_in_dir(sb, p_dir, newentry, §or_new); if (!epnew) { buf_unlock(sb, sector_old); - return FFS_MEDIAERR; + return -ENOENT; } memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); @@ -3447,7 +3447,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, if (!epold || !epnew) { buf_unlock(sb, sector_old); - return FFS_MEDIAERR; + return -ENOENT; } memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); @@ -3502,7 +3502,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, epmov = get_entry_in_dir(sb, p_olddir, oldentry, §or_mov); if (!epmov) - return FFS_MEDIAERR; + return -ENOENT; /* check if the source and target directory is the same */ if (fs_func->get_entry_type(epmov) == TYPE_DIR && @@ -3516,7 +3516,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, epmov); if (num_old_entries < 0) { buf_unlock(sb, sector_mov); - return FFS_MEDIAERR; + return -ENOENT; } num_old_entries++; @@ -3536,7 +3536,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, epnew = get_entry_in_dir(sb, p_newdir, newentry, §or_new); if (!epnew) { buf_unlock(sb, sector_mov); - return FFS_MEDIAERR; + return -ENOENT; } memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); @@ -3556,7 +3556,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, §or_new); if (!epmov || !epnew) { buf_unlock(sb, sector_mov); - return FFS_MEDIAERR; + return -ENOENT; } memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); @@ -3569,7 +3569,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, epnew = get_entry_in_dir(sb, &clu, 1, §or_new); if (!epnew) - return FFS_MEDIAERR; + return -ENOENT; if (p_newdir->dir == p_fs->root_dir) fs_func->set_entry_clu0(epnew, CLUSTER_32(0)); @@ -3601,7 +3601,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, bool read) { - s32 ret = FFS_MEDIAERR; + s32 ret = -EIO; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); if ((sec >= (p_fs->PBR_sector + p_fs->num_sectors)) && @@ -3624,7 +3624,7 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, bool sync) { - s32 ret = FFS_MEDIAERR; + s32 ret = -EIO; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); if (sec >= (p_fs->PBR_sector + p_fs->num_sectors) && @@ -3653,7 +3653,7 @@ int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, int multi_sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, s32 num_secs, bool read) { - s32 ret = FFS_MEDIAERR; + s32 ret = -EIO; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); if (((sec + num_secs) > (p_fs->PBR_sector + p_fs->num_sectors)) && @@ -3676,7 +3676,7 @@ int multi_sector_read(struct super_block *sb, sector_t sec, int multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, bool sync) { - s32 ret = FFS_MEDIAERR; + s32 ret = -EIO; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); if ((sec + num_secs) > (p_fs->PBR_sector + p_fs->num_sectors) && diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 9337fd4caaae..1a906579724c 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -364,7 +364,9 @@ static int ffsMountVol(struct super_block *sb) bdev_open(sb); if (p_bd->sector_size < sb->s_blocksize) { - ret = FFS_MEDIAERR; + printk(KERN_INFO "EXFAT: maont failed - sector size %d less than blocksize %ld\n", + p_bd->sector_size, sb->s_blocksize); + ret = -EINVAL; goto out; } if (p_bd->sector_size > sb->s_blocksize) @@ -372,7 +374,7 @@ static int ffsMountVol(struct super_block *sb) /* read Sector 0 */ if (sector_read(sb, 0, &tmp_bh, 1) != FFS_SUCCESS) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } @@ -435,7 +437,7 @@ static int ffsMountVol(struct super_block *sb) free_alloc_bitmap(sb); } bdev_close(sb); - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } @@ -475,7 +477,7 @@ static int ffsUmountVol(struct super_block *sb) if (p_fs->dev_ejected) { pr_info("[EXFAT] unmounted with media errors. Device is already ejected.\n"); - err = FFS_MEDIAERR; + err = -EIO; } buf_shutdown(sb); @@ -511,7 +513,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) info->FreeClusters = info->NumClusters - info->UsedClusters; if (p_fs->dev_ejected) - err = FFS_MEDIAERR; + err = -EIO; /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -532,7 +534,7 @@ static int ffsSyncVol(struct super_block *sb, bool do_sync) fs_set_vol_flags(sb, VOL_CLEAN); if (p_fs->dev_ejected) - err = FFS_MEDIAERR; + err = -EIO; /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -601,14 +603,14 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) es = get_entry_set_in_dir(sb, &dir, dentry, ES_2_ENTRIES, &ep); if (!es) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep + 1; } else { ep = get_entry_in_dir(sb, &dir, dentry, NULL); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep; @@ -633,7 +635,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) } if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -673,7 +675,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -744,7 +746,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, while (clu_offset > 0) { /* clu = FAT_read(sb, clu); */ if (FAT_read(sb, clu, &clu) == -1) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } @@ -799,7 +801,7 @@ err_out: *rcount = read_bytes; if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -890,7 +892,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, last_clu = clu; /* clu = FAT_read(sb, clu); */ if (FAT_read(sb, clu, &clu) == -1) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } clu_offset--; @@ -912,7 +914,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, if (num_alloced == 0) break; if (num_alloced < 0) { - ret = FFS_MEDIAERR; + ret = num_alloced; goto out; } @@ -1057,7 +1059,7 @@ err_out: ret = -ENOSPC; else if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -1118,7 +1120,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) while (num_clusters > 0) { last_clu = clu.dir; if (FAT_read(sb, clu.dir, &clu.dir) == -1) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } num_clusters--; @@ -1140,14 +1142,14 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep + 1; } else { ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep; @@ -1189,7 +1191,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: pr_debug("%s exited (%d)\n", __func__, ret); @@ -1262,7 +1264,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, ep = get_entry_in_dir(sb, &olddir, dentry, NULL); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out2; } @@ -1275,7 +1277,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, if (new_inode) { u32 entry_type; - ret = FFS_MEDIAERR; + ret = -ENOENT; new_fid = &EXFAT_I(new_inode)->fid; update_parent_info(new_fid, new_parent_inode); @@ -1337,7 +1339,7 @@ out: #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out2: /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -1369,7 +1371,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) ep = get_entry_in_dir(sb, &dir, dentry, NULL); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } @@ -1399,7 +1401,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -1423,7 +1425,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) if (fid->attr == attr) { if (p_fs->dev_ejected) - return FFS_MEDIAERR; + return -EIO; return FFS_SUCCESS; } @@ -1431,7 +1433,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) if ((fid->dir.dir == p_fs->root_dir) && (fid->entry == -1)) { if (p_fs->dev_ejected) - return FFS_MEDIAERR; + return -EIO; return FFS_SUCCESS; } } @@ -1444,13 +1446,13 @@ static int ffsSetAttr(struct inode *inode, u32 attr) es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } } else { ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } } @@ -1460,7 +1462,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) if (((type == TYPE_FILE) && (attr & ATTR_SUBDIR)) || ((type == TYPE_DIR) && (!(attr & ATTR_SUBDIR)))) { if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; else ret = FFS_ERROR; @@ -1488,7 +1490,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -1544,13 +1546,13 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) count = count_dos_name_entries(sb, &dir, TYPE_DIR); if (count < 0) { - ret = FFS_MEDIAERR; + ret = count; /* propogate error upward */ goto out; } info->NumSubdirs = count; if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } } @@ -1560,14 +1562,14 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_2_ENTRIES, &ep); if (!es) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep + 1; } else { ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep; @@ -1633,14 +1635,14 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) count = count_dos_name_entries(sb, &dir, TYPE_DIR); if (count < 0) { - ret = FFS_MEDIAERR; + ret = count; /* propogate error upward */ goto out; } info->NumSubdirs += count; } if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -1671,7 +1673,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) if ((fid->dir.dir == p_fs->root_dir) && (fid->entry == -1)) { if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; ret = FFS_SUCCESS; goto out; } @@ -1684,7 +1686,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep + 1; @@ -1692,7 +1694,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) /* for other than exfat */ ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } ep2 = ep; @@ -1727,7 +1729,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) } if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -1789,7 +1791,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) while ((clu_offset > 0) && (*clu != CLUSTER_32(~0))) { last_clu = *clu; if (FAT_read(sb, *clu, clu) == -1) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } clu_offset--; @@ -1807,7 +1809,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) /* (1) allocate a cluster */ num_alloced = p_fs->fs_func->alloc_cluster(sb, 1, &new_clu); if (num_alloced < 0) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } else if (num_alloced == 0) { ret = -ENOSPC; @@ -1838,7 +1840,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, ES_ALL_ENTRIES, &ep); if (!es) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } /* get stream entry */ @@ -1851,7 +1853,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } } @@ -1881,7 +1883,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) fid->hint_last_clu = *clu; if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -1926,7 +1928,7 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -1956,7 +1958,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) /* check if the given file ID is opened */ if (fid->type != TYPE_DIR) - return -EPERM; + return -ENOTDIR; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -2006,7 +2008,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) while (clu_offset > 0) { /* clu.dir = FAT_read(sb, clu.dir); */ if (FAT_read(sb, clu.dir, &clu.dir) == -1) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } clu_offset--; @@ -2026,7 +2028,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) for ( ; i < dentries_per_clu; i++, dentry++) { ep = get_entry_in_dir(sb, &clu, i, §or); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } type = fs_func->get_entry_type(ep); @@ -2074,7 +2076,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) if (p_fs->vol_type == EXFAT) { ep = get_entry_in_dir(sb, &clu, i + 1, NULL); if (!ep) { - ret = FFS_MEDIAERR; + ret = -ENOENT; goto out; } } else { @@ -2098,7 +2100,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) fid->rwoffset = (s64)(++dentry); if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } @@ -2113,7 +2115,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) } else { /* clu.dir = FAT_read(sb, clu.dir); */ if (FAT_read(sb, clu.dir, &clu.dir) == -1) { - ret = FFS_MEDIAERR; + ret = -EIO; goto out; } } @@ -2124,7 +2126,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) fid->rwoffset = (s64)(++dentry); if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -2187,7 +2189,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) #endif if (p_fs->dev_ejected) - ret = FFS_MEDIAERR; + ret = -EIO; out: /* release the lock for file system critical section */ @@ -2247,12 +2249,11 @@ get_new: /* at least we tried to read a sector * move cpos to next sector position (should be aligned) */ - if (err == FFS_MEDIAERR) { + if (err == -EIO) { cpos += 1 << p_bd->sector_size_bits; cpos &= ~((1 << p_bd->sector_size_bits) - 1); } - err = -EIO; goto end_of_dir; } @@ -3550,7 +3551,7 @@ static int exfat_statfs(struct dentry *dentry, struct kstatfs *buf) struct vol_info_t info; if (p_fs->used_clusters == UINT_MAX) { - if (ffsGetVolInfo(sb, &info) == FFS_MEDIAERR) + if (ffsGetVolInfo(sb, &info) == -EIO) return -EIO; } else { -- cgit v1.2.3-59-g8ed1b From f9c53abb42997d5af1232712a39f81c7f1ba1c01 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:51 -0500 Subject: staging: exfat: Clean up return codes - FFS_EOF Convert FFS_EOF to return 0 for a zero-length read() as per 'man 2 read'. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-4-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_super.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 286605262345..292af85e3cd2 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -217,7 +217,6 @@ static inline u16 get_row_index(u16 i) #define FFS_INVALIDFID 8 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 -#define FFS_EOF 15 #define FFS_ERROR 19 #define NUM_UPCASE 2918 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 1a906579724c..77e00d007ad3 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -723,7 +723,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, if (count == 0) { if (rcount) *rcount = 0; - ret = FFS_EOF; + ret = 0; goto out; } -- cgit v1.2.3-59-g8ed1b From 7785913b079fafd461a668034c76d604fe513770 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:52 -0500 Subject: staging: exfat: Clean up return codes - FFS_INVALIDFID Covert FFS_INVALIDFID to -EINVAL Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-5-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_super.c | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 292af85e3cd2..7a817405c624 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -214,7 +214,6 @@ static inline u16 get_row_index(u16 i) #define FFS_NOTMOUNTED 4 #define FFS_ALIGNMENTERR 5 #define FFS_SEMAPHOREERR 6 -#define FFS_INVALIDFID 8 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 #define FFS_ERROR 19 diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 77e00d007ad3..a9129b569523 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -699,7 +699,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, /* check the validity of the given file id */ if (!fid) - return FFS_INVALIDFID; + return -EINVAL; /* check the validity of pointer parameters */ if (!buffer) @@ -831,7 +831,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, /* check the validity of the given file id */ if (!fid) - return FFS_INVALIDFID; + return -EINVAL; /* check the validity of pointer parameters */ if (!buffer) @@ -1237,7 +1237,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, /* check the validity of the given file id */ if (!fid) - return FFS_INVALIDFID; + return -EINVAL; /* check the validity of pointer parameters */ if (!new_path || (*new_path == '\0')) @@ -1358,7 +1358,7 @@ static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) /* check the validity of the given file id */ if (!fid) - return FFS_INVALIDFID; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -2145,7 +2145,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) /* check the validity of the given file id */ if (!fid) - return FFS_INVALIDFID; + return -EINVAL; dir.dir = fid->dir.dir; dir.size = fid->dir.size; -- cgit v1.2.3-59-g8ed1b From 0a7ef8d9483b96bea89c8b99b7b509697d48701d Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:53 -0500 Subject: staging: exfat: Clean up return codes - FFS_ERROR Convert FFS_ERROR to -EINVAL Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-6-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 1 - drivers/staging/exfat/exfat_core.c | 10 +++++----- drivers/staging/exfat/exfat_super.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 7a817405c624..443fafe1d89d 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -216,7 +216,6 @@ static inline u16 get_row_index(u16 i) #define FFS_SEMAPHOREERR 6 #define FFS_NOTOPENED 12 #define FFS_MAXOPENED 13 -#define FFS_ERROR 19 #define NUM_UPCASE 2918 diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 2f6e9d724625..ffcad6867ecb 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -699,7 +699,7 @@ void sync_alloc_bitmap(struct super_block *sb) static s32 __load_upcase_table(struct super_block *sb, sector_t sector, u32 num_sectors, u32 utbl_checksum) { - int i, ret = FFS_ERROR; + int i, ret = -EINVAL; u32 j; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); @@ -774,7 +774,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector, brelse(tmp_bh); return FFS_SUCCESS; } - ret = FFS_ERROR; + ret = -EINVAL; error: if (tmp_bh) brelse(tmp_bh); @@ -784,7 +784,7 @@ error: static s32 __load_default_upcase_table(struct super_block *sb) { - int i, ret = FFS_ERROR; + int i, ret = -EINVAL; u32 j; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -1906,7 +1906,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, return FFS_SUCCESS; err_out: pr_debug("%s failed\n", __func__); - return FFS_ERROR; + return -EINVAL; } /* write back all entries in entry set */ @@ -1931,7 +1931,7 @@ s32 write_partial_entries_in_entry_set(struct super_block *sb, /* vaidity check */ if (ep + count > ((struct dentry_t *)&es->__buf) + es->num_entries) - return FFS_ERROR; + return -EINVAL; dir.dir = GET_CLUSTER_FROM_SECTOR(es->sector); dir.flags = es->alloc_flag; diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index a9129b569523..2f199d78bfa6 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -498,7 +498,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) /* check the validity of pointer parameters */ if (!info) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -561,7 +561,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) /* check the validity of pointer parameters */ if (!fid || !path || (*path == '\0')) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -654,7 +654,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, /* check the validity of pointer parameters */ if (!fid || !path || (*path == '\0')) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -703,7 +703,7 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, /* check the validity of pointer parameters */ if (!buffer) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -835,7 +835,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, /* check the validity of pointer parameters */ if (!buffer) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -1241,7 +1241,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, /* check the validity of pointer parameters */ if (!new_path || (*new_path == '\0')) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -1464,7 +1464,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) if (p_fs->dev_ejected) ret = -EIO; else - ret = FFS_ERROR; + ret = -EINVAL; if (p_fs->vol_type == EXFAT) release_entry_set(es); @@ -1756,7 +1756,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) /* check the validity of pointer parameters */ if (!clu) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -1908,7 +1908,7 @@ static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) /* check the validity of pointer parameters */ if (!fid || !path || (*path == '\0')) - return FFS_ERROR; + return -EINVAL; /* acquire the lock for file system critical section */ mutex_lock(&p_fs->v_mutex); @@ -1954,7 +1954,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) /* check the validity of pointer parameters */ if (!dir_entry) - return FFS_ERROR; + return -EINVAL; /* check if the given file ID is opened */ if (fid->type != TYPE_DIR) -- cgit v1.2.3-59-g8ed1b From 97eab6cee3a6ac679a2f531a248df3c994182522 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:54 -0500 Subject: staging: exfat: Clean up return codes - remove unused codes There are 6 FFS_* error values not used at all. Remove them. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-7-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 443fafe1d89d..b3fc9bb06c24 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -210,12 +210,6 @@ static inline u16 get_row_index(u16 i) /* return values */ #define FFS_SUCCESS 0 -#define FFS_MOUNTED 3 -#define FFS_NOTMOUNTED 4 -#define FFS_ALIGNMENTERR 5 -#define FFS_SEMAPHOREERR 6 -#define FFS_NOTOPENED 12 -#define FFS_MAXOPENED 13 #define NUM_UPCASE 2918 -- cgit v1.2.3-59-g8ed1b From 4b18672132332d3ec429ea9370d0b380dae730cd Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:55 -0500 Subject: staging: exfat: Clean up return codes - FFS_SUCCESS Convert FFS_SUCCESS to 0. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-8-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 3 -- drivers/staging/exfat/exfat_cache.c | 4 +- drivers/staging/exfat/exfat_core.c | 104 ++++++++++++++++++------------------ drivers/staging/exfat/exfat_super.c | 50 ++++++++--------- 4 files changed, 79 insertions(+), 82 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index b3fc9bb06c24..72cf40e123de 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -208,9 +208,6 @@ static inline u16 get_row_index(u16 i) #define FM_REGULAR 0x00 #define FM_SYMLINK 0x40 -/* return values */ -#define FFS_SUCCESS 0 - #define NUM_UPCASE 2918 #define DOS_CUR_DIR_NAME ". " diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index 467b93630d86..28a67f8139ea 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -462,7 +462,7 @@ u8 *FAT_getblk(struct super_block *sb, sector_t sec) FAT_cache_insert_hash(sb, bp); - if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) { + if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) { FAT_cache_remove_hash(bp); bp->drv = -1; bp->sec = ~0; @@ -582,7 +582,7 @@ static u8 *__buf_getblk(struct super_block *sb, sector_t sec) buf_cache_insert_hash(sb, bp); - if (sector_read(sb, sec, &bp->buf_bh, 1) != FFS_SUCCESS) { + if (sector_read(sb, sec, &bp->buf_bh, 1) != 0) { buf_cache_remove_hash(bp); bp->drv = -1; bp->sec = ~0; diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index ffcad6867ecb..1f0ef94bdd47 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -102,7 +102,7 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag) if (p_fs->vol_type == EXFAT) { if (!p_fs->pbr_bh) { if (sector_read(sb, p_fs->PBR_sector, - &p_fs->pbr_bh, 1) != FFS_SUCCESS) + &p_fs->pbr_bh, 1) != 0) return; } @@ -139,7 +139,7 @@ void fs_error(struct super_block *sb) s32 clear_cluster(struct super_block *sb, u32 clu) { sector_t s, n; - s32 ret = FFS_SUCCESS; + s32 ret = 0; struct buffer_head *tmp_bh = NULL; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); @@ -154,12 +154,12 @@ s32 clear_cluster(struct super_block *sb, u32 clu) for (; s < n; s++) { ret = sector_read(sb, s, &tmp_bh, 0); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; memset((char *)tmp_bh->b_data, 0x0, p_bd->sector_size); ret = sector_write(sb, s, tmp_bh, 0); - if (ret != FFS_SUCCESS) + if (ret != 0) break; } @@ -251,7 +251,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, } } - if (set_alloc_bitmap(sb, new_clu - 2) != FFS_SUCCESS) + if (set_alloc_bitmap(sb, new_clu - 2) != 0) return -EIO; num_clusters++; @@ -370,7 +370,7 @@ void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, buf_release(sb, sector + i); } - if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS) + if (clr_alloc_bitmap(sb, clu - 2) != 0) break; clu++; @@ -387,7 +387,7 @@ void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, buf_release(sb, sector + i); } - if (clr_alloc_bitmap(sb, clu - 2) != FFS_SUCCESS) + if (clr_alloc_bitmap(sb, clu - 2) != 0) break; if (FAT_read(sb, clu, &clu) == -1) @@ -552,7 +552,7 @@ s32 load_alloc_bitmap(struct super_block *sb) for (j = 0; j < p_fs->map_sectors; j++) { p_fs->vol_amap[j] = NULL; ret = sector_read(sb, sector + j, &p_fs->vol_amap[j], 1); - if (ret != FFS_SUCCESS) { + if (ret != 0) { /* release all buffers and free vol_amap */ i = 0; while (i < j) @@ -565,7 +565,7 @@ s32 load_alloc_bitmap(struct super_block *sb) } p_fs->pbr_bh = NULL; - return FFS_SUCCESS; + return 0; } } @@ -721,7 +721,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector, while (sector < end_sector) { ret = sector_read(sb, sector, &tmp_bh, 1); - if (ret != FFS_SUCCESS) { + if (ret != 0) { pr_debug("sector read (0x%llX)fail\n", (unsigned long long)sector); goto error; @@ -772,7 +772,7 @@ static s32 __load_upcase_table(struct super_block *sb, sector_t sector, if (index >= 0xFFFF && utbl_checksum == checksum) { if (tmp_bh) brelse(tmp_bh); - return FFS_SUCCESS; + return 0; } ret = -EINVAL; error: @@ -833,7 +833,7 @@ static s32 __load_default_upcase_table(struct super_block *sb) } if (index >= 0xFFFF) - return FFS_SUCCESS; + return 0; error: /* FATAL error: default upcase table has error */ @@ -878,9 +878,9 @@ s32 load_upcase_table(struct super_block *sb) sector = START_SECTOR(tbl_clu); num_sectors = ((tbl_size - 1) >> p_bd->sector_size_bits) + 1; if (__load_upcase_table(sb, sector, num_sectors, - GET32_A(ep->checksum)) != FFS_SUCCESS) + GET32_A(ep->checksum)) != 0) break; - return FFS_SUCCESS; + return 0; } if (FAT_read(sb, clu.dir, &clu.dir) != 0) return -EIO; @@ -1251,7 +1251,7 @@ s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, init_dos_entry(dos_ep, type, start_clu); buf_modify(sb, sector); - return FFS_SUCCESS; + return 0; } s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, @@ -1281,7 +1281,7 @@ s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, init_strm_entry(strm_ep, flags, start_clu, size); buf_modify(sb, sector); - return FFS_SUCCESS; + return 0; } static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, @@ -1332,7 +1332,7 @@ static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, buf_modify(sb, sector); } - return FFS_SUCCESS; + return 0; } static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, @@ -1378,7 +1378,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, update_dir_checksum(sb, p_dir, entry); - return FFS_SUCCESS; + return 0; } void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu) @@ -1599,7 +1599,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir, if (clu) *clu = cur_clu; - return FFS_SUCCESS; + return 0; } s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, @@ -1618,7 +1618,7 @@ s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, *sector += p_fs->root_start_sector; } else { ret = _walk_fat_chain(sb, p_dir, off, &clu); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; /* byte offset in cluster */ @@ -1631,7 +1631,7 @@ s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, *sector = off >> p_bd->sector_size_bits; *sector += START_SECTOR(clu); } - return FFS_SUCCESS; + return 0; } struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, @@ -1654,7 +1654,7 @@ struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, sector_t sec; u8 *buf; - if (find_location(sb, p_dir, entry, &sec, &off) != FFS_SUCCESS) + if (find_location(sb, p_dir, entry, &sec, &off) != 0) return NULL; buf = buf_getblk(sb, sec); @@ -1708,7 +1708,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, byte_offset = entry << DENTRY_SIZE_BITS; ret = _walk_fat_chain(sb, p_dir, byte_offset, &clu); - if (ret != FFS_SUCCESS) + if (ret != 0) return NULL; /* byte offset in cluster */ @@ -1903,7 +1903,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, } pr_debug("%s exited successfully\n", __func__); - return FFS_SUCCESS; + return 0; err_out: pr_debug("%s failed\n", __func__); return -EINVAL; @@ -1942,7 +1942,7 @@ s32 write_partial_entries_in_entry_set(struct super_block *sb, byte_offset += ((void **)ep - &es->__buf) + es->offset; ret = _walk_fat_chain(sb, &dir, byte_offset, &clu); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; /* byte offset in cluster */ @@ -2086,7 +2086,7 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries if (ret < 1) return -EIO; - if (clear_cluster(sb, clu.dir) != FFS_SUCCESS) + if (clear_cluster(sb, clu.dir) != 0) return -EIO; /* (2) append to the FAT chain */ @@ -2597,7 +2597,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, *entries = num_entries; - return FFS_SUCCESS; + return 0; } void get_uni_name_from_dos_entry(struct super_block *sb, @@ -2833,7 +2833,7 @@ s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, fat_attach_count_to_dos_name(p_dosname->name, count); /* Now dos_name has DOS~????.EXT */ - return FFS_SUCCESS; + return 0; } void fat_attach_count_to_dos_name(u8 *dosname, s32 count) @@ -2975,7 +2975,7 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, p_dir->size = (s32)(fid->size >> p_fs->cluster_size_bits); p_dir->flags = fid->flags; - return FFS_SUCCESS; + return 0; } /* @@ -3067,7 +3067,7 @@ s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) p_fs->fs_func = &fat_fs_func; - return FFS_SUCCESS; + return 0; } s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) @@ -3120,7 +3120,7 @@ s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) p_fs->fs_func = &fat_fs_func; - return FFS_SUCCESS; + return 0; } static struct fs_func exfat_fs_func = { @@ -3195,7 +3195,7 @@ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) p_fs->fs_func = &exfat_fs_func; - return FFS_SUCCESS; + return 0; } s32 create_dir(struct inode *inode, struct chain_t *p_dir, @@ -3231,7 +3231,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, return -ENOSPC; ret = clear_cluster(sb, clu.dir); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; if (p_fs->vol_type == EXFAT) { @@ -3249,11 +3249,11 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, ret = fs_func->init_dir_entry(sb, &clu, 0, TYPE_DIR, clu.dir, 0); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; ret = fs_func->init_ext_entry(sb, &clu, 0, 1, NULL, &dot_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; memcpy(dot_name.name, DOS_PAR_DIR_NAME, DOS_NAME_LENGTH); @@ -3265,12 +3265,12 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, ret = fs_func->init_dir_entry(sb, &clu, 1, TYPE_DIR, p_dir->dir, 0); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; ret = p_fs->fs_func->init_ext_entry(sb, &clu, 1, 1, NULL, &dot_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; } @@ -3278,12 +3278,12 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, /* make sub-dir entry in parent directory */ ret = fs_func->init_dir_entry(sb, p_dir, dentry, TYPE_DIR, clu.dir, size); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; ret = fs_func->init_ext_entry(sb, p_dir, dentry, num_entries, p_uniname, &dos_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; fid->dir.dir = p_dir->dir; @@ -3300,7 +3300,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, fid->rwoffset = 0; fid->hint_last_off = -1; - return FFS_SUCCESS; + return 0; } s32 create_file(struct inode *inode, struct chain_t *p_dir, @@ -3328,12 +3328,12 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir, */ ret = fs_func->init_dir_entry(sb, p_dir, dentry, TYPE_FILE | mode, CLUSTER_32(0), 0); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; ret = fs_func->init_ext_entry(sb, p_dir, dentry, num_entries, p_uniname, &dos_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; fid->dir.dir = p_dir->dir; @@ -3350,7 +3350,7 @@ s32 create_file(struct inode *inode, struct chain_t *p_dir, fid->rwoffset = 0; fid->hint_last_off = -1; - return FFS_SUCCESS; + return 0; } void remove_file(struct inode *inode, struct chain_t *p_dir, s32 entry) @@ -3458,7 +3458,7 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ret = fs_func->init_ext_entry(sb, p_dir, newentry, num_new_entries, p_uniname, &dos_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; fs_func->delete_dir_entry(sb, p_dir, oldentry, 0, @@ -3477,14 +3477,14 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ret = fs_func->init_ext_entry(sb, p_dir, oldentry, num_new_entries, p_uniname, &dos_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; fs_func->delete_dir_entry(sb, p_dir, oldentry, num_new_entries, num_old_entries); } - return FFS_SUCCESS; + return 0; } s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, @@ -3580,7 +3580,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, ret = fs_func->init_ext_entry(sb, p_newdir, newentry, num_new_entries, p_uniname, &dos_name); - if (ret != FFS_SUCCESS) + if (ret != 0) return ret; fs_func->delete_dir_entry(sb, p_olddir, oldentry, 0, num_old_entries); @@ -3591,7 +3591,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, fid->entry = newentry; - return FFS_SUCCESS; + return 0; } /* @@ -3614,7 +3614,7 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, if (!p_fs->dev_ejected) { ret = bdev_read(sb, sec, bh, 1, read); - if (ret != FFS_SUCCESS) + if (ret != 0) p_fs->dev_ejected = 1; } @@ -3643,7 +3643,7 @@ int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, if (!p_fs->dev_ejected) { ret = bdev_write(sb, sec, bh, 1, sync); - if (ret != FFS_SUCCESS) + if (ret != 0) p_fs->dev_ejected = 1; } @@ -3666,7 +3666,7 @@ int multi_sector_read(struct super_block *sb, sector_t sec, if (!p_fs->dev_ejected) { ret = bdev_read(sb, sec, bh, num_secs, read); - if (ret != FFS_SUCCESS) + if (ret != 0) p_fs->dev_ejected = 1; } @@ -3694,7 +3694,7 @@ int multi_sector_write(struct super_block *sb, sector_t sec, if (!p_fs->dev_ejected) { ret = bdev_write(sb, sec, bh, num_secs, sync); - if (ret != FFS_SUCCESS) + if (ret != 0) p_fs->dev_ejected = 1; } diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 2f199d78bfa6..7941944ec09f 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -373,7 +373,7 @@ static int ffsMountVol(struct super_block *sb) sb_set_blocksize(sb, p_bd->sector_size); /* read Sector 0 */ - if (sector_read(sb, 0, &tmp_bh, 1) != FFS_SUCCESS) { + if (sector_read(sb, 0, &tmp_bh, 1) != 0) { ret = -EIO; goto out; } @@ -452,7 +452,7 @@ out: static int ffsUmountVol(struct super_block *sb) { struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - int err = FFS_SUCCESS; + int err = 0; pr_info("[EXFAT] trying to unmount...\n"); @@ -493,7 +493,7 @@ static int ffsUmountVol(struct super_block *sb) static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) { - int err = FFS_SUCCESS; + int err = 0; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); /* check the validity of pointer parameters */ @@ -523,7 +523,7 @@ static int ffsGetVolInfo(struct super_block *sb, struct vol_info_t *info) static int ffsSyncVol(struct super_block *sb, bool do_sync) { - int err = FFS_SUCCESS; + int err = 0; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); /* acquire the lock for file system critical section */ @@ -776,13 +776,13 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, if ((offset == 0) && (oneblkread == p_bd->sector_size)) { if (sector_read(sb, LogSector, &tmp_bh, 1) != - FFS_SUCCESS) + 0) goto err_out; memcpy((char *)buffer + read_bytes, (char *)tmp_bh->b_data, (s32)oneblkread); } else { if (sector_read(sb, LogSector, &tmp_bh, 1) != - FFS_SUCCESS) + 0) goto err_out; memcpy((char *)buffer + read_bytes, (char *)tmp_bh->b_data + offset, @@ -852,7 +852,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, if (count == 0) { if (wcount) *wcount = 0; - ret = FFS_SUCCESS; + ret = 0; goto out; } @@ -962,12 +962,12 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, if ((offset == 0) && (oneblkwrite == p_bd->sector_size)) { if (sector_read(sb, LogSector, &tmp_bh, 0) != - FFS_SUCCESS) + 0) goto err_out; memcpy((char *)tmp_bh->b_data, (char *)buffer + write_bytes, (s32)oneblkwrite); if (sector_write(sb, LogSector, tmp_bh, 0) != - FFS_SUCCESS) { + 0) { brelse(tmp_bh); goto err_out; } @@ -975,18 +975,18 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, if ((offset > 0) || ((fid->rwoffset + oneblkwrite) < fid->size)) { if (sector_read(sb, LogSector, &tmp_bh, 1) != - FFS_SUCCESS) + 0) goto err_out; } else { if (sector_read(sb, LogSector, &tmp_bh, 0) != - FFS_SUCCESS) + 0) goto err_out; } memcpy((char *)tmp_bh->b_data + offset, (char *)buffer + write_bytes, (s32)oneblkwrite); if (sector_write(sb, LogSector, tmp_bh, 0) != - FFS_SUCCESS) { + 0) { brelse(tmp_bh); goto err_out; } @@ -1100,7 +1100,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) } if (old_size <= new_size) { - ret = FFS_SUCCESS; + ret = 0; goto out; } @@ -1319,7 +1319,7 @@ static int ffsMoveFile(struct inode *old_parent_inode, struct file_id_t *fid, ret = move_file(new_parent_inode, &olddir, dentry, &newdir, &uni_name, fid); - if ((ret == FFS_SUCCESS) && new_inode) { + if ((ret == 0) && new_inode) { /* delete entries of new_dir */ ep = get_entry_in_dir(sb, p_dir, new_entry, NULL); if (!ep) @@ -1350,7 +1350,7 @@ out2: static int ffsRemoveFile(struct inode *inode, struct file_id_t *fid) { s32 dentry; - int ret = FFS_SUCCESS; + int ret = 0; struct chain_t dir, clu_to_free; struct dentry_t *ep; struct super_block *sb = inode->i_sb; @@ -1414,7 +1414,7 @@ out: static int ffsSetAttr(struct inode *inode, u32 attr) { u32 type; - int ret = FFS_SUCCESS; + int ret = 0; sector_t sector = 0; struct dentry_t *ep; struct super_block *sb = inode->i_sb; @@ -1426,7 +1426,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) if (fid->attr == attr) { if (p_fs->dev_ejected) return -EIO; - return FFS_SUCCESS; + return 0; } if (is_dir) { @@ -1434,7 +1434,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) (fid->entry == -1)) { if (p_fs->dev_ejected) return -EIO; - return FFS_SUCCESS; + return 0; } } @@ -1503,7 +1503,7 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) { sector_t sector = 0; s32 count; - int ret = FFS_SUCCESS; + int ret = 0; struct chain_t dir; struct uni_name_t uni_name; struct timestamp_t tm; @@ -1655,7 +1655,7 @@ out: static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) { sector_t sector = 0; - int ret = FFS_SUCCESS; + int ret = 0; struct timestamp_t tm; struct dentry_t *ep, *ep2; struct entry_set_cache_t *es = NULL; @@ -1674,7 +1674,7 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) (fid->entry == -1)) { if (p_fs->dev_ejected) ret = -EIO; - ret = FFS_SUCCESS; + ret = 0; goto out; } } @@ -1745,7 +1745,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) s32 num_clusters, num_alloced; bool modified = false; u32 last_clu; - int ret = FFS_SUCCESS; + int ret = 0; sector_t sector = 0; struct chain_t new_clu; struct dentry_t *ep; @@ -1898,7 +1898,7 @@ out: static int ffsCreateDir(struct inode *inode, char *path, struct file_id_t *fid) { - int ret = FFS_SUCCESS; + int ret = 0; struct chain_t dir; struct uni_name_t uni_name; struct super_block *sb = inode->i_sb; @@ -1939,7 +1939,7 @@ out: static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) { int i, dentry, clu_offset; - int ret = FFS_SUCCESS; + int ret = 0; s32 dentries_per_clu, dentries_per_clu_bits = 0; u32 type; sector_t sector; @@ -2138,7 +2138,7 @@ out: static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) { s32 dentry; - int ret = FFS_SUCCESS; + int ret = 0; struct chain_t dir, clu_to_free; struct super_block *sb = inode->i_sb; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); -- cgit v1.2.3-59-g8ed1b From ad03f80f7b7229f39623f6a11fe8cb07cab1c05e Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:56 -0500 Subject: staging: exfat: Collapse redundant return code translations Now that we no longer use odd internal return codes, we can heave the translation code over the side, and just pass the error code back up the call chain. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-9-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 92 ++++++------------------------------- 1 file changed, 14 insertions(+), 78 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 7941944ec09f..3e13e002cd14 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -650,7 +650,7 @@ static int ffsCreateFile(struct inode *inode, char *path, u8 mode, struct uni_name_t uni_name; struct super_block *sb = inode->i_sb; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - int ret; + int ret = 0; /* check the validity of pointer parameters */ if (!fid || !path || (*path == '\0')) @@ -2366,19 +2366,9 @@ static int exfat_create(struct inode *dir, struct dentry *dentry, umode_t mode, pr_debug("%s entered\n", __func__); err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_REGULAR, &fid); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOSPC) - err = -ENOSPC; - else if (err == -ENAMETOOLONG) - err = -ENAMETOOLONG; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_ctime = curtime; @@ -2543,13 +2533,9 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) EXFAT_I(inode)->fid.size = i_size_read(inode); err = ffsRemoveFile(dir, &(EXFAT_I(inode)->fid)); - if (err) { - if (err == -EPERM) - err = -EPERM; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_mtime = curtime; @@ -2589,27 +2575,14 @@ static int exfat_symlink(struct inode *dir, struct dentry *dentry, pr_debug("%s entered\n", __func__); err = ffsCreateFile(dir, (u8 *)dentry->d_name.name, FM_SYMLINK, &fid); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOSPC) - err = -ENOSPC; - else - err = -EIO; + if (err) goto out; - } + err = ffsWriteFile(dir, &fid, (char *)target, len, &ret); if (err) { ffsRemoveFile(dir, &fid); - - if (err == -ENOSPC) - err = -ENOSPC; - else - err = -EIO; goto out; } @@ -2666,19 +2639,9 @@ static int exfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) pr_debug("%s entered\n", __func__); err = ffsCreateDir(dir, (u8 *)dentry->d_name.name, &fid); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOSPC) - err = -ENOSPC; - else if (err == -ENAMETOOLONG) - err = -ENAMETOOLONG; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_ctime = curtime; @@ -2727,19 +2690,9 @@ static int exfat_rmdir(struct inode *dir, struct dentry *dentry) EXFAT_I(inode)->fid.size = i_size_read(inode); err = ffsRemoveDir(dir, &(EXFAT_I(inode)->fid)); - if (err) { - if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -ENOTEMPTY; - else if (err == -ENOENT) - err = -ENOENT; - else if (err == -EBUSY) - err = -EBUSY; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(dir); curtime = current_time(dir); dir->i_mtime = curtime; @@ -2787,21 +2740,9 @@ static int exfat_rename(struct inode *old_dir, struct dentry *old_dentry, err = ffsMoveFile(old_dir, &(EXFAT_I(old_inode)->fid), new_dir, new_dentry); - if (err) { - if (err == -EPERM) - err = -EPERM; - else if (err == -EINVAL) - err = -EINVAL; - else if (err == -EEXIST) - err = -EEXIST; - else if (err == -ENOENT) - err = -ENOENT; - else if (err == -ENOSPC) - err = -ENOSPC; - else - err = -EIO; + if (err) goto out; - } + INC_IVERSION(new_dir); curtime = current_time(new_dir); new_dir->i_ctime = curtime; @@ -3161,12 +3102,7 @@ static int exfat_bmap(struct inode *inode, sector_t sector, sector_t *phys, err = ffsMapCluster(inode, clu_offset, &cluster); - if (err) { - if (err == -ENOSPC) - return -ENOSPC; - else - return -EIO; - } else if (cluster != CLUSTER_32(~0)) { + if (!err && (cluster != CLUSTER_32(~0))) { *phys = START_SECTOR(cluster) + sec_offset; *mapped_blocks = p_fs->sectors_per_clu - sec_offset; } -- cgit v1.2.3-59-g8ed1b From ecbc9e989f62e59cdd3e87b1e7babacc765041ba Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Mon, 11 Nov 2019 21:09:57 -0500 Subject: staging: exfat: Correct return code Use -ENOTEMPTY rather than -EEXIST for attempting to remove a directory that still has files in it. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112021000.42091-10-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 3e13e002cd14..4c8afe60d48b 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -2167,7 +2167,7 @@ static int ffsRemoveDir(struct inode *inode, struct file_id_t *fid) clu_to_free.flags = fid->flags; if (!is_dir_empty(sb, &clu_to_free)) { - ret = -EEXIST; + ret = -ENOTEMPTY; goto out; } -- cgit v1.2.3-59-g8ed1b From 04a991cd9066dd182602a82e234bf91b1ea423d7 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:27 -0500 Subject: staging: exfat: Remove FAT/VFAT mount support, part 1 Remove the top-level mount functionality, to make this driver handle only exfat file systems. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-2-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/Kconfig | 9 -- drivers/staging/exfat/exfat.h | 2 - drivers/staging/exfat/exfat_core.c | 193 ------------------------------------ drivers/staging/exfat/exfat_super.c | 8 +- 4 files changed, 1 insertion(+), 211 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/Kconfig b/drivers/staging/exfat/Kconfig index ce32dfe33bec..0130019cbec2 100644 --- a/drivers/staging/exfat/Kconfig +++ b/drivers/staging/exfat/Kconfig @@ -6,15 +6,6 @@ config EXFAT_FS help This adds support for the exFAT file system. -config EXFAT_DONT_MOUNT_VFAT - bool "Prohibit mounting of fat/vfat filesystems by exFAT" - depends on EXFAT_FS - default y - help - By default, the exFAT driver will only mount exFAT filesystems, and refuse - to mount fat/vfat filesystems. Set this to 'n' to allow the exFAT driver - to mount these filesystems. - config EXFAT_DISCARD bool "enable discard support" depends on EXFAT_FS diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 72cf40e123de..68f79e13af2b 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -915,8 +915,6 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, s32 resolve_name(u8 *name, u8 **arg); /* file operation functions */ -s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); -s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); s32 create_dir(struct inode *inode, struct chain_t *p_dir, struct uni_name_t *p_uniname, struct file_id_t *fid); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 1f0ef94bdd47..89bed7460162 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -1284,57 +1284,6 @@ s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, return 0; } -static s32 fat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 num_entries, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname) -{ - int i; - sector_t sector; - u8 chksum; - u16 *uniname = p_uniname->name; - struct dos_dentry_t *dos_ep; - struct ext_dentry_t *ext_ep; - - dos_ep = (struct dos_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - §or); - if (!dos_ep) - return -EIO; - - dos_ep->lcase = p_dosname->name_case; - memcpy(dos_ep->name, p_dosname->name, DOS_NAME_LENGTH); - buf_modify(sb, sector); - - if ((--num_entries) > 0) { - chksum = calc_checksum_1byte((void *)dos_ep->name, - DOS_NAME_LENGTH, 0); - - for (i = 1; i < num_entries; i++) { - ext_ep = (struct ext_dentry_t *)get_entry_in_dir(sb, - p_dir, - entry - i, - §or); - if (!ext_ep) - return -EIO; - - init_ext_entry(ext_ep, i, chksum, uniname); - buf_modify(sb, sector); - uniname += 13; - } - - ext_ep = (struct ext_dentry_t *)get_entry_in_dir(sb, p_dir, - entry - i, - §or); - if (!ext_ep) - return -EIO; - - init_ext_entry(ext_ep, i + 0x40, chksum, uniname); - buf_modify(sb, sector); - } - - return 0; -} - static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 num_entries, struct uni_name_t *p_uniname, @@ -2981,148 +2930,6 @@ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, /* * File Operation Functions */ -static struct fs_func fat_fs_func = { - .alloc_cluster = fat_alloc_cluster, - .free_cluster = fat_free_cluster, - .count_used_clusters = fat_count_used_clusters, - - .init_dir_entry = fat_init_dir_entry, - .init_ext_entry = fat_init_ext_entry, - .find_dir_entry = fat_find_dir_entry, - .delete_dir_entry = fat_delete_dir_entry, - .get_uni_name_from_ext_entry = fat_get_uni_name_from_ext_entry, - .count_ext_entries = fat_count_ext_entries, - .calc_num_entries = fat_calc_num_entries, - - .get_entry_type = fat_get_entry_type, - .set_entry_type = fat_set_entry_type, - .get_entry_attr = fat_get_entry_attr, - .set_entry_attr = fat_set_entry_attr, - .get_entry_flag = fat_get_entry_flag, - .set_entry_flag = fat_set_entry_flag, - .get_entry_clu0 = fat_get_entry_clu0, - .set_entry_clu0 = fat_set_entry_clu0, - .get_entry_size = fat_get_entry_size, - .set_entry_size = fat_set_entry_size, - .get_entry_time = fat_get_entry_time, - .set_entry_time = fat_set_entry_time, -}; - -s32 fat16_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) -{ - s32 num_reserved, num_root_sectors; - struct bpb16_t *p_bpb = (struct bpb16_t *)p_pbr->bpb; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - if (p_bpb->num_fats == 0) - return -EFSCORRUPTED; - - num_root_sectors = GET16(p_bpb->num_root_entries) << DENTRY_SIZE_BITS; - num_root_sectors = ((num_root_sectors - 1) >> - p_bd->sector_size_bits) + 1; - - p_fs->sectors_per_clu = p_bpb->sectors_per_clu; - p_fs->sectors_per_clu_bits = ilog2(p_bpb->sectors_per_clu); - p_fs->cluster_size_bits = p_fs->sectors_per_clu_bits + - p_bd->sector_size_bits; - p_fs->cluster_size = 1 << p_fs->cluster_size_bits; - - p_fs->num_FAT_sectors = GET16(p_bpb->num_fat_sectors); - - p_fs->FAT1_start_sector = p_fs->PBR_sector + GET16(p_bpb->num_reserved); - if (p_bpb->num_fats == 1) - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector; - else - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector + - p_fs->num_FAT_sectors; - - p_fs->root_start_sector = p_fs->FAT2_start_sector + - p_fs->num_FAT_sectors; - p_fs->data_start_sector = p_fs->root_start_sector + num_root_sectors; - - p_fs->num_sectors = GET16(p_bpb->num_sectors); - if (p_fs->num_sectors == 0) - p_fs->num_sectors = GET32(p_bpb->num_huge_sectors); - - num_reserved = p_fs->data_start_sector - p_fs->PBR_sector; - p_fs->num_clusters = ((p_fs->num_sectors - num_reserved) >> - p_fs->sectors_per_clu_bits) + 2; - /* because the cluster index starts with 2 */ - - if (p_fs->num_clusters < FAT12_THRESHOLD) - p_fs->vol_type = FAT12; - else - p_fs->vol_type = FAT16; - p_fs->vol_id = GET32(p_bpb->vol_serial); - - p_fs->root_dir = 0; - p_fs->dentries_in_root = GET16(p_bpb->num_root_entries); - p_fs->dentries_per_clu = 1 << (p_fs->cluster_size_bits - - DENTRY_SIZE_BITS); - - p_fs->vol_flag = VOL_CLEAN; - p_fs->clu_srch_ptr = 2; - p_fs->used_clusters = UINT_MAX; - - p_fs->fs_func = &fat_fs_func; - - return 0; -} - -s32 fat32_mount(struct super_block *sb, struct pbr_sector_t *p_pbr) -{ - s32 num_reserved; - struct bpb32_t *p_bpb = (struct bpb32_t *)p_pbr->bpb; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - if (p_bpb->num_fats == 0) - return -EFSCORRUPTED; - - p_fs->sectors_per_clu = p_bpb->sectors_per_clu; - p_fs->sectors_per_clu_bits = ilog2(p_bpb->sectors_per_clu); - p_fs->cluster_size_bits = p_fs->sectors_per_clu_bits + - p_bd->sector_size_bits; - p_fs->cluster_size = 1 << p_fs->cluster_size_bits; - - p_fs->num_FAT_sectors = GET32(p_bpb->num_fat32_sectors); - - p_fs->FAT1_start_sector = p_fs->PBR_sector + GET16(p_bpb->num_reserved); - if (p_bpb->num_fats == 1) - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector; - else - p_fs->FAT2_start_sector = p_fs->FAT1_start_sector + - p_fs->num_FAT_sectors; - - p_fs->root_start_sector = p_fs->FAT2_start_sector + - p_fs->num_FAT_sectors; - p_fs->data_start_sector = p_fs->root_start_sector; - - p_fs->num_sectors = GET32(p_bpb->num_huge_sectors); - num_reserved = p_fs->data_start_sector - p_fs->PBR_sector; - - p_fs->num_clusters = ((p_fs->num_sectors - num_reserved) >> - p_fs->sectors_per_clu_bits) + 2; - /* because the cluster index starts with 2 */ - - p_fs->vol_type = FAT32; - p_fs->vol_id = GET32(p_bpb->vol_serial); - - p_fs->root_dir = GET32(p_bpb->root_cluster); - p_fs->dentries_in_root = 0; - p_fs->dentries_per_clu = 1 << (p_fs->cluster_size_bits - - DENTRY_SIZE_BITS); - - p_fs->vol_flag = VOL_CLEAN; - p_fs->clu_srch_ptr = 2; - p_fs->used_clusters = UINT_MAX; - - p_fs->fs_func = &fat_fs_func; - - return 0; -} - static struct fs_func exfat_fs_func = { .alloc_cluster = exfat_alloc_cluster, .free_cluster = exfat_free_cluster, diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 4c8afe60d48b..0ebf342122da 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -396,16 +396,10 @@ static int ffsMountVol(struct super_block *sb) break; if (i < 53) { -#ifdef CONFIG_EXFAT_DONT_MOUNT_VFAT + /* Not sure how we'd get here, but complain if it does */ ret = -EINVAL; pr_info("EXFAT: Attempted to mount VFAT filesystem\n"); goto out; -#else - if (GET16(p_pbr->bpb + 11)) /* num_fat_sectors */ - ret = fat16_mount(sb, p_pbr); - else - ret = fat32_mount(sb, p_pbr); -#endif } else { ret = exfat_mount(sb, p_pbr); } -- cgit v1.2.3-59-g8ed1b From 7c6d78eb7c9c55952e354fe9fd212d45d9af0807 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:28 -0500 Subject: staging: exfat: Remove FAT/VFAT mount support, part 2 Remove no longer referenced FAT/VFAT routines. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-3-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 44 --- drivers/staging/exfat/exfat_core.c | 619 ------------------------------------- 2 files changed, 663 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 68f79e13af2b..9ea865f607af 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -766,17 +766,12 @@ void fs_error(struct super_block *sb); /* cluster management functions */ s32 clear_cluster(struct super_block *sb, u32 clu); -s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, - struct chain_t *p_chain); s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain); -void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, - s32 do_relse); void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse); u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); s32 count_num_clusters(struct super_block *sb, struct chain_t *dir); -s32 fat_count_used_clusters(struct super_block *sb); s32 exfat_count_used_clusters(struct super_block *sb); void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); @@ -793,63 +788,36 @@ s32 load_upcase_table(struct super_block *sb); void free_upcase_table(struct super_block *sb); /* dir entry management functions */ -u32 fat_get_entry_type(struct dentry_t *p_entry); u32 exfat_get_entry_type(struct dentry_t *p_entry); -void fat_set_entry_type(struct dentry_t *p_entry, u32 type); void exfat_set_entry_type(struct dentry_t *p_entry, u32 type); -u32 fat_get_entry_attr(struct dentry_t *p_entry); u32 exfat_get_entry_attr(struct dentry_t *p_entry); -void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr); void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr); -u8 fat_get_entry_flag(struct dentry_t *p_entry); u8 exfat_get_entry_flag(struct dentry_t *p_entry); -void fat_set_entry_flag(struct dentry_t *p_entry, u8 flag); void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flag); -u32 fat_get_entry_clu0(struct dentry_t *p_entry); u32 exfat_get_entry_clu0(struct dentry_t *p_entry); -void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); -u64 fat_get_entry_size(struct dentry_t *p_entry); u64 exfat_get_entry_size(struct dentry_t *p_entry); -void fat_set_entry_size(struct dentry_t *p_entry, u64 size); void exfat_set_entry_size(struct dentry_t *p_entry, u64 size); struct timestamp_t *tm_current(struct timestamp_t *tm); -void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); -s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, - u32 type, u32 start_clu, u64 size); s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); -s32 fat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 num_entries, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname); s32 exfat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 num_entries, struct uni_name_t *p_uniname, struct dos_name_t *p_dosname); -void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu); -void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, - u16 *uniname); void init_file_entry(struct file_dentry_t *ep, u32 type); void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); void init_name_entry(struct name_dentry_t *ep, u16 *uniname); -void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries); void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries); s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector, s32 *offset); -struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, - s32 offset); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, @@ -865,14 +833,9 @@ s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries); s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries); -s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 num_entries, - struct dos_name_t *p_dosname, u32 type); s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type); -s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, - s32 entry, struct dentry_t *p_entry); s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, @@ -890,14 +853,9 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, void get_uni_name_from_dos_entry(struct super_block *sb, struct dos_dentry_t *ep, struct uni_name_t *p_uniname, u8 mode); -void fat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname); void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname); -s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, - u16 *uniname, s32 order); s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order); s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, @@ -905,9 +863,7 @@ s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, void fat_attach_count_to_dos_name(u8 *dosname, s32 count); s32 fat_calc_num_entries(struct uni_name_t *p_uniname); s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); -u8 calc_checksum_1byte(void *data, s32 len, u8 chksum); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); -u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type); /* name resolution functions */ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 89bed7460162..ed9e4521ec04 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -167,60 +167,6 @@ s32 clear_cluster(struct super_block *sb, u32 clu) return ret; } -s32 fat_alloc_cluster(struct super_block *sb, s32 num_alloc, - struct chain_t *p_chain) -{ - int i, num_clusters = 0; - u32 new_clu, last_clu = CLUSTER_32(~0), read_clu; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - new_clu = p_chain->dir; - if (new_clu == CLUSTER_32(~0)) - new_clu = p_fs->clu_srch_ptr; - else if (new_clu >= p_fs->num_clusters) - new_clu = 2; - - __set_sb_dirty(sb); - - p_chain->dir = CLUSTER_32(~0); - - for (i = 2; i < p_fs->num_clusters; i++) { - if (FAT_read(sb, new_clu, &read_clu) != 0) - return -1; - - if (read_clu == CLUSTER_32(0)) { - if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0) - return -1; - num_clusters++; - - if (p_chain->dir == CLUSTER_32(~0)) { - p_chain->dir = new_clu; - } else { - if (FAT_write(sb, last_clu, new_clu) < 0) - return -1; - } - - last_clu = new_clu; - - if ((--num_alloc) == 0) { - p_fs->clu_srch_ptr = new_clu; - if (p_fs->used_clusters != UINT_MAX) - p_fs->used_clusters += num_clusters; - - return num_clusters; - } - } - if ((++new_clu) >= p_fs->num_clusters) - new_clu = 2; - } - - p_fs->clu_srch_ptr = new_clu; - if (p_fs->used_clusters != UINT_MAX) - p_fs->used_clusters += num_clusters; - - return num_clusters; -} - s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { @@ -300,47 +246,6 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, return num_clusters; } -void fat_free_cluster(struct super_block *sb, struct chain_t *p_chain, - s32 do_relse) -{ - s32 num_clusters = 0; - u32 clu, prev; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - int i; - sector_t sector; - - if ((p_chain->dir == CLUSTER_32(0)) || (p_chain->dir == CLUSTER_32(~0))) - return; - __set_sb_dirty(sb); - clu = p_chain->dir; - - if (p_chain->size <= 0) - return; - - do { - if (p_fs->dev_ejected) - break; - - if (do_relse) { - sector = START_SECTOR(clu); - for (i = 0; i < p_fs->sectors_per_clu; i++) - buf_release(sb, sector + i); - } - - prev = clu; - if (FAT_read(sb, clu, &clu) == -1) - break; - - if (FAT_write(sb, prev, CLUSTER_32(0)) < 0) - break; - num_clusters++; - - } while (clu != CLUSTER_32(~0)); - - if (p_fs->used_clusters != UINT_MAX) - p_fs->used_clusters -= num_clusters; -} - void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse) { @@ -447,22 +352,6 @@ s32 count_num_clusters(struct super_block *sb, struct chain_t *p_chain) return count; } -s32 fat_count_used_clusters(struct super_block *sb) -{ - int i, count = 0; - u32 clu; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - for (i = 2; i < p_fs->num_clusters; i++) { - if (FAT_read(sb, i, &clu) != 0) - break; - if (clu != CLUSTER_32(0)) - count++; - } - - return count; -} - s32 exfat_count_used_clusters(struct super_block *sb) { int i, map_i, map_b, count = 0; @@ -907,28 +796,6 @@ void free_upcase_table(struct super_block *sb) * Directory Entry Management Functions */ -u32 fat_get_entry_type(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - if (*ep->name == 0x0) - return TYPE_UNUSED; - - else if (*ep->name == 0xE5) - return TYPE_DELETED; - - else if (ep->attr == ATTR_EXTEND) - return TYPE_EXTEND; - - else if ((ep->attr & (ATTR_SUBDIR | ATTR_VOLUME)) == ATTR_VOLUME) - return TYPE_VOLUME; - - else if ((ep->attr & (ATTR_SUBDIR | ATTR_VOLUME)) == ATTR_SUBDIR) - return TYPE_DIR; - - return TYPE_FILE; -} - u32 exfat_get_entry_type(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -974,29 +841,6 @@ u32 exfat_get_entry_type(struct dentry_t *p_entry) return TYPE_BENIGN_SEC; } -void fat_set_entry_type(struct dentry_t *p_entry, u32 type) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - if (type == TYPE_UNUSED) - *ep->name = 0x0; - - else if (type == TYPE_DELETED) - *ep->name = 0xE5; - - else if (type == TYPE_EXTEND) - ep->attr = ATTR_EXTEND; - - else if (type == TYPE_DIR) - ep->attr = ATTR_SUBDIR; - - else if (type == TYPE_FILE) - ep->attr = ATTR_ARCHIVE; - - else if (type == TYPE_SYMLINK) - ep->attr = ATTR_ARCHIVE | ATTR_SYMLINK; -} - void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1027,13 +871,6 @@ void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) } } -u32 fat_get_entry_attr(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - return (u32)ep->attr; -} - u32 exfat_get_entry_attr(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1041,13 +878,6 @@ u32 exfat_get_entry_attr(struct dentry_t *p_entry) return (u32)GET16_A(ep->attr); } -void fat_set_entry_attr(struct dentry_t *p_entry, u32 attr) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - ep->attr = (u8)attr; -} - void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -1055,11 +885,6 @@ void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) SET16_A(ep->attr, (u16)attr); } -u8 fat_get_entry_flag(struct dentry_t *p_entry) -{ - return 0x01; -} - u8 exfat_get_entry_flag(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1067,10 +892,6 @@ u8 exfat_get_entry_flag(struct dentry_t *p_entry) return ep->flags; } -void fat_set_entry_flag(struct dentry_t *p_entry, u8 flags) -{ -} - void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1078,14 +899,6 @@ void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) ep->flags = flags; } -u32 fat_get_entry_clu0(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - return ((u32)GET16_A(ep->start_clu_hi) << 16) | - GET16_A(ep->start_clu_lo); -} - u32 exfat_get_entry_clu0(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1093,14 +906,6 @@ u32 exfat_get_entry_clu0(struct dentry_t *p_entry) return GET32_A(ep->start_clu); } -void fat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - SET16_A(ep->start_clu_lo, CLUSTER_16(start_clu)); - SET16_A(ep->start_clu_hi, CLUSTER_16(start_clu >> 16)); -} - void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1108,13 +913,6 @@ void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) SET32_A(ep->start_clu, start_clu); } -u64 fat_get_entry_size(struct dentry_t *p_entry) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - return (u64)GET32_A(ep->size); -} - u64 exfat_get_entry_size(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1122,13 +920,6 @@ u64 exfat_get_entry_size(struct dentry_t *p_entry) return GET64_A(ep->valid_size); } -void fat_set_entry_size(struct dentry_t *p_entry, u64 size) -{ - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - SET32_A(ep->size, (u32)size); -} - void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -1137,31 +928,6 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) SET64_A(ep->size, size); } -void fat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode) -{ - u16 t = 0x00, d = 0x21; - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - switch (mode) { - case TM_CREATE: - t = GET16_A(ep->create_time); - d = GET16_A(ep->create_date); - break; - case TM_MODIFY: - t = GET16_A(ep->modify_time); - d = GET16_A(ep->modify_date); - break; - } - - tp->sec = (t & 0x001F) << 1; - tp->min = (t >> 5) & 0x003F; - tp->hour = (t >> 11); - tp->day = (d & 0x001F); - tp->mon = (d >> 5) & 0x000F; - tp->year = (d >> 9); -} - void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { @@ -1191,27 +957,6 @@ void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, tp->year = (d >> 9); } -void fat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode) -{ - u16 t, d; - struct dos_dentry_t *ep = (struct dos_dentry_t *)p_entry; - - t = (tp->hour << 11) | (tp->min << 5) | (tp->sec >> 1); - d = (tp->year << 9) | (tp->mon << 5) | tp->day; - - switch (mode) { - case TM_CREATE: - SET16_A(ep->create_time, t); - SET16_A(ep->create_date, d); - break; - case TM_MODIFY: - SET16_A(ep->modify_time, t); - SET16_A(ep->modify_date, d); - break; - } -} - void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { @@ -1237,23 +982,6 @@ void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, } } -s32 fat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, - u32 type, u32 start_clu, u64 size) -{ - sector_t sector; - struct dos_dentry_t *dos_ep; - - dos_ep = (struct dos_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - §or); - if (!dos_ep) - return -EIO; - - init_dos_entry(dos_ep, type, start_clu); - buf_modify(sb, sector); - - return 0; -} - s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { @@ -1330,70 +1058,6 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return 0; } -void init_dos_entry(struct dos_dentry_t *ep, u32 type, u32 start_clu) -{ - struct timestamp_t tm, *tp; - - fat_set_entry_type((struct dentry_t *)ep, type); - SET16_A(ep->start_clu_lo, CLUSTER_16(start_clu)); - SET16_A(ep->start_clu_hi, CLUSTER_16(start_clu >> 16)); - SET32_A(ep->size, 0); - - tp = tm_current(&tm); - fat_set_entry_time((struct dentry_t *)ep, tp, TM_CREATE); - fat_set_entry_time((struct dentry_t *)ep, tp, TM_MODIFY); - SET16_A(ep->access_date, 0); - ep->create_time_ms = 0; -} - -void init_ext_entry(struct ext_dentry_t *ep, s32 order, u8 chksum, u16 *uniname) -{ - int i; - bool end = false; - - fat_set_entry_type((struct dentry_t *)ep, TYPE_EXTEND); - ep->order = (u8)order; - ep->sysid = 0; - ep->checksum = chksum; - SET16_A(ep->start_clu, 0); - - for (i = 0; i < 10; i += 2) { - if (!end) { - SET16(ep->unicode_0_4 + i, *uniname); - if (*uniname == 0x0) - end = true; - else - uniname++; - } else { - SET16(ep->unicode_0_4 + i, 0xFFFF); - } - } - - for (i = 0; i < 12; i += 2) { - if (!end) { - SET16_A(ep->unicode_5_10 + i, *uniname); - if (*uniname == 0x0) - end = true; - else - uniname++; - } else { - SET16_A(ep->unicode_5_10 + i, 0xFFFF); - } - } - - for (i = 0; i < 4; i += 2) { - if (!end) { - SET16_A(ep->unicode_11_12 + i, *uniname); - if (*uniname == 0x0) - end = true; - else - uniname++; - } else { - SET16_A(ep->unicode_11_12 + i, 0xFFFF); - } - } -} - void init_file_entry(struct file_dentry_t *ep, u32 type) { struct timestamp_t tm, *tp; @@ -1433,24 +1097,6 @@ void init_name_entry(struct name_dentry_t *ep, u16 *uniname) } } -void fat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries) -{ - int i; - sector_t sector; - struct dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - for (i = num_entries - 1; i >= order; i--) { - ep = get_entry_in_dir(sb, p_dir, entry - i, §or); - if (!ep) - return; - - p_fs->fs_func->set_entry_type(ep, TYPE_DELETED); - buf_modify(sb, sector); - } -} - void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { @@ -1583,19 +1229,6 @@ s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, return 0; } -struct dentry_t *get_entry_with_sector(struct super_block *sb, sector_t sector, - s32 offset) -{ - u8 *buf; - - buf = buf_getblk(sb, sector); - - if (!buf) - return NULL; - - return (struct dentry_t *)(buf + offset); -} - struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector) { @@ -1866,46 +1499,6 @@ s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) es->num_entries); } -/* write back some entries in entry set */ -s32 write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, - struct dentry_t *ep, u32 count) -{ - s32 ret, byte_offset, off; - u32 clu = 0; - sector_t sec; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - struct chain_t dir; - - /* vaidity check */ - if (ep + count > ((struct dentry_t *)&es->__buf) + es->num_entries) - return -EINVAL; - - dir.dir = GET_CLUSTER_FROM_SECTOR(es->sector); - dir.flags = es->alloc_flag; - dir.size = 0xffffffff; /* XXX */ - - byte_offset = (es->sector - START_SECTOR(dir.dir)) << - p_bd->sector_size_bits; - byte_offset += ((void **)ep - &es->__buf) + es->offset; - - ret = _walk_fat_chain(sb, &dir, byte_offset, &clu); - if (ret != 0) - return ret; - - /* byte offset in cluster */ - byte_offset &= p_fs->cluster_size - 1; - - /* byte offset in sector */ - off = byte_offset & p_bd->sector_size_mask; - - /* sector offset in cluster */ - sec = byte_offset >> p_bd->sector_size_bits; - sec += START_SECTOR(clu); - return __write_partial_entries_in_entry_set(sb, es, sec, off, count); -} - /* search EMPTY CONTINUOUS "num_entries" entries */ s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries) @@ -2087,104 +1680,6 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries return dentry; } -/* return values of fat_find_dir_entry() - * >= 0 : return dir entiry position with the name in dir - * -1 : (root dir, ".") it is the root dir itself - * -2 : entry with the name does not exist - */ -s32 fat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 num_entries, - struct dos_name_t *p_dosname, u32 type) -{ - int i, dentry = 0, len; - s32 order = 0; - bool is_feasible_entry = true, has_ext_entry = false; - s32 dentries_per_clu; - u32 entry_type; - u16 entry_uniname[14], *uniname = NULL, unichar; - struct chain_t clu; - struct dentry_t *ep; - struct dos_dentry_t *dos_ep; - struct ext_dentry_t *ext_ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - if (p_dir->dir == p_fs->root_dir) { - if ((!nls_uniname_cmp(sb, p_uniname->name, - (u16 *)UNI_CUR_DIR_NAME)) || - (!nls_uniname_cmp(sb, p_uniname->name, - (u16 *)UNI_PAR_DIR_NAME))) - return -1; // special case, root directory itself - } - - if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ - dentries_per_clu = p_fs->dentries_in_root; - else - dentries_per_clu = p_fs->dentries_per_clu; - - clu.dir = p_dir->dir; - clu.flags = p_dir->flags; - - while (clu.dir != CLUSTER_32(~0)) { - if (p_fs->dev_ejected) - break; - - for (i = 0; i < dentries_per_clu; i++, dentry++) { - ep = get_entry_in_dir(sb, &clu, i, NULL); - if (!ep) - return -2; - - entry_type = p_fs->fs_func->get_entry_type(ep); - - if ((entry_type == TYPE_FILE) || (entry_type == TYPE_DIR)) { - if ((type == TYPE_ALL) || (type == entry_type)) { - if (is_feasible_entry && has_ext_entry) - return dentry; - - dos_ep = (struct dos_dentry_t *)ep; - if (!nls_dosname_cmp(sb, p_dosname->name, dos_ep->name)) - return dentry; - } - is_feasible_entry = true; - has_ext_entry = false; - } else if (entry_type == TYPE_EXTEND) { - if (is_feasible_entry) { - ext_ep = (struct ext_dentry_t *)ep; - if (ext_ep->order > 0x40) { - order = (s32)(ext_ep->order - 0x40); - uniname = p_uniname->name + 13 * (order - 1); - } else { - order = (s32)ext_ep->order; - uniname -= 13; - } - - len = extract_uni_name_from_ext_entry(ext_ep, entry_uniname, order); - - unichar = *(uniname + len); - *(uniname + len) = 0x0; - - if (nls_uniname_cmp(sb, uniname, entry_uniname)) - is_feasible_entry = false; - - *(uniname + len) = unichar; - } - has_ext_entry = true; - } else if (entry_type == TYPE_UNUSED) { - return -2; - } - is_feasible_entry = true; - has_ext_entry = false; - } - - if (p_dir->dir == CLUSTER_32(0)) - break; /* FAT16 root_dir */ - - if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return -2; - } - - return -2; -} - /* return values of exfat_find_dir_entry() * >= 0 : return dir entiry position with the name in dir * -1 : (root dir, ".") it is the root dir itself @@ -2333,36 +1828,6 @@ s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, return -2; } -s32 fat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, - s32 entry, struct dentry_t *p_entry) -{ - s32 count = 0; - u8 chksum; - struct dos_dentry_t *dos_ep = (struct dos_dentry_t *)p_entry; - struct ext_dentry_t *ext_ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - chksum = calc_checksum_1byte((void *)dos_ep->name, DOS_NAME_LENGTH, 0); - - for (entry--; entry >= 0; entry--) { - ext_ep = (struct ext_dentry_t *)get_entry_in_dir(sb, p_dir, - entry, NULL); - if (!ext_ep) - return -1; - - if ((p_fs->fs_func->get_entry_type((struct dentry_t *)ext_ep) == - TYPE_EXTEND) && (ext_ep->checksum == chksum)) { - count++; - if (ext_ep->order > 0x40) - return count; - } else { - return count; - } - } - - return count; -} - s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry) { @@ -2564,33 +2029,6 @@ void get_uni_name_from_dos_entry(struct super_block *sb, nls_dosname_to_uniname(sb, p_uniname, &dos_name); } -void fat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname) -{ - int i; - struct ext_dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - for (entry--, i = 1; entry >= 0; entry--, i++) { - ep = (struct ext_dentry_t *)get_entry_in_dir(sb, p_dir, entry, - NULL); - if (!ep) - return; - - if (p_fs->fs_func->get_entry_type((struct dentry_t *)ep) == - TYPE_EXTEND) { - extract_uni_name_from_ext_entry(ep, uniname, i); - if (ep->order > 0x40) - return; - } else { - return; - } - - uniname += 13; - } -} - void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname) @@ -2628,51 +2066,6 @@ out: release_entry_set(es); } -s32 extract_uni_name_from_ext_entry(struct ext_dentry_t *ep, u16 *uniname, - s32 order) -{ - int i, len = 0; - - for (i = 0; i < 10; i += 2) { - *uniname = GET16(ep->unicode_0_4 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - - if (order < 20) { - for (i = 0; i < 12; i += 2) { - *uniname = GET16_A(ep->unicode_5_10 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - } else { - for (i = 0; i < 8; i += 2) { - *uniname = GET16_A(ep->unicode_5_10 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - *uniname = 0x0; /* uniname[MAX_NAME_LENGTH-1] */ - return len; - } - - for (i = 0; i < 4; i += 2) { - *uniname = GET16_A(ep->unicode_11_12 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - - *uniname = 0x0; - return len; -} - s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order) { @@ -2812,18 +2205,6 @@ void fat_attach_count_to_dos_name(u8 *dosname, s32 count) dosname[7] = ' '; } -s32 fat_calc_num_entries(struct uni_name_t *p_uniname) -{ - s32 len; - - len = p_uniname->name_len; - if (len == 0) - return 0; - - /* 1 dos name entry + extended entries */ - return (len - 1) / 13 + 2; -} - s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; -- cgit v1.2.3-59-g8ed1b From 2a17b09fdecd580c88a5b80fd7ccd33bee576e4d Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:29 -0500 Subject: staging: exfat: Remove FAT/VFAT mount support, part 3 In this patch, we straighten out most of the cases where the code was testing 'p_fs->vol_type == EXFAT' and '!= EXFAT' There's still some ?: ops and a few places where the code is doing checks for '.' and '..' that require looking at, but those are future patches Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-4-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_cache.c | 207 +++---------------------- drivers/staging/exfat/exfat_core.c | 205 +++++++------------------ drivers/staging/exfat/exfat_super.c | 297 +++++++++--------------------------- 3 files changed, 148 insertions(+), 561 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index 28a67f8139ea..1d344c5f3e15 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -202,107 +202,22 @@ static int __FAT_read(struct super_block *sb, u32 loc, u32 *content) struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - if (p_fs->vol_type == FAT12) { - sec = p_fs->FAT1_start_sector + - ((loc + (loc >> 1)) >> p_bd->sector_size_bits); - off = (loc + (loc >> 1)) & p_bd->sector_size_mask; - - if (off == (p_bd->sector_size - 1)) { - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - _content = (u32)fat_sector[off]; - - fat_sector = FAT_getblk(sb, ++sec); - if (!fat_sector) - return -1; - - _content |= (u32)fat_sector[0] << 8; - } else { - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - fat_entry = &fat_sector[off]; - _content = GET16(fat_entry); - } - - if (loc & 1) - _content >>= 4; - - _content &= 0x00000FFF; - - if (_content >= CLUSTER_16(0x0FF8)) { - *content = CLUSTER_32(~0); - return 0; - } - *content = CLUSTER_32(_content); - return 0; - } else if (p_fs->vol_type == FAT16) { - sec = p_fs->FAT1_start_sector + - (loc >> (p_bd->sector_size_bits - 1)); - off = (loc << 1) & p_bd->sector_size_mask; - - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - fat_entry = &fat_sector[off]; - - _content = GET16_A(fat_entry); - - _content &= 0x0000FFFF; - - if (_content >= CLUSTER_16(0xFFF8)) { - *content = CLUSTER_32(~0); - return 0; - } - *content = CLUSTER_32(_content); - return 0; - } else if (p_fs->vol_type == FAT32) { - sec = p_fs->FAT1_start_sector + - (loc >> (p_bd->sector_size_bits - 2)); - off = (loc << 2) & p_bd->sector_size_mask; - - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; + sec = p_fs->FAT1_start_sector + + (loc >> (p_bd->sector_size_bits - 2)); + off = (loc << 2) & p_bd->sector_size_mask; - fat_entry = &fat_sector[off]; + fat_sector = FAT_getblk(sb, sec); + if (!fat_sector) + return -1; - _content = GET32_A(fat_entry); + fat_entry = &fat_sector[off]; + _content = GET32_A(fat_entry); - _content &= 0x0FFFFFFF; - - if (_content >= CLUSTER_32(0x0FFFFFF8)) { - *content = CLUSTER_32(~0); - return 0; - } - *content = CLUSTER_32(_content); - return 0; - } else if (p_fs->vol_type == EXFAT) { - sec = p_fs->FAT1_start_sector + - (loc >> (p_bd->sector_size_bits - 2)); - off = (loc << 2) & p_bd->sector_size_mask; - - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - fat_entry = &fat_sector[off]; - _content = GET32_A(fat_entry); - - if (_content >= CLUSTER_32(0xFFFFFFF8)) { - *content = CLUSTER_32(~0); - return 0; - } - *content = CLUSTER_32(_content); + if (_content >= CLUSTER_32(0xFFFFFFF8)) { + *content = CLUSTER_32(~0); return 0; } - - /* Unknown volume type, throw in the towel and go home */ - *content = CLUSTER_32(~0); + *content = CLUSTER_32(_content); return 0; } @@ -330,101 +245,17 @@ static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content) struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - if (p_fs->vol_type == FAT12) { - content &= 0x00000FFF; + sec = p_fs->FAT1_start_sector + (loc >> + (p_bd->sector_size_bits - 2)); + off = (loc << 2) & p_bd->sector_size_mask; - sec = p_fs->FAT1_start_sector + - ((loc + (loc >> 1)) >> p_bd->sector_size_bits); - off = (loc + (loc >> 1)) & p_bd->sector_size_mask; + fat_sector = FAT_getblk(sb, sec); + if (!fat_sector) + return -1; - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; + fat_entry = &fat_sector[off]; - if (loc & 1) { /* odd */ - content <<= 4; - - if (off == (p_bd->sector_size - 1)) { - fat_sector[off] = (u8)(content | - (fat_sector[off] & - 0x0F)); - FAT_modify(sb, sec); - - fat_sector = FAT_getblk(sb, ++sec); - if (!fat_sector) - return -1; - - fat_sector[0] = (u8)(content >> 8); - } else { - fat_entry = &fat_sector[off]; - content |= GET16(fat_entry) & 0x000F; - - SET16(fat_entry, content); - } - } else { /* even */ - fat_sector[off] = (u8)(content); - - if (off == (p_bd->sector_size - 1)) { - fat_sector[off] = (u8)(content); - FAT_modify(sb, sec); - - fat_sector = FAT_getblk(sb, ++sec); - if (!fat_sector) - return -1; - fat_sector[0] = (u8)((fat_sector[0] & 0xF0) | - (content >> 8)); - } else { - fat_entry = &fat_sector[off]; - content |= GET16(fat_entry) & 0xF000; - - SET16(fat_entry, content); - } - } - } - - else if (p_fs->vol_type == FAT16) { - content &= 0x0000FFFF; - - sec = p_fs->FAT1_start_sector + (loc >> - (p_bd->sector_size_bits - 1)); - off = (loc << 1) & p_bd->sector_size_mask; - - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - fat_entry = &fat_sector[off]; - - SET16_A(fat_entry, content); - } else if (p_fs->vol_type == FAT32) { - content &= 0x0FFFFFFF; - - sec = p_fs->FAT1_start_sector + (loc >> - (p_bd->sector_size_bits - 2)); - off = (loc << 2) & p_bd->sector_size_mask; - - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - fat_entry = &fat_sector[off]; - - content |= GET32_A(fat_entry) & 0xF0000000; - - SET32_A(fat_entry, content); - } else { /* p_fs->vol_type == EXFAT */ - sec = p_fs->FAT1_start_sector + (loc >> - (p_bd->sector_size_bits - 2)); - off = (loc << 2) & p_bd->sector_size_mask; - - fat_sector = FAT_getblk(sb, sec); - if (!fat_sector) - return -1; - - fat_entry = &fat_sector[off]; - - SET32_A(fat_entry, content); - } + SET32_A(fat_entry, content); FAT_modify(sb, sec); return 0; diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index ed9e4521ec04..77b826dfdeda 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -20,15 +20,6 @@ static void __set_sb_dirty(struct super_block *sb) static u8 name_buf[MAX_PATH_LENGTH * MAX_CHARSET_SIZE]; -static char *reserved_names[] = { - "AUX ", "CON ", "NUL ", "PRN ", - "COM1 ", "COM2 ", "COM3 ", "COM4 ", - "COM5 ", "COM6 ", "COM7 ", "COM8 ", "COM9 ", - "LPT1 ", "LPT2 ", "LPT3 ", "LPT4 ", - "LPT5 ", "LPT6 ", "LPT7 ", "LPT8 ", "LPT9 ", - NULL -}; - static u8 free_bit[] = { 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, /* 0 ~ 19 */ 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, /* 20 ~ 39 */ @@ -99,25 +90,23 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag) p_fs->vol_flag = new_flag; - if (p_fs->vol_type == EXFAT) { - if (!p_fs->pbr_bh) { - if (sector_read(sb, p_fs->PBR_sector, - &p_fs->pbr_bh, 1) != 0) - return; - } + if (!p_fs->pbr_bh) { + if (sector_read(sb, p_fs->PBR_sector, + &p_fs->pbr_bh, 1) != 0) + return; + } - p_pbr = (struct pbr_sector_t *)p_fs->pbr_bh->b_data; - p_bpb = (struct bpbex_t *)p_pbr->bpb; - SET16(p_bpb->vol_flags, (u16)new_flag); + p_pbr = (struct pbr_sector_t *)p_fs->pbr_bh->b_data; + p_bpb = (struct bpbex_t *)p_pbr->bpb; + SET16(p_bpb->vol_flags, (u16)new_flag); - /* XXX duyoung - * what can we do here? (cuz fs_set_vol_flags() is void) - */ - if ((new_flag == VOL_DIRTY) && (!buffer_dirty(p_fs->pbr_bh))) - sector_write(sb, p_fs->PBR_sector, p_fs->pbr_bh, 1); - else - sector_write(sb, p_fs->PBR_sector, p_fs->pbr_bh, 0); - } + /* XXX duyoung + * what can we do here? (cuz fs_set_vol_flags() is void) + */ + if ((new_flag == VOL_DIRTY) && (!buffer_dirty(p_fs->pbr_bh))) + sector_write(sb, p_fs->PBR_sector, p_fs->pbr_bh, 1); + else + sector_write(sb, p_fs->PBR_sector, p_fs->pbr_bh, 0); } void fs_error(struct super_block *sb) @@ -1613,10 +1602,8 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries if (p_fs->dev_ejected) break; - if (p_fs->vol_type == EXFAT) { - if (p_dir->dir != p_fs->root_dir) - size = i_size_read(inode); - } + if (p_dir->dir != p_fs->root_dir) + size = i_size_read(inode); last_clu = find_last_cluster(sb, p_dir); clu.dir = last_clu + 1; @@ -1653,21 +1640,19 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries p_dir->size++; /* (3) update the directory entry */ - if (p_fs->vol_type == EXFAT) { - if (p_dir->dir != p_fs->root_dir) { - size += p_fs->cluster_size; - - ep = get_entry_in_dir(sb, &fid->dir, - fid->entry + 1, §or); - if (!ep) - return -ENOENT; - p_fs->fs_func->set_entry_size(ep, size); - p_fs->fs_func->set_entry_flag(ep, p_dir->flags); - buf_modify(sb, sector); - - update_dir_checksum(sb, &fid->dir, - fid->entry); - } + if (p_dir->dir != p_fs->root_dir) { + size += p_fs->cluster_size; + + ep = get_entry_in_dir(sb, &fid->dir, + fid->entry + 1, §or); + if (!ep) + return -ENOENT; + p_fs->fs_func->set_entry_size(ep, size); + p_fs->fs_func->set_entry_flag(ep, p_dir->flags); + buf_modify(sb, sector); + + update_dir_checksum(sb, &fid->dir, + fid->entry); } i_size_write(inode, i_size_read(inode) + p_fs->cluster_size); @@ -1979,36 +1964,13 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 *entries, struct dos_name_t *p_dosname) { - s32 ret, num_entries; - bool lossy = false; - char **r; + s32 num_entries; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); num_entries = p_fs->fs_func->calc_num_entries(p_uniname); if (num_entries == 0) return -EINVAL; - if (p_fs->vol_type != EXFAT) { - nls_uniname_to_dosname(sb, p_dosname, p_uniname, &lossy); - - if (lossy) { - ret = fat_generate_dos_name(sb, p_dir, p_dosname); - if (ret) - return ret; - } else { - for (r = reserved_names; *r; r++) { - if (!strncmp((void *)p_dosname->name, *r, 8)) - return -EINVAL; - } - - if (p_dosname->name_case != 0xFF) - num_entries = 1; - } - - if (num_entries > 1) - p_dosname->name_case = 0x0; - } - *entries = num_entries; return 0; @@ -2392,7 +2354,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, s32 ret, dentry, num_entries; u64 size; struct chain_t clu; - struct dos_name_t dos_name, dot_name; + struct dos_name_t dos_name; struct super_block *sb = inode->i_sb; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); struct fs_func *fs_func = p_fs->fs_func; @@ -2422,45 +2384,7 @@ s32 create_dir(struct inode *inode, struct chain_t *p_dir, if (ret != 0) return ret; - if (p_fs->vol_type == EXFAT) { - size = p_fs->cluster_size; - } else { - size = 0; - - /* initialize the . and .. entry - * Information for . points to itself - * Information for .. points to parent dir - */ - - dot_name.name_case = 0x0; - memcpy(dot_name.name, DOS_CUR_DIR_NAME, DOS_NAME_LENGTH); - - ret = fs_func->init_dir_entry(sb, &clu, 0, TYPE_DIR, clu.dir, - 0); - if (ret != 0) - return ret; - - ret = fs_func->init_ext_entry(sb, &clu, 0, 1, NULL, &dot_name); - if (ret != 0) - return ret; - - memcpy(dot_name.name, DOS_PAR_DIR_NAME, DOS_NAME_LENGTH); - - if (p_dir->dir == p_fs->root_dir) - ret = fs_func->init_dir_entry(sb, &clu, 1, TYPE_DIR, - CLUSTER_32(0), 0); - else - ret = fs_func->init_dir_entry(sb, &clu, 1, TYPE_DIR, - p_dir->dir, 0); - - if (ret != 0) - return ret; - - ret = p_fs->fs_func->init_ext_entry(sb, &clu, 1, 1, NULL, - &dot_name); - if (ret != 0) - return ret; - } + size = p_fs->cluster_size; /* (2) update the directory entry */ /* make sub-dir entry in parent directory */ @@ -2626,23 +2550,21 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, buf_modify(sb, sector_new); buf_unlock(sb, sector_old); - if (p_fs->vol_type == EXFAT) { - epold = get_entry_in_dir(sb, p_dir, oldentry + 1, - §or_old); - buf_lock(sb, sector_old); - epnew = get_entry_in_dir(sb, p_dir, newentry + 1, - §or_new); - - if (!epold || !epnew) { - buf_unlock(sb, sector_old); - return -ENOENT; - } + epold = get_entry_in_dir(sb, p_dir, oldentry + 1, + §or_old); + buf_lock(sb, sector_old); + epnew = get_entry_in_dir(sb, p_dir, newentry + 1, + §or_new); - memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); - buf_modify(sb, sector_new); + if (!epold || !epnew) { buf_unlock(sb, sector_old); + return -ENOENT; } + memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); + buf_modify(sb, sector_new); + buf_unlock(sb, sector_old); + ret = fs_func->init_ext_entry(sb, p_dir, newentry, num_new_entries, p_uniname, &dos_name); @@ -2681,7 +2603,6 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, { s32 ret, newentry, num_new_entries, num_old_entries; sector_t sector_mov, sector_new; - struct chain_t clu; struct dos_name_t dos_name; struct dentry_t *epmov, *epnew; struct super_block *sb = inode->i_sb; @@ -2736,36 +2657,20 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, buf_modify(sb, sector_new); buf_unlock(sb, sector_mov); - if (p_fs->vol_type == EXFAT) { - epmov = get_entry_in_dir(sb, p_olddir, oldentry + 1, - §or_mov); - buf_lock(sb, sector_mov); - epnew = get_entry_in_dir(sb, p_newdir, newentry + 1, - §or_new); - if (!epmov || !epnew) { - buf_unlock(sb, sector_mov); - return -ENOENT; - } - - memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); - buf_modify(sb, sector_new); + epmov = get_entry_in_dir(sb, p_olddir, oldentry + 1, + §or_mov); + buf_lock(sb, sector_mov); + epnew = get_entry_in_dir(sb, p_newdir, newentry + 1, + §or_new); + if (!epmov || !epnew) { buf_unlock(sb, sector_mov); - } else if (fs_func->get_entry_type(epnew) == TYPE_DIR) { - /* change ".." pointer to new parent dir */ - clu.dir = fs_func->get_entry_clu0(epnew); - clu.flags = 0x01; - - epnew = get_entry_in_dir(sb, &clu, 1, §or_new); - if (!epnew) - return -ENOENT; - - if (p_newdir->dir == p_fs->root_dir) - fs_func->set_entry_clu0(epnew, CLUSTER_32(0)); - else - fs_func->set_entry_clu0(epnew, p_newdir->dir); - buf_modify(sb, sector_new); + return -ENOENT; } + memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); + buf_modify(sb, sector_new); + buf_unlock(sb, sector_mov); + ret = fs_func->init_ext_entry(sb, p_newdir, newentry, num_new_entries, p_uniname, &dos_name); if (ret != 0) diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 0ebf342122da..259cb5a7bd81 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -411,25 +411,21 @@ static int ffsMountVol(struct super_block *sb) goto out; } - if (p_fs->vol_type == EXFAT) { - ret = load_alloc_bitmap(sb); - if (ret) { - bdev_close(sb); - goto out; - } - ret = load_upcase_table(sb); - if (ret) { - free_alloc_bitmap(sb); - bdev_close(sb); - goto out; - } + ret = load_alloc_bitmap(sb); + if (ret) { + bdev_close(sb); + goto out; + } + ret = load_upcase_table(sb); + if (ret) { + free_alloc_bitmap(sb); + bdev_close(sb); + goto out; } if (p_fs->dev_ejected) { - if (p_fs->vol_type == EXFAT) { - free_upcase_table(sb); - free_alloc_bitmap(sb); - } + free_upcase_table(sb); + free_alloc_bitmap(sb); bdev_close(sb); ret = -EIO; goto out; @@ -458,10 +454,8 @@ static int ffsUmountVol(struct super_block *sb) fs_sync(sb, true); fs_set_vol_flags(sb, VOL_CLEAN); - if (p_fs->vol_type == EXFAT) { - free_upcase_table(sb); - free_alloc_bitmap(sb); - } + free_upcase_table(sb); + free_alloc_bitmap(sb); FAT_release_all(sb); buf_release_all(sb); @@ -593,22 +587,13 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) fid->size = 0; fid->start_clu = p_fs->root_dir; } else { - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &dir, dentry, - ES_2_ENTRIES, &ep); - if (!es) { - ret = -ENOENT; - goto out; - } - ep2 = ep + 1; - } else { - ep = get_entry_in_dir(sb, &dir, dentry, NULL); - if (!ep) { - ret = -ENOENT; - goto out; - } - ep2 = ep; + es = get_entry_set_in_dir(sb, &dir, dentry, + ES_2_ENTRIES, &ep); + if (!es) { + ret = -ENOENT; + goto out; } + ep2 = ep + 1; fid->type = p_fs->fs_func->get_entry_type(ep); fid->rwoffset = 0; @@ -624,8 +609,7 @@ static int ffsLookupFile(struct inode *inode, char *path, struct file_id_t *fid) fid->start_clu = p_fs->fs_func->get_entry_clu0(ep2); } - if (p_fs->vol_type == EXFAT) - release_entry_set(es); + release_entry_set(es); } if (p_fs->dev_ejected) @@ -812,7 +796,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, s32 num_clusters, num_alloc, num_alloced = (s32)~0; int ret = 0; u32 clu, last_clu; - sector_t LogSector, sector = 0; + sector_t LogSector; u64 oneblkwrite, write_bytes; struct chain_t new_clu; struct timestamp_t tm; @@ -1001,25 +985,15 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, brelse(tmp_bh); /* (3) update the direcoty entry */ - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, - ES_ALL_ENTRIES, &ep); - if (!es) - goto err_out; - ep2 = ep + 1; - } else { - ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); - if (!ep) - goto err_out; - ep2 = ep; - } + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, + ES_ALL_ENTRIES, &ep); + if (!es) + goto err_out; + ep2 = ep + 1; p_fs->fs_func->set_entry_time(ep, tm_current(&tm), TM_MODIFY); p_fs->fs_func->set_entry_attr(ep, fid->attr); - if (p_fs->vol_type != EXFAT) - buf_modify(sb, sector); - if (modified) { if (p_fs->fs_func->get_entry_flag(ep2) != fid->flags) p_fs->fs_func->set_entry_flag(ep2, fid->flags); @@ -1029,15 +1003,10 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, if (p_fs->fs_func->get_entry_clu0(ep2) != fid->start_clu) p_fs->fs_func->set_entry_clu0(ep2, fid->start_clu); - - if (p_fs->vol_type != EXFAT) - buf_modify(sb, sector); } - if (p_fs->vol_type == EXFAT) { - update_dir_checksum_with_entry_set(sb, es); - release_entry_set(es); - } + update_dir_checksum_with_entry_set(sb, es); + release_entry_set(es); #ifndef CONFIG_EXFAT_DELAYED_SYNC fs_sync(sb, true); @@ -1067,7 +1036,6 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) s32 num_clusters; u32 last_clu = CLUSTER_32(0); int ret = 0; - sector_t sector = 0; struct chain_t clu; struct timestamp_t tm; struct dentry_t *ep, *ep2; @@ -1132,22 +1100,13 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) } /* (1) update the directory entry */ - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, - ES_ALL_ENTRIES, &ep); - if (!es) { - ret = -ENOENT; - goto out; - } - ep2 = ep + 1; - } else { - ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); - if (!ep) { - ret = -ENOENT; - goto out; + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, + ES_ALL_ENTRIES, &ep); + if (!es) { + ret = -ENOENT; + goto out; } - ep2 = ep; - } + ep2 = ep + 1; p_fs->fs_func->set_entry_time(ep, tm_current(&tm), TM_MODIFY); p_fs->fs_func->set_entry_attr(ep, fid->attr); @@ -1158,12 +1117,8 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) p_fs->fs_func->set_entry_clu0(ep2, CLUSTER_32(0)); } - if (p_fs->vol_type != EXFAT) { - buf_modify(sb, sector); - } else { - update_dir_checksum_with_entry_set(sb, es); - release_entry_set(es); - } + update_dir_checksum_with_entry_set(sb, es); + release_entry_set(es); /* (2) cut off from the FAT chain */ if (last_clu != CLUSTER_32(0)) { @@ -1436,19 +1391,11 @@ static int ffsSetAttr(struct inode *inode, u32 attr) mutex_lock(&p_fs->v_mutex); /* get the directory entry of given file */ - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, - ES_ALL_ENTRIES, &ep); - if (!es) { - ret = -ENOENT; - goto out; - } - } else { - ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); - if (!ep) { - ret = -ENOENT; - goto out; - } + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, + ES_ALL_ENTRIES, &ep); + if (!es) { + ret = -ENOENT; + goto out; } type = p_fs->fs_func->get_entry_type(ep); @@ -1460,8 +1407,7 @@ static int ffsSetAttr(struct inode *inode, u32 attr) else ret = -EINVAL; - if (p_fs->vol_type == EXFAT) - release_entry_set(es); + release_entry_set(es); goto out; } @@ -1471,12 +1417,8 @@ static int ffsSetAttr(struct inode *inode, u32 attr) fid->attr = attr; p_fs->fs_func->set_entry_attr(ep, attr); - if (p_fs->vol_type != EXFAT) { - buf_modify(sb, sector); - } else { - update_dir_checksum_with_entry_set(sb, es); - release_entry_set(es); - } + update_dir_checksum_with_entry_set(sb, es); + release_entry_set(es); #ifndef CONFIG_EXFAT_DELAYED_SYNC fs_sync(sb, true); @@ -1495,7 +1437,6 @@ out: static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) { - sector_t sector = 0; s32 count; int ret = 0; struct chain_t dir; @@ -1552,23 +1493,13 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) } /* get the directory entry of given file or directory */ - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, - ES_2_ENTRIES, &ep); - if (!es) { - ret = -ENOENT; - goto out; - } - ep2 = ep + 1; - } else { - ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); - if (!ep) { - ret = -ENOENT; - goto out; - } - ep2 = ep; - buf_lock(sb, sector); + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, + ES_2_ENTRIES, &ep); + if (!es) { + ret = -ENOENT; + goto out; } + ep2 = ep + 1; /* set FILE_INFO structure using the acquired struct dentry_t */ info->Attr = p_fs->fs_func->get_entry_attr(ep); @@ -1599,25 +1530,13 @@ static int ffsReadStat(struct inode *inode, struct dir_entry_t *info) */ p_fs->fs_func->get_uni_name_from_ext_entry(sb, &fid->dir, fid->entry, uni_name.name); - if (*uni_name.name == 0x0 && p_fs->vol_type != EXFAT) - get_uni_name_from_dos_entry(sb, (struct dos_dentry_t *)ep, - &uni_name, 0x1); nls_uniname_to_cstring(sb, info->Name, &uni_name); - if (p_fs->vol_type == EXFAT) { - info->NumSubdirs = 2; - } else { - buf_unlock(sb, sector); - get_uni_name_from_dos_entry(sb, (struct dos_dentry_t *)ep, - &uni_name, 0x0); - nls_uniname_to_cstring(sb, info->ShortName, &uni_name); - info->NumSubdirs = 0; - } + info->NumSubdirs = 2; info->Size = p_fs->fs_func->get_entry_size(ep2); - if (p_fs->vol_type == EXFAT) - release_entry_set(es); + release_entry_set(es); if (is_dir) { dir.dir = fid->start_clu; @@ -1648,7 +1567,6 @@ out: static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) { - sector_t sector = 0; int ret = 0; struct timestamp_t tm; struct dentry_t *ep, *ep2; @@ -1676,23 +1594,13 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) fs_set_vol_flags(sb, VOL_DIRTY); /* get the directory entry of given file or directory */ - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, - ES_ALL_ENTRIES, &ep); - if (!es) { - ret = -ENOENT; - goto out; - } - ep2 = ep + 1; - } else { - /* for other than exfat */ - ep = get_entry_in_dir(sb, &fid->dir, fid->entry, §or); - if (!ep) { - ret = -ENOENT; - goto out; - } - ep2 = ep; + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, + ES_ALL_ENTRIES, &ep); + if (!es) { + ret = -ENOENT; + goto out; } + ep2 = ep + 1; p_fs->fs_func->set_entry_attr(ep, info->Attr); @@ -1715,12 +1623,8 @@ static int ffsWriteStat(struct inode *inode, struct dir_entry_t *info) p_fs->fs_func->set_entry_size(ep2, info->Size); - if (p_fs->vol_type != EXFAT) { - buf_modify(sb, sector); - } else { - update_dir_checksum_with_entry_set(sb, es); - release_entry_set(es); - } + update_dir_checksum_with_entry_set(sb, es); + release_entry_set(es); if (p_fs->dev_ejected) ret = -EIO; @@ -1740,7 +1644,6 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) bool modified = false; u32 last_clu; int ret = 0; - sector_t sector = 0; struct chain_t new_clu; struct dentry_t *ep; struct entry_set_cache_t *es = NULL; @@ -1830,28 +1733,17 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) num_clusters += num_alloced; *clu = new_clu.dir; - if (p_fs->vol_type == EXFAT) { - es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, - ES_ALL_ENTRIES, &ep); - if (!es) { - ret = -ENOENT; - goto out; - } - /* get stream entry */ - ep++; + es = get_entry_set_in_dir(sb, &fid->dir, fid->entry, + ES_ALL_ENTRIES, &ep); + if (!es) { + ret = -ENOENT; + goto out; } + /* get stream entry */ + ep++; /* (3) update directory entry */ if (modified) { - if (p_fs->vol_type != EXFAT) { - ep = get_entry_in_dir(sb, &fid->dir, - fid->entry, §or); - if (!ep) { - ret = -ENOENT; - goto out; - } - } - if (p_fs->fs_func->get_entry_flag(ep) != fid->flags) p_fs->fs_func->set_entry_flag(ep, fid->flags); @@ -1859,14 +1751,10 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) p_fs->fs_func->set_entry_clu0(ep, fid->start_clu); - if (p_fs->vol_type != EXFAT) - buf_modify(sb, sector); } - if (p_fs->vol_type == EXFAT) { - update_dir_checksum_with_entry_set(sb, es); - release_entry_set(es); - } + update_dir_checksum_with_entry_set(sb, es); + release_entry_set(es); /* add number of new blocks to inode */ inode->i_blocks += num_alloced << (p_fs->cluster_size_bits - 9); @@ -2060,25 +1948,13 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) *uni_name.name = 0x0; fs_func->get_uni_name_from_ext_entry(sb, &dir, dentry, uni_name.name); - if (*uni_name.name == 0x0 && p_fs->vol_type != EXFAT) - get_uni_name_from_dos_entry(sb, - (struct dos_dentry_t *)ep, - &uni_name, 0x1); nls_uniname_to_cstring(sb, dir_entry->Name, &uni_name); buf_unlock(sb, sector); - if (p_fs->vol_type == EXFAT) { - ep = get_entry_in_dir(sb, &clu, i + 1, NULL); - if (!ep) { - ret = -ENOENT; - goto out; - } - } else { - get_uni_name_from_dos_entry(sb, - (struct dos_dentry_t *)ep, - &uni_name, 0x0); - nls_uniname_to_cstring(sb, dir_entry->ShortName, - &uni_name); + ep = get_entry_in_dir(sb, &clu, i + 1, NULL); + if (!ep) { + ret = -ENOENT; + goto out; } dir_entry->Size = fs_func->get_entry_size(ep); @@ -3056,7 +2932,6 @@ static int exfat_bmap(struct inode *inode, sector_t sector, sector_t *phys, struct super_block *sb = inode->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); struct fs_info_t *p_fs = &sbi->fs_info; - struct bd_info_t *p_bd = &sbi->bd_info; const unsigned long blocksize = sb->s_blocksize; const unsigned char blocksize_bits = sb->s_blocksize_bits; sector_t last_block; @@ -3066,18 +2941,6 @@ static int exfat_bmap(struct inode *inode, sector_t sector, sector_t *phys, *phys = 0; *mapped_blocks = 0; - if ((p_fs->vol_type == FAT12) || (p_fs->vol_type == FAT16)) { - if (inode->i_ino == EXFAT_ROOT_INO) { - if (sector < - (p_fs->dentries_in_root >> - (p_bd->sector_size_bits - DENTRY_SIZE_BITS))) { - *phys = sector + p_fs->root_start_sector; - *mapped_blocks = 1; - } - return 0; - } - } - last_block = (i_size_read(inode) + (blocksize - 1)) >> blocksize_bits; if (sector >= last_block) { if (*create == 0) @@ -3823,7 +3686,6 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) struct exfat_sb_info *sbi; int debug, ret; long error; - char buf[50]; /* * GFP_KERNEL is ok here, because while we do hold the @@ -3870,17 +3732,6 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) * if (FAT_FIRST_ENT(sb, media) != first) */ - /* codepage is not meaningful in exfat */ - if (sbi->fs_info.vol_type != EXFAT) { - error = -EINVAL; - sprintf(buf, "cp%d", sbi->options.codepage); - sbi->nls_disk = load_nls(buf); - if (!sbi->nls_disk) { - pr_err("[EXFAT] Codepage %s not found\n", buf); - goto out_fail2; - } - } - sbi->nls_io = load_nls(sbi->options.iocharset); error = -ENOMEM; -- cgit v1.2.3-59-g8ed1b From 35a829c1b797d1a927bf54b6a958e154eb248026 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:30 -0500 Subject: staging: exfat: Remove FAT/VFAT mount support, part 4 The code simplification from the previous patch rendered a few more routines unreferenced, so heave them over the side as well. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-5-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 19 ---- drivers/staging/exfat/exfat_core.c | 137 -------------------------- drivers/staging/exfat/exfat_nls.c | 192 ------------------------------------- 3 files changed, 348 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 9ea865f607af..470e409ef536 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -729,14 +729,7 @@ static inline struct exfat_inode_info *EXFAT_I(struct inode *inode) /* NLS management function */ u16 nls_upper(struct super_block *sb, u16 a); -int nls_dosname_cmp(struct super_block *sb, u8 *a, u8 *b); int nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b); -void nls_uniname_to_dosname(struct super_block *sb, - struct dos_name_t *p_dosname, - struct uni_name_t *p_uniname, bool *p_lossy); -void nls_dosname_to_uniname(struct super_block *sb, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname); void nls_uniname_to_cstring(struct super_block *sb, u8 *p_cstring, struct uni_name_t *p_uniname); void nls_cstring_to_uniname(struct super_block *sb, @@ -805,10 +798,6 @@ void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode); s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size); -s32 exfat_init_ext_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 num_entries, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname); void init_file_entry(struct file_dentry_t *ep, u32 type); void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); @@ -850,25 +839,17 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir); s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 *entries, struct dos_name_t *p_dosname); -void get_uni_name_from_dos_entry(struct super_block *sb, - struct dos_dentry_t *ep, - struct uni_name_t *p_uniname, u8 mode); void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname); s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order); -s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, - struct dos_name_t *p_dosname); -void fat_attach_count_to_dos_name(u8 *dosname, s32 count); -s32 fat_calc_num_entries(struct uni_name_t *p_uniname); s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); /* name resolution functions */ s32 resolve_path(struct inode *inode, char *path, struct chain_t *p_dir, struct uni_name_t *p_uniname); -s32 resolve_name(u8 *name, u8 **arg); /* file operation functions */ s32 exfat_mount(struct super_block *sb, struct pbr_sector_t *p_pbr); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 77b826dfdeda..c3454e883e3c 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -1976,21 +1976,6 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, return 0; } -void get_uni_name_from_dos_entry(struct super_block *sb, - struct dos_dentry_t *ep, - struct uni_name_t *p_uniname, u8 mode) -{ - struct dos_name_t dos_name; - - if (mode == 0x0) - dos_name.name_case = 0x0; - else - dos_name.name_case = ep->lcase; - - memcpy(dos_name.name, ep->name, DOS_NAME_LENGTH); - nls_dosname_to_uniname(sb, p_uniname, &dos_name); -} - void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname) @@ -2045,128 +2030,6 @@ s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, return len; } -s32 fat_generate_dos_name(struct super_block *sb, struct chain_t *p_dir, - struct dos_name_t *p_dosname) -{ - int i, j, count = 0; - bool count_begin = false; - s32 dentries_per_clu; - u32 type; - u8 bmap[128/* 1 ~ 1023 */]; - struct chain_t clu; - struct dos_dentry_t *ep; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - - memset(bmap, 0, sizeof(bmap)); - exfat_bitmap_set(bmap, 0); - - if (p_dir->dir == CLUSTER_32(0)) /* FAT16 root_dir */ - dentries_per_clu = p_fs->dentries_in_root; - else - dentries_per_clu = p_fs->dentries_per_clu; - - clu.dir = p_dir->dir; - clu.flags = p_dir->flags; - - while (clu.dir != CLUSTER_32(~0)) { - if (p_fs->dev_ejected) - break; - - for (i = 0; i < dentries_per_clu; i++) { - ep = (struct dos_dentry_t *)get_entry_in_dir(sb, &clu, - i, NULL); - if (!ep) - return -ENOENT; - - type = p_fs->fs_func->get_entry_type((struct dentry_t *) - ep); - - if (type == TYPE_UNUSED) - break; - if ((type != TYPE_FILE) && (type != TYPE_DIR)) - continue; - - count = 0; - count_begin = false; - - for (j = 0; j < 8; j++) { - if (ep->name[j] == ' ') - break; - - if (ep->name[j] == '~') { - count_begin = true; - } else if (count_begin) { - if ((ep->name[j] >= '0') && - (ep->name[j] <= '9')) { - count = count * 10 + - (ep->name[j] - '0'); - } else { - count = 0; - count_begin = false; - } - } - } - - if ((count > 0) && (count < 1024)) - exfat_bitmap_set(bmap, count); - } - - if (p_dir->dir == CLUSTER_32(0)) - break; /* FAT16 root_dir */ - - if (FAT_read(sb, clu.dir, &clu.dir) != 0) - return -EIO; - } - - count = 0; - for (i = 0; i < 128; i++) { - if (bmap[i] != 0xFF) { - for (j = 0; j < 8; j++) { - if (exfat_bitmap_test(&bmap[i], j) == 0) { - count = (i << 3) + j; - break; - } - } - if (count != 0) - break; - } - } - - if ((count == 0) || (count >= 1024)) - return -EEXIST; - fat_attach_count_to_dos_name(p_dosname->name, count); - - /* Now dos_name has DOS~????.EXT */ - return 0; -} - -void fat_attach_count_to_dos_name(u8 *dosname, s32 count) -{ - int i, j, length; - char str_count[6]; - - snprintf(str_count, sizeof(str_count), "~%d", count); - length = strlen(str_count); - - i = 0; - j = 0; - while (j <= (8 - length)) { - i = j; - if (dosname[j] == ' ') - break; - if (dosname[j] & 0x80) - j += 2; - else - j++; - } - - for (j = 0; j < length; i++, j++) - dosname[i] = (u8)str_count[j]; - - if (i == 7) - dosname[7] = ' '; -} - s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; diff --git a/drivers/staging/exfat/exfat_nls.c b/drivers/staging/exfat/exfat_nls.c index a5c4b68925fb..91e8b0c4dce7 100644 --- a/drivers/staging/exfat/exfat_nls.c +++ b/drivers/staging/exfat/exfat_nls.c @@ -7,13 +7,6 @@ #include #include "exfat.h" -static u16 bad_dos_chars[] = { - /* + , ; = [ ] */ - 0x002B, 0x002C, 0x003B, 0x003D, 0x005B, 0x005D, - 0xFF0B, 0xFF0C, 0xFF1B, 0xFF1D, 0xFF3B, 0xFF3D, - 0 -}; - static u16 bad_uni_chars[] = { /* " * / : < > ? \ | */ 0x0022, 0x002A, 0x002F, 0x003A, @@ -96,11 +89,6 @@ static u16 *nls_wstrchr(u16 *str, u16 wchar) return NULL; } -int nls_dosname_cmp(struct super_block *sb, u8 *a, u8 *b) -{ - return strncmp(a, b, DOS_NAME_LENGTH); -} - int nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b) { int i; @@ -114,186 +102,6 @@ int nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b) return 0; } -void nls_uniname_to_dosname(struct super_block *sb, - struct dos_name_t *p_dosname, - struct uni_name_t *p_uniname, bool *p_lossy) -{ - int i, j, len; - bool lossy = false; - u8 buf[MAX_CHARSET_SIZE]; - u8 lower = 0, upper = 0; - u8 *dosname = p_dosname->name; - u16 *uniname = p_uniname->name; - u16 *p, *last_period; - struct nls_table *nls = EXFAT_SB(sb)->nls_disk; - - for (i = 0; i < DOS_NAME_LENGTH; i++) - *(dosname + i) = ' '; - - if (!nls_uniname_cmp(sb, uniname, (u16 *)UNI_CUR_DIR_NAME)) { - *(dosname) = '.'; - p_dosname->name_case = 0x0; - if (p_lossy) - *p_lossy = false; - return; - } - - if (!nls_uniname_cmp(sb, uniname, (u16 *)UNI_PAR_DIR_NAME)) { - *(dosname) = '.'; - *(dosname + 1) = '.'; - p_dosname->name_case = 0x0; - if (p_lossy) - *p_lossy = false; - return; - } - - /* search for the last embedded period */ - last_period = NULL; - for (p = uniname; *p; p++) { - if (*p == (u16)'.') - last_period = p; - } - - i = 0; - while (i < DOS_NAME_LENGTH) { - if (i == 8) { - if (!last_period) - break; - - if (uniname <= last_period) { - if (uniname < last_period) - lossy = true; - uniname = last_period + 1; - } - } - - if (*uniname == (u16)'\0') { - break; - } else if (*uniname == (u16)' ') { - lossy = true; - } else if (*uniname == (u16)'.') { - if (uniname < last_period) - lossy = true; - else - i = 8; - } else if (nls_wstrchr(bad_dos_chars, *uniname)) { - lossy = true; - *(dosname + i) = '_'; - i++; - } else { - len = convert_uni_to_ch(nls, buf, *uniname, &lossy); - - if (len > 1) { - if ((i >= 8) && ((i + len) > DOS_NAME_LENGTH)) - break; - - if ((i < 8) && ((i + len) > 8)) { - i = 8; - continue; - } - - lower = 0xFF; - - for (j = 0; j < len; j++, i++) - *(dosname + i) = *(buf + j); - } else { /* len == 1 */ - if ((*buf >= 'a') && (*buf <= 'z')) { - *(dosname + i) = *buf - ('a' - 'A'); - - if (i < 8) - lower |= 0x08; - else - lower |= 0x10; - } else if ((*buf >= 'A') && (*buf <= 'Z')) { - *(dosname + i) = *buf; - - if (i < 8) - upper |= 0x08; - else - upper |= 0x10; - } else { - *(dosname + i) = *buf; - } - i++; - } - } - - uniname++; - } - - if (*dosname == 0xE5) - *dosname = 0x05; - - if (*uniname != 0x0) - lossy = true; - - if (upper & lower) - p_dosname->name_case = 0xFF; - else - p_dosname->name_case = lower; - - if (p_lossy) - *p_lossy = lossy; -} - -void nls_dosname_to_uniname(struct super_block *sb, - struct uni_name_t *p_uniname, - struct dos_name_t *p_dosname) -{ - int i = 0, j, n = 0; - u8 buf[DOS_NAME_LENGTH + 2]; - u8 *dosname = p_dosname->name; - u16 *uniname = p_uniname->name; - struct nls_table *nls = EXFAT_SB(sb)->nls_disk; - - if (*dosname == 0x05) { - *buf = 0xE5; - i++; - n++; - } - - for (; i < 8; i++, n++) { - if (*(dosname + i) == ' ') - break; - - if ((*(dosname + i) >= 'A') && (*(dosname + i) <= 'Z') && - (p_dosname->name_case & 0x08)) - *(buf + n) = *(dosname + i) + ('a' - 'A'); - else - *(buf + n) = *(dosname + i); - } - if (*(dosname + 8) != ' ') { - *(buf + n) = '.'; - n++; - } - - for (i = 8; i < DOS_NAME_LENGTH; i++, n++) { - if (*(dosname + i) == ' ') - break; - - if ((*(dosname + i) >= 'A') && (*(dosname + i) <= 'Z') && - (p_dosname->name_case & 0x10)) - *(buf + n) = *(dosname + i) + ('a' - 'A'); - else - *(buf + n) = *(dosname + i); - } - *(buf + n) = '\0'; - - i = 0; - j = 0; - while (j < (MAX_NAME_LENGTH - 1)) { - if (*(buf + i) == '\0') - break; - - i += convert_ch_to_uni(nls, uniname, (buf + i), NULL); - - uniname++; - j++; - } - - *uniname = (u16)'\0'; -} - void nls_uniname_to_cstring(struct super_block *sb, u8 *p_cstring, struct uni_name_t *p_uniname) { -- cgit v1.2.3-59-g8ed1b From 19e2bfe6ed135ed45d6adb6860181cad49dbb90e Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:31 -0500 Subject: staging: exfat: Clean up the namespace pollution part 1 Everything referenced in the struct fs_func exfat_fs_func is located in that same .c file. Make them static and remove from exfat.h Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-6-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 32 ----------------------------- drivers/staging/exfat/exfat_core.c | 42 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 53 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 470e409ef536..5efba3d4259b 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -759,13 +759,8 @@ void fs_error(struct super_block *sb); /* cluster management functions */ s32 clear_cluster(struct super_block *sb, u32 clu); -s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, - struct chain_t *p_chain); -void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, - s32 do_relse); u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); s32 count_num_clusters(struct super_block *sb, struct chain_t *dir); -s32 exfat_count_used_clusters(struct super_block *sb); void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); /* allocation bitmap management functions */ @@ -781,29 +776,11 @@ s32 load_upcase_table(struct super_block *sb); void free_upcase_table(struct super_block *sb); /* dir entry management functions */ -u32 exfat_get_entry_type(struct dentry_t *p_entry); -void exfat_set_entry_type(struct dentry_t *p_entry, u32 type); -u32 exfat_get_entry_attr(struct dentry_t *p_entry); -void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr); -u8 exfat_get_entry_flag(struct dentry_t *p_entry); -void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flag); -u32 exfat_get_entry_clu0(struct dentry_t *p_entry); -void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu); -u64 exfat_get_entry_size(struct dentry_t *p_entry); -void exfat_set_entry_size(struct dentry_t *p_entry, u64 size); struct timestamp_t *tm_current(struct timestamp_t *tm); -void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); -void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, - u8 mode); -s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, u32 type, u32 start_clu, u64 size); void init_file_entry(struct file_dentry_t *ep, u32 type); void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); void init_name_entry(struct name_dentry_t *ep, u16 *uniname); -void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, - s32 entry, s32 order, s32 num_entries); s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector, s32 *offset); @@ -822,11 +799,6 @@ s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries); s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries); -s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, - struct uni_name_t *p_uniname, s32 num_entries, - struct dos_name_t *p_dosname, u32 type); -s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, - s32 entry, struct dentry_t *p_entry); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, @@ -839,12 +811,8 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir); s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 *entries, struct dos_name_t *p_dosname); -void exfat_get_uni_name_from_ext_entry(struct super_block *sb, - struct chain_t *p_dir, s32 entry, - u16 *uniname); s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, s32 order); -s32 exfat_calc_num_entries(struct uni_name_t *p_uniname); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); /* name resolution functions */ diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index c3454e883e3c..2dc07e81bad0 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -156,7 +156,7 @@ s32 clear_cluster(struct super_block *sb, u32 clu) return ret; } -s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, +static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { s32 num_clusters = 0; @@ -235,7 +235,7 @@ s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, return num_clusters; } -void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, +static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, s32 do_relse) { s32 num_clusters = 0; @@ -341,7 +341,7 @@ s32 count_num_clusters(struct super_block *sb, struct chain_t *p_chain) return count; } -s32 exfat_count_used_clusters(struct super_block *sb) +static s32 exfat_count_used_clusters(struct super_block *sb) { int i, map_i, map_b, count = 0; u8 k; @@ -785,7 +785,7 @@ void free_upcase_table(struct super_block *sb) * Directory Entry Management Functions */ -u32 exfat_get_entry_type(struct dentry_t *p_entry) +static u32 exfat_get_entry_type(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -830,7 +830,7 @@ u32 exfat_get_entry_type(struct dentry_t *p_entry) return TYPE_BENIGN_SEC; } -void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) +static void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; @@ -860,56 +860,56 @@ void exfat_set_entry_type(struct dentry_t *p_entry, u32 type) } } -u32 exfat_get_entry_attr(struct dentry_t *p_entry) +static u32 exfat_get_entry_attr(struct dentry_t *p_entry) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; return (u32)GET16_A(ep->attr); } -void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) +static void exfat_set_entry_attr(struct dentry_t *p_entry, u32 attr) { struct file_dentry_t *ep = (struct file_dentry_t *)p_entry; SET16_A(ep->attr, (u16)attr); } -u8 exfat_get_entry_flag(struct dentry_t *p_entry) +static u8 exfat_get_entry_flag(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; return ep->flags; } -void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) +static void exfat_set_entry_flag(struct dentry_t *p_entry, u8 flags) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; ep->flags = flags; } -u32 exfat_get_entry_clu0(struct dentry_t *p_entry) +static u32 exfat_get_entry_clu0(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; return GET32_A(ep->start_clu); } -void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) +static void exfat_set_entry_clu0(struct dentry_t *p_entry, u32 start_clu) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; SET32_A(ep->start_clu, start_clu); } -u64 exfat_get_entry_size(struct dentry_t *p_entry) +static u64 exfat_get_entry_size(struct dentry_t *p_entry) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; return GET64_A(ep->valid_size); } -void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) +static void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) { struct strm_dentry_t *ep = (struct strm_dentry_t *)p_entry; @@ -917,7 +917,7 @@ void exfat_set_entry_size(struct dentry_t *p_entry, u64 size) SET64_A(ep->size, size); } -void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { u16 t = 0x00, d = 0x21; @@ -946,7 +946,7 @@ void exfat_get_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, tp->year = (d >> 9); } -void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, +static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, u8 mode) { u16 t, d; @@ -971,7 +971,7 @@ void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *tp, } } -s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { sector_t sector; @@ -1086,7 +1086,7 @@ void init_name_entry(struct name_dentry_t *ep, u16 *uniname) } } -void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { int i; @@ -1670,7 +1670,7 @@ s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries * -1 : (root dir, ".") it is the root dir itself * -2 : entry with the name does not exist */ -s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 num_entries, struct dos_name_t *p_dosname, u32 type) { @@ -1813,7 +1813,7 @@ s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, return -2; } -s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, +static s32 exfat_count_ext_entries(struct super_block *sb, struct chain_t *p_dir, s32 entry, struct dentry_t *p_entry) { int i, count = 0; @@ -1976,7 +1976,7 @@ s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, return 0; } -void exfat_get_uni_name_from_ext_entry(struct super_block *sb, +static void exfat_get_uni_name_from_ext_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u16 *uniname) { @@ -2030,7 +2030,7 @@ s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, return len; } -s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) +static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; -- cgit v1.2.3-59-g8ed1b From ed5916c1e8db99eeab6cbbf7cba150a5cee90c0f Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:32 -0500 Subject: staging: exfat: Clean up the namespace pollution part 2 Rename all the bdev_* to exfat_bdev_* Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-7-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 10 +++++----- drivers/staging/exfat/exfat_blkdev.c | 10 +++++----- drivers/staging/exfat/exfat_core.c | 8 ++++---- drivers/staging/exfat/exfat_super.c | 16 ++++++++-------- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 5efba3d4259b..5044523ccb97 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -842,13 +842,13 @@ int multi_sector_read(struct super_block *sb, sector_t sec, int multi_sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, s32 num_secs, bool sync); -void bdev_open(struct super_block *sb); -void bdev_close(struct super_block *sb); -int bdev_read(struct super_block *sb, sector_t secno, +void exfat_bdev_open(struct super_block *sb); +void exfat_bdev_close(struct super_block *sb); +int exfat_bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, bool read); -int bdev_write(struct super_block *sb, sector_t secno, +int exfat_bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, bool sync); -int bdev_sync(struct super_block *sb); +int exfat_bdev_sync(struct super_block *sb); extern const u8 uni_upcase[]; #endif /* _EXFAT_H */ diff --git a/drivers/staging/exfat/exfat_blkdev.c b/drivers/staging/exfat/exfat_blkdev.c index 0abae041f632..7bcd98b13109 100644 --- a/drivers/staging/exfat/exfat_blkdev.c +++ b/drivers/staging/exfat/exfat_blkdev.c @@ -8,7 +8,7 @@ #include #include "exfat.h" -void bdev_open(struct super_block *sb) +void exfat_bdev_open(struct super_block *sb) { struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); @@ -23,14 +23,14 @@ void bdev_open(struct super_block *sb) p_bd->opened = true; } -void bdev_close(struct super_block *sb) +void exfat_bdev_close(struct super_block *sb) { struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); p_bd->opened = false; } -int bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, +int exfat_bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, u32 num_secs, bool read) { struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); @@ -65,7 +65,7 @@ int bdev_read(struct super_block *sb, sector_t secno, struct buffer_head **bh, return -EIO; } -int bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, +int exfat_bdev_write(struct super_block *sb, sector_t secno, struct buffer_head *bh, u32 num_secs, bool sync) { s32 count; @@ -118,7 +118,7 @@ no_bh: return -EIO; } -int bdev_sync(struct super_block *sb) +int exfat_bdev_sync(struct super_block *sb) { struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); #ifdef CONFIG_EXFAT_KERNEL_DEBUG diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 2dc07e81bad0..5a01fc25f31d 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -2569,7 +2569,7 @@ int sector_read(struct super_block *sb, sector_t sec, struct buffer_head **bh, } if (!p_fs->dev_ejected) { - ret = bdev_read(sb, sec, bh, 1, read); + ret = exfat_bdev_read(sb, sec, bh, 1, read); if (ret != 0) p_fs->dev_ejected = 1; } @@ -2598,7 +2598,7 @@ int sector_write(struct super_block *sb, sector_t sec, struct buffer_head *bh, } if (!p_fs->dev_ejected) { - ret = bdev_write(sb, sec, bh, 1, sync); + ret = exfat_bdev_write(sb, sec, bh, 1, sync); if (ret != 0) p_fs->dev_ejected = 1; } @@ -2621,7 +2621,7 @@ int multi_sector_read(struct super_block *sb, sector_t sec, } if (!p_fs->dev_ejected) { - ret = bdev_read(sb, sec, bh, num_secs, read); + ret = exfat_bdev_read(sb, sec, bh, num_secs, read); if (ret != 0) p_fs->dev_ejected = 1; } @@ -2649,7 +2649,7 @@ int multi_sector_write(struct super_block *sb, sector_t sec, } if (!p_fs->dev_ejected) { - ret = bdev_write(sb, sec, bh, num_secs, sync); + ret = exfat_bdev_write(sb, sec, bh, num_secs, sync); if (ret != 0) p_fs->dev_ejected = 1; } diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 259cb5a7bd81..3828150bca3f 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -289,7 +289,7 @@ static DEFINE_MUTEX(z_mutex); static inline void fs_sync(struct super_block *sb, bool do_sync) { if (do_sync) - bdev_sync(sb); + exfat_bdev_sync(sb); } /* @@ -361,7 +361,7 @@ static int ffsMountVol(struct super_block *sb) p_fs->dev_ejected = 0; /* open the block device */ - bdev_open(sb); + exfat_bdev_open(sb); if (p_bd->sector_size < sb->s_blocksize) { printk(KERN_INFO "EXFAT: maont failed - sector size %d less than blocksize %ld\n", @@ -385,7 +385,7 @@ static int ffsMountVol(struct super_block *sb) /* check the validity of PBR */ if (GET16_A(p_pbr->signature) != PBR_SIGNATURE) { brelse(tmp_bh); - bdev_close(sb); + exfat_bdev_close(sb); ret = -EFSCORRUPTED; goto out; } @@ -407,26 +407,26 @@ static int ffsMountVol(struct super_block *sb) brelse(tmp_bh); if (ret) { - bdev_close(sb); + exfat_bdev_close(sb); goto out; } ret = load_alloc_bitmap(sb); if (ret) { - bdev_close(sb); + exfat_bdev_close(sb); goto out; } ret = load_upcase_table(sb); if (ret) { free_alloc_bitmap(sb); - bdev_close(sb); + exfat_bdev_close(sb); goto out; } if (p_fs->dev_ejected) { free_upcase_table(sb); free_alloc_bitmap(sb); - bdev_close(sb); + exfat_bdev_close(sb); ret = -EIO; goto out; } @@ -461,7 +461,7 @@ static int ffsUmountVol(struct super_block *sb) buf_release_all(sb); /* close the block device */ - bdev_close(sb); + exfat_bdev_close(sb); if (p_fs->dev_ejected) { pr_info("[EXFAT] unmounted with media errors. Device is already ejected.\n"); -- cgit v1.2.3-59-g8ed1b From 388cd66808d52cd761c2885defd22f7f52ce4c52 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:33 -0500 Subject: staging: exfat: Clean up the namespace pollution part 3 These functions are only used in the local file, make them static Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-8-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 6 ------ drivers/staging/exfat/exfat_core.c | 8 ++++---- 2 files changed, 4 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 5044523ccb97..407dbb017c5f 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -758,8 +758,6 @@ void fs_set_vol_flags(struct super_block *sb, u32 new_flag); void fs_error(struct super_block *sb); /* cluster management functions */ -s32 clear_cluster(struct super_block *sb, u32 clu); -u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain); s32 count_num_clusters(struct super_block *sb, struct chain_t *dir); void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); @@ -782,8 +780,6 @@ void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size); void init_name_entry(struct name_dentry_t *ep, u16 *uniname); -s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, - sector_t *sector, s32 *offset); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, @@ -797,8 +793,6 @@ s32 write_partial_entries_in_entry_set(struct super_block *sb, struct dentry_t *ep, u32 count); s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries); -s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, - s32 num_entries); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 5a01fc25f31d..3ea51d12c38d 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -125,7 +125,7 @@ void fs_error(struct super_block *sb) * Cluster Management Functions */ -s32 clear_cluster(struct super_block *sb, u32 clu) +static s32 clear_cluster(struct super_block *sb, u32 clu) { sector_t s, n; s32 ret = 0; @@ -294,7 +294,7 @@ static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, p_fs->used_clusters -= num_clusters; } -u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain) +static u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain) { u32 clu, next; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -1186,7 +1186,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir, return 0; } -s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, +static s32 find_location(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector, s32 *offset) { s32 off, ret; @@ -1583,7 +1583,7 @@ s32 search_deleted_or_unused_entry(struct super_block *sb, return -1; } -s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries) +static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_entries) { s32 ret, dentry; u32 last_clu; -- cgit v1.2.3-59-g8ed1b From 9435fa8d0601b22d30a6e0d0d78a28aca5e1a7b7 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:34 -0500 Subject: staging: exfat: Clean up the namespace pollution part 4 Relocating these functions to before first use lets us make them static Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-9-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 4 -- drivers/staging/exfat/exfat_core.c | 78 +++++++++++++++++++------------------- 2 files changed, 39 insertions(+), 43 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 407dbb017c5f..48267dd11e9d 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -775,10 +775,6 @@ void free_upcase_table(struct super_block *sb); /* dir entry management functions */ struct timestamp_t *tm_current(struct timestamp_t *tm); -void init_file_entry(struct file_dentry_t *ep, u32 type); -void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, - u64 size); -void init_name_entry(struct name_dentry_t *ep, u16 *uniname); struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, s32 entry, sector_t *sector); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 3ea51d12c38d..24700b251acb 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -971,6 +971,45 @@ static void exfat_set_entry_time(struct dentry_t *p_entry, struct timestamp_t *t } } +static void init_file_entry(struct file_dentry_t *ep, u32 type) +{ + struct timestamp_t tm, *tp; + + exfat_set_entry_type((struct dentry_t *)ep, type); + + tp = tm_current(&tm); + exfat_set_entry_time((struct dentry_t *)ep, tp, TM_CREATE); + exfat_set_entry_time((struct dentry_t *)ep, tp, TM_MODIFY); + exfat_set_entry_time((struct dentry_t *)ep, tp, TM_ACCESS); + ep->create_time_ms = 0; + ep->modify_time_ms = 0; + ep->access_time_ms = 0; +} + +static void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size) +{ + exfat_set_entry_type((struct dentry_t *)ep, TYPE_STREAM); + ep->flags = flags; + SET32_A(ep->start_clu, start_clu); + SET64_A(ep->valid_size, size); + SET64_A(ep->size, size); +} + +static void init_name_entry(struct name_dentry_t *ep, u16 *uniname) +{ + int i; + + exfat_set_entry_type((struct dentry_t *)ep, TYPE_EXTEND); + ep->flags = 0x0; + + for (i = 0; i < 30; i++, i++) { + SET16_A(ep->unicode_0_14 + i, *uniname); + if (*uniname == 0x0) + break; + uniname++; + } +} + static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, u32 type, u32 start_clu, u64 size) { @@ -1047,45 +1086,6 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return 0; } -void init_file_entry(struct file_dentry_t *ep, u32 type) -{ - struct timestamp_t tm, *tp; - - exfat_set_entry_type((struct dentry_t *)ep, type); - - tp = tm_current(&tm); - exfat_set_entry_time((struct dentry_t *)ep, tp, TM_CREATE); - exfat_set_entry_time((struct dentry_t *)ep, tp, TM_MODIFY); - exfat_set_entry_time((struct dentry_t *)ep, tp, TM_ACCESS); - ep->create_time_ms = 0; - ep->modify_time_ms = 0; - ep->access_time_ms = 0; -} - -void init_strm_entry(struct strm_dentry_t *ep, u8 flags, u32 start_clu, u64 size) -{ - exfat_set_entry_type((struct dentry_t *)ep, TYPE_STREAM); - ep->flags = flags; - SET32_A(ep->start_clu, start_clu); - SET64_A(ep->valid_size, size); - SET64_A(ep->size, size); -} - -void init_name_entry(struct name_dentry_t *ep, u16 *uniname) -{ - int i; - - exfat_set_entry_type((struct dentry_t *)ep, TYPE_EXTEND); - ep->flags = 0x0; - - for (i = 0; i < 30; i++, i++) { - SET16_A(ep->unicode_0_14 + i, *uniname); - if (*uniname == 0x0) - break; - uniname++; - } -} - static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir, s32 entry, s32 order, s32 num_entries) { -- cgit v1.2.3-59-g8ed1b From a78b34b89bcbb919b912fc8c0e1e964189972d87 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:35 -0500 Subject: staging: exfat: Clean up the namespace pollution part 5 Some more functions that can be moved and made static Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-10-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 3 - drivers/staging/exfat/exfat_core.c | 182 ++++++++++++++++++------------------- 2 files changed, 91 insertions(+), 94 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 48267dd11e9d..c41fc3ec9f29 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -764,9 +764,6 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len); /* allocation bitmap management functions */ s32 load_alloc_bitmap(struct super_block *sb); void free_alloc_bitmap(struct super_block *sb); -s32 set_alloc_bitmap(struct super_block *sb, u32 clu); -s32 clr_alloc_bitmap(struct super_block *sb, u32 clu); -u32 test_alloc_bitmap(struct super_block *sb, u32 clu); void sync_alloc_bitmap(struct super_block *sb); /* upcase table management functions */ diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 24700b251acb..8d38f70c9726 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -156,6 +156,97 @@ static s32 clear_cluster(struct super_block *sb, u32 clu) return ret; } +static s32 set_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, b; + sector_t sector; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + i = clu >> (p_bd->sector_size_bits + 3); + b = clu & ((p_bd->sector_size << 3) - 1); + + sector = START_SECTOR(p_fs->map_clu) + i; + + exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b); + + return sector_write(sb, sector, p_fs->vol_amap[i], 0); +} + +static s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, b; + sector_t sector; +#ifdef CONFIG_EXFAT_DISCARD + struct exfat_sb_info *sbi = EXFAT_SB(sb); + struct exfat_mount_options *opts = &sbi->options; + int ret; +#endif /* CONFIG_EXFAT_DISCARD */ + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + i = clu >> (p_bd->sector_size_bits + 3); + b = clu & ((p_bd->sector_size << 3) - 1); + + sector = START_SECTOR(p_fs->map_clu) + i; + + exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b); + + return sector_write(sb, sector, p_fs->vol_amap[i], 0); + +#ifdef CONFIG_EXFAT_DISCARD + if (opts->discard) { + ret = sb_issue_discard(sb, START_SECTOR(clu), + (1 << p_fs->sectors_per_clu_bits), + GFP_NOFS, 0); + if (ret == -EOPNOTSUPP) { + pr_warn("discard not supported by device, disabling"); + opts->discard = 0; + } + } +#endif /* CONFIG_EXFAT_DISCARD */ +} + +static u32 test_alloc_bitmap(struct super_block *sb, u32 clu) +{ + int i, map_i, map_b; + u32 clu_base, clu_free; + u8 k, clu_mask; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + + clu_base = (clu & ~(0x7)) + 2; + clu_mask = (1 << (clu - clu_base + 2)) - 1; + + map_i = clu >> (p_bd->sector_size_bits + 3); + map_b = (clu >> 3) & p_bd->sector_size_mask; + + for (i = 2; i < p_fs->num_clusters; i += 8) { + k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); + if (clu_mask > 0) { + k |= clu_mask; + clu_mask = 0; + } + if (k < 0xFF) { + clu_free = clu_base + free_bit[k]; + if (clu_free < p_fs->num_clusters) + return clu_free; + } + clu_base += 8; + + if (((++map_b) >= p_bd->sector_size) || + (clu_base >= p_fs->num_clusters)) { + if ((++map_i) >= p_fs->map_sectors) { + clu_base = 2; + map_i = 0; + } + map_b = 0; + } + } + + return CLUSTER_32(~0); +} + static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, struct chain_t *p_chain) { @@ -468,97 +559,6 @@ void free_alloc_bitmap(struct super_block *sb) p_fs->vol_amap = NULL; } -s32 set_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, b; - sector_t sector; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - i = clu >> (p_bd->sector_size_bits + 3); - b = clu & ((p_bd->sector_size << 3) - 1); - - sector = START_SECTOR(p_fs->map_clu) + i; - - exfat_bitmap_set((u8 *)p_fs->vol_amap[i]->b_data, b); - - return sector_write(sb, sector, p_fs->vol_amap[i], 0); -} - -s32 clr_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, b; - sector_t sector; -#ifdef CONFIG_EXFAT_DISCARD - struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct exfat_mount_options *opts = &sbi->options; - int ret; -#endif /* CONFIG_EXFAT_DISCARD */ - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - i = clu >> (p_bd->sector_size_bits + 3); - b = clu & ((p_bd->sector_size << 3) - 1); - - sector = START_SECTOR(p_fs->map_clu) + i; - - exfat_bitmap_clear((u8 *)p_fs->vol_amap[i]->b_data, b); - - return sector_write(sb, sector, p_fs->vol_amap[i], 0); - -#ifdef CONFIG_EXFAT_DISCARD - if (opts->discard) { - ret = sb_issue_discard(sb, START_SECTOR(clu), - (1 << p_fs->sectors_per_clu_bits), - GFP_NOFS, 0); - if (ret == -EOPNOTSUPP) { - pr_warn("discard not supported by device, disabling"); - opts->discard = 0; - } - } -#endif /* CONFIG_EXFAT_DISCARD */ -} - -u32 test_alloc_bitmap(struct super_block *sb, u32 clu) -{ - int i, map_i, map_b; - u32 clu_base, clu_free; - u8 k, clu_mask; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - - clu_base = (clu & ~(0x7)) + 2; - clu_mask = (1 << (clu - clu_base + 2)) - 1; - - map_i = clu >> (p_bd->sector_size_bits + 3); - map_b = (clu >> 3) & p_bd->sector_size_mask; - - for (i = 2; i < p_fs->num_clusters; i += 8) { - k = *(((u8 *)p_fs->vol_amap[map_i]->b_data) + map_b); - if (clu_mask > 0) { - k |= clu_mask; - clu_mask = 0; - } - if (k < 0xFF) { - clu_free = clu_base + free_bit[k]; - if (clu_free < p_fs->num_clusters) - return clu_free; - } - clu_base += 8; - - if (((++map_b) >= p_bd->sector_size) || - (clu_base >= p_fs->num_clusters)) { - if ((++map_i) >= p_fs->map_sectors) { - clu_base = 2; - map_i = 0; - } - map_b = 0; - } - } - - return CLUSTER_32(~0); -} - void sync_alloc_bitmap(struct super_block *sb) { int i; -- cgit v1.2.3-59-g8ed1b From e5a490e03756ab07adbb736c9ecd3c34b40e0da4 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:36 -0500 Subject: staging: exfat: Clean up the namespace pollution part 6 Move a few more things so we can make them static and clear exfat.h out. At this point, pretty much everything that can be static is static. (Note: FAT_sync(), buf_sync(), and sync_alloc_bitmap() aren't called anyplace, but aren't static because (a) that will toss an error and (b) they probably *should* be getting called someplace Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-11-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 8 -- drivers/staging/exfat/exfat_core.c | 170 ++++++++++++++++++------------------- 2 files changed, 85 insertions(+), 93 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index c41fc3ec9f29..188ea1bd7162 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -780,12 +780,6 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, u32 type, struct dentry_t **file_ep); void release_entry_set(struct entry_set_cache_t *es); -s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es); -s32 write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, - struct dentry_t *ep, u32 count); -s32 search_deleted_or_unused_entry(struct super_block *sb, - struct chain_t *p_dir, s32 num_entries); s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, u32 type); void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, @@ -798,8 +792,6 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir); s32 get_num_entries_and_dos_name(struct super_block *sb, struct chain_t *p_dir, struct uni_name_t *p_uniname, s32 *entries, struct dos_name_t *p_dosname); -s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, - u16 *uniname, s32 order); u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type); /* name resolution functions */ diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 8d38f70c9726..3cc13aaaed24 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -1140,6 +1140,73 @@ void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, buf_unlock(sb, sector); } +static s32 __write_partial_entries_in_entry_set(struct super_block *sb, + struct entry_set_cache_t *es, + sector_t sec, s32 off, u32 count) +{ + s32 num_entries, buf_off = (off - es->offset); + u32 remaining_byte_in_sector, copy_entries; + struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); + struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); + u32 clu; + u8 *buf, *esbuf = (u8 *)&es->__buf; + + pr_debug("%s entered es %p sec %llu off %d count %d\n", + __func__, es, (unsigned long long)sec, off, count); + num_entries = count; + + while (num_entries) { + /* white per sector base */ + remaining_byte_in_sector = (1 << p_bd->sector_size_bits) - off; + copy_entries = min_t(s32, + remaining_byte_in_sector >> DENTRY_SIZE_BITS, + num_entries); + buf = buf_getblk(sb, sec); + if (!buf) + goto err_out; + pr_debug("es->buf %p buf_off %u\n", esbuf, buf_off); + pr_debug("copying %d entries from %p to sector %llu\n", + copy_entries, (esbuf + buf_off), + (unsigned long long)sec); + memcpy(buf + off, esbuf + buf_off, + copy_entries << DENTRY_SIZE_BITS); + buf_modify(sb, sec); + num_entries -= copy_entries; + + if (num_entries) { + /* get next sector */ + if (IS_LAST_SECTOR_IN_CLUSTER(sec)) { + clu = GET_CLUSTER_FROM_SECTOR(sec); + if (es->alloc_flag == 0x03) { + clu++; + } else { + if (FAT_read(sb, clu, &clu) == -1) + goto err_out; + } + sec = START_SECTOR(clu); + } else { + sec++; + } + off = 0; + buf_off += copy_entries << DENTRY_SIZE_BITS; + } + } + + pr_debug("%s exited successfully\n", __func__); + return 0; +err_out: + pr_debug("%s failed\n", __func__); + return -EINVAL; +} + +/* write back all entries in entry set */ +static s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) +{ + return __write_partial_entries_in_entry_set(sb, es, es->sector, + es->offset, + es->num_entries); +} + void update_dir_checksum_with_entry_set(struct super_block *sb, struct entry_set_cache_t *es) { @@ -1421,75 +1488,8 @@ void release_entry_set(struct entry_set_cache_t *es) kfree(es); } -static s32 __write_partial_entries_in_entry_set(struct super_block *sb, - struct entry_set_cache_t *es, - sector_t sec, s32 off, u32 count) -{ - s32 num_entries, buf_off = (off - es->offset); - u32 remaining_byte_in_sector, copy_entries; - struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); - struct bd_info_t *p_bd = &(EXFAT_SB(sb)->bd_info); - u32 clu; - u8 *buf, *esbuf = (u8 *)&es->__buf; - - pr_debug("%s entered es %p sec %llu off %d count %d\n", - __func__, es, (unsigned long long)sec, off, count); - num_entries = count; - - while (num_entries) { - /* white per sector base */ - remaining_byte_in_sector = (1 << p_bd->sector_size_bits) - off; - copy_entries = min_t(s32, - remaining_byte_in_sector >> DENTRY_SIZE_BITS, - num_entries); - buf = buf_getblk(sb, sec); - if (!buf) - goto err_out; - pr_debug("es->buf %p buf_off %u\n", esbuf, buf_off); - pr_debug("copying %d entries from %p to sector %llu\n", - copy_entries, (esbuf + buf_off), - (unsigned long long)sec); - memcpy(buf + off, esbuf + buf_off, - copy_entries << DENTRY_SIZE_BITS); - buf_modify(sb, sec); - num_entries -= copy_entries; - - if (num_entries) { - /* get next sector */ - if (IS_LAST_SECTOR_IN_CLUSTER(sec)) { - clu = GET_CLUSTER_FROM_SECTOR(sec); - if (es->alloc_flag == 0x03) { - clu++; - } else { - if (FAT_read(sb, clu, &clu) == -1) - goto err_out; - } - sec = START_SECTOR(clu); - } else { - sec++; - } - off = 0; - buf_off += copy_entries << DENTRY_SIZE_BITS; - } - } - - pr_debug("%s exited successfully\n", __func__); - return 0; -err_out: - pr_debug("%s failed\n", __func__); - return -EINVAL; -} - -/* write back all entries in entry set */ -s32 write_whole_entry_set(struct super_block *sb, struct entry_set_cache_t *es) -{ - return __write_partial_entries_in_entry_set(sb, es, es->sector, - es->offset, - es->num_entries); -} - /* search EMPTY CONTINUOUS "num_entries" entries */ -s32 search_deleted_or_unused_entry(struct super_block *sb, +static s32 search_deleted_or_unused_entry(struct super_block *sb, struct chain_t *p_dir, s32 num_entries) { int i, dentry, num_empty = 0; @@ -1665,6 +1665,23 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_ return dentry; } +static s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, + s32 order) +{ + int i, len = 0; + + for (i = 0; i < 30; i += 2) { + *uniname = GET16_A(ep->unicode_0_14 + i); + if (*uniname == 0x0) + return len; + uniname++; + len++; + } + + *uniname = 0x0; + return len; +} + /* return values of exfat_find_dir_entry() * >= 0 : return dir entiry position with the name in dir * -1 : (root dir, ".") it is the root dir itself @@ -2013,23 +2030,6 @@ out: release_entry_set(es); } -s32 extract_uni_name_from_name_entry(struct name_dentry_t *ep, u16 *uniname, - s32 order) -{ - int i, len = 0; - - for (i = 0; i < 30; i += 2) { - *uniname = GET16_A(ep->unicode_0_14 + i); - if (*uniname == 0x0) - return len; - uniname++; - len++; - } - - *uniname = 0x0; - return len; -} - static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) { s32 len; -- cgit v1.2.3-59-g8ed1b From 99a4b135289ed3e633a2f6bba1750513d9e4f731 Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:37 -0500 Subject: staging: exfat: Clean up the namespace pollution part 7 Global functions called 'buf*' are a linkage editor disaster waiting to happen. Rename our buf_* functions to exfat_buf_* Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-12-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 18 +++---- drivers/staging/exfat/exfat_cache.c | 22 ++++----- drivers/staging/exfat/exfat_core.c | 96 ++++++++++++++++++------------------- drivers/staging/exfat/exfat_super.c | 12 ++--- 4 files changed, 74 insertions(+), 74 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 188ea1bd7162..6a9cb6c68d28 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -737,21 +737,21 @@ void nls_cstring_to_uniname(struct super_block *sb, bool *p_lossy); /* buffer cache management */ -void buf_init(struct super_block *sb); -void buf_shutdown(struct super_block *sb); +void exfat_buf_init(struct super_block *sb); +void exfat_buf_shutdown(struct super_block *sb); int FAT_read(struct super_block *sb, u32 loc, u32 *content); s32 FAT_write(struct super_block *sb, u32 loc, u32 content); u8 *FAT_getblk(struct super_block *sb, sector_t sec); void FAT_modify(struct super_block *sb, sector_t sec); void FAT_release_all(struct super_block *sb); void FAT_sync(struct super_block *sb); -u8 *buf_getblk(struct super_block *sb, sector_t sec); -void buf_modify(struct super_block *sb, sector_t sec); -void buf_lock(struct super_block *sb, sector_t sec); -void buf_unlock(struct super_block *sb, sector_t sec); -void buf_release(struct super_block *sb, sector_t sec); -void buf_release_all(struct super_block *sb); -void buf_sync(struct super_block *sb); +u8 *exfat_buf_getblk(struct super_block *sb, sector_t sec); +void exfat_buf_modify(struct super_block *sb, sector_t sec); +void exfat_buf_lock(struct super_block *sb, sector_t sec); +void exfat_buf_unlock(struct super_block *sb, sector_t sec); +void exfat_buf_release(struct super_block *sb, sector_t sec); +void exfat_buf_release_all(struct super_block *sb); +void exfat_buf_sync(struct super_block *sb); /* fs management functions */ void fs_set_vol_flags(struct super_block *sb, u32 new_flag); diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index 1d344c5f3e15..835871b2a3d0 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -128,7 +128,7 @@ static void buf_cache_remove_hash(struct buf_cache_t *bp) (bp->hash_next)->hash_prev = bp->hash_prev; } -void buf_init(struct super_block *sb) +void exfat_buf_init(struct super_block *sb) { struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -189,7 +189,7 @@ void buf_init(struct super_block *sb) buf_cache_insert_hash(sb, &p_fs->buf_cache_array[i]); } -void buf_shutdown(struct super_block *sb) +void exfat_buf_shutdown(struct super_block *sb) { } @@ -392,7 +392,7 @@ static struct buf_cache_t *buf_cache_get(struct super_block *sb, sector_t sec) return bp; } -static u8 *__buf_getblk(struct super_block *sb, sector_t sec) +static u8 *__exfat_buf_getblk(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -427,18 +427,18 @@ static u8 *__buf_getblk(struct super_block *sb, sector_t sec) return bp->buf_bh->b_data; } -u8 *buf_getblk(struct super_block *sb, sector_t sec) +u8 *exfat_buf_getblk(struct super_block *sb, sector_t sec) { u8 *buf; mutex_lock(&b_mutex); - buf = __buf_getblk(sb, sec); + buf = __exfat_buf_getblk(sb, sec); mutex_unlock(&b_mutex); return buf; } -void buf_modify(struct super_block *sb, sector_t sec) +void exfat_buf_modify(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; @@ -454,7 +454,7 @@ void buf_modify(struct super_block *sb, sector_t sec) mutex_unlock(&b_mutex); } -void buf_lock(struct super_block *sb, sector_t sec) +void exfat_buf_lock(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; @@ -470,7 +470,7 @@ void buf_lock(struct super_block *sb, sector_t sec) mutex_unlock(&b_mutex); } -void buf_unlock(struct super_block *sb, sector_t sec) +void exfat_buf_unlock(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; @@ -486,7 +486,7 @@ void buf_unlock(struct super_block *sb, sector_t sec) mutex_unlock(&b_mutex); } -void buf_release(struct super_block *sb, sector_t sec) +void exfat_buf_release(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -510,7 +510,7 @@ void buf_release(struct super_block *sb, sector_t sec) mutex_unlock(&b_mutex); } -void buf_release_all(struct super_block *sb) +void exfat_buf_release_all(struct super_block *sb) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -535,7 +535,7 @@ void buf_release_all(struct super_block *sb) mutex_unlock(&b_mutex); } -void buf_sync(struct super_block *sb) +void exfat_buf_sync(struct super_block *sb) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 3cc13aaaed24..f60fb691e165 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -352,7 +352,7 @@ static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, if (do_relse) { sector = START_SECTOR(clu); for (i = 0; i < p_fs->sectors_per_clu; i++) - buf_release(sb, sector + i); + exfat_buf_release(sb, sector + i); } if (clr_alloc_bitmap(sb, clu - 2) != 0) @@ -369,7 +369,7 @@ static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, if (do_relse) { sector = START_SECTOR(clu); for (i = 0; i < p_fs->sectors_per_clu; i++) - buf_release(sb, sector + i); + exfat_buf_release(sb, sector + i); } if (clr_alloc_bitmap(sb, clu - 2) != 0) @@ -1032,10 +1032,10 @@ static s32 exfat_init_dir_entry(struct super_block *sb, struct chain_t *p_dir, return -ENOENT; init_file_entry(file_ep, type); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); init_strm_entry(strm_ep, flags, start_clu, size); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); return 0; } @@ -1058,7 +1058,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return -ENOENT; file_ep->num_ext = (u8)(num_entries - 1); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); strm_ep = (struct strm_dentry_t *)get_entry_in_dir(sb, p_dir, entry + 1, §or); @@ -1067,7 +1067,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, strm_ep->name_len = p_uniname->name_len; SET16_A(strm_ep->name_hash, p_uniname->name_hash); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); for (i = 2; i < num_entries; i++) { name_ep = (struct name_dentry_t *)get_entry_in_dir(sb, p_dir, @@ -1077,7 +1077,7 @@ static s32 exfat_init_ext_entry(struct super_block *sb, struct chain_t *p_dir, return -ENOENT; init_name_entry(name_ep, uniname); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); uniname += 15; } @@ -1100,7 +1100,7 @@ static void exfat_delete_dir_entry(struct super_block *sb, struct chain_t *p_dir return; p_fs->fs_func->set_entry_type(ep, TYPE_DELETED); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); } } @@ -1118,7 +1118,7 @@ void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, if (!file_ep) return; - buf_lock(sb, sector); + exfat_buf_lock(sb, sector); num_entries = (s32)file_ep->num_ext + 1; chksum = calc_checksum_2byte((void *)file_ep, DENTRY_SIZE, 0, @@ -1127,7 +1127,7 @@ void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, for (i = 1; i < num_entries; i++) { ep = get_entry_in_dir(sb, p_dir, entry + i, NULL); if (!ep) { - buf_unlock(sb, sector); + exfat_buf_unlock(sb, sector); return; } @@ -1136,8 +1136,8 @@ void update_dir_checksum(struct super_block *sb, struct chain_t *p_dir, } SET16_A(file_ep->checksum, chksum); - buf_modify(sb, sector); - buf_unlock(sb, sector); + exfat_buf_modify(sb, sector); + exfat_buf_unlock(sb, sector); } static s32 __write_partial_entries_in_entry_set(struct super_block *sb, @@ -1161,7 +1161,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, copy_entries = min_t(s32, remaining_byte_in_sector >> DENTRY_SIZE_BITS, num_entries); - buf = buf_getblk(sb, sec); + buf = exfat_buf_getblk(sb, sec); if (!buf) goto err_out; pr_debug("es->buf %p buf_off %u\n", esbuf, buf_off); @@ -1170,7 +1170,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, (unsigned long long)sec); memcpy(buf + off, esbuf + buf_off, copy_entries << DENTRY_SIZE_BITS); - buf_modify(sb, sec); + exfat_buf_modify(sb, sec); num_entries -= copy_entries; if (num_entries) { @@ -1295,7 +1295,7 @@ struct dentry_t *get_entry_in_dir(struct super_block *sb, struct chain_t *p_dir, if (find_location(sb, p_dir, entry, &sec, &off) != 0) return NULL; - buf = buf_getblk(sb, sec); + buf = exfat_buf_getblk(sb, sec); if (!buf) return NULL; @@ -1359,7 +1359,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, sec = byte_offset >> p_bd->sector_size_bits; sec += START_SECTOR(clu); - buf = buf_getblk(sb, sec); + buf = exfat_buf_getblk(sb, sec); if (!buf) goto err_out; @@ -1457,7 +1457,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, } else { sec++; } - buf = buf_getblk(sb, sec); + buf = exfat_buf_getblk(sb, sec); if (!buf) goto err_out; off = 0; @@ -1649,7 +1649,7 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_ return -ENOENT; p_fs->fs_func->set_entry_size(ep, size); p_fs->fs_func->set_entry_flag(ep, p_dir->flags); - buf_modify(sb, sector); + exfat_buf_modify(sb, sector); update_dir_checksum(sb, &fid->dir, fid->entry); @@ -2341,17 +2341,17 @@ void remove_file(struct inode *inode, struct chain_t *p_dir, s32 entry) if (!ep) return; - buf_lock(sb, sector); + exfat_buf_lock(sb, sector); - /* buf_lock() before call count_ext_entries() */ + /* exfat_buf_lock() before call count_ext_entries() */ num_entries = fs_func->count_ext_entries(sb, p_dir, entry, ep); if (num_entries < 0) { - buf_unlock(sb, sector); + exfat_buf_unlock(sb, sector); return; } num_entries++; - buf_unlock(sb, sector); + exfat_buf_unlock(sb, sector); /* (1) update the directory entry */ fs_func->delete_dir_entry(sb, p_dir, entry, 0, num_entries); @@ -2372,13 +2372,13 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, if (!epold) return -ENOENT; - buf_lock(sb, sector_old); + exfat_buf_lock(sb, sector_old); - /* buf_lock() before call count_ext_entries() */ + /* exfat_buf_lock() before call count_ext_entries() */ num_old_entries = fs_func->count_ext_entries(sb, p_dir, oldentry, epold); if (num_old_entries < 0) { - buf_unlock(sb, sector_old); + exfat_buf_unlock(sb, sector_old); return -ENOENT; } num_old_entries++; @@ -2386,20 +2386,20 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ret = get_num_entries_and_dos_name(sb, p_dir, p_uniname, &num_new_entries, &dos_name); if (ret) { - buf_unlock(sb, sector_old); + exfat_buf_unlock(sb, sector_old); return ret; } if (num_old_entries < num_new_entries) { newentry = find_empty_entry(inode, p_dir, num_new_entries); if (newentry < 0) { - buf_unlock(sb, sector_old); + exfat_buf_unlock(sb, sector_old); return -ENOSPC; } epnew = get_entry_in_dir(sb, p_dir, newentry, §or_new); if (!epnew) { - buf_unlock(sb, sector_old); + exfat_buf_unlock(sb, sector_old); return -ENOENT; } @@ -2410,23 +2410,23 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ATTR_ARCHIVE); fid->attr |= ATTR_ARCHIVE; } - buf_modify(sb, sector_new); - buf_unlock(sb, sector_old); + exfat_buf_modify(sb, sector_new); + exfat_buf_unlock(sb, sector_old); epold = get_entry_in_dir(sb, p_dir, oldentry + 1, §or_old); - buf_lock(sb, sector_old); + exfat_buf_lock(sb, sector_old); epnew = get_entry_in_dir(sb, p_dir, newentry + 1, §or_new); if (!epold || !epnew) { - buf_unlock(sb, sector_old); + exfat_buf_unlock(sb, sector_old); return -ENOENT; } memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); - buf_modify(sb, sector_new); - buf_unlock(sb, sector_old); + exfat_buf_modify(sb, sector_new); + exfat_buf_unlock(sb, sector_old); ret = fs_func->init_ext_entry(sb, p_dir, newentry, num_new_entries, p_uniname, @@ -2444,8 +2444,8 @@ s32 rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ATTR_ARCHIVE); fid->attr |= ATTR_ARCHIVE; } - buf_modify(sb, sector_old); - buf_unlock(sb, sector_old); + exfat_buf_modify(sb, sector_old); + exfat_buf_unlock(sb, sector_old); ret = fs_func->init_ext_entry(sb, p_dir, oldentry, num_new_entries, p_uniname, @@ -2481,13 +2481,13 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, fs_func->get_entry_clu0(epmov) == p_newdir->dir) return -EINVAL; - buf_lock(sb, sector_mov); + exfat_buf_lock(sb, sector_mov); - /* buf_lock() before call count_ext_entries() */ + /* exfat_buf_lock() before call count_ext_entries() */ num_old_entries = fs_func->count_ext_entries(sb, p_olddir, oldentry, epmov); if (num_old_entries < 0) { - buf_unlock(sb, sector_mov); + exfat_buf_unlock(sb, sector_mov); return -ENOENT; } num_old_entries++; @@ -2495,19 +2495,19 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, ret = get_num_entries_and_dos_name(sb, p_newdir, p_uniname, &num_new_entries, &dos_name); if (ret) { - buf_unlock(sb, sector_mov); + exfat_buf_unlock(sb, sector_mov); return ret; } newentry = find_empty_entry(inode, p_newdir, num_new_entries); if (newentry < 0) { - buf_unlock(sb, sector_mov); + exfat_buf_unlock(sb, sector_mov); return -ENOSPC; } epnew = get_entry_in_dir(sb, p_newdir, newentry, §or_new); if (!epnew) { - buf_unlock(sb, sector_mov); + exfat_buf_unlock(sb, sector_mov); return -ENOENT; } @@ -2517,22 +2517,22 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, ATTR_ARCHIVE); fid->attr |= ATTR_ARCHIVE; } - buf_modify(sb, sector_new); - buf_unlock(sb, sector_mov); + exfat_buf_modify(sb, sector_new); + exfat_buf_unlock(sb, sector_mov); epmov = get_entry_in_dir(sb, p_olddir, oldentry + 1, §or_mov); - buf_lock(sb, sector_mov); + exfat_buf_lock(sb, sector_mov); epnew = get_entry_in_dir(sb, p_newdir, newentry + 1, §or_new); if (!epmov || !epnew) { - buf_unlock(sb, sector_mov); + exfat_buf_unlock(sb, sector_mov); return -ENOENT; } memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); - buf_modify(sb, sector_new); - buf_unlock(sb, sector_mov); + exfat_buf_modify(sb, sector_new); + exfat_buf_unlock(sb, sector_mov); ret = fs_func->init_ext_entry(sb, p_newdir, newentry, num_new_entries, p_uniname, &dos_name); diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 3828150bca3f..4b8915098d20 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -355,7 +355,7 @@ static int ffsMountVol(struct super_block *sb) mutex_lock(&z_mutex); - buf_init(sb); + exfat_buf_init(sb); mutex_init(&p_fs->v_mutex); p_fs->dev_ejected = 0; @@ -458,7 +458,7 @@ static int ffsUmountVol(struct super_block *sb) free_alloc_bitmap(sb); FAT_release_all(sb); - buf_release_all(sb); + exfat_buf_release_all(sb); /* close the block device */ exfat_bdev_close(sb); @@ -468,7 +468,7 @@ static int ffsUmountVol(struct super_block *sb) err = -EIO; } - buf_shutdown(sb); + exfat_buf_shutdown(sb); /* release the lock for file system critical section */ mutex_unlock(&p_fs->v_mutex); @@ -1921,7 +1921,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) if ((type != TYPE_FILE) && (type != TYPE_DIR)) continue; - buf_lock(sb, sector); + exfat_buf_lock(sb, sector); dir_entry->Attr = fs_func->get_entry_attr(ep); fs_func->get_entry_time(ep, &tm, TM_CREATE); @@ -1949,7 +1949,7 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) fs_func->get_uni_name_from_ext_entry(sb, &dir, dentry, uni_name.name); nls_uniname_to_cstring(sb, dir_entry->Name, &uni_name); - buf_unlock(sb, sector); + exfat_buf_unlock(sb, sector); ep = get_entry_in_dir(sb, &clu, i + 1, NULL); if (!ep) { @@ -3822,7 +3822,7 @@ static void exfat_debug_kill_sb(struct super_block *sb) */ mutex_lock(&p_fs->v_mutex); FAT_release_all(sb); - buf_release_all(sb); + exfat_buf_release_all(sb); mutex_unlock(&p_fs->v_mutex); invalidate_bdev(bdev); -- cgit v1.2.3-59-g8ed1b From 65b88d81f5c9603ddfc86fc86c28f282408ffe8e Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 16:12:38 -0500 Subject: staging: exfat: Clean up the namespace pollution part 8 Rename all the FAT_* functions to exfat_fat_*. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112211238.156490-13-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat.h | 12 ++++++------ drivers/staging/exfat/exfat_cache.c | 26 +++++++++++++------------- drivers/staging/exfat/exfat_core.c | 34 +++++++++++++++++----------------- drivers/staging/exfat/exfat_super.c | 30 +++++++++++++++--------------- 4 files changed, 51 insertions(+), 51 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat.h b/drivers/staging/exfat/exfat.h index 6a9cb6c68d28..2aac1e000977 100644 --- a/drivers/staging/exfat/exfat.h +++ b/drivers/staging/exfat/exfat.h @@ -739,12 +739,12 @@ void nls_cstring_to_uniname(struct super_block *sb, /* buffer cache management */ void exfat_buf_init(struct super_block *sb); void exfat_buf_shutdown(struct super_block *sb); -int FAT_read(struct super_block *sb, u32 loc, u32 *content); -s32 FAT_write(struct super_block *sb, u32 loc, u32 content); -u8 *FAT_getblk(struct super_block *sb, sector_t sec); -void FAT_modify(struct super_block *sb, sector_t sec); -void FAT_release_all(struct super_block *sb); -void FAT_sync(struct super_block *sb); +int exfat_fat_read(struct super_block *sb, u32 loc, u32 *content); +s32 exfat_fat_write(struct super_block *sb, u32 loc, u32 content); +u8 *exfat_fat_getblk(struct super_block *sb, sector_t sec); +void exfat_fat_modify(struct super_block *sb, sector_t sec); +void exfat_fat_release_all(struct super_block *sb); +void exfat_fat_sync(struct super_block *sb); u8 *exfat_buf_getblk(struct super_block *sb, sector_t sec); void exfat_buf_modify(struct super_block *sb, sector_t sec); void exfat_buf_lock(struct super_block *sb, sector_t sec); diff --git a/drivers/staging/exfat/exfat_cache.c b/drivers/staging/exfat/exfat_cache.c index 835871b2a3d0..3fd5604058a9 100644 --- a/drivers/staging/exfat/exfat_cache.c +++ b/drivers/staging/exfat/exfat_cache.c @@ -193,7 +193,7 @@ void exfat_buf_shutdown(struct super_block *sb) { } -static int __FAT_read(struct super_block *sb, u32 loc, u32 *content) +static int __exfat_fat_read(struct super_block *sb, u32 loc, u32 *content) { s32 off; u32 _content; @@ -206,7 +206,7 @@ static int __FAT_read(struct super_block *sb, u32 loc, u32 *content) (loc >> (p_bd->sector_size_bits - 2)); off = (loc << 2) & p_bd->sector_size_mask; - fat_sector = FAT_getblk(sb, sec); + fat_sector = exfat_fat_getblk(sb, sec); if (!fat_sector) return -1; @@ -226,18 +226,18 @@ static int __FAT_read(struct super_block *sb, u32 loc, u32 *content) * returns 0 on success * -1 on error */ -int FAT_read(struct super_block *sb, u32 loc, u32 *content) +int exfat_fat_read(struct super_block *sb, u32 loc, u32 *content) { s32 ret; mutex_lock(&f_mutex); - ret = __FAT_read(sb, loc, content); + ret = __exfat_fat_read(sb, loc, content); mutex_unlock(&f_mutex); return ret; } -static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content) +static s32 __exfat_fat_write(struct super_block *sb, u32 loc, u32 content) { s32 off; sector_t sec; @@ -249,7 +249,7 @@ static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content) (p_bd->sector_size_bits - 2)); off = (loc << 2) & p_bd->sector_size_mask; - fat_sector = FAT_getblk(sb, sec); + fat_sector = exfat_fat_getblk(sb, sec); if (!fat_sector) return -1; @@ -257,22 +257,22 @@ static s32 __FAT_write(struct super_block *sb, u32 loc, u32 content) SET32_A(fat_entry, content); - FAT_modify(sb, sec); + exfat_fat_modify(sb, sec); return 0; } -int FAT_write(struct super_block *sb, u32 loc, u32 content) +int exfat_fat_write(struct super_block *sb, u32 loc, u32 content) { s32 ret; mutex_lock(&f_mutex); - ret = __FAT_write(sb, loc, content); + ret = __exfat_fat_write(sb, loc, content); mutex_unlock(&f_mutex); return ret; } -u8 *FAT_getblk(struct super_block *sb, sector_t sec) +u8 *exfat_fat_getblk(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -307,7 +307,7 @@ u8 *FAT_getblk(struct super_block *sb, sector_t sec) return bp->buf_bh->b_data; } -void FAT_modify(struct super_block *sb, sector_t sec) +void exfat_fat_modify(struct super_block *sb, sector_t sec) { struct buf_cache_t *bp; @@ -316,7 +316,7 @@ void FAT_modify(struct super_block *sb, sector_t sec) sector_write(sb, sec, bp->buf_bh, 0); } -void FAT_release_all(struct super_block *sb) +void exfat_fat_release_all(struct super_block *sb) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); @@ -341,7 +341,7 @@ void FAT_release_all(struct super_block *sb) mutex_unlock(&f_mutex); } -void FAT_sync(struct super_block *sb) +void exfat_fat_sync(struct super_block *sb) { struct buf_cache_t *bp; struct fs_info_t *p_fs = &(EXFAT_SB(sb)->fs_info); diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index f60fb691e165..1638ed266f68 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -283,7 +283,7 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, num_clusters++; if (p_chain->flags == 0x01) { - if (FAT_write(sb, new_clu, CLUSTER_32(~0)) < 0) + if (exfat_fat_write(sb, new_clu, CLUSTER_32(~0)) < 0) return -EIO; } @@ -291,7 +291,7 @@ static s32 exfat_alloc_cluster(struct super_block *sb, s32 num_alloc, p_chain->dir = new_clu; } else { if (p_chain->flags == 0x01) { - if (FAT_write(sb, last_clu, new_clu) < 0) + if (exfat_fat_write(sb, last_clu, new_clu) < 0) return -EIO; } } @@ -375,7 +375,7 @@ static void exfat_free_cluster(struct super_block *sb, struct chain_t *p_chain, if (clr_alloc_bitmap(sb, clu - 2) != 0) break; - if (FAT_read(sb, clu, &clu) == -1) + if (exfat_fat_read(sb, clu, &clu) == -1) break; num_clusters++; } while ((clu != CLUSTER_32(0)) && (clu != CLUSTER_32(~0))); @@ -395,7 +395,7 @@ static u32 find_last_cluster(struct super_block *sb, struct chain_t *p_chain) if (p_chain->flags == 0x03) { clu += p_chain->size - 1; } else { - while ((FAT_read(sb, clu, &next) == 0) && + while ((exfat_fat_read(sb, clu, &next) == 0) && (next != CLUSTER_32(~0))) { if (p_fs->dev_ejected) break; @@ -422,7 +422,7 @@ s32 count_num_clusters(struct super_block *sb, struct chain_t *p_chain) } else { for (i = 2; i < p_fs->num_clusters; i++) { count++; - if (FAT_read(sb, clu, &clu) != 0) + if (exfat_fat_read(sb, clu, &clu) != 0) return 0; if (clu == CLUSTER_32(~0)) break; @@ -461,12 +461,12 @@ void exfat_chain_cont_cluster(struct super_block *sb, u32 chain, s32 len) return; while (len > 1) { - if (FAT_write(sb, chain, chain + 1) < 0) + if (exfat_fat_write(sb, chain, chain + 1) < 0) break; chain++; len--; } - FAT_write(sb, chain, CLUSTER_32(~0)); + exfat_fat_write(sb, chain, CLUSTER_32(~0)); } /* @@ -538,7 +538,7 @@ s32 load_alloc_bitmap(struct super_block *sb) } } - if (FAT_read(sb, clu.dir, &clu.dir) != 0) + if (exfat_fat_read(sb, clu.dir, &clu.dir) != 0) return -EIO; } @@ -760,7 +760,7 @@ s32 load_upcase_table(struct super_block *sb) break; return 0; } - if (FAT_read(sb, clu.dir, &clu.dir) != 0) + if (exfat_fat_read(sb, clu.dir, &clu.dir) != 0) return -EIO; } /* load default upcase table */ @@ -1180,7 +1180,7 @@ static s32 __write_partial_entries_in_entry_set(struct super_block *sb, if (es->alloc_flag == 0x03) { clu++; } else { - if (FAT_read(sb, clu, &clu) == -1) + if (exfat_fat_read(sb, clu, &clu) == -1) goto err_out; } sec = START_SECTOR(clu); @@ -1242,7 +1242,7 @@ static s32 _walk_fat_chain(struct super_block *sb, struct chain_t *p_dir, cur_clu += clu_offset; } else { while (clu_offset > 0) { - if (FAT_read(sb, cur_clu, &cur_clu) == -1) + if (exfat_fat_read(sb, cur_clu, &cur_clu) == -1) return -EIO; clu_offset--; } @@ -1450,7 +1450,7 @@ struct entry_set_cache_t *get_entry_set_in_dir(struct super_block *sb, if (es->alloc_flag == 0x03) { clu++; } else { - if (FAT_read(sb, clu, &clu) == -1) + if (exfat_fat_read(sb, clu, &clu) == -1) goto err_out; } sec = START_SECTOR(clu); @@ -1575,7 +1575,7 @@ static s32 search_deleted_or_unused_entry(struct super_block *sb, else clu.dir = CLUSTER_32(~0); } else { - if (FAT_read(sb, clu.dir, &clu.dir) != 0) + if (exfat_fat_read(sb, clu.dir, &clu.dir) != 0) return -1; } } @@ -1625,7 +1625,7 @@ static s32 find_empty_entry(struct inode *inode, struct chain_t *p_dir, s32 num_ p_fs->hint_uentry.clu.flags = 0x01; } if (clu.flags == 0x01) - if (FAT_write(sb, last_clu, clu.dir) < 0) + if (exfat_fat_write(sb, last_clu, clu.dir) < 0) return -EIO; if (p_fs->hint_uentry.entry == -1) { @@ -1822,7 +1822,7 @@ static s32 exfat_find_dir_entry(struct super_block *sb, struct chain_t *p_dir, else clu.dir = CLUSTER_32(~0); } else { - if (FAT_read(sb, clu.dir, &clu.dir) != 0) + if (exfat_fat_read(sb, clu.dir, &clu.dir) != 0) return -2; } } @@ -1903,7 +1903,7 @@ s32 count_dos_name_entries(struct super_block *sb, struct chain_t *p_dir, else clu.dir = CLUSTER_32(~0); } else { - if (FAT_read(sb, clu.dir, &clu.dir) != 0) + if (exfat_fat_read(sb, clu.dir, &clu.dir) != 0) return -EIO; } } @@ -1963,7 +1963,7 @@ bool is_dir_empty(struct super_block *sb, struct chain_t *p_dir) else clu.dir = CLUSTER_32(~0); } - if (FAT_read(sb, clu.dir, &clu.dir) != 0) + if (exfat_fat_read(sb, clu.dir, &clu.dir) != 0) break; } diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 4b8915098d20..23002aefc964 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -457,7 +457,7 @@ static int ffsUmountVol(struct super_block *sb) free_upcase_table(sb); free_alloc_bitmap(sb); - FAT_release_all(sb); + exfat_fat_release_all(sb); exfat_buf_release_all(sb); /* close the block device */ @@ -722,8 +722,8 @@ static int ffsReadFile(struct inode *inode, struct file_id_t *fid, void *buffer, } while (clu_offset > 0) { - /* clu = FAT_read(sb, clu); */ - if (FAT_read(sb, clu, &clu) == -1) { + /* clu = exfat_fat_read(sb, clu); */ + if (exfat_fat_read(sb, clu, &clu) == -1) { ret = -EIO; goto out; } @@ -868,8 +868,8 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, while ((clu_offset > 0) && (clu != CLUSTER_32(~0))) { last_clu = clu; - /* clu = FAT_read(sb, clu); */ - if (FAT_read(sb, clu, &clu) == -1) { + /* clu = exfat_fat_read(sb, clu); */ + if (exfat_fat_read(sb, clu, &clu) == -1) { ret = -EIO; goto out; } @@ -911,7 +911,7 @@ static int ffsWriteFile(struct inode *inode, struct file_id_t *fid, modified = true; } if (new_clu.flags == 0x01) - FAT_write(sb, last_clu, new_clu.dir); + exfat_fat_write(sb, last_clu, new_clu.dir); } num_clusters += num_alloced; @@ -1081,7 +1081,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) } else { while (num_clusters > 0) { last_clu = clu.dir; - if (FAT_read(sb, clu.dir, &clu.dir) == -1) { + if (exfat_fat_read(sb, clu.dir, &clu.dir) == -1) { ret = -EIO; goto out; } @@ -1123,7 +1123,7 @@ static int ffsTruncateFile(struct inode *inode, u64 old_size, u64 new_size) /* (2) cut off from the FAT chain */ if (last_clu != CLUSTER_32(0)) { if (fid->flags == 0x01) - FAT_write(sb, last_clu, CLUSTER_32(~0)); + exfat_fat_write(sb, last_clu, CLUSTER_32(~0)); } /* (3) free the clusters */ @@ -1687,7 +1687,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) while ((clu_offset > 0) && (*clu != CLUSTER_32(~0))) { last_clu = *clu; - if (FAT_read(sb, *clu, clu) == -1) { + if (exfat_fat_read(sb, *clu, clu) == -1) { ret = -EIO; goto out; } @@ -1727,7 +1727,7 @@ static int ffsMapCluster(struct inode *inode, s32 clu_offset, u32 *clu) modified = true; } if (new_clu.flags == 0x01) - FAT_write(sb, last_clu, new_clu.dir); + exfat_fat_write(sb, last_clu, new_clu.dir); } num_clusters += num_alloced; @@ -1888,8 +1888,8 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) } while (clu_offset > 0) { - /* clu.dir = FAT_read(sb, clu.dir); */ - if (FAT_read(sb, clu.dir, &clu.dir) == -1) { + /* clu.dir = exfat_fat_read(sb, clu.dir); */ + if (exfat_fat_read(sb, clu.dir, &clu.dir) == -1) { ret = -EIO; goto out; } @@ -1983,8 +1983,8 @@ static int ffsReadDir(struct inode *inode, struct dir_entry_t *dir_entry) else clu.dir = CLUSTER_32(~0); } else { - /* clu.dir = FAT_read(sb, clu.dir); */ - if (FAT_read(sb, clu.dir, &clu.dir) == -1) { + /* clu.dir = exfat_fat_read(sb, clu.dir); */ + if (exfat_fat_read(sb, clu.dir, &clu.dir) == -1) { ret = -EIO; goto out; } @@ -3821,7 +3821,7 @@ static void exfat_debug_kill_sb(struct super_block *sb) * dirty. We use this to simulate device removal. */ mutex_lock(&p_fs->v_mutex); - FAT_release_all(sb); + exfat_fat_release_all(sb); exfat_buf_release_all(sb); mutex_unlock(&p_fs->v_mutex); -- cgit v1.2.3-59-g8ed1b From 6366e523eb56b4b7191fd4261941a2762b6957bd Mon Sep 17 00:00:00 2001 From: Valdis Kletnieks Date: Tue, 12 Nov 2019 17:36:08 -0500 Subject: staging: exfat: Update the TODO file Updating with the current laundry list of things that need attention. Signed-off-by: Valdis Kletnieks Link: https://lore.kernel.org/r/20191112223609.163501-1-Valdis.Kletnieks@vt.edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/TODO | 70 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/TODO b/drivers/staging/exfat/TODO index b60e50b9cf4e..a283ce534cf4 100644 --- a/drivers/staging/exfat/TODO +++ b/drivers/staging/exfat/TODO @@ -1,17 +1,22 @@ +A laundry list of things that need looking at, most of which will +require more work than the average checkpatch cleanup... + +Note that some of these entries may not be bugs - they're things +that need to be looked at, and *possibly* fixed. + +Clean up the ffsCamelCase function names. + +Fix (thing)->flags to not use magic numbers - multiple offenders + +Sort out all the s32/u32/u8 nonsense - most of these should be plain int. + exfat_core.c - ffsReadFile - the goto err_out seem to leak a brelse(). same for ffsWriteFile. -exfat_core.c - fs_sync(sb,0) all over the place looks fishy as hell. -There's only one place that calls it with a non-zero argument. -Randomly removing fs_sync() calls is *not* the right answer, especially -if the removal then leaves a call to fs_set_vol_flags(VOL_CLEAN), as that -says the file system is clean and synced when we *know* it isn't. -The proper fix here is to go through and actually analyze how DELAYED_SYNC -should work, and any time we're setting VOL_CLEAN, ensure the file system -has in fact been synced to disk. In other words, changing the 'false' to -'true' is probably more correct. Also, it's likely that the one current -place where it actually does an bdev_sync isn't sufficient in the DELAYED_SYNC -case. +All the calls to fs_sync() need to be looked at, particularly in the +context of EXFAT_DELAYED_SYNC. Currently, if that's defined, we only +flush to disk when sync() gets called. We should be doing at least +metadata flushes at appropriate times. ffsTruncateFile - if (old_size <= new_size) { That doesn't look right. How did it ever work? Are they relying on lazy @@ -19,3 +24,46 @@ block allocation when actual writes happen? If nothing else, it never does the 'fid->size = new_size' and do the inode update.... ffsSetAttr() is just dangling in the breeze, not wired up at all... + +Convert global mutexes to a per-superblock mutex. + +Right now, we load exactly one UTF-8 table. Check to see +if that plays nice with different codepage and iocharset values +for simultanous mounts of different devices + +exfat_rmdir() checks for -EBUSY but ffsRemoveDir() doesn't return it. +In fact, there's a complete lack of -EBUSY testing anywhere. + +There's probably a few missing checks for -EEXIST + +check return codes of sync_dirty_buffer() + +Why is remove_file doing a num_entries++?? + +Double check a lot of can't-happen parameter checks (for null pointers for +things that have only one call site and can't pass a null, etc). + +All the DEBUG stuff can probably be tossed, including the ioctl(). Either +that, or convert to a proper fault-injection system. + +exfat_remount does exactly one thing. Fix to actually deal with remount +options, particularly handling R/O correctly. For that matter, allow +R/O mounts in the first place. + +Figure out why the VFAT code used multi_sector_(read|write) but the +exfat code doesn't use it. The difference matters on SSDs with wear leveling. + +exfat_fat_sync(), exfat_buf_sync(), and sync_alloc_bitmap() +aren't called anyplace.... + +Create helper function for exfat_set_entry_time() and exfat_set_entry_type() +because it's sort of ugly to be calling the same functionn directly and +other code calling through the fs_func struc ponters... + +clean up the remaining vol_type checks, which are of two types: +some are ?: operators with magic numbers, and the rest are places +where we're doing stuff with '.' and '..'. + +Patches to: + Greg Kroah-Hartman + Valdis Kletnieks -- cgit v1.2.3-59-g8ed1b From 7a3674898de30ede4a1fa1724016b5bc4f14604c Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 13 Nov 2019 16:42:10 +0000 Subject: staging: exfat: fix indentation issue There is a declaration that requires indentation. Add in the missing tab. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20191113164210.103586-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 23002aefc964..c939c57e8fd7 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -2175,7 +2175,7 @@ static int exfat_ioctl_volume_id(struct inode *dir) static long exfat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { -struct inode *inode = filp->f_path.dentry->d_inode; + struct inode *inode = filp->f_path.dentry->d_inode; #ifdef CONFIG_EXFAT_KERNEL_DEBUG unsigned int flags; #endif /* CONFIG_EXFAT_KERNEL_DEBUG */ -- cgit v1.2.3-59-g8ed1b From 8c7128c4cf4e0e6eb67bd65b4dbe619c3d297bb6 Mon Sep 17 00:00:00 2001 From: Jules Irenge Date: Wed, 13 Nov 2019 11:00:52 +0000 Subject: staging: align to fix warnings of line over 80 characters Align to fix multiple warnings of line over 80 characters. Issue detected by checkpatch tool. Signed-off-by: Jules Irenge Link: https://lore.kernel.org/r/20191113110052.14855-1-jbi.octave@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bus_sdio.c | 4 +- drivers/staging/wfx/data_rx.h | 3 +- drivers/staging/wfx/debug.c | 15 +++-- drivers/staging/wfx/fwio.c | 65 +++++++++++++------ drivers/staging/wfx/hif_rx.c | 78 +++++++++++++++-------- drivers/staging/wfx/hif_tx.c | 66 ++++++++++++------- drivers/staging/wfx/hif_tx_mib.h | 11 ++-- drivers/staging/wfx/hwio.c | 42 ++++++++----- drivers/staging/wfx/hwio.h | 9 ++- drivers/staging/wfx/key.c | 24 ++++--- drivers/staging/wfx/main.c | 61 ++++++++++++------ drivers/staging/wfx/queue.c | 31 ++++++--- drivers/staging/wfx/queue.h | 6 +- drivers/staging/wfx/scan.c | 15 +++-- drivers/staging/wfx/sta.c | 133 ++++++++++++++++++++++++++------------- drivers/staging/wfx/sta.h | 6 +- drivers/staging/wfx/traces.h | 27 +++++--- drivers/staging/wfx/wfx.h | 6 +- 18 files changed, 407 insertions(+), 195 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bus_sdio.c b/drivers/staging/wfx/bus_sdio.c index 375e07d6d9ae..f8901164c206 100644 --- a/drivers/staging/wfx/bus_sdio.c +++ b/drivers/staging/wfx/bus_sdio.c @@ -188,7 +188,9 @@ static int wfx_sdio_probe(struct sdio_func *func, bus->func = func; sdio_set_drvdata(func, bus); - func->card->quirks |= MMC_QUIRK_LENIENT_FN0 | MMC_QUIRK_BLKSZ_FOR_BYTE_MODE | MMC_QUIRK_BROKEN_BYTE_MODE_512; + func->card->quirks |= MMC_QUIRK_LENIENT_FN0 | + MMC_QUIRK_BLKSZ_FOR_BYTE_MODE | + MMC_QUIRK_BROKEN_BYTE_MODE_512; sdio_claim_host(func); ret = sdio_enable_func(func); diff --git a/drivers/staging/wfx/data_rx.h b/drivers/staging/wfx/data_rx.h index b44d15268f83..a50ce352bc5e 100644 --- a/drivers/staging/wfx/data_rx.h +++ b/drivers/staging/wfx/data_rx.h @@ -13,6 +13,7 @@ struct wfx_vif; struct sk_buff; -void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, struct sk_buff *skb); +void wfx_rx_cb(struct wfx_vif *wvif, struct hif_ind_rx *arg, + struct sk_buff *skb); #endif /* WFX_DATA_RX_H */ diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 0a9ca109039c..d17a75242365 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -72,7 +72,8 @@ static int wfx_counters_show(struct seq_file *seq, void *v) return -EIO; #define PUT_COUNTER(name) \ - seq_printf(seq, "%24s %d\n", #name ":", le32_to_cpu(counters.count_##name)) + seq_printf(seq, "%24s %d\n", #name ":",\ + le32_to_cpu(counters.count_##name)) PUT_COUNTER(tx_packets); PUT_COUNTER(tx_multicast_frames); @@ -211,7 +212,8 @@ struct dbgfs_hif_msg { int ret; }; -static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user_buf, +static ssize_t wfx_send_hif_msg_write(struct file *file, + const char __user *user_buf, size_t count, loff_t *ppos) { struct dbgfs_hif_msg *context = file->private_data; @@ -236,7 +238,8 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user kfree(request); return -EINVAL; } - context->ret = wfx_cmd_send(wdev, request, context->reply, sizeof(context->reply), false); + context->ret = wfx_cmd_send(wdev, request, context->reply, + sizeof(context->reply), false); kfree(request); complete(&context->complete); @@ -299,8 +302,10 @@ int wfx_debug_init(struct wfx_dev *wdev) debugfs_create_file("counters", 0444, d, wdev, &wfx_counters_fops); debugfs_create_file("rx_stats", 0444, d, wdev, &wfx_rx_stats_fops); debugfs_create_file("send_pds", 0200, d, wdev, &wfx_send_pds_fops); - debugfs_create_file("burn_slk_key", 0200, d, wdev, &wfx_burn_slk_key_fops); - debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); + debugfs_create_file("burn_slk_key", 0200, d, wdev, + &wfx_burn_slk_key_fops); + debugfs_create_file("send_hif_msg", 0600, d, wdev, + &wfx_send_hif_msg_fops); return 0; } diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c index 6d82c6244c7f..dbf8bda71ff7 100644 --- a/drivers/staging/wfx/fwio.c +++ b/drivers/staging/wfx/fwio.c @@ -107,11 +107,14 @@ int get_firmware(struct wfx_dev *wdev, u32 keyset_chip, const char *data; int ret; - snprintf(filename, sizeof(filename), "%s_%02X.sec", wdev->pdata.file_fw, keyset_chip); + snprintf(filename, sizeof(filename), "%s_%02X.sec", wdev->pdata.file_fw, + keyset_chip); ret = firmware_request_nowarn(fw, filename, wdev->dev); if (ret) { - dev_info(wdev->dev, "can't load %s, falling back to %s.sec\n", filename, wdev->pdata.file_fw); - snprintf(filename, sizeof(filename), "%s.sec", wdev->pdata.file_fw); + dev_info(wdev->dev, "can't load %s, falling back to %s.sec\n", + filename, wdev->pdata.file_fw); + snprintf(filename, sizeof(filename), "%s.sec", + wdev->pdata.file_fw); ret = request_firmware(fw, filename, wdev->dev); if (ret) { dev_err(wdev->dev, "can't load %s\n", filename); @@ -164,7 +167,8 @@ static int wait_ncp_status(struct wfx_dev *wdev, u32 status) return -ETIMEDOUT; } if (ktime_compare(now, start)) - dev_dbg(wdev->dev, "chip answer after %lldus\n", ktime_us_delta(now, start)); + dev_dbg(wdev->dev, "chip answer after %lldus\n", + ktime_us_delta(now, start)); else dev_dbg(wdev->dev, "chip answer immediately\n"); return 0; @@ -188,15 +192,18 @@ static int upload_firmware(struct wfx_dev *wdev, const u8 *data, size_t len) if (ret < 0) return ret; now = ktime_get(); - if (offs + DNLD_BLOCK_SIZE - bytes_done < DNLD_FIFO_SIZE) + if (offs + + DNLD_BLOCK_SIZE - bytes_done < DNLD_FIFO_SIZE) break; if (ktime_after(now, ktime_add_ms(start, DCA_TIMEOUT))) return -ETIMEDOUT; } if (ktime_compare(now, start)) - dev_dbg(wdev->dev, "answer after %lldus\n", ktime_us_delta(now, start)); + dev_dbg(wdev->dev, "answer after %lldus\n", + ktime_us_delta(now, start)); - ret = sram_write_dma_safe(wdev, WFX_DNLD_FIFO + (offs % DNLD_FIFO_SIZE), + ret = sram_write_dma_safe(wdev, WFX_DNLD_FIFO + + (offs % DNLD_FIFO_SIZE), data + offs, DNLD_BLOCK_SIZE); if (ret < 0) return ret; @@ -220,10 +227,14 @@ static void print_boot_status(struct wfx_dev *wdev) dev_info(wdev->dev, "no error reported by secure boot\n"); } else { sram_reg_read(wdev, WFX_ERR_INFO, &val32); - if (val32 < ARRAY_SIZE(fwio_error_strings) && fwio_error_strings[val32]) - dev_info(wdev->dev, "secure boot error: %s\n", fwio_error_strings[val32]); + if (val32 < ARRAY_SIZE(fwio_error_strings) && + fwio_error_strings[val32]) + dev_info(wdev->dev, "secure boot error: %s\n", + fwio_error_strings[val32]); else - dev_info(wdev->dev, "secure boot error: Unknown (0x%02x)\n", val32); + dev_info(wdev->dev, + "secure boot error: Unknown (0x%02x)\n", + val32); } } @@ -262,9 +273,13 @@ static int load_firmware_secure(struct wfx_dev *wdev) goto error; sram_reg_write(wdev, WFX_DNLD_FIFO, 0xFFFFFFFF); // Fifo init - sram_write_dma_safe(wdev, WFX_DCA_FW_VERSION, "\x01\x00\x00\x00", FW_VERSION_SIZE); - sram_write_dma_safe(wdev, WFX_DCA_FW_SIGNATURE, fw->data + fw_offset, FW_SIGNATURE_SIZE); - sram_write_dma_safe(wdev, WFX_DCA_FW_HASH, fw->data + fw_offset + FW_SIGNATURE_SIZE, FW_HASH_SIZE); + sram_write_dma_safe(wdev, WFX_DCA_FW_VERSION, "\x01\x00\x00\x00", + FW_VERSION_SIZE); + sram_write_dma_safe(wdev, WFX_DCA_FW_SIGNATURE, fw->data + fw_offset, + FW_SIGNATURE_SIZE); + sram_write_dma_safe(wdev, WFX_DCA_FW_HASH, + fw->data + fw_offset + FW_SIGNATURE_SIZE, + FW_HASH_SIZE); sram_reg_write(wdev, WFX_DCA_IMAGE_SIZE, fw->size - header_size); sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_UPLOAD_PENDING); ret = wait_ncp_status(wdev, NCP_DOWNLOAD_PENDING); @@ -272,10 +287,12 @@ static int load_firmware_secure(struct wfx_dev *wdev) goto error; start = ktime_get(); - ret = upload_firmware(wdev, fw->data + header_size, fw->size - header_size); + ret = upload_firmware(wdev, fw->data + header_size, + fw->size - header_size); if (ret) goto error; - dev_dbg(wdev->dev, "firmware load after %lldus\n", ktime_us_delta(ktime_get(), start)); + dev_dbg(wdev->dev, "firmware load after %lldus\n", + ktime_us_delta(ktime_get(), start)); sram_reg_write(wdev, WFX_DCA_HOST_STATUS, HOST_UPLOAD_COMPLETE); ret = wait_ncp_status(wdev, NCP_AUTH_OK); @@ -310,10 +327,12 @@ static int init_gpr(struct wfx_dev *wdev) }; for (i = 0; i < ARRAY_SIZE(gpr_init); i++) { - ret = igpr_reg_write(wdev, gpr_init[i].index, gpr_init[i].value); + ret = igpr_reg_write(wdev, gpr_init[i].index, + gpr_init[i].value); if (ret < 0) return ret; - dev_dbg(wdev->dev, " index %02x: %08x\n", gpr_init[i].index, gpr_init[i].value); + dev_dbg(wdev->dev, " index %02x: %08x\n", gpr_init[i].index, + gpr_init[i].value); } return 0; } @@ -348,7 +367,8 @@ int wfx_init_device(struct wfx_dev *wdev) hw_revision = FIELD_GET(CFG_DEVICE_ID_MAJOR, reg); if (hw_revision == 0 || hw_revision > 2) { - dev_err(wdev->dev, "bad hardware revision number: %d\n", hw_revision); + dev_err(wdev->dev, "bad hardware revision number: %d\n", + hw_revision); return -ENODEV; } hw_type = FIELD_GET(CFG_DEVICE_ID_TYPE, reg); @@ -375,7 +395,8 @@ int wfx_init_device(struct wfx_dev *wdev) return -ETIMEDOUT; } } - dev_dbg(wdev->dev, "chip wake up after %lldus\n", ktime_us_delta(now, start)); + dev_dbg(wdev->dev, "chip wake up after %lldus\n", + ktime_us_delta(now, start)); ret = config_reg_write_bits(wdev, CFG_CPU_RESET, 0); if (ret < 0) @@ -383,6 +404,10 @@ int wfx_init_device(struct wfx_dev *wdev) ret = load_firmware_secure(wdev); if (ret < 0) return ret; - ret = config_reg_write_bits(wdev, CFG_DIRECT_ACCESS_MODE | CFG_IRQ_ENABLE_DATA | CFG_IRQ_ENABLE_WRDY, CFG_IRQ_ENABLE_DATA); + ret = config_reg_write_bits(wdev, + CFG_DIRECT_ACCESS_MODE | + CFG_IRQ_ENABLE_DATA | + CFG_IRQ_ENABLE_WRDY, + CFG_IRQ_ENABLE_DATA); return ret; } diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index 36e171b27ae2..820de216be0c 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -18,7 +18,8 @@ #include "secure_link.h" #include "hif_api_cmd.h" -static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { // All confirm messages start with status int status = le32_to_cpu(*((__le32 *) buf)); @@ -33,7 +34,8 @@ static int hif_generic_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void * } if (cmd != wdev->hif_cmd.buf_send->id) { - dev_warn(wdev->dev, "chip response mismatch request: 0x%.2x vs 0x%.2x\n", + dev_warn(wdev->dev, + "chip response mismatch request: 0x%.2x vs 0x%.2x\n", cmd, wdev->hif_cmd.buf_send->id); return -EINVAL; } @@ -70,7 +72,8 @@ static int hif_tx_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) return 0; } -static int hif_multi_tx_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_multi_tx_confirm(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { struct hif_cnf_multi_transmit *body = buf; struct hif_cnf_tx *buf_loc = (struct hif_cnf_tx *) &body->tx_conf_payload; @@ -90,7 +93,8 @@ static int hif_multi_tx_confirm(struct wfx_dev *wdev, struct hif_msg *hif, void return 0; } -static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { struct hif_ind_startup *body = buf; @@ -108,7 +112,8 @@ static int hif_startup_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi return 0; } -static int hif_wakeup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_wakeup_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { if (!wdev->pdata.gpio_wakeup || !gpiod_get_value(wdev->pdata.gpio_wakeup)) { @@ -118,7 +123,8 @@ static int hif_wakeup_indication(struct wfx_dev *wdev, struct hif_msg *hif, void return 0; } -static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { struct hif_ind_sl_exchange_pub_keys *body = buf; @@ -131,13 +137,15 @@ static int hif_keys_indication(struct wfx_dev *wdev, struct hif_msg *hif, void * return 0; } -static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf, struct sk_buff *skb) +static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf, struct sk_buff *skb) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); struct hif_ind_rx *body = buf; if (!wvif) { - dev_warn(wdev->dev, "ignore rx data for non-existent vif %d\n", hif->interface); + dev_warn(wdev->dev, "ignore rx data for non-existent vif %d\n", + hif->interface); return 0; } skb_pull(skb, sizeof(struct hif_msg) + sizeof(struct hif_ind_rx)); @@ -146,7 +154,8 @@ static int hif_receive_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi return 0; } -static int hif_event_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_event_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); struct hif_ind_event *body = buf; @@ -173,7 +182,8 @@ static int hif_event_indication(struct wfx_dev *wdev, struct hif_msg *hif, void return 0; } -static int hif_pm_mode_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_pm_mode_complete_indication(struct wfx_dev *wdev, + struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); @@ -183,7 +193,8 @@ static int hif_pm_mode_complete_indication(struct wfx_dev *wdev, struct hif_msg return 0; } -static int hif_scan_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_scan_complete_indication(struct wfx_dev *wdev, + struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); struct hif_ind_scan_cmpl *body = buf; @@ -194,7 +205,8 @@ static int hif_scan_complete_indication(struct wfx_dev *wdev, struct hif_msg *hi return 0; } -static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_join_complete_indication(struct wfx_dev *wdev, + struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); @@ -204,7 +216,8 @@ static int hif_join_complete_indication(struct wfx_dev *wdev, struct hif_msg *hi return 0; } -static int hif_suspend_resume_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_suspend_resume_indication(struct wfx_dev *wdev, + struct hif_msg *hif, void *buf) { struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); struct hif_ind_suspend_resume_tx *body = buf; @@ -215,7 +228,8 @@ static int hif_suspend_resume_indication(struct wfx_dev *wdev, struct hif_msg *h return 0; } -static int hif_error_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_error_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { struct hif_ind_error *body = buf; u8 *pRollback = (u8 *) body->data; @@ -223,31 +237,39 @@ static int hif_error_indication(struct wfx_dev *wdev, struct hif_msg *hif, void switch (body->type) { case HIF_ERROR_FIRMWARE_ROLLBACK: - dev_err(wdev->dev, "asynchronous error: firmware rollback error %d\n", *pRollback); + dev_err(wdev->dev, + "asynchronous error: firmware rollback error %d\n", + *pRollback); break; case HIF_ERROR_FIRMWARE_DEBUG_ENABLED: dev_err(wdev->dev, "asynchronous error: firmware debug feature enabled\n"); break; case HIF_ERROR_OUTDATED_SESSION_KEY: - dev_err(wdev->dev, "asynchronous error: secure link outdated key: %#.8x\n", *pStatus); + dev_err(wdev->dev, "asynchronous error: secure link outdated key: %#.8x\n", + *pStatus); break; case HIF_ERROR_INVALID_SESSION_KEY: dev_err(wdev->dev, "asynchronous error: invalid session key\n"); break; case HIF_ERROR_OOR_VOLTAGE: - dev_err(wdev->dev, "asynchronous error: out-of-range overvoltage: %#.8x\n", *pStatus); + dev_err(wdev->dev, "asynchronous error: out-of-range overvoltage: %#.8x\n", + *pStatus); break; case HIF_ERROR_PDS_VERSION: - dev_err(wdev->dev, "asynchronous error: wrong PDS payload or version: %#.8x\n", *pStatus); + dev_err(wdev->dev, + "asynchronous error: wrong PDS payload or version: %#.8x\n", + *pStatus); break; default: - dev_err(wdev->dev, "asynchronous error: unknown (%d)\n", body->type); + dev_err(wdev->dev, "asynchronous error: unknown (%d)\n", + body->type); break; } return 0; } -static int hif_generic_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_generic_indication(struct wfx_dev *wdev, struct hif_msg *hif, + void *buf) { struct hif_ind_generic *body = buf; @@ -255,23 +277,29 @@ static int hif_generic_indication(struct wfx_dev *wdev, struct hif_msg *hif, voi case HIF_GENERIC_INDICATION_TYPE_RAW: return 0; case HIF_GENERIC_INDICATION_TYPE_STRING: - dev_info(wdev->dev, "firmware says: %s\n", (char *) body->indication_data.raw_data); + dev_info(wdev->dev, "firmware says: %s\n", + (char *) body->indication_data.raw_data); return 0; case HIF_GENERIC_INDICATION_TYPE_RX_STATS: mutex_lock(&wdev->rx_stats_lock); // Older firmware send a generic indication beside RxStats if (!wfx_api_older_than(wdev, 1, 4)) - dev_info(wdev->dev, "Rx test ongoing. Temperature: %d°C\n", body->indication_data.rx_stats.current_temp); - memcpy(&wdev->rx_stats, &body->indication_data.rx_stats, sizeof(wdev->rx_stats)); + dev_info(wdev->dev, "Rx test ongoing. Temperature: %d°C\n", + body->indication_data.rx_stats.current_temp); + memcpy(&wdev->rx_stats, &body->indication_data.rx_stats, + sizeof(wdev->rx_stats)); mutex_unlock(&wdev->rx_stats_lock); return 0; default: - dev_err(wdev->dev, "generic_indication: unknown indication type: %#.8x\n", body->indication_type); + dev_err(wdev->dev, + "generic_indication: unknown indication type: %#.8x\n", + body->indication_type); return -EIO; } } -static int hif_exception_indication(struct wfx_dev *wdev, struct hif_msg *hif, void *buf) +static int hif_exception_indication(struct wfx_dev *wdev, + struct hif_msg *hif, void *buf) { size_t len = hif->len - 4; // drop header dev_err(wdev->dev, "firmware exception\n"); diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 2f5dadff0660..cb7cddcb9815 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -24,7 +24,8 @@ void wfx_init_hif_cmd(struct wfx_hif_cmd *hif_cmd) mutex_init(&hif_cmd->key_renew_lock); } -static void wfx_fill_header(struct hif_msg *hif, int if_id, unsigned int cmd, size_t size) +static void wfx_fill_header(struct hif_msg *hif, int if_id, unsigned int cmd, + size_t size) { if (if_id == -1) if_id = 2; @@ -47,7 +48,8 @@ static void *wfx_alloc_hif(size_t body_len, struct hif_msg **hif) return NULL; } -int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, size_t reply_len, bool async) +int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, + size_t reply_len, bool async) { const char *mib_name = ""; const char *mib_sep = ""; @@ -100,7 +102,8 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct hif_msg *request, void *reply, siz wdev->hif_cmd.buf_send = NULL; mutex_unlock(&wdev->hif_cmd.lock); - if (ret && (cmd == HIF_REQ_ID_READ_MIB || cmd == HIF_REQ_ID_WRITE_MIB)) { + if (ret && + (cmd == HIF_REQ_ID_READ_MIB || cmd == HIF_REQ_ID_WRITE_MIB)) { mib_name = get_mib_name(((u16 *) request)[2]); mib_sep = "/"; } @@ -170,7 +173,8 @@ int hif_reset(struct wfx_vif *wvif, bool reset_stat) return ret; } -int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, size_t val_len) +int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, + size_t val_len) { int ret; struct hif_msg *hif; @@ -183,11 +187,13 @@ int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, size_t ret = wfx_cmd_send(wdev, hif, reply, buf_len, false); if (!ret && mib_id != reply->mib_id) { - dev_warn(wdev->dev, "%s: confirmation mismatch request\n", __func__); + dev_warn(wdev->dev, + "%s: confirmation mismatch request\n", __func__); ret = -EIO; } if (ret == -ENOMEM) - dev_err(wdev->dev, "buffer is too small to receive %s (%zu < %d)\n", + dev_err(wdev->dev, + "buffer is too small to receive %s (%zu < %d)\n", get_mib_name(mib_id), val_len, reply->length); if (!ret) memcpy(val, &reply->mib_data, reply->length); @@ -198,7 +204,8 @@ int hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, size_t return ret; } -int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, size_t val_len) +int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, + size_t val_len) { int ret; struct hif_msg *hif; @@ -236,7 +243,8 @@ int hif_scan(struct wfx_vif *wvif, const struct wfx_scan_params *arg) cpu_to_le32s(&body->min_channel_time); cpu_to_le32s(&body->max_channel_time); cpu_to_le32s(&body->tx_power_level); - memcpy(ptr, arg->ssids, arg->scan_req.num_of_ssi_ds * sizeof(struct hif_ssid_def)); + memcpy(ptr, arg->ssids, + arg->scan_req.num_of_ssi_ds * sizeof(struct hif_ssid_def)); ssids = (struct hif_ssid_def *) ptr; for (i = 0; i < body->num_of_ssi_ds; ++i) cpu_to_le32s(&ssids[i].ssid_length); @@ -281,16 +289,19 @@ int hif_join(struct wfx_vif *wvif, const struct hif_req_join *arg) return ret; } -int hif_set_bss_params(struct wfx_vif *wvif, const struct hif_req_set_bss_params *arg) +int hif_set_bss_params(struct wfx_vif *wvif, + const struct hif_req_set_bss_params *arg) { int ret; struct hif_msg *hif; - struct hif_req_set_bss_params *body = wfx_alloc_hif(sizeof(*body), &hif); + struct hif_req_set_bss_params *body = wfx_alloc_hif(sizeof(*body), + &hif); memcpy(body, arg, sizeof(*body)); cpu_to_le16s(&body->aid); cpu_to_le32s(&body->operational_rate_set); - wfx_fill_header(hif, wvif->id, HIF_REQ_ID_SET_BSS_PARAMS, sizeof(*body)); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_SET_BSS_PARAMS, + sizeof(*body)); ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); kfree(hif); return ret; @@ -308,7 +319,8 @@ int hif_add_key(struct wfx_dev *wdev, const struct hif_req_add_key *arg) if (wfx_api_older_than(wdev, 1, 5)) // Legacy firmwares expect that add_key to be sent on right // interface. - wfx_fill_header(hif, arg->int_id, HIF_REQ_ID_ADD_KEY, sizeof(*body)); + wfx_fill_header(hif, arg->int_id, HIF_REQ_ID_ADD_KEY, + sizeof(*body)); else wfx_fill_header(hif, -1, HIF_REQ_ID_ADD_KEY, sizeof(*body)); ret = wfx_cmd_send(wdev, hif, NULL, 0, false); @@ -329,18 +341,21 @@ int hif_remove_key(struct wfx_dev *wdev, int idx) return ret; } -int hif_set_edca_queue_params(struct wfx_vif *wvif, const struct hif_req_edca_queue_params *arg) +int hif_set_edca_queue_params(struct wfx_vif *wvif, + const struct hif_req_edca_queue_params *arg) { int ret; struct hif_msg *hif; - struct hif_req_edca_queue_params *body = wfx_alloc_hif(sizeof(*body), &hif); + struct hif_req_edca_queue_params *body = wfx_alloc_hif(sizeof(*body), + &hif); // NOTE: queues numerotation are not the same between WFx and Linux memcpy(body, arg, sizeof(*body)); cpu_to_le16s(&body->cw_min); cpu_to_le16s(&body->cw_max); cpu_to_le16s(&body->tx_op_limit); - wfx_fill_header(hif, wvif->id, HIF_REQ_ID_EDCA_QUEUE_PARAMS, sizeof(*body)); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_EDCA_QUEUE_PARAMS, + sizeof(*body)); ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); kfree(hif); return ret; @@ -379,10 +394,12 @@ int hif_beacon_transmit(struct wfx_vif *wvif, bool enable_beaconing) { int ret; struct hif_msg *hif; - struct hif_req_beacon_transmit *body = wfx_alloc_hif(sizeof(*body), &hif); + struct hif_req_beacon_transmit *body = wfx_alloc_hif(sizeof(*body), + &hif); body->enable_beaconing = enable_beaconing ? 1 : 0; - wfx_fill_header(hif, wvif->id, HIF_REQ_ID_BEACON_TRANSMIT, sizeof(*body)); + wfx_fill_header(hif, wvif->id, HIF_REQ_ID_BEACON_TRANSMIT, + sizeof(*body)); ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); kfree(hif); return ret; @@ -421,16 +438,20 @@ int hif_update_ie(struct wfx_vif *wvif, const struct hif_ie_flags *target_frame, return ret; } -int hif_sl_send_pub_keys(struct wfx_dev *wdev, const uint8_t *pubkey, const uint8_t *pubkey_hmac) +int hif_sl_send_pub_keys(struct wfx_dev *wdev, const uint8_t *pubkey, + const uint8_t *pubkey_hmac) { int ret; struct hif_msg *hif; - struct hif_req_sl_exchange_pub_keys *body = wfx_alloc_hif(sizeof(*body), &hif); + struct hif_req_sl_exchange_pub_keys *body = wfx_alloc_hif(sizeof(*body), + &hif); body->algorithm = HIF_SL_CURVE25519; memcpy(body->host_pub_key, pubkey, sizeof(body->host_pub_key)); - memcpy(body->host_pub_key_mac, pubkey_hmac, sizeof(body->host_pub_key_mac)); - wfx_fill_header(hif, -1, HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS, sizeof(*body)); + memcpy(body->host_pub_key_mac, pubkey_hmac, + sizeof(body->host_pub_key_mac)); + wfx_fill_header(hif, -1, HIF_REQ_ID_SL_EXCHANGE_PUB_KEYS, + sizeof(*body)); ret = wfx_cmd_send(wdev, hif, NULL, 0, false); kfree(hif); // Compatibility with legacy secure link @@ -457,7 +478,8 @@ int hif_sl_set_mac_key(struct wfx_dev *wdev, const u8 *slk_key, { int ret; struct hif_msg *hif; - struct hif_req_set_sl_mac_key *body = wfx_alloc_hif(sizeof(*body), &hif); + struct hif_req_set_sl_mac_key *body = wfx_alloc_hif(sizeof(*body), + &hif); memcpy(body->key_value, slk_key, sizeof(body->key_value)); body->otp_or_ram = destination; diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index d1cabd697205..bb091e395ff5 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -57,8 +57,9 @@ static inline int hif_get_counters_table(struct wfx_dev *wdev, return hif_read_mib(wdev, 0, HIF_MIB_ID_COUNTERS_TABLE, arg, sizeof(struct hif_mib_count_table)); } else { - return hif_read_mib(wdev, 0, HIF_MIB_ID_EXTENDED_COUNTERS_TABLE, - arg, sizeof(struct hif_mib_extended_count_table)); + return hif_read_mib(wdev, 0, + HIF_MIB_ID_EXTENDED_COUNTERS_TABLE, arg, + sizeof(struct hif_mib_extended_count_table)); } } @@ -112,7 +113,8 @@ static inline int hif_beacon_filter_control(struct wfx_vif *wvif, .bcn_count = cpu_to_le32(beacon_count), }; return hif_write_mib(wvif->wdev, wvif->id, - HIF_MIB_ID_BEACON_FILTER_ENABLE, &arg, sizeof(arg)); + HIF_MIB_ID_BEACON_FILTER_ENABLE, + &arg, sizeof(arg)); } static inline int hif_set_operational_mode(struct wfx_dev *wdev, @@ -173,7 +175,8 @@ static inline int hif_set_association_mode(struct wfx_vif *wvif, static inline int hif_set_tx_rate_retry_policy(struct wfx_vif *wvif, struct hif_mib_set_tx_rate_retry_policy *arg) { - size_t size = struct_size(arg, tx_rate_retry_policy, arg->num_tx_rate_policies); + size_t size = struct_size(arg, tx_rate_retry_policy, + arg->num_tx_rate_policies); return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg, size); diff --git a/drivers/staging/wfx/hwio.c b/drivers/staging/wfx/hwio.c index 0cf52aee10e7..47e04c59ed93 100644 --- a/drivers/staging/wfx/hwio.c +++ b/drivers/staging/wfx/hwio.c @@ -34,12 +34,14 @@ static int read32(struct wfx_dev *wdev, int reg, u32 *val) *val = ~0; // Never return undefined value if (!tmp) return -ENOMEM; - ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, tmp, sizeof(u32)); + ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, reg, tmp, + sizeof(u32)); if (ret >= 0) *val = le32_to_cpu(*tmp); kfree(tmp); if (ret) - dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + dev_err(wdev->dev, "%s: bus communication error: %d\n", + __func__, ret); return ret; } @@ -51,10 +53,12 @@ static int write32(struct wfx_dev *wdev, int reg, u32 val) if (!tmp) return -ENOMEM; *tmp = cpu_to_le32(val); - ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, tmp, sizeof(u32)); + ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, tmp, + sizeof(u32)); kfree(tmp); if (ret) - dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + dev_err(wdev->dev, "%s: bus communication error: %d\n", + __func__, ret); return ret; } @@ -102,7 +106,8 @@ err: return ret; } -static int indirect_read(struct wfx_dev *wdev, int reg, u32 addr, void *buf, size_t len) +static int indirect_read(struct wfx_dev *wdev, int reg, u32 addr, void *buf, + size_t len) { int ret; int i; @@ -152,7 +157,8 @@ err: return ret; } -static int indirect_write(struct wfx_dev *wdev, int reg, u32 addr, const void *buf, size_t len) +static int indirect_write(struct wfx_dev *wdev, int reg, u32 addr, + const void *buf, size_t len) { int ret; @@ -165,7 +171,8 @@ static int indirect_write(struct wfx_dev *wdev, int reg, u32 addr, const void *b return wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, reg, buf, len); } -static int indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr, void *buf, size_t len) +static int indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr, + void *buf, size_t len) { int ret; @@ -176,7 +183,8 @@ static int indirect_read_locked(struct wfx_dev *wdev, int reg, u32 addr, void *b return ret; } -static int indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr, const void *buf, size_t len) +static int indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr, + const void *buf, size_t len) { int ret; @@ -187,7 +195,8 @@ static int indirect_write_locked(struct wfx_dev *wdev, int reg, u32 addr, const return ret; } -static int indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 *val) +static int indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, + u32 *val) { int ret; __le32 *tmp = kmalloc(sizeof(u32), GFP_KERNEL); @@ -203,7 +212,8 @@ static int indirect_read32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 * return ret; } -static int indirect_write32_locked(struct wfx_dev *wdev, int reg, u32 addr, u32 val) +static int indirect_write32_locked(struct wfx_dev *wdev, int reg, u32 addr, + u32 val) { int ret; __le32 *tmp = kmalloc(sizeof(u32), GFP_KERNEL); @@ -225,11 +235,13 @@ int wfx_data_read(struct wfx_dev *wdev, void *buf, size_t len) WARN((long) buf & 3, "%s: unaligned buffer", __func__); wdev->hwbus_ops->lock(wdev->hwbus_priv); - ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); + ret = wdev->hwbus_ops->copy_from_io(wdev->hwbus_priv, + WFX_REG_IN_OUT_QUEUE, buf, len); _trace_io_read(WFX_REG_IN_OUT_QUEUE, buf, len); wdev->hwbus_ops->unlock(wdev->hwbus_priv); if (ret) - dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + dev_err(wdev->dev, "%s: bus communication error: %d\n", + __func__, ret); return ret; } @@ -239,11 +251,13 @@ int wfx_data_write(struct wfx_dev *wdev, const void *buf, size_t len) WARN((long) buf & 3, "%s: unaligned buffer", __func__); wdev->hwbus_ops->lock(wdev->hwbus_priv); - ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, WFX_REG_IN_OUT_QUEUE, buf, len); + ret = wdev->hwbus_ops->copy_to_io(wdev->hwbus_priv, + WFX_REG_IN_OUT_QUEUE, buf, len); _trace_io_write(WFX_REG_IN_OUT_QUEUE, buf, len); wdev->hwbus_ops->unlock(wdev->hwbus_priv); if (ret) - dev_err(wdev->dev, "%s: bus communication error: %d\n", __func__, ret); + dev_err(wdev->dev, "%s: bus communication error: %d\n", + __func__, ret); return ret; } diff --git a/drivers/staging/wfx/hwio.h b/drivers/staging/wfx/hwio.h index 906524f71fd1..b2c1a66de963 100644 --- a/drivers/staging/wfx/hwio.h +++ b/drivers/staging/wfx/hwio.h @@ -37,8 +37,13 @@ int ahb_reg_write(struct wfx_dev *wdev, u32 addr, u32 val); #define CFG_ERR_HOST_NO_IN_QUEUE 0x00000040 #define CFG_ERR_HOST_CRC_MISS 0x00000080 // only with SDIO #define CFG_SPI_IGNORE_CS 0x00000080 // only with SPI -#define CFG_WORD_MODE_MASK 0x00000300 // Bytes ordering (only writable in SPI): -#define CFG_WORD_MODE0 0x00000000 // B1,B0,B3,B2 (In SPI, register address and CONFIG data always use this mode) +/* Bytes ordering (only writable in SPI): */ +#define CFG_WORD_MODE_MASK 0x00000300 +/* + * B1,B0,B3,B2 (In SPI, register address and + * CONFIG data always use this mode) + */ +#define CFG_WORD_MODE0 0x00000000 #define CFG_WORD_MODE1 0x00000100 // B3,B2,B1,B0 #define CFG_WORD_MODE2 0x00000200 // B0,B1,B2,B3 (SDIO) #define CFG_DIRECT_ACCESS_MODE 0x00000400 // Direct or queue access mode diff --git a/drivers/staging/wfx/key.c b/drivers/staging/wfx/key.c index caea6d959b0e..96adfa330604 100644 --- a/drivers/staging/wfx/key.c +++ b/drivers/staging/wfx/key.c @@ -171,28 +171,36 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta, return -EINVAL; k = &wdev->keys[idx]; k->int_id = wvif->id; - if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) { + if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) { if (pairwise) - k->type = fill_wep_pair(&k->key.wep_pairwise_key, key, sta->addr); + k->type = fill_wep_pair(&k->key.wep_pairwise_key, key, + sta->addr); else k->type = fill_wep_group(&k->key.wep_group_key, key); } else if (key->cipher == WLAN_CIPHER_SUITE_TKIP) { if (pairwise) - k->type = fill_tkip_pair(&k->key.tkip_pairwise_key, key, sta->addr); + k->type = fill_tkip_pair(&k->key.tkip_pairwise_key, key, + sta->addr); else - k->type = fill_tkip_group(&k->key.tkip_group_key, key, &seq, wvif->vif->type); + k->type = fill_tkip_group(&k->key.tkip_group_key, key, + &seq, wvif->vif->type); } else if (key->cipher == WLAN_CIPHER_SUITE_CCMP) { if (pairwise) - k->type = fill_ccmp_pair(&k->key.aes_pairwise_key, key, sta->addr); + k->type = fill_ccmp_pair(&k->key.aes_pairwise_key, key, + sta->addr); else - k->type = fill_ccmp_group(&k->key.aes_group_key, key, &seq); + k->type = fill_ccmp_group(&k->key.aes_group_key, key, + &seq); } else if (key->cipher == WLAN_CIPHER_SUITE_SMS4) { if (pairwise) - k->type = fill_sms4_pair(&k->key.wapi_pairwise_key, key, sta->addr); + k->type = fill_sms4_pair(&k->key.wapi_pairwise_key, key, + sta->addr); else k->type = fill_sms4_group(&k->key.wapi_group_key, key); } else if (key->cipher == WLAN_CIPHER_SUITE_AES_CMAC) { - k->type = fill_aes_cmac_group(&k->key.igtk_group_key, key, &seq); + k->type = fill_aes_cmac_group(&k->key.igtk_group_key, key, + &seq); } else { dev_warn(wdev->dev, "unsupported key type %d\n", key->cipher); wfx_free_key(wdev, idx); diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 18f07f7ad347..986a2ef678b9 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -99,7 +99,8 @@ static const struct ieee80211_supported_band wfx_band_2ghz = { .ht_cap = { // Receive caps .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_MAX_AMSDU | (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT), + IEEE80211_HT_CAP_MAX_AMSDU | + (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT), .ht_supported = 1, .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K, .ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE, @@ -163,14 +164,17 @@ bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) return false; } -struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *label) +struct gpio_desc *wfx_get_gpio(struct device *dev, int override, + const char *label) { struct gpio_desc *ret; char label_buf[256]; if (override >= 0) { snprintf(label_buf, sizeof(label_buf), "wfx_%s", label); - ret = ERR_PTR(devm_gpio_request_one(dev, override, GPIOF_OUT_INIT_LOW, label_buf)); + ret = ERR_PTR(devm_gpio_request_one(dev, override, + GPIOF_OUT_INIT_LOW, + label_buf)); if (!ret) ret = gpio_to_desc(override); } else if (override == -1) { @@ -182,10 +186,12 @@ struct gpio_desc *wfx_get_gpio(struct device *dev, int override, const char *lab if (!ret || PTR_ERR(ret) == -ENOENT) dev_warn(dev, "gpio %s is not defined\n", label); else - dev_warn(dev, "error while requesting gpio %s\n", label); + dev_warn(dev, + "error while requesting gpio %s\n", label); ret = NULL; } else { - dev_dbg(dev, "using gpio %d for %s\n", desc_to_gpio(ret), label); + dev_dbg(dev, + "using gpio %d for %s\n", desc_to_gpio(ret), label); } return ret; } @@ -215,7 +221,8 @@ int wfx_send_pds(struct wfx_dev *wdev, unsigned char *buf, size_t len) buf[i] = 0; dev_dbg(wdev->dev, "send PDS '%s}'\n", buf + start); buf[i] = '}'; - ret = hif_configuration(wdev, buf + start, i - start + 1); + ret = hif_configuration(wdev, buf + start, + i - start + 1); if (ret == HIF_STATUS_FAILURE) { dev_err(wdev->dev, "PDS bytes %d to %d: invalid data (unsupported options?)\n", start, i); return -EINVAL; @@ -243,7 +250,8 @@ static int wfx_send_pdata_pds(struct wfx_dev *wdev) ret = request_firmware(&pds, wdev->pdata.file_pds, wdev->dev); if (ret) { - dev_err(wdev->dev, "can't load PDS file %s\n", wdev->pdata.file_pds); + dev_err(wdev->dev, "can't load PDS file %s\n", + wdev->pdata.file_pds); return ret; } tmp_buf = kmemdup(pds->data, pds->size, GFP_KERNEL); @@ -282,7 +290,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, hw->queues = 4; hw->max_rates = 8; hw->max_rate_tries = 15; - hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_msg) + hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + + sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + 4 /* alignment */ + 8 /* TKIP IV */; hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | @@ -297,7 +306,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, hw->wiphy->iface_combinations = wfx_iface_combinations; hw->wiphy->bands[NL80211_BAND_2GHZ] = devm_kmalloc(dev, sizeof(wfx_band_2ghz), GFP_KERNEL); // FIXME: also copy wfx_rates and wfx_2ghz_chantable - memcpy(hw->wiphy->bands[NL80211_BAND_2GHZ], &wfx_band_2ghz, sizeof(wfx_band_2ghz)); + memcpy(hw->wiphy->bands[NL80211_BAND_2GHZ], &wfx_band_2ghz, + sizeof(wfx_band_2ghz)); wdev = hw->priv; wdev->hw = hw; @@ -305,7 +315,8 @@ struct wfx_dev *wfx_init_common(struct device *dev, wdev->hwbus_ops = hwbus_ops; wdev->hwbus_priv = hwbus_priv; memcpy(&wdev->pdata, pdata, sizeof(*pdata)); - of_property_read_string(dev->of_node, "config-file", &wdev->pdata.file_pds); + of_property_read_string(dev->of_node, "config-file", + &wdev->pdata.file_pds); wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); wfx_sl_fill_pdata(dev, &wdev->pdata); @@ -344,7 +355,8 @@ int wfx_probe(struct wfx_dev *wdev) if (err) goto err1; - err = wait_for_completion_interruptible_timeout(&wdev->firmware_ready, 10 * HZ); + err = wait_for_completion_interruptible_timeout(&wdev->firmware_ready, + 10 * HZ); if (err <= 0) { if (err == 0) { dev_err(wdev->dev, "timeout while waiting for startup indication. IRQ configuration error?\n"); @@ -359,16 +371,19 @@ int wfx_probe(struct wfx_dev *wdev) dev_info(wdev->dev, "started firmware %d.%d.%d \"%s\" (API: %d.%d, keyset: %02X, caps: 0x%.8X)\n", wdev->hw_caps.firmware_major, wdev->hw_caps.firmware_minor, wdev->hw_caps.firmware_build, wdev->hw_caps.firmware_label, - wdev->hw_caps.api_version_major, wdev->hw_caps.api_version_minor, + wdev->hw_caps.api_version_major, + wdev->hw_caps.api_version_minor, wdev->keyset, *((u32 *) &wdev->hw_caps.capabilities)); - snprintf(wdev->hw->wiphy->fw_version, sizeof(wdev->hw->wiphy->fw_version), + snprintf(wdev->hw->wiphy->fw_version, + sizeof(wdev->hw->wiphy->fw_version), "%d.%d.%d", wdev->hw_caps.firmware_major, wdev->hw_caps.firmware_minor, wdev->hw_caps.firmware_build); if (wfx_api_older_than(wdev, 1, 0)) { - dev_err(wdev->dev, "unsupported firmware API version (expect 1 while firmware returns %d)\n", + dev_err(wdev->dev, + "unsupported firmware API version (expect 1 while firmware returns %d)\n", wdev->hw_caps.api_version_major); err = -ENOTSUPP; goto err1; @@ -376,7 +391,8 @@ int wfx_probe(struct wfx_dev *wdev) err = wfx_sl_init(wdev); if (err && wdev->hw_caps.capabilities.link_mode == SEC_LINK_ENFORCED) { - dev_err(wdev->dev, "chip require secure_link, but can't negociate it\n"); + dev_err(wdev->dev, + "chip require secure_link, but can't negociate it\n"); goto err1; } @@ -386,15 +402,18 @@ int wfx_probe(struct wfx_dev *wdev) wdev->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[13].flags |= IEEE80211_CHAN_DISABLED; } - dev_dbg(wdev->dev, "sending configuration file %s\n", wdev->pdata.file_pds); + dev_dbg(wdev->dev, "sending configuration file %s\n", + wdev->pdata.file_pds); err = wfx_send_pdata_pds(wdev); if (err < 0) goto err1; wdev->pdata.gpio_wakeup = gpio_saved; if (wdev->pdata.gpio_wakeup) { - dev_dbg(wdev->dev, "enable 'quiescent' power mode with gpio %d and PDS file %s\n", - desc_to_gpio(wdev->pdata.gpio_wakeup), wdev->pdata.file_pds); + dev_dbg(wdev->dev, + "enable 'quiescent' power mode with gpio %d and PDS file %s\n", + desc_to_gpio(wdev->pdata.gpio_wakeup), + wdev->pdata.file_pds); gpiod_set_value(wdev->pdata.gpio_wakeup, 1); control_reg_write(wdev, 0); hif_set_operational_mode(wdev, HIF_OP_POWER_MODE_QUIESCENT); @@ -411,13 +430,15 @@ int wfx_probe(struct wfx_dev *wdev) ether_addr_copy(wdev->addresses[i].addr, macaddr); wdev->addresses[i].addr[ETH_ALEN - 1] += i; } else { - ether_addr_copy(wdev->addresses[i].addr, wdev->hw_caps.mac_addr[i]); + ether_addr_copy(wdev->addresses[i].addr, + wdev->hw_caps.mac_addr[i]); } if (!is_valid_ether_addr(wdev->addresses[i].addr)) { dev_warn(wdev->dev, "using random MAC address\n"); eth_random_addr(wdev->addresses[i].addr); } - dev_info(wdev->dev, "MAC address %d: %pM\n", i, wdev->addresses[i].addr); + dev_info(wdev->dev, "MAC address %d: %pM\n", i, + wdev->addresses[i].addr); } wdev->hw->wiphy->n_addresses = ARRAY_SIZE(wdev->addresses); wdev->hw->wiphy->addresses = wdev->addresses; diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 71e92744fed0..c7ee90888f69 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -42,7 +42,8 @@ void wfx_tx_flush(struct wfx_dev *wdev) !wdev->hif.tx_buffers_used, msecs_to_jiffies(3000)); if (!ret) { - dev_warn(wdev->dev, "cannot flush tx buffers (%d still busy)\n", wdev->hif.tx_buffers_used); + dev_warn(wdev->dev, "cannot flush tx buffers (%d still busy)\n", + wdev->hif.tx_buffers_used); wfx_pending_dump_old_frames(wdev, 3000); // FIXME: drop pending frames here wdev->chip_frozen = 1; @@ -121,7 +122,8 @@ void wfx_tx_queues_wait_empty_vif(struct wfx_vif *wvif) } while (!done); } -static void wfx_tx_queue_clear(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff_head *gc_list) +static void wfx_tx_queue_clear(struct wfx_dev *wdev, struct wfx_queue *queue, + struct sk_buff_head *gc_list) { int i; struct sk_buff *item; @@ -189,7 +191,8 @@ size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, ret = skb_queue_len(&queue->queue); } else { ret = 0; - for (i = 0, bit = 1; i < ARRAY_SIZE(queue->link_map_cache); ++i, bit <<= 1) { + for (i = 0, bit = 1; i < ARRAY_SIZE(queue->link_map_cache); + ++i, bit <<= 1) { if (link_id_map & bit) ret += queue->link_map_cache[i]; } @@ -198,7 +201,8 @@ size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, return ret; } -void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff *skb) +void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, + struct sk_buff *skb) { struct wfx_queue_stats *stats = &wdev->tx_queue_stats; struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); @@ -315,7 +319,8 @@ void wfx_pending_dump_old_frames(struct wfx_dev *wdev, unsigned int limit_ms) skb_queue_walk(&stats->pending, skb) { tx_priv = wfx_skb_tx_priv(skb); req = wfx_skb_txreq(skb); - if (ktime_after(now, ktime_add_ms(tx_priv->xmit_timestamp, limit_ms))) { + if (ktime_after(now, ktime_add_ms(tx_priv->xmit_timestamp, + limit_ms))) { if (first) { dev_info(wdev->dev, "frames stuck in firmware since %dms or more:\n", limit_ms); @@ -329,7 +334,8 @@ void wfx_pending_dump_old_frames(struct wfx_dev *wdev, unsigned int limit_ms) spin_unlock_bh(&stats->pending.lock); } -unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb) +unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, + struct sk_buff *skb) { ktime_t now = ktime_get(); struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb); @@ -376,7 +382,8 @@ static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb, case NL80211_IFTYPE_AP: if (!wvif->state) { action = do_drop; - } else if (!(BIT(tx_priv->raw_link_id) & (BIT(0) | wvif->link_id_map))) { + } else if (!(BIT(tx_priv->raw_link_id) & + (BIT(0) | wvif->link_id_map))) { dev_warn(wvif->wdev->dev, "a frame with expired link-id is dropped\n"); action = do_drop; } @@ -462,7 +469,8 @@ static int wfx_get_prio_queue(struct wfx_vif *wvif, /* override winner if bursting */ if (winner >= 0 && wvif->wdev->tx_burst_idx >= 0 && winner != wvif->wdev->tx_burst_idx && - !wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[winner], tx_allowed_mask & urgent) && + !wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[winner], + tx_allowed_mask & urgent) && wfx_tx_queue_get_num_queued(&wvif->wdev->tx_queue[wvif->wdev->tx_burst_idx], tx_allowed_mask)) winner = wvif->wdev->tx_burst_idx; @@ -536,10 +544,13 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { spin_lock_bh(&wvif->ps_state_lock); - not_found = wfx_tx_queue_mask_get(wvif, &vif_queue, &vif_tx_allowed_mask, &vif_more); + not_found = wfx_tx_queue_mask_get(wvif, &vif_queue, + &vif_tx_allowed_mask, + &vif_more); if (wvif->mcast_buffered && (not_found || !vif_more) && - (wvif->mcast_tx || !wvif->sta_asleep_mask)) { + (wvif->mcast_tx || + !wvif->sta_asleep_mask)) { wvif->mcast_buffered = false; if (wvif->mcast_tx) { wvif->mcast_tx = false; diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index 938dbf3469e7..21566e48b2c2 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -47,13 +47,15 @@ bool wfx_tx_queues_is_empty(struct wfx_dev *wdev); void wfx_tx_queues_wait_empty_vif(struct wfx_vif *wvif); struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev); -void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, struct sk_buff *skb); +void wfx_tx_queue_put(struct wfx_dev *wdev, struct wfx_queue *queue, + struct sk_buff *skb); size_t wfx_tx_queue_get_num_queued(struct wfx_queue *queue, u32 link_id_map); struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id); int wfx_pending_remove(struct wfx_dev *wdev, struct sk_buff *skb); int wfx_pending_requeue(struct wfx_dev *wdev, struct sk_buff *skb); -unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb); +unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, + struct sk_buff *skb); void wfx_pending_dump_old_frames(struct wfx_dev *wdev, unsigned int limit_ms); #endif /* WFX_QUEUE_H */ diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index cba735c1e73c..35fcf9119f96 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -12,7 +12,8 @@ #include "sta.h" #include "hif_tx_mib.h" -static void __ieee80211_scan_completed_compat(struct ieee80211_hw *hw, bool aborted) +static void __ieee80211_scan_completed_compat(struct ieee80211_hw *hw, + bool aborted) { struct cfg80211_scan_info info = { .aborted = aborted ? 1 : 0, @@ -159,7 +160,8 @@ void wfx_scan_work(struct work_struct *work) if (!wvif->scan.req || wvif->scan.curr == wvif->scan.end) { if (wvif->scan.output_power != wvif->wdev->output_power) - hif_set_output_power(wvif, wvif->wdev->output_power * 10); + hif_set_output_power(wvif, + wvif->wdev->output_power * 10); if (wvif->scan.status < 0) dev_warn(wvif->wdev->dev, "scan failed\n"); @@ -172,7 +174,8 @@ void wfx_scan_work(struct work_struct *work) wfx_scan_restart_delayed(wvif); wfx_tx_unlock(wvif->wdev); mutex_unlock(&wvif->wdev->conf_mutex); - __ieee80211_scan_completed_compat(wvif->wdev->hw, wvif->scan.status ? 1 : 0); + __ieee80211_scan_completed_compat(wvif->wdev->hw, + wvif->scan.status ? 1 : 0); up(&wvif->scan.lock); if (wvif->state == WFX_STATE_STA && !(wvif->powersave_mode.pm_mode.enter_psm)) @@ -211,7 +214,8 @@ void wfx_scan_work(struct work_struct *work) scan.scan_req.scan_flags.fbg = 1; } - scan.ch = kcalloc(scan.scan_req.num_of_channels, sizeof(u8), GFP_KERNEL); + scan.ch = kcalloc(scan.scan_req.num_of_channels, + sizeof(u8), GFP_KERNEL); if (!scan.ch) { wvif->scan.status = -ENOMEM; @@ -273,7 +277,8 @@ void wfx_scan_complete_cb(struct wfx_vif *wvif, struct hif_ind_scan_cmpl *arg) void wfx_scan_timeout(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, scan.timeout.work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + scan.timeout.work); if (atomic_xchg(&wvif->scan.in_progress, 0)) { if (wvif->scan.status > 0) { diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 1cdfa88ffee7..29848a202ab4 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -100,7 +100,8 @@ void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad) skb = ieee80211_nullfunc_get(wvif->wdev->hw, wvif->vif, false); if (!skb) goto end; - memset(IEEE80211_SKB_CB(skb), 0, sizeof(*IEEE80211_SKB_CB(skb))); + memset(IEEE80211_SKB_CB(skb), 0, + sizeof(*IEEE80211_SKB_CB(skb))); IEEE80211_SKB_CB(skb)->control.vif = wvif->vif; IEEE80211_SKB_CB(skb)->driver_rates[0].idx = 0; IEEE80211_SKB_CB(skb)->driver_rates[0].count = 1; @@ -177,8 +178,10 @@ static int wfx_set_mcast_filter(struct wfx_vif *wvif, for (i = 0; i < fp->num_addresses; i++) { filter_addr_val.condition_idx = i; filter_addr_val.address_type = HIF_MAC_ADDR_A1; - ether_addr_copy(filter_addr_val.mac_address, fp->address_list[i]); - ret = hif_set_mac_addr_condition(wvif, &filter_addr_val); + ether_addr_copy(filter_addr_val.mac_address, + fp->address_list[i]); + ret = hif_set_mac_addr_condition(wvif, + &filter_addr_val); if (ret) return ret; config.mac_cond |= 1 << i; @@ -243,7 +246,8 @@ void wfx_update_filtering(struct wfx_vif *wvif) bf_ctrl.bcn_count = 1; n_filter_ies = 0; } else if (!is_sta) { - bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE | HIF_BEACON_FILTER_AUTO_ERP; + bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE | + HIF_BEACON_FILTER_AUTO_ERP; bf_ctrl.bcn_count = 0; n_filter_ies = 2; } else { @@ -254,9 +258,11 @@ void wfx_update_filtering(struct wfx_vif *wvif) ret = hif_set_rx_filter(wvif, filter_bssid, fwd_probe_req); if (!ret) - ret = hif_set_beacon_filter_table(wvif, n_filter_ies, filter_ies); + ret = hif_set_beacon_filter_table(wvif, n_filter_ies, + filter_ies); if (!ret) - ret = hif_beacon_filter_control(wvif, bf_ctrl.enable, bf_ctrl.bcn_count); + ret = hif_beacon_filter_control(wvif, bf_ctrl.enable, + bf_ctrl.bcn_count); if (!ret) ret = wfx_set_mcast_filter(wvif, &wvif->mcast_filter); if (ret) @@ -265,12 +271,14 @@ void wfx_update_filtering(struct wfx_vif *wvif) static void wfx_update_filtering_work(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, update_filtering_work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + update_filtering_work); wfx_update_filtering(wvif); } -u64 wfx_prepare_multicast(struct ieee80211_hw *hw, struct netdev_hw_addr_list *mc_list) +u64 wfx_prepare_multicast(struct ieee80211_hw *hw, + struct netdev_hw_addr_list *mc_list) { int i; struct netdev_hw_addr *ha; @@ -280,12 +288,14 @@ u64 wfx_prepare_multicast(struct ieee80211_hw *hw, struct netdev_hw_addr_list *m while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { memset(&wvif->mcast_filter, 0x00, sizeof(wvif->mcast_filter)); - if (!count || count > ARRAY_SIZE(wvif->mcast_filter.address_list)) + if (!count || + count > ARRAY_SIZE(wvif->mcast_filter.address_list)) continue; i = 0; netdev_hw_addr_list_for_each(ha, mc_list) { - ether_addr_copy(wvif->mcast_filter.address_list[i], ha->addr); + ether_addr_copy(wvif->mcast_filter.address_list[i], + ha->addr); i++; } wvif->mcast_filter.enable = true; @@ -307,7 +317,8 @@ void wfx_configure_filter(struct ieee80211_hw *hw, while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { down(&wvif->scan.lock); - wvif->filter_bssid = (*total_flags & (FIF_OTHER_BSS | FIF_PROBE_REQ)) ? 0 : 1; + wvif->filter_bssid = (*total_flags & + (FIF_OTHER_BSS | FIF_PROBE_REQ)) ? 0 : 1; wvif->disable_beacon_filter = !(*total_flags & FIF_PROBE_REQ); wfx_fwd_probe_req(wvif, true); wfx_update_filtering(wvif); @@ -381,8 +392,10 @@ int wfx_set_pm(struct wfx_vif *wvif, const struct hif_req_set_pm_mode *arg) pm.pm_mode.fast_psm = 0; } - if (!wait_for_completion_timeout(&wvif->set_pm_mode_complete, msecs_to_jiffies(300))) - dev_warn(wvif->wdev->dev, "timeout while waiting of set_pm_mode_complete\n"); + if (!wait_for_completion_timeout(&wvif->set_pm_mode_complete, + msecs_to_jiffies(300))) + dev_warn(wvif->wdev->dev, + "timeout while waiting of set_pm_mode_complete\n"); ret = hif_set_pm(wvif, &pm); // FIXME: why ? if (-ETIMEDOUT == wvif->scan.status) @@ -442,7 +455,8 @@ void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, wvif = (struct wfx_vif *) vif->drv_priv; if (wvif->vif->type == NL80211_IFTYPE_MONITOR) drop = true; - if (wvif->vif->type == NL80211_IFTYPE_AP && !wvif->enable_beacon) + if (wvif->vif->type == NL80211_IFTYPE_AP && + !wvif->enable_beacon) drop = true; } @@ -494,7 +508,8 @@ static void wfx_event_handler_work(struct work_struct *work) */ wvif->delayed_link_loss = 1; /* Also start a watchdog. */ - schedule_delayed_work(&wvif->bss_loss_work, 5 * HZ); + schedule_delayed_work(&wvif->bss_loss_work, + 5 * HZ); } break; case HIF_EVENT_IND_BSSREGAINED: @@ -502,13 +517,17 @@ static void wfx_event_handler_work(struct work_struct *work) cancel_work_sync(&wvif->unjoin_work); break; case HIF_EVENT_IND_RCPI_RSSI: - wfx_event_report_rssi(wvif, event->evt.event_data.rcpi_rssi); + wfx_event_report_rssi(wvif, + event->evt.event_data.rcpi_rssi); break; case HIF_EVENT_IND_PS_MODE_ERROR: - dev_warn(wvif->wdev->dev, "error while processing power save request\n"); + dev_warn(wvif->wdev->dev, + "error while processing power save request\n"); break; default: - dev_warn(wvif->wdev->dev, "unhandled event indication: %.2x\n", event->evt.event_id); + dev_warn(wvif->wdev->dev, + "unhandled event indication: %.2x\n", + event->evt.event_id); break; } } @@ -517,14 +536,16 @@ static void wfx_event_handler_work(struct work_struct *work) static void wfx_bss_loss_work(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, bss_loss_work.work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + bss_loss_work.work); ieee80211_connection_loss(wvif->vif); } static void wfx_bss_params_work(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, bss_params_work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + bss_params_work); mutex_lock(&wvif->wdev->conf_mutex); wvif->bss_params.bss_flags.lost_count_only = 1; @@ -535,9 +556,11 @@ static void wfx_bss_params_work(struct work_struct *work) static void wfx_set_beacon_wakeup_period_work(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, set_beacon_wakeup_period_work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + set_beacon_wakeup_period_work); - hif_set_beacon_wakeup_period(wvif, wvif->dtim_period, wvif->dtim_period); + hif_set_beacon_wakeup_period(wvif, wvif->dtim_period, + wvif->dtim_period); } static void wfx_do_unjoin(struct wfx_vif *wvif) @@ -546,7 +569,8 @@ static void wfx_do_unjoin(struct wfx_vif *wvif) if (atomic_read(&wvif->scan.in_progress)) { if (wvif->delayed_unjoin) - dev_dbg(wvif->wdev->dev, "delayed unjoin is already scheduled\n"); + dev_dbg(wvif->wdev->dev, + "delayed unjoin is already scheduled\n"); else wvif->delayed_unjoin = true; goto done; @@ -588,7 +612,8 @@ done: mutex_unlock(&wvif->wdev->conf_mutex); } -static void wfx_set_mfp(struct wfx_vif *wvif, struct cfg80211_bss *bss) +static void wfx_set_mfp(struct wfx_vif *wvif, + struct cfg80211_bss *bss) { const int pairwise_cipher_suite_count_offset = 8 / sizeof(u16); const int pairwise_cipher_suite_size = 4 / sizeof(u16); @@ -629,7 +654,8 @@ static void wfx_do_join(struct wfx_vif *wvif) .preamble_type = conf->use_short_preamble ? HIF_PREAMBLE_SHORT : HIF_PREAMBLE_LONG, .probe_for_join = 1, .atim_window = 0, - .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates), + .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, + conf->basic_rates), }; if (wvif->channel->flags & IEEE80211_CHAN_NO_IR) @@ -640,7 +666,8 @@ static void wfx_do_join(struct wfx_vif *wvif) bssid = wvif->vif->bss_conf.bssid; - bss = cfg80211_get_bss(wvif->wdev->hw->wiphy, wvif->channel, bssid, NULL, 0, + bss = cfg80211_get_bss(wvif->wdev->hw->wiphy, wvif->channel, + bssid, NULL, 0, IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY); if (!bss && !conf->ibss_joined) { @@ -816,7 +843,8 @@ static int wfx_start_ap(struct wfx_vif *wvif) .beacon_interval = conf->beacon_int, .dtim_period = conf->dtim_period, .preamble_type = conf->use_short_preamble ? HIF_PREAMBLE_SHORT : HIF_PREAMBLE_LONG, - .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates), + .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, + conf->basic_rates), }; memset(start.ssid, 0, sizeof(start.ssid)); @@ -928,7 +956,8 @@ static int wfx_ht_ampdu_density(const struct wfx_ht_info *ht_info) return ht_info->ht_cap.ampdu_density; } -static void wfx_join_finalize(struct wfx_vif *wvif, struct ieee80211_bss_conf *info) +static void wfx_join_finalize(struct wfx_vif *wvif, + struct ieee80211_bss_conf *info) { struct ieee80211_sta *sta = NULL; struct hif_mib_set_association_mode association_mode = { }; @@ -952,7 +981,8 @@ static void wfx_join_finalize(struct wfx_vif *wvif, struct ieee80211_bss_conf *i rcu_read_unlock(); /* Non Greenfield stations present */ - if (wvif->ht_info.operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) + if (wvif->ht_info.operation_mode & + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) hif_dual_cts_protection(wvif, true); else hif_dual_cts_protection(wvif, false); @@ -1011,7 +1041,9 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, filter.condition_idx = i; if (i < nb_arp_addr) { // Caution: type of arp_addr_list[i] is __be32 - memcpy(filter.ipv4_address, &info->arp_addr_list[i], sizeof(filter.ipv4_address)); + memcpy(filter.ipv4_address, + &info->arp_addr_list[i], + sizeof(filter.ipv4_address)); filter.arp_enable = HIF_ARP_NS_FILTERING_ENABLE; } else { filter.arp_enable = HIF_ARP_NS_FILTERING_DISABLE; @@ -1028,7 +1060,8 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, wfx_upload_beacon(wvif); } - if (changed & BSS_CHANGED_BEACON_ENABLED && wvif->state != WFX_STATE_IBSS) { + if (changed & BSS_CHANGED_BEACON_ENABLED && + wvif->state != WFX_STATE_IBSS) { if (wvif->enable_beacon != info->enable_beacon) { hif_beacon_transmit(wvif, info->enable_beacon); wvif->enable_beacon = info->enable_beacon; @@ -1061,7 +1094,8 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_BSSID | - BSS_CHANGED_IBSS | BSS_CHANGED_BASIC_RATES | BSS_CHANGED_HT)) { + BSS_CHANGED_IBSS | BSS_CHANGED_BASIC_RATES | + BSS_CHANGED_HT)) { if (info->assoc) { if (wvif->state < WFX_STATE_PRE_STA) { ieee80211_connection_loss(vif); @@ -1077,7 +1111,8 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, if (info->assoc || info->ibss_joined) wfx_join_finalize(wvif, info); else - memset(&wvif->bss_params, 0, sizeof(wvif->bss_params)); + memset(&wvif->bss_params, 0, + sizeof(wvif->bss_params)); } } @@ -1132,7 +1167,8 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, hif_set_rcpi_rssi_threshold(wvif, &th); } - if (changed & BSS_CHANGED_TXPOWER && info->txpower != wdev->output_power) { + if (changed & BSS_CHANGED_TXPOWER && + info->txpower != wdev->output_power) { wdev->output_power = info->txpower; hif_set_output_power(wvif, wdev->output_power * 10); } @@ -1247,7 +1283,8 @@ int wfx_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) static void wfx_mcast_start_work(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, mcast_start_work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + mcast_start_work); long tmo = wvif->dtim_period * TU_TO_JIFFIES(wvif->beacon_int + 20); cancel_work_sync(&wvif->mcast_stop_work); @@ -1262,7 +1299,8 @@ static void wfx_mcast_start_work(struct work_struct *work) static void wfx_mcast_stop_work(struct work_struct *work) { - struct wfx_vif *wvif = container_of(work, struct wfx_vif, mcast_stop_work); + struct wfx_vif *wvif = container_of(work, struct wfx_vif, + mcast_stop_work); if (wvif->aid0_bit_set) { del_timer_sync(&wvif->mcast_timeout); @@ -1310,7 +1348,8 @@ void wfx_suspend_resume(struct wfx_vif *wvif, if (!arg->suspend_resume_flags.resume) wvif->mcast_tx = false; else - wvif->mcast_tx = wvif->aid0_bit_set && wvif->mcast_buffered; + wvif->mcast_tx = wvif->aid0_bit_set && + wvif->mcast_buffered; if (wvif->mcast_tx) { cancel_tmo = true; wfx_bh_request_tx(wvif->wdev); @@ -1358,7 +1397,8 @@ int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return 0; } -void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, +void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, struct ieee80211_chanctx_conf *conf) { struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; @@ -1392,14 +1432,19 @@ int wfx_config(struct ieee80211_hw *hw, u32 changed) if (changed & IEEE80211_CONF_CHANGE_PS) { wvif = NULL; while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { - memset(&wvif->powersave_mode, 0, sizeof(wvif->powersave_mode)); + memset(&wvif->powersave_mode, 0, + sizeof(wvif->powersave_mode)); if (conf->flags & IEEE80211_CONF_PS) { wvif->powersave_mode.pm_mode.enter_psm = 1; if (conf->dynamic_ps_timeout > 0) { wvif->powersave_mode.pm_mode.fast_psm = 1; - // Firmware does not support more than 128ms + /* + * Firmware does not support more than + * 128ms + */ wvif->powersave_mode.fast_psm_idle_period = - min(conf->dynamic_ps_timeout * 2, 255); + min(conf->dynamic_ps_timeout * + 2, 255); } } if (wvif->state == WFX_STATE_STA && wvif->bss_params.aid) @@ -1515,7 +1560,8 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) init_completion(&wvif->set_pm_mode_complete); complete(&wvif->set_pm_mode_complete); - INIT_WORK(&wvif->set_beacon_wakeup_period_work, wfx_set_beacon_wakeup_period_work); + INIT_WORK(&wvif->set_beacon_wakeup_period_work, + wfx_set_beacon_wakeup_period_work); INIT_WORK(&wvif->update_filtering_work, wfx_update_filtering_work); INIT_WORK(&wvif->bss_params_work, wfx_bss_params_work); INIT_WORK(&wvif->set_cts_work, wfx_set_cts_work); @@ -1525,7 +1571,8 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) hif_set_macaddr(wvif, vif->addr); for (i = 0; i < IEEE80211_NUM_ACS; i++) { - memcpy(&wvif->edca.params[i], &default_edca_params[i], sizeof(default_edca_params[i])); + memcpy(&wvif->edca.params[i], &default_edca_params[i], + sizeof(default_edca_params[i])); wvif->edca.uapsd_enable[i] = false; hif_set_edca_queue_params(wvif, &wvif->edca.params[i]); } diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 57c46bd4e650..4ccf1b17632b 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -86,11 +86,13 @@ void wfx_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf, u32 changed); int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_chanctx_conf *conf); -void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, +void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, struct ieee80211_chanctx_conf *conf); // WSM Callbacks -void wfx_suspend_resume(struct wfx_vif *wvif, struct hif_ind_suspend_resume_tx *arg); +void wfx_suspend_resume(struct wfx_vif *wvif, + struct hif_ind_suspend_resume_tx *arg); // Other Helpers void wfx_cqm_bssloss_sm(struct wfx_vif *wvif, int init, int good, int bad); diff --git a/drivers/staging/wfx/traces.h b/drivers/staging/wfx/traces.h index 67457cda133b..3f6198ab2235 100644 --- a/drivers/staging/wfx/traces.h +++ b/drivers/staging/wfx/traces.h @@ -177,14 +177,16 @@ DECLARE_EVENT_CLASS(hif_data, else __entry->msg_type = "REQ"; if (!is_recv && - (__entry->msg_id == HIF_REQ_ID_READ_MIB || __entry->msg_id == HIF_REQ_ID_WRITE_MIB)) { + (__entry->msg_id == HIF_REQ_ID_READ_MIB || + __entry->msg_id == HIF_REQ_ID_WRITE_MIB)) { __entry->mib = le16_to_cpup((u16 *) hif->body); header_len = 4; } else { __entry->mib = -1; header_len = 0; } - __entry->buf_len = min_t(int, __entry->msg_len, sizeof(__entry->buf)) + __entry->buf_len = min_t(int, __entry->msg_len, + sizeof(__entry->buf)) - sizeof(struct hif_msg) - header_len; memcpy(__entry->buf, hif->body + header_len, __entry->buf_len); ), @@ -203,11 +205,13 @@ DECLARE_EVENT_CLASS(hif_data, DEFINE_EVENT(hif_data, hif_send, TP_PROTO(struct hif_msg *hif, int tx_fill_level, bool is_recv), TP_ARGS(hif, tx_fill_level, is_recv)); -#define _trace_hif_send(hif, tx_fill_level) trace_hif_send(hif, tx_fill_level, false) +#define _trace_hif_send(hif, tx_fill_level)\ + trace_hif_send(hif, tx_fill_level, false) DEFINE_EVENT(hif_data, hif_recv, TP_PROTO(struct hif_msg *hif, int tx_fill_level, bool is_recv), TP_ARGS(hif, tx_fill_level, is_recv)); -#define _trace_hif_recv(hif, tx_fill_level) trace_hif_recv(hif, tx_fill_level, true) +#define _trace_hif_recv(hif, tx_fill_level)\ + trace_hif_recv(hif, tx_fill_level, true) #define wfx_reg_list_enum \ wfx_reg_name(WFX_REG_CONFIG, "CONFIG") \ @@ -241,7 +245,8 @@ DECLARE_EVENT_CLASS(io_data, __entry->reg = reg; __entry->addr = addr; __entry->msg_len = len; - __entry->buf_len = min_t(int, sizeof(__entry->buf), __entry->msg_len); + __entry->buf_len = min_t(int, sizeof(__entry->buf), + __entry->msg_len); memcpy(__entry->buf, io_buf, __entry->buf_len); if (addr >= 0) snprintf(__entry->addr_str, 10, "/%08x", addr); @@ -259,12 +264,14 @@ DECLARE_EVENT_CLASS(io_data, DEFINE_EVENT(io_data, io_write, TP_PROTO(int reg, int addr, const void *io_buf, size_t len), TP_ARGS(reg, addr, io_buf, len)); -#define _trace_io_ind_write(reg, addr, io_buf, len) trace_io_write(reg, addr, io_buf, len) +#define _trace_io_ind_write(reg, addr, io_buf, len)\ + trace_io_write(reg, addr, io_buf, len) #define _trace_io_write(reg, io_buf, len) trace_io_write(reg, -1, io_buf, len) DEFINE_EVENT(io_data, io_read, TP_PROTO(int reg, int addr, const void *io_buf, size_t len), TP_ARGS(reg, addr, io_buf, len)); -#define _trace_io_ind_read(reg, addr, io_buf, len) trace_io_read(reg, addr, io_buf, len) +#define _trace_io_ind_read(reg, addr, io_buf, len)\ + trace_io_read(reg, addr, io_buf, len) #define _trace_io_read(reg, io_buf, len) trace_io_read(reg, -1, io_buf, len) DECLARE_EVENT_CLASS(io_data32, @@ -348,7 +355,8 @@ TRACE_EVENT(bh_stats, __entry->release ? "release" : "keep" ) ); -#define _trace_bh_stats(ind, req, cnf, busy, release) trace_bh_stats(ind, req, cnf, busy, release) +#define _trace_bh_stats(ind, req, cnf, busy, release)\ + trace_bh_stats(ind, req, cnf, busy, release) TRACE_EVENT(tx_stats, TP_PROTO(struct hif_cnf_tx *tx_cnf, struct sk_buff *skb, int delay), @@ -365,7 +373,8 @@ TRACE_EVENT(tx_stats, ), TP_fast_assign( // Keep sync with wfx_rates definition in main.c - static const int hw_rate[] = { 0, 1, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13 }; + static const int hw_rate[] = { 0, 1, 2, 3, 6, 7, 8, 9, + 10, 11, 12, 13 }; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_rate *rates = tx_info->driver_rates; int i; diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 44e580a07c91..781a8c8ba982 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -141,13 +141,15 @@ static inline struct wfx_vif *wdev_to_wvif(struct wfx_dev *wdev, int vif_id) } vif_id = array_index_nospec(vif_id, ARRAY_SIZE(wdev->vif)); if (!wdev->vif[vif_id]) { - dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", vif_id); + dev_dbg(wdev->dev, "requesting non-allocated vif: %d\n", + vif_id); return NULL; } return (struct wfx_vif *) wdev->vif[vif_id]->drv_priv; } -static inline struct wfx_vif *wvif_iterate(struct wfx_dev *wdev, struct wfx_vif *cur) +static inline struct wfx_vif *wvif_iterate(struct wfx_dev *wdev, + struct wfx_vif *cur) { int i; int mark = 0; -- cgit v1.2.3-59-g8ed1b From 3b2fa0c92686562ac0b8cf00c0326a45814f8e18 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sat, 19 Oct 2019 10:12:33 +0200 Subject: MIPS: ralink: enable PCI support only if driver for mt7621 SoC is selected Some versions of SoC MT7621 have three PCI express hosts. Some boards make use of those PCI through the staging driver mt7621-pci. Recently PCI support has been removed from MT7621 Soc kernel configuration due to a build error. This makes imposible to compile staging driver and produces a regression for gnubee based boards. Enable support for PCI again but enable it only if staging mt7621-pci driver is selected. Fixes: c4d48cf5e2f0 ("MIPS: ralink: deactivate PCI support for SOC_MT7621") Cc: Hauke Mehrtens Cc: ralf@linux-mips.org Cc: jhogan@kernel.org Cc: john@phrozen.org Cc: NeilBrown Cc: linux-mips@vger.kernel.org Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20191019081233.7337-1-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- arch/mips/ralink/Kconfig | 1 + drivers/staging/mt7621-pci/Kconfig | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/arch/mips/ralink/Kconfig b/arch/mips/ralink/Kconfig index 1434fa60f3db..94e9ce994494 100644 --- a/arch/mips/ralink/Kconfig +++ b/arch/mips/ralink/Kconfig @@ -51,6 +51,7 @@ choice select MIPS_GIC select COMMON_CLK select CLKSRC_MIPS_GIC + select HAVE_PCI if PCI_MT7621 endchoice choice diff --git a/drivers/staging/mt7621-pci/Kconfig b/drivers/staging/mt7621-pci/Kconfig index af928b75a940..ce58042f2f21 100644 --- a/drivers/staging/mt7621-pci/Kconfig +++ b/drivers/staging/mt7621-pci/Kconfig @@ -2,7 +2,6 @@ config PCI_MT7621 tristate "MediaTek MT7621 PCI Controller" depends on RALINK - depends on PCI select PCI_DRIVERS_GENERIC help This selects a driver for the MediaTek MT7621 PCI Controller. -- cgit v1.2.3-59-g8ed1b From abc16585919cfa6d10bc4295dd91dce51fdc6343 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 14 Nov 2019 09:54:30 +0000 Subject: staging: rtl8192u: fix indentation issue There is a block of statements that are indented too deeply, remove the extraneous tabs. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20191114095430.132120-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index e064f43fd8b6..bc98cdaf61ec 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -169,19 +169,20 @@ static void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); u16 tx_rate; - /* 87B have to S/W beacon for DTM encryption_cmn. */ - if (priv->ieee80211->current_network.mode == IEEE_A || - priv->ieee80211->current_network.mode == IEEE_N_5G || - (priv->ieee80211->current_network.mode == IEEE_N_24G && - (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { - tx_rate = 60; - DMESG("send beacon frame tx rate is 6Mbpm\n"); - } else { - tx_rate = 10; - DMESG("send beacon frame tx rate is 1Mbpm\n"); - } - rtl819xusb_beacon_tx(dev, tx_rate); /* HW Beacon */ + /* 87B have to S/W beacon for DTM encryption_cmn. */ + if (priv->ieee80211->current_network.mode == IEEE_A || + priv->ieee80211->current_network.mode == IEEE_N_5G || + (priv->ieee80211->current_network.mode == IEEE_N_24G && + (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { + tx_rate = 60; + DMESG("send beacon frame tx rate is 6Mbpm\n"); + } else { + tx_rate = 10; + DMESG("send beacon frame tx rate is 1Mbpm\n"); + } + + rtl819xusb_beacon_tx(dev, tx_rate); /* HW Beacon */ } /*----------------------------------------------------------------------------- -- cgit v1.2.3-59-g8ed1b From 6caba26ff7210e4591f6793e6597d5236c74c4bb Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 14 Nov 2019 09:57:47 +0000 Subject: staging: rtl8723bs: fix indentation issue There is a block of statements that are indented too deeply, remove the extraneous tabs. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20191114095747.132407-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 5aa5910687d1..9c4607114cea 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1621,12 +1621,12 @@ static sint aes_decipher(u8 *key, uint hdrlen, pn_vector, i + 1, frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ - aes128k128d(key, ctr_preload, aes_out); - bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); - for (j = 0; j < 16; j++) - pframe[payload_index++] = chain_buffer[j]; - } + for (j = 0; j < 16; j++) + pframe[payload_index++] = chain_buffer[j]; + } if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ -- cgit v1.2.3-59-g8ed1b From d138aed68a932476aaeb9abe680a65b2a120cdc3 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Thu, 14 Nov 2019 22:03:48 +0800 Subject: staging: exfat: remove two unused functions Fix sparse warnings: drivers/staging/exfat/exfat_core.c:2045:4: warning: symbol 'calc_checksum_1byte' was not declared. Should it be static? drivers/staging/exfat/exfat_core.c:2080:5: warning: symbol 'calc_checksum_4byte' was not declared. Should it be static? The two functions has no caller in tree, so remove it. Reported-by: Hulk Robot Signed-off-by: YueHaibing Link: https://lore.kernel.org/r/20191114140348.46088-1-yuehaibing@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_core.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_core.c b/drivers/staging/exfat/exfat_core.c index 1638ed266f68..d2d3447083c7 100644 --- a/drivers/staging/exfat/exfat_core.c +++ b/drivers/staging/exfat/exfat_core.c @@ -2042,17 +2042,6 @@ static s32 exfat_calc_num_entries(struct uni_name_t *p_uniname) return (len - 1) / 15 + 3; } -u8 calc_checksum_1byte(void *data, s32 len, u8 chksum) -{ - int i; - u8 *c = (u8 *)data; - - for (i = 0; i < len; i++, c++) - chksum = (((chksum & 1) << 7) | ((chksum & 0xFE) >> 1)) + *c; - - return chksum; -} - u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type) { int i; @@ -2077,30 +2066,6 @@ u16 calc_checksum_2byte(void *data, s32 len, u16 chksum, s32 type) return chksum; } -u32 calc_checksum_4byte(void *data, s32 len, u32 chksum, s32 type) -{ - int i; - u8 *c = (u8 *)data; - - switch (type) { - case CS_PBR_SECTOR: - for (i = 0; i < len; i++, c++) { - if ((i == 106) || (i == 107) || (i == 112)) - continue; - chksum = (((chksum & 1) << 31) | - ((chksum & 0xFFFFFFFE) >> 1)) + (u32)*c; - } - break; - default - : - for (i = 0; i < len; i++, c++) - chksum = (((chksum & 1) << 31) | - ((chksum & 0xFFFFFFFE) >> 1)) + (u32)*c; - } - - return chksum; -} - /* * Name Resolution Functions */ -- cgit v1.2.3-59-g8ed1b From 635dad0911d12d633df7611a5c564a3b98f425cf Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 14 Nov 2019 22:15:09 +0000 Subject: staging: exfat: fix spelling mistake "maont" -> "mount" There is a spelling mistake in a kernel info message. Fix it. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20191114221509.10728-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/exfat/exfat_super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index c939c57e8fd7..6e481908c59f 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -364,7 +364,7 @@ static int ffsMountVol(struct super_block *sb) exfat_bdev_open(sb); if (p_bd->sector_size < sb->s_blocksize) { - printk(KERN_INFO "EXFAT: maont failed - sector size %d less than blocksize %ld\n", + printk(KERN_INFO "EXFAT: mount failed - sector size %d less than blocksize %ld\n", p_bd->sector_size, sb->s_blocksize); ret = -EINVAL; goto out; -- cgit v1.2.3-59-g8ed1b From 2611045e3555cd0d75837ae69ffd70ef51e28bf7 Mon Sep 17 00:00:00 2001 From: Marcelo Diop-Gonzalez Date: Thu, 14 Nov 2019 18:28:01 -0500 Subject: staging: vchiq: Refactor indentation in vchiq_platform_conn_state_changed() Reducing the indentation level helps a bit with the readability of this function. There's also a checkpatch fix here, moving the first argument to kthread_create() onto the same line, as well as a relocation of the statement "char threadname[16];" to the top of the function to avoid a declaration in the middle of code. Signed-off-by: Marcelo Diop-Gonzalez Link: https://lore.kernel.org/r/20191114232801.71458-1-marcgonzalez@google.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 41 +++++++++++----------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index be8b2a71da2d..319e7aa0e0e0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3132,31 +3132,32 @@ void vchiq_platform_conn_state_changed(struct vchiq_state *state, enum vchiq_connstate newstate) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); + char threadname[16]; vchiq_log_info(vchiq_susp_log_level, "%d: %s->%s", state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate)); - if (state->conn_state == VCHIQ_CONNSTATE_CONNECTED) { - write_lock_bh(&arm_state->susp_res_lock); - if (!arm_state->first_connect) { - char threadname[16]; + if (state->conn_state != VCHIQ_CONNSTATE_CONNECTED) + return; - arm_state->first_connect = 1; - write_unlock_bh(&arm_state->susp_res_lock); - snprintf(threadname, sizeof(threadname), "vchiq-keep/%d", - state->id); - arm_state->ka_thread = kthread_create( - &vchiq_keepalive_thread_func, - (void *)state, + write_lock_bh(&arm_state->susp_res_lock); + if (arm_state->first_connect) { + write_unlock_bh(&arm_state->susp_res_lock); + return; + } + + arm_state->first_connect = 1; + write_unlock_bh(&arm_state->susp_res_lock); + snprintf(threadname, sizeof(threadname), "vchiq-keep/%d", + state->id); + arm_state->ka_thread = kthread_create(&vchiq_keepalive_thread_func, + (void *)state, + threadname); + if (IS_ERR(arm_state->ka_thread)) { + vchiq_log_error(vchiq_susp_log_level, + "vchiq: FATAL: couldn't create thread %s", threadname); - if (IS_ERR(arm_state->ka_thread)) { - vchiq_log_error(vchiq_susp_log_level, - "vchiq: FATAL: couldn't create thread %s", - threadname); - } else { - wake_up_process(arm_state->ka_thread); - } - } else - write_unlock_bh(&arm_state->susp_res_lock); + } else { + wake_up_process(arm_state->ka_thread); } } -- cgit v1.2.3-59-g8ed1b From 6cfed598480493d814414ce7e53027bd6fc45c49 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Fri, 15 Nov 2019 09:28:28 -0800 Subject: staging: rtl*: Remove tasklet callback casts In order to make the entire kernel usable under Clang's Control Flow Integrity protections, function prototype casts need to be avoided because this will trip CFI checks at runtime (i.e. a mismatch between the caller's expected function prototype and the destination function's prototype). Many of these cases can be found with -Wcast-function-type, which found that the rtl wifi drivers had a bunch of needless function casts. Remove function casts for tasklet callbacks in the various drivers. Signed-off-by: Kees Cook Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/201911150926.2894A4F973@keescook Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 3 +-- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 3 +-- drivers/staging/rtl8188eu/include/rtl8188e_recv.h | 2 +- drivers/staging/rtl8188eu/include/rtl8188e_xmit.h | 2 +- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 8 ++++---- drivers/staging/rtl8192e/rtllib_softmac.c | 7 +++---- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 7 +++---- drivers/staging/rtl8192u/r8192U_core.c | 8 ++++---- drivers/staging/rtl8712/rtl8712_recv.c | 9 ++++----- drivers/staging/rtl8712/rtl871x_xmit.c | 5 ++--- drivers/staging/rtl8712/rtl871x_xmit.h | 2 +- drivers/staging/rtl8712/usb_ops_linux.c | 4 ++-- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 11 ++++------- 13 files changed, 31 insertions(+), 40 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index c0d51ba70a75..1cf8cff9a2a4 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -22,8 +22,7 @@ int rtw_hal_init_recv_priv(struct adapter *padapter) int i, res = _SUCCESS; struct recv_buf *precvbuf; - tasklet_init(&precvpriv->recv_tasklet, - (void(*)(unsigned long))rtl8188eu_recv_tasklet, + tasklet_init(&precvpriv->recv_tasklet, rtl8188eu_recv_tasklet, (unsigned long)padapter); /* init recv_buf */ diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index ab94ad9d608a..2808f2b119bf 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -17,8 +17,7 @@ s32 rtw_hal_init_xmit_priv(struct adapter *adapt) { struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(unsigned long))rtl8188eu_xmit_tasklet, + tasklet_init(&pxmitpriv->xmit_tasklet, rtl8188eu_xmit_tasklet, (unsigned long)adapt); return _SUCCESS; } diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h index c2c7ef974dc5..23251ffa8404 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h @@ -43,7 +43,7 @@ enum rx_packet_type { }; #define INTERRUPT_MSG_FORMAT_LEN 60 -void rtl8188eu_recv_tasklet(void *priv); +void rtl8188eu_recv_tasklet(unsigned long priv); void rtl8188e_process_phy_info(struct adapter *padapter, struct recv_frame *prframe); void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h index 421e9f45306f..c6c2ad20d9cf 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -148,7 +148,7 @@ void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); #define hal_xmit_handler rtl8188eu_xmit_buf_handler -void rtl8188eu_xmit_tasklet(void *priv); +void rtl8188eu_xmit_tasklet(unsigned long priv); bool rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxmitpriv); diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index aaab0d577453..3cd6da1f843d 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -773,10 +773,10 @@ void usb_write_port_cancel(struct adapter *padapter) } } -void rtl8188eu_recv_tasklet(void *priv) +void rtl8188eu_recv_tasklet(unsigned long priv) { struct sk_buff *pskb; - struct adapter *adapt = priv; + struct adapter *adapt = (struct adapter *)priv; struct recv_priv *precvpriv = &adapt->recvpriv; while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { @@ -792,9 +792,9 @@ void rtl8188eu_recv_tasklet(void *priv) } } -void rtl8188eu_xmit_tasklet(void *priv) +void rtl8188eu_xmit_tasklet(unsigned long priv) { - struct adapter *adapt = priv; + struct adapter *adapt = (struct adapter *)priv; struct xmit_priv *pxmitpriv = &adapt->xmitpriv; if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index f2f7529e7c80..6e2f620afd14 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2044,8 +2044,9 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) } -static inline void rtllib_sta_ps(struct rtllib_device *ieee) +static inline void rtllib_sta_ps(unsigned long data) { + struct rtllib_device *ieee = (struct rtllib_device *)data; u64 time; short sleep; unsigned long flags, flags2; @@ -3027,9 +3028,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee) spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) rtllib_sta_ps, - (unsigned long)ieee); + tasklet_init(&ieee->ps_task, rtllib_sta_ps, (unsigned long)ieee); } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index bd5b554787d1..90692db81b71 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1683,8 +1683,9 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, return 1; } -static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) +static inline void ieee80211_sta_ps(unsigned long data) { + struct ieee80211_device *ieee = (struct ieee80211_device *)data; u32 th, tl; short sleep; @@ -2593,9 +2594,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); - tasklet_init(&ieee->ps_task, - (void(*)(unsigned long)) ieee80211_sta_ps, - (unsigned long)ieee); + tasklet_init(&ieee->ps_task, ieee80211_sta_ps, (unsigned long)ieee); } void ieee80211_softmac_free(struct ieee80211_device *ieee) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 48f1591ed5b4..7e2cabd16e88 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2193,7 +2193,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv) static void rtl819x_watchdog_wqcallback(struct work_struct *work); -static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv); +static void rtl8192_irq_rx_tasklet(unsigned long data); /* init tasklet and wait_queue here. only 2.6 above kernel is considered */ #define DRV_NAME "wlan0" static void rtl8192_init_priv_task(struct net_device *dev) @@ -2214,8 +2214,7 @@ static void rtl8192_init_priv_task(struct net_device *dev) InitialGainOperateWorkItemCallBack); INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); - tasklet_init(&priv->irq_rx_tasklet, - (void(*)(unsigned long))rtl8192_irq_rx_tasklet, + tasklet_init(&priv->irq_rx_tasklet, rtl8192_irq_rx_tasklet, (unsigned long)priv); } @@ -4655,8 +4654,9 @@ static void rtl8192_rx_cmd(struct sk_buff *skb) } } -static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) +static void rtl8192_irq_rx_tasklet(unsigned long data) { + struct r8192_priv *priv = (struct r8192_priv *)data; struct sk_buff *skb; struct rtl8192_rx_info *info; diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 06de031be6a9..00ea0beb12c9 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -33,7 +33,7 @@ static u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ static u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; -static void recv_tasklet(void *priv); +static void recv_tasklet(unsigned long priv); void r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter) @@ -65,8 +65,7 @@ void r8712_init_recv_priv(struct recv_priv *precvpriv, precvbuf++; } precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; - tasklet_init(&precvpriv->recv_tasklet, - (void(*)(unsigned long))recv_tasklet, + tasklet_init(&precvpriv->recv_tasklet, recv_tasklet, (unsigned long)padapter); skb_queue_head_init(&precvpriv->rx_skb_queue); @@ -1078,10 +1077,10 @@ static void recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) } while ((transfer_len > 0) && pkt_cnt > 0); } -static void recv_tasklet(void *priv) +static void recv_tasklet(unsigned long priv) { struct sk_buff *pskb; - struct _adapter *padapter = priv; + struct _adapter *padapter = (struct _adapter *)priv; struct recv_priv *precvpriv = &padapter->recvpriv; while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index cc5809e49e35..f0b85338b567 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -143,9 +143,8 @@ int _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, INIT_WORK(&padapter->wk_filter_rx_ff0, r8712_SetFilter); alloc_hwxmits(padapter); init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); - tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(unsigned long))r8712_xmit_bh, - (unsigned long)padapter); + tasklet_init(&pxmitpriv->xmit_tasklet, r8712_xmit_bh, + (unsigned long)padapter); return 0; } diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index b14da38bf652..f227828094bf 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -277,7 +277,7 @@ int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe); int r8712_xmit_enqueue(struct _adapter *padapter, struct xmit_frame *pxmitframe); void r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe); -void r8712_xmit_bh(void *priv); +void r8712_xmit_bh(unsigned long priv); void xmitframe_xmitbuf_attach(struct xmit_frame *pxmitframe, struct xmit_buf *pxmitbuf); diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 9d290bc2fdb7..0045da3bb69a 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -308,10 +308,10 @@ void r8712_usb_read_port_cancel(struct _adapter *padapter) } } -void r8712_xmit_bh(void *priv) +void r8712_xmit_bh(unsigned long priv) { int ret = false; - struct _adapter *padapter = priv; + struct _adapter *padapter = (struct _adapter *)priv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; if (padapter->driver_stopped || diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index e8577c084bbd..1e8b61443408 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -230,7 +230,7 @@ static inline bool pkt_exceeds_tail(struct recv_priv *precvpriv, return false; } -static void rtl8723bs_recv_tasklet(void *priv) +static void rtl8723bs_recv_tasklet(unsigned long priv) { struct adapter *padapter; struct hal_com_data *p_hal_data; @@ -244,7 +244,7 @@ static void rtl8723bs_recv_tasklet(void *priv) _pkt *pkt_copy = NULL; u8 shift_sz = 0, rx_report_sz = 0; - padapter = priv; + padapter = (struct adapter *)priv; p_hal_data = GET_HAL_DATA(padapter); precvpriv = &padapter->recvpriv; recv_buf_queue = &precvpriv->recv_buf_pending_queue; @@ -462,11 +462,8 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter) goto initbuferror; /* 3 2. init tasklet */ - tasklet_init( - &precvpriv->recv_tasklet, - (void(*)(unsigned long))rtl8723bs_recv_tasklet, - (unsigned long)padapter - ); + tasklet_init(&precvpriv->recv_tasklet, rtl8723bs_recv_tasklet, + (unsigned long)padapter); goto exit; -- cgit v1.2.3-59-g8ed1b From 04254066ac76a96dfaafd730a999daa678aa59c0 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 15:58:21 +0800 Subject: staging: rtl8192e: remove set but not used variable 'frag' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c: In function _rtl92e_process_phyinfo: drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c:1689:15: warning: variable frag set but not used [-Wunused-but-set-variable] It is introduced by commit 3d461c912462 ("rtl8192e: Split into two directories"), but never used, so remove it. Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574063901-87429-1-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index ef92ce957466..980b850d729a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -1686,11 +1686,10 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, static u32 last_beacon_adc_pwdb; struct rtllib_hdr_3addr *hdr; u16 sc; - unsigned int frag, seq; + unsigned int seq; hdr = (struct rtllib_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); - frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); curr_st->Seq_Num = seq; if (!prev_st->bIsAMPDU) -- cgit v1.2.3-59-g8ed1b From 7fcd011a86dc17b57dd70276f948bacb5376022b Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 15:45:52 +0800 Subject: staging: rtl8723bs: remove set but not used variable 'pHalData', 'pregistrypriv' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/hal/sdio_halinit.c: In function sdio_AggSettingRxUpdate: drivers/staging/rtl8723bs/hal/sdio_halinit.c:578:23: warning: variable pHalData set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/sdio_halinit.c: In function rtl8723bs_hal_init: drivers/staging/rtl8723bs/hal/sdio_halinit.c:734:24: warning: variable pregistrypriv set but not used [-Wunused-but-set-variable] They are introduced by commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver"), but never used, so remove them. Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574063156-68155-2-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 0f5dd4629e6f..e813382e78a6 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -570,14 +570,11 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) static void sdio_AggSettingRxUpdate(struct adapter *padapter) { - struct hal_com_data *pHalData; u8 valueDMA; u8 valueRxAggCtrl = 0; u8 aggBurstNum = 3; /* 0:1, 1:2, 2:3, 3:4 */ u8 aggBurstSize = 0; /* 0:1K, 1:512Byte, 2:256Byte... */ - pHalData = GET_HAL_DATA(padapter); - valueDMA = rtw_read8(padapter, REG_TRXDMA_CTRL); valueDMA |= RXDMA_AGG_EN; rtw_write8(padapter, REG_TRXDMA_CTRL, valueDMA); @@ -713,13 +710,11 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) s32 ret; struct hal_com_data *pHalData; struct pwrctrl_priv *pwrctrlpriv; - struct registry_priv *pregistrypriv; u32 NavUpper = WiFiNavUpperUs; u8 u1bTmp; pHalData = GET_HAL_DATA(padapter); pwrctrlpriv = adapter_to_pwrctl(padapter); - pregistrypriv = &padapter->registrypriv; if ( adapter_to_pwrctl(padapter)->bips_processing == true && -- cgit v1.2.3-59-g8ed1b From 68a65ab1b7f19a702679e06e5691e81ea0181a7a Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 15:45:53 +0800 Subject: staging: rtl8723bs: remove set but not used variable 'pHalData', 'pdmpriv' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c: In function rtl8723b_InitAntenna_Selection: drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:2237:23: warning: variable pHalData set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c: In function rtl8723b_fill_default_txdesc: drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:3056:18: warning: variable pdmpriv set but not used [-Wunused-but-set-variable] They are introduced by commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver"), but never used, so remove them. Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574063156-68155-3-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 22931ab3a5fc..66127f6c8e4d 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2234,12 +2234,8 @@ void rtl8723b_set_hal_ops(struct hal_ops *pHalFunc) void rtl8723b_InitAntenna_Selection(struct adapter *padapter) { - struct hal_com_data *pHalData; u8 val; - - pHalData = GET_HAL_DATA(padapter); - val = rtw_read8(padapter, REG_LEDCFG2); /* Let 8051 take control antenna settting */ val |= BIT(7); /* DPDT_SEL_EN, 0x4C[23] */ @@ -3053,7 +3049,6 @@ static void rtl8723b_fill_default_txdesc( { struct adapter *padapter; struct hal_com_data *pHalData; - struct dm_priv *pdmpriv; struct mlme_ext_priv *pmlmeext; struct mlme_ext_info *pmlmeinfo; struct pkt_attrib *pattrib; @@ -3064,7 +3059,6 @@ static void rtl8723b_fill_default_txdesc( padapter = pxmitframe->padapter; pHalData = GET_HAL_DATA(padapter); - pdmpriv = &pHalData->dmpriv; pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &(pmlmeext->mlmext_info); -- cgit v1.2.3-59-g8ed1b From 17b937a9d6f7ed4aeba0b610baafccf7e730e71f Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 15:45:54 +0800 Subject: staging: rtl8723bs: remove set but not used variable 'pmlmeinfo', 'pHalData' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c: In function ConstructBtNullFunctionData: drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c:2099:24: warning: variable pmlmeinfo set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c: In function SetFwRsvdPagePkt_BTCoex: drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c:2154:24: warning: variable pmlmeinfo set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c: In function SetFwRsvdPagePkt_BTCoex: drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c:2149:23: warning: variable pHalData set but not used [-Wunused-but-set-variable] They are introduced by commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver"), but never used, so remove them. Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574063156-68155-4-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 7760fd0eb6c9..71b5a50b6ef6 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -2071,8 +2071,6 @@ static void ConstructBtNullFunctionData( struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; u32 pktlen; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; u8 bssid[ETH_ALEN]; @@ -2080,8 +2078,6 @@ static void ConstructBtNullFunctionData( FUNC_ADPT_ARG(padapter), bQoS, bEosp, bForcePowerSave); pwlanhdr = (struct ieee80211_hdr *)pframe; - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; if (!StaAddr) { memcpy(bssid, myid(&padapter->eeprompriv), ETH_ALEN); @@ -2122,12 +2118,9 @@ static void ConstructBtNullFunctionData( static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter) { - struct hal_com_data *pHalData; struct xmit_frame *pcmdframe; struct pkt_attrib *pattrib; struct xmit_priv *pxmitpriv; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; u32 BeaconLength = 0; u32 BTQosNullLength = 0; u8 *ReservedPagePacket; @@ -2140,10 +2133,7 @@ static void SetFwRsvdPagePkt_BTCoex(struct adapter *padapter) /* DBG_8192C("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); */ - pHalData = GET_HAL_DATA(padapter); pxmitpriv = &padapter->xmitpriv; - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; TxDescLen = TXDESC_SIZE; TxDescOffset = TXDESC_OFFSET; PageSize = PAGE_SIZE_TX_8723B; -- cgit v1.2.3-59-g8ed1b From eb22caade58d6da19595f7a515ca4b8fdfccb9a2 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 15:45:55 +0800 Subject: staging: rtl8723bs: remove set but not used variable 'notify_ielen', 'notify_ie', 'notify_interval', 'notify_capability' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c: In function rtw_cfg80211_inform_bss: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:248:9: warning: variable notify_ielen set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c: In function rtw_cfg80211_inform_bss: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:247:6: warning: variable notify_ie set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c: In function rtw_cfg80211_inform_bss: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:246:6: warning: variable notify_interval set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c: In function rtw_cfg80211_inform_bss: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:245:6: warning: variable notify_capability set but not used [-Wunused-but-set-variable] They are introduced by commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver"), but never used, so remove them. Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574063156-68155-5-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 52c1f6625038..9a17a9b19905 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -240,10 +240,6 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl u16 channel; u32 freq; u64 notify_timestamp; - u16 notify_capability; - u16 notify_interval; - u8 *notify_ie; - size_t notify_ielen; s32 notify_signal; u8 *buf = NULL, *pbuf; size_t len, bssinf_len = 0; @@ -324,12 +320,6 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl notify_timestamp = ktime_to_us(ktime_get_boottime()); - notify_interval = le16_to_cpu(*(__le16 *)rtw_get_beacon_interval_from_ie(pnetwork->network.IEs)); - notify_capability = le16_to_cpu(*(__le16 *)rtw_get_capability_from_ie(pnetwork->network.IEs)); - - notify_ie = pnetwork->network.IEs+_FIXED_IE_LENGTH_; - notify_ielen = pnetwork->network.IELength-_FIXED_IE_LENGTH_; - /* We've set wiphy's signal_type as CFG80211_SIGNAL_TYPE_MBM: signal strength in mBm (100*dBm) */ if (check_fwstate(pmlmepriv, _FW_LINKED) == true && is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) { -- cgit v1.2.3-59-g8ed1b From 7da8abcf482adcc0d84ebf619f9f841058fccdb1 Mon Sep 17 00:00:00 2001 From: zhengbin Date: Mon, 18 Nov 2019 15:45:56 +0800 Subject: staging: rtl8723bs: remove set but not used variable 'change', 'pos' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c: In function cfg80211_rtw_change_iface: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1310:5: warning: variable change set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c: In function rtw_cfg80211_set_wpa_ie: drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1803:19: warning: variable pos set but not used [-Wunused-but-set-variable] They are introduced by commit 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver"), but never used, so remove them. Reported-by: Hulk Robot Signed-off-by: zhengbin Link: https://lore.kernel.org/r/1574063156-68155-6-git-send-email-zhengbin13@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 9a17a9b19905..322cabb97b99 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1295,7 +1295,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, struct wireless_dev *rtw_wdev = padapter->rtw_wdev; struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); int ret = 0; - u8 change = false; DBG_871X(FUNC_NDEV_FMT" type =%d\n", FUNC_NDEV_ARG(ndev), type); @@ -1326,7 +1325,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, if (old_type != type) { - change = true; pmlmeext->action_public_rxseq = 0xffff; pmlmeext->action_public_dialog_token = 0xff; } @@ -1795,7 +1793,7 @@ static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv, u32 key static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t ielen) { - u8 *buf = NULL, *pos = NULL; + u8 *buf = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; int wpa_ielen = 0; @@ -1830,7 +1828,6 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel DBG_8192C("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); } - pos = buf; if (ielen < RSN_HEADER_LEN) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen)); ret = -1; -- cgit v1.2.3-59-g8ed1b From 21f585480deb4bcf0d92b08879c35d066dfee030 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 20 Nov 2019 11:57:12 +0200 Subject: fbtft: Make sure string is NULL terminated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New GCC warns about inappropriate use of strncpy(): drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_framebuffer_alloc’: drivers/staging/fbtft/fbtft-core.c:665:2: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] 665 | strncpy(info->fix.id, dev->driver->name, 16); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Later on the copy is being used with the assumption to be NULL terminated. Make sure string is NULL terminated by switching to snprintf(). Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20191120095716.26628-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 63d36f21eb98..d08048584ec4 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -666,7 +666,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, fbdefio->deferred_io = fbtft_deferred_io; fb_deferred_io_init(info); - strncpy(info->fix.id, dev->driver->name, 16); + snprintf(info->fix.id, sizeof(info->fix.id), "%s", dev->driver->name); info->fix.type = FB_TYPE_PACKED_PIXELS; info->fix.visual = FB_VISUAL_TRUECOLOR; info->fix.xpanstep = 0; -- cgit v1.2.3-59-g8ed1b From 6753e7957fef5d9f48eaee25b87314d7a800eb3a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 20 Nov 2019 11:57:13 +0200 Subject: fbtft: Describe function parameters in kernel-doc Kernel documentation script complains that some of the function parameters are not described: drivers/staging/fbtft/fbtft-core.c:543: warning: Function parameter or member 'pdata' not described in 'fbtft_framebuffer_alloc' Describe function parameters where it's appropriate. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20191120095716.26628-2-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index d08048584ec4..9040a87291ac 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -529,6 +529,7 @@ static void fbtft_merge_fbtftops(struct fbtft_ops *dst, struct fbtft_ops *src) * * @display: pointer to structure describing the display * @dev: pointer to the device for this fb, this can be NULL + * @pdata: platform data for the display in use * * Creates a new frame buffer info structure. * -- cgit v1.2.3-59-g8ed1b From 2494fd4c8388af803fcb5d5198b46d1285121afb Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 20 Nov 2019 11:57:14 +0200 Subject: fbtft: Drop useless #ifdef CONFIG_OF and dead code First of all there is no need to guard GPIO request by CONFIG_OF. It works for everybody independently on resource provider. While here, rename the function to reflect the above. Moreover, since we have a global dependency to OF, the rest of conditional compilation is no-op, i.e. it's always be true. Due to above drop useless #ifdef CONFIG_OF and therefore dead code. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20191120095716.26628-3-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 9040a87291ac..52ea15437c4d 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -70,7 +70,6 @@ void fbtft_dbg_hex(const struct device *dev, int groupsize, } EXPORT_SYMBOL(fbtft_dbg_hex); -#ifdef CONFIG_OF static int fbtft_request_one_gpio(struct fbtft_par *par, const char *name, int index, struct gpio_desc **gpiop) @@ -92,14 +91,11 @@ static int fbtft_request_one_gpio(struct fbtft_par *par, return ret; } -static int fbtft_request_gpios_dt(struct fbtft_par *par) +static int fbtft_request_gpios(struct fbtft_par *par) { int i; int ret; - if (!par->info->device->of_node) - return -EINVAL; - ret = fbtft_request_one_gpio(par, "reset", 0, &par->gpio.reset); if (ret) return ret; @@ -135,7 +131,6 @@ static int fbtft_request_gpios_dt(struct fbtft_par *par) return 0; } -#endif #ifdef CONFIG_FB_BACKLIGHT static int fbtft_backlight_update_status(struct backlight_device *bd) @@ -898,7 +893,6 @@ int fbtft_unregister_framebuffer(struct fb_info *fb_info) } EXPORT_SYMBOL(fbtft_unregister_framebuffer); -#ifdef CONFIG_OF /** * fbtft_init_display_dt() - Device Tree init_display() function * @par: Driver data @@ -977,7 +971,6 @@ static int fbtft_init_display_dt(struct fbtft_par *par) return 0; } -#endif /** * fbtft_init_display() - Generic init_display() function @@ -1138,7 +1131,6 @@ static int fbtft_verify_gpios(struct fbtft_par *par) return 0; } -#ifdef CONFIG_OF /* returns 0 if the property is not present */ static u32 fbtft_of_value(struct device_node *node, const char *propname) { @@ -1184,17 +1176,10 @@ static struct fbtft_platform_data *fbtft_probe_dt(struct device *dev) pdata->display.backlight = 1; if (of_find_property(node, "init", NULL)) pdata->display.fbtftops.init_display = fbtft_init_display_dt; - pdata->display.fbtftops.request_gpios = fbtft_request_gpios_dt; + pdata->display.fbtftops.request_gpios = fbtft_request_gpios; return pdata; } -#else -static struct fbtft_platform_data *fbtft_probe_dt(struct device *dev) -{ - dev_err(dev, "Missing platform data\n"); - return ERR_PTR(-EINVAL); -} -#endif /** * fbtft_probe_common() - Generic device probe() helper function -- cgit v1.2.3-59-g8ed1b From 8b2d3aeeb7ec8110458ba59bf9c8b3af84f1139a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 20 Nov 2019 11:57:15 +0200 Subject: fbtft: Make use of device property API Make use of device property API in this driver so that both OF based system and ACPI based system can use this driver. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20191120095716.26628-4-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 105 ++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 47 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 52ea15437c4d..ffb84987dd86 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -22,8 +22,9 @@ #include #include #include +#include #include -#include + #include