Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: rtl8712: Use completions for signaling

r8712_sitesurvey_cmd() uses a variable to notify r8712_SetFilter() that it
has completed operation. There is no sort of assurance that the variable will
actually change and it could cache the value the first time it is read and
then never update it for the whole loop logic.

Use completion variables because they are better suited for the purpose.

This patch fixes the checkpatch.pl warnings like:
CHECK: Avoid CamelCase: <blnEnableRxFF0Filter>
+ u8 blnEnableRxFF0Filter;

Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Sathish Kumar <skumark1902@gmail.com>
Link: https://lore.kernel.org/r/20220323045515.2513-1-skumark1902@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Sathish Kumar and committed by
Greg Kroah-Hartman
a3515f20 52a0af70

+4 -11
+1 -2
drivers/staging/rtl8712/drv_types.h
··· 157 157 struct iw_statistics iwstats; 158 158 int pid; /*process id from UI*/ 159 159 struct work_struct wk_filter_rx_ff0; 160 - u8 blnEnableRxFF0Filter; 161 - spinlock_t lock_rx_ff0_filter; 162 160 const struct firmware *fw; 163 161 struct usb_interface *pusb_intf; 164 162 struct mutex mutex_start; 165 163 struct completion rtl8712_fw_ready; 164 + struct completion rx_filter_ready; 166 165 }; 167 166 168 167 static inline u8 *myid(struct eeprom_priv *peepriv)
+1 -1
drivers/staging/rtl8712/rtl871x_cmd.c
··· 202 202 mod_timer(&pmlmepriv->scan_to_timer, 203 203 jiffies + msecs_to_jiffies(SCANNING_TIMEOUT)); 204 204 padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY); 205 - padapter->blnEnableRxFF0Filter = 0; 205 + complete(&padapter->rx_filter_ready); 206 206 return _SUCCESS; 207 207 } 208 208
+1 -1
drivers/staging/rtl8712/usb_intf.c
··· 568 568 /* step 6. Load the firmware asynchronously */ 569 569 if (rtl871x_load_fw(padapter)) 570 570 goto deinit_drv_sw; 571 - spin_lock_init(&padapter->lock_rx_ff0_filter); 571 + init_completion(&padapter->rx_filter_ready); 572 572 mutex_init(&padapter->mutex_start); 573 573 return 0; 574 574
+1 -7
drivers/staging/rtl8712/xmit_linux.c
··· 95 95 struct _adapter *adapter = container_of(work, struct _adapter, 96 96 wk_filter_rx_ff0); 97 97 u8 oldvalue = 0x00, newvalue = 0x00; 98 - unsigned long irqL; 99 98 100 99 oldvalue = r8712_read8(adapter, 0x117); 101 100 newvalue = oldvalue & 0xfe; 102 101 r8712_write8(adapter, 0x117, newvalue); 103 102 104 - spin_lock_irqsave(&adapter->lock_rx_ff0_filter, irqL); 105 - adapter->blnEnableRxFF0Filter = 1; 106 - spin_unlock_irqrestore(&adapter->lock_rx_ff0_filter, irqL); 107 - do { 108 - msleep(100); 109 - } while (adapter->blnEnableRxFF0Filter == 1); 103 + wait_for_completion(&adapter->rx_filter_ready); 110 104 r8712_write8(adapter, 0x117, oldvalue); 111 105 } 112 106