diff options
72 files changed, 1330 insertions, 2666 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 124214ba6feb..8bdfe2a13135 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14069,6 +14069,16 @@ F: drivers/regulator/mpq7920.c F: drivers/regulator/mpq7920.h F: include/linux/mfd/mp2629.h +MOST(R) TECHNOLOGY DRIVER +M: Parthiban Veerasooran <parthiban.veerasooran@microchip.com> +M: Christian Gromm <christian.gromm@microchip.com> +S: Maintained +F: Documentation/ABI/testing/configfs-most +F: Documentation/ABI/testing/sysfs-bus-most +F: drivers/most/ +F: drivers/staging/most/ +F: include/linux/most.h + MOTION EYE VAIO PICTUREBOOK CAMERA DRIVER S: Orphan W: http://popies.net/meye/ diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index b4e19174bef2..f9765841c4aa 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -2587,10 +2587,15 @@ static int nbu2ss_ep_queue(struct usb_ep *_ep, req->unaligned = false; if (req->unaligned) { - if (!ep->virt_buf) + if (!ep->virt_buf) { ep->virt_buf = dma_alloc_coherent(udc->dev, PAGE_SIZE, &ep->phys_buf, GFP_ATOMIC | GFP_DMA); + if (!ep->virt_buf) { + spin_unlock_irqrestore(&udc->lock, flags); + return -ENOMEM; + } + } if (ep->epnum > 0) { if (ep->direct == USB_DIR_IN) memcpy(ep->virt_buf, req->req.buf, diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index 8a7cf1d0e968..d729b922a750 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -43,7 +43,11 @@ struct gb_gpio_controller { }; #define gpio_chip_to_gb_gpio_controller(chip) \ container_of(chip, struct gb_gpio_controller, chip) -#define irq_data_to_gpio_chip(d) (d->domain->host_data) + +static struct gpio_chip *irq_data_to_gpio_chip(struct irq_data *d) +{ + return d->domain->host_data; +} static int gb_gpio_line_count_operation(struct gb_gpio_controller *ggc) { diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c index 8e9d9d59a357..b7badf87a3f0 100644 --- a/drivers/staging/greybus/usb.c +++ b/drivers/staging/greybus/usb.c @@ -27,7 +27,7 @@ struct gb_usb_hub_control_request { }; struct gb_usb_hub_control_response { - u8 buf[0]; + DECLARE_FLEX_ARRAY(u8, buf); }; struct gb_usb_device { diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 044c807ca022..e03c87f0bfe7 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -382,8 +382,7 @@ static int ks_wlan_get_nick(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ - strncpy(extra, priv->nick, 16); - extra[16] = '\0'; + strscpy(extra, priv->nick, 17); dwrq->data.length = strlen(extra) + 1; return 0; diff --git a/drivers/staging/pi433/TODO b/drivers/staging/pi433/TODO index 5cf3fd99d521..23c808fc99de 100644 --- a/drivers/staging/pi433/TODO +++ b/drivers/staging/pi433/TODO @@ -3,3 +3,6 @@ * Some missing data (marked with ###) needs to be added in the documentation * Change (struct pi433_tx_cfg)->bit_rate to be a u32 so that we can support bit rates up to 300kbps per the spec. + -> This configuration needs to be moved to sysfs instead of being done through + IOCTL. Going forward, we need to port userspace tools to use sysfs instead + of IOCTL and then we would delete IOCTL. diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index d4e06a3929f3..b59f6a4cb611 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -55,6 +55,7 @@ static dev_t pi433_dev; static DEFINE_IDR(pi433_idr); static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */ +static struct dentry *root_dir; /* debugfs root directory for the driver */ static struct class *pi433_class; /* mainly for udev to create /dev/pi433 */ @@ -1306,8 +1307,7 @@ static int pi433_probe(struct spi_device *spi) /* spi setup */ spi_set_drvdata(spi, device); - entry = debugfs_create_dir(dev_name(device->dev), - debugfs_lookup(KBUILD_MODNAME, NULL)); + entry = debugfs_create_dir(dev_name(device->dev), root_dir); debugfs_create_file("regs", 0400, entry, device, &pi433_debugfs_regs_fops); return 0; @@ -1333,9 +1333,8 @@ RX_failed: static void pi433_remove(struct spi_device *spi) { struct pi433_device *device = spi_get_drvdata(spi); - struct dentry *mod_entry = debugfs_lookup(KBUILD_MODNAME, NULL); - debugfs_remove(debugfs_lookup(dev_name(device->dev), mod_entry)); + debugfs_lookup_and_remove(dev_name(device->dev), root_dir); /* free GPIOs */ free_gpio(device); @@ -1408,7 +1407,7 @@ static int __init pi433_init(void) return PTR_ERR(pi433_class); } - debugfs_create_dir(KBUILD_MODNAME, NULL); + root_dir = debugfs_create_dir(KBUILD_MODNAME, NULL); status = spi_register_driver(&pi433_spi_driver); if (status < 0) { @@ -1427,7 +1426,7 @@ static void __exit pi433_exit(void) spi_unregister_driver(&pi433_spi_driver); class_destroy(pi433_class); unregister_chrdev(MAJOR(pi433_dev), pi433_spi_driver.driver.name); - debugfs_remove_recursive(debugfs_lookup(KBUILD_MODNAME, NULL)); + debugfs_remove(root_dir); } module_exit(pi433_exit); diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 19b2f73d481d..ca9e3d4ee7f4 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -28,32 +28,6 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) } } -/* Calling Context: - * - * rtw_enqueue_cmd can only be called between kernel thread, - * since only spin_lock is used. - * - * ISR/Call-Back functions can't call this sub-function. - */ - -static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) -{ - unsigned long flags; - - if (!obj) - goto exit; - - spin_lock_irqsave(&queue->lock, flags); - - list_add_tail(&obj->list, &queue->queue); - - spin_unlock_irqrestore(&queue->lock, flags); - -exit: - - return _SUCCESS; -} - int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { init_completion(&pcmdpriv->enqueue_cmd); @@ -65,8 +39,6 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - pcmdpriv->cmd_seq = 1; - pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, GFP_KERNEL); @@ -127,28 +99,25 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) { - int res = _FAIL; + unsigned long flags; struct adapter *padapter = pcmdpriv->padapter; if (!cmd_obj) - goto exit; + return _FAIL; cmd_obj->padapter = padapter; - res = rtw_cmd_filter(pcmdpriv, cmd_obj); - if (res == _FAIL) { + if (rtw_cmd_filter(pcmdpriv, cmd_obj) == _FAIL) { rtw_free_cmd_obj(cmd_obj); - goto exit; + return _FAIL; } - res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); - - if (res == _SUCCESS) - complete(&pcmdpriv->enqueue_cmd); - -exit: + spin_lock_irqsave(&pcmdpriv->cmd_queue.lock, flags); + list_add_tail(&cmd_obj->list, &pcmdpriv->cmd_queue.queue); + spin_unlock_irqrestore(&pcmdpriv->cmd_queue.lock, flags); - return res; + complete(&pcmdpriv->enqueue_cmd); + return _SUCCESS; } struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) @@ -233,8 +202,6 @@ _next: ret = cmd_hdl(pcmd->padapter, pcmdbuf); pcmd->res = ret; } - - pcmdpriv->cmd_seq++; } else { pcmd->res = H2C_PARAMETERS_ERROR; } @@ -1201,24 +1168,20 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) } } -u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) +void rtw_chk_hi_queue_cmd(struct adapter *padapter) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } + if (!ph2c) + return; pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); if (!pdrvextra_cmd_parm) { kfree(ph2c); - res = _FAIL; - goto exit; + return; } pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID; @@ -1227,9 +1190,7 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - return res; + rtw_enqueue_cmd(pcmdpriv, ph2c); } u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c index 682c65b1e04c..1e4baf74ecd5 100644 --- a/drivers/staging/r8188eu/core/rtw_fw.c +++ b/drivers/staging/r8188eu/core/rtw_fw.c @@ -89,9 +89,8 @@ static int block_write(struct adapter *padapter, u8 *buffer, u32 size) addr = FW_8188E_START_ADDRESS + i * block_size; data = buffer + i * block_size; - ret = rtw_writeN(padapter, addr, block_size, data); - if (ret == _FAIL) - goto exit; + if (rtw_writeN(padapter, addr, block_size, data)) + return _FAIL; } if (remain) { @@ -105,9 +104,8 @@ static int block_write(struct adapter *padapter, u8 *buffer, u32 size) addr = FW_8188E_START_ADDRESS + offset + i * block_size; data = buffer + offset + i * block_size; - ret = rtw_writeN(padapter, addr, block_size, data); - if (ret == _FAIL) - goto exit; + if (rtw_writeN(padapter, addr, block_size, data)) + return _FAIL; } } diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index b272123626ac..fb7d0e161fdd 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -444,8 +444,6 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex if (check_fwstate(pmlmepriv, _FW_LINKED) && is_same_network(&pmlmepriv->cur_network.network, pnetwork)) { update_network(&pmlmepriv->cur_network.network, pnetwork, adapter, true); - rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), - pmlmepriv->cur_network.network.IELength); } } @@ -1027,9 +1025,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net break; } - rtw_update_protection(padapter, (cur_network->network.IEs) + - sizeof(struct ndis_802_11_fixed_ie), - (cur_network->network.IELength)); rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength); } diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 1b9cf7596a76..dc181e491b34 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -3735,35 +3735,18 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) return _SUCCESS; } -static void on_action_public_vendor(struct recv_frame *precv_frame) -{ - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - - if (!memcmp(frame_body + 2, P2P_OUI, 4)) - on_action_public_p2p(precv_frame); -} - -static void on_action_public_default(struct recv_frame *precv_frame) -{ - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - u8 token; - - token = frame_body[2]; - - rtw_action_public_decache(precv_frame, token); -} - static void on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) { struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data; + u8 *frame_body = (u8 *)&mgmt->u; /* All members of the action enum start with action_code. */ - if (mgmt->u.action.u.s1g.action_code == WLAN_PUB_ACTION_VENDOR_SPECIFIC) - on_action_public_vendor(precv_frame); - else - on_action_public_default(precv_frame); + if (mgmt->u.action.u.s1g.action_code == WLAN_PUB_ACTION_VENDOR_SPECIFIC) { + if (!memcmp(frame_body + 2, P2P_OUI, 4)) + on_action_public_p2p(precv_frame); + } else { + rtw_action_public_decache(precv_frame, frame_body[2]); + } } static void OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 5290ac36f08c..051cdcb11ff5 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -8,7 +8,7 @@ #include "../include/osdep_intf.h" #include "../include/linux/usb.h" -void ips_enter(struct adapter *padapter) +static void ips_enter(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct xmit_priv *pxmit_priv = &padapter->xmitpriv; @@ -25,21 +25,20 @@ void ips_enter(struct adapter *padapter) pwrpriv->ips_mode = pwrpriv->ips_mode_req; pwrpriv->ips_enter_cnts++; - if (rf_off == pwrpriv->change_rfpwrstate) { - pwrpriv->bpower_saving = true; + pwrpriv->bpower_saving = true; - if (pwrpriv->ips_mode == IPS_LEVEL_2) - pwrpriv->bkeepfwalive = true; + if (pwrpriv->ips_mode == IPS_LEVEL_2) + pwrpriv->bkeepfwalive = true; + + rtw_ips_pwr_down(padapter); + pwrpriv->rf_pwrstate = rf_off; - rtw_ips_pwr_down(padapter); - pwrpriv->rf_pwrstate = rf_off; - } pwrpriv->bips_processing = false; mutex_unlock(&pwrpriv->lock); } -int ips_leave(struct adapter *padapter) +static int ips_leave(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -51,7 +50,6 @@ int ips_leave(struct adapter *padapter) if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { pwrpriv->bips_processing = true; - pwrpriv->change_rfpwrstate = rf_on; pwrpriv->ips_leave_cnts++; result = rtw_ips_pwr_up(padapter); @@ -133,10 +131,9 @@ void rtw_ps_processor(struct adapter *padapter) if (!rtw_pwr_unassociated_idle(padapter)) goto exit; - if (pwrpriv->rf_pwrstate == rf_on) { - pwrpriv->change_rfpwrstate = rf_off; + if (pwrpriv->rf_pwrstate == rf_on) ips_enter(padapter); - } + exit: rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); pwrpriv->ps_processing = false; diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 631c500dda42..fc7568cf948b 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -38,7 +38,7 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) static int rtl8188eu_init_recv_priv(struct adapter *padapter) { struct recv_priv *precvpriv = &padapter->recvpriv; - int i, res = _SUCCESS; + int i, err = 0; struct recv_buf *precvbuf; tasklet_init(&precvpriv->recv_tasklet, @@ -50,10 +50,8 @@ static int rtl8188eu_init_recv_priv(struct adapter *padapter) precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, GFP_KERNEL); - if (!precvpriv->pallocated_recv_buf) { - res = _FAIL; - goto exit; - } + if (!precvpriv->pallocated_recv_buf) + return -ENOMEM; precvpriv->precv_buf = (u8 *)ALIGN((size_t)(precvpriv->pallocated_recv_buf), 4); @@ -64,7 +62,7 @@ static int rtl8188eu_init_recv_priv(struct adapter *padapter) precvbuf->reuse = false; precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); if (!precvbuf->purb) { - res = _FAIL; + err = -ENOMEM; break; } precvbuf->adapter = padapter; @@ -94,17 +92,15 @@ static int rtl8188eu_init_recv_priv(struct adapter *padapter) pskb = NULL; } } -exit: - return res; + + return err; } int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) { int i; - struct recv_frame *precvframe; - - int res = _SUCCESS; + int err; spin_lock_init(&precvpriv->lock); @@ -117,11 +113,8 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvpriv->free_recvframe_cnt = NR_RECVFRAME; precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); - - if (!precvpriv->pallocated_frame_buf) { - res = _FAIL; - goto exit; - } + if (!precvpriv->pallocated_frame_buf) + return -ENOMEM; precvpriv->precv_frame_buf = (u8 *)ALIGN((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); @@ -141,15 +134,14 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) } precvpriv->rx_pending_cnt = 1; - res = rtl8188eu_init_recv_priv(padapter); + err = rtl8188eu_init_recv_priv(padapter); timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, 0); precvpriv->signal_stat_sampling_interval = 1000; /* ms */ rtw_set_signal_stat_timer(precvpriv); -exit: - return res; + return err; } static void rtl8188eu_free_recv_priv(struct adapter *padapter) diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index b4aee8623099..e1ae1859686e 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -260,22 +260,22 @@ void rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) spin_lock_bh(&pxmitpriv->lock); - rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q); + rtw_free_xmitframe_list(pxmitpriv, get_list_head(&psta->sleep_q)); psta->sleepq_len = 0; - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); + rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); list_del_init(&pstaxmitpriv->vo_q.tx_pending); - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); + rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); list_del_init(&pstaxmitpriv->vi_q.tx_pending); - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); + rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); list_del_init(&pstaxmitpriv->bk_q.tx_pending); - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); + rtw_free_xmitframe_list(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); list_del_init(&pstaxmitpriv->be_q.tx_pending); @@ -391,8 +391,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) /* any station allocated can be searched by hash list */ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { - struct list_head *plist, *phead; - struct sta_info *psta = NULL; + struct sta_info *ploop, *psta = NULL; u32 index; u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -409,18 +408,11 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_lock_bh(&pstapriv->sta_hash_lock); - phead = &pstapriv->sta_hash[index]; - plist = phead->next; - - while (phead != plist) { - psta = container_of(plist, struct sta_info, hash_list); - - if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) { - /* if found the matched address */ + list_for_each_entry(ploop, &pstapriv->sta_hash[index], hash_list) { + if (!memcmp(ploop->hwaddr, addr, ETH_ALEN)) { + psta = ploop; break; } - psta = NULL; - plist = plist->next; } spin_unlock_bh(&pstapriv->sta_hash_lock); diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 34494f08c0cd..df88b3e29e77 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -17,7 +17,7 @@ static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; static void _init_txservq(struct tx_servq *ptxservq) { INIT_LIST_HEAD(&ptxservq->tx_pending); - rtw_init_queue(&ptxservq->sta_pending); + INIT_LIST_HEAD(&ptxservq->sta_pending); ptxservq->qcnt = 0; } @@ -29,8 +29,6 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) _init_txservq(&psta_xmitpriv->bk_q); _init_txservq(&psta_xmitpriv->vi_q); _init_txservq(&psta_xmitpriv->vo_q); - INIT_LIST_HEAD(&psta_xmitpriv->legacy_dz); - INIT_LIST_HEAD(&psta_xmitpriv->apsd); } static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, @@ -41,7 +39,6 @@ static int rtw_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *px return -ENOMEM; pxmitbuf->pbuf = (u8 *)ALIGN((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); - pxmitbuf->dma_transfer_addr = 0; pxmitbuf->pxmit_urb = usb_alloc_urb(0, GFP_KERNEL); if (!pxmitbuf->pxmit_urb) { @@ -70,7 +67,6 @@ int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ spin_lock_init(&pxmitpriv->lock); - sema_init(&pxmitpriv->terminate_xmitthread_sema, 0); /* * Please insert all the queue initializaiton using rtw_init_queue below @@ -78,11 +74,10 @@ int _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); + INIT_LIST_HEAD(&pxmitpriv->be_pending); + INIT_LIST_HEAD(&pxmitpriv->bk_pending); + INIT_LIST_HEAD(&pxmitpriv->vi_pending); + INIT_LIST_HEAD(&pxmitpriv->vo_pending); rtw_init_queue(&pxmitpriv->free_xmit_queue); @@ -153,7 +148,7 @@ int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) goto free_xmitbuf; } - pxmitbuf->flags = XMIT_VO_QUEUE; + pxmitbuf->high_queue = false; list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue); pxmitbuf++; @@ -192,26 +187,14 @@ int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (rtw_alloc_hwxmits(padapter)) goto free_xmit_extbuf; - rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); - for (i = 0; i < 4; i++) pxmitpriv->wmm_para_seq[i] = i; - pxmitpriv->txirp_cnt = 1; - - sema_init(&pxmitpriv->tx_retevt, 0); - - /* per AC pending irp */ - pxmitpriv->beq_cnt = 0; - pxmitpriv->bkq_cnt = 0; - pxmitpriv->viq_cnt = 0; - pxmitpriv->voq_cnt = 0; - pxmitpriv->ack_tx = false; mutex_init(&pxmitpriv->ack_tx_mutex); rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0); - rtl8188eu_init_xmit_priv(padapter); + tasklet_init(&pxmitpriv->xmit_tasklet, rtl8188eu_xmit_tasklet, (unsigned long)padapter); return 0; @@ -296,7 +279,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) vfree(pxmitpriv->pallocated_xmit_extbuf); - rtw_free_hwxmits(padapter); + kfree(pxmitpriv->hwxmits); mutex_destroy(&pxmitpriv->ack_tx_mutex); } @@ -761,28 +744,27 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr return _SUCCESS; } -static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) +static void xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { struct pkt_attrib *pattrib = &pxmitframe->attrib; - if (pattrib->bswenc) { - switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: - rtw_wep_encrypt(padapter, pxmitframe); - break; - case _TKIP_: - rtw_tkip_encrypt(padapter, pxmitframe); - break; - case _AES_: - rtw_aes_encrypt(padapter, pxmitframe); - break; - default: - break; - } - } + if (!pattrib->bswenc) + return; - return _SUCCESS; + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + rtw_wep_encrypt(padapter, pxmitframe); + break; + case _TKIP_: + rtw_tkip_encrypt(padapter, pxmitframe); + break; + case _AES_: + rtw_aes_encrypt(padapter, pxmitframe); + break; + default: + break; + } } s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) @@ -792,9 +774,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; - u8 qos_option = false; - - int res = _SUCCESS; + bool qos_option; __le16 *fctrl = &pwlanhdr->frame_control; struct sta_info *psta; @@ -810,106 +790,99 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr SetFrameSubType(fctrl, pattrib->subtype); - if (pattrib->subtype & IEEE80211_FTYPE_DATA) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - /* to_ds = 1, fr_ds = 0; */ - /* Data transfer to AP */ - SetToDs(fctrl); - memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); - - if (pqospriv->qos_option) - qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - /* to_ds = 0, fr_ds = 1; */ - SetFrDs(fctrl); - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); - - if (psta->qos_option) - qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - - if (psta->qos_option) - qos_option = true; - } else { - res = _FAIL; - goto exit; - } + if (!(pattrib->subtype & IEEE80211_FTYPE_DATA)) + return _SUCCESS; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + /* to_ds = 1, fr_ds = 0; */ + /* Data transfer to AP */ + SetToDs(fctrl); + memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); + qos_option = pqospriv->qos_option; + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* to_ds = 0, fr_ds = 1; */ + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); + qos_option = psta->qos_option; + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); + qos_option = psta->qos_option; + } else { + return _FAIL; + } - if (pattrib->mdata) - SetMData(fctrl); + if (pattrib->mdata) + SetMData(fctrl); - if (pattrib->encrypt) - SetPrivacy(fctrl); + if (pattrib->encrypt) + SetPrivacy(fctrl); - if (qos_option) { - qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); + if (qos_option) { + qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); - if (pattrib->priority) - SetPriority(qc, pattrib->priority); + if (pattrib->priority) + SetPriority(qc, pattrib->priority); - SetEOSP(qc, pattrib->eosp); + SetEOSP(qc, pattrib->eosp); - SetAckpolicy(qc, pattrib->ack_policy); - } + SetAckpolicy(qc, pattrib->ack_policy); + } - /* TODO: fill HT Control Field */ + /* TODO: fill HT Control Field */ - /* Update Seq Num will be handled by f/w */ - if (psta) { - psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; - psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; + /* Update Seq Num will be handled by f/w */ + if (psta) { + psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; - pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; - SetSeqNum(hdr, pattrib->seqnum); + SetSeqNum(hdr, pattrib->seqnum); - /* check if enable ampdu */ - if (pattrib->ht_en && psta->htpriv.ampdu_enable) { - if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) - pattrib->ampdu_en = true; - } + /* check if enable ampdu */ + if (pattrib->ht_en && psta->htpriv.ampdu_enable) { + 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) { - u16 tx_seq; + /* re-check if enable ampdu by BA_starting_seqctrl */ + if (pattrib->ampdu_en) { + u16 tx_seq; - tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; + tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; - /* check BA_starting_seqctrl */ - if (SN_LESS(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; + /* check BA_starting_seqctrl */ + if (SN_LESS(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 { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff; - pattrib->ampdu_en = true;/* AGG EN */ - } + pattrib->ampdu_en = true;/* AGG EN */ + } else { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff; + pattrib->ampdu_en = true;/* AGG EN */ } } } -exit: - return res; + return _SUCCESS; } s32 rtw_txframes_pending(struct adapter *padapter) { struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - return (!list_empty(&pxmitpriv->be_pending.queue) || - !list_empty(&pxmitpriv->bk_pending.queue) || - !list_empty(&pxmitpriv->vi_pending.queue) || - !list_empty(&pxmitpriv->vo_pending.queue)); + return (!list_empty(&pxmitpriv->be_pending) || + !list_empty(&pxmitpriv->bk_pending) || + !list_empty(&pxmitpriv->vi_pending) || + !list_empty(&pxmitpriv->vo_pending)); } s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib) @@ -1010,25 +983,23 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct /* adding icv, if necessary... */ if (pattrib->iv_len) { - if (psta) { - switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: - WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); - break; - case _TKIP_: - if (bmcst) - TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); - else - TKIP_IV(pattrib->iv, psta->dot11txpn, 0); - break; - case _AES_: - if (bmcst) - AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); - else - AES_IV(pattrib->iv, psta->dot11txpn, 0); - break; - } + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + break; + case _TKIP_: + if (bmcst) + TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + else + TKIP_IV(pattrib->iv, psta->dot11txpn, 0); + break; + case _AES_: + if (bmcst) + AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + else + AES_IV(pattrib->iv, psta->dot11txpn, 0); + break; } memcpy(pframe, pattrib->iv, pattrib->iv_len); @@ -1126,40 +1097,6 @@ s32 rtw_put_snap(u8 *data, u16 h_proto) return SNAP_SIZE + sizeof(u16); } -void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) -{ - uint protection; - u8 *perp; - int erp_len; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - - switch (pxmitpriv->vcs_setting) { - case DISABLE_VCS: - pxmitpriv->vcs = NONE_VCS; - break; - case ENABLE_VCS: - break; - case AUTO_VCS: - default: - perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); - if (!perp) { - pxmitpriv->vcs = NONE_VCS; - } else { - protection = (*(perp + 2)) & BIT(1); - if (protection) { - if (pregistrypriv->vcs_type == RTS_CTS) - pxmitpriv->vcs = RTS_CTS; - else - pxmitpriv->vcs = CTS_TO_SELF; - } else { - pxmitpriv->vcs = NONE_VCS; - } - } - break; - } -} - void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) { struct sta_info *psta = NULL; @@ -1319,38 +1256,32 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf spin_lock_bh(&pfree_xmit_queue->lock); - if (list_empty(&pfree_xmit_queue->queue)) { - pxframe = NULL; - } else { - phead = get_list_head(pfree_xmit_queue); - - plist = phead->next; - - pxframe = container_of(plist, struct xmit_frame, list); + if (list_empty(&pfree_xmit_queue->queue)) + goto out; - list_del_init(&pxframe->list); - } + phead = get_list_head(pfree_xmit_queue); + plist = phead->next; + pxframe = container_of(plist, struct xmit_frame, list); + list_del_init(&pxframe->list); - if (pxframe) { /* default value setting */ - pxmitpriv->free_xmitframe_cnt--; + pxmitpriv->free_xmitframe_cnt--; - pxframe->buf_addr = NULL; - pxframe->pxmitbuf = NULL; + pxframe->buf_addr = NULL; + pxframe->pxmitbuf = NULL; - memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); - /* pxframe->attrib.psta = NULL; */ + memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); + /* pxframe->attrib.psta = NULL; */ - pxframe->frame_tag = DATA_FRAMETAG; + pxframe->frame_tag = DATA_FRAMETAG; - pxframe->pkt = NULL; - pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */ + pxframe->pkt = NULL; + pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */ - pxframe->agg_num = 1; - pxframe->ack_report = 0; - } + pxframe->agg_num = 1; + pxframe->ack_report = 0; +out: spin_unlock_bh(&pfree_xmit_queue->lock); - return pxframe; } @@ -1386,101 +1317,49 @@ exit: return _SUCCESS; } -void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue) +void rtw_free_xmitframe_list(struct xmit_priv *pxmitpriv, struct list_head *xframe_list) { - struct list_head *plist, *phead; - struct xmit_frame *pxmitframe; - - spin_lock_bh(&pframequeue->lock); - - phead = get_list_head(pframequeue); - plist = phead->next; - - while (phead != plist) { - pxmitframe = container_of(plist, struct xmit_frame, list); - - plist = plist->next; + struct xmit_frame *pxmitframe, *tmp_xmitframe; + list_for_each_entry_safe(pxmitframe, tmp_xmitframe, xframe_list, list) rtw_free_xmitframe(pxmitpriv, pxmitframe); - } - spin_unlock_bh(&pframequeue->lock); -} - -s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) { -/* pxmitframe->pkt = NULL; */ - return _FAIL; - } - - return _SUCCESS; -} - -static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit, struct tx_servq *ptxservq, struct __queue *pframe_queue) -{ - struct list_head *xmitframe_plist, *xmitframe_phead; - struct xmit_frame *pxmitframe = NULL; - - xmitframe_phead = get_list_head(pframe_queue); - xmitframe_plist = xmitframe_phead->next; - - if (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - - list_del_init(&pxmitframe->list); - - ptxservq->qcnt--; - } - return pxmitframe; } -struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry) +struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i) { - struct list_head *sta_plist, *sta_phead; struct hw_xmit *phwxmit; - struct tx_servq *ptxservq = NULL; - struct __queue *pframe_queue = NULL; + struct tx_servq *ptxservq, *tmp_txservq; + struct list_head *xframe_list; struct xmit_frame *pxmitframe = NULL; struct adapter *padapter = pxmitpriv->adapter; struct registry_priv *pregpriv = &padapter->registrypriv; - int i, inx[4]; - - inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; + int i, inx[] = { 0, 1, 2, 3 }; if (pregpriv->wifi_spec == 1) { - int j; - - for (j = 0; j < 4; j++) - inx[j] = pxmitpriv->wmm_para_seq[j]; + for (i = 0; i < ARRAY_SIZE(inx); i++) + inx[i] = pxmitpriv->wmm_para_seq[i]; } spin_lock_bh(&pxmitpriv->lock); - for (i = 0; i < entry; i++) { + for (i = 0; i < HWXMIT_ENTRY; i++) { phwxmit = phwxmit_i + inx[i]; + list_for_each_entry_safe(ptxservq, tmp_txservq, phwxmit->sta_list, tx_pending) { + xframe_list = &ptxservq->sta_pending; + if (list_empty(xframe_list)) + continue; - sta_phead = get_list_head(phwxmit->sta_queue); - sta_plist = sta_phead->next; - - while (sta_phead != sta_plist) { - ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); - - pframe_queue = &ptxservq->sta_pending; + pxmitframe = container_of(xframe_list->next, struct xmit_frame, list); + list_del_init(&pxmitframe->list); - pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit, ptxservq, pframe_queue); + phwxmit->accnt--; + ptxservq->qcnt--; - if (pxmitframe) { - phwxmit->accnt--; + /* Remove sta node when there are no pending packets. */ + if (list_empty(xframe_list)) + list_del_init(&ptxservq->tx_pending); - /* Remove sta node when there are no pending packets. */ - if (list_empty(&pframe_queue->queue)) /* must be done after get_next and before break */ - list_del_init(&ptxservq->tx_pending); - goto exit; - } - - sta_plist = sta_plist->next; + goto exit; } } exit: @@ -1547,9 +1426,9 @@ 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(&ptxservq->tx_pending, phwxmits[ac_index].sta_list); - list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); + list_add_tail(&pxmitframe->list, &ptxservq->sta_pending); ptxservq->qcnt++; phwxmits[ac_index].accnt++; exit: @@ -1562,39 +1441,20 @@ int rtw_alloc_hwxmits(struct adapter *padapter) struct hw_xmit *hwxmits; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; - - pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL); + pxmitpriv->hwxmits = kcalloc(HWXMIT_ENTRY, sizeof(struct hw_xmit), GFP_KERNEL); if (!pxmitpriv->hwxmits) return -ENOMEM; hwxmits = pxmitpriv->hwxmits; - hwxmits[0].sta_queue = &pxmitpriv->vo_pending; - hwxmits[1].sta_queue = &pxmitpriv->vi_pending; - hwxmits[2].sta_queue = &pxmitpriv->be_pending; - hwxmits[3].sta_queue = &pxmitpriv->bk_pending; + hwxmits[0].sta_list = &pxmitpriv->vo_pending; + hwxmits[1].sta_list = &pxmitpriv->vi_pending; + hwxmits[2].sta_list = &pxmitpriv->be_pending; + hwxmits[3].sta_list = &pxmitpriv->bk_pending; return 0; } -void rtw_free_hwxmits(struct adapter *padapter) -{ - struct hw_xmit *hwxmits; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - hwxmits = pxmitpriv->hwxmits; - kfree(hwxmits); -} - -void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry) -{ - int i; - - for (i = 0; i < entry; i++, phwxmit++) - phwxmit->accnt = 0; -} - static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) { struct sk_buff *skb = *pskb; @@ -1743,15 +1603,6 @@ u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) return addr; } -static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib) -{ - u8 qsel; - - qsel = pattrib->priority; - - pattrib->qsel = qsel; -} - /* * The main transmit(tx) entry * @@ -1765,18 +1616,14 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = NULL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - void *br_port = NULL; s32 res; pxmitframe = rtw_alloc_xmitframe(pxmitpriv); if (!pxmitframe) return -1; - rcu_read_lock(); - br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); - rcu_read_unlock(); - - if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) { + if (rcu_access_pointer(padapter->pnetdev->rx_handler_data) && + check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) { res = rtw_br_client_tx(padapter, ppkt); if (res == -1) { rtw_free_xmitframe(pxmitpriv, pxmitframe); @@ -1794,7 +1641,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) rtw_led_control(padapter, LED_CTL_TX); - do_queue_select(padapter, &pxmitframe->attrib); + pxmitframe->attrib.qsel = pxmitframe->attrib.priority; spin_lock_bh(&pxmitpriv->lock); if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) { @@ -1911,16 +1758,15 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra return ret; } -static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue) +static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct list_head *phead) { - struct list_head *plist, *phead; + struct list_head *plist; u8 ac_index; struct tx_servq *ptxservq; struct pkt_attrib *pattrib; struct xmit_frame *pxmitframe; struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; - phead = get_list_head(pframequeue); plist = phead->next; while (phead != plist) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 8310d7f53982..788904d4655c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -193,9 +193,9 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) } -void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) +void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, u16 mstatus_rpt) { - u16 mst_rpt = le16_to_cpu(mstatus_rpt); + __le16 mst_rpt = cpu_to_le16(mstatus_rpt); FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt); } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index b7f3c7a670fb..f4edf4a8f5c2 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -315,21 +315,20 @@ rtl8188e_PHY_SetRFReg( * 08/12/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -s32 PHY_MACConfig8188E(struct adapter *Adapter) +int PHY_MACConfig8188E(struct adapter *Adapter) { struct hal_data_8188e *pHalData = &Adapter->haldata; - int rtStatus = _SUCCESS; + int err; /* */ /* Config MAC */ /* */ - if (ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv)) - rtStatus = _FAIL; + err = ODM_ReadAndConfig_MAC_REG_8188E(&pHalData->odmpriv); /* 2010.07.13 AMPDU aggregation number B */ rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); - return rtStatus; + return err; } /** @@ -450,13 +449,15 @@ static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) { struct eeprom_priv *pEEPROM = &Adapter->eeprompriv; struct hal_data_8188e *pHalData = &Adapter->haldata; + int err; /* */ /* 1. Read PHY_REG.TXT BB INIT!! */ /* We will separate as 88C / 92C according to chip version */ /* */ - if (ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv)) - return _FAIL; + err = ODM_ReadAndConfig_PHY_REG_1T_8188E(&pHalData->odmpriv); + if (err) + return err; /* 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ if (!pEEPROM->bautoload_fail_flag) { @@ -465,10 +466,11 @@ static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) } /* 3. BB AGC table Initialization */ - if (ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv)) - return _FAIL; + err = ODM_ReadAndConfig_AGC_TAB_1T_8188E(&pHalData->odmpriv); + if (err) + return err; - return _SUCCESS; + return 0; } int @@ -476,18 +478,17 @@ PHY_BBConfig8188E( struct adapter *Adapter ) { - int rtStatus = _SUCCESS; struct hal_data_8188e *pHalData = &Adapter->haldata; u16 RegVal; u8 CrystalCap; - int res; + int err; phy_InitBBRFRegisterDefinition(Adapter); /* Enable BB and RF */ - res = rtw_read16(Adapter, REG_SYS_FUNC_EN, &RegVal); - if (res) - return _FAIL; + err = rtw_read16(Adapter, REG_SYS_FUNC_EN, &RegVal); + if (err) + return err; rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal | BIT(13) | BIT(0) | BIT(1))); @@ -498,13 +499,13 @@ PHY_BBConfig8188E( rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); /* Config BB and AGC */ - rtStatus = phy_BB8188E_Config_ParaFile(Adapter); + err = phy_BB8188E_Config_ParaFile(Adapter); /* write 0x24[16:11] = 0x24[22:17] = CrystalCap */ CrystalCap = pHalData->CrystalCap & 0x3F; rtl8188e_PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6))); - return rtStatus; + return err; } static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index e5ec6e563fbd..1988fb6e780a 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -371,7 +371,7 @@ int phy_RF6052_Config_ParaFile(struct adapter *Adapter) struct bb_reg_def *pPhyReg; struct hal_data_8188e *pHalData = &Adapter->haldata; u32 u4RegValue = 0; - int rtStatus = _SUCCESS; + int err; /* Initialize RF */ @@ -396,11 +396,10 @@ int phy_RF6052_Config_ParaFile(struct adapter *Adapter) udelay(1);/* PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ - if (ODM_ReadAndConfig_RadioA_1T_8188E(&pHalData->odmpriv)) - rtStatus = _FAIL; + err = ODM_ReadAndConfig_RadioA_1T_8188E(&pHalData->odmpriv); /*----Restore RFENV control type----*/; rtl8188e_PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); - return rtStatus; + return err; } diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index 6d1f56d1f9d7..3ffab4953a5c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -9,16 +9,6 @@ #include "../include/usb_ops.h" #include "../include/rtl8188e_hal.h" -s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) -{ - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - - tasklet_init(&pxmitpriv->xmit_tasklet, - rtl8188eu_xmit_tasklet, - (unsigned long)adapt); - return _SUCCESS; -} - static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) { u16 *usptr = (u16 *)ptxdesc; @@ -147,7 +137,7 @@ static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) } } -static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagg_pkt) +static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz) { uint qsel; u8 data_rate, pwr_status, offset; @@ -329,7 +319,7 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) sz = pattrib->last_txcmdsz; } - pull = update_txdesc(pxmitframe, mem_addr, sz, false); + pull = update_txdesc(pxmitframe, mem_addr, sz); if (pull) { mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */ @@ -375,11 +365,13 @@ static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) return len; } -bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +bool rtl8188eu_xmitframe_complete(struct adapter *adapt) { + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt); struct xmit_frame *pxmitframe = NULL; struct xmit_frame *pfirstframe = NULL; + struct xmit_buf *pxmitbuf; /* aggregate variable */ struct hw_xmit *phwxmit; @@ -403,17 +395,11 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit else bulksize = USB_FULL_SPEED_BULK_SIZE; - /* check xmitbuffer is ok */ - if (!pxmitbuf) { - pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (!pxmitbuf) - return false; - } - - /* 3 1. pick up first frame */ - rtw_free_xmitframe(pxmitpriv, pxmitframe); + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (!pxmitbuf) + return false; - pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); + pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits); if (!pxmitframe) { /* no more xmit frame, release xmit buffer */ rtw_free_xmitbuf(pxmitpriv, pxmitbuf); @@ -475,7 +461,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit } spin_lock_bh(&pxmitpriv->lock); - xmitframe_phead = get_list_head(&ptxservq->sta_pending); + xmitframe_phead = &ptxservq->sta_pending; xmitframe_plist = xmitframe_phead->next; while (xmitframe_phead != xmitframe_plist) { @@ -503,7 +489,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit rtw_xmit_complete(adapt, pxmitframe); /* (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */ - update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz, true); + update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz); /* don't need xmitframe any more */ rtw_free_xmitframe(pxmitpriv, pxmitframe); @@ -526,7 +512,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit } } /* end while (aggregate same priority and same DA(AP or STA) frames) */ - if (list_empty(&ptxservq->sta_pending.queue)) + if (list_empty(&ptxservq->sta_pending)) list_del_init(&ptxservq->tx_pending); spin_unlock_bh(&pxmitpriv->lock); @@ -543,7 +529,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmit pfirstframe->pkt_offset--; } - update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz, true); + update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz); /* 3 4. write xmit buffer to USB FIFO */ ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe); @@ -610,7 +596,7 @@ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) return true; enqueue: - res = rtw_xmitframe_enqueue(adapt, pxmitframe); + res = rtw_xmit_classifier(adapt, pxmitframe); spin_unlock_bh(&pxmitpriv->lock); if (res != _SUCCESS) { diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index d28b4dc2a767..a1051ac1cac4 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -600,20 +600,17 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) Adapter->pwrctrlpriv.bFwCurrentInPSMode = false; haldata->LastHMEBoxNum = 0; - status = PHY_MACConfig8188E(Adapter); - if (status == _FAIL) - goto exit; + if (PHY_MACConfig8188E(Adapter)) + return _FAIL; /* */ /* d. Initialize BB related configurations. */ /* */ - status = PHY_BBConfig8188E(Adapter); - if (status == _FAIL) - goto exit; + if (PHY_BBConfig8188E(Adapter)) + return _FAIL; - status = phy_RF6052_Config_ParaFile(Adapter); - if (status == _FAIL) - goto exit; + if (phy_RF6052_Config_ParaFile(Adapter)) + return _FAIL; status = rtl8188e_iol_efuse_patch(Adapter); if (status == _FAIL) @@ -851,29 +848,25 @@ u32 rtl8188eu_hal_deinit(struct adapter *Adapter) return _SUCCESS; } -unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) +int rtl8188eu_inirp_init(struct adapter *Adapter) { u8 i; struct recv_buf *precvbuf; - uint status; struct recv_priv *precvpriv = &Adapter->recvpriv; - - status = _SUCCESS; + int ret; /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (!rtw_read_port(Adapter, (unsigned char *)precvbuf)) { - status = _FAIL; - goto exit; - } + ret = rtw_read_port(Adapter, precvbuf); + if (ret) + return ret; precvbuf++; precvpriv->free_recv_buf_queue_cnt--; } -exit: - return status; + return 0; } /* */ diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 7c72f5e04d9b..9611b19ab55b 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -7,9 +7,12 @@ #include "../include/usb_ops.h" #include "../include/rtl8188e_hal.h" -static int usb_read(struct intf_hdl *intf, u16 value, void *data, u8 size) +#define VENDOR_CMD_MAX_DATA_LEN 254 + +#define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */ + +static int usb_read(struct adapter *adapt, u16 value, void *data, u8 size) { - struct adapter *adapt = intf->padapter; struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); struct usb_device *udev = dvobjpriv->pusbdev; int status; @@ -50,9 +53,8 @@ static int usb_read(struct intf_hdl *intf, u16 value, void *data, u8 size) return status; } -static int usb_write(struct intf_hdl *intf, u16 value, void *data, u8 size) +static int usb_write(struct adapter *adapt, u16 value, void *data, u8 size) { - struct adapter *adapt = intf->padapter; struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); struct usb_device *udev = dvobjpriv->pusbdev; int status; @@ -95,22 +97,18 @@ static int usb_write(struct intf_hdl *intf, u16 value, void *data, u8 size) int __must_check rtw_read8(struct adapter *adapter, u32 addr, u8 *data) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; - return usb_read(intf, value, data, 1); + return usb_read(adapter, value, data, 1); } int __must_check rtw_read16(struct adapter *adapter, u32 addr, u16 *data) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; __le16 le_data; int res; - res = usb_read(intf, value, &le_data, 2); + res = usb_read(adapter, value, &le_data, 2); if (res) return res; @@ -121,13 +119,11 @@ int __must_check rtw_read16(struct adapter *adapter, u32 addr, u16 *data) int __must_check rtw_read32(struct adapter *adapter, u32 addr, u32 *data) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; __le32 le_data; int res; - res = usb_read(intf, value, &le_data, 4); + res = usb_read(adapter, value, &le_data, 4); if (res) return res; @@ -138,55 +134,44 @@ int __must_check rtw_read32(struct adapter *adapter, u32 addr, u32 *data) int rtw_write8(struct adapter *adapter, u32 addr, u8 val) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; int ret; - ret = usb_write(intf, value, &val, 1); + ret = usb_write(adapter, value, &val, 1); return RTW_STATUS_CODE(ret); } int rtw_write16(struct adapter *adapter, u32 addr, u16 val) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; __le16 data = cpu_to_le16(val); int ret; - ret = usb_write(intf, value, &data, 2); + ret = usb_write(adapter, value, &data, 2); return RTW_STATUS_CODE(ret); } int rtw_write32(struct adapter *adapter, u32 addr, u32 val) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; __le32 data = cpu_to_le32(val); int ret; - ret = usb_write(intf, value, &data, 4); + ret = usb_write(adapter, value, &data, 4); return RTW_STATUS_CODE(ret); } int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *data) { - struct io_priv *io_priv = &adapter->iopriv; - struct intf_hdl *intf = &io_priv->intf; u16 value = addr & 0xffff; - int ret; if (length > VENDOR_CMD_MAX_DATA_LEN) - return _FAIL; + return -EINVAL; - ret = usb_write(intf, value, data, length); - - return RTW_STATUS_CODE(ret); + return usb_write(adapter, value, data, length); } static void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) @@ -363,7 +348,7 @@ void rtl8188eu_recv_tasklet(unsigned long priv) } } -static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) +static void usb_read_port_complete(struct urb *purb) { struct recv_buf *precvbuf = (struct recv_buf *)purb->context; struct adapter *adapt = (struct adapter *)precvbuf->adapter; @@ -379,7 +364,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) if (purb->status == 0) { /* SUCCESS */ if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { precvbuf->reuse = true; - rtw_read_port(adapt, (unsigned char *)precvbuf); + rtw_read_port(adapt, precvbuf); } else { rtw_reset_continual_urb_error(adapter_to_dvobj(adapt)); @@ -391,7 +376,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) precvbuf->pskb = NULL; precvbuf->reuse = false; - rtw_read_port(adapt, (unsigned char *)precvbuf); + rtw_read_port(adapt, precvbuf); } } else { skb_put(precvbuf->pskb, purb->actual_length); @@ -411,7 +396,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) case -EPROTO: case -EOVERFLOW: precvbuf->reuse = true; - rtw_read_port(adapt, (unsigned char *)precvbuf); + rtw_read_port(adapt, precvbuf); break; case -EINPROGRESS: break; @@ -421,10 +406,9 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) } } -u32 rtw_read_port(struct adapter *adapter, u8 *rmem) +int rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf) { struct urb *purb = NULL; - struct recv_buf *precvbuf = (struct recv_buf *)rmem; struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); struct recv_priv *precvpriv = &adapter->recvpriv; struct usb_device *pusbd = pdvobj->pusbdev; @@ -432,13 +416,12 @@ u32 rtw_read_port(struct adapter *adapter, u8 *rmem) unsigned int pipe; size_t tmpaddr = 0; size_t alignment = 0; - u32 ret = _SUCCESS; if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - return _FAIL; + return -EPERM; if (!precvbuf) - return _FAIL; + return -ENOMEM; if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); @@ -450,7 +433,7 @@ u32 rtw_read_port(struct adapter *adapter, u8 *rmem) if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); if (!precvbuf->pskb) - return _FAIL; + return -ENOMEM; tmpaddr = (size_t)precvbuf->pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); @@ -474,29 +457,20 @@ u32 rtw_read_port(struct adapter *adapter, u8 *rmem) err = usb_submit_urb(purb, GFP_ATOMIC); if ((err) && (err != (-EPERM))) - ret = _FAIL; + return err; - return ret; + return 0; } void rtl8188eu_xmit_tasklet(unsigned long priv) { - int ret = false; struct adapter *adapt = (struct adapter *)priv; - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) return; - while (1) { - if ((adapt->bDriverStopped) || - (adapt->bSurpriseRemoved) || - (adapt->bWritePortCancel)) - break; - - ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL); - - if (!ret) + do { + if (adapt->bDriverStopped || adapt->bSurpriseRemoved || adapt->bWritePortCancel) break; - } + } while (rtl8188eu_xmitframe_complete(adapt)); } diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index 8fef5759c36a..159990facb8a 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -152,7 +152,6 @@ struct adapter { struct mlme_ext_priv mlmeextpriv; struct cmd_priv cmdpriv; struct evt_priv evtpriv; - struct io_priv iopriv; struct xmit_priv xmitpriv; struct recv_priv recvpriv; struct sta_priv stapriv; @@ -172,8 +171,6 @@ struct adapter { s8 signal_strength; void *cmdThread; - void (*intf_start)(struct adapter *adapter); - void (*intf_stop)(struct adapter *adapter); struct net_device *pnetdev; /* used by rtw_rereg_nd_name related function */ @@ -187,7 +184,6 @@ struct adapter { int bup; struct net_device_stats stats; struct iw_statistics iwstats; - struct proc_dir_entry *dir_dev;/* for proc directory */ int net_closed; u8 bFWReady; diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index ac6e3f95c5b7..296aa5b8268d 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -26,7 +26,7 @@ void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level); int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt); -unsigned int rtl8188eu_inirp_init(struct adapter *Adapter); +int rtl8188eu_inirp_init(struct adapter *Adapter); uint rtw_hal_init(struct adapter *padapter); uint rtw_hal_deinit(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h index 6d66cb57225e..457fb3852a19 100644 --- a/drivers/staging/r8188eu/include/osdep_intf.h +++ b/drivers/staging/r8188eu/include/osdep_intf.h @@ -7,38 +7,6 @@ #include "osdep_service.h" #include "drv_types.h" -struct intf_priv { - u8 *intf_dev; - u32 max_iosz; /* USB2.0: 128, USB1.1: 64, SDIO:64 */ - u32 max_xmitsz; /* USB2.0: unlimited, SDIO:512 */ - u32 max_recvsz; /* USB2.0: unlimited, SDIO:512 */ - - u8 *io_rwmem; - u8 *allocated_io_rwmem; - u32 io_wsz; /* unit: 4bytes */ - u32 io_rsz;/* unit: 4bytes */ - u8 intf_status; - - void (*_bus_io)(u8 *priv); - -/* -Under Sync. IRP (SDIO/USB) -A protection mechanism is necessary for the io_rwmem(read/write protocol) - -Under Async. IRP (SDIO/USB) -The protection mechanism is through the pending queue. -*/ - struct mutex ioctl_mutex; - /* when in USB, IO is through interrupt in/out endpoints */ - struct usb_device *udev; - struct urb *piorw_urb; - u8 io_irp_cnt; - u8 bio_irp_pending; - struct timer_list io_timer; - u8 bio_irp_timeout; - u8 bio_timer_cancel; -}; - int netdev_open(struct net_device *pnetdev); int netdev_close(struct net_device *pnetdev); diff --git a/drivers/staging/r8188eu/include/rtl8188e_cmd.h b/drivers/staging/r8188eu/include/rtl8188e_cmd.h index 1e01c1662f9a..c785cf8ed683 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_cmd.h +++ b/drivers/staging/r8188eu/include/rtl8188e_cmd.h @@ -85,6 +85,6 @@ void rtl8188e_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 arg, void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state); void CheckFwRsvdPageContent(struct adapter *adapt); -void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt); +void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, u16 mstatus_rpt); #endif/* __RTL8188E_CMD_H__ */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h index 3fa3b3e5dd64..25b31417cd58 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h @@ -510,28 +510,7 @@ Default: 00b. /* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ #define BW_OPMODE_20MHZ BIT(2) -/* 8192C CAM Config Setting (offset 0x250, 1 byte) */ -#define CAM_VALID BIT(15) -#define CAM_NOTVALID 0x0000 -#define CAM_USEDK BIT(5) - -#define CAM_CONTENT_COUNT 8 - -#define CAM_NONE 0x0 -#define CAM_WEP40 0x01 -#define CAM_TKIP 0x02 -#define CAM_AES 0x04 -#define CAM_WEP104 0x05 -#define CAM_SMS4 0x6 - -#define TOTAL_CAM_ENTRY 32 -#define HALF_CAM_ENTRY 16 - -#define CAM_CONFIG_USEDK true -#define CAM_CONFIG_NO_USEDK false - #define CAM_WRITE BIT(16) -#define CAM_READ 0x00000000 #define CAM_POLLINIG BIT(31) #define SCR_UseDK 0x01 diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index 6db7fabebea9..a023dd792da7 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -5,17 +5,7 @@ #define __RTL8188E_XMIT_H__ #define MAX_TX_AGG_PACKET_NUMBER 0xFF -/* */ -/* Queue Select Value in TxDesc */ -/* */ -#define QSLT_BK 0x2/* 0x01 */ -#define QSLT_BE 0x0 -#define QSLT_VI 0x5/* 0x4 */ -#define QSLT_VO 0x7/* 0x6 */ -#define QSLT_BEACON 0x10 -#define QSLT_HIGH 0x11 #define QSLT_MGNT 0x12 -#define QSLT_CMD 0x13 /* For 88e early mode */ #define SET_EARLYMODE_PKTNUM(__paddr, __value) \ @@ -131,14 +121,10 @@ struct txrpt_ccx_88e { void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); -s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); -#define hal_xmit_handler rtl8188eu_xmit_buf_handler void rtl8188eu_xmit_tasklet(unsigned long priv); -bool rtl8188eu_xmitframe_complete(struct adapter *padapter, - struct xmit_priv *pxmitpriv, - struct xmit_buf *pxmitbuf); +bool rtl8188eu_xmitframe_complete(struct adapter *padapter); #endif /* __RTL8188E_XMIT_H__ */ diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h index c330a4435b31..e8eecd52d1d8 100644 --- a/drivers/staging/r8188eu/include/rtw_cmd.h +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -32,7 +32,6 @@ struct cmd_priv { struct completion start_cmd_thread; struct completion stop_cmd_thread; struct __queue cmd_queue; - u8 cmd_seq; u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ u8 *cmd_allocated_buf; u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ @@ -744,7 +743,7 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 minRptTime); u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue); u8 rtw_ps_cmd(struct adapter *padapter); -u8 rtw_chk_hi_queue_cmd(struct adapter *padapter); +void rtw_chk_hi_queue_cmd(struct adapter *padapter); u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan); diff --git a/drivers/staging/r8188eu/include/rtw_io.h b/drivers/staging/r8188eu/include/rtw_io.h index e9744694204b..e1718f739cc9 100644 --- a/drivers/staging/r8188eu/include/rtw_io.h +++ b/drivers/staging/r8188eu/include/rtw_io.h @@ -16,215 +16,10 @@ #include <linux/usb.h> #include <linux/usb/ch9.h> -#define rtw_usb_buffer_alloc(dev, size, dma) \ - usb_alloc_coherent((dev), (size), (in_interrupt() ? \ - GFP_ATOMIC : GFP_KERNEL), (dma)) -#define rtw_usb_buffer_free(dev, size, addr, dma) \ - usb_free_coherent((dev), (size), (addr), (dma)) - -#define NUM_IOREQ 8 - -#define MAX_PROT_SZ (64-16) - -#define _IOREADY 0 -#define _IO_WAIT_COMPLETE 1 -#define _IO_WAIT_RSP 2 - -/* IO COMMAND TYPE */ -#define _IOSZ_MASK_ (0x7F) -#define _IO_WRITE_ BIT(7) -#define _IO_FIXED_ BIT(8) -#define _IO_BURST_ BIT(9) -#define _IO_BYTE_ BIT(10) -#define _IO_HW_ BIT(11) -#define _IO_WORD_ BIT(12) -#define _IO_SYNC_ BIT(13) -#define _IO_CMDMASK_ (0x1F80) - -/* - For prompt mode accessing, caller shall free io_req - Otherwise, io_handler will free io_req -*/ - -/* IO STATUS TYPE */ -#define _IO_ERR_ BIT(2) -#define _IO_SUCCESS_ BIT(1) -#define _IO_DONE_ BIT(0) - -#define IO_RD32 (_IO_SYNC_ | _IO_WORD_) -#define IO_RD16 (_IO_SYNC_ | _IO_HW_) -#define IO_RD8 (_IO_SYNC_ | _IO_BYTE_) - -#define IO_RD32_ASYNC (_IO_WORD_) -#define IO_RD16_ASYNC (_IO_HW_) -#define IO_RD8_ASYNC (_IO_BYTE_) - -#define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_) -#define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_) -#define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_) - -#define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_) -#define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_) -#define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_) - -/* - Only Sync. burst accessing is provided. -*/ - -#define IO_WR_BURST(x) \ - (_IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_)) -#define IO_RD_BURST(x) \ - (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_)) - -/* below is for the intf_option bit defition... */ - -#define _INTF_ASYNC_ BIT(0) /* support async io */ - -struct intf_priv; -struct intf_hdl; -struct io_queue; - -struct io_req { - struct list_head list; - u32 addr; - u32 val; - u32 command; - u32 status; - u8 *pbuf; - struct semaphore sema; - - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, u8 *cnxt); - u8 *cnxt; -}; - -struct intf_hdl { - struct adapter *padapter; - struct dvobj_priv *pintf_dev; -}; - -struct reg_protocol_rd { -#ifdef __LITTLE_ENDIAN - /* DW1 */ - u32 NumOfTrans:4; - u32 Reserved1:4; - u32 Reserved2:24; - /* DW2 */ - u32 ByteCount:7; - u32 WriteEnable:1; /* 0:read, 1:write */ - u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */ - u32 BurstMode:1; - u32 Byte1Access:1; - u32 Byte2Access:1; - u32 Byte4Access:1; - u32 Reserved3:3; - u32 Reserved4:16; - /* DW3 */ - u32 BusAddress; - /* DW4 */ - /* u32 Value; */ -#else -/* DW1 */ - u32 Reserved1:4; - u32 NumOfTrans:4; - u32 Reserved2:24; - /* DW2 */ - u32 WriteEnable:1; - u32 ByteCount:7; - u32 Reserved3:3; - u32 Byte4Access:1; - - u32 Byte2Access:1; - u32 Byte1Access:1; - u32 BurstMode:1; - u32 FixOrContinuous:1; - u32 Reserved4:16; - /* DW3 */ - u32 BusAddress; - - /* DW4 */ -#endif -}; - -struct reg_protocol_wt { -#ifdef __LITTLE_ENDIAN - /* DW1 */ - u32 NumOfTrans:4; - u32 Reserved1:4; - u32 Reserved2:24; - /* DW2 */ - u32 ByteCount:7; - u32 WriteEnable:1; /* 0:read, 1:write */ - u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */ - u32 BurstMode:1; - u32 Byte1Access:1; - u32 Byte2Access:1; - u32 Byte4Access:1; - u32 Reserved3:3; - u32 Reserved4:16; - /* DW3 */ - u32 BusAddress; - /* DW4 */ - u32 Value; -#else - /* DW1 */ - u32 Reserved1 :4; - u32 NumOfTrans:4; - u32 Reserved2:24; - /* DW2 */ - u32 WriteEnable:1; - u32 ByteCount:7; - u32 Reserved3:3; - u32 Byte4Access:1; - u32 Byte2Access:1; - u32 Byte1Access:1; - u32 BurstMode:1; - u32 FixOrContinuous:1; - u32 Reserved4:16; - /* DW3 */ - u32 BusAddress; - /* DW4 */ - u32 Value; -#endif -}; - -/* -Below is the data structure used by _io_handler -*/ - -struct io_queue { - spinlock_t lock; - struct list_head free_ioreqs; - struct list_head pending; /* The io_req list that will be served - * in the single protocol read/write.*/ - struct list_head processing; - u8 *free_ioreqs_buf; /* 4-byte aligned */ - u8 *pallocated_free_ioreqs_buf; - struct intf_hdl intf; -}; - -struct io_priv { - struct adapter *padapter; - struct intf_hdl intf; -}; - -uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); -void sync_ioreq_enqueue(struct io_req *preq, struct io_queue *ioqueue); -uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); -uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue); -struct io_req *alloc_ioreq(struct io_queue *pio_q); - -uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); -void unregister_intf_hdl(struct intf_hdl *pintfhdl); - -void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - int __must_check rtw_read8(struct adapter *adapter, u32 addr, u8 *data); int __must_check rtw_read16(struct adapter *adapter, u32 addr, u16 *data); int __must_check rtw_read32(struct adapter *adapter, u32 addr, u32 *data); -void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -u32 rtw_read_port(struct adapter *adapter, u8 *pmem); +int rtw_read_port(struct adapter *adapter, struct recv_buf *precvbuf); void rtw_read_port_cancel(struct adapter *adapter); int rtw_write8(struct adapter *adapter, u32 addr, u8 val); @@ -232,57 +27,7 @@ int rtw_write16(struct adapter *adapter, u32 addr, u16 val); int rtw_write32(struct adapter *adapter, u32 addr, u32 val); int rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata); -void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); u32 rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); void rtw_write_port_cancel(struct adapter *adapter); -void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem); - -/* ioreq */ -void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval); -void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval); -void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval); -void ioreq_write8(struct adapter *adapter, u32 addr, u8 val); -void ioreq_write16(struct adapter *adapter, u32 addr, u16 val); -void ioreq_write32(struct adapter *adapter, u32 addr, u32 val); - -uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff, - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, - u8 *cnxt), u8 *cnxt); -uint async_read16(struct adapter *adapter, u32 addr, u8 *pbuff, - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, - u8 *cnxt), u8 *cnxt); -uint async_read32(struct adapter *adapter, u32 addr, u8 *pbuff, - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, - u8 *cnxt), u8 *cnxt); - -void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - -void async_write8(struct adapter *adapter, u32 addr, u8 val, - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, - u8 *cnxt), u8 *cnxt); -void async_write16(struct adapter *adapter, u32 addr, u16 val, - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, - u8 *cnxt), u8 *cnxt); -void async_write32(struct adapter *adapter, u32 addr, u32 val, - void (*_async_io_callback)(struct adapter *padater, - struct io_req *pio_req, - u8 *cnxt), u8 *cnxt); - -void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); -void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); - -uint alloc_io_queue(struct adapter *adapter); -void free_io_queue(struct adapter *adapter); -void async_bus_io(struct io_queue *pio_q); -void bus_sync_io(struct io_queue *pio_q); -u32 _ioreq2rwmem(struct io_queue *pio_q); -void dev_power_down(struct adapter *Adapter, u8 bpwrup); - #endif /* _RTL8711_IO_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h index 6e9fdd66fad1..9f5cffd8bfb1 100644 --- a/drivers/staging/r8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h @@ -71,7 +71,6 @@ struct pwrctrl_priv { int pwr_state_check_interval; enum rt_rf_power_state rf_pwrstate;/* cur power state */ - enum rt_rf_power_state change_rfpwrstate; u8 bkeepfwalive; }; @@ -99,8 +98,6 @@ void rtw_set_firmware_ps_mode(struct adapter *adapter, u8 mode); void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode); void LeaveAllPowerSaveMode(struct adapter *adapter); -void ips_enter(struct adapter *padapter); -int ips_leave(struct adapter *padapter); void rtw_ps_processor(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h index 6e7ebea5362d..feeac85aedb0 100644 --- a/drivers/staging/r8188eu/include/rtw_xmit.h +++ b/drivers/staging/r8188eu/include/rtw_xmit.h @@ -97,7 +97,7 @@ union txdesc { }; struct hw_xmit { - struct __queue *sta_queue; + struct list_head *sta_list; int accnt; }; @@ -152,14 +152,7 @@ struct pkt_attrib { #define NULL_FRAMETAG (0x0) #define DATA_FRAMETAG 0x01 -#define L2_FRAMETAG 0x02 #define MGNT_FRAMETAG 0x03 -#define AMSDU_FRAMETAG 0x04 - -#define EII_FRAMETAG 0x05 -#define IEEE8023_FRAMETAG 0x06 - -#define MP_FRAMETAG 0x07 #define TXAGG_FRAMETAG 0x08 @@ -196,14 +189,11 @@ struct xmit_buf { u8 *pbuf; void *priv_data; u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ - u16 flags; + bool high_queue; u32 alloc_sz; u32 len; struct submit_ctx *sctx; - u32 ff_hwaddr; struct urb *pxmit_urb; - dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ - u8 bpending[8]; int last[8]; }; @@ -223,21 +213,16 @@ struct xmit_frame { struct tx_servq { struct list_head tx_pending; - struct __queue sta_pending; + struct list_head sta_pending; int qcnt; }; struct sta_xmit_priv { spinlock_t lock; - int option; - int apsd_setting; /* When bit mask is on, the associated edca - * queue supports APSD. */ struct tx_servq be_q; /* priority == 0,3 */ struct tx_servq bk_q; /* priority == 1,2 */ struct tx_servq vi_q; /* priority == 4,5 */ struct tx_servq vo_q; /* priority == 6,7 */ - struct list_head legacy_dz; - struct list_head apsd; u16 txseq_tid[16]; }; @@ -252,46 +237,28 @@ struct hw_txqueue { int ac_tag; }; -struct agg_pkt_info { - u16 offset; - u16 pkt_len; -}; - struct xmit_priv { spinlock_t lock; - struct semaphore terminate_xmitthread_sema; - struct __queue be_pending; - struct __queue bk_pending; - struct __queue vi_pending; - struct __queue vo_pending; - struct __queue bm_pending; + struct list_head be_pending; + struct list_head bk_pending; + struct list_head vi_pending; + struct list_head vo_pending; u8 *pallocated_frame_buf; u8 *pxmit_frame_buf; uint free_xmitframe_cnt; struct __queue free_xmit_queue; uint frag_len; struct adapter *adapter; - u8 vcs_setting; - u8 vcs; - u8 vcs_type; u64 tx_bytes; u64 tx_pkts; u64 tx_drop; u64 last_tx_bytes; u64 last_tx_pkts; struct hw_xmit *hwxmits; - u8 hwxmit_entry; u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength * from large to small. it's value is 0->vo, * 1->vi, 2->be, 3->bk. */ - struct semaphore tx_retevt;/* all tx return event; */ - u8 txirp_cnt;/* */ struct tasklet_struct xmit_tasklet; - /* per AC pending irp */ - int beq_cnt; - int bkq_cnt; - int viq_cnt; - int voq_cnt; struct __queue free_xmitbuf_queue; struct __queue pending_xmitbuf_queue; u8 *pallocated_xmitbuf; @@ -324,7 +291,6 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz); -void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len); s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib); s32 rtw_put_snap(u8 *data, u16 h_proto); @@ -332,14 +298,11 @@ s32 rtw_put_snap(u8 *data, u16 h_proto); struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv); s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe); -void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, - struct __queue *pframequeue); +void rtw_free_xmitframe_list(struct xmit_priv *pxmitpriv, struct list_head *xframe_list); struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, int up, u8 *ac); -s32 rtw_xmitframe_enqueue(struct adapter *padapter, - struct xmit_frame *pxmitframe); struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, - struct hw_xmit *phwxmit_i, int entry); + struct hw_xmit *phwxmit_i); s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe); @@ -350,11 +313,9 @@ void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv); s32 rtw_txframes_pending(struct adapter *padapter); s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib); -void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); int _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); int rtw_alloc_hwxmits(struct adapter *padapter); -void rtw_free_hwxmits(struct adapter *padapter); s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe); diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index ddc46cb44358..5bd8ce37aebf 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -17,8 +17,6 @@ #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) -#include "usb_ops_linux.h" - /* * Increase and check if the continual_urb_error of this @param dvobjprivei * is larger than MAX_CONTINUAL_URB_ERR diff --git a/drivers/staging/r8188eu/include/usb_ops_linux.h b/drivers/staging/r8188eu/include/usb_ops_linux.h deleted file mode 100644 index 966688eedf66..000000000000 --- a/drivers/staging/r8188eu/include/usb_ops_linux.h +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __USB_OPS_LINUX_H__ -#define __USB_OPS_LINUX_H__ - -#define VENDOR_CMD_MAX_DATA_LEN 254 - -#define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */ -#define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */ - -#define MAX_USBCTRL_VENDORREQ_TIMES 10 - -#define RTW_USB_BULKOUT_TIME 5000/* ms */ - -#define _usbctrl_vendorreq_async_callback(urb, regs) \ - _usbctrl_vendorreq_async_callback(urb) -#define usb_bulkout_zero_complete(purb, regs) \ - usb_bulkout_zero_complete(purb) -#define usb_write_mem_complete(purb, regs) \ - usb_write_mem_complete(purb) -#define usb_write_port_complete(purb, regs) \ - usb_write_port_complete(purb) -#define usb_read_port_complete(purb, regs) \ - usb_read_port_complete(purb) -#define usb_read_interrupt_complete(purb, regs) \ - usb_read_interrupt_complete(purb) - -#endif diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 8e9b7b0664bc..e0a819970546 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -3061,8 +3061,7 @@ static int rtw_rereg_nd_name(struct net_device *dev, char *reg_ifname; reg_ifname = padapter->registrypriv.if2name; - strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ - 1] = 0; + strscpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); } if (wrqu->data.length > IFNAMSIZ) @@ -3084,8 +3083,7 @@ static int rtw_rereg_nd_name(struct net_device *dev, rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); } - strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ - 1] = 0; + strscpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); if (!memcmp(new_ifname, "disable%d", 9)) { /* free network queue for Android's timming issue */ diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 2f59bb994796..dc419fd1ffa5 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -392,9 +392,6 @@ static void rtw_init_default_value(struct adapter *padapter) struct security_priv *psecuritypriv = &padapter->securitypriv; /* xmit_priv */ - pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; - pxmitpriv->vcs = pregistrypriv->vcs_type; - pxmitpriv->vcs_type = pregistrypriv->vcs_type; pxmitpriv->frag_len = pregistrypriv->frag_thresh; /* mlme_priv */ @@ -485,7 +482,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter) goto free_mlme_ext; } - if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) { + if (_rtw_init_recv_priv(&padapter->recvpriv, padapter)) { dev_err(dvobj_to_dev(padapter->dvobj), "_rtw_init_recv_priv failed\n"); goto free_xmit_priv; } @@ -634,8 +631,8 @@ static int _netdev_open(struct net_device *pnetdev) pr_info("can't init mlme_ext_priv\n"); goto netdev_open_error; } - if (padapter->intf_start) - padapter->intf_start(padapter); + if (rtl8188eu_inirp_init(padapter)) + goto netdev_open_error; rtw_led_control(padapter, LED_CTL_NO_LINK); @@ -687,8 +684,8 @@ static int ips_netdrv_open(struct adapter *padapter) if (status == _FAIL) goto netdev_open_error; - if (padapter->intf_start) - padapter->intf_start(padapter); + if (rtl8188eu_inirp_init(padapter)) + goto netdev_open_error; rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000); @@ -764,8 +761,8 @@ void rtw_ips_dev_unload(struct adapter *padapter) { rtw_fifo_cleanup(padapter); - if (padapter->intf_stop) - padapter->intf_stop(padapter); + rtw_read_port_cancel(padapter); + rtw_write_port_cancel(padapter); /* s5. */ if (!padapter->bSurpriseRemoved) diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 5fbfbcd95de2..74a16d1757ce 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -152,22 +152,6 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) } -static void usb_intf_start(struct adapter *padapter) -{ - rtl8188eu_inirp_init(padapter); -} - -static void usb_intf_stop(struct adapter *padapter) -{ - /* cancel in irp */ - rtw_read_port_cancel(padapter); - - /* cancel out irp */ - rtw_write_port_cancel(padapter); - - /* todo:cancel other irps */ -} - static void rtw_dev_unload(struct adapter *padapter) { if (padapter->bup) { @@ -175,8 +159,9 @@ static void rtw_dev_unload(struct adapter *padapter) if (padapter->xmitpriv.ack_tx) rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP); /* s3. */ - if (padapter->intf_stop) - padapter->intf_stop(padapter); + rtw_read_port_cancel(padapter); + rtw_write_port_cancel(padapter); + /* s4. */ rtw_stop_drv_threads(padapter); @@ -290,8 +275,6 @@ static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusb { struct adapter *padapter = NULL; struct net_device *pnetdev = NULL; - struct io_priv *piopriv; - struct intf_hdl *pintf; int ret; padapter = vzalloc(sizeof(*padapter)); @@ -315,16 +298,6 @@ static int rtw_usb_if1_init(struct dvobj_priv *dvobj, struct usb_interface *pusb SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); padapter = rtw_netdev_priv(pnetdev); - padapter->intf_start = &usb_intf_start; - padapter->intf_stop = &usb_intf_stop; - - /* step init_io_priv */ - piopriv = &padapter->iopriv; - pintf = &piopriv->intf; - piopriv->padapter = padapter; - pintf->padapter = padapter; - pintf->pintf_dev = adapter_to_dvobj(padapter); - /* step read_chip_version */ rtl8188e_read_chip_version(padapter); diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c index 220e592b757c..ca09f7ed7e4d 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -4,7 +4,6 @@ #define _USB_OPS_LINUX_C_ #include "../include/drv_types.h" -#include "../include/usb_ops_linux.h" #include "../include/rtl8188e_recv.h" static unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) @@ -29,68 +28,40 @@ void rtw_read_port_cancel(struct adapter *padapter) for (i = 0; i < NR_RECVBUFF; i++) { precvbuf->reuse = true; - if (precvbuf->purb) - usb_kill_urb(precvbuf->purb); + usb_kill_urb(precvbuf->purb); precvbuf++; } } -static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) +static void usb_write_port_complete(struct urb *purb) { struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; - struct adapter *padapter = pxmitbuf->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct adapter *padapter = pxmitbuf->padapter; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - switch (pxmitbuf->flags) { - case VO_QUEUE_INX: - pxmitpriv->voq_cnt--; - break; - case VI_QUEUE_INX: - pxmitpriv->viq_cnt--; - break; - case BE_QUEUE_INX: - pxmitpriv->beq_cnt--; - break; - case BK_QUEUE_INX: - pxmitpriv->bkq_cnt--; - break; - case HIGH_QUEUE_INX: + if (pxmitbuf->high_queue) rtw_chk_hi_queue_cmd(padapter); + + switch (purb->status) { + case 0: + case -EINPROGRESS: + case -ENOENT: + case -ECONNRESET: + case -EPIPE: + case -EPROTO: + break; + case -ESHUTDOWN: + padapter->bDriverStopped = true; break; default: + padapter->bSurpriseRemoved = true; break; } - if (padapter->bSurpriseRemoved || padapter->bDriverStopped || - padapter->bWritePortCancel) - goto check_completion; - - if (purb->status) { - if (purb->status == -EINPROGRESS) { - goto check_completion; - } else if (purb->status == -ENOENT) { - goto check_completion; - } else if (purb->status == -ECONNRESET) { - goto check_completion; - } else if (purb->status == -ESHUTDOWN) { - padapter->bDriverStopped = true; - goto check_completion; - } else if ((purb->status != -EPIPE) && (purb->status != -EPROTO)) { - padapter->bSurpriseRemoved = true; - - goto check_completion; - } - } - -check_completion: rtw_sctx_done_err(&pxmitbuf->sctx, - purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : - RTW_SCTX_DONE_SUCCESS); - + purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); rtw_free_xmitbuf(pxmitpriv, pxmitbuf); - tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - } u32 rtw_write_port(struct adapter *padapter, u32 addr, u32 cnt, u8 *wmem) @@ -112,32 +83,7 @@ u32 rtw_write_port(struct adapter *padapter, u32 addr, u32 cnt, u8 *wmem) } spin_lock_irqsave(&pxmitpriv->lock, irqL); - - switch (addr) { - case VO_QUEUE_INX: - pxmitpriv->voq_cnt++; - pxmitbuf->flags = VO_QUEUE_INX; - break; - case VI_QUEUE_INX: - pxmitpriv->viq_cnt++; - pxmitbuf->flags = VI_QUEUE_INX; - break; - case BE_QUEUE_INX: - pxmitpriv->beq_cnt++; - pxmitbuf->flags = BE_QUEUE_INX; - break; - case BK_QUEUE_INX: - pxmitpriv->bkq_cnt++; - pxmitbuf->flags = BK_QUEUE_INX; - break; - case HIGH_QUEUE_INX: - pxmitbuf->flags = HIGH_QUEUE_INX; - break; - default: - pxmitbuf->flags = MGT_QUEUE_INX; - break; - } - + pxmitbuf->high_queue = (addr == HIGH_QUEUE_INX); spin_unlock_irqrestore(&pxmitpriv->lock, irqL); purb = pxmitbuf->pxmit_urb; @@ -154,14 +100,8 @@ u32 rtw_write_port(struct adapter *padapter, u32 addr, u32 cnt, u8 *wmem) status = usb_submit_urb(purb, GFP_ATOMIC); if (status) { rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); - - switch (status) { - case -ENODEV: + if (status == -ENODEV) padapter->bDriverStopped = true; - break; - default: - break; - } goto exit; } @@ -184,15 +124,13 @@ void rtw_write_port_cancel(struct adapter *padapter) padapter->bWritePortCancel = true; for (i = 0; i < NR_XMITBUFF; i++) { - if (pxmitbuf->pxmit_urb) - usb_kill_urb(pxmitbuf->pxmit_urb); + usb_kill_urb(pxmitbuf->pxmit_urb); pxmitbuf++; } pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf; for (i = 0; i < NR_XMIT_EXTBUFF; i++) { - if (pxmitbuf->pxmit_urb) - usb_kill_urb(pxmitbuf->pxmit_urb); + usb_kill_urb(pxmitbuf->pxmit_urb); pxmitbuf++; } } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c index ab2e9b729883..73a86e1d0701 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c @@ -21,7 +21,7 @@ void rtl92e_set_bandwidth(struct net_device *dev, return; } - for (eRFPath = 0; eRFPath < priv->NumTotalRFPath; eRFPath++) { + for (eRFPath = 0; eRFPath < priv->num_total_rf_path; eRFPath++) { if (!rtl92e_is_legal_rf_path(dev, eRFPath)) continue; @@ -63,14 +63,14 @@ bool rtl92e_config_rf(struct net_device *dev) u8 ConstRetryTimes = 5, RetryTimes = 5; u8 ret = 0; - priv->NumTotalRFPath = RTL819X_TOTAL_RF_PATH; + priv->num_total_rf_path = RTL819X_TOTAL_RF_PATH; for (eRFPath = (enum rf90_radio_path)RF90_PATH_A; - eRFPath < priv->NumTotalRFPath; eRFPath++) { + eRFPath < priv->num_total_rf_path; eRFPath++) { if (!rtl92e_is_legal_rf_path(dev, eRFPath)) continue; - pPhyReg = &priv->PHYRegDef[eRFPath]; + pPhyReg = &priv->phy_reg_def[eRFPath]; switch (eRFPath) { case RF90_PATH_A: @@ -150,11 +150,11 @@ void rtl92e_set_cck_tx_power(struct net_device *dev, u8 powerlevel) struct r8192_priv *priv = rtllib_priv(dev); TxAGC = powerlevel; - if (priv->bDynamicTxLowPower) { - if (priv->CustomerID == RT_CID_819x_Netcore) + if (priv->dynamic_tx_low_pwr) { + if (priv->customer_id == RT_CID_819X_NETCORE) TxAGC = 0x22; else - TxAGC += priv->CckPwEnl; + TxAGC += priv->cck_pwr_enl; } if (TxAGC > 0x24) TxAGC = 0x24; @@ -169,7 +169,7 @@ void rtl92e_set_ofdm_tx_power(struct net_device *dev, u8 powerlevel) u16 RegOffset[6] = {0xe00, 0xe04, 0xe10, 0xe14, 0xe18, 0xe1c}; u8 byte0, byte1, byte2, byte3; - powerBase0 = powerlevel + priv->LegacyHTTxPowerDiff; + powerBase0 = powerlevel + priv->legacy_ht_tx_pwr_diff; powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | (powerBase0 << 8) | powerBase0; powerBase1 = powerlevel; @@ -177,7 +177,7 @@ void rtl92e_set_ofdm_tx_power(struct net_device *dev, u8 powerlevel) (powerBase1 << 8) | powerBase1; for (index = 0; index < 6; index++) { - writeVal = (u32)(priv->MCSTxPowerLevelOriginalOffset[index] + + writeVal = (u32)(priv->mcs_tx_pwr_level_org_offset[index] + ((index < 2) ? powerBase0 : powerBase1)); byte0 = writeVal & 0x7f; byte1 = (writeVal & 0x7f00) >> 8; @@ -195,10 +195,10 @@ void rtl92e_set_ofdm_tx_power(struct net_device *dev, u8 powerlevel) if (index == 3) { writeVal_tmp = (byte3 << 24) | (byte2 << 16) | (byte1 << 8) | byte0; - priv->Pwr_Track = writeVal_tmp; + priv->pwr_track = writeVal_tmp; } - if (priv->bDynamicTxHighPower) + if (priv->dynamic_tx_high_pwr) writeVal = 0x03030303; else writeVal = (byte3 << 24) | (byte2 << 16) | diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c index 8bf06f736ffb..eba8364d0ff2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_cmdpkt.c @@ -76,7 +76,7 @@ bool rtl92e_send_cmd_pkt(struct net_device *dev, u32 type, const void *data, } while (frag_offset < len); - rtl92e_writeb(dev, TPPoll, TPPoll_CQ); + rtl92e_writeb(dev, TP_POLL, TP_POLL_CQ); Failed: return rt_status; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index f02e67f68e23..0b5b2ae27f9e 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -54,22 +54,16 @@ static void _rtl92e_update_msr(struct net_device *dev) switch (priv->rtllib->iw_mode) { case IW_MODE_INFRA: if (priv->rtllib->state == RTLLIB_LINKED) - msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT); - else - msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); + msr |= MSR_LINK_MANAGED; LedAction = LED_CTL_LINK; break; case IW_MODE_ADHOC: if (priv->rtllib->state == RTLLIB_LINKED) - msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT); - else - msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); + msr |= MSR_LINK_ADHOC; break; case IW_MODE_MASTER: if (priv->rtllib->state == RTLLIB_LINKED) - msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT); - else - msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT); + msr |= MSR_LINK_MASTER; break; default: break; @@ -127,7 +121,7 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) Type = val[0]; RegRCR = rtl92e_readl(dev, RCR); - priv->ReceiveConfig = RegRCR; + priv->receive_config = RegRCR; if (Type) RegRCR |= (RCR_CBSSID); @@ -135,7 +129,7 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) RegRCR &= (~RCR_CBSSID); rtl92e_writel(dev, RCR, RegRCR); - priv->ReceiveConfig = RegRCR; + priv->receive_config = RegRCR; } break; @@ -222,41 +216,41 @@ void rtl92e_set_reg(struct net_device *dev, u8 variable, u8 *val) union aci_aifsn *pAciAifsn = (union aci_aifsn *)& (qos_parameters->aifs[0]); u8 acm = pAciAifsn->f.acm; - u8 AcmCtrl = rtl92e_readb(dev, AcmHwCtrl); + u8 AcmCtrl = rtl92e_readb(dev, ACM_HW_CTRL); if (acm) { switch (eACI) { case AC0_BE: - AcmCtrl |= AcmHw_BeqEn; + AcmCtrl |= ACM_HW_BEQ_EN; break; case AC2_VI: - AcmCtrl |= AcmHw_ViqEn; + AcmCtrl |= ACM_HW_VIQ_EN; break; case AC3_VO: - AcmCtrl |= AcmHw_VoqEn; + AcmCtrl |= ACM_HW_VOQ_EN; break; } } else { switch (eACI) { case AC0_BE: - AcmCtrl &= (~AcmHw_BeqEn); + AcmCtrl &= (~ACM_HW_BEQ_EN); break; case AC2_VI: - AcmCtrl &= (~AcmHw_ViqEn); + AcmCtrl &= (~ACM_HW_VIQ_EN); break; case AC3_VO: - AcmCtrl &= (~AcmHw_BeqEn); + AcmCtrl &= (~ACM_HW_BEQ_EN); break; default: break; } } - rtl92e_writeb(dev, AcmHwCtrl, AcmCtrl); + rtl92e_writeb(dev, ACM_HW_CTRL, AcmCtrl); break; } @@ -292,21 +286,21 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) if (EEPROMId != RTL8190_EEPROM_ID) { netdev_err(dev, "%s(): Invalid EEPROM ID: %x\n", __func__, EEPROMId); - priv->AutoloadFailFlag = true; + priv->autoload_fail_flag = true; } else { - priv->AutoloadFailFlag = false; + priv->autoload_fail_flag = false; } - if (!priv->AutoloadFailFlag) { + if (!priv->autoload_fail_flag) { priv->eeprom_vid = rtl92e_eeprom_read(dev, EEPROM_VID >> 1); priv->eeprom_did = rtl92e_eeprom_read(dev, EEPROM_DID >> 1); usValue = rtl92e_eeprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8; - priv->eeprom_CustomerID = usValue & 0xff; + priv->eeprom_customer_id = usValue & 0xff; usValue = rtl92e_eeprom_read(dev, EEPROM_ICVersion_ChannelPlan>>1); - priv->eeprom_ChannelPlan = usValue&0xff; + priv->eeprom_chnl_plan = usValue&0xff; IC_Version = (usValue & 0xff00)>>8; ICVer8192 = IC_Version & 0xf; @@ -327,11 +321,11 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->card_8192_version = VERSION_8190_BD; priv->eeprom_vid = 0; priv->eeprom_did = 0; - priv->eeprom_CustomerID = 0; - priv->eeprom_ChannelPlan = 0; + priv->eeprom_customer_id = 0; + priv->eeprom_chnl_plan = 0; } - if (!priv->AutoloadFailFlag) { + if (!priv->autoload_fail_flag) { u8 addr[ETH_ALEN]; for (i = 0; i < 6; i += 2) { @@ -345,125 +339,94 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) } if (priv->card_8192_version > VERSION_8190_BD) - priv->bTXPowerDataReadFromEEPORM = true; + priv->tx_pwr_data_read_from_eeprom = true; else - priv->bTXPowerDataReadFromEEPORM = false; + priv->tx_pwr_data_read_from_eeprom = false; priv->rf_type = RTL819X_DEFAULT_RF_TYPE; if (priv->card_8192_version > VERSION_8190_BD) { - if (!priv->AutoloadFailFlag) { + if (!priv->autoload_fail_flag) { tempval = (rtl92e_eeprom_read(dev, (EEPROM_RFInd_PowerDiff >> 1))) & 0xff; - priv->EEPROMLegacyHTTxPowerDiff = tempval & 0xf; + priv->eeprom_legacy_ht_tx_pwr_diff = tempval & 0xf; if (tempval&0x80) priv->rf_type = RF_1T2R; else priv->rf_type = RF_2T4R; } else { - priv->EEPROMLegacyHTTxPowerDiff = 0x04; + priv->eeprom_legacy_ht_tx_pwr_diff = 0x04; } - if (!priv->AutoloadFailFlag) - priv->EEPROMThermalMeter = ((rtl92e_eeprom_read(dev, + if (!priv->autoload_fail_flag) + priv->eeprom_thermal_meter = ((rtl92e_eeprom_read(dev, (EEPROM_ThermalMeter>>1))) & 0xff00) >> 8; else - priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; - priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; + priv->eeprom_thermal_meter = EEPROM_Default_ThermalMeter; + priv->tssi_13dBm = priv->eeprom_thermal_meter * 100; if (priv->epromtype == EEPROM_93C46) { - if (!priv->AutoloadFailFlag) { + if (!priv->autoload_fail_flag) { usValue = rtl92e_eeprom_read(dev, EEPROM_TxPwDiff_CrystalCap >> 1); - priv->EEPROMAntPwDiff = usValue & 0x0fff; - priv->EEPROMCrystalCap = (usValue & 0xf000) + priv->eeprom_ant_pwr_diff = usValue & 0x0fff; + priv->eeprom_crystal_cap = (usValue & 0xf000) >> 12; } else { - priv->EEPROMAntPwDiff = + priv->eeprom_ant_pwr_diff = EEPROM_Default_AntTxPowerDiff; - priv->EEPROMCrystalCap = + priv->eeprom_crystal_cap = EEPROM_Default_TxPwDiff_CrystalCap; } for (i = 0; i < 14; i += 2) { - if (!priv->AutoloadFailFlag) + if (!priv->autoload_fail_flag) usValue = rtl92e_eeprom_read(dev, (EEPROM_TxPwIndex_CCK + i) >> 1); else usValue = EEPROM_Default_TxPower; - *((u16 *)(&priv->EEPROMTxPowerLevelCCK[i])) = + *((u16 *)(&priv->eeprom_tx_pwr_level_cck[i])) = usValue; } for (i = 0; i < 14; i += 2) { - if (!priv->AutoloadFailFlag) + if (!priv->autoload_fail_flag) usValue = rtl92e_eeprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1); else usValue = EEPROM_Default_TxPower; - *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[i])) + *((u16 *)(&priv->eeprom_tx_pwr_level_ofdm24g[i])) = usValue; } } if (priv->epromtype == EEPROM_93C46) { for (i = 0; i < 14; i++) { - priv->TxPowerLevelCCK[i] = - priv->EEPROMTxPowerLevelCCK[i]; - priv->TxPowerLevelOFDM24G[i] = - priv->EEPROMTxPowerLevelOFDM24G[i]; + priv->tx_pwr_level_cck[i] = + priv->eeprom_tx_pwr_level_cck[i]; + priv->tx_pwr_level_ofdm_24g[i] = + priv->eeprom_tx_pwr_level_ofdm24g[i]; } - priv->LegacyHTTxPowerDiff = - priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = priv->EEPROMAntPwDiff & 0xf; - priv->AntennaTxPwDiff[1] = (priv->EEPROMAntPwDiff & + priv->legacy_ht_tx_pwr_diff = + priv->eeprom_legacy_ht_tx_pwr_diff; + priv->antenna_tx_pwr_diff[0] = priv->eeprom_ant_pwr_diff & 0xf; + priv->antenna_tx_pwr_diff[1] = (priv->eeprom_ant_pwr_diff & 0xf0) >> 4; - priv->AntennaTxPwDiff[2] = (priv->EEPROMAntPwDiff & + priv->antenna_tx_pwr_diff[2] = (priv->eeprom_ant_pwr_diff & 0xf00) >> 8; - priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = priv->EEPROMThermalMeter & 0xf; - priv->ThermalMeter[1] = (priv->EEPROMThermalMeter & + priv->crystal_cap = priv->eeprom_crystal_cap; + priv->thermal_meter[0] = priv->eeprom_thermal_meter & 0xf; + priv->thermal_meter[1] = (priv->eeprom_thermal_meter & 0xf0) >> 4; } else if (priv->epromtype == EEPROM_93C56) { - - for (i = 0; i < 3; i++) { - priv->TxPowerLevelCCK_A[i] = - priv->EEPROMRfACCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_A[i] = - priv->EEPROMRfAOfdmChnlTxPwLevel[0]; - priv->TxPowerLevelCCK_C[i] = - priv->EEPROMRfCCCKChnl1TxPwLevel[0]; - priv->TxPowerLevelOFDM24G_C[i] = - priv->EEPROMRfCOfdmChnlTxPwLevel[0]; - } - for (i = 3; i < 9; i++) { - priv->TxPowerLevelCCK_A[i] = - priv->EEPROMRfACCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_A[i] = - priv->EEPROMRfAOfdmChnlTxPwLevel[1]; - priv->TxPowerLevelCCK_C[i] = - priv->EEPROMRfCCCKChnl1TxPwLevel[1]; - priv->TxPowerLevelOFDM24G_C[i] = - priv->EEPROMRfCOfdmChnlTxPwLevel[1]; - } - for (i = 9; i < 14; i++) { - priv->TxPowerLevelCCK_A[i] = - priv->EEPROMRfACCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_A[i] = - priv->EEPROMRfAOfdmChnlTxPwLevel[2]; - priv->TxPowerLevelCCK_C[i] = - priv->EEPROMRfCCCKChnl1TxPwLevel[2]; - priv->TxPowerLevelOFDM24G_C[i] = - priv->EEPROMRfCOfdmChnlTxPwLevel[2]; - } - priv->LegacyHTTxPowerDiff = - priv->EEPROMLegacyHTTxPowerDiff; - priv->AntennaTxPwDiff[0] = 0; - priv->AntennaTxPwDiff[1] = 0; - priv->AntennaTxPwDiff[2] = 0; - priv->CrystalCap = priv->EEPROMCrystalCap; - priv->ThermalMeter[0] = priv->EEPROMThermalMeter & 0xf; - priv->ThermalMeter[1] = (priv->EEPROMThermalMeter & + priv->legacy_ht_tx_pwr_diff = + priv->eeprom_legacy_ht_tx_pwr_diff; + priv->antenna_tx_pwr_diff[0] = 0; + priv->antenna_tx_pwr_diff[1] = 0; + priv->antenna_tx_pwr_diff[2] = 0; + priv->crystal_cap = priv->eeprom_crystal_cap; + priv->thermal_meter[0] = priv->eeprom_thermal_meter & 0xf; + priv->thermal_meter[1] = (priv->eeprom_thermal_meter & 0xf0) >> 4; } } @@ -473,41 +436,41 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) priv->rf_chip = RF_8256; if (priv->reg_chnl_plan == 0xf) - priv->ChannelPlan = priv->eeprom_ChannelPlan; + priv->chnl_plan = priv->eeprom_chnl_plan; else - priv->ChannelPlan = priv->reg_chnl_plan; + priv->chnl_plan = priv->reg_chnl_plan; if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) - priv->CustomerID = RT_CID_DLINK; + priv->customer_id = RT_CID_DLINK; - switch (priv->eeprom_CustomerID) { + switch (priv->eeprom_customer_id) { case EEPROM_CID_DEFAULT: - priv->CustomerID = RT_CID_DEFAULT; + priv->customer_id = RT_CID_DEFAULT; break; case EEPROM_CID_CAMEO: - priv->CustomerID = RT_CID_819x_CAMEO; + priv->customer_id = RT_CID_819x_CAMEO; break; case EEPROM_CID_RUNTOP: - priv->CustomerID = RT_CID_819x_RUNTOP; + priv->customer_id = RT_CID_819x_RUNTOP; break; case EEPROM_CID_NetCore: - priv->CustomerID = RT_CID_819x_Netcore; + priv->customer_id = RT_CID_819X_NETCORE; break; case EEPROM_CID_TOSHIBA: - priv->CustomerID = RT_CID_TOSHIBA; - if (priv->eeprom_ChannelPlan&0x80) - priv->ChannelPlan = priv->eeprom_ChannelPlan&0x7f; + priv->customer_id = RT_CID_TOSHIBA; + if (priv->eeprom_chnl_plan & 0x80) + priv->chnl_plan = priv->eeprom_chnl_plan & 0x7f; else - priv->ChannelPlan = 0x0; + priv->chnl_plan = 0x0; break; case EEPROM_CID_Nettronix: - priv->CustomerID = RT_CID_Nettronix; + priv->customer_id = RT_CID_Nettronix; break; case EEPROM_CID_Pronet: - priv->CustomerID = RT_CID_PRONET; + priv->customer_id = RT_CID_PRONET; break; case EEPROM_CID_DLINK: - priv->CustomerID = RT_CID_DLINK; + priv->customer_id = RT_CID_DLINK; break; case EEPROM_CID_WHQL: @@ -516,9 +479,9 @@ static void _rtl92e_read_eeprom_info(struct net_device *dev) break; } - if (priv->ChannelPlan > CHANNEL_PLAN_LEN - 1) - priv->ChannelPlan = 0; - priv->ChannelPlan = COUNTRY_CODE_WORLD_WIDE_13; + if (priv->chnl_plan > CHANNEL_PLAN_LEN - 1) + priv->chnl_plan = 0; + priv->chnl_plan = COUNTRY_CODE_WORLD_WIDE_13; if (priv->eeprom_vid == 0x1186 && priv->eeprom_did == 0x3304) priv->rtllib->bSupportRemoteWakeUp = true; @@ -594,8 +557,8 @@ static void _rtl92e_hwconfig(struct net_device *dev) rtl92e_writel(dev, RRSR, regRRSR); rtl92e_writew(dev, RETRY_LIMIT, - priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | - priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); + priv->short_retry_limit << RETRY_LIMIT_SHORT_SHIFT | + priv->long_retry_limit << RETRY_LIMIT_LONG_SHIFT); } bool rtl92e_start_adapter(struct net_device *dev) @@ -614,21 +577,21 @@ bool rtl92e_start_adapter(struct net_device *dev) start: rtl92e_reset_desc_ring(dev); - priv->Rf_Mode = RF_OP_By_SW_3wire; + priv->rf_mode = RF_OP_By_SW_3wire; if (priv->rst_progress == RESET_TYPE_NORESET) { rtl92e_writeb(dev, ANAPAR, 0x37); mdelay(500); } - priv->pFirmware->status = FW_STATUS_0_INIT; + priv->fw_info->status = FW_STATUS_0_INIT; ulRegRead = rtl92e_readl(dev, CPU_GEN); - if (priv->pFirmware->status == FW_STATUS_0_INIT) + if (priv->fw_info->status == FW_STATUS_0_INIT) ulRegRead |= CPU_GEN_SYSTEM_RESET; - else if (priv->pFirmware->status == FW_STATUS_5_READY) + else if (priv->fw_info->status == FW_STATUS_5_READY) ulRegRead |= CPU_GEN_FIRMWARE_RESET; else netdev_err(dev, "%s(): undefined firmware state: %d.\n", - __func__, priv->pFirmware->status); + __func__, priv->fw_info->status); rtl92e_writel(dev, CPU_GEN, ulRegRead); @@ -647,13 +610,13 @@ start: return rtStatus; } - priv->LoopbackMode = RTL819X_NO_LOOPBACK; + priv->loopback_mode = RTL819X_NO_LOOPBACK; if (priv->rst_progress == RESET_TYPE_NORESET) { ulRegRead = rtl92e_readl(dev, CPU_GEN); - if (priv->LoopbackMode == RTL819X_NO_LOOPBACK) + if (priv->loopback_mode == RTL819X_NO_LOOPBACK) ulRegRead = (ulRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET; - else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK) + else if (priv->loopback_mode == RTL819X_MAC_LOOPBACK) ulRegRead |= CPU_CCK_LOOPBACK; else netdev_err(dev, "%s: Invalid loopback mode setting.\n", @@ -666,11 +629,11 @@ start: _rtl92e_hwconfig(dev); rtl92e_writeb(dev, CMDR, CR_RE | CR_TE); - rtl92e_writeb(dev, PCIF, ((MXDMA2_NoLimit<<MXDMA2_RX_SHIFT) | - (MXDMA2_NoLimit<<MXDMA2_TX_SHIFT))); + rtl92e_writeb(dev, PCIF, ((MXDMA2_NO_LIMIT << MXDMA2_RX_SHIFT) | + (MXDMA2_NO_LIMIT << MXDMA2_TX_SHIFT))); rtl92e_writel(dev, MAC0, ((u32 *)dev->dev_addr)[0]); rtl92e_writew(dev, MAC4, ((u16 *)(dev->dev_addr + 4))[0]); - rtl92e_writel(dev, RCR, priv->ReceiveConfig); + rtl92e_writel(dev, RCR, priv->receive_config); rtl92e_writel(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | @@ -724,7 +687,7 @@ start: } tmpvalue = rtl92e_readb(dev, IC_VERRSION); - priv->IC_Cut = tmpvalue; + priv->ic_cut = tmpvalue; bfirmwareok = rtl92e_init_fw(dev); if (!bfirmwareok) { @@ -760,19 +723,19 @@ start: } if (priv->rtllib->FwRWRF) - priv->Rf_Mode = RF_OP_By_FW; + priv->rf_mode = RF_OP_By_FW; else - priv->Rf_Mode = RF_OP_By_SW_3wire; + priv->rf_mode = RF_OP_By_SW_3wire; if (priv->rst_progress == RESET_TYPE_NORESET) { rtl92e_dm_init_txpower_tracking(dev); - if (priv->IC_Cut >= IC_VersionCut_D) { + if (priv->ic_cut >= IC_VersionCut_D) { tmpRegA = rtl92e_get_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); rtl92e_get_bb_reg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord); - for (i = 0; i < TxBBGainTableLength; i++) { + for (i = 0; i < TX_BB_GAIN_TABLE_LEN; i++) { if (tmpRegA == dm_tx_bb_gain[i]) { priv->rfa_txpowertrackingindex = i; priv->rfa_txpowertrackingindex_real = i; @@ -785,16 +748,16 @@ start: TempCCk = rtl92e_get_bb_reg(dev, rCCK0_TxFilter1, bMaskByte2); - for (i = 0; i < CCKTxBBGainTableLength; i++) { + for (i = 0; i < CCK_TX_BB_GAIN_TABLE_LEN; i++) { if (TempCCk == dm_cck_tx_bb_gain[i][0]) { - priv->CCKPresentAttentuation_20Mdefault = i; + priv->cck_present_attn_20m_def = i; break; } } - priv->CCKPresentAttentuation_40Mdefault = 0; - priv->CCKPresentAttentuation_difference = 0; + priv->cck_present_attn_40m_def = 0; + priv->cck_present_attn_diff = 0; priv->cck_present_attn = - priv->CCKPresentAttentuation_20Mdefault; + priv->cck_present_attn_20m_def; priv->btxpower_tracking = false; } } @@ -860,9 +823,9 @@ void rtl92e_link_change(struct net_device *dev) if (ieee->intel_promiscuous_md_info.promiscuous_on) ; else - priv->ReceiveConfig = reg |= RCR_CBSSID; + priv->receive_config = reg |= RCR_CBSSID; } else - priv->ReceiveConfig = reg &= ~RCR_CBSSID; + priv->receive_config = reg &= ~RCR_CBSSID; rtl92e_writel(dev, RCR, reg); } @@ -874,12 +837,12 @@ void rtl92e_set_monitor_mode(struct net_device *dev, bool bAllowAllDA, struct r8192_priv *priv = rtllib_priv(dev); if (bAllowAllDA) - priv->ReceiveConfig |= RCR_AAP; + priv->receive_config |= RCR_AAP; else - priv->ReceiveConfig &= ~RCR_AAP; + priv->receive_config &= ~RCR_AAP; if (WriteIntoReg) - rtl92e_writel(dev, RCR, priv->ReceiveConfig); + rtl92e_writel(dev, RCR, priv->receive_config); } static u8 _rtl92e_rate_mgn_to_hw(u8 rate) @@ -1068,13 +1031,13 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, pTxFwInfo->RtsShort = (pTxFwInfo->RtsHT == 0) ? (cb_desc->bRTSUseShortPreamble ? 1 : 0) : (cb_desc->bRTSUseShortGI ? 1 : 0); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { + if (priv->current_chnl_bw == HT_CHANNEL_WIDTH_20_40) { if (cb_desc->bPacketBW) { pTxFwInfo->TxBandwidth = 1; pTxFwInfo->TxSubCarrier = 0; } else { pTxFwInfo->TxBandwidth = 0; - pTxFwInfo->TxSubCarrier = priv->nCur40MhzPrimeSC; + pTxFwInfo->TxSubCarrier = priv->n_cur_40mhz_prime_sc; } } else { pTxFwInfo->TxBandwidth = 0; @@ -1327,11 +1290,10 @@ static void _rtl92e_query_rxphystatus( { struct phy_sts_ofdm_819xpci *pofdm_buf; struct phy_sts_cck_819xpci *pcck_buf; - struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc; u8 *prxpkt; - u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + u8 i, max_spatial_stream, tmp_rxevm; s8 rx_pwr[4], rx_pwr_all = 0; - s8 rx_snrX, rx_evmX; + s8 rx_evmX; u8 evm, pwdb_all; u32 RSSI, total_rssi = 0; u8 is_cck_rate = 0; @@ -1339,8 +1301,6 @@ static void _rtl92e_query_rxphystatus( static u8 check_reg824; static u32 reg824_bit9; - priv->stats.numqry_phystatus++; - is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); memset(precord_stats, 0, sizeof(struct rtllib_rx_stats)); pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = @@ -1372,7 +1332,6 @@ static void _rtl92e_query_rxphystatus( if (is_cck_rate) { u8 report; - priv->stats.numqry_phystatusCCK++; if (!reg824_bit9) { report = pcck_buf->cck_agc_rpt & 0xc0; report >>= 6; @@ -1447,7 +1406,6 @@ static void _rtl92e_query_rxphystatus( precord_stats->RxMIMOSignalQuality[1] = -1; } } else { - priv->stats.numqry_phystatusHT++; for (i = RF90_PATH_A; i < RF90_PATH_MAX; i++) { if (priv->brfpath_rxenable[i]) rf_rx_num++; @@ -1455,11 +1413,6 @@ static void _rtl92e_query_rxphystatus( rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i] & 0x3F) * 2) - 110; - tmp_rxsnr = pofdm_buf->rxsnr_X[i]; - rx_snrX = (s8)(tmp_rxsnr); - rx_snrX /= 2; - priv->stats.rxSNRdB[i] = (long)rx_snrX; - RSSI = rtl92e_rx_db_to_percent(rx_pwr[i]); if (priv->brfpath_rxenable[i]) total_rssi += RSSI; @@ -1499,15 +1452,6 @@ static void _rtl92e_query_rxphystatus( precord_stats->RxMIMOSignalQuality[i] = evm & 0xff; } } - - - rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (struct phy_ofdm_rx_status_rxsc_sgien_exintfflag *) - &rxsc_sgien_exflg; - if (pdrvinfo->BW) - priv->stats.received_bwtype[1+prxsc->rxsc]++; - else - priv->stats.received_bwtype[0]++; } if (is_cck_rate) { @@ -1570,7 +1514,6 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, if (!bcheck) return; - priv->stats.num_process_phyinfo++; if (!prev_st->bIsCCK && prev_st->bPacketToSelf) { for (rfpath = RF90_PATH_A; rfpath < RF90_PATH_C; rfpath++) { if (!rtl92e_is_legal_rf_path(priv->rtllib->dev, rfpath)) @@ -1605,17 +1548,17 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, PHY_Beacon_RSSI_SLID_WIN_MAX) { slide_beacon_adc_pwdb_statistics = PHY_Beacon_RSSI_SLID_WIN_MAX; - last_beacon_adc_pwdb = priv->stats.Slide_Beacon_pwdb + last_beacon_adc_pwdb = priv->stats.slide_beacon_pwdb [slide_beacon_adc_pwdb_index]; - priv->stats.Slide_Beacon_Total -= last_beacon_adc_pwdb; + priv->stats.slide_beacon_total -= last_beacon_adc_pwdb; } - priv->stats.Slide_Beacon_Total += prev_st->RxPWDBAll; - priv->stats.Slide_Beacon_pwdb[slide_beacon_adc_pwdb_index] = + priv->stats.slide_beacon_total += prev_st->RxPWDBAll; + priv->stats.slide_beacon_pwdb[slide_beacon_adc_pwdb_index] = prev_st->RxPWDBAll; slide_beacon_adc_pwdb_index++; if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) slide_beacon_adc_pwdb_index = 0; - prev_st->RxPWDBAll = priv->stats.Slide_Beacon_Total / + prev_st->RxPWDBAll = priv->stats.slide_beacon_total / slide_beacon_adc_pwdb_statistics; if (prev_st->RxPWDBAll >= 3) prev_st->RxPWDBAll -= 3; @@ -1659,7 +1602,6 @@ static void _rtl92e_process_phyinfo(struct r8192_priv *priv, u8 *buffer, tmp_val = priv->stats.slide_evm_total / slide_evm_statistics; - priv->stats.signal_quality = tmp_val; priv->stats.last_signal_strength_inpercent = tmp_val; } @@ -1716,10 +1658,6 @@ static void _rtl92e_translate_rx_signal_stats(struct net_device *dev, ether_addr_equal(praddr, priv->rtllib->dev->dev_addr); if (WLAN_FC_GET_FRAMETYPE(fc) == RTLLIB_STYPE_BEACON) bPacketBeacon = true; - if (bpacket_match_bssid) - priv->stats.numpacket_matchbssid++; - if (bpacket_toself) - priv->stats.numpacket_toself++; _rtl92e_process_phyinfo(priv, tmp_buf, &previous_stats, pstats); _rtl92e_query_rxphystatus(priv, pstats, pdesc, pdrvinfo, &previous_stats, bpacket_match_bssid, @@ -1734,18 +1672,12 @@ static void _rtl92e_update_received_rate_histogram_stats( struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); u32 rcvType = 1; u32 rateIndex; - u32 preamble_guardinterval; if (pstats->bCRC) rcvType = 2; else if (pstats->bICV) rcvType = 3; - if (pstats->bShortPreamble) - preamble_guardinterval = 1; - else - preamble_guardinterval = 0; - switch (pstats->rate) { case MGN_1M: rateIndex = 0; @@ -1835,7 +1767,6 @@ static void _rtl92e_update_received_rate_histogram_stats( rateIndex = 28; break; } - priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; priv->stats.received_rate_histogram[0][rateIndex]++; priv->stats.received_rate_histogram[rcvType][rateIndex]++; } @@ -1843,7 +1774,6 @@ static void _rtl92e_update_received_rate_histogram_stats( bool rtl92e_get_rx_stats(struct net_device *dev, struct rtllib_rx_stats *stats, struct rx_desc *pdesc, struct sk_buff *skb) { - struct r8192_priv *priv = rtllib_priv(dev); struct rx_fwinfo *pDrvInfo = NULL; stats->bICV = pdesc->ICV; @@ -1856,15 +1786,6 @@ bool rtl92e_get_rx_stats(struct net_device *dev, struct rtllib_rx_stats *stats, if (stats->bHwError) { stats->bShift = false; - - if (pdesc->CRC32) { - if (pdesc->Length < 500) - priv->stats.rxcrcerrmin++; - else if (pdesc->Length > 1000) - priv->stats.rxcrcerrmax++; - else - priv->stats.rxcrcerrmid++; - } return false; } @@ -1895,7 +1816,7 @@ bool rtl92e_get_rx_stats(struct net_device *dev, struct rtllib_rx_stats *stats, stats->RxIs40MHzPacket = pDrvInfo->BW; _rtl92e_translate_rx_signal_stats(dev, skb, stats, pdesc, pDrvInfo); - skb_trim(skb, skb->len - 4/*sCrcLng*/); + skb_trim(skb, skb->len - S_CRC_LEN); stats->packetlength = stats->Length-4; @@ -1940,7 +1861,7 @@ void rtl92e_stop_adapter(struct net_device *dev, bool reset) rtl92e_writeb(dev, PMR, 0x5); - rtl92e_writeb(dev, MacBlkCtrl, 0xa); + rtl92e_writeb(dev, MAC_BLK_CTRL, 0xa); } } @@ -2010,10 +1931,10 @@ rtl92e_init_variables(struct net_device *dev) priv->rtllib->tx_headroom = sizeof(struct tx_fwinfo_8190pci); - priv->ShortRetryLimit = 0x30; - priv->LongRetryLimit = 0x30; + priv->short_retry_limit = 0x30; + priv->long_retry_limit = 0x30; - priv->ReceiveConfig = RCR_ADD3 | + priv->receive_config = RCR_ADD3 | RCR_AMF | RCR_ADF | RCR_AICV | RCR_AB | RCR_AM | RCR_APM | @@ -2027,8 +1948,6 @@ rtl92e_init_variables(struct net_device *dev) IMR_RDU | IMR_RXFOVW | IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER); - priv->PwrDomainProtect = false; - priv->bfirst_after_down = false; } @@ -2098,21 +2017,21 @@ bool rtl92e_is_rx_stuck(struct net_device *dev) u8 SilentResetRxSoltNum = 4; rx_chk_cnt++; - if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) { + if (priv->undecorated_smoothed_pwdb >= (RATE_ADAPTIVE_TH_HIGH + 5)) { rx_chk_cnt = 0; - } else if ((priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5)) - && (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M)) - || ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M)))) { + } else if ((priv->undecorated_smoothed_pwdb < (RATE_ADAPTIVE_TH_HIGH + 5)) + && (((priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RATE_ADAPTIVE_TH_LOW_40M)) + || ((priv->current_chnl_bw == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb >= RATE_ADAPTIVE_TH_LOW_20M)))) { if (rx_chk_cnt < 2) return bStuck; rx_chk_cnt = 0; - } else if ((((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M)) || - ((priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) && - (priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M))) && - priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { + } else if ((((priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb < RATE_ADAPTIVE_TH_LOW_40M)) || + ((priv->current_chnl_bw == HT_CHANNEL_WIDTH_20) && + (priv->undecorated_smoothed_pwdb < RATE_ADAPTIVE_TH_LOW_20M))) && + priv->undecorated_smoothed_pwdb >= VERY_LOW_RSSI) { if (rx_chk_cnt < 4) return bStuck; rx_chk_cnt = 0; @@ -2123,24 +2042,24 @@ bool rtl92e_is_rx_stuck(struct net_device *dev) } - SlotIndex = (priv->SilentResetRxSlotIndex++)%SilentResetRxSoltNum; + SlotIndex = (priv->silent_reset_rx_slot_index++)%SilentResetRxSoltNum; if (priv->rx_ctr == RegRxCounter) { - priv->SilentResetRxStuckEvent[SlotIndex] = 1; + priv->silent_reset_rx_stuck_event[SlotIndex] = 1; for (i = 0; i < SilentResetRxSoltNum; i++) - TotalRxStuckCount += priv->SilentResetRxStuckEvent[i]; + TotalRxStuckCount += priv->silent_reset_rx_stuck_event[i]; if (TotalRxStuckCount == SilentResetRxSoltNum) { bStuck = true; for (i = 0; i < SilentResetRxSoltNum; i++) TotalRxStuckCount += - priv->SilentResetRxStuckEvent[i]; + priv->silent_reset_rx_stuck_event[i]; } } else { - priv->SilentResetRxStuckEvent[SlotIndex] = 0; + priv->silent_reset_rx_stuck_event[SlotIndex] = 0; } priv->rx_ctr = RegRxCounter; @@ -2154,10 +2073,10 @@ bool rtl92e_is_tx_stuck(struct net_device *dev) bool bStuck = false; u16 RegTxCounter = rtl92e_readw(dev, 0x128); - if (priv->TxCounter == RegTxCounter) + if (priv->tx_counter == RegTxCounter) bStuck = true; - priv->TxCounter = RegTxCounter; + priv->tx_counter = RegTxCounter; return bStuck; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index 789d288d7503..b011ec8c8a41 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -51,7 +51,7 @@ static bool _rtl92e_fw_check_ready(struct net_device *dev, u8 load_fw_status) { struct r8192_priv *priv = rtllib_priv(dev); - struct rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->fw_info; bool rt_status = true; switch (load_fw_status) { @@ -134,7 +134,7 @@ bool rtl92e_init_fw(struct net_device *dev) enum opt_rst_type rst_opt = OPT_SYSTEM_RESET; enum firmware_init_step starting_state = FW_INIT_STEP0_BOOT; - struct rt_firmware *pfirmware = priv->pFirmware; + struct rt_firmware *pfirmware = priv->fw_info; netdev_dbg(dev, " PlatformInitFirmware()==>\n"); diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_hw.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_hw.h index 3e223151d4b7..99640c4779f7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_hw.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_hw.h @@ -8,141 +8,72 @@ #define R8180_HW enum baseband_config { - BaseBand_Config_PHY_REG = 0, - BaseBand_Config_AGC_TAB = 1, + BB_CONFIG_PHY_REG = 0, + BB_CONFIG_AGC_TAB = 1, }; -#define RTL8187_REQT_READ 0xc0 -#define RTL8187_REQT_WRITE 0x40 -#define RTL8187_REQ_GET_REGS 0x05 -#define RTL8187_REQ_SET_REGS 0x05 - -#define MAX_TX_URB 5 -#define MAX_RX_URB 16 -#define RX_URB_SIZE 9100 - -#define BB_ANTATTEN_CHAN14 0x0c -#define BB_ANTENNA_B 0x40 - -#define BB_HOST_BANG (1<<30) -#define BB_HOST_BANG_EN (1<<2) -#define BB_HOST_BANG_CLK (1<<1) -#define BB_HOST_BANG_RW (1<<3) -#define BB_HOST_BANG_DATA 1 - #define RTL8190_EEPROM_ID 0x8129 #define EEPROM_VID 0x02 #define EEPROM_DID 0x04 #define EEPROM_NODE_ADDRESS_BYTE_0 0x0C -#define EEPROM_TxPowerDiff 0x1F - - -#define EEPROM_PwDiff 0x21 -#define EEPROM_CrystalCap 0x22 - - - -#define EEPROM_TxPwIndex_CCK_V1 0x29 -#define EEPROM_TxPwIndex_OFDM_24G_V1 0x2C -#define EEPROM_TxPwIndex_Ver 0x27 - -#define EEPROM_Default_TxPowerDiff 0x0 #define EEPROM_Default_ThermalMeter 0x77 #define EEPROM_Default_AntTxPowerDiff 0x0 #define EEPROM_Default_TxPwDiff_CrystalCap 0x5 -#define EEPROM_Default_PwDiff 0x4 -#define EEPROM_Default_CrystalCap 0x5 #define EEPROM_Default_TxPower 0x1010 #define EEPROM_ICVersion_ChannelPlan 0x7C #define EEPROM_Customer_ID 0x7B #define EEPROM_RFInd_PowerDiff 0x28 + #define EEPROM_ThermalMeter 0x29 #define EEPROM_TxPwDiff_CrystalCap 0x2A #define EEPROM_TxPwIndex_CCK 0x2C #define EEPROM_TxPwIndex_OFDM_24G 0x3A -#define EEPROM_Default_TxPowerLevel 0x10 -#define EEPROM_IC_VER 0x7d -#define EEPROM_CRC 0x7e #define EEPROM_CID_DEFAULT 0x0 #define EEPROM_CID_CAMEO 0x1 #define EEPROM_CID_RUNTOP 0x2 -#define EEPROM_CID_Senao 0x3 #define EEPROM_CID_TOSHIBA 0x4 #define EEPROM_CID_NetCore 0x5 #define EEPROM_CID_Nettronix 0x6 #define EEPROM_CID_Pronet 0x7 #define EEPROM_CID_DLINK 0x8 #define EEPROM_CID_WHQL 0xFE -enum _RTL8192Pci_HW { +enum _RTL8192PCI_HW { MAC0 = 0x000, - MAC1 = 0x001, - MAC2 = 0x002, - MAC3 = 0x003, MAC4 = 0x004, - MAC5 = 0x005, PCIF = 0x009, -#define MXDMA2_16bytes 0x000 -#define MXDMA2_32bytes 0x001 -#define MXDMA2_64bytes 0x010 -#define MXDMA2_128bytes 0x011 -#define MXDMA2_256bytes 0x100 -#define MXDMA2_512bytes 0x101 -#define MXDMA2_1024bytes 0x110 -#define MXDMA2_NoLimit 0x7 +#define MXDMA2_NO_LIMIT 0x7 -#define MULRW_SHIFT 3 #define MXDMA2_RX_SHIFT 4 #define MXDMA2_TX_SHIFT 0 PMR = 0x00c, EPROM_CMD = 0x00e, -#define EPROM_CMD_RESERVED_MASK BIT5 + #define EPROM_CMD_9356SEL BIT4 #define EPROM_CMD_OPERATING_MODE_SHIFT 6 -#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6)) -#define EPROM_CMD_CONFIG 0x3 #define EPROM_CMD_NORMAL 0 -#define EPROM_CMD_LOAD 1 #define EPROM_CMD_PROGRAM 2 #define EPROM_CS_BIT 3 #define EPROM_CK_BIT 2 #define EPROM_W_BIT 1 #define EPROM_R_BIT 0 - AFR = 0x010, -#define AFR_CardBEn (1<<0) -#define AFR_CLKRUN_SEL (1<<1) -#define AFR_FuncRegEn (1<<2) - ANAPAR = 0x17, #define BB_GLOBAL_RESET_BIT 0x1 BB_GLOBAL_RESET = 0x020, BSSIDR = 0x02E, CMDR = 0x037, -#define CR_RST 0x10 #define CR_RE 0x08 #define CR_TE 0x04 -#define CR_MulRW 0x01 SIFS = 0x03E, - TCR = 0x040, RCR = 0x044, -#define RCR_FILTER_MASK (BIT0 | BIT1 | BIT2 | BIT3 | BIT5 | BIT12 | \ - BIT18 | BIT19 | BIT20 | BIT21 | BIT22 | BIT23) #define RCR_ONLYERLPKT BIT31 -#define RCR_ENCS2 BIT30 -#define RCR_ENCS1 BIT29 -#define RCR_ENMBID BIT27 -#define RCR_ACKTXBW (BIT24|BIT25) #define RCR_CBSSID BIT23 -#define RCR_APWRMGT BIT22 #define RCR_ADD3 BIT21 #define RCR_AMF BIT20 -#define RCR_ACF BIT19 #define RCR_ADF BIT18 -#define RCR_RXFTH BIT13 #define RCR_AICV BIT12 -#define RCR_ACRC32 BIT5 #define RCR_AB BIT3 #define RCR_AM BIT2 #define RCR_APM BIT1 @@ -151,8 +82,6 @@ enum _RTL8192Pci_HW { #define RCR_FIFO_OFFSET 13 SLOT_TIME = 0x049, ACK_TIMEOUT = 0x04c, - PIFS_TIME = 0x04d, - USTIME = 0x04e, EDCAPARA_BE = 0x050, EDCAPARA_BK = 0x054, EDCAPARA_VO = 0x058, @@ -161,53 +90,25 @@ enum _RTL8192Pci_HW { #define AC_PARAM_ECW_MAX_OFFSET 12 #define AC_PARAM_ECW_MIN_OFFSET 8 #define AC_PARAM_AIFS_OFFSET 0 - RFPC = 0x05F, - CWRR = 0x060, BCN_TCFG = 0x062, #define BCN_TCFG_CW_SHIFT 8 #define BCN_TCFG_IFS 0 BCN_INTERVAL = 0x070, ATIMWND = 0x072, BCN_DRV_EARLY_INT = 0x074, -#define BCN_DRV_EARLY_INT_SWBCN_SHIFT 8 -#define BCN_DRV_EARLY_INT_TIME_SHIFT 0 BCN_DMATIME = 0x076, BCN_ERR_THRESH = 0x078, RWCAM = 0x0A0, -#define CAM_CM_SecCAMPolling BIT31 -#define CAM_CM_SecCAMClr BIT30 -#define CAM_CM_SecCAMWE BIT16 -#define CAM_VALID BIT15 -#define CAM_NOTVALID 0x0000 -#define CAM_USEDK BIT5 - -#define CAM_NONE 0x0 -#define CAM_WEP40 0x01 -#define CAM_TKIP 0x02 -#define CAM_AES 0x04 -#define CAM_WEP104 0x05 - #define TOTAL_CAM_ENTRY 32 - -#define CAM_CONFIG_USEDK true -#define CAM_CONFIG_NO_USEDK false -#define CAM_WRITE BIT16 -#define CAM_READ 0x00000000 -#define CAM_POLLINIG BIT31 -#define SCR_UseDK 0x01 WCAMI = 0x0A4, - RCAMO = 0x0A8, SECR = 0x0B0, #define SCR_TxUseDK BIT0 #define SCR_RxUseDK BIT1 #define SCR_TxEncEnable BIT2 #define SCR_RxDecEnable BIT3 -#define SCR_SKByA2 BIT4 #define SCR_NoSKMC BIT5 SWREGULATOR = 0x0BD, INTA_MASK = 0x0f4, -#define IMR8190_DISABLED 0x0 -#define IMR_ATIMEND BIT28 #define IMR_TBDOK BIT27 #define IMR_TBDER BIT26 #define IMR_TXFOVW BIT15 @@ -227,30 +128,10 @@ enum _RTL8192Pci_HW { #define IMR_VODOK BIT1 #define IMR_ROK BIT0 ISR = 0x0f8, - TPPoll = 0x0fd, -#define TPPoll_BKQ BIT0 -#define TPPoll_BEQ BIT1 -#define TPPoll_VIQ BIT2 -#define TPPoll_VOQ BIT3 -#define TPPoll_BQ BIT4 -#define TPPoll_CQ BIT5 -#define TPPoll_MQ BIT6 -#define TPPoll_HQ BIT7 -#define TPPoll_HCCAQ BIT8 -#define TPPoll_StopBK BIT9 -#define TPPoll_StopBE BIT10 -#define TPPoll_StopVI BIT11 -#define TPPoll_StopVO BIT12 -#define TPPoll_StopMgt BIT13 -#define TPPoll_StopHigh BIT14 -#define TPPoll_StopHCCA BIT15 -#define TPPoll_SHIFT 8 - + TP_POLL = 0x0fd, +#define TP_POLL_CQ BIT5 PSR = 0x0ff, -#define PSR_GEN 0x0 -#define PSR_CPU 0x1 CPU_GEN = 0x100, - BB_RESET = 0x101, #define CPU_CCK_LOOPBACK 0x00030000 #define CPU_GEN_SYSTEM_RESET 0x00000001 #define CPU_GEN_FIRMWARE_RESET 0x00000008 @@ -261,31 +142,13 @@ enum _RTL8192Pci_HW { #define CPU_GEN_PWR_STB_CPU 0x00000004 #define CPU_GEN_NO_LOOPBACK_MSK 0xFFF8FFFF #define CPU_GEN_NO_LOOPBACK_SET 0x00080000 -#define CPU_GEN_GPIO_UART 0x00007000 - - LED1Cfg = 0x154, - LED0Cfg = 0x155, - - AcmAvg = 0x170, - AcmHwCtrl = 0x171, -#define AcmHw_HwEn BIT0 -#define AcmHw_BeqEn BIT1 -#define AcmHw_ViqEn BIT2 -#define AcmHw_VoqEn BIT3 -#define AcmHw_BeqStatus BIT4 -#define AcmHw_ViqStatus BIT5 -#define AcmHw_VoqStatus BIT6 - AcmFwCtrl = 0x172, -#define AcmFw_BeqStatus BIT0 -#define AcmFw_ViqStatus BIT1 -#define AcmFw_VoqStatus BIT2 - VOAdmTime = 0x174, - VIAdmTime = 0x178, - BEAdmTime = 0x17C, + ACM_HW_CTRL = 0x171, +#define ACM_HW_BEQ_EN BIT1 +#define ACM_HW_VIQ_EN BIT2 +#define ACM_HW_VOQ_EN BIT3 RQPN1 = 0x180, RQPN2 = 0x184, RQPN3 = 0x188, - QPRR = 0x1E0, QPNR = 0x1F0, BQDA = 0x200, HQDA = 0x204, @@ -296,51 +159,21 @@ enum _RTL8192Pci_HW { VIQDA = 0x218, BEQDA = 0x21C, BKQDA = 0x220, - RCQDA = 0x224, RDQDA = 0x228, - MAR0 = 0x240, - MAR4 = 0x244, - - CCX_PERIOD = 0x250, - CLM_RESULT = 0x251, - NHM_PERIOD = 0x252, - - NHM_THRESHOLD0 = 0x253, - NHM_THRESHOLD1 = 0x254, - NHM_THRESHOLD2 = 0x255, - NHM_THRESHOLD3 = 0x256, - NHM_THRESHOLD4 = 0x257, - NHM_THRESHOLD5 = 0x258, - NHM_THRESHOLD6 = 0x259, - - MCTRL = 0x25A, - - NHM_RPI_COUNTER0 = 0x264, - NHM_RPI_COUNTER1 = 0x265, - NHM_RPI_COUNTER2 = 0x266, - NHM_RPI_COUNTER3 = 0x267, - NHM_RPI_COUNTER4 = 0x268, - NHM_RPI_COUNTER5 = 0x269, - NHM_RPI_COUNTER6 = 0x26A, - NHM_RPI_COUNTER7 = 0x26B, WFCRC0 = 0x2f0, WFCRC1 = 0x2f4, WFCRC2 = 0x2f8, BW_OPMODE = 0x300, -#define BW_OPMODE_11J BIT0 #define BW_OPMODE_5G BIT1 #define BW_OPMODE_20MHZ BIT2 IC_VERRSION = 0x301, MSR = 0x303, -#define MSR_LINK_MASK ((1<<0)|(1<<1)) +#define MSR_LINK_MASK (BIT(1) | BIT(0)) #define MSR_LINK_MANAGED 2 -#define MSR_LINK_NONE 0 -#define MSR_LINK_SHIFT 0 #define MSR_LINK_ADHOC 1 #define MSR_LINK_MASTER 3 -#define MSR_LINK_ENEDCA (1<<4) #define MSR_NOLINK 0x00 #define MSR_ADHOC 0x01 @@ -352,12 +185,7 @@ enum _RTL8192Pci_HW { #define RETRY_LIMIT_LONG_SHIFT 0 TSFR = 0x308, RRSR = 0x310, -#define RRSR_RSC_OFFSET 21 #define RRSR_SHORT_OFFSET 23 -#define RRSR_RSC_DUPLICATE 0x600000 -#define RRSR_RSC_UPSUBCHNL 0x400000 -#define RRSR_RSC_LOWSUBCHNL 0x200000 -#define RRSR_SHORT 0x800000 #define RRSR_1M BIT0 #define RRSR_2M BIT1 #define RRSR_5_5M BIT2 @@ -370,14 +198,6 @@ enum _RTL8192Pci_HW { #define RRSR_36M BIT9 #define RRSR_48M BIT10 #define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 #define BRSR_AckShortPmb BIT23 UFWP = 0x318, RATR0 = 0x320, @@ -419,21 +239,14 @@ enum _RTL8192Pci_HW { RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ RATR_MCS14|RATR_MCS15) - DRIVER_RSSI = 0x32c, MCS_TXAGC = 0x340, CCK_TXAGC = 0x348, - MacBlkCtrl = 0x403, - -} -; + MAC_BLK_CTRL = 0x403, +}; #define GPI 0x108 -#define GPO 0x109 -#define GPE 0x10a - -#define HWSET_MAX_SIZE_92S 128 -#define ANAPAR_FOR_8192PciE 0x17 +#define ANAPAR_FOR_8192PCIE 0x17 #endif diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index a813eded4cb3..c6cbdea6d5b2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -94,24 +94,24 @@ static u32 _rtl92e_phy_rf_read(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); u32 ret = 0; u32 NewOffset = 0; - struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition *pPhyReg = &priv->phy_reg_def[eRFPath]; Offset &= 0x3f; if (priv->rf_chip == RF_8256) { rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); if (Offset >= 31) { - priv->RfReg0Value[eRFPath] |= 0x140; + priv->rf_reg_0value[eRFPath] |= 0x140; rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - (priv->RfReg0Value[eRFPath]<<16)); + (priv->rf_reg_0value[eRFPath] << 16)); NewOffset = Offset - 30; } else if (Offset >= 16) { - priv->RfReg0Value[eRFPath] |= 0x100; - priv->RfReg0Value[eRFPath] &= (~0x40); + priv->rf_reg_0value[eRFPath] |= 0x100; + priv->rf_reg_0value[eRFPath] &= (~0x40); rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - (priv->RfReg0Value[eRFPath]<<16)); + (priv->rf_reg_0value[eRFPath] << 16)); NewOffset = Offset - 15; } else @@ -130,10 +130,10 @@ static u32 _rtl92e_phy_rf_read(struct net_device *dev, bLSSIReadBackData); if (priv->rf_chip == RF_8256) { - priv->RfReg0Value[eRFPath] &= 0xebf; + priv->rf_reg_0value[eRFPath] &= 0xebf; rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + (priv->rf_reg_0value[eRFPath] << 16)); rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } @@ -149,24 +149,24 @@ static void _rtl92e_phy_rf_write(struct net_device *dev, { struct r8192_priv *priv = rtllib_priv(dev); u32 DataAndAddr = 0, NewOffset = 0; - struct bb_reg_definition *pPhyReg = &priv->PHYRegDef[eRFPath]; + struct bb_reg_definition *pPhyReg = &priv->phy_reg_def[eRFPath]; Offset &= 0x3f; if (priv->rf_chip == RF_8256) { rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter4, 0xf00, 0x0); if (Offset >= 31) { - priv->RfReg0Value[eRFPath] |= 0x140; + priv->rf_reg_0value[eRFPath] |= 0x140; rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + (priv->rf_reg_0value[eRFPath] << 16)); NewOffset = Offset - 30; } else if (Offset >= 16) { - priv->RfReg0Value[eRFPath] |= 0x100; - priv->RfReg0Value[eRFPath] &= (~0x40); + priv->rf_reg_0value[eRFPath] |= 0x100; + priv->rf_reg_0value[eRFPath] &= (~0x40); rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + (priv->rf_reg_0value[eRFPath] << 16)); NewOffset = Offset - 15; } else NewOffset = Offset; @@ -179,14 +179,14 @@ static void _rtl92e_phy_rf_write(struct net_device *dev, rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); if (Offset == 0x0) - priv->RfReg0Value[eRFPath] = Data; + priv->rf_reg_0value[eRFPath] = Data; if (priv->rf_chip == RF_8256) { if (Offset != 0) { - priv->RfReg0Value[eRFPath] &= 0xebf; + priv->rf_reg_0value[eRFPath] &= 0xebf; rtl92e_set_bb_reg(dev, pPhyReg->rf3wireOffset, bMaskDWord, - (priv->RfReg0Value[eRFPath] << 16)); + (priv->rf_reg_0value[eRFPath] << 16)); } rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter4, 0x300, 0x3); } @@ -203,7 +203,7 @@ void rtl92e_set_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath, if (priv->rtllib->rf_power_state != rf_on && !priv->being_init_adapter) return; - if (priv->Rf_Mode == RF_OP_By_FW) { + if (priv->rf_mode == RF_OP_By_FW) { if (BitMask != bMask12Bits) { Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath, RegAddr); @@ -240,7 +240,7 @@ u32 rtl92e_get_rf_reg(struct net_device *dev, enum rf90_radio_path eRFPath, if (priv->rtllib->rf_power_state != rf_on && !priv->being_init_adapter) return 0; mutex_lock(&priv->rf_mutex); - if (priv->Rf_Mode == RF_OP_By_FW) { + if (priv->rf_mode == RF_OP_By_FW) { Original_Value = _rtl92e_phy_rf_fw_read(dev, eRFPath, RegAddr); udelay(200); } else { @@ -306,7 +306,7 @@ void rtl92e_config_mac(struct net_device *dev) u32 *pdwArray = NULL; struct r8192_priv *priv = rtllib_priv(dev); - if (priv->bTXPowerDataReadFromEEPORM) { + if (priv->tx_pwr_data_read_from_eeprom) { dwArrayLen = MACPHY_Array_PGLength; pdwArray = Rtl819XMACPHY_Array_PG; @@ -342,13 +342,13 @@ static void _rtl92e_phy_config_bb(struct net_device *dev, u8 ConfigType) Rtl819XPHY_REGArray_Table = Rtl819XPHY_REG_1T2RArray; } - if (ConfigType == BaseBand_Config_PHY_REG) { + if (ConfigType == BB_CONFIG_PHY_REG) { for (i = 0; i < PHY_REGArrayLen; i += 2) { rtl92e_set_bb_reg(dev, Rtl819XPHY_REGArray_Table[i], bMaskDWord, Rtl819XPHY_REGArray_Table[i+1]); } - } else if (ConfigType == BaseBand_Config_AGC_TAB) { + } else if (ConfigType == BB_CONFIG_AGC_TAB) { for (i = 0; i < AGCTAB_ArrayLen; i += 2) { rtl92e_set_bb_reg(dev, Rtl819XAGCTAB_Array_Table[i], bMaskDWord, @@ -361,90 +361,90 @@ static void _rtl92e_init_bb_rf_reg_def(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - priv->PHYRegDef[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; - priv->PHYRegDef[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; - priv->PHYRegDef[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; - priv->PHYRegDef[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW; - - priv->PHYRegDef[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; - priv->PHYRegDef[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB; - priv->PHYRegDef[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB; - priv->PHYRegDef[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB; - - priv->PHYRegDef[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; - priv->PHYRegDef[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; - priv->PHYRegDef[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE; - priv->PHYRegDef[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE; - - priv->PHYRegDef[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; - priv->PHYRegDef[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; - priv->PHYRegDef[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE; - priv->PHYRegDef[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE; - - priv->PHYRegDef[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; - priv->PHYRegDef[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; - priv->PHYRegDef[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter; - priv->PHYRegDef[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter; - - priv->PHYRegDef[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; - priv->PHYRegDef[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; - priv->PHYRegDef[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; - priv->PHYRegDef[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; - - priv->PHYRegDef[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; - priv->PHYRegDef[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; - priv->PHYRegDef[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; - priv->PHYRegDef[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; - - priv->PHYRegDef[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; - priv->PHYRegDef[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; - priv->PHYRegDef[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; - priv->PHYRegDef[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; - - priv->PHYRegDef[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; - priv->PHYRegDef[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; - priv->PHYRegDef[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; - priv->PHYRegDef[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; - - priv->PHYRegDef[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; - priv->PHYRegDef[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; - priv->PHYRegDef[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; - priv->PHYRegDef[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; - - priv->PHYRegDef[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; - priv->PHYRegDef[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; - priv->PHYRegDef[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; - priv->PHYRegDef[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; - - priv->PHYRegDef[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; - priv->PHYRegDef[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; - priv->PHYRegDef[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; - priv->PHYRegDef[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; - - priv->PHYRegDef[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; - priv->PHYRegDef[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; - priv->PHYRegDef[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; - priv->PHYRegDef[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; - - priv->PHYRegDef[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE; - priv->PHYRegDef[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; - priv->PHYRegDef[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; - priv->PHYRegDef[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; - - priv->PHYRegDef[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; - priv->PHYRegDef[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; - priv->PHYRegDef[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; - priv->PHYRegDef[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; - - priv->PHYRegDef[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE; - priv->PHYRegDef[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; - priv->PHYRegDef[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; - priv->PHYRegDef[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; - - priv->PHYRegDef[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; - priv->PHYRegDef[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; - priv->PHYRegDef[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; - priv->PHYRegDef[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; + priv->phy_reg_def[RF90_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; + priv->phy_reg_def[RF90_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; + priv->phy_reg_def[RF90_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW; + priv->phy_reg_def[RF90_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW; + + priv->phy_reg_def[RF90_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; + priv->phy_reg_def[RF90_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB; + priv->phy_reg_def[RF90_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB; + priv->phy_reg_def[RF90_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB; + + priv->phy_reg_def[RF90_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; + priv->phy_reg_def[RF90_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; + priv->phy_reg_def[RF90_PATH_C].rfintfo = rFPGA0_XC_RFInterfaceOE; + priv->phy_reg_def[RF90_PATH_D].rfintfo = rFPGA0_XD_RFInterfaceOE; + + priv->phy_reg_def[RF90_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; + priv->phy_reg_def[RF90_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; + priv->phy_reg_def[RF90_PATH_C].rfintfe = rFPGA0_XC_RFInterfaceOE; + priv->phy_reg_def[RF90_PATH_D].rfintfe = rFPGA0_XD_RFInterfaceOE; + + priv->phy_reg_def[RF90_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; + priv->phy_reg_def[RF90_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; + priv->phy_reg_def[RF90_PATH_C].rf3wireOffset = rFPGA0_XC_LSSIParameter; + priv->phy_reg_def[RF90_PATH_D].rf3wireOffset = rFPGA0_XD_LSSIParameter; + + priv->phy_reg_def[RF90_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; + priv->phy_reg_def[RF90_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; + priv->phy_reg_def[RF90_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; + priv->phy_reg_def[RF90_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; + + priv->phy_reg_def[RF90_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; + priv->phy_reg_def[RF90_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; + priv->phy_reg_def[RF90_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; + priv->phy_reg_def[RF90_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; + + priv->phy_reg_def[RF90_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; + priv->phy_reg_def[RF90_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; + priv->phy_reg_def[RF90_PATH_C].rfHSSIPara1 = rFPGA0_XC_HSSIParameter1; + priv->phy_reg_def[RF90_PATH_D].rfHSSIPara1 = rFPGA0_XD_HSSIParameter1; + + priv->phy_reg_def[RF90_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; + priv->phy_reg_def[RF90_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; + priv->phy_reg_def[RF90_PATH_C].rfHSSIPara2 = rFPGA0_XC_HSSIParameter2; + priv->phy_reg_def[RF90_PATH_D].rfHSSIPara2 = rFPGA0_XD_HSSIParameter2; + + priv->phy_reg_def[RF90_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; + priv->phy_reg_def[RF90_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; + priv->phy_reg_def[RF90_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; + priv->phy_reg_def[RF90_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; + + priv->phy_reg_def[RF90_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; + priv->phy_reg_def[RF90_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; + priv->phy_reg_def[RF90_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; + priv->phy_reg_def[RF90_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; + + priv->phy_reg_def[RF90_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; + priv->phy_reg_def[RF90_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; + priv->phy_reg_def[RF90_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; + priv->phy_reg_def[RF90_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; + + priv->phy_reg_def[RF90_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; + priv->phy_reg_def[RF90_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; + priv->phy_reg_def[RF90_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; + priv->phy_reg_def[RF90_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; + + priv->phy_reg_def[RF90_PATH_A].rfRxAFE = rOFDM0_XARxAFE; + priv->phy_reg_def[RF90_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; + priv->phy_reg_def[RF90_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; + priv->phy_reg_def[RF90_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; + + priv->phy_reg_def[RF90_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; + priv->phy_reg_def[RF90_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; + priv->phy_reg_def[RF90_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; + priv->phy_reg_def[RF90_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; + + priv->phy_reg_def[RF90_PATH_A].rfTxAFE = rOFDM0_XATxAFE; + priv->phy_reg_def[RF90_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; + priv->phy_reg_def[RF90_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; + priv->phy_reg_def[RF90_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; + + priv->phy_reg_def[RF90_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + priv->phy_reg_def[RF90_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + priv->phy_reg_def[RF90_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; + priv->phy_reg_def[RF90_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; } @@ -526,25 +526,25 @@ static bool _rtl92e_bb_config_para_file(struct net_device *dev) return rtStatus; } rtl92e_set_bb_reg(dev, rFPGA0_RFMOD, bCCKEn|bOFDMEn, 0x0); - _rtl92e_phy_config_bb(dev, BaseBand_Config_PHY_REG); + _rtl92e_phy_config_bb(dev, BB_CONFIG_PHY_REG); dwRegValue = rtl92e_readl(dev, CPU_GEN); rtl92e_writel(dev, CPU_GEN, (dwRegValue|CPU_GEN_BB_RST)); - _rtl92e_phy_config_bb(dev, BaseBand_Config_AGC_TAB); + _rtl92e_phy_config_bb(dev, BB_CONFIG_AGC_TAB); - if (priv->IC_Cut > VERSION_8190_BD) { + if (priv->ic_cut > VERSION_8190_BD) { if (priv->rf_type == RF_2T4R) - dwRegValue = priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]; + dwRegValue = priv->antenna_tx_pwr_diff[2] << 8 | + priv->antenna_tx_pwr_diff[1] << 4 | + priv->antenna_tx_pwr_diff[0]; else dwRegValue = 0x0; rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage, (bXBTxAGC|bXCTxAGC|bXDTxAGC), dwRegValue); - dwRegValue = priv->CrystalCap; + dwRegValue = priv->crystal_cap; rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter1, bXtalCap92x, dwRegValue); } @@ -561,65 +561,43 @@ void rtl92e_get_tx_power(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - priv->MCSTxPowerLevelOriginalOffset[0] = + priv->mcs_tx_pwr_level_org_offset[0] = rtl92e_readl(dev, rTxAGC_Rate18_06); - priv->MCSTxPowerLevelOriginalOffset[1] = + priv->mcs_tx_pwr_level_org_offset[1] = rtl92e_readl(dev, rTxAGC_Rate54_24); - priv->MCSTxPowerLevelOriginalOffset[2] = + priv->mcs_tx_pwr_level_org_offset[2] = rtl92e_readl(dev, rTxAGC_Mcs03_Mcs00); - priv->MCSTxPowerLevelOriginalOffset[3] = + priv->mcs_tx_pwr_level_org_offset[3] = rtl92e_readl(dev, rTxAGC_Mcs07_Mcs04); - priv->MCSTxPowerLevelOriginalOffset[4] = + priv->mcs_tx_pwr_level_org_offset[4] = rtl92e_readl(dev, rTxAGC_Mcs11_Mcs08); - priv->MCSTxPowerLevelOriginalOffset[5] = + priv->mcs_tx_pwr_level_org_offset[5] = rtl92e_readl(dev, rTxAGC_Mcs15_Mcs12); - priv->DefaultInitialGain[0] = rtl92e_readb(dev, rOFDM0_XAAGCCore1); - priv->DefaultInitialGain[1] = rtl92e_readb(dev, rOFDM0_XBAGCCore1); - priv->DefaultInitialGain[2] = rtl92e_readb(dev, rOFDM0_XCAGCCore1); - priv->DefaultInitialGain[3] = rtl92e_readb(dev, rOFDM0_XDAGCCore1); + priv->def_initial_gain[0] = rtl92e_readb(dev, rOFDM0_XAAGCCore1); + priv->def_initial_gain[1] = rtl92e_readb(dev, rOFDM0_XBAGCCore1); + priv->def_initial_gain[2] = rtl92e_readb(dev, rOFDM0_XCAGCCore1); + priv->def_initial_gain[3] = rtl92e_readb(dev, rOFDM0_XDAGCCore1); priv->framesync = rtl92e_readb(dev, rOFDM0_RxDetector3); - priv->framesyncC34 = rtl92e_readl(dev, rOFDM0_RxDetector2); - priv->SifsTime = rtl92e_readw(dev, SIFS); } void rtl92e_set_tx_power(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); u8 powerlevel = 0, powerlevelOFDM24G = 0; - s8 ant_pwr_diff; - u32 u4RegValue; if (priv->epromtype == EEPROM_93C46) { - powerlevel = priv->TxPowerLevelCCK[channel-1]; - powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; + powerlevel = priv->tx_pwr_level_cck[channel - 1]; + powerlevelOFDM24G = priv->tx_pwr_level_ofdm_24g[channel - 1]; } else if (priv->epromtype == EEPROM_93C56) { - if (priv->rf_type == RF_1T2R) { - powerlevel = priv->TxPowerLevelCCK_C[channel-1]; - powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_C[channel-1]; - } else if (priv->rf_type == RF_2T4R) { - powerlevel = priv->TxPowerLevelCCK_A[channel-1]; - powerlevelOFDM24G = priv->TxPowerLevelOFDM24G_A[channel-1]; - - ant_pwr_diff = priv->TxPowerLevelOFDM24G_C[channel-1] - - priv->TxPowerLevelOFDM24G_A[channel-1]; - - priv->RF_C_TxPwDiff = ant_pwr_diff; - - ant_pwr_diff &= 0xf; - - priv->AntennaTxPwDiff[2] = 0; - priv->AntennaTxPwDiff[1] = (u8)(ant_pwr_diff); - priv->AntennaTxPwDiff[0] = 0; - - u4RegValue = priv->AntennaTxPwDiff[2]<<8 | - priv->AntennaTxPwDiff[1]<<4 | - priv->AntennaTxPwDiff[0]; + if (priv->rf_type == RF_2T4R) { + priv->antenna_tx_pwr_diff[2] = 0; + priv->antenna_tx_pwr_diff[1] = 0; + priv->antenna_tx_pwr_diff[0] = 0; rtl92e_set_bb_reg(dev, rFPGA0_TxGainStage, - (bXBTxAGC|bXCTxAGC|bXDTxAGC), - u4RegValue); + (bXBTxAGC | bXCTxAGC | bXDTxAGC), 0); } } switch (priv->rf_chip) { @@ -726,8 +704,8 @@ u8 rtl92e_config_rf_path(struct net_device *dev, enum rf90_radio_path eRFPath) static void _rtl92e_set_tx_power_level(struct net_device *dev, u8 channel) { struct r8192_priv *priv = rtllib_priv(dev); - u8 powerlevel = priv->TxPowerLevelCCK[channel-1]; - u8 powerlevelOFDM24G = priv->TxPowerLevelOFDM24G[channel-1]; + u8 powerlevel = priv->tx_pwr_level_cck[channel - 1]; + u8 powerlevelOFDM24G = priv->tx_pwr_level_ofdm_24g[channel - 1]; switch (priv->rf_chip) { case RF_8225: @@ -886,7 +864,7 @@ static u8 _rtl92e_phy_switch_channel_step(struct net_device *dev, u8 channel, continue; switch (CurrentCmd->CmdID) { case CmdID_SetTxPowerLevel: - if (priv->IC_Cut > VERSION_8190_BD) + if (priv->ic_cut > VERSION_8190_BD) _rtl92e_set_tx_power_level(dev, channel); break; @@ -904,7 +882,7 @@ static u8 _rtl92e_phy_switch_channel_step(struct net_device *dev, u8 channel, break; case CmdID_RF_WriteReg: for (eRFPath = 0; eRFPath < - priv->NumTotalRFPath; eRFPath++) + priv->num_total_rf_path; eRFPath++) rtl92e_set_rf_reg(dev, (enum rf90_radio_path)eRFPath, CurrentCmd->Para1, bMask12Bits, @@ -929,8 +907,8 @@ static void _rtl92e_phy_switch_channel(struct net_device *dev, u8 channel) u32 delay = 0; while (!_rtl92e_phy_switch_channel_step(dev, channel, - &priv->SwChnlStage, - &priv->SwChnlStep, &delay)) { + &priv->sw_chnl_stage, + &priv->sw_chnl_step, &delay)) { if (delay > 0) msleep(delay); if (!priv->up) @@ -954,7 +932,7 @@ u8 rtl92e_set_channel(struct net_device *dev, u8 channel) netdev_err(dev, "%s(): Driver is not initialized\n", __func__); return false; } - if (priv->SwChnlInProgress) + if (priv->sw_chnl_in_progress) return false; @@ -987,18 +965,18 @@ u8 rtl92e_set_channel(struct net_device *dev, u8 channel) break; } - priv->SwChnlInProgress = true; + priv->sw_chnl_in_progress = true; if (channel == 0) channel = 1; priv->chan = channel; - priv->SwChnlStage = 0; - priv->SwChnlStep = 0; + priv->sw_chnl_stage = 0; + priv->sw_chnl_step = 0; if (priv->up) _rtl92e_phy_switch_channel_work_item(dev); - priv->SwChnlInProgress = false; + priv->sw_chnl_in_progress = false; return true; } @@ -1006,16 +984,16 @@ static void _rtl92e_cck_tx_power_track_bw_switch_tssi(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - switch (priv->CurrentChannelBW) { + switch (priv->current_chnl_bw) { case HT_CHANNEL_WIDTH_20: priv->cck_present_attn = - priv->CCKPresentAttentuation_20Mdefault + - priv->CCKPresentAttentuation_difference; + priv->cck_present_attn_20m_def + + priv->cck_present_attn_diff; if (priv->cck_present_attn > - (CCKTxBBGainTableLength-1)) + (CCK_TX_BB_GAIN_TABLE_LEN - 1)) priv->cck_present_attn = - CCKTxBBGainTableLength-1; + CCK_TX_BB_GAIN_TABLE_LEN - 1; if (priv->cck_present_attn < 0) priv->cck_present_attn = 0; @@ -1034,13 +1012,13 @@ static void _rtl92e_cck_tx_power_track_bw_switch_tssi(struct net_device *dev) case HT_CHANNEL_WIDTH_20_40: priv->cck_present_attn = - priv->CCKPresentAttentuation_40Mdefault + - priv->CCKPresentAttentuation_difference; + priv->cck_present_attn_40m_def + + priv->cck_present_attn_diff; if (priv->cck_present_attn > - (CCKTxBBGainTableLength - 1)) + (CCK_TX_BB_GAIN_TABLE_LEN - 1)) priv->cck_present_attn = - CCKTxBBGainTableLength-1; + CCK_TX_BB_GAIN_TABLE_LEN - 1; if (priv->cck_present_attn < 0) priv->cck_present_attn = 0; @@ -1070,15 +1048,15 @@ static void _rtl92e_cck_tx_power_track_bw_switch_thermal(struct net_device *dev) priv->bcck_in_ch14) priv->bcck_in_ch14 = false; - switch (priv->CurrentChannelBW) { + switch (priv->current_chnl_bw) { case HT_CHANNEL_WIDTH_20: - if (priv->Record_CCK_20Mindex == 0) - priv->Record_CCK_20Mindex = 6; - priv->CCK_index = priv->Record_CCK_20Mindex; + if (priv->rec_cck_20m_idx == 0) + priv->rec_cck_20m_idx = 6; + priv->cck_index = priv->rec_cck_20m_idx; break; case HT_CHANNEL_WIDTH_20_40: - priv->CCK_index = priv->Record_CCK_40Mindex; + priv->cck_index = priv->rec_cck_40m_idx; break; } rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); @@ -1088,7 +1066,7 @@ static void _rtl92e_cck_tx_power_track_bw_switch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->IC_Cut >= IC_VersionCut_D) + if (priv->ic_cut >= IC_VersionCut_D) _rtl92e_cck_tx_power_track_bw_switch_tssi(dev); else _rtl92e_cck_tx_power_track_bw_switch_thermal(dev); @@ -1101,7 +1079,7 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) u8 regBwOpMode; if (priv->rf_chip == RF_PSEUDO_11N) { - priv->SetBWModeInProgress = false; + priv->set_bw_mode_in_progress = false; return; } if (!priv->up) { @@ -1110,7 +1088,7 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) } regBwOpMode = rtl92e_readb(dev, BW_OPMODE); - switch (priv->CurrentChannelBW) { + switch (priv->current_chnl_bw) { case HT_CHANNEL_WIDTH_20: regBwOpMode |= BW_OPMODE_20MHZ; rtl92e_writeb(dev, BW_OPMODE, regBwOpMode); @@ -1123,11 +1101,11 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) default: netdev_err(dev, "%s(): unknown Bandwidth: %#X\n", __func__, - priv->CurrentChannelBW); + priv->current_chnl_bw); break; } - switch (priv->CurrentChannelBW) { + switch (priv->current_chnl_bw) { case HT_CHANNEL_WIDTH_20: rtl92e_set_bb_reg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); rtl92e_set_bb_reg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); @@ -1156,15 +1134,15 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) } rtl92e_set_bb_reg(dev, rCCK0_System, bCCKSideBand, - (priv->nCur40MhzPrimeSC>>1)); + (priv->n_cur_40mhz_prime_sc>>1)); rtl92e_set_bb_reg(dev, rOFDM1_LSTF, 0xC00, - priv->nCur40MhzPrimeSC); + priv->n_cur_40mhz_prime_sc); rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0); break; default: netdev_err(dev, "%s(): unknown Bandwidth: %#X\n", __func__, - priv->CurrentChannelBW); + priv->current_chnl_bw); break; } @@ -1174,7 +1152,7 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) break; case RF_8256: - rtl92e_set_bandwidth(dev, priv->CurrentChannelBW); + rtl92e_set_bandwidth(dev, priv->current_chnl_bw); break; case RF_8258: @@ -1190,7 +1168,7 @@ static void _rtl92e_set_bw_mode_work_item(struct net_device *dev) } atomic_dec(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress = false; + priv->set_bw_mode_in_progress = false; } void rtl92e_set_bw_mode(struct net_device *dev, enum ht_channel_width bandwidth, @@ -1199,20 +1177,20 @@ void rtl92e_set_bw_mode(struct net_device *dev, enum ht_channel_width bandwidth, struct r8192_priv *priv = rtllib_priv(dev); - if (priv->SetBWModeInProgress) + if (priv->set_bw_mode_in_progress) return; atomic_inc(&(priv->rtllib->atm_swbw)); - priv->SetBWModeInProgress = true; + priv->set_bw_mode_in_progress = true; - priv->CurrentChannelBW = bandwidth; + priv->current_chnl_bw = bandwidth; if (Offset == HT_EXTCHNL_OFFSET_LOWER) - priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_UPPER; + priv->n_cur_40mhz_prime_sc = HAL_PRIME_CHNL_OFFSET_UPPER; else if (Offset == HT_EXTCHNL_OFFSET_UPPER) - priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_LOWER; + priv->n_cur_40mhz_prime_sc = HAL_PRIME_CHNL_OFFSET_LOWER; else - priv->nCur40MhzPrimeSC = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + priv->n_cur_40mhz_prime_sc = HAL_PRIME_CHNL_OFFSET_DONT_CARE; _rtl92e_set_bw_mode_work_item(dev); @@ -1295,7 +1273,7 @@ void rtl92e_set_rf_off(struct net_device *dev) rtl92e_set_bb_reg(dev, rOFDM1_TRxPathEnable, 0xf, 0x0); rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter1, 0x60, 0x0); rtl92e_set_bb_reg(dev, rFPGA0_AnalogParameter1, 0x4, 0x0); - rtl92e_writeb(dev, ANAPAR_FOR_8192PciE, 0x07); + rtl92e_writeb(dev, ANAPAR_FOR_8192PCIE, 0x07); } @@ -1309,9 +1287,9 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, u8 i = 0, QueueID = 0; struct rtl8192_tx_ring *ring = NULL; - if (priv->SetRFPowerStateInProgress) + if (priv->set_rf_pwr_state_in_progress) return false; - priv->SetRFPowerStateInProgress = true; + priv->set_rf_pwr_state_in_progress = true; switch (priv->rf_chip) { case RF_8256: @@ -1331,7 +1309,7 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, netdev_err(dev, "%s(): Failed to initialize Adapter.\n", __func__); - priv->SetRFPowerStateInProgress = false; + priv->set_rf_pwr_state_in_progress = false; return false; } @@ -1438,7 +1416,7 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, } } - priv->SetRFPowerStateInProgress = false; + priv->set_rf_pwr_state_in_progress = false; return bResult; } diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h index 433272a2aae8..f846f109ed98 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h @@ -42,8 +42,6 @@ #define CCK_TXAGC 0x348 /* Mac block on/off control register */ -#define MacBlkCtrl 0x403 - #define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC */ #define rFPGA0_TxInfo 0x804 #define rFPGA0_PSDFunction 0x808 diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index f8fbe78ccad9..104b16cfa979 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -692,16 +692,13 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset) priv->rtllib->ieee_up = 1; priv->up_first_time = 0; - priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (!init_status) { netdev_err(dev, "%s(): Initialization failed!\n", __func__); - priv->bfirst_init = false; return -1; } RT_CLEAR_PS_LEVEL(psc, RT_RF_OFF_LEVL_HALT_NIC); - priv->bfirst_init = false; if (priv->polling_timer_on == 0) rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer); @@ -837,7 +834,6 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->blinked_ingpio = false; priv->being_init_adapter = false; priv->bdisable_nic = false; - priv->bfirst_init = false; priv->txringcount = 64; priv->rxbuffersize = 9100; priv->rxringcount = MAX_RX_COUNT; @@ -862,7 +858,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->cck_present_attn = 0; priv->rfa_txpowertrackingindex = 0; priv->rfc_txpowertrackingindex = 0; - priv->CckPwEnl = 6; + priv->cck_pwr_enl = 6; priv->rst_progress = RESET_TYPE_NORESET; priv->force_reset = false; memset(priv->rtllib->swcamtable, 0, sizeof(struct sw_cam_table) * 32); @@ -872,7 +868,7 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->rtllib->rf_off_reason = 0; priv->rf_change_in_progress = false; priv->hw_rf_off_action = 0; - priv->SetRFPowerStateInProgress = false; + priv->set_rf_pwr_state_in_progress = false; priv->rtllib->pwr_save_ctrl.bLeisurePs = true; priv->rtllib->LPSDelayCnt = 0; priv->rtllib->sta_sleep = LPS_IS_WAKE; @@ -891,8 +887,8 @@ static void _rtl92e_init_priv_variable(struct net_device *dev) priv->card_type = PCI; - priv->pFirmware = vzalloc(sizeof(struct rt_firmware)); - if (!priv->pFirmware) + priv->fw_info = vzalloc(sizeof(struct rt_firmware)); + if (!priv->fw_info) netdev_err(dev, "rtl8192e: Unable to allocate space for firmware\n"); @@ -952,13 +948,13 @@ static short _rtl92e_get_channel_map(struct net_device *dev) return -1; } - if (priv->ChannelPlan >= COUNTRY_CODE_MAX) { + if (priv->chnl_plan >= COUNTRY_CODE_MAX) { netdev_info(dev, "rtl819x_init:Error channel plan! Set to default.\n"); - priv->ChannelPlan = COUNTRY_CODE_FCC; + priv->chnl_plan = COUNTRY_CODE_FCC; } dot11d_init(priv->rtllib); - dot11d_channel_map(priv->ChannelPlan, priv->rtllib); + dot11d_channel_map(priv->chnl_plan, priv->rtllib); for (i = 1; i <= 11; i++) (priv->rtllib->active_channel_map)[i] = 1; (priv->rtllib->active_channel_map)[12] = 2; @@ -1138,7 +1134,7 @@ static void _rtl92e_if_silent_reset(struct net_device *dev) goto END; } priv->rf_change_in_progress = true; - priv->bResetInProgress = true; + priv->reset_in_progress = true; spin_unlock_irqrestore(&priv->rf_ps_lock, flag); RESET_START: @@ -1229,7 +1225,7 @@ RESET_START: END: priv->rst_progress = RESET_TYPE_NORESET; priv->reset_count++; - priv->bResetInProgress = false; + priv->reset_in_progress = false; rtl92e_writeb(dev, UFWP, 1); } @@ -1397,7 +1393,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) if ((priv->force_reset || ResetType == RESET_TYPE_SILENT)) _rtl92e_if_silent_reset(dev); priv->force_reset = false; - priv->bResetInProgress = false; + priv->reset_in_progress = false; } static void _rtl92e_watchdog_timer_cb(struct timer_list *t) @@ -1486,7 +1482,7 @@ static void _rtl92e_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, u8 queue_index = tcb_desc->queue_index; if ((priv->rtllib->rf_power_state == rf_off) || !priv->up || - priv->bResetInProgress) { + priv->reset_in_progress) { kfree_skb(skb); return; } @@ -1519,7 +1515,7 @@ static int _rtl92e_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) if (queue_index != TXCMD_QUEUE) { if ((priv->rtllib->rf_power_state == rf_off) || - !priv->up || priv->bResetInProgress) { + !priv->up || priv->reset_in_progress) { kfree_skb(skb); return 0; } @@ -1620,11 +1616,7 @@ static short _rtl92e_tx(struct net_device *dev, struct sk_buff *skb) type = WLAN_FC_GET_TYPE(fc); pda_addr = header->addr1; - if (is_broadcast_ether_addr(pda_addr)) - priv->stats.txbytesbroadcast += skb->len - fwinfo_size; - else if (is_multicast_ether_addr(pda_addr)) - priv->stats.txbytesmulticast += skb->len - fwinfo_size; - else + if (!is_broadcast_ether_addr(pda_addr) && !is_multicast_ether_addr(pda_addr)) priv->stats.txbytesunicast += skb->len - fwinfo_size; spin_lock_irqsave(&priv->irq_th_lock, flags); @@ -1654,7 +1646,7 @@ static short _rtl92e_tx(struct net_device *dev, struct sk_buff *skb) spin_unlock_irqrestore(&priv->irq_th_lock, flags); netif_trans_update(dev); - rtl92e_writew(dev, TPPoll, 0x01 << tcb_desc->queue_index); + rtl92e_writew(dev, TP_POLL, 0x01 << tcb_desc->queue_index); return 0; } @@ -1807,9 +1799,9 @@ void rtl92e_update_rx_pkt_timestamp(struct net_device *dev, struct r8192_priv *priv = rtllib_priv(dev); if (stats->bIsAMPDU && !stats->bFirstMPDU) - stats->mac_time = priv->LastRxDescTSF; + stats->mac_time = priv->last_rx_desc_tsf; else - priv->LastRxDescTSF = stats->mac_time; + priv->last_rx_desc_tsf = stats->mac_time; } long rtl92e_translate_to_dbm(struct r8192_priv *priv, u8 signal_strength_index) @@ -1914,7 +1906,7 @@ static void _rtl92e_rx_normal(struct net_device *dev) skb_put(skb, pdesc->Length); skb_reserve(skb, stats.RxDrvInfoSize + stats.RxBufShift); - skb_trim(skb, skb->len - 4/*sCrcLng*/); + skb_trim(skb, skb->len - S_CRC_LEN); rtllib_hdr = (struct rtllib_hdr_1addr *)skb->data; if (!is_multicast_ether_addr(rtllib_hdr->addr1)) { /* unicast packet */ @@ -1930,19 +1922,11 @@ static void _rtl92e_rx_normal(struct net_device *dev) priv->rtllib->LedControlHandler(dev, LED_CTL_RX); - if (stats.bCRC) { - if (type != RTLLIB_FTYPE_MGMT) - priv->stats.rxdatacrcerr++; - else - priv->stats.rxmgmtcrcerr++; - } - skb_len = skb->len; if (!rtllib_rx(priv->rtllib, skb, &stats)) { dev_kfree_skb_any(skb); } else { - priv->stats.rxok++; if (unicast_packet) priv->stats.rxbytesunicast += skb_len; } @@ -2135,7 +2119,6 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) spin_lock_irqsave(&priv->irq_th_lock, flags); priv->ops->interrupt_recognized(dev, &inta, &intb); - priv->stats.shints++; if (!inta) { spin_unlock_irqrestore(&priv->irq_th_lock, flags); @@ -2147,21 +2130,12 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) goto done; } - priv->stats.ints++; - if (!netif_running(dev)) { spin_unlock_irqrestore(&priv->irq_th_lock, flags); goto done; } - if (inta & IMR_TBDOK) - priv->stats.txbeaconokint++; - - if (inta & IMR_TBDER) - priv->stats.txbeaconerr++; - if (inta & IMR_MGNTDOK) { - priv->stats.txmanageokint++; _rtl92e_tx_isr(dev, MGNT_QUEUE); spin_unlock_irqrestore(&priv->irq_th_lock, flags); if (priv->rtllib->ack_tx_to_ieee) { @@ -2173,57 +2147,43 @@ static irqreturn_t _rtl92e_irq(int irq, void *netdev) spin_lock_irqsave(&priv->irq_th_lock, flags); } - if (inta & IMR_COMDOK) { - priv->stats.txcmdpktokint++; + if (inta & IMR_COMDOK) _rtl92e_tx_isr(dev, TXCMD_QUEUE); - } if (inta & IMR_HIGHDOK) _rtl92e_tx_isr(dev, HIGH_QUEUE); - if (inta & IMR_ROK) { - priv->stats.rxint++; + if (inta & IMR_ROK) tasklet_schedule(&priv->irq_rx_tasklet); - } if (inta & IMR_BcnInt) tasklet_schedule(&priv->irq_prepare_beacon_tasklet); if (inta & IMR_RDU) { - priv->stats.rxrdu++; rtl92e_writel(dev, INTA_MASK, rtl92e_readl(dev, INTA_MASK) & ~IMR_RDU); tasklet_schedule(&priv->irq_rx_tasklet); } - if (inta & IMR_RXFOVW) { - priv->stats.rxoverflow++; + if (inta & IMR_RXFOVW) tasklet_schedule(&priv->irq_rx_tasklet); - } - - if (inta & IMR_TXFOVW) - priv->stats.txoverflow++; if (inta & IMR_BKDOK) { - priv->stats.txbkokint++; priv->rtllib->link_detect_info.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, BK_QUEUE); } if (inta & IMR_BEDOK) { - priv->stats.txbeokint++; priv->rtllib->link_detect_info.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, BE_QUEUE); } if (inta & IMR_VIDOK) { - priv->stats.txviokint++; priv->rtllib->link_detect_info.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, VI_QUEUE); } if (inta & IMR_VODOK) { - priv->stats.txvookint++; priv->rtllib->link_detect_info.NumTxOkInPeriod++; _rtl92e_tx_isr(dev, VO_QUEUE); } @@ -2386,8 +2346,8 @@ static void _rtl92e_pci_disconnect(struct pci_dev *pdev) priv->polling_timer_on = 0; _rtl92e_down(dev, true); rtl92e_dm_deinit(dev); - vfree(priv->pFirmware); - priv->pFirmware = NULL; + vfree(priv->fw_info); + priv->fw_info = NULL; _rtl92e_free_rx_ring(dev); for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) _rtl92e_free_tx_ring(dev, i); @@ -2423,7 +2383,6 @@ bool rtl92e_enable_nic(struct net_device *dev) return false; } - priv->bfirst_init = true; init_status = priv->ops->initialize_adapter(dev); if (!init_status) { netdev_warn(dev, "%s(): Initialization failed!\n", __func__); @@ -2431,7 +2390,6 @@ bool rtl92e_enable_nic(struct net_device *dev) return false; } RT_CLEAR_PS_LEVEL(psc, RT_RF_OFF_LEVL_HALT_NIC); - priv->bfirst_init = false; rtl92e_irq_enable(dev); priv->bdisable_nic = false; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index cceb77492363..fd96eef90c7f 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -90,11 +90,11 @@ #define PHY_RSSI_SLID_WIN_MAX 100 -#define TxBBGainTableLength 37 -#define CCKTxBBGainTableLength 23 +#define TX_BB_GAIN_TABLE_LEN 37 +#define CCK_TX_BB_GAIN_TABLE_LEN 23 #define CHANNEL_PLAN_LEN 10 -#define sCrcLng 4 +#define S_CRC_LEN 4 #define NIC_SEND_HANG_THRESHOLD_NORMAL 4 #define NIC_SEND_HANG_THRESHOLD_POWERSAVE 8 @@ -145,35 +145,13 @@ enum rt_rf_type_819xu { enum rt_customer_id { RT_CID_DEFAULT = 0, - RT_CID_8187_ALPHA0 = 1, - RT_CID_8187_SERCOMM_PS = 2, - RT_CID_8187_HW_LED = 3, - RT_CID_8187_NETGEAR = 4, - RT_CID_WHQL = 5, RT_CID_819x_CAMEO = 6, RT_CID_819x_RUNTOP = 7, - RT_CID_819x_Senao = 8, RT_CID_TOSHIBA = 9, - RT_CID_819x_Netcore = 10, + RT_CID_819X_NETCORE = 10, RT_CID_Nettronix = 11, RT_CID_DLINK = 12, RT_CID_PRONET = 13, - RT_CID_COREGA = 14, - RT_CID_819x_ALPHA = 15, - RT_CID_819x_Sitecom = 16, - RT_CID_CCX = 17, - RT_CID_819x_Lenovo = 18, - RT_CID_819x_QMI = 19, - RT_CID_819x_Edimax_Belkin = 20, - RT_CID_819x_Sercomm_Belkin = 21, - RT_CID_819x_CAMEO1 = 22, - RT_CID_819x_MSI = 23, - RT_CID_819x_Acer = 24, - RT_CID_819x_HP = 27, - RT_CID_819x_CLEVO = 28, - RT_CID_819x_Arcadyan_Belkin = 29, - RT_CID_819x_SAMSUNG = 30, - RT_CID_819x_WNC_COREGA = 31, }; enum reset_type { @@ -183,37 +161,7 @@ enum reset_type { }; struct rt_stats { - unsigned long rxrdu; - unsigned long rxok; - unsigned long rxdatacrcerr; - unsigned long rxmgmtcrcerr; - unsigned long rxcrcerrmin; - unsigned long rxcrcerrmid; - unsigned long rxcrcerrmax; unsigned long received_rate_histogram[4][32]; - unsigned long received_preamble_GI[2][32]; - unsigned long numpacket_matchbssid; - unsigned long numpacket_toself; - unsigned long num_process_phyinfo; - unsigned long numqry_phystatus; - unsigned long numqry_phystatusCCK; - unsigned long numqry_phystatusHT; - unsigned long received_bwtype[5]; - unsigned long rxoverflow; - unsigned long rxint; - unsigned long ints; - unsigned long shints; - unsigned long txoverflow; - unsigned long txbeokint; - unsigned long txbkokint; - unsigned long txviokint; - unsigned long txvookint; - unsigned long txbeaconokint; - unsigned long txbeaconerr; - unsigned long txmanageokint; - unsigned long txcmdpktokint; - unsigned long txbytesmulticast; - unsigned long txbytesbroadcast; unsigned long txbytesunicast; unsigned long rxbytesunicast; unsigned long txretrycount; @@ -223,14 +171,12 @@ struct rt_stats { unsigned long slide_rssi_total; unsigned long slide_evm_total; long signal_strength; - long signal_quality; long last_signal_strength_inpercent; long recv_signal_power; u8 rx_rssi_percentage[4]; u8 rx_evm_percentage[2]; - long rxSNRdB[4]; - u32 Slide_Beacon_pwdb[100]; - u32 Slide_Beacon_Total; + u32 slide_beacon_pwdb[100]; + u32 slide_beacon_total; u32 CurrentShowTxate; }; @@ -257,8 +203,6 @@ struct rtl8192_tx_ring { struct sk_buff_head queue; }; - - struct rtl819x_ops { enum nic_t nic_type; void (*get_eeprom_size)(struct net_device *dev); @@ -298,7 +242,6 @@ struct r8192_priv { struct pci_dev *pdev; struct pci_dev *bridge_pdev; - bool bfirst_init; bool bfirst_after_down; bool being_init_adapter; @@ -317,16 +260,15 @@ struct r8192_priv { struct work_struct reset_wq; - enum rt_customer_id CustomerID; - + enum rt_customer_id customer_id; enum rt_rf_type_819xu rf_chip; - enum ht_channel_width CurrentChannelBW; - struct bb_reg_definition PHYRegDef[4]; + enum ht_channel_width current_chnl_bw; + struct bb_reg_definition phy_reg_def[4]; struct rate_adaptive rate_adaptive; - struct rt_firmware *pFirmware; - enum rtl819x_loopback LoopbackMode; + struct rt_firmware *fw_info; + enum rtl819x_loopback loopback_mode; struct timer_list watch_dog_timer; struct timer_list fsync_timer; @@ -360,9 +302,9 @@ struct r8192_priv { int rxringcount; u16 rxbuffersize; - u64 LastRxDescTSF; + u64 last_rx_desc_tsf; - u32 ReceiveConfig; + u32 receive_config; u8 retry_data; u8 retry_rts; u16 rts; @@ -371,8 +313,8 @@ struct r8192_priv { int txringcount; atomic_t tx_pending[0x10]; - u16 ShortRetryLimit; - u16 LongRetryLimit; + u16 short_retry_limit; + u16 long_retry_limit; bool hw_radio_off; bool blinked_ingpio; @@ -396,94 +338,82 @@ struct r8192_priv { u32 irq_mask[2]; - u8 Rf_Mode; + u8 rf_mode; enum nic_t card_8192; u8 card_8192_version; u8 rf_type; - u8 IC_Cut; + u8 ic_cut; char nick[IW_ESSID_MAX_SIZE + 1]; u8 check_roaming_cnt; - u32 SilentResetRxSlotIndex; - u32 SilentResetRxStuckEvent[MAX_SILENT_RESET_RX_SLOT_NUM]; + u32 silent_reset_rx_slot_index; + u32 silent_reset_rx_stuck_event[MAX_SILENT_RESET_RX_SLOT_NUM]; u16 basic_rate; u8 short_preamble; u8 dot11_current_preamble_mode; u8 slot_time; - u16 SifsTime; - bool AutoloadFailFlag; + bool autoload_fail_flag; short epromtype; u16 eeprom_vid; u16 eeprom_did; - u8 eeprom_CustomerID; - u16 eeprom_ChannelPlan; + u8 eeprom_customer_id; + u16 eeprom_chnl_plan; - u8 EEPROMTxPowerLevelCCK[14]; - u8 EEPROMTxPowerLevelOFDM24G[14]; - u8 EEPROMRfACCKChnl1TxPwLevel[3]; - u8 EEPROMRfAOfdmChnlTxPwLevel[3]; - u8 EEPROMRfCCCKChnl1TxPwLevel[3]; - u8 EEPROMRfCOfdmChnlTxPwLevel[3]; - u16 EEPROMAntPwDiff; - u8 EEPROMThermalMeter; - u8 EEPROMCrystalCap; + u8 eeprom_tx_pwr_level_cck[14]; + u8 eeprom_tx_pwr_level_ofdm24g[14]; + u16 eeprom_ant_pwr_diff; + u8 eeprom_thermal_meter; + u8 eeprom_crystal_cap; - u8 EEPROMLegacyHTTxPowerDiff; + u8 eeprom_legacy_ht_tx_pwr_diff; - u8 CrystalCap; - u8 ThermalMeter[2]; + u8 crystal_cap; + u8 thermal_meter[2]; - u8 SwChnlInProgress; - u8 SwChnlStage; - u8 SwChnlStep; - u8 SetBWModeInProgress; + u8 sw_chnl_in_progress; + u8 sw_chnl_stage; + u8 sw_chnl_step; + u8 set_bw_mode_in_progress; - u8 nCur40MhzPrimeSC; + u8 n_cur_40mhz_prime_sc; - u32 RfReg0Value[4]; - u8 NumTotalRFPath; + u32 rf_reg_0value[4]; + u8 num_total_rf_path; bool brfpath_rxenable[4]; - bool bTXPowerDataReadFromEEPORM; + bool tx_pwr_data_read_from_eeprom; u16 reg_chnl_plan; - u16 ChannelPlan; + u16 chnl_plan; u8 hw_rf_off_action; bool rf_change_in_progress; - bool SetRFPowerStateInProgress; + bool set_rf_pwr_state_in_progress; bool bdisable_nic; - u8 DM_Type; - - u8 CckPwEnl; - u16 TSSI_13dBm; - u32 Pwr_Track; - u8 CCKPresentAttentuation_20Mdefault; - u8 CCKPresentAttentuation_40Mdefault; - s8 CCKPresentAttentuation_difference; + u8 cck_pwr_enl; + u16 tssi_13dBm; + u32 pwr_track; + u8 cck_present_attn_20m_def; + u8 cck_present_attn_40m_def; + s8 cck_present_attn_diff; s8 cck_present_attn; long undecorated_smoothed_pwdb; - u32 MCSTxPowerLevelOriginalOffset[6]; - u8 TxPowerLevelCCK[14]; - u8 TxPowerLevelCCK_A[14]; - u8 TxPowerLevelCCK_C[14]; - u8 TxPowerLevelOFDM24G[14]; - u8 TxPowerLevelOFDM24G_A[14]; - u8 TxPowerLevelOFDM24G_C[14]; - u8 LegacyHTTxPowerDiff; - s8 RF_C_TxPwDiff; - u8 AntennaTxPwDiff[3]; - - bool bDynamicTxHighPower; - bool bDynamicTxLowPower; - bool bLastDTPFlag_High; - bool bLastDTPFlag_Low; + u32 mcs_tx_pwr_level_org_offset[6]; + u8 tx_pwr_level_cck[14]; + u8 tx_pwr_level_ofdm_24g[14]; + u8 legacy_ht_tx_pwr_diff; + u8 antenna_tx_pwr_diff[3]; + + bool dynamic_tx_high_pwr; + bool dynamic_tx_low_pwr; + bool last_dtp_flag_high; + bool last_dtp_flag_low; u8 rfa_txpowertrackingindex; u8 rfa_txpowertrackingindex_real; @@ -494,42 +424,38 @@ struct r8192_priv { bool bcck_in_ch14; u8 txpower_count; - bool btxpower_trackingInit; + bool tx_pwr_tracking_init; - u8 OFDM_index[2]; - u8 CCK_index; + u8 ofdm_index[2]; + u8 cck_index; - u8 Record_CCK_20Mindex; - u8 Record_CCK_40Mindex; + u8 rec_cck_20m_idx; + u8 rec_cck_40m_idx; struct init_gain initgain_backup; - u8 DefaultInitialGain[4]; + u8 def_initial_gain[4]; bool bis_any_nonbepkts; bool bcurrent_turbo_EDCA; bool bis_cur_rdlstate; bool bfsync_processing; u32 rate_record; - u32 rateCountDiffRecord; - u32 ContinueDiffCount; + u32 rate_count_diff_rec; + u32 continue_diff_count; bool bswitch_fsync; u8 framesync; - u32 framesyncC34; - u8 framesyncMonitor; + u8 frame_sync_monitor; u32 reset_count; enum reset_type rst_progress; - u16 TxCounter; + u16 tx_counter; u16 rx_ctr; - bool bResetInProgress; + bool reset_in_progress; bool force_reset; bool force_lps; bool chan_forced; - - u8 PwrDomainProtect; - u8 H2CTxCmdSeq; }; extern const struct ethtool_ops rtl819x_ethtool_ops; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index a18393c8a833..d8455b23e555 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -46,7 +46,7 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = { 0x5e4332 }; -const u32 dm_tx_bb_gain[TxBBGainTableLength] = { +const u32 dm_tx_bb_gain[TX_BB_GAIN_TABLE_LEN] = { 0x7f8001fe, /* 12 dB */ 0x788001e2, /* 11 dB */ 0x71c001c7, @@ -86,7 +86,7 @@ const u32 dm_tx_bb_gain[TxBBGainTableLength] = { 0x10000040, /* -24 dB */ }; -const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8] = { +const u8 dm_cck_tx_bb_gain[CCK_TX_BB_GAIN_TABLE_LEN][8] = { {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, @@ -112,7 +112,7 @@ const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8] = { {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} }; -const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8] = { +const u8 dm_cck_tx_bb_gain_ch14[CCK_TX_BB_GAIN_TABLE_LEN][8] = { {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, @@ -144,7 +144,7 @@ const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8] = { /*------------------------Define global variable-----------------------------*/ struct dig_t dm_digtable; -struct drx_path_sel DM_RxPathSelTable; +struct drx_path_sel dm_rx_path_sel_table; /*------------------------Define global variable-----------------------------*/ @@ -203,8 +203,6 @@ void rtl92e_dm_init(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - priv->DM_Type = DM_Type_ByDriver; - priv->undecorated_smoothed_pwdb = -1; _rtl92e_dm_init_dynamic_tx_power(dev); @@ -284,15 +282,15 @@ void rtl92e_init_adaptive_rate(struct net_device *dev) struct rate_adaptive *pra = &priv->rate_adaptive; pra->ratr_state = DM_RATR_STA_MAX; - pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High; - pra->low2high_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M+5; - pra->low2high_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M+5; + pra->high2low_rssi_thresh_for_ra = RATE_ADAPTIVE_TH_HIGH; + pra->low2high_rssi_thresh_for_ra20M = RATE_ADAPTIVE_TH_LOW_20M + 5; + pra->low2high_rssi_thresh_for_ra40M = RATE_ADAPTIVE_TH_LOW_40M + 5; - pra->high_rssi_thresh_for_ra = RateAdaptiveTH_High+5; - pra->low_rssi_thresh_for_ra20M = RateAdaptiveTH_Low_20M; - pra->low_rssi_thresh_for_ra40M = RateAdaptiveTH_Low_40M; + pra->high_rssi_thresh_for_ra = RATE_ADAPTIVE_TH_HIGH + 5; + pra->low_rssi_thresh_for_ra20M = RATE_ADAPTIVE_TH_LOW_20M; + pra->low_rssi_thresh_for_ra40M = RATE_ADAPTIVE_TH_LOW_40M; - if (priv->CustomerID == RT_CID_819x_Netcore) + if (priv->customer_id == RT_CID_819X_NETCORE) pra->ping_rssi_enable = 1; else pra->ping_rssi_enable = 0; @@ -353,7 +351,7 @@ static void _rtl92e_dm_check_rate_adaptive(struct net_device *dev) (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) { pra->low_rssi_threshold_ratr = (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0); @@ -368,15 +366,15 @@ static void _rtl92e_dm_check_rate_adaptive(struct net_device *dev) if (pra->ratr_state == DM_RATR_STA_HIGH) { HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + LowRSSIThreshForRA = (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) ? (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } else if (pra->ratr_state == DM_RATR_STA_LOW) { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + LowRSSIThreshForRA = (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) ? (pra->low2high_rssi_thresh_for_ra40M) : (pra->low2high_rssi_thresh_for_ra20M); } else { HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra; - LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? + LowRSSIThreshForRA = (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) ? (pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M); } @@ -443,8 +441,8 @@ static void _rtl92e_dm_bandwidth_autoswitch(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 || - !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable) + if (priv->current_chnl_bw == HT_CHANNEL_WIDTH_20 || + !priv->rtllib->bandwidth_auto_switch.bautoswitch_enable) return; if (!priv->rtllib->bandwidth_auto_switch.bforced_tx20Mhz) { if (priv->undecorated_smoothed_pwdb <= @@ -457,7 +455,7 @@ static void _rtl92e_dm_bandwidth_autoswitch(struct net_device *dev) } } -static u32 OFDMSwingTable[OFDM_Table_Length] = { +static u32 OFDMSwingTable[OFDM_TABLE_LEN] = { 0x7f8001fe, 0x71c001c7, 0x65400195, @@ -479,7 +477,7 @@ static u32 OFDMSwingTable[OFDM_Table_Length] = { 0x10000040 }; -static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { +static u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_LEN][8] = { {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, @@ -494,7 +492,7 @@ static u8 CCKSwingTable_Ch1_Ch13[CCK_Table_length][8] = { {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01} }; -static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = { +static u8 CCKSwingTable_Ch14[CCK_TABLE_LEN][8] = { {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, @@ -570,8 +568,8 @@ static void _rtl92e_dm_tx_update_tssi_strong_signal(struct net_device *dev, struct r8192_priv *p = rtllib_priv(dev); if (RF_Type == RF_2T4R) { - if ((p->rfa_txpowertrackingindex < TxBBGainTableLength - 1) && - (p->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) { + if ((p->rfa_txpowertrackingindex < TX_BB_GAIN_TABLE_LEN - 1) && + (p->rfc_txpowertrackingindex < TX_BB_GAIN_TABLE_LEN - 1)) { p->rfa_txpowertrackingindex++; p->rfa_txpowertrackingindex_real++; rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, @@ -585,13 +583,13 @@ static void _rtl92e_dm_tx_update_tssi_strong_signal(struct net_device *dev, } else { rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - dm_tx_bb_gain[TxBBGainTableLength - 1]); + dm_tx_bb_gain[TX_BB_GAIN_TABLE_LEN - 1]); rtl92e_set_bb_reg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord, - dm_tx_bb_gain[TxBBGainTableLength - 1]); + dm_tx_bb_gain[TX_BB_GAIN_TABLE_LEN - 1]); } } else { - if (p->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) { + if (p->rfa_txpowertrackingindex < (TX_BB_GAIN_TABLE_LEN - 1)) { p->rfa_txpowertrackingindex++; p->rfa_txpowertrackingindex_real++; rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, @@ -600,7 +598,7 @@ static void _rtl92e_dm_tx_update_tssi_strong_signal(struct net_device *dev, } else { rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - dm_tx_bb_gain[TxBBGainTableLength - 1]); + dm_tx_bb_gain[TX_BB_GAIN_TABLE_LEN - 1]); } } } @@ -615,14 +613,14 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) u8 RF_Type, tmp_report[5] = {0, 0, 0, 0, 0}; u32 Value; u8 Pwr_Flag; - u16 Avg_TSSI_Meas, TSSI_13dBm, Avg_TSSI_Meas_from_driver = 0; + u16 Avg_TSSI_Meas, tssi_13dBm, Avg_TSSI_Meas_from_driver = 0; u32 delta = 0; rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); priv->rtllib->bdynamic_txpower_enable = false; - powerlevelOFDM24G = priv->Pwr_Track >> 24; + powerlevelOFDM24G = priv->pwr_track >> 24; RF_Type = priv->rf_type; Value = (RF_Type<<8) | powerlevelOFDM24G; @@ -640,7 +638,7 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) if (Pwr_Flag == 0) { mdelay(1); - if (priv->bResetInProgress) { + if (priv->reset_in_progress) { rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); return; @@ -688,12 +686,12 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) Avg_TSSI_Meas_from_driver += tmp_report[k]; Avg_TSSI_Meas_from_driver *= 100 / 5; - TSSI_13dBm = priv->TSSI_13dBm; + tssi_13dBm = priv->tssi_13dBm; - if (Avg_TSSI_Meas_from_driver > TSSI_13dBm) - delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm; + if (Avg_TSSI_Meas_from_driver > tssi_13dBm) + delta = Avg_TSSI_Meas_from_driver - tssi_13dBm; else - delta = TSSI_13dBm - Avg_TSSI_Meas_from_driver; + delta = tssi_13dBm - Avg_TSSI_Meas_from_driver; if (delta <= E_FOR_TX_POWER_TRACK) { priv->rtllib->bdynamic_txpower_enable = true; @@ -701,36 +699,36 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) rtl92e_writeb(dev, FW_Busy_Flag, 0); return; } - if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) + if (Avg_TSSI_Meas_from_driver < tssi_13dBm - E_FOR_TX_POWER_TRACK) _rtl92e_dm_tx_update_tssi_weak_signal(dev, RF_Type); else _rtl92e_dm_tx_update_tssi_strong_signal(dev, RF_Type); if (RF_Type == RF_2T4R) { - priv->CCKPresentAttentuation_difference + priv->cck_present_attn_diff = priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default; } else { - priv->CCKPresentAttentuation_difference + priv->cck_present_attn_diff = priv->rfa_txpowertrackingindex_real - priv->rfa_txpowertracking_default; } - if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw == HT_CHANNEL_WIDTH_20) priv->cck_present_attn = - priv->CCKPresentAttentuation_20Mdefault + - priv->CCKPresentAttentuation_difference; + priv->cck_present_attn_20m_def + + priv->cck_present_attn_diff; else priv->cck_present_attn = - priv->CCKPresentAttentuation_40Mdefault + - priv->CCKPresentAttentuation_difference; + priv->cck_present_attn_40m_def + + priv->cck_present_attn_diff; - if (priv->cck_present_attn > (CCKTxBBGainTableLength-1)) - priv->cck_present_attn = CCKTxBBGainTableLength-1; + if (priv->cck_present_attn > (CCK_TX_BB_GAIN_TABLE_LEN - 1)) + priv->cck_present_attn = CCK_TX_BB_GAIN_TABLE_LEN - 1; if (priv->cck_present_attn < 0) priv->cck_present_attn = 0; if (priv->cck_present_attn > -1 && - priv->cck_present_attn < CCKTxBBGainTableLength) { + priv->cck_present_attn < CCK_TX_BB_GAIN_TABLE_LEN) { if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) { priv->bcck_in_ch14 = true; @@ -742,8 +740,8 @@ static void _rtl92e_dm_tx_power_tracking_callback_tssi(struct net_device *dev) rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); } - if (priv->CCKPresentAttentuation_difference <= -12 || - priv->CCKPresentAttentuation_difference >= 24) { + if (priv->cck_present_attn_diff <= -12 || + priv->cck_present_attn_diff >= 24) { priv->rtllib->bdynamic_txpower_enable = true; rtl92e_writeb(dev, Pw_Track_Flag, 0); rtl92e_writeb(dev, FW_Busy_Flag, 0); @@ -770,22 +768,22 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) u8 tmpOFDMindex, tmpCCKindex, tmpCCK20Mindex, tmpCCK40Mindex, tmpval; int i = 0, CCKSwingNeedUpdate = 0; - if (!priv->btxpower_trackingInit) { + if (!priv->tx_pwr_tracking_init) { tmpRegA = rtl92e_get_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); - for (i = 0; i < OFDM_Table_Length; i++) { + for (i = 0; i < OFDM_TABLE_LEN; i++) { if (tmpRegA == OFDMSwingTable[i]) - priv->OFDM_index[0] = i; + priv->ofdm_index[0] = i; } TempCCk = rtl92e_get_bb_reg(dev, rCCK0_TxFilter1, bMaskByte2); - for (i = 0; i < CCK_Table_length; i++) { + for (i = 0; i < CCK_TABLE_LEN; i++) { if (TempCCk == (u32)CCKSwingTable_Ch1_Ch13[i][0]) { - priv->CCK_index = i; + priv->cck_index = i; break; } } - priv->btxpower_trackingInit = true; + priv->tx_pwr_tracking_init = true; return; } @@ -794,21 +792,21 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) return; if (tmpRegA >= 12) tmpRegA = 12; - priv->ThermalMeter[0] = ThermalMeterVal; - priv->ThermalMeter[1] = ThermalMeterVal; + priv->thermal_meter[0] = ThermalMeterVal; + priv->thermal_meter[1] = ThermalMeterVal; - if (priv->ThermalMeter[0] >= (u8)tmpRegA) { - tmpOFDMindex = tmpCCK20Mindex = 6+(priv->ThermalMeter[0] - + if (priv->thermal_meter[0] >= (u8)tmpRegA) { + tmpOFDMindex = tmpCCK20Mindex = 6+(priv->thermal_meter[0] - (u8)tmpRegA); tmpCCK40Mindex = tmpCCK20Mindex - 6; - if (tmpOFDMindex >= OFDM_Table_Length) - tmpOFDMindex = OFDM_Table_Length-1; - if (tmpCCK20Mindex >= CCK_Table_length) - tmpCCK20Mindex = CCK_Table_length-1; - if (tmpCCK40Mindex >= CCK_Table_length) - tmpCCK40Mindex = CCK_Table_length-1; + if (tmpOFDMindex >= OFDM_TABLE_LEN) + tmpOFDMindex = OFDM_TABLE_LEN - 1; + if (tmpCCK20Mindex >= CCK_TABLE_LEN) + tmpCCK20Mindex = CCK_TABLE_LEN - 1; + if (tmpCCK40Mindex >= CCK_TABLE_LEN) + tmpCCK40Mindex = CCK_TABLE_LEN - 1; } else { - tmpval = (u8)tmpRegA - priv->ThermalMeter[0]; + tmpval = (u8)tmpRegA - priv->thermal_meter[0]; if (tmpval >= 6) { tmpOFDMindex = 0; tmpCCK20Mindex = 0; @@ -818,13 +816,13 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) } tmpCCK40Mindex = 0; } - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) tmpCCKindex = tmpCCK40Mindex; else tmpCCKindex = tmpCCK20Mindex; - priv->Record_CCK_20Mindex = tmpCCK20Mindex; - priv->Record_CCK_40Mindex = tmpCCK40Mindex; + priv->rec_cck_20m_idx = tmpCCK20Mindex; + priv->rec_cck_40m_idx = tmpCCK40Mindex; if (priv->rtllib->current_network.channel == 14 && !priv->bcck_in_ch14) { @@ -836,17 +834,17 @@ static void _rtl92e_dm_tx_power_tracking_cb_thermal(struct net_device *dev) CCKSwingNeedUpdate = 1; } - if (priv->CCK_index != tmpCCKindex) { - priv->CCK_index = tmpCCKindex; + if (priv->cck_index != tmpCCKindex) { + priv->cck_index = tmpCCKindex; CCKSwingNeedUpdate = 1; } if (CCKSwingNeedUpdate) rtl92e_dm_cck_txpower_adjust(dev, priv->bcck_in_ch14); - if (priv->OFDM_index[0] != tmpOFDMindex) { - priv->OFDM_index[0] = tmpOFDMindex; + if (priv->ofdm_index[0] != tmpOFDMindex) { + priv->ofdm_index[0] = tmpOFDMindex; rtl92e_set_bb_reg(dev, rOFDM0_XATxIQImbalance, bMaskDWord, - OFDMSwingTable[priv->OFDM_index[0]]); + OFDMSwingTable[priv->ofdm_index[0]]); } priv->txpower_count = 0; } @@ -857,7 +855,7 @@ void rtl92e_dm_txpower_tracking_wq(void *data) struct r8192_priv, txpower_tracking_wq); struct net_device *dev = priv->rtllib->dev; - if (priv->IC_Cut >= IC_VersionCut_D) + if (priv->ic_cut >= IC_VersionCut_D) _rtl92e_dm_tx_power_tracking_callback_tssi(dev); else _rtl92e_dm_tx_power_tracking_cb_thermal(dev); @@ -870,7 +868,7 @@ static void _rtl92e_dm_initialize_tx_power_tracking_tssi(struct net_device *dev) priv->btxpower_tracking = true; priv->txpower_count = 0; - priv->btxpower_trackingInit = false; + priv->tx_pwr_tracking_init = false; } @@ -884,14 +882,14 @@ static void _rtl92e_dm_init_tx_power_tracking_thermal(struct net_device *dev) else priv->btxpower_tracking = false; priv->txpower_count = 0; - priv->btxpower_trackingInit = false; + priv->tx_pwr_tracking_init = false; } void rtl92e_dm_init_txpower_tracking(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->IC_Cut >= IC_VersionCut_D) + if (priv->ic_cut >= IC_VersionCut_D) _rtl92e_dm_initialize_tx_power_tracking_tssi(dev); else _rtl92e_dm_init_tx_power_tracking_thermal(dev); @@ -952,7 +950,7 @@ static void _rtl92e_dm_check_tx_power_tracking(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->IC_Cut >= IC_VersionCut_D) + if (priv->ic_cut >= IC_VersionCut_D) _rtl92e_dm_check_tx_power_tracking_tssi(dev); else _rtl92e_dm_check_tx_power_tracking_thermal(dev); @@ -1005,30 +1003,30 @@ static void _rtl92e_dm_cck_tx_power_adjust_thermal_meter(struct net_device *dev, TempVal = 0; if (!bInCH14) { - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1] << 8); + TempVal = CCKSwingTable_Ch1_Ch13[priv->cck_index][0] + + (CCKSwingTable_Ch1_Ch13[priv->cck_index][1] << 8); rtl92e_set_bb_reg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3] << 8) + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4] << 16)+ - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5] << 24); + TempVal = CCKSwingTable_Ch1_Ch13[priv->cck_index][2] + + (CCKSwingTable_Ch1_Ch13[priv->cck_index][3] << 8) + + (CCKSwingTable_Ch1_Ch13[priv->cck_index][4] << 16)+ + (CCKSwingTable_Ch1_Ch13[priv->cck_index][5] << 24); rtl92e_set_bb_reg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] + - (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7] << 8); + TempVal = CCKSwingTable_Ch1_Ch13[priv->cck_index][6] + + (CCKSwingTable_Ch1_Ch13[priv->cck_index][7] << 8); rtl92e_set_bb_reg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } else { - TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] + - (CCKSwingTable_Ch14[priv->CCK_index][1] << 8); + TempVal = CCKSwingTable_Ch14[priv->cck_index][0] + + (CCKSwingTable_Ch14[priv->cck_index][1] << 8); rtl92e_set_bb_reg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal); - TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] + - (CCKSwingTable_Ch14[priv->CCK_index][3] << 8) + - (CCKSwingTable_Ch14[priv->CCK_index][4] << 16)+ - (CCKSwingTable_Ch14[priv->CCK_index][5] << 24); + TempVal = CCKSwingTable_Ch14[priv->cck_index][2] + + (CCKSwingTable_Ch14[priv->cck_index][3] << 8) + + (CCKSwingTable_Ch14[priv->cck_index][4] << 16)+ + (CCKSwingTable_Ch14[priv->cck_index][5] << 24); rtl92e_set_bb_reg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal); - TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] + - (CCKSwingTable_Ch14[priv->CCK_index][7]<<8); + TempVal = CCKSwingTable_Ch14[priv->cck_index][6] + + (CCKSwingTable_Ch14[priv->cck_index][7]<<8); rtl92e_set_bb_reg(dev, rCCK0_DebugPort, bMaskLWord, TempVal); } @@ -1038,7 +1036,7 @@ void rtl92e_dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { struct r8192_priv *priv = rtllib_priv(dev); - if (priv->IC_Cut >= IC_VersionCut_D) + if (priv->ic_cut >= IC_VersionCut_D) _rtl92e_dm_cck_tx_power_adjust_tssi(dev, binch14); else _rtl92e_dm_cck_tx_power_adjust_thermal_meter(dev, binch14); @@ -1075,7 +1073,7 @@ void rtl92e_dm_restore_state(struct net_device *dev) ratr_value &= ~(RATE_ALL_OFDM_2SS); rtl92e_writel(dev, RATR0, ratr_value); rtl92e_writeb(dev, UFWP, 1); - if (priv->btxpower_trackingInit && priv->btxpower_tracking) + if (priv->tx_pwr_tracking_init && priv->btxpower_tracking) _rtl92e_dm_tx_power_reset_recovery(dev); _rtl92e_dm_bb_initialgain_restore(dev); @@ -1150,7 +1148,7 @@ static void _rtl92e_dm_dig_init(struct net_device *dev) dm_digtable.rssi_val = 50; dm_digtable.backoff_val = DM_DIG_BACKOFF; dm_digtable.rx_gain_range_max = DM_DIG_MAX; - if (priv->CustomerID == RT_CID_819x_Netcore) + if (priv->customer_id == RT_CID_819X_NETCORE) dm_digtable.rx_gain_range_min = DM_DIG_MIN_Netcore; else dm_digtable.rx_gain_range_min = DM_DIG_MIN; @@ -1260,7 +1258,7 @@ static void _rtl92e_dm_ctrl_initgain_byrssi_false_alarm(struct net_device *dev) rtl92e_writeb(dev, rOFDM0_XCAGCCore1, 0x17); rtl92e_writeb(dev, rOFDM0_XDAGCCore1, 0x17); - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x00); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x42); @@ -1297,7 +1295,7 @@ static void _rtl92e_dm_ctrl_initgain_byrssi_false_alarm(struct net_device *dev) rtl92e_writeb(dev, rOFDM0_XDAGCCore1, 0x20); } - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x20); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x44); @@ -1328,7 +1326,7 @@ static void _rtl92e_dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) return; dm_digtable.dig_highpwr_state = DM_STA_DIG_ON; - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x10); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x43); @@ -1342,7 +1340,7 @@ static void _rtl92e_dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev) dm_digtable.rssi_high_power_lowthresh) && (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh)) { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x20); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x44); @@ -1378,12 +1376,12 @@ static void _rtl92e_dm_initial_gain(struct net_device *dev) dm_digtable.cur_ig_value = gain_range; } else { if (dm_digtable.cur_ig_value == 0) - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; + dm_digtable.cur_ig_value = priv->def_initial_gain[0]; else dm_digtable.cur_ig_value = dm_digtable.pre_ig_value; } } else { - dm_digtable.cur_ig_value = priv->DefaultInitialGain[0]; + dm_digtable.cur_ig_value = priv->def_initial_gain[0]; dm_digtable.pre_ig_value = 0; } @@ -1453,18 +1451,18 @@ static void _rtl92e_dm_pd_th(struct net_device *dev) if ((dm_digtable.prepd_thstate != dm_digtable.curpd_thstate) || (initialized <= 3) || force_write) { if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x00); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x42); } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x20); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x44); } else if (dm_digtable.curpd_thstate == DIG_PD_AT_HIGH_POWER) { - if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) + if (priv->current_chnl_bw != HT_CHANNEL_WIDTH_20) rtl92e_writeb(dev, (rOFDM0_XATxAFE+3), 0x10); else rtl92e_writeb(dev, rOFDM0_RxDetector1, 0x43); @@ -1651,7 +1649,7 @@ static void _rtl92e_dm_init_wa_broadcom_iot(struct net_device *dev) struct rt_hi_throughput *ht_info = priv->rtllib->ht_info; ht_info->bWAIotBroadcom = false; - ht_info->WAIotTH = WAIotTHVal; + ht_info->WAIotTH = WA_IOT_TH_VAL; } static void _rtl92e_dm_check_rf_ctrl_gpio(void *data) @@ -1722,7 +1720,7 @@ void rtl92e_dm_rf_pathcheck_wq(void *data) else priv->brfpath_rxenable[i] = false; } - if (!DM_RxPathSelTable.Enable) + if (!dm_rx_path_sel_table.enable) return; _rtl92e_dm_rx_path_sel_byrssi(dev); @@ -1733,18 +1731,18 @@ static void _rtl92e_dm_init_rx_path_selection(struct net_device *dev) u8 i; struct r8192_priv *priv = rtllib_priv(dev); - DM_RxPathSelTable.Enable = 1; - DM_RxPathSelTable.SS_TH_low = RxPathSelection_SS_TH_low; - DM_RxPathSelTable.diff_TH = RxPathSelection_diff_TH; - if (priv->CustomerID == RT_CID_819x_Netcore) - DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; + dm_rx_path_sel_table.enable = 1; + dm_rx_path_sel_table.ss_th_low = RX_PATH_SEL_SS_TH_LOW; + dm_rx_path_sel_table.diff_th = RX_PATH_SEL_DIFF_TH; + if (priv->customer_id == RT_CID_819X_NETCORE) + dm_rx_path_sel_table.cck_method = CCK_Rx_Version_2; else - DM_RxPathSelTable.cck_method = CCK_Rx_Version_1; - DM_RxPathSelTable.disabledRF = 0; + dm_rx_path_sel_table.cck_method = CCK_Rx_Version_1; + dm_rx_path_sel_table.disabled_rf = 0; for (i = 0; i < 4; i++) { - DM_RxPathSelTable.rf_rssi[i] = 50; - DM_RxPathSelTable.cck_pwdb_sta[i] = -64; - DM_RxPathSelTable.rf_enable_rssi_th[i] = 100; + dm_rx_path_sel_table.rf_rssi[i] = 50; + dm_rx_path_sel_table.cck_pwdb_sta[i] = -64; + dm_rx_path_sel_table.rf_enable_rssi_th[i] = 100; } } @@ -1771,22 +1769,22 @@ static void _rtl92e_dm_rx_path_sel_byrssi(struct net_device *dev) return; if (!cck_Rx_Path_initialized) { - DM_RxPathSelTable.cck_Rx_path = (rtl92e_readb(dev, 0xa07)&0xf); + dm_rx_path_sel_table.cck_rx_path = (rtl92e_readb(dev, 0xa07)&0xf); cck_Rx_Path_initialized = 1; } - DM_RxPathSelTable.disabledRF = 0xf; - DM_RxPathSelTable.disabledRF &= ~(rtl92e_readb(dev, 0xc04)); + dm_rx_path_sel_table.disabled_rf = 0xf; + dm_rx_path_sel_table.disabled_rf &= ~(rtl92e_readb(dev, 0xc04)); if (priv->rtllib->mode == WIRELESS_MODE_B) - DM_RxPathSelTable.cck_method = CCK_Rx_Version_2; + dm_rx_path_sel_table.cck_method = CCK_Rx_Version_2; for (i = 0; i < RF90_PATH_MAX; i++) { - DM_RxPathSelTable.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; + dm_rx_path_sel_table.rf_rssi[i] = priv->stats.rx_rssi_percentage[i]; if (priv->brfpath_rxenable[i]) { rf_num++; - cur_rf_rssi = DM_RxPathSelTable.rf_rssi[i]; + cur_rf_rssi = dm_rx_path_sel_table.rf_rssi[i]; if (rf_num == 1) { max_rssi_index = min_rssi_index = sec_rssi_index = i; @@ -1834,12 +1832,12 @@ static void _rtl92e_dm_rx_path_sel_byrssi(struct net_device *dev) } rf_num = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + if (dm_rx_path_sel_table.cck_method == CCK_Rx_Version_2) { for (i = 0; i < RF90_PATH_MAX; i++) { if (priv->brfpath_rxenable[i]) { rf_num++; cur_cck_pwdb = - DM_RxPathSelTable.cck_pwdb_sta[i]; + dm_rx_path_sel_table.cck_pwdb_sta[i]; if (rf_num == 1) { cck_rx_ver2_max_index = i; @@ -1896,17 +1894,17 @@ static void _rtl92e_dm_rx_path_sel_byrssi(struct net_device *dev) } update_cck_rx_path = 0; - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_2) { + if (dm_rx_path_sel_table.cck_method == CCK_Rx_Version_2) { cck_default_Rx = cck_rx_ver2_max_index; cck_optional_Rx = cck_rx_ver2_sec_index; if (tmp_cck_max_pwdb != -64) update_cck_rx_path = 1; } - if (tmp_min_rssi < DM_RxPathSelTable.SS_TH_low && disabled_rf_cnt < 2) { + if (tmp_min_rssi < dm_rx_path_sel_table.ss_th_low && disabled_rf_cnt < 2) { if ((tmp_max_rssi - tmp_min_rssi) >= - DM_RxPathSelTable.diff_TH) { - DM_RxPathSelTable.rf_enable_rssi_th[min_rssi_index] = + dm_rx_path_sel_table.diff_th) { + dm_rx_path_sel_table.rf_enable_rssi_th[min_rssi_index] = tmp_max_rssi+5; rtl92e_set_bb_reg(dev, rOFDM0_TRxPathEnable, 0x1<<min_rssi_index, 0x0); @@ -1914,7 +1912,7 @@ static void _rtl92e_dm_rx_path_sel_byrssi(struct net_device *dev) 0x1<<min_rssi_index, 0x0); disabled_rf_cnt++; } - if (DM_RxPathSelTable.cck_method == CCK_Rx_Version_1) { + if (dm_rx_path_sel_table.cck_method == CCK_Rx_Version_1) { cck_default_Rx = max_rssi_index; cck_optional_Rx = sec_rssi_index; if (tmp_max_rssi) @@ -1923,24 +1921,24 @@ static void _rtl92e_dm_rx_path_sel_byrssi(struct net_device *dev) } if (update_cck_rx_path) { - DM_RxPathSelTable.cck_Rx_path = (cck_default_Rx<<2) | + dm_rx_path_sel_table.cck_rx_path = (cck_default_Rx<<2) | (cck_optional_Rx); rtl92e_set_bb_reg(dev, rCCK0_AFESetting, 0x0f000000, - DM_RxPathSelTable.cck_Rx_path); + dm_rx_path_sel_table.cck_rx_path); } - if (DM_RxPathSelTable.disabledRF) { + if (dm_rx_path_sel_table.disabled_rf) { for (i = 0; i < 4; i++) { - if ((DM_RxPathSelTable.disabledRF>>i) & 0x1) { + if ((dm_rx_path_sel_table.disabled_rf >> i) & 0x1) { if (tmp_max_rssi >= - DM_RxPathSelTable.rf_enable_rssi_th[i]) { + dm_rx_path_sel_table.rf_enable_rssi_th[i]) { rtl92e_set_bb_reg(dev, rOFDM0_TRxPathEnable, 0x1 << i, 0x1); rtl92e_set_bb_reg(dev, rOFDM1_TRxPathEnable, 0x1 << i, 0x1); - DM_RxPathSelTable.rf_enable_rssi_th[i] + dm_rx_path_sel_table.rf_enable_rssi_th[i] = 100; disabled_rf_cnt--; } @@ -1969,7 +1967,7 @@ static void _rtl92e_dm_init_fsync(struct net_device *dev) priv->rtllib->fsync_firstdiff_ratethreshold = 100; priv->rtllib->fsync_seconddiff_ratethreshold = 200; priv->rtllib->fsync_state = Default_Fsync; - priv->framesyncMonitor = 1; + priv->frame_sync_monitor = 1; timer_setup(&priv->fsync_timer, _rtl92e_dm_fsync_timer_callback, 0); } @@ -2008,31 +2006,31 @@ static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t) priv->rate_record; else rate_count_diff = rate_count - priv->rate_record; - if (rate_count_diff < priv->rateCountDiffRecord) { + if (rate_count_diff < priv->rate_count_diff_rec) { - u32 DiffNum = priv->rateCountDiffRecord - + u32 DiffNum = priv->rate_count_diff_rec - rate_count_diff; if (DiffNum >= priv->rtllib->fsync_seconddiff_ratethreshold) - priv->ContinueDiffCount++; + priv->continue_diff_count++; else - priv->ContinueDiffCount = 0; + priv->continue_diff_count = 0; - if (priv->ContinueDiffCount >= 2) { + if (priv->continue_diff_count >= 2) { bSwitchFromCountDiff = true; - priv->ContinueDiffCount = 0; + priv->continue_diff_count = 0; } } else { - priv->ContinueDiffCount = 0; + priv->continue_diff_count = 0; } if (rate_count_diff <= priv->rtllib->fsync_firstdiff_ratethreshold) { bSwitchFromCountDiff = true; - priv->ContinueDiffCount = 0; + priv->continue_diff_count = 0; } priv->rate_record = rate_count; - priv->rateCountDiffRecord = rate_count_diff; + priv->rate_count_diff_rec = rate_count_diff; if (priv->undecorated_smoothed_pwdb > priv->rtllib->fsync_rssi_threshold && bSwitchFromCountDiff) { @@ -2073,7 +2071,7 @@ static void _rtl92e_dm_fsync_timer_callback(struct timer_list *t) rtl92e_writeb(dev, 0xC36, 0x5c); rtl92e_writeb(dev, 0xC3e, 0x96); } - priv->ContinueDiffCount = 0; + priv->continue_diff_count = 0; rtl92e_writel(dev, rOFDM0_RxDetector2, 0x465c52cd); } } @@ -2114,7 +2112,7 @@ static void _rtl92e_dm_end_sw_fsync(struct net_device *dev) rtl92e_writeb(dev, 0xC3e, 0x96); } - priv->ContinueDiffCount = 0; + priv->continue_diff_count = 0; rtl92e_writel(dev, rOFDM0_RxDetector2, 0x465c52cd); } @@ -2125,8 +2123,8 @@ static void _rtl92e_dm_start_sw_fsync(struct net_device *dev) u32 rate_bitmap; priv->rate_record = 0; - priv->ContinueDiffCount = 0; - priv->rateCountDiffRecord = 0; + priv->continue_diff_count = 0; + priv->rate_count_diff_rec = 0; priv->bswitch_fsync = false; if (priv->rtllib->mode == WIRELESS_MODE_N_24G) { @@ -2196,7 +2194,7 @@ static void _rtl92e_dm_check_fsync(struct net_device *dev) } } - if (priv->framesyncMonitor) { + if (priv->frame_sync_monitor) { if (reg_c38_State != RegC38_Fsync_AP_BCM) { rtl92e_writeb(dev, rOFDM0_RxDetector3, 0x95); @@ -2218,7 +2216,7 @@ static void _rtl92e_dm_check_fsync(struct net_device *dev) break; } - if (priv->framesyncMonitor) { + if (priv->frame_sync_monitor) { if (priv->rtllib->state == RTLLIB_LINKED) { if (priv->undecorated_smoothed_pwdb <= RegC38_TH) { @@ -2249,7 +2247,7 @@ static void _rtl92e_dm_check_fsync(struct net_device *dev) } } } - if (priv->framesyncMonitor) { + if (priv->frame_sync_monitor) { if (priv->reset_count != reset_cnt) { rtl92e_writeb(dev, rOFDM0_RxDetector3, priv->framesync); @@ -2271,10 +2269,10 @@ static void _rtl92e_dm_init_dynamic_tx_power(struct net_device *dev) struct r8192_priv *priv = rtllib_priv(dev); priv->rtllib->bdynamic_txpower_enable = true; - priv->bLastDTPFlag_High = false; - priv->bLastDTPFlag_Low = false; - priv->bDynamicTxHighPower = false; - priv->bDynamicTxLowPower = false; + priv->last_dtp_flag_high = false; + priv->last_dtp_flag_low = false; + priv->dynamic_tx_high_pwr = false; + priv->dynamic_tx_low_pwr = false; } static void _rtl92e_dm_dynamic_tx_power(struct net_device *dev) @@ -2284,8 +2282,8 @@ static void _rtl92e_dm_dynamic_tx_power(struct net_device *dev) unsigned int txlowpower_threshold = 0; if (!priv->rtllib->bdynamic_txpower_enable) { - priv->bDynamicTxHighPower = false; - priv->bDynamicTxLowPower = false; + priv->dynamic_tx_high_pwr = false; + priv->dynamic_tx_low_pwr = false; return; } if ((priv->rtllib->ht_info->IOTPeer == HT_IOT_PEER_ATHEROS) && @@ -2299,28 +2297,28 @@ static void _rtl92e_dm_dynamic_tx_power(struct net_device *dev) if (priv->rtllib->state == RTLLIB_LINKED) { if (priv->undecorated_smoothed_pwdb >= txhipower_threshold) { - priv->bDynamicTxHighPower = true; - priv->bDynamicTxLowPower = false; + priv->dynamic_tx_high_pwr = true; + priv->dynamic_tx_low_pwr = false; } else { if (priv->undecorated_smoothed_pwdb < - txlowpower_threshold && priv->bDynamicTxHighPower) - priv->bDynamicTxHighPower = false; + txlowpower_threshold && priv->dynamic_tx_high_pwr) + priv->dynamic_tx_high_pwr = false; if (priv->undecorated_smoothed_pwdb < 35) - priv->bDynamicTxLowPower = true; + priv->dynamic_tx_low_pwr = true; else if (priv->undecorated_smoothed_pwdb >= 40) - priv->bDynamicTxLowPower = false; + priv->dynamic_tx_low_pwr = false; } } else { - priv->bDynamicTxHighPower = false; - priv->bDynamicTxLowPower = false; + priv->dynamic_tx_high_pwr = false; + priv->dynamic_tx_low_pwr = false; } - if ((priv->bDynamicTxHighPower != priv->bLastDTPFlag_High) || - (priv->bDynamicTxLowPower != priv->bLastDTPFlag_Low)) { + if ((priv->dynamic_tx_high_pwr != priv->last_dtp_flag_high) || + (priv->dynamic_tx_low_pwr != priv->last_dtp_flag_low)) { rtl92e_set_tx_power(dev, priv->rtllib->current_network.channel); } - priv->bLastDTPFlag_High = priv->bDynamicTxHighPower; - priv->bLastDTPFlag_Low = priv->bDynamicTxLowPower; + priv->last_dtp_flag_high = priv->dynamic_tx_high_pwr; + priv->last_dtp_flag_low = priv->dynamic_tx_low_pwr; } diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h index 1d4d7d98a859..01587e2fec65 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h @@ -7,10 +7,9 @@ #ifndef __R8192UDM_H__ #define __R8192UDM_H__ - /*--------------------------Define Parameters-------------------------------*/ -#define OFDM_Table_Length 19 -#define CCK_Table_length 12 +#define OFDM_TABLE_LEN 19 +#define CCK_TABLE_LEN 12 #define DM_DIG_THRESH_HIGH 40 #define DM_DIG_THRESH_LOW 35 @@ -26,15 +25,15 @@ #define DM_DIG_MIN 0x1c #define DM_DIG_MIN_Netcore 0x12 -#define RxPathSelection_SS_TH_low 30 -#define RxPathSelection_diff_TH 18 +#define RX_PATH_SEL_SS_TH_LOW 30 +#define RX_PATH_SEL_DIFF_TH 18 -#define RateAdaptiveTH_High 50 -#define RateAdaptiveTH_Low_20M 30 -#define RateAdaptiveTH_Low_40M 10 -#define VeryLowRSSI 15 +#define RATE_ADAPTIVE_TH_HIGH 50 +#define RATE_ADAPTIVE_TH_LOW_20M 30 +#define RATE_ADAPTIVE_TH_LOW_40M 10 +#define VERY_LOW_RSSI 15 -#define WAIotTHVal 25 +#define WA_IOT_TH_VAL 25 #define E_FOR_TX_POWER_TRACK 300 #define TX_POWER_NEAR_FIELD_THRESH_HIGH 68 @@ -47,11 +46,8 @@ #define TX_RETRY_COUNT_REG 0x1ac #define RegC38_TH 20 -#define DM_Type_ByDriver 1 - /*--------------------------Define Parameters-------------------------------*/ - /*------------------------------Define structure----------------------------*/ struct dig_t { u8 dig_enable_flag; @@ -90,7 +86,6 @@ enum dm_dig_sta { DM_STA_DIG_MAX }; - enum dm_ratr_sta { DM_RATR_STA_HIGH = 0, DM_RATR_STA_MIDDLE = 1, @@ -130,13 +125,13 @@ enum dm_dig_cs_ratio { }; struct drx_path_sel { - u8 Enable; + u8 enable; u8 cck_method; - u8 cck_Rx_path; + u8 cck_rx_path; - u8 SS_TH_low; - u8 diff_TH; - u8 disabledRF; + u8 ss_th_low; + u8 diff_th; + u8 disabled_rf; u8 reserved; u8 rf_rssi[4]; @@ -150,29 +145,26 @@ enum dm_cck_rx_path_method { CCK_Rx_Version_MAX }; - struct dcmd_txcmd { u32 op; u32 length; u32 value; }; -/*------------------------------Define structure----------------------------*/ +/*------------------------------Define structure----------------------------*/ /*------------------------Export global variable----------------------------*/ extern struct dig_t dm_digtable; -extern struct drx_path_sel DM_RxPathSelTable; /* Pre-calculated gain tables */ -extern const u32 dm_tx_bb_gain[TxBBGainTableLength]; -extern const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8]; -extern const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8]; +extern const u32 dm_tx_bb_gain[TX_BB_GAIN_TABLE_LEN]; +extern const u8 dm_cck_tx_bb_gain[CCK_TX_BB_GAIN_TABLE_LEN][8]; +extern const u8 dm_cck_tx_bb_gain_ch14[CCK_TX_BB_GAIN_TABLE_LEN][8]; /* Maps table index to iq amplify gain (dB, 12 to -24dB) */ #define dm_tx_bb_gain_idx_to_amplify(idx) (-idx + 12) /*------------------------Export global variable----------------------------*/ - /*--------------------------Exported Function prototype---------------------*/ /*--------------------------Exported Function prototype---------------------*/ @@ -181,7 +173,6 @@ void rtl92e_dm_deinit(struct net_device *dev); void rtl92e_dm_watchdog(struct net_device *dev); - void rtl92e_init_adaptive_rate(struct net_device *dev); void rtl92e_dm_txpower_tracking_wq(void *data); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c index 82b45c61ac75..9c80dc1b6e12 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c @@ -41,7 +41,7 @@ int rtl92e_suspend(struct device *dev_d) rtl92e_writel(dev, WFCRC1, 0xffffffff); rtl92e_writel(dev, WFCRC2, 0xffffffff); rtl92e_writeb(dev, PMR, 0x5); - rtl92e_writeb(dev, MacBlkCtrl, 0xa); + rtl92e_writeb(dev, MAC_BLK_CTRL, 0xa); } out_pci_suspend: netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ? diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index c5c43d2fb93e..694d1b18f81c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1823,7 +1823,7 @@ struct ieee80211_device { struct work_struct associate_procedure_wq; struct delayed_work softmac_scan_wq; struct delayed_work associate_retry_wq; - struct delayed_work start_ibss_wq; + struct delayed_work start_ibss_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; // Qos related. Added by Annie, 2005-11-01. diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index f1fc077ed29c..0fcae6871108 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -653,7 +653,7 @@ static void Hal_EfusePowerSwitch( if (PwrState) { - /* To avoid cannot access efuse regsiters after disable/enable several times during DTM test. */ + /* To avoid cannot access efuse registers after disable/enable several times during DTM test. */ /* Suggested by SD1 IsaacHsu. 2013.07.08, added by tynli. */ tempval = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HSUS_CTRL); if (tempval & BIT(0)) { /* SDIO local register is suspend */ @@ -1693,7 +1693,7 @@ void rtl8723b_InitBeaconParameters(struct adapter *padapter) rtw_write8(padapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME_8723B); /* 2ms */ /* Suggested by designer timchen. Change beacon AIFS to the largest number */ - /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ + /* because test chip does not contension before sending beacon. by tynli. 2009.11.03 */ rtw_write16(padapter, REG_BCNTCFG, 0x660F); pHalData->RegBcnCtrlVal = rtw_read8(padapter, REG_BCN_CTRL); @@ -2089,7 +2089,7 @@ void Hal_EfuseParseIDCode(struct adapter *padapter, u8 *hwinfo) u16 EEPROMId; - /* Checl 0x8129 again for making sure autoload status!! */ + /* Check 0x8129 again for making sure autoload status!! */ EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); if (EEPROMId != RTL_EEPROM_ID) { pEEPROM->bautoload_fail_flag = true; @@ -2510,7 +2510,7 @@ static void rtl8723b_cal_txdesc_chksum(struct tx_desc *ptxdesc) /* Clear first */ ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); - /* checksume is always calculated by first 32 bytes, */ + /* checksum is always calculated by first 32 bytes, */ /* and it doesn't depend on TX DESC length. */ /* Thomas, Lucas@SD4, 20130515 */ count = 16; @@ -2723,7 +2723,7 @@ static void rtl8723b_fill_default_txdesc( * multicast / mgnt frame should be controlled by Hw because Fw * will also send null data which we cannot control when Fw LPS * enable. - * --> default enable non-Qos data sequense number. 2010.06.23. + * --> default enable non-Qos data sequence number. 2010.06.23. * by tynli. * (2) Enable HW SEQ control for beacon packet, because we use * Hw beacon. @@ -2777,7 +2777,7 @@ void rtl8723b_fill_fake_txdesc( SET_TX_DESC_PKT_SIZE_8723B(pDesc, BufferLen); /* Buffer size + command header */ SET_TX_DESC_QUEUE_SEL_8723B(pDesc, QSLT_MGNT); /* Fixed queue of Mgnt queue */ - /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ + /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error value by Hw. */ if (IsPsPoll) { SET_TX_DESC_NAV_USE_HDR_8723B(pDesc, 1); } else { @@ -3406,7 +3406,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) /* polling bit, and No Write enable, and address */ ulCommand = CAM_CONTENT_COUNT*ucIndex+i; ulCommand = ulCommand | CAM_POLLINIG | CAM_WRITE; - /* write content 0 is equall to mark invalid */ + /* write content 0 is equal to mark as invalid */ rtw_write32(padapter, WCAMI, ulContent); /* mdelay(40); */ rtw_write32(padapter, RWCAM, ulCommand); /* mdelay(40); */ } diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index 14449f8afad5..bfeb5873bf3b 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -1768,6 +1768,8 @@ static int ms_copy_page(struct rtsx_chip *chip, u16 old_blk, u16 new_blk, 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; ms_set_err_code(chip, MS_NO_ERROR); diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index 1fd191e2e2a5..44794bdf6173 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -15,5 +15,3 @@ obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/ obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += vchiq-mmal/ -ccflags-y += -I $(srctree)/$(src)/include - diff --git a/drivers/staging/vc04_services/bcm2835-audio/Makefile b/drivers/staging/vc04_services/bcm2835-audio/Makefile index d59fe4dde615..01ceebdf88e7 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/Makefile +++ b/drivers/staging/vc04_services/bcm2835-audio/Makefile @@ -1,5 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_SND_BCM2835) += snd-bcm2835.o snd-bcm2835-objs := bcm2835.o bcm2835-ctl.o bcm2835-pcm.o bcm2835-vchiq.o - -ccflags-y += -I $(srctree)/$(src)/../include -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index f4c2c9506d86..d74110ca17ab 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -91,17 +91,17 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, return bcm2835_audio_send_msg(instance, &m, wait); } -static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, void *userdata) +static int audio_vchi_callback(struct vchiq_instance *vchiq_instance, + enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, void *userdata) { struct bcm2835_audio_instance *instance = vchiq_get_service_userdata(vchiq_instance, handle); struct vc_audio_msg *m; if (reason != VCHIQ_MESSAGE_AVAILABLE) - return VCHIQ_SUCCESS; + return 0; m = (void *)header->data; if (m->type == VC_AUDIO_MSG_TYPE_RESULT) { @@ -119,7 +119,7 @@ static enum vchiq_status audio_vchi_callback(struct vchiq_instance *vchiq_instan } vchiq_release_message(vchiq_instance, instance->service_handle, header); - return VCHIQ_SUCCESS; + return 0; } static int diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 38b7451d77b2..0a81383c475a 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -6,11 +6,12 @@ #include <linux/device.h> #include <linux/wait.h> -#include <linux/raspberrypi/vchiq.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/pcm-indirect.h> +#include "../include/linux/raspberrypi/vchiq.h" + #define MAX_SUBSTREAMS (8) #define AVAIL_SUBSTREAMS_MASK (0xff) diff --git a/drivers/staging/vc04_services/bcm2835-camera/Makefile b/drivers/staging/vc04_services/bcm2835-camera/Makefile index 3a76d6ade428..203b93899b20 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/Makefile +++ b/drivers/staging/vc04_services/bcm2835-camera/Makefile @@ -4,8 +4,3 @@ bcm2835-v4l2-$(CONFIG_VIDEO_BCM2835) := \ controls.o obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-v4l2.o - -ccflags-y += \ - -I $(srctree)/$(src)/.. \ - -I $(srctree)/$(src)/../vchiq-mmal/ \ - -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 797ebe2a973a..4f81765912ea 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -26,11 +26,11 @@ #include <linux/delay.h> #include <linux/platform_device.h> -#include "mmal-common.h" -#include "mmal-encodings.h" -#include "mmal-vchiq.h" -#include "mmal-msg.h" -#include "mmal-parameters.h" +#include "../vchiq-mmal/mmal-common.h" +#include "../vchiq-mmal/mmal-encodings.h" +#include "../vchiq-mmal/mmal-vchiq.h" +#include "../vchiq-mmal/mmal-msg.h" +#include "../vchiq-mmal/mmal-parameters.h" #include "bcm2835-camera.h" #define MIN_WIDTH 32 diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 5644d1d457b9..6bce45925bf1 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -23,9 +23,9 @@ #include <media/v4l2-event.h> #include <media/v4l2-common.h> -#include "mmal-common.h" -#include "mmal-vchiq.h" -#include "mmal-parameters.h" +#include "../vchiq-mmal/mmal-common.h" +#include "../vchiq-mmal/mmal-vchiq.h" +#include "../vchiq-mmal/mmal-parameters.h" #include "bcm2835-camera.h" /* The supported V4L2_CID_AUTO_EXPOSURE_BIAS values are from -4.0 to +4.0. diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index 690ab7165b2c..66965da11443 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -17,12 +17,6 @@ enum vchiq_reason { VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ }; -enum vchiq_status { - VCHIQ_ERROR = -1, - VCHIQ_SUCCESS = 0, - VCHIQ_RETRY = 1 -}; - enum vchiq_bulk_mode { VCHIQ_BULK_MODE_CALLBACK, VCHIQ_BULK_MODE_BLOCKING, @@ -57,11 +51,11 @@ struct vchiq_instance; struct vchiq_service_base { int fourcc; - enum vchiq_status (*callback)(struct vchiq_instance *instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); + int (*callback)(struct vchiq_instance *instance, + enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *userdata; }; @@ -74,11 +68,11 @@ struct vchiq_completion_data_kernel { struct vchiq_service_params_kernel { int fourcc; - enum vchiq_status (*callback)(struct vchiq_instance *instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); + int (*callback)(struct vchiq_instance *instance, + enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ @@ -87,32 +81,31 @@ struct vchiq_service_params_kernel { struct vchiq_instance; extern int 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_open_service(struct vchiq_instance *instance, - const struct vchiq_service_params_kernel *params, - unsigned int *pservice); -extern enum vchiq_status vchiq_close_service(struct vchiq_instance *instance, - unsigned int service); -extern enum vchiq_status vchiq_use_service(struct vchiq_instance *instance, unsigned int service); -extern enum vchiq_status vchiq_release_service(struct vchiq_instance *instance, - unsigned int service); +extern int vchiq_shutdown(struct vchiq_instance *instance); +extern int vchiq_connect(struct vchiq_instance *instance); +extern int vchiq_open_service(struct vchiq_instance *instance, + const struct vchiq_service_params_kernel *params, + unsigned int *pservice); +extern int vchiq_close_service(struct vchiq_instance *instance, + unsigned int service); +extern int vchiq_use_service(struct vchiq_instance *instance, unsigned int service); +extern int vchiq_release_service(struct vchiq_instance *instance, + unsigned int service); extern void vchiq_msg_queue_push(struct vchiq_instance *instance, unsigned int handle, struct vchiq_header *header); extern void vchiq_release_message(struct vchiq_instance *instance, unsigned int service, struct vchiq_header *header); extern int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned int handle, void *data, unsigned int size); -extern enum vchiq_status vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int service, - const void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int service, - void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); +extern int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int service, + const void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); +extern int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int service, + void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); extern void *vchiq_get_service_userdata(struct vchiq_instance *instance, unsigned int service); -extern enum vchiq_status vchiq_get_peer_version(struct vchiq_instance *instance, - unsigned int handle, - short *peer_version); +extern int vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handle, + short *peer_version); extern struct vchiq_header *vchiq_msg_hold(struct vchiq_instance *instance, unsigned int handle); #endif /* VCHIQ_H */ diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging/vc04_services/interface/TODO index 97085a0b3223..6d9d4a800aa7 100644 --- a/drivers/staging/vc04_services/interface/TODO +++ b/drivers/staging/vc04_services/interface/TODO @@ -40,11 +40,6 @@ beneficial to go over all of them and, if correct, comment on their merits. Extra points to whomever confidently reviews the remote_event_*() family of functions. -* Get rid of custom function return values - -Most functions use a custom set of return values, we should force proper Linux -error numbers. Special care is needed for VCHIQ_RETRY. - * Reformat core code with more sane indentations The code follows the 80 characters limitation yet tends to go 3 or 4 levels of 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 dc33490ba7fb..cddcd3c596c9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -151,7 +151,7 @@ static struct semaphore g_free_fragments_sema; static DEFINE_SEMAPHORE(g_free_fragments_mutex); -static enum vchiq_status +static int vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir); @@ -501,7 +501,7 @@ int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size); if (!vchiq_slot_zero) - return -EINVAL; + return -ENOMEM; vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX] = (int)slot_phys + slot_mem_size; @@ -541,9 +541,15 @@ int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) channelbase = slot_phys; err = rpi_firmware_property(fw, RPI_FIRMWARE_VCHIQ_INIT, &channelbase, sizeof(channelbase)); - if (err || channelbase) { - dev_err(dev, "failed to set channelbase\n"); - return err ? : -ENXIO; + if (err) { + dev_err(dev, "failed to send firmware property: %d\n", err); + return err; + } + + if (channelbase) { + dev_err(dev, "failed to set channelbase (response: %x)\n", + channelbase); + return -ENXIO; } vchiq_log_info(vchiq_arm_log_level, "vchiq_init - done (slots %pK, phys %pad)", @@ -722,13 +728,13 @@ void free_bulk_waiter(struct vchiq_instance *instance) } } -enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance) +int vchiq_shutdown(struct vchiq_instance *instance) { - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; struct vchiq_state *state = instance->state; if (mutex_lock_killable(&state->mutex)) - return VCHIQ_RETRY; + return -EAGAIN; /* Remove all services */ vchiq_shutdown_internal(state, instance); @@ -749,19 +755,19 @@ static int vchiq_is_connected(struct vchiq_instance *instance) return instance->connected; } -enum vchiq_status vchiq_connect(struct vchiq_instance *instance) +int vchiq_connect(struct vchiq_instance *instance) { - enum vchiq_status status; + int status; struct vchiq_state *state = instance->state; if (mutex_lock_killable(&state->mutex)) { vchiq_log_trace(vchiq_core_log_level, "%s: call to mutex_lock failed", __func__); - status = VCHIQ_RETRY; + status = -EAGAIN; goto failed; } status = vchiq_connect_internal(state, instance); - if (status == VCHIQ_SUCCESS) + if (!status) instance->connected = 1; mutex_unlock(&state->mutex); @@ -773,12 +779,12 @@ failed: } EXPORT_SYMBOL(vchiq_connect); -static enum vchiq_status +static int vchiq_add_service(struct vchiq_instance *instance, const struct vchiq_service_params_kernel *params, unsigned int *phandle) { - enum vchiq_status status; + int status; struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; int srvstate; @@ -793,9 +799,9 @@ vchiq_add_service(struct vchiq_instance *instance, if (service) { *phandle = service->handle; - status = VCHIQ_SUCCESS; + status = 0; } else { - status = VCHIQ_ERROR; + status = -EINVAL; } vchiq_log_trace(vchiq_core_log_level, "%s(%p): returning %d", __func__, instance, status); @@ -803,12 +809,12 @@ vchiq_add_service(struct vchiq_instance *instance, return status; } -enum vchiq_status +int vchiq_open_service(struct vchiq_instance *instance, const struct vchiq_service_params_kernel *params, unsigned int *phandle) { - enum vchiq_status status = VCHIQ_ERROR; + int status = -EINVAL; struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; @@ -822,7 +828,7 @@ vchiq_open_service(struct vchiq_instance *instance, if (service) { *phandle = service->handle; status = vchiq_open_service_internal(service, current->pid); - if (status != VCHIQ_SUCCESS) { + if (status) { vchiq_remove_service(instance, service->handle); *phandle = VCHIQ_SERVICE_HANDLE_INVALID; } @@ -835,11 +841,11 @@ failed: } EXPORT_SYMBOL(vchiq_open_service); -enum vchiq_status +int vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode) { - enum vchiq_status status; + int status; while (1) { switch (mode) { @@ -855,15 +861,15 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const VCHIQ_BULK_TRANSMIT); break; default: - return VCHIQ_ERROR; + return -EINVAL; } /* - * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need + * vchiq_*_bulk_transfer() may return -EAGAIN, so we need * to implement a retry mechanism since this function is * supposed to block until queued */ - if (status != VCHIQ_RETRY) + if (status != -EAGAIN) break; msleep(1); @@ -873,11 +879,11 @@ vchiq_bulk_transmit(struct vchiq_instance *instance, unsigned int handle, const } EXPORT_SYMBOL(vchiq_bulk_transmit); -enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handle, - void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode) +int vchiq_bulk_receive(struct vchiq_instance *instance, unsigned int handle, + void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode) { - enum vchiq_status status; + int status; while (1) { switch (mode) { @@ -892,15 +898,15 @@ enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsigned i VCHIQ_BULK_RECEIVE); break; default: - return VCHIQ_ERROR; + return -EINVAL; } /* - * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need + * vchiq_*_bulk_transfer() may return -EAGAIN, so we need * to implement a retry mechanism since this function is * supposed to block until queued */ - if (status != VCHIQ_RETRY) + if (status != -EAGAIN) break; msleep(1); @@ -910,17 +916,17 @@ enum vchiq_status vchiq_bulk_receive(struct vchiq_instance *instance, unsigned i } EXPORT_SYMBOL(vchiq_bulk_receive); -static enum vchiq_status +static int vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir) { struct vchiq_service *service; - enum vchiq_status status; + int status; struct bulk_waiter_node *waiter = NULL, *iter; service = find_service_by_handle(instance, handle); if (!service) - return VCHIQ_ERROR; + return -EINVAL; vchiq_service_put(service); @@ -954,14 +960,14 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl waiter = kzalloc(sizeof(*waiter), GFP_KERNEL); if (!waiter) { vchiq_log_error(vchiq_core_log_level, "%s - out of memory", __func__); - return VCHIQ_ERROR; + return -ENOMEM; } } status = vchiq_bulk_transfer(instance, handle, data, NULL, size, &waiter->bulk_waiter, VCHIQ_BULK_MODE_BLOCKING, dir); - if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { + if ((status != -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk; if (bulk) { @@ -983,7 +989,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl return status; } -static enum vchiq_status +static int add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, struct user_service *user_service, void *bulk_userdata) @@ -1001,10 +1007,10 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); if (wait_for_completion_interruptible(&instance->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); - return VCHIQ_RETRY; + return -EAGAIN; } else if (instance->closing) { vchiq_log_info(vchiq_arm_log_level, "service_callback closing"); - return VCHIQ_SUCCESS; + return 0; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); } @@ -1041,10 +1047,10 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, complete(&instance->insert_event); - return VCHIQ_SUCCESS; + return 0; } -enum vchiq_status +int service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { @@ -1066,14 +1072,14 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, service = handle_to_service(instance, handle); if (WARN_ON(!service)) { rcu_read_unlock(); - return VCHIQ_SUCCESS; + return 0; } user_service = (struct user_service *)service->base.userdata; if (!instance || instance->closing) { rcu_read_unlock(); - return VCHIQ_SUCCESS; + return 0; } /* @@ -1103,14 +1109,14 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, */ if ((user_service->message_available_pos - instance->completion_remove) < 0) { - enum vchiq_status status; + int status; vchiq_log_info(vchiq_arm_log_level, "Inserting extra MESSAGE_AVAILABLE"); DEBUG_TRACE(SERVICE_CALLBACK_LINE); status = add_completion(instance, reason, NULL, user_service, bulk_userdata); - if (status != VCHIQ_SUCCESS) { + if (status) { DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); return status; @@ -1122,12 +1128,12 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); - return VCHIQ_RETRY; + return -EAGAIN; } else if (instance->closing) { vchiq_log_info(vchiq_arm_log_level, "%s closing", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); vchiq_service_put(service); - return VCHIQ_ERROR; + return -EINVAL; } DEBUG_TRACE(SERVICE_CALLBACK_LINE); spin_lock(&msg_queue_spinlock); @@ -1158,7 +1164,7 @@ service_callback(struct vchiq_instance *instance, enum vchiq_reason reason, vchiq_service_put(service); if (skip_completion) - return VCHIQ_SUCCESS; + return 0; return add_completion(instance, reason, header, user_service, bulk_userdata); @@ -1314,7 +1320,7 @@ vchiq_get_state(void) * Autosuspend related functionality */ -static enum vchiq_status +static int vchiq_keepalive_vchiq_callback(struct vchiq_instance *instance, enum vchiq_reason reason, struct vchiq_header *header, @@ -1330,7 +1336,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); - enum vchiq_status status; + int status; struct vchiq_instance *instance; unsigned int ka_handle; int ret; @@ -1350,14 +1356,14 @@ vchiq_keepalive_thread_func(void *v) } status = vchiq_connect(instance); - if (status != VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_connect failed %d", __func__, status); goto shutdown; } status = vchiq_add_service(instance, ¶ms, &ka_handle); - if (status != VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_open_service failed %d", __func__, status); goto shutdown; @@ -1386,14 +1392,14 @@ vchiq_keepalive_thread_func(void *v) while (uc--) { atomic_inc(&arm_state->ka_use_ack_count); status = vchiq_use_service(instance, ka_handle); - if (status != VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_use_service error %d", __func__, status); } } while (rc--) { status = vchiq_release_service(instance, ka_handle); - if (status != VCHIQ_SUCCESS) { + if (status) { vchiq_log_error(vchiq_susp_log_level, "%s vchiq_release_service error %d", __func__, status); @@ -1446,13 +1452,13 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, write_unlock_bh(&arm_state->susp_res_lock); if (!ret) { - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; long ack_cnt = atomic_xchg(&arm_state->ka_use_ack_count, 0); - while (ack_cnt && (status == VCHIQ_SUCCESS)) { + while (ack_cnt && !status) { /* Send the use notify to videocore */ status = vchiq_send_remote_use_active(state); - if (status == VCHIQ_SUCCESS) + if (!status) ack_cnt--; else atomic_add(ack_cnt, &arm_state->ka_use_ack_count); @@ -1587,10 +1593,10 @@ vchiq_instance_set_trace(struct vchiq_instance *instance, int trace) instance->trace = (trace != 0); } -enum vchiq_status +int vchiq_use_service(struct vchiq_instance *instance, unsigned int handle) { - enum vchiq_status ret = VCHIQ_ERROR; + int ret = -EINVAL; struct vchiq_service *service = find_service_by_handle(instance, handle); if (service) { @@ -1601,10 +1607,10 @@ vchiq_use_service(struct vchiq_instance *instance, unsigned int handle) } EXPORT_SYMBOL(vchiq_use_service); -enum vchiq_status +int vchiq_release_service(struct vchiq_instance *instance, unsigned int handle) { - enum vchiq_status ret = VCHIQ_ERROR; + int ret = -EINVAL; struct vchiq_service *service = find_service_by_handle(instance, handle); if (service) { @@ -1695,11 +1701,11 @@ vchiq_dump_service_use_state(struct vchiq_state *state) kfree(service_data); } -enum vchiq_status +int vchiq_check_service(struct vchiq_service *service) { struct vchiq_arm_state *arm_state; - enum vchiq_status ret = VCHIQ_ERROR; + int ret = -EINVAL; if (!service || !service->state) goto out; @@ -1708,10 +1714,10 @@ vchiq_check_service(struct vchiq_service *service) read_lock_bh(&arm_state->susp_res_lock); if (service->service_use_count) - ret = VCHIQ_SUCCESS; + ret = 0; read_unlock_bh(&arm_state->susp_res_lock); - if (ret == VCHIQ_ERROR) { + if (ret) { vchiq_log_error(vchiq_susp_log_level, "%s ERROR - %c%c%c%c:%d service count %d, state count %d", __func__, VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), service->client_id, 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 cd20eb18f275..2fb31f9b527f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -85,13 +85,13 @@ extern struct vchiq_state g_state; extern struct vchiq_state * vchiq_get_state(void); -enum vchiq_status +int vchiq_use_service(struct vchiq_instance *instance, unsigned int handle); -extern enum vchiq_status +extern int vchiq_release_service(struct vchiq_instance *instance, unsigned int handle); -extern enum vchiq_status +extern int vchiq_check_service(struct vchiq_service *service); extern void @@ -137,7 +137,7 @@ static inline int vchiq_register_chrdev(struct device *parent) { return 0; } #endif /* IS_ENABLED(CONFIG_VCHIQ_CDEV) */ -extern enum vchiq_status +extern int service_callback(struct vchiq_instance *vchiq_instance, enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata); 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 45ed30bfdbf5..596894338cb4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -463,22 +463,22 @@ mark_service_closing(struct vchiq_service *service) mark_service_closing_internal(service, 0); } -static inline enum vchiq_status +static inline int make_service_callback(struct vchiq_service *service, enum vchiq_reason reason, struct vchiq_header *header, void *bulk_userdata) { - enum vchiq_status status; + int status; vchiq_log_trace(vchiq_core_log_level, "%d: callback:%d (%s, %pK, %pK)", service->state->id, service->localport, reason_names[reason], header, bulk_userdata); status = service->base.callback(service->instance, reason, header, service->handle, bulk_userdata); - if (status == VCHIQ_ERROR) { + if (status && (status != -EAGAIN)) { vchiq_log_warning(vchiq_core_log_level, "%d: ignoring ERROR from callback to service %x", service->state->id, service->handle); - status = VCHIQ_SUCCESS; + status = 0; } if (reason != VCHIQ_MESSAGE_AVAILABLE) @@ -498,6 +498,7 @@ vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newstate) vchiq_platform_conn_state_changed(state, oldstate, newstate); } +/* This initialises a single remote_event, and the associated wait_queue. */ static inline void remote_event_create(wait_queue_head_t *wq, struct remote_event *event) { @@ -536,6 +537,10 @@ remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) return 1; } +/* + * Acknowledge that the event has been signalled, and wake any waiters. Usually + * called as a result of the doorbell being rung. + */ static inline void remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event) { @@ -544,6 +549,7 @@ remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event) wake_up_all(wq); } +/* Check if a single event has been signalled, waking the waiters if it has. */ static inline void remote_event_poll(wait_queue_head_t *wq, struct remote_event *event) { @@ -551,6 +557,10 @@ remote_event_poll(wait_queue_head_t *wq, struct remote_event *event) remote_event_signal_local(wq, event); } +/* + * VCHIQ used a small, fixed number of remote events. It is simplest to + * enumerate them here for polling. + */ void remote_event_pollall(struct vchiq_state *state) { @@ -900,7 +910,7 @@ copy_message_data(ssize_t (*copy_callback)(void *context, void *dest, size_t off } /* Called by the slot handler and application threads */ -static enum vchiq_status +static int queue_message(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -922,7 +932,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && mutex_lock_killable(&state->slot_mutex)) - return VCHIQ_RETRY; + return -EAGAIN; if (type == VCHIQ_MSG_DATA) { int tx_end_index; @@ -930,7 +940,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (!service) { WARN(1, "%s: service is NULL\n", __func__); mutex_unlock(&state->slot_mutex); - return VCHIQ_ERROR; + return -EINVAL; } WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | @@ -939,7 +949,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (service->closing) { /* The service has been closed */ mutex_unlock(&state->slot_mutex); - return VCHIQ_ERROR; + return -EHOSTDOWN; } quota = &state->service_quotas[service->localport]; @@ -963,7 +973,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, mutex_unlock(&state->slot_mutex); if (wait_for_completion_interruptible(&state->data_quota_event)) - return VCHIQ_RETRY; + return -EAGAIN; mutex_lock(&state->slot_mutex); spin_lock("a_spinlock); @@ -987,15 +997,15 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); if (wait_for_completion_interruptible("a->quota_event)) - return VCHIQ_RETRY; + return -EAGAIN; if (service->closing) - return VCHIQ_ERROR; + return -EHOSTDOWN; if (mutex_lock_killable(&state->slot_mutex)) - return VCHIQ_RETRY; + return -EAGAIN; if (service->srvstate != VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ mutex_unlock(&state->slot_mutex); - return VCHIQ_ERROR; + return -EHOSTDOWN; } spin_lock("a_spinlock); tx_end_index = SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos + stride - 1); @@ -1015,7 +1025,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, */ if (!(flags & QMFLAGS_NO_MUTEX_LOCK)) mutex_unlock(&state->slot_mutex); - return VCHIQ_RETRY; + return -EAGAIN; } if (type == VCHIQ_MSG_DATA) { @@ -1037,7 +1047,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (callback_result < 0) { mutex_unlock(&state->slot_mutex); VCHIQ_SERVICE_STATS_INC(service, error_count); - return VCHIQ_ERROR; + return -EINVAL; } if (SRVTRACE_ENABLED(service, @@ -1135,11 +1145,11 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, remote_event_signal(&state->remote->trigger); - return VCHIQ_SUCCESS; + return 0; } /* Called by the slot handler and application threads */ -static enum vchiq_status +static int queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, @@ -1154,7 +1164,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME && mutex_lock_killable(&state->sync_mutex)) - return VCHIQ_RETRY; + return -EAGAIN; remote_event_wait(&state->sync_release_event, &local->sync_release); @@ -1185,7 +1195,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, if (callback_result < 0) { mutex_unlock(&state->slot_mutex); VCHIQ_SERVICE_STATS_INC(service, error_count); - return VCHIQ_ERROR; + return -EINVAL; } if (service) { @@ -1223,7 +1233,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_PAUSE) mutex_unlock(&state->sync_mutex); - return VCHIQ_SUCCESS; + return 0; } static inline void @@ -1299,11 +1309,11 @@ get_bulk_reason(struct vchiq_bulk *bulk) } /* Called by the slot handler - don't hold the bulk mutex */ -static enum vchiq_status +static int notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, int retry_poll) { - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; vchiq_log_trace(vchiq_core_log_level, "%d: nb:%d %cx - p=%x rn=%x r=%x", service->state->id, service->localport, (queue == &service->bulk_tx) ? 't' : 'r', @@ -1348,7 +1358,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, get_bulk_reason(bulk); status = make_service_callback(service, reason, NULL, bulk->userdata); - if (status == VCHIQ_RETRY) + if (status == -EAGAIN) break; } } @@ -1357,9 +1367,9 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, complete(&service->bulk_remove_event); } if (!retry_poll) - status = VCHIQ_SUCCESS; + status = 0; - if (status == VCHIQ_RETRY) + if (status == -EAGAIN) request_poll(service->state, service, (queue == &service->bulk_tx) ? VCHIQ_POLL_TXNOTIFY : VCHIQ_POLL_RXNOTIFY); @@ -1398,13 +1408,12 @@ poll_services_of_group(struct vchiq_state *state, int group) */ service->public_fourcc = VCHIQ_FOURCC_INVALID; - if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) != - VCHIQ_SUCCESS) + if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_REMOVE); } else if (service_flags & BIT(VCHIQ_POLL_TERMINATE)) { vchiq_log_info(vchiq_core_log_level, "%d: ps - terminate %d<->%d", state->id, service->localport, service->remoteport); - if (vchiq_close_service_internal(service, NO_CLOSE_RECVD) != VCHIQ_SUCCESS) + if (vchiq_close_service_internal(service, NO_CLOSE_RECVD)) request_poll(state, service, VCHIQ_POLL_TERMINATE); } if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY)) @@ -1527,14 +1536,14 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) /* Acknowledge the OPEN */ if (service->sync) { if (queue_message_sync(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload), 0) == VCHIQ_RETRY) + &ack_payload, sizeof(ack_payload), 0) == -EAGAIN) goto bail_not_ready; /* The service is now open */ set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); } else { if (queue_message(state, NULL, openack_id, memcpy_copy_callback, - &ack_payload, sizeof(ack_payload), 0) == VCHIQ_RETRY) + &ack_payload, sizeof(ack_payload), 0) == -EAGAIN) goto bail_not_ready; /* The service is now open */ @@ -1549,7 +1558,7 @@ parse_open(struct vchiq_state *state, struct vchiq_header *header) fail_open: /* No available service, or an invalid request - send a CLOSE */ if (queue_message(state, NULL, MAKE_CLOSE(0, VCHIQ_MSG_SRCPORT(msgid)), - NULL, NULL, 0, 0) == VCHIQ_RETRY) + NULL, NULL, 0, 0) == -EAGAIN) goto bail_not_ready; return 1; @@ -1688,7 +1697,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) mark_service_closing_internal(service, 1); - if (vchiq_close_service_internal(service, CLOSE_RECVD) == VCHIQ_RETRY) + if (vchiq_close_service_internal(service, CLOSE_RECVD) == -EAGAIN) goto bail_not_ready; vchiq_log_info(vchiq_core_log_level, "Close Service %c%c%c%c s:%u d:%d", @@ -1705,7 +1714,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) claim_slot(state->rx_info); DEBUG_TRACE(PARSE_LINE); if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, - NULL) == VCHIQ_RETRY) { + NULL) == -EAGAIN) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } @@ -1803,7 +1812,7 @@ parse_message(struct vchiq_state *state, struct vchiq_header *header) if (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT) { /* Send a PAUSE in response */ if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) == VCHIQ_RETRY) + QMFLAGS_NO_MUTEX_UNLOCK) == -EAGAIN) goto bail_not_ready; } /* At this point slot_mutex is held */ @@ -1920,7 +1929,7 @@ handle_poll(struct vchiq_state *state) case VCHIQ_CONNSTATE_PAUSING: if (queue_message(state, NULL, MAKE_PAUSE, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_UNLOCK) != VCHIQ_RETRY) { + QMFLAGS_NO_MUTEX_UNLOCK) != -EAGAIN) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSE_SENT); } else { /* Retry later */ @@ -1930,7 +1939,7 @@ handle_poll(struct vchiq_state *state) case VCHIQ_CONNSTATE_RESUMING: if (queue_message(state, NULL, MAKE_RESUME, NULL, NULL, 0, - QMFLAGS_NO_MUTEX_LOCK) != VCHIQ_RETRY) { + QMFLAGS_NO_MUTEX_LOCK) != -EAGAIN) { vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); } else { /* @@ -2086,9 +2095,9 @@ sync_func(void *v) if ((service->remoteport == remoteport) && (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC)) { if (make_service_callback(service, VCHIQ_MESSAGE_AVAILABLE, header, - NULL) == VCHIQ_RETRY) + NULL) == -EAGAIN) vchiq_log_error(vchiq_sync_log_level, - "synchronous callback to service %d returns VCHIQ_RETRY", + "synchronous callback to service %d returns -EAGAIN", localport); } break; @@ -2486,7 +2495,7 @@ vchiq_add_service_internal(struct vchiq_state *state, return service; } -enum vchiq_status +int vchiq_open_service_internal(struct vchiq_service *service, int client_id) { struct vchiq_open_payload payload = { @@ -2495,7 +2504,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) service->version, service->version_min }; - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; service->client_id = client_id; vchiq_use_service_internal(service); @@ -2506,12 +2515,12 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) sizeof(payload), QMFLAGS_IS_BLOCKING); - if (status != VCHIQ_SUCCESS) + if (status) return status; /* Wait for the ACK/NAK */ if (wait_for_completion_interruptible(&service->remove_event)) { - status = VCHIQ_RETRY; + status = -EAGAIN; vchiq_release_service_internal(service); } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && (service->srvstate != VCHIQ_SRVSTATE_OPENSYNC)) { @@ -2521,7 +2530,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) service->state->id, srvstate_names[service->srvstate], kref_read(&service->ref_count)); - status = VCHIQ_ERROR; + status = -EINVAL; VCHIQ_SERVICE_STATS_INC(service, error_count); vchiq_release_service_internal(service); } @@ -2592,7 +2601,7 @@ release_service_messages(struct vchiq_service *service) static int do_abort_bulks(struct vchiq_service *service) { - enum vchiq_status status; + int status; /* Abort any outstanding bulk transfers */ if (mutex_lock_killable(&service->bulk_mutex)) @@ -2602,17 +2611,17 @@ do_abort_bulks(struct vchiq_service *service) mutex_unlock(&service->bulk_mutex); status = notify_bulks(service, &service->bulk_tx, NO_RETRY_POLL); - if (status != VCHIQ_SUCCESS) + if (status) return 0; status = notify_bulks(service, &service->bulk_rx, NO_RETRY_POLL); - return (status == VCHIQ_SUCCESS); + return !status; } -static enum vchiq_status +static int close_service_complete(struct vchiq_service *service, int failstate) { - enum vchiq_status status; + int status; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); int newstate; @@ -2639,12 +2648,12 @@ close_service_complete(struct vchiq_service *service, int failstate) vchiq_log_error(vchiq_core_log_level, "%s(%x) called in state %s", __func__, service->handle, srvstate_names[service->srvstate]); WARN(1, "%s in unexpected state\n", __func__); - return VCHIQ_ERROR; + return -EINVAL; } status = make_service_callback(service, VCHIQ_SERVICE_CLOSED, NULL, NULL); - if (status != VCHIQ_RETRY) { + if (status != -EAGAIN) { int uc = service->service_use_count; int i; /* Complete the close process */ @@ -2674,11 +2683,11 @@ close_service_complete(struct vchiq_service *service, int failstate) } /* Called by the slot handler */ -enum vchiq_status +int vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) { struct vchiq_state *state = service->state; - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); int close_id = MAKE_CLOSE(service->localport, VCHIQ_MSG_DSTPORT(service->remoteport)); @@ -2696,7 +2705,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) __func__, srvstate_names[service->srvstate]); } else if (is_server) { if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) { - status = VCHIQ_ERROR; + status = -EINVAL; } else { service->client_id = 0; service->remoteport = VCHIQ_PORT_FREE; @@ -2725,16 +2734,16 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) case VCHIQ_SRVSTATE_OPEN: if (close_recvd) { if (!do_abort_bulks(service)) - status = VCHIQ_RETRY; + status = -EAGAIN; } release_service_messages(service); - if (status == VCHIQ_SUCCESS) + if (!status) status = queue_message(state, service, close_id, NULL, NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK); - if (status != VCHIQ_SUCCESS) { + if (status) { if (service->srvstate == VCHIQ_SRVSTATE_OPENSYNC) mutex_unlock(&state->sync_mutex); break; @@ -2764,11 +2773,11 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) break; if (!do_abort_bulks(service)) { - status = VCHIQ_RETRY; + status = -EAGAIN; break; } - if (status == VCHIQ_SUCCESS) + if (!status) status = close_service_complete(service, VCHIQ_SRVSTATE_CLOSERECVD); break; @@ -2832,7 +2841,7 @@ vchiq_free_service_internal(struct vchiq_service *service) vchiq_service_put(service); } -enum vchiq_status +int vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instance) { struct vchiq_service *service; @@ -2848,21 +2857,21 @@ vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instanc if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED) { if (queue_message(state, NULL, MAKE_CONNECT, NULL, NULL, 0, - QMFLAGS_IS_BLOCKING) == VCHIQ_RETRY) - return VCHIQ_RETRY; + QMFLAGS_IS_BLOCKING) == -EAGAIN) + return -EAGAIN; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTING); } if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) { if (wait_for_completion_interruptible(&state->connect)) - return VCHIQ_RETRY; + return -EAGAIN; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); complete(&state->connect); } - return VCHIQ_SUCCESS; + return 0; } void @@ -2879,15 +2888,15 @@ vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instan } } -enum vchiq_status +int vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(instance, handle); - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; if (!service) - return VCHIQ_ERROR; + return -EINVAL; vchiq_log_info(vchiq_core_log_level, "%d: close_service:%d", service->state->id, service->localport); @@ -2896,14 +2905,14 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) (service->srvstate == VCHIQ_SRVSTATE_LISTENING) || (service->srvstate == VCHIQ_SRVSTATE_HIDDEN)) { vchiq_service_put(service); - return VCHIQ_ERROR; + return -EINVAL; } mark_service_closing(service); if (current == service->state->slot_handler_thread) { status = vchiq_close_service_internal(service, NO_CLOSE_RECVD); - WARN_ON(status == VCHIQ_RETRY); + WARN_ON(status == -EAGAIN); } else { /* Mark the service for termination by the slot handler */ request_poll(service->state, service, VCHIQ_POLL_TERMINATE); @@ -2911,7 +2920,7 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) while (1) { if (wait_for_completion_interruptible(&service->remove_event)) { - status = VCHIQ_RETRY; + status = -EAGAIN; break; } @@ -2926,10 +2935,10 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) srvstate_names[service->srvstate]); } - if ((status == VCHIQ_SUCCESS) && + if (!status && (service->srvstate != VCHIQ_SRVSTATE_FREE) && (service->srvstate != VCHIQ_SRVSTATE_LISTENING)) - status = VCHIQ_ERROR; + status = -EINVAL; vchiq_service_put(service); @@ -2937,22 +2946,22 @@ vchiq_close_service(struct vchiq_instance *instance, unsigned int handle) } EXPORT_SYMBOL(vchiq_close_service); -enum vchiq_status +int vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) { /* Unregister the service */ struct vchiq_service *service = find_service_by_handle(instance, handle); - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; if (!service) - return VCHIQ_ERROR; + return -EINVAL; vchiq_log_info(vchiq_core_log_level, "%d: remove_service:%d", service->state->id, service->localport); if (service->srvstate == VCHIQ_SRVSTATE_FREE) { vchiq_service_put(service); - return VCHIQ_ERROR; + return -EINVAL; } mark_service_closing(service); @@ -2966,14 +2975,14 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) service->public_fourcc = VCHIQ_FOURCC_INVALID; status = vchiq_close_service_internal(service, NO_CLOSE_RECVD); - WARN_ON(status == VCHIQ_RETRY); + WARN_ON(status == -EAGAIN); } else { /* Mark the service for removal by the slot handler */ request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { if (wait_for_completion_interruptible(&service->remove_event)) { - status = VCHIQ_RETRY; + status = -EAGAIN; break; } @@ -2987,9 +2996,8 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) srvstate_names[service->srvstate]); } - if ((status == VCHIQ_SUCCESS) && - (service->srvstate != VCHIQ_SRVSTATE_FREE)) - status = VCHIQ_ERROR; + if (!status && (service->srvstate != VCHIQ_SRVSTATE_FREE)) + status = -EINVAL; vchiq_service_put(service); @@ -2998,15 +3006,15 @@ vchiq_remove_service(struct vchiq_instance *instance, unsigned int handle) /* * This function may be called by kernel threads or user threads. - * User threads may receive VCHIQ_RETRY to indicate that a signal has been + * User threads may receive -EAGAIN to indicate that a signal has been * received and the call should be retried after being returned to user * context. * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, - void *offset, void __user *uoffset, int size, void *userdata, - enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir) +int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, + void *offset, void __user *uoffset, int size, void *userdata, + enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir) { struct vchiq_service *service = find_service_by_handle(instance, handle); struct vchiq_bulk_queue *queue; @@ -3016,7 +3024,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned 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; - enum vchiq_status status = VCHIQ_ERROR; + int status = -EINVAL; int payload[2]; if (!service) @@ -3028,7 +3036,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned if (!offset && !uoffset) goto error_exit; - if (vchiq_check_service(service) != VCHIQ_SUCCESS) + if (vchiq_check_service(service)) goto error_exit; switch (mode) { @@ -3055,7 +3063,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned &service->bulk_tx : &service->bulk_rx; if (mutex_lock_killable(&service->bulk_mutex)) { - status = VCHIQ_RETRY; + status = -EAGAIN; goto error_exit; } @@ -3064,11 +3072,11 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned do { mutex_unlock(&service->bulk_mutex); if (wait_for_completion_interruptible(&service->bulk_remove_event)) { - status = VCHIQ_RETRY; + status = -EAGAIN; goto error_exit; } if (mutex_lock_killable(&service->bulk_mutex)) { - status = VCHIQ_RETRY; + status = -EAGAIN; goto error_exit; } } while (queue->local_insert == queue->remove + @@ -3101,7 +3109,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned * claim it here to ensure that isn't happening */ if (mutex_lock_killable(&state->slot_mutex)) { - status = VCHIQ_RETRY; + status = -EAGAIN; goto cancel_bulk_error_exit; } @@ -3121,7 +3129,7 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned QMFLAGS_IS_BLOCKING | QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK); - if (status != VCHIQ_SUCCESS) + if (status) goto unlock_both_error_exit; queue->local_insert++; @@ -3136,14 +3144,14 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned waiting: vchiq_service_put(service); - status = VCHIQ_SUCCESS; + status = 0; if (bulk_waiter) { bulk_waiter->bulk = bulk; if (wait_for_completion_interruptible(&bulk_waiter->event)) - status = VCHIQ_RETRY; + status = -EAGAIN; else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) - status = VCHIQ_ERROR; + status = -EINVAL; } return status; @@ -3161,7 +3169,7 @@ error_exit: return status; } -enum vchiq_status +int vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -3169,13 +3177,13 @@ vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, size_t size) { struct vchiq_service *service = find_service_by_handle(instance, handle); - enum vchiq_status status = VCHIQ_ERROR; + int status = -EINVAL; int data_id; if (!service) goto error_exit; - if (vchiq_check_service(service) != VCHIQ_SUCCESS) + if (vchiq_check_service(service)) goto error_exit; if (!size) { @@ -3200,7 +3208,7 @@ vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, copy_callback, context, size, 1); break; default: - status = VCHIQ_ERROR; + status = -EINVAL; break; } @@ -3214,18 +3222,18 @@ error_exit: int vchiq_queue_kernel_message(struct vchiq_instance *instance, unsigned int handle, void *data, unsigned int size) { - enum vchiq_status status; + int status; while (1) { status = vchiq_queue_message(instance, handle, memcpy_copy_callback, data, size); /* - * vchiq_queue_message() may return VCHIQ_RETRY, so we need to + * vchiq_queue_message() may return -EAGAIN, so we need to * implement a retry mechanism since this function is supposed * to block until queued */ - if (status != VCHIQ_RETRY) + if (status != -EAGAIN) break; msleep(1); @@ -3277,23 +3285,23 @@ release_message_sync(struct vchiq_state *state, struct vchiq_header *header) remote_event_signal(&state->remote->sync_release); } -enum vchiq_status +int vchiq_get_peer_version(struct vchiq_instance *instance, unsigned int handle, short *peer_version) { - enum vchiq_status status = VCHIQ_ERROR; + int status = -EINVAL; struct vchiq_service *service = find_service_by_handle(instance, handle); if (!service) goto exit; - if (vchiq_check_service(service) != VCHIQ_SUCCESS) + if (vchiq_check_service(service)) goto exit; if (!peer_version) goto exit; *peer_version = service->peer_version; - status = VCHIQ_SUCCESS; + status = 0; exit: if (service) @@ -3640,18 +3648,18 @@ vchiq_loud_error_footer(void) "============================================================================"); } -enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state) +int vchiq_send_remote_use(struct vchiq_state *state) { if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED) - return VCHIQ_RETRY; + return -ENOTCONN; return queue_message(state, NULL, MAKE_REMOTE_USE, NULL, NULL, 0, 0); } -enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state) +int vchiq_send_remote_use_active(struct vchiq_state *state) { if (state->conn_state == VCHIQ_CONNSTATE_DISCONNECTED) - return VCHIQ_RETRY; + return -ENOTCONN; return queue_message(state, NULL, MAKE_REMOTE_USE_ACTIVE, NULL, NULL, 0, 0); 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 8b4a38f5b3f2..ec1a3caefaea 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -10,8 +10,8 @@ #include <linux/kref.h> #include <linux/rcupdate.h> #include <linux/wait.h> -#include <linux/raspberrypi/vchiq.h> +#include "../../include/linux/raspberrypi/vchiq.h" #include "vchiq_cfg.h" /* Do this so that we can test-build the code on non-rpi systems */ @@ -166,6 +166,24 @@ struct vchiq_bulk_queue { struct vchiq_bulk bulks[VCHIQ_NUM_SERVICE_BULKS]; }; +/* + * Remote events provide a way of presenting several virtual doorbells to a + * peer (ARM host to VPU) using only one physical doorbell. They can be thought + * of as a way for the peer to signal a semaphore, in this case implemented as + * a workqueue. + * + * Remote events remain signalled until acknowledged by the receiver, and they + * are non-counting. They are designed in such a way as to minimise the number + * of interrupts and avoid unnecessary waiting. + * + * A remote_event is as small data structures that live in shared memory. It + * comprises two booleans - armed and fired: + * + * The sender sets fired when they signal the receiver. + * If fired is set, the receiver has been signalled and need not wait. + * The receiver sets the armed field before they begin to wait. + * If armed is set, the receiver is waiting and wishes to be woken by interrupt. + */ struct remote_event { int armed; int fired; @@ -458,7 +476,7 @@ vchiq_init_slots(void *mem_base, int mem_size); extern int vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero, struct device *dev); -extern enum vchiq_status +extern int vchiq_connect_internal(struct vchiq_state *state, struct vchiq_instance *instance); struct vchiq_service * @@ -467,10 +485,10 @@ vchiq_add_service_internal(struct vchiq_state *state, int srvstate, struct vchiq_instance *instance, void (*userdata_term)(void *userdata)); -extern enum vchiq_status +extern int vchiq_open_service_internal(struct vchiq_service *service, int client_id); -extern enum vchiq_status +extern int vchiq_close_service_internal(struct vchiq_service *service, int close_recvd); extern void @@ -485,7 +503,7 @@ vchiq_shutdown_internal(struct vchiq_state *state, struct vchiq_instance *instan extern void remote_event_pollall(struct vchiq_state *state); -extern enum vchiq_status +extern int vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *offset, void __user *uoffset, int size, void *userdata, enum vchiq_bulk_mode mode, enum vchiq_bulk_dir dir); @@ -536,7 +554,7 @@ vchiq_service_get(struct vchiq_service *service); extern void vchiq_service_put(struct vchiq_service *service); -extern enum vchiq_status +extern int vchiq_queue_message(struct vchiq_instance *instance, unsigned int handle, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -568,13 +586,13 @@ void vchiq_on_remote_release(struct vchiq_state *state); int vchiq_platform_init_state(struct vchiq_state *state); -enum vchiq_status vchiq_check_service(struct vchiq_service *service); +int vchiq_check_service(struct vchiq_service *service); void vchiq_on_remote_use_active(struct vchiq_state *state); -enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state); +int vchiq_send_remote_use(struct vchiq_state *state); -enum vchiq_status vchiq_send_remote_use_active(struct vchiq_state *state); +int vchiq_send_remote_use_active(struct vchiq_state *state); void vchiq_platform_conn_state_changed(struct vchiq_state *state, enum vchiq_connstate oldstate, @@ -584,7 +602,7 @@ void vchiq_set_conn_state(struct vchiq_state *state, enum vchiq_connstate newsta void vchiq_log_dump_mem(const char *label, u32 addr, const void *void_mem, size_t num_bytes); -enum vchiq_status vchiq_remove_service(struct vchiq_instance *instance, unsigned int service); +int vchiq_remove_service(struct vchiq_instance *instance, unsigned int service); int vchiq_get_client_id(struct vchiq_instance *instance, unsigned int service); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index 7e297494437e..841e1a535642 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -112,7 +112,7 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance, unsigned int handle, struct vchiq_element *elements, unsigned long count) { struct vchiq_io_copy_callback_context context; - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; unsigned long i; size_t total_size = 0; @@ -130,9 +130,9 @@ vchiq_ioc_queue_message(struct vchiq_instance *instance, unsigned int handle, status = vchiq_queue_message(instance, handle, vchiq_ioc_copy_element_data, &context, total_size); - if (status == VCHIQ_ERROR) + if (status == -EINVAL) return -EIO; - else if (status == VCHIQ_RETRY) + else if (status == -EAGAIN) return -EINTR; return 0; } @@ -142,7 +142,7 @@ static int vchiq_ioc_create_service(struct vchiq_instance *instance, { struct user_service *user_service = NULL; struct vchiq_service *service; - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; struct vchiq_service_params_kernel params; int srvstate; @@ -190,9 +190,9 @@ static int vchiq_ioc_create_service(struct vchiq_instance *instance, if (args->is_open) { status = vchiq_open_service_internal(service, instance->pid); - if (status != VCHIQ_SUCCESS) { + if (status) { vchiq_remove_service(instance, service->handle); - return (status == VCHIQ_RETRY) ? + return (status == -EAGAIN) ? -EINTR : -EIO; } } @@ -338,7 +338,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, goto out; } - if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || + if ((status != -EAGAIN) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { if (waiter->bulk_waiter.bulk) { /* Cancel the signal when the transfer completes. */ @@ -364,9 +364,9 @@ out: vchiq_service_put(service); if (ret) return ret; - else if (status == VCHIQ_ERROR) + else if (status == -EINVAL) return -EIO; - else if (status == VCHIQ_RETRY) + else if (status == -EAGAIN) return -EINTR; return 0; } @@ -577,7 +577,7 @@ static long vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct vchiq_instance *instance = file->private_data; - enum vchiq_status status = VCHIQ_SUCCESS; + int status = 0; struct vchiq_service *service = NULL; long ret = 0; int i, rc; @@ -598,12 +598,12 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) instance, &i))) { status = vchiq_remove_service(instance, service->handle); vchiq_service_put(service); - if (status != VCHIQ_SUCCESS) + if (status) break; } service = NULL; - if (status == VCHIQ_SUCCESS) { + if (!status) { /* Wake the completion thread and ask it to exit */ instance->closing = 1; complete(&instance->insert_event); @@ -627,7 +627,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) status = vchiq_connect_internal(instance->state, instance); mutex_unlock(&instance->state->mutex); - if (status == VCHIQ_SUCCESS) + if (!status) instance->connected = 1; else vchiq_log_error(vchiq_arm_log_level, @@ -675,7 +675,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ? vchiq_close_service(instance, service->handle) : vchiq_remove_service(instance, service->handle); - if (status != VCHIQ_SUCCESS) + if (status) break; } @@ -686,7 +686,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) */ if (user_service->close_pending && wait_for_completion_interruptible(&user_service->close_event)) - status = VCHIQ_RETRY; + status = -EAGAIN; break; } @@ -862,13 +862,13 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) vchiq_service_put(service); if (ret == 0) { - if (status == VCHIQ_ERROR) + if (status == -EINVAL) ret = -EIO; - else if (status == VCHIQ_RETRY) + else if (status == -EAGAIN) ret = -EINTR; } - if ((status == VCHIQ_SUCCESS) && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK)) + if (!status && (ret < 0) && (ret != -EINTR) && (ret != -EWOULDBLOCK)) vchiq_log_info(vchiq_arm_log_level, " ioctl instance %pK, cmd %s -> status %d, %ld", instance, (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? 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 86d77f2eeea5..17550831f86c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -5,17 +5,18 @@ #define VCHIQ_IOCTLS_H #include <linux/ioctl.h> -#include <linux/raspberrypi/vchiq.h> + +#include "../../include/linux/raspberrypi/vchiq.h" #define VCHIQ_IOC_MAGIC 0xc4 #define VCHIQ_INVALID_HANDLE (~0) struct vchiq_service_params { int fourcc; - enum vchiq_status __user (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); + int __user (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void __user *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/Makefile b/drivers/staging/vc04_services/vchiq-mmal/Makefile index b2a830f48acc..6937f6534c26 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/Makefile +++ b/drivers/staging/vc04_services/vchiq-mmal/Makefile @@ -2,8 +2,3 @@ bcm2835-mmal-vchiq-objs := mmal-vchiq.o obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += bcm2835-mmal-vchiq.o - -ccflags-y += \ - -I$(srctree)/$(src)/.. \ - -I$(srctree)/$(src)/../include \ - -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 294b184d4a49..258aa0e37f55 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -23,9 +23,9 @@ #include <linux/slab.h> #include <linux/completion.h> #include <linux/vmalloc.h> -#include <linux/raspberrypi/vchiq.h> #include <media/videobuf2-vmalloc.h> +#include "../include/linux/raspberrypi/vchiq.h" #include "mmal-common.h" #include "mmal-vchiq.h" #include "mmal-msg.h" @@ -245,7 +245,7 @@ static void event_to_host_cb(struct vchiq_mmal_instance *instance, /* workqueue scheduled callback * * we do this because it is important we do not call any other vchiq - * sync calls from witin the message delivery thread + * sync calls from within the message delivery thread */ static void buffer_work_cb(struct work_struct *work) { @@ -548,10 +548,9 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, } /* incoming event service callback */ -static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance, - enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, void *bulk_ctx) +static int service_callback(struct vchiq_instance *vchiq_instance, + enum vchiq_reason reason, struct vchiq_header *header, + unsigned int handle, void *bulk_ctx) { struct vchiq_mmal_instance *instance = vchiq_get_service_userdata(vchiq_instance, handle); u32 msg_len; @@ -560,7 +559,7 @@ static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance, if (!instance) { pr_err("Message callback passed NULL instance\n"); - return VCHIQ_SUCCESS; + return 0; } switch (reason) { @@ -644,7 +643,7 @@ static enum vchiq_status service_callback(struct vchiq_instance *vchiq_instance, break; } - return VCHIQ_SUCCESS; + return 0; } static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, diff --git a/drivers/staging/vme_user/vme.h b/drivers/staging/vme_user/vme.h index 98da8d039d60..faa9816046a9 100644 --- a/drivers/staging/vme_user/vme.h +++ b/drivers/staging/vme_user/vme.h @@ -2,6 +2,8 @@ #ifndef _VME_H_ #define _VME_H_ +#include <linux/bitops.h> + /* Resource Type */ enum vme_resource_type { VME_MASTER, @@ -54,20 +56,20 @@ enum vme_resource_type { #define VME_R_ROBIN_MODE 0x1 #define VME_PRIORITY_MODE 0x2 -#define VME_DMA_PATTERN (1<<0) -#define VME_DMA_PCI (1<<1) -#define VME_DMA_VME (1<<2) +#define VME_DMA_PATTERN BIT(0) +#define VME_DMA_PCI BIT(1) +#define VME_DMA_VME BIT(2) -#define VME_DMA_PATTERN_BYTE (1<<0) -#define VME_DMA_PATTERN_WORD (1<<1) -#define VME_DMA_PATTERN_INCREMENT (1<<2) +#define VME_DMA_PATTERN_BYTE BIT(0) +#define VME_DMA_PATTERN_WORD BIT(1) +#define VME_DMA_PATTERN_INCREMENT BIT(2) -#define VME_DMA_VME_TO_MEM (1<<0) -#define VME_DMA_MEM_TO_VME (1<<1) -#define VME_DMA_VME_TO_VME (1<<2) -#define VME_DMA_MEM_TO_MEM (1<<3) -#define VME_DMA_PATTERN_TO_VME (1<<4) -#define VME_DMA_PATTERN_TO_MEM (1<<5) +#define VME_DMA_VME_TO_MEM BIT(0) +#define VME_DMA_MEM_TO_VME BIT(1) +#define VME_DMA_VME_TO_VME BIT(2) +#define VME_DMA_MEM_TO_MEM BIT(3) +#define VME_DMA_PATTERN_TO_VME BIT(4) +#define VME_DMA_PATTERN_TO_MEM BIT(5) struct vme_dma_attr { u32 type; diff --git a/drivers/staging/vme_user/vme_bridge.h b/drivers/staging/vme_user/vme_bridge.h index 0bbefe9851d7..11df0a5e7f7b 100644 --- a/drivers/staging/vme_user/vme_bridge.h +++ b/drivers/staging/vme_user/vme_bridge.h @@ -4,7 +4,7 @@ #include "vme.h" -#define VME_CRCSR_BUF_SIZE (508*1024) +#define VME_CRCSR_BUF_SIZE (508 * 1024) /* * Resource structures */ @@ -84,7 +84,7 @@ struct vme_error_handler { unsigned long long end; /* End of error window */ unsigned long long first_error; /* Address of the first error */ u32 aspace; /* Address space of error window*/ - unsigned num_errors; /* Number of errors */ + unsigned int num_errors; /* Number of errors */ }; struct vme_callback { @@ -128,45 +128,45 @@ struct vme_bridge { struct mutex irq_mtx; /* Slave Functions */ - int (*slave_get) (struct vme_slave_resource *, int *, + int (*slave_get)(struct vme_slave_resource *, int *, unsigned long long *, unsigned long long *, dma_addr_t *, u32 *, u32 *); - int (*slave_set) (struct vme_slave_resource *, int, unsigned long long, + int (*slave_set)(struct vme_slave_resource *, int, unsigned long long, unsigned long long, dma_addr_t, u32, u32); /* Master Functions */ - int (*master_get) (struct vme_master_resource *, int *, + int (*master_get)(struct vme_master_resource *, int *, unsigned long long *, unsigned long long *, u32 *, u32 *, u32 *); - int (*master_set) (struct vme_master_resource *, int, + int (*master_set)(struct vme_master_resource *, int, unsigned long long, unsigned long long, u32, u32, u32); - ssize_t (*master_read) (struct vme_master_resource *, void *, size_t, + ssize_t (*master_read)(struct vme_master_resource *, void *, size_t, loff_t); - ssize_t (*master_write) (struct vme_master_resource *, void *, size_t, + ssize_t (*master_write)(struct vme_master_resource *, void *, size_t, loff_t); - unsigned int (*master_rmw) (struct vme_master_resource *, unsigned int, + unsigned int (*master_rmw)(struct vme_master_resource *, unsigned int, unsigned int, unsigned int, loff_t); /* DMA Functions */ - int (*dma_list_add) (struct vme_dma_list *, struct vme_dma_attr *, + int (*dma_list_add)(struct vme_dma_list *, struct vme_dma_attr *, struct vme_dma_attr *, size_t); - int (*dma_list_exec) (struct vme_dma_list *); - int (*dma_list_empty) (struct vme_dma_list *); + int (*dma_list_exec)(struct vme_dma_list *); + int (*dma_list_empty)(struct vme_dma_list *); /* Interrupt Functions */ - void (*irq_set) (struct vme_bridge *, int, int, int); - int (*irq_generate) (struct vme_bridge *, int, int); + void (*irq_set)(struct vme_bridge *, int, int, int); + int (*irq_generate)(struct vme_bridge *, int, int); /* Location monitor functions */ - int (*lm_set) (struct vme_lm_resource *, unsigned long long, u32, u32); - int (*lm_get) (struct vme_lm_resource *, unsigned long long *, u32 *, + int (*lm_set)(struct vme_lm_resource *, unsigned long long, u32, u32); + int (*lm_get)(struct vme_lm_resource *, unsigned long long *, u32 *, u32 *); int (*lm_attach)(struct vme_lm_resource *, int, void (*callback)(void *), void *); - int (*lm_detach) (struct vme_lm_resource *, int); + int (*lm_detach)(struct vme_lm_resource *, int); /* CR/CSR space functions */ - int (*slot_get) (struct vme_bridge *); + int (*slot_get)(struct vme_bridge *); /* Bridge parent interface */ void *(*alloc_consistent)(struct device *dev, size_t size, diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 0611e37df6ac..e33dd1b9c40e 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -904,40 +904,6 @@ union hfa384x_usbin { *-------------------------------------------------------------------- */ -struct hfa384x_pdr_pcb_partnum { - u8 num[8]; -} __packed; - -struct hfa384x_pdr_pcb_tracenum { - u8 num[8]; -} __packed; - -struct hfa384x_pdr_nic_serial { - u8 num[12]; -} __packed; - -struct hfa384x_pdr_mkk_measurements { - double carrier_freq; - double occupied_band; - double power_density; - double tx_spur_f1; - double tx_spur_f2; - double tx_spur_f3; - double tx_spur_f4; - double tx_spur_l1; - double tx_spur_l2; - double tx_spur_l3; - double tx_spur_l4; - double rx_spur_f1; - double rx_spur_f2; - double rx_spur_l1; - double rx_spur_l2; -} __packed; - -struct hfa384x_pdr_nic_ramsize { - u8 size[12]; /* units of KB */ -} __packed; - struct hfa384x_pdr_mfisuprange { u16 id; u16 variant; @@ -959,150 +925,13 @@ struct hfa384x_pdr_nicid { u16 minor; } __packed; -struct hfa384x_pdr_refdac_measurements { - u16 value[0]; -} __packed; - -struct hfa384x_pdr_vgdac_measurements { - u16 value[0]; -} __packed; - -struct hfa384x_pdr_level_comp_measurements { - u16 value[0]; -} __packed; - -struct hfa384x_pdr_mac_address { - u8 addr[6]; -} __packed; - -struct hfa384x_pdr_mkk_callname { - u8 callname[8]; -} __packed; - -struct hfa384x_pdr_regdomain { - u16 numdomains; - u16 domain[5]; -} __packed; - -struct hfa384x_pdr_allowed_channel { - u16 ch_bitmap; -} __packed; - -struct hfa384x_pdr_default_channel { - u16 channel; -} __packed; - -struct hfa384x_pdr_privacy_option { - u16 available; -} __packed; - -struct hfa384x_pdr_temptype { - u16 type; -} __packed; - -struct hfa384x_pdr_refdac_setup { - u16 ch_value[14]; -} __packed; - -struct hfa384x_pdr_vgdac_setup { - u16 ch_value[14]; -} __packed; - -struct hfa384x_pdr_level_comp_setup { - u16 ch_value[14]; -} __packed; - -struct hfa384x_pdr_trimdac_setup { - u16 trimidac; - u16 trimqdac; -} __packed; - -struct hfa384x_pdr_ifr_setting { - u16 value[3]; -} __packed; - -struct hfa384x_pdr_rfr_setting { - u16 value[3]; -} __packed; - -struct hfa384x_pdr_hfa3861_baseline { - u16 value[50]; -} __packed; - -struct hfa384x_pdr_hfa3861_shadow { - u32 value[32]; -} __packed; - -struct hfa384x_pdr_hfa3861_ifrf { - u32 value[20]; -} __packed; - -struct hfa384x_pdr_hfa3861_chcalsp { - u16 value[14]; -} __packed; - -struct hfa384x_pdr_hfa3861_chcali { - u16 value[17]; -} __packed; - -struct hfa384x_pdr_hfa3861_nic_config { - u16 config_bitmap; -} __packed; - -struct hfa384x_pdr_hfo_delay { - u8 hfo_delay; -} __packed; - -struct hfa384x_pdr_hfa3861_manf_testsp { - u16 value[30]; -} __packed; - -struct hfa384x_pdr_hfa3861_manf_testi { - u16 value[30]; -} __packed; - -struct hfa384x_pdr_end_of_pda { - u16 crc; -} __packed; - struct hfa384x_pdrec { __le16 len; /* in words */ __le16 code; union pdr { - struct hfa384x_pdr_pcb_partnum pcb_partnum; - struct hfa384x_pdr_pcb_tracenum pcb_tracenum; - struct hfa384x_pdr_nic_serial nic_serial; - struct hfa384x_pdr_mkk_measurements mkk_measurements; - struct hfa384x_pdr_nic_ramsize nic_ramsize; struct hfa384x_pdr_mfisuprange mfisuprange; struct hfa384x_pdr_cfisuprange cfisuprange; struct hfa384x_pdr_nicid nicid; - struct hfa384x_pdr_refdac_measurements refdac_measurements; - struct hfa384x_pdr_vgdac_measurements vgdac_measurements; - struct hfa384x_pdr_level_comp_measurements level_compc_measurements; - struct hfa384x_pdr_mac_address mac_address; - struct hfa384x_pdr_mkk_callname mkk_callname; - struct hfa384x_pdr_regdomain regdomain; - struct hfa384x_pdr_allowed_channel allowed_channel; - struct hfa384x_pdr_default_channel default_channel; - struct hfa384x_pdr_privacy_option privacy_option; - struct hfa384x_pdr_temptype temptype; - struct hfa384x_pdr_refdac_setup refdac_setup; - struct hfa384x_pdr_vgdac_setup vgdac_setup; - struct hfa384x_pdr_level_comp_setup level_comp_setup; - struct hfa384x_pdr_trimdac_setup trimdac_setup; - struct hfa384x_pdr_ifr_setting ifr_setting; - struct hfa384x_pdr_rfr_setting rfr_setting; - struct hfa384x_pdr_hfa3861_baseline hfa3861_baseline; - struct hfa384x_pdr_hfa3861_shadow hfa3861_shadow; - struct hfa384x_pdr_hfa3861_ifrf hfa3861_ifrf; - struct hfa384x_pdr_hfa3861_chcalsp hfa3861_chcalsp; - struct hfa384x_pdr_hfa3861_chcali hfa3861_chcali; - struct hfa384x_pdr_hfa3861_nic_config nic_config; - struct hfa384x_pdr_hfo_delay hfo_delay; - struct hfa384x_pdr_hfa3861_manf_testsp hfa3861_manf_testsp; - struct hfa384x_pdr_hfa3861_manf_testi hfa3861_manf_testi; - struct hfa384x_pdr_end_of_pda end_of_pda; } data; } __packed; |