From 64af1ab93e315d462d4562907c3c6a0ed4282cde Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 5 Jan 2024 10:32:16 +0100 Subject: staging: rtl8192e: remove return statement from void function Remove return statement from the void function _rtl92e_if_check_reset(). Found by checkpatch. WARNING: void function return statements are not generally useful Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20240105093216.13981-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 6815d18a7919..7b5d954acf6d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -909,7 +909,6 @@ static void _rtl92e_if_check_reset(struct net_device *dev) netdev_info(dev, "%s(): TxResetType is %d, RxResetType is %d\n", __func__, TxResetType, RxResetType); } - return; } static void _rtl92e_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, -- cgit v1.2.3-58-ga151 From d5cae945ebbf7f3f21cac467fc6cd6af72b92104 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:36 -0800 Subject: Staging: rtl8192e: Remove unnecessary parenthesis in rtllib_softmac_new_net() Remove parentheses to fix checkpatch Warning: Unnecessary parentheses around ieee->current_network Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-2-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b9278b26accd..520b90abcde7 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1220,7 +1220,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, if ((ieee->current_network.qos_data.supported == 1) && ieee->current_network.bssht.bd_support_ht) ht_reset_self_and_save_peer_setting(ieee, - &(ieee->current_network)); + &ieee->current_network); else ieee->ht_info->current_ht_support = false; -- cgit v1.2.3-58-ga151 From 0f5986018bd5575434fef330eec585c1120b51dd Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:37 -0800 Subject: Staging: rtl8192e: Rename variable SlotIndex Rename variable SlotIndex to slot_index to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-3-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 8 ++++---- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 8 ++++---- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index c7a2eae2fdb9..9b9d95ba06df 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -1852,7 +1852,7 @@ bool rtl92e_is_rx_stuck(struct net_device *dev) u16 RegRxCounter = rtl92e_readw(dev, 0x130); bool bStuck = false; static u8 rx_chk_cnt; - u32 SlotIndex = 0, TotalRxStuckCount = 0; + u32 slot_index = 0, TotalRxStuckCount = 0; u8 i; u8 SilentResetRxSoltNum = 4; @@ -1882,10 +1882,10 @@ bool rtl92e_is_rx_stuck(struct net_device *dev) } - SlotIndex = (priv->silent_reset_rx_slot_index++) % SilentResetRxSoltNum; + slot_index = (priv->silent_reset_rx_slot_index++) % SilentResetRxSoltNum; if (priv->rx_ctr == RegRxCounter) { - priv->silent_reset_rx_stuck_event[SlotIndex] = 1; + priv->silent_reset_rx_stuck_event[slot_index] = 1; for (i = 0; i < SilentResetRxSoltNum; i++) TotalRxStuckCount += priv->silent_reset_rx_stuck_event[i]; @@ -1897,7 +1897,7 @@ bool rtl92e_is_rx_stuck(struct net_device *dev) priv->silent_reset_rx_stuck_event[i]; } } else { - priv->silent_reset_rx_stuck_event[SlotIndex] = 0; + priv->silent_reset_rx_stuck_event[slot_index] = 0; } priv->rx_ctr = RegRxCounter; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 7b5d954acf6d..49c5d308097a 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -914,17 +914,17 @@ static void _rtl92e_if_check_reset(struct net_device *dev) static void _rtl92e_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, u32 *TotalRxDataNum) { - u16 SlotIndex; + u16 slot_index; u8 i; *TotalRxBcnNum = 0; *TotalRxDataNum = 0; - SlotIndex = (priv->rtllib->link_detect_info.SlotIndex++) % + slot_index = (priv->rtllib->link_detect_info.slot_index++) % (priv->rtllib->link_detect_info.SlotNum); - priv->rtllib->link_detect_info.RxBcnNum[SlotIndex] = + priv->rtllib->link_detect_info.RxBcnNum[slot_index] = priv->rtllib->link_detect_info.NumRecvBcnInPeriod; - priv->rtllib->link_detect_info.RxDataNum[SlotIndex] = + priv->rtllib->link_detect_info.RxDataNum[slot_index] = priv->rtllib->link_detect_info.NumRecvDataInPeriod; for (i = 0; i < priv->rtllib->link_detect_info.SlotNum; i++) { *TotalRxBcnNum += priv->rtllib->link_detect_info.RxBcnNum[i]; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 7b39a1987fdd..37bcd968a542 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1116,7 +1116,7 @@ struct rt_link_detect { u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; u16 SlotNum; - u16 SlotIndex; + u16 slot_index; u32 num_tx_ok_in_period; u32 num_rx_ok_in_period; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 520b90abcde7..1d490704389e 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2072,7 +2072,7 @@ int rtllib_softmac_init(struct rtllib_device *ieee) for (i = 0; i < 5; i++) ieee->seq_ctrl[i] = 0; - ieee->link_detect_info.SlotIndex = 0; + ieee->link_detect_info.slot_index = 0; ieee->link_detect_info.SlotNum = 2; ieee->link_detect_info.NumRecvBcnInPeriod = 0; ieee->link_detect_info.NumRecvDataInPeriod = 0; -- cgit v1.2.3-58-ga151 From 7fe65bc52d660309a8f51821e7ce3bce9042eac7 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:38 -0800 Subject: Staging: rtl8192e: Rename function rtllib_MgntDisconnectAP() Rename function rtllib_MgntDisconnectAP to rtllib_mgnt_disconnect_ap to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-4-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 1d490704389e..6f730242728a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2265,7 +2265,7 @@ static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, } } -static void rtllib_MgntDisconnectAP(struct rtllib_device *rtllib, u8 asRsn) +static void rtllib_mgnt_disconnect_ap(struct rtllib_device *rtllib, u8 asRsn) { bool bFilterOutNonAssociatedBSSID = false; @@ -2285,7 +2285,7 @@ bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn) if (rtllib->link_state == MAC80211_LINKED) { if (rtllib->iw_mode == IW_MODE_INFRA) - rtllib_MgntDisconnectAP(rtllib, asRsn); + rtllib_mgnt_disconnect_ap(rtllib, asRsn); } return true; -- cgit v1.2.3-58-ga151 From 9ad8d831a08e28fa532d3fd0db359afdb1e3bab4 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:39 -0800 Subject: Staging: rtl8192e: Rename variable bMulticast Rename variable bMulticast to multicast to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-5-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- drivers/staging/rtl8192e/rtllib_tx.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 37bcd968a542..9d3c79105508 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -123,7 +123,7 @@ struct cb_desc { u8 bPacketBW:1; u8 bRTSUseShortPreamble:1; u8 bRTSUseShortGI:1; - u8 bMulticast:1; + u8 multicast:1; u8 bBroadcast:1; u8 drv_agg_enable:1; u8 reserved2:1; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 6f730242728a..9db834f5d637 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1816,7 +1816,7 @@ void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee) /* update the tx status */ tcb_desc = (struct cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); - if (tcb_desc->bMulticast) + if (tcb_desc->multicast) ieee->stats.multicast++; /* if xmit available, just xmit it immediately, else just insert it to diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index f7098a2ba8b0..f1e9a0390be0 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -356,7 +356,7 @@ static void rtllib_query_BandwidthMode(struct rtllib_device *ieee, if (!ht_info->current_ht_support || !ht_info->enable_ht) return; - if (tcb_desc->bMulticast || tcb_desc->bBroadcast) + if (tcb_desc->multicast || tcb_desc->bBroadcast) return; if ((tcb_desc->data_rate & 0x80) == 0) @@ -378,7 +378,7 @@ static void rtllib_query_protectionmode(struct rtllib_device *ieee, tcb_desc->RTSSC = 0; tcb_desc->bRTSBW = false; - if (tcb_desc->bBroadcast || tcb_desc->bMulticast) + if (tcb_desc->bBroadcast || tcb_desc->multicast) return; if (is_broadcast_ether_addr(skb->data + 16)) @@ -843,11 +843,11 @@ static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) tcb_desc->tx_use_drv_assinged_rate = 1; } else { if (is_multicast_ether_addr(header.addr1)) - tcb_desc->bMulticast = 1; + tcb_desc->multicast = 1; if (is_broadcast_ether_addr(header.addr1)) tcb_desc->bBroadcast = 1; rtllib_txrate_selectmode(ieee, tcb_desc); - if (tcb_desc->bMulticast || tcb_desc->bBroadcast) + if (tcb_desc->multicast || tcb_desc->bBroadcast) tcb_desc->data_rate = ieee->basic_rate; else tcb_desc->data_rate = rtllib_current_rate(ieee); -- cgit v1.2.3-58-ga151 From 698888bdbde4c3e250f6f7f846db19d412db3f99 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:40 -0800 Subject: Staging: rtl8192e: Rename variable MaxPeriod Rename variable MaxPeriod to max_period to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-6-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 9db834f5d637..0d53e0a92a4c 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1381,12 +1381,12 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) if (ieee->bAwakePktSent) { psc->LPSAwakeIntvl = 1; } else { - u8 MaxPeriod = 5; + u8 max_period = 5; if (psc->LPSAwakeIntvl == 0) psc->LPSAwakeIntvl = 1; psc->LPSAwakeIntvl = (psc->LPSAwakeIntvl >= - MaxPeriod) ? MaxPeriod : + max_period) ? max_period : (psc->LPSAwakeIntvl + 1); } { -- cgit v1.2.3-58-ga151 From eba9c98485df2d142af106e5ba4359ab3da6cb43 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:41 -0800 Subject: Staging: rtl8192e: Rename variable bAwakePktSent Rename variable bAwakePktSent to awake_pkt_sent to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-7-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 49c5d308097a..d0898df6053d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1256,7 +1256,7 @@ static short _rtl92e_tx(struct net_device *dev, struct sk_buff *skb) int idx; u32 fwinfo_size = 0; - priv->rtllib->bAwakePktSent = true; + priv->rtllib->awake_pkt_sent = true; fwinfo_size = sizeof(struct tx_fwinfo_8190pci); diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 9d3c79105508..9d6704fc86ff 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1374,7 +1374,7 @@ struct rtllib_device { /* for PS mode */ unsigned long last_rx_ps_time; - bool bAwakePktSent; + bool awake_pkt_sent; u8 LPSDelayCnt; /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */ diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 0d53e0a92a4c..08ff55c2f1be 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1378,7 +1378,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time) return 0; if (time) { - if (ieee->bAwakePktSent) { + if (ieee->awake_pkt_sent) { psc->LPSAwakeIntvl = 1; } else { u8 max_period = 5; @@ -1461,7 +1461,7 @@ static inline void rtllib_sta_ps(struct work_struct *work) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - ieee->bAwakePktSent = false; + ieee->awake_pkt_sent = false; } else if (sleep == 2) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); -- cgit v1.2.3-58-ga151 From c7c4440d19623011ff72c966b5d0f1bb37479649 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:42 -0800 Subject: Staging: rtl8192e: Rename variable bSupportNmode Rename variable bSupportNmode to support_nmode to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-8-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 08ff55c2f1be..85e6e727bec7 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1648,7 +1648,7 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) int errcode; u8 *challenge; int chlen = 0; - bool bSupportNmode = true, bHalfSupportNmode = false; + bool support_nmode = true, bHalfSupportNmode = false; errcode = auth_parse(ieee->dev, skb, &challenge, &chlen); @@ -1666,16 +1666,16 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) if (!(ieee->ht_info->iot_action & HT_IOT_ACT_PURE_N_MODE)) { if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { if (is_ht_half_nmode_aps(ieee)) { - bSupportNmode = true; + support_nmode = true; bHalfSupportNmode = true; } else { - bSupportNmode = false; + support_nmode = false; bHalfSupportNmode = false; } } } /* Dummy wirless mode setting to avoid encryption issue */ - if (bSupportNmode) { + if (support_nmode) { ieee->set_wireless_mode(ieee->dev, ieee->current_network.mode); } else { -- cgit v1.2.3-58-ga151 From 6593d5bcf14a7988335e1635bc3e9e7d8f6b7137 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:43 -0800 Subject: Staging: rtl8192e: Rename variable bBusyTraffic Rename variable bBusyTraffic to busy_traffic to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-9-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +++--- drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index d0898df6053d..5d0b977b313b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -942,7 +942,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) unsigned long flags; struct rt_pwr_save_ctrl *psc = (struct rt_pwr_save_ctrl *) (&priv->rtllib->pwr_save_ctrl); - bool bBusyTraffic = false; + bool busy_traffic = false; bool bHigherBusyTraffic = false; bool bHigherBusyRxTraffic = false; bool bEnterPS = false; @@ -972,7 +972,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) if ((ieee->link_state == MAC80211_LINKED) && (ieee->iw_mode == IW_MODE_INFRA)) { if (ieee->link_detect_info.num_rx_ok_in_period > 100 || ieee->link_detect_info.num_tx_ok_in_period > 100) - bBusyTraffic = true; + busy_traffic = true; if (ieee->link_detect_info.num_rx_ok_in_period > 4000 || ieee->link_detect_info.num_tx_ok_in_period > 4000) { @@ -1005,7 +1005,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) ieee->link_detect_info.num_rx_ok_in_period = 0; ieee->link_detect_info.num_tx_ok_in_period = 0; ieee->link_detect_info.NumRxUnicastOkInPeriod = 0; - ieee->link_detect_info.bBusyTraffic = bBusyTraffic; + ieee->link_detect_info.busy_traffic = busy_traffic; ieee->link_detect_info.bHigherBusyTraffic = bHigherBusyTraffic; ieee->link_detect_info.bHigherBusyRxTraffic = bHigherBusyRxTraffic; diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c index 4c884c5277f9..5fd44d0c4b1d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c @@ -253,7 +253,7 @@ static int _rtl92e_wx_set_scan(struct net_device *dev, rt_state = priv->rtllib->rf_power_state; if (!priv->up) return -ENETDOWN; - if (priv->rtllib->link_detect_info.bBusyTraffic) + if (priv->rtllib->link_detect_info.busy_traffic) return -EAGAIN; if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 9d6704fc86ff..d127528e7932 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1121,7 +1121,7 @@ struct rt_link_detect { u32 num_tx_ok_in_period; u32 num_rx_ok_in_period; u32 NumRxUnicastOkInPeriod; - bool bBusyTraffic; + bool busy_traffic; bool bHigherBusyTraffic; bool bHigherBusyRxTraffic; }; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 85e6e727bec7..40d6ae15b246 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1734,7 +1734,7 @@ rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) ieee->link_state = RTLLIB_ASSOCIATING; ieee->softmac_stats.reassoc++; ieee->is_roaming = true; - ieee->link_detect_info.bBusyTraffic = false; + ieee->link_detect_info.busy_traffic = false; rtllib_disassociate(ieee); RemovePeerTS(ieee, header->addr2); if (!(ieee->rtllib_ap_sec_type(ieee) & -- cgit v1.2.3-58-ga151 From 5d8fef84aa9a6c5eb16c076a99f2e454a5687bde Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:44 -0800 Subject: Staging: rtl8192e: Rename function rtllib_MgntDisconnect() Rename function rtllib_MgntDisconnect to rtllib_mgnt_disconnect fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-10-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 5d0b977b313b..d30a802c2650 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -172,7 +172,7 @@ bool rtl92e_set_rf_state(struct net_device *dev, priv->blinked_ingpio = true; else priv->blinked_ingpio = false; - rtllib_MgntDisconnect(priv->rtllib, + rtllib_mgnt_disconnect(priv->rtllib, WLAN_REASON_DISASSOC_STA_HAS_LEFT); } } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index d127528e7932..35c66ecd20e6 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1805,7 +1805,7 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) } /* fun with the built-in rtllib stack... */ -bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn); +bool rtllib_mgnt_disconnect(struct rtllib_device *rtllib, u8 asRsn); /* For the function is more related to hardware setting, it's better to use the * ieee handler to refer to it. diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 40d6ae15b246..3d7fad28c414 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2278,7 +2278,7 @@ static void rtllib_mgnt_disconnect_ap(struct rtllib_device *rtllib, u8 asRsn) rtllib->link_state = MAC80211_NOLINK; } -bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn) +bool rtllib_mgnt_disconnect(struct rtllib_device *rtllib, u8 asRsn) { if (rtllib->ps != RTLLIB_PS_DISABLED) rtllib->sta_wake_up(rtllib->dev); @@ -2290,7 +2290,7 @@ bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn) return true; } -EXPORT_SYMBOL(rtllib_MgntDisconnect); +EXPORT_SYMBOL(rtllib_mgnt_disconnect); void notify_wx_assoc_event(struct rtllib_device *ieee) { -- cgit v1.2.3-58-ga151 From e2bf5a27c0fb921d63798076d7b183c7d58b271f Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:45 -0800 Subject: Staging: rtl8192e: Rename variable bFilterOutNonAssociatedBSSID Rename variable bFilterOutNonAssociatedBSSID -> filter_out_nonassociated_bssid to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-11-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 3d7fad28c414..98c1041214fb 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2267,11 +2267,11 @@ static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, static void rtllib_mgnt_disconnect_ap(struct rtllib_device *rtllib, u8 asRsn) { - bool bFilterOutNonAssociatedBSSID = false; + bool filter_out_nonassociated_bssid = false; - bFilterOutNonAssociatedBSSID = false; + filter_out_nonassociated_bssid = false; rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, - (u8 *)(&bFilterOutNonAssociatedBSSID)); + (u8 *)(&filter_out_nonassociated_bssid)); rtllib_MlmeDisassociateRequest(rtllib, rtllib->current_network.bssid, asRsn); -- cgit v1.2.3-58-ga151 From a89dd127306ebf090607554f644fbf2b52a71884 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:46 -0800 Subject: Staging: rtl8192e: Rename variable array Bssid Rename variable array Bssid -> bssid to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-12-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 35c66ecd20e6..f379819287b4 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1161,7 +1161,7 @@ struct rate_adaptive { #define NUM_PMKID_CACHE 16 struct rt_pmkid_list { - u8 Bssid[ETH_ALEN]; + u8 bssid[ETH_ALEN]; u8 PMKID[16]; u8 SsidBuf[33]; u8 used; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 98c1041214fb..8fb69fa09cc2 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -671,7 +671,7 @@ static inline int SecIsInPMKIDList(struct rtllib_device *ieee, u8 *bssid) do { if ((ieee->PMKIDList[i].used) && - (memcmp(ieee->PMKIDList[i].Bssid, bssid, ETH_ALEN) == 0)) + (memcmp(ieee->PMKIDList[i].bssid, bssid, ETH_ALEN) == 0)) break; i++; } while (i < NUM_PMKID_CACHE); -- cgit v1.2.3-58-ga151 From 124f2e444e6cfe518aea81bb9f92bb75179ca9f6 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:47 -0800 Subject: Staging: rtl8192e: Rename variable NumRxUnicastOkInPeriod Rename variable NumRxUnicastOkInPeriod to num_rx_unicast_ok_in_period to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-13-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 6 +++--- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 6 +++--- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index d30a802c2650..5f19d62a9244 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -983,9 +983,9 @@ static void _rtl92e_watchdog_wq_cb(void *data) bHigherBusyRxTraffic = false; } - if (((ieee->link_detect_info.NumRxUnicastOkInPeriod + + if (((ieee->link_detect_info.num_rx_unicast_ok_in_period + ieee->link_detect_info.num_tx_ok_in_period) > 8) || - (ieee->link_detect_info.NumRxUnicastOkInPeriod > 2)) + (ieee->link_detect_info.num_rx_unicast_ok_in_period > 2)) bEnterPS = false; else bEnterPS = true; @@ -1004,7 +1004,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) ieee->link_detect_info.num_rx_ok_in_period = 0; ieee->link_detect_info.num_tx_ok_in_period = 0; - ieee->link_detect_info.NumRxUnicastOkInPeriod = 0; + ieee->link_detect_info.num_rx_unicast_ok_in_period = 0; ieee->link_detect_info.busy_traffic = busy_traffic; ieee->link_detect_info.bHigherBusyTraffic = bHigherBusyTraffic; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index f379819287b4..5cab1aa6455a 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1120,7 +1120,7 @@ struct rt_link_detect { u32 num_tx_ok_in_period; u32 num_rx_ok_in_period; - u32 NumRxUnicastOkInPeriod; + u32 num_rx_unicast_ok_in_period; bool busy_traffic; bool bHigherBusyTraffic; bool bHigherBusyRxTraffic; diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 4df20f4d6bf9..f777febcfe3b 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1149,9 +1149,9 @@ static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, { if (unicast) { if (ieee->link_state == MAC80211_LINKED) { - if (((ieee->link_detect_info.NumRxUnicastOkInPeriod + + if (((ieee->link_detect_info.num_rx_unicast_ok_in_period + ieee->link_detect_info.num_tx_ok_in_period) > 8) || - (ieee->link_detect_info.NumRxUnicastOkInPeriod > 2)) { + (ieee->link_detect_info.num_rx_unicast_ok_in_period > 2)) { ieee->leisure_ps_leave(ieee->dev); } } @@ -1363,7 +1363,7 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb, else nr_subframes = 1; if (unicast) - ieee->link_detect_info.NumRxUnicastOkInPeriod += nr_subframes; + ieee->link_detect_info.num_rx_unicast_ok_in_period += nr_subframes; rtllib_rx_check_leave_lps(ieee, unicast, nr_subframes); /* Indicate packets to upper layer or Rx Reorder */ diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 8fb69fa09cc2..9a9b8f63218b 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2078,7 +2078,7 @@ int rtllib_softmac_init(struct rtllib_device *ieee) ieee->link_detect_info.NumRecvDataInPeriod = 0; ieee->link_detect_info.num_tx_ok_in_period = 0; ieee->link_detect_info.num_rx_ok_in_period = 0; - ieee->link_detect_info.NumRxUnicastOkInPeriod = 0; + ieee->link_detect_info.num_rx_unicast_ok_in_period = 0; ieee->is_aggregate_frame = false; ieee->assoc_id = 0; ieee->queue_stop = 0; -- cgit v1.2.3-58-ga151 From 254c59bfdeaf7987d08317e08f55760ef857675f Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:48 -0800 Subject: Staging: rtl8192e: Rename variable SlotNum Rename variable SlotNum to slot_num to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-14-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 5f19d62a9244..bfba6d1a278b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -921,12 +921,12 @@ static void _rtl92e_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, *TotalRxDataNum = 0; slot_index = (priv->rtllib->link_detect_info.slot_index++) % - (priv->rtllib->link_detect_info.SlotNum); + (priv->rtllib->link_detect_info.slot_num); priv->rtllib->link_detect_info.RxBcnNum[slot_index] = priv->rtllib->link_detect_info.NumRecvBcnInPeriod; priv->rtllib->link_detect_info.RxDataNum[slot_index] = priv->rtllib->link_detect_info.NumRecvDataInPeriod; - for (i = 0; i < priv->rtllib->link_detect_info.SlotNum; i++) { + for (i = 0; i < priv->rtllib->link_detect_info.slot_num; i++) { *TotalRxBcnNum += priv->rtllib->link_detect_info.RxBcnNum[i]; *TotalRxDataNum += priv->rtllib->link_detect_info.RxDataNum[i]; } diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 5cab1aa6455a..26ceb579afeb 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1115,7 +1115,7 @@ struct rt_link_detect { u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; - u16 SlotNum; + u16 slot_num; u16 slot_index; u32 num_tx_ok_in_period; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 9a9b8f63218b..d7edfa1dca65 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1072,7 +1072,7 @@ static void rtllib_associate_complete_wq(void *data) ieee->ht_info->enable_ht); memset(ieee->dot11ht_oper_rate_set, 0, 16); } - ieee->link_detect_info.SlotNum = 2 * (1 + + ieee->link_detect_info.slot_num = 2 * (1 + ieee->current_network.beacon_interval / 500); if (ieee->link_detect_info.NumRecvBcnInPeriod == 0 || @@ -2073,7 +2073,7 @@ int rtllib_softmac_init(struct rtllib_device *ieee) ieee->seq_ctrl[i] = 0; ieee->link_detect_info.slot_index = 0; - ieee->link_detect_info.SlotNum = 2; + ieee->link_detect_info.slot_num = 2; ieee->link_detect_info.NumRecvBcnInPeriod = 0; ieee->link_detect_info.NumRecvDataInPeriod = 0; ieee->link_detect_info.num_tx_ok_in_period = 0; -- cgit v1.2.3-58-ga151 From f70205ad3c2369d7c6c647f62c74c333e88cabf9 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:49 -0800 Subject: Staging: rtl8192e: Rename variable RemoveAllTS Rename variable RemoveAllTS to remove_all_ts to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-15-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_TSProc.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 7e73d31dcccf..48374cae816d 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -402,7 +402,7 @@ void RemovePeerTS(struct rtllib_device *ieee, u8 *addr) } EXPORT_SYMBOL(RemovePeerTS); -void RemoveAllTS(struct rtllib_device *ieee) +void remove_all_ts(struct rtllib_device *ieee) { struct ts_common_info *ts, *pTmpTS; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 26ceb579afeb..ed9ca77fbcb9 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1789,7 +1789,7 @@ void rtllib_ts_init(struct rtllib_device *ieee); void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS); void RemovePeerTS(struct rtllib_device *ieee, u8 *addr); -void RemoveAllTS(struct rtllib_device *ieee); +void remove_all_ts(struct rtllib_device *ieee); static inline const char *escape_essid(const char *essid, u8 essid_len) { diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index d7edfa1dca65..b9750c9b3952 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2002,7 +2002,7 @@ void rtllib_stop_protocol(struct rtllib_device *ieee) rtllib_disassociate(ieee); } - RemoveAllTS(ieee); + remove_all_ts(ieee); ieee->proto_stoppping = 0; kfree(ieee->assocreq_ies); -- cgit v1.2.3-58-ga151 From b7e6e1ef1960cb49113a85788ec4a9f6ae0523b7 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:50 -0800 Subject: Staging: rtl8192e: Rename function RemovePeerTS() Rename function RemovePeerTS to remove_peer_ts to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-16-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtl819x_TSProc.c | 4 ++-- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index bfba6d1a278b..3889443330cf 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1031,7 +1031,7 @@ static void _rtl92e_watchdog_wq_cb(void *data) ieee->link_state = RTLLIB_ASSOCIATING; - RemovePeerTS(priv->rtllib, + remove_peer_ts(priv->rtllib, priv->rtllib->current_network.bssid); ieee->is_roaming = true; ieee->is_set_key = false; diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c index 48374cae816d..e9a193b5ab10 100644 --- a/drivers/staging/rtl8192e/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c @@ -360,7 +360,7 @@ static void RemoveTsEntry(struct rtllib_device *ieee, } } -void RemovePeerTS(struct rtllib_device *ieee, u8 *addr) +void remove_peer_ts(struct rtllib_device *ieee, u8 *addr) { struct ts_common_info *ts, *pTmpTS; @@ -400,7 +400,7 @@ void RemovePeerTS(struct rtllib_device *ieee, u8 *addr) } } } -EXPORT_SYMBOL(RemovePeerTS); +EXPORT_SYMBOL(remove_peer_ts); void remove_all_ts(struct rtllib_device *ieee) { diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index ed9ca77fbcb9..d20a1809cffd 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1788,7 +1788,7 @@ bool rtllib_get_ts(struct rtllib_device *ieee, struct ts_common_info **ppTS, u8 void rtllib_ts_init(struct rtllib_device *ieee); void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS); -void RemovePeerTS(struct rtllib_device *ieee, u8 *addr); +void remove_peer_ts(struct rtllib_device *ieee, u8 *addr); void remove_all_ts(struct rtllib_device *ieee); static inline const char *escape_essid(const char *essid, u8 essid_len) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b9750c9b3952..ff43697768cb 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1736,7 +1736,7 @@ rtllib_rx_deauth(struct rtllib_device *ieee, struct sk_buff *skb) ieee->is_roaming = true; ieee->link_detect_info.busy_traffic = false; rtllib_disassociate(ieee); - RemovePeerTS(ieee, header->addr2); + remove_peer_ts(ieee, header->addr2); if (!(ieee->rtllib_ap_sec_type(ieee) & (SEC_ALG_CCMP | SEC_ALG_TKIP))) schedule_delayed_work( @@ -2247,7 +2247,7 @@ static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 i; u8 op_mode; - RemovePeerTS(rtllib, asSta); + remove_peer_ts(rtllib, asSta); if (memcmp(rtllib->current_network.bssid, asSta, 6) == 0) { rtllib->link_state = MAC80211_NOLINK; -- cgit v1.2.3-58-ga151 From 053e3b7c4d1d313c9ee47bd680621269c5db51dd Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:51 -0800 Subject: Staging: rtl8192e: Rename function rtllib_MlmeDisassociateRequest() Rename function rtllib_MlmeDisassociateRequest to rtllib_mlme_disassociate_request to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-17-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index ff43697768cb..7c5056f9f6f5 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2241,7 +2241,7 @@ u8 rtllib_ap_sec_type(struct rtllib_device *ieee) } } -static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, +static void rtllib_mlme_disassociate_request(struct rtllib_device *rtllib, u8 *asSta, u8 asRsn) { u8 i; @@ -2272,7 +2272,7 @@ static void rtllib_mgnt_disconnect_ap(struct rtllib_device *rtllib, u8 asRsn) filter_out_nonassociated_bssid = false; rtllib->SetHwRegHandler(rtllib->dev, HW_VAR_CECHK_BSSID, (u8 *)(&filter_out_nonassociated_bssid)); - rtllib_MlmeDisassociateRequest(rtllib, rtllib->current_network.bssid, + rtllib_mlme_disassociate_request(rtllib, rtllib->current_network.bssid, asRsn); rtllib->link_state = MAC80211_NOLINK; -- cgit v1.2.3-58-ga151 From c41616e98a00286ded2599348579cd016051a779 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:52 -0800 Subject: Staging: rtl8192e: Rename function SendDisassociation() Rename function SendDisassociation to send_disassociation to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-18-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 4 ++-- drivers/staging/rtl8192e/rtllib_wx.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index d20a1809cffd..c453af8dec47 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1662,7 +1662,7 @@ int rtllib_rx_frame_softmac(struct rtllib_device *ieee, struct sk_buff *skb, void rtllib_softmac_new_net(struct rtllib_device *ieee, struct rtllib_network *net); -void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); +void send_disassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn); void rtllib_softmac_xmit(struct rtllib_txb *txb, struct rtllib_device *ieee); int rtllib_softmac_init(struct rtllib_device *ieee); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 7c5056f9f6f5..b422ffbf0cbc 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1998,7 +1998,7 @@ void rtllib_stop_protocol(struct rtllib_device *ieee) if (ieee->link_state == MAC80211_LINKED) { if (ieee->iw_mode == IW_MODE_INFRA) - SendDisassociation(ieee, 1, WLAN_REASON_DEAUTH_LEAVING); + send_disassociation(ieee, 1, WLAN_REASON_DEAUTH_LEAVING); rtllib_disassociate(ieee); } @@ -2199,7 +2199,7 @@ rtllib_disassociate_skb(struct rtllib_network *beacon, return skb; } -void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn) +void send_disassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn) { struct rtllib_network *beacon = &ieee->current_network; struct sk_buff *skb; diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index f92ec0faf4d5..55a3e4222cd6 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -636,7 +636,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, ieee->cannot_notify = true; - SendDisassociation(ieee, deauth, mlme->reason_code); + send_disassociation(ieee, deauth, mlme->reason_code); rtllib_disassociate(ieee); ieee->wap_set = 0; -- cgit v1.2.3-58-ga151 From 64df2dccb87d180e403861cf80bfd3ea83456242 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:53 -0800 Subject: Staging: rtl8192e: Rename variable bHalfSupportNmode Rename variable bHalfSupportNmode to half_support_nmode to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-19-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b422ffbf0cbc..5305486c9594 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1648,7 +1648,7 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) int errcode; u8 *challenge; int chlen = 0; - bool support_nmode = true, bHalfSupportNmode = false; + bool support_nmode = true, half_support_nmode = false; errcode = auth_parse(ieee->dev, skb, &challenge, &chlen); @@ -1667,10 +1667,10 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { if (is_ht_half_nmode_aps(ieee)) { support_nmode = true; - bHalfSupportNmode = true; + half_support_nmode = true; } else { support_nmode = false; - bHalfSupportNmode = false; + half_support_nmode = false; } } } @@ -1684,7 +1684,7 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) } if ((ieee->current_network.mode == WIRELESS_MODE_N_24G) && - bHalfSupportNmode) { + half_support_nmode) { netdev_info(ieee->dev, "======>enter half N mode\n"); ieee->bHalfWirelessN24GMode = true; } else { -- cgit v1.2.3-58-ga151 From 7ee99ed399ff20fddad65ddc51821b8e859384ae Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:54 -0800 Subject: Staging: rtl8192e: Rename variable PMKCacheIdx Rename variable PMKCacheIdx to pmk_cache_idx to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-20-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_softmac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 5305486c9594..533af4b28aa7 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -700,7 +700,7 @@ rtllib_association_req(struct rtllib_network *beacon, unsigned int cxvernum_ie_len = 0; struct lib80211_crypt_data *crypt; int encrypt; - int PMKCacheIdx; + int pmk_cache_idx; unsigned int rate_len = (beacon->rates_len ? (beacon->rates_len + 2) : 0) + @@ -748,8 +748,8 @@ rtllib_association_req(struct rtllib_network *beacon, if (beacon->BssCcxVerNumber >= 2) cxvernum_ie_len = 5 + 2; - PMKCacheIdx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); - if (PMKCacheIdx >= 0) { + pmk_cache_idx = SecIsInPMKIDList(ieee, ieee->current_network.bssid); + if (pmk_cache_idx >= 0) { wpa_ie_len += 18; netdev_info(ieee->dev, "[PMK cache]: WPA2 IE length: %x\n", wpa_ie_len); @@ -878,11 +878,11 @@ rtllib_association_req(struct rtllib_network *beacon, if (wpa_ie_len) { skb_put_data(skb, ieee->wpa_ie, ieee->wpa_ie_len); - if (PMKCacheIdx >= 0) { + if (pmk_cache_idx >= 0) { tag = skb_put(skb, 18); *tag = 1; *(tag + 1) = 0; - memcpy((tag + 2), &ieee->PMKIDList[PMKCacheIdx].PMKID, + memcpy((tag + 2), &ieee->PMKIDList[pmk_cache_idx].PMKID, 16); } } -- cgit v1.2.3-58-ga151 From c9f43ad42187652383f89df279a03a675a6b4362 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:55 -0800 Subject: Staging: rtl8192e: Rename function GetNmodeSupportBySecCfg() Rename function GetNmodeSupportBySecCfg to get_nmode_support_by_sec_cfg fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-21-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- drivers/staging/rtl8192e/rtllib_tx.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 3889443330cf..32acba4ce3f7 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -656,7 +656,7 @@ static void _rtl92e_init_priv_handler(struct net_device *dev) priv->rtllib->enter_sleep_state = rtl92e_enter_sleep; priv->rtllib->ps_is_queue_empty = _rtl92e_is_tx_queue_empty; - priv->rtllib->GetNmodeSupportBySecCfg = rtl92e_get_nmode_support_by_sec; + priv->rtllib->get_nmode_support_by_sec_cfg = rtl92e_get_nmode_support_by_sec; priv->rtllib->GetHalfNmodeSupportByAPsHandler = rtl92e_is_halfn_supported_by_ap; diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index c453af8dec47..2d753a159358 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1484,7 +1484,7 @@ struct rtllib_device { void (*set_bw_mode_handler)(struct net_device *dev, enum ht_channel_width bandwidth, enum ht_extchnl_offset Offset); - bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); + bool (*get_nmode_support_by_sec_cfg)(struct net_device *dev); void (*set_wireless_mode)(struct net_device *dev, u8 wireless_mode); bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); u8 (*rtllib_ap_sec_type)(struct rtllib_device *ieee); diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 533af4b28aa7..b9b79f6b0c08 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1664,7 +1664,7 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb) ieee->link_state = RTLLIB_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; if (!(ieee->ht_info->iot_action & HT_IOT_ACT_PURE_N_MODE)) { - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { + if (!ieee->get_nmode_support_by_sec_cfg(ieee->dev)) { if (is_ht_half_nmode_aps(ieee)) { support_nmode = true; half_support_nmode = true; diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index f1e9a0390be0..b82f3415085b 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -286,7 +286,7 @@ static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, if (ht_info->iot_action & HT_IOT_ACT_TX_NO_AGGREGATION) return; - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) + if (!ieee->get_nmode_support_by_sec_cfg(ieee->dev)) return; if (ht_info->current_ampdu_enable) { if (!rtllib_get_ts(ieee, (struct ts_common_info **)(&ts), hdr->addr1, -- cgit v1.2.3-58-ga151 From 1cc357dd4e9563c9796f84f3777e4877e1f7ad86 Mon Sep 17 00:00:00 2001 From: Tree Davies Date: Fri, 5 Jan 2024 21:55:56 -0800 Subject: Staging: rtl8192e: Rename variable AsocRetryCount Rename variable AsocRetryCount to asoc_retry_count to fix checkpatch warning Avoid CamelCase. Signed-off-by: Tree Davies Link: https://lore.kernel.org/r/20240106055556.430948-22-tdavies@darkphysics.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 2d753a159358..0fdc767d43e0 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -1381,7 +1381,7 @@ struct rtllib_device { struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; - u8 AsocRetryCount; + u8 asoc_retry_count; struct sk_buff_head skb_waitq[MAX_QUEUE_SIZE]; bool bdynamic_txpower_enable; diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index b9b79f6b0c08..9d1e9b780bc7 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1216,7 +1216,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee, ieee->wmm_acm = 0; if (ieee->iw_mode == IW_MODE_INFRA) { /* Join the network for the first time */ - ieee->AsocRetryCount = 0; + ieee->asoc_retry_count = 0; if ((ieee->current_network.qos_data.supported == 1) && ieee->current_network.bssht.bd_support_ht) ht_reset_self_and_save_peer_setting(ieee, @@ -1319,10 +1319,10 @@ static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb, status_code == WLAN_STATUS_CAPS_UNSUPPORTED) && ((ieee->mode == WIRELESS_MODE_G) && (ieee->current_network.mode == WIRELESS_MODE_N_24G) && - (ieee->AsocRetryCount++ < (RT_ASOC_RETRY_LIMIT - 1)))) { + (ieee->asoc_retry_count++ < (RT_ASOC_RETRY_LIMIT - 1)))) { ieee->ht_info->iot_action |= HT_IOT_ACT_PURE_N_MODE; } else { - ieee->AsocRetryCount = 0; + ieee->asoc_retry_count = 0; } return le16_to_cpu(response_head->status); @@ -1634,7 +1634,7 @@ rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, netdev_info(ieee->dev, "Association response status code 0x%x\n", errcode); - if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT) + if (ieee->asoc_retry_count < RT_ASOC_RETRY_LIMIT) schedule_delayed_work(&ieee->associate_procedure_wq, 0); else rtllib_associate_abort(ieee); -- cgit v1.2.3-58-ga151 From 9914cd29453564568668db8147973dba348c12ee Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 5 Jan 2024 11:38:08 +0100 Subject: staging: greybus: gbphy: make gbphy_bus_type const Now that the driver core can properly handle constant struct bus_type, move the gbphy_bus_type variable to be a constant structure as well, placing it into read-only memory which can not be modified at runtime. Cc: Alex Elder Cc: greybus-dev@lists.linaro.org Cc: linux-staging@lists.linux.dev Reviewed-by: Johan Hovold Link: https://lore.kernel.org/r/2024010508-fossil-glove-c2c6@gregkh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/gbphy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c index 6a7d8cf2a1eb..1c41b008ba39 100644 --- a/drivers/staging/greybus/gbphy.c +++ b/drivers/staging/greybus/gbphy.c @@ -182,7 +182,7 @@ static void gbphy_dev_remove(struct device *dev) pm_runtime_dont_use_autosuspend(dev); } -static struct bus_type gbphy_bus_type = { +static const struct bus_type gbphy_bus_type = { .name = "gbphy", .match = gbphy_dev_match, .probe = gbphy_dev_probe, -- cgit v1.2.3-58-ga151 From 11e922cf62ee8a61e807c6205fce8cce2d0e11eb Mon Sep 17 00:00:00 2001 From: Matthias Yee Date: Tue, 9 Jan 2024 23:23:05 -0800 Subject: staging: vt6655: fix open parentheses alignment Adjusted whitespace to fix checkpatch warning Alignment Should Match Open Parenthesis. Signed-off-by: Matthias Yee Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20240110072304.2226-1-mgyee9@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 74 +++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 36183f2a64c1..688c870d89bc 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -81,9 +81,9 @@ static void vt6655_mac_set_bb_type(void __iomem *iobase, u32 mask) * Return Value: none */ static void calculate_ofdmr_parameter(unsigned char rate, - u8 bb_type, - unsigned char *tx_rate, - unsigned char *rsv_time) + u8 bb_type, + unsigned char *tx_rate, + unsigned char *rsv_time) { switch (rate) { case RATE_6M: @@ -288,7 +288,7 @@ bool card_set_phy_parameter(struct vnt_private *priv, u8 bb_type) * Return Value: none */ bool card_update_tsf(struct vnt_private *priv, unsigned char rx_rate, - u64 bss_timestamp) + u64 bss_timestamp) { u64 local_tsf; u64 tsf_offset = 0; @@ -297,7 +297,7 @@ bool card_update_tsf(struct vnt_private *priv, unsigned char rx_rate, if (bss_timestamp != local_tsf) { tsf_offset = card_get_tsf_offset(rx_rate, bss_timestamp, - local_tsf); + local_tsf); /* adjust TSF, HW's TSF add TSF Offset reg */ tsf_offset = le64_to_cpu(tsf_offset); iowrite32((u32)tsf_offset, priv->port_offset + MAC_REG_TSFOFST); @@ -321,7 +321,7 @@ bool card_update_tsf(struct vnt_private *priv, unsigned char rx_rate, * Return Value: true if succeed; otherwise false */ bool card_set_beacon_period(struct vnt_private *priv, - unsigned short beacon_interval) + unsigned short beacon_interval) { u64 next_tbtt; @@ -586,61 +586,61 @@ void card_set_rspinf(struct vnt_private *priv, u8 bb_type) /* RSPINF_a_6 */ calculate_ofdmr_parameter(RATE_6M, - bb_type, - &byTxRate, - &byRsvTime); + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_6); /* RSPINF_a_9 */ calculate_ofdmr_parameter(RATE_9M, - bb_type, - &byTxRate, - &byRsvTime); + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_9); /* RSPINF_a_12 */ calculate_ofdmr_parameter(RATE_12M, - bb_type, - &byTxRate, - &byRsvTime); + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_12); /* RSPINF_a_18 */ calculate_ofdmr_parameter(RATE_18M, - bb_type, - &byTxRate, - &byRsvTime); + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_18); /* RSPINF_a_24 */ calculate_ofdmr_parameter(RATE_24M, - bb_type, - &byTxRate, - &byRsvTime); + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_24); /* RSPINF_a_36 */ calculate_ofdmr_parameter(CARDwGetOFDMControlRate((void *)priv, - RATE_36M), - bb_type, - &byTxRate, - &byRsvTime); + RATE_36M), + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_36); /* RSPINF_a_48 */ calculate_ofdmr_parameter(CARDwGetOFDMControlRate((void *)priv, - RATE_48M), - bb_type, - &byTxRate, - &byRsvTime); + RATE_48M), + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_48); /* RSPINF_a_54 */ calculate_ofdmr_parameter(CARDwGetOFDMControlRate((void *)priv, - RATE_54M), - bb_type, - &byTxRate, - &byRsvTime); + RATE_54M), + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_54); /* RSPINF_a_72 */ calculate_ofdmr_parameter(CARDwGetOFDMControlRate((void *)priv, - RATE_54M), - bb_type, - &byTxRate, - &byRsvTime); + RATE_54M), + bb_type, + &byTxRate, + &byRsvTime); iowrite16(MAKEWORD(byTxRate, byRsvTime), priv->port_offset + MAC_REG_RSPINF_A_72); /* Set to Page0 */ VT6655_MAC_SELECT_PAGE0(priv->port_offset); -- cgit v1.2.3-58-ga151 From 5b5ea3124488129f63a5ac176707731931673180 Mon Sep 17 00:00:00 2001 From: Pranav Athreya Date: Fri, 12 Jan 2024 10:22:43 +0530 Subject: staging: vt6655: Remove extra blank lines between code blocks Adhere to Linux kernel coding style. Reported by checkpatch: drivers/staging/vt6655/rxtx.h:22: CHECK: Please don't use multiple blank lines Signed-off-by: Pranav Athreya Link: https://lore.kernel.org/r/ZaDFm6XX7HiGWn58@pop-os Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index a67757c9bb5c..be1e5180d57b 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -19,7 +19,6 @@ #define DEFAULT_MSDU_LIFETIME_RES_64us 8000 /* 64us */ #define DEFAULT_MGN_LIFETIME_RES_64us 125 /* 64us */ - /*--------------------- Export Definitions -------------------------*/ /*--------------------- Export Variables --------------------------*/ -- cgit v1.2.3-58-ga151 From 5500382eeba89aa0d4e6d1b0a5b500e8ab9945cf Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Mon, 15 Jan 2024 21:22:29 +0100 Subject: staging: greybus: Remove usage of the deprecated ida_simple_xx() API ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove(). Note that the upper limit of ida_simple_get() is exclusive, buInputt the one of ida_alloc_range()/ida_alloc_max() is inclusive. So a -1 has been added when needed. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/2e7bbdaf8a495bb1273396395b5c779363287581.1705350141.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_manager.c | 8 ++++---- drivers/staging/greybus/authentication.c | 6 +++--- drivers/staging/greybus/fw-download.c | 7 +++---- drivers/staging/greybus/fw-management.c | 20 +++++++++----------- drivers/staging/greybus/gbphy.c | 6 +++--- drivers/staging/greybus/loopback.c | 6 +++--- drivers/staging/greybus/raw.c | 6 +++--- drivers/staging/greybus/vibrator.c | 6 +++--- 8 files changed, 31 insertions(+), 34 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/greybus/audio_manager.c b/drivers/staging/greybus/audio_manager.c index 9a3f7c034ab4..fa43d35bbcec 100644 --- a/drivers/staging/greybus/audio_manager.c +++ b/drivers/staging/greybus/audio_manager.c @@ -44,14 +44,14 @@ int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc) int id; int err; - id = ida_simple_get(&module_id, 0, 0, GFP_KERNEL); + id = ida_alloc(&module_id, GFP_KERNEL); if (id < 0) return id; err = gb_audio_manager_module_create(&module, manager_kset, id, desc); if (err) { - ida_simple_remove(&module_id, id); + ida_free(&module_id, id); return err; } @@ -78,7 +78,7 @@ int gb_audio_manager_remove(int id) list_del(&module->list); kobject_put(&module->kobj); up_write(&modules_rwsem); - ida_simple_remove(&module_id, id); + ida_free(&module_id, id); return 0; } EXPORT_SYMBOL_GPL(gb_audio_manager_remove); @@ -92,7 +92,7 @@ void gb_audio_manager_remove_all(void) list_for_each_entry_safe(module, next, &modules_list, list) { list_del(&module->list); - ida_simple_remove(&module_id, module->id); + ida_free(&module_id, module->id); kobject_put(&module->kobj); } diff --git a/drivers/staging/greybus/authentication.c b/drivers/staging/greybus/authentication.c index b67315641d18..d53e58f92e81 100644 --- a/drivers/staging/greybus/authentication.c +++ b/drivers/staging/greybus/authentication.c @@ -324,7 +324,7 @@ int gb_cap_connection_init(struct gb_connection *connection) if (ret) goto err_list_del; - minor = ida_simple_get(&cap_minors_map, 0, NUM_MINORS, GFP_KERNEL); + minor = ida_alloc_max(&cap_minors_map, NUM_MINORS - 1, GFP_KERNEL); if (minor < 0) { ret = minor; goto err_connection_disable; @@ -351,7 +351,7 @@ int gb_cap_connection_init(struct gb_connection *connection) err_del_cdev: cdev_del(&cap->cdev); err_remove_ida: - ida_simple_remove(&cap_minors_map, minor); + ida_free(&cap_minors_map, minor); err_connection_disable: gb_connection_disable(connection); err_list_del: @@ -375,7 +375,7 @@ void gb_cap_connection_exit(struct gb_connection *connection) device_destroy(&cap_class, cap->dev_num); cdev_del(&cap->cdev); - ida_simple_remove(&cap_minors_map, MINOR(cap->dev_num)); + ida_free(&cap_minors_map, MINOR(cap->dev_num)); /* * Disallow any new ioctl operations on the char device and wait for diff --git a/drivers/staging/greybus/fw-download.c b/drivers/staging/greybus/fw-download.c index 543692c567f9..2a5c6d1b049c 100644 --- a/drivers/staging/greybus/fw-download.c +++ b/drivers/staging/greybus/fw-download.c @@ -63,8 +63,7 @@ static void fw_req_release(struct kref *kref) * just hope that it never happens. */ if (!fw_req->timedout) - ida_simple_remove(&fw_req->fw_download->id_map, - fw_req->firmware_id); + ida_free(&fw_req->fw_download->id_map, fw_req->firmware_id); kfree(fw_req); } @@ -171,7 +170,7 @@ static struct fw_request *find_firmware(struct fw_download *fw_download, return ERR_PTR(-ENOMEM); /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */ - ret = ida_simple_get(&fw_download->id_map, 1, 256, GFP_KERNEL); + ret = ida_alloc_range(&fw_download->id_map, 1, 255, GFP_KERNEL); if (ret < 0) { dev_err(fw_download->parent, "failed to allocate firmware id (%d)\n", ret); @@ -212,7 +211,7 @@ static struct fw_request *find_firmware(struct fw_download *fw_download, return fw_req; err_free_id: - ida_simple_remove(&fw_download->id_map, fw_req->firmware_id); + ida_free(&fw_download->id_map, fw_req->firmware_id); err_free_req: kfree(fw_req); diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c index 93137a3c4907..3054f084d777 100644 --- a/drivers/staging/greybus/fw-management.c +++ b/drivers/staging/greybus/fw-management.c @@ -165,7 +165,7 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, } /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */ - ret = ida_simple_get(&fw_mgmt->id_map, 1, 256, GFP_KERNEL); + ret = ida_alloc_range(&fw_mgmt->id_map, 1, 255, GFP_KERNEL); if (ret < 0) { dev_err(fw_mgmt->parent, "failed to allocate request id (%d)\n", ret); @@ -180,8 +180,7 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, GB_FW_MGMT_TYPE_LOAD_AND_VALIDATE_FW, &request, sizeof(request), NULL, 0); if (ret) { - ida_simple_remove(&fw_mgmt->id_map, - fw_mgmt->intf_fw_request_id); + ida_free(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id); fw_mgmt->intf_fw_request_id = 0; dev_err(fw_mgmt->parent, "load and validate firmware request failed (%d)\n", @@ -220,7 +219,7 @@ static int fw_mgmt_interface_fw_loaded_operation(struct gb_operation *op) return -ENODEV; } - ida_simple_remove(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id); + ida_free(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id); fw_mgmt->intf_fw_request_id = 0; fw_mgmt->intf_fw_status = request->status; fw_mgmt->intf_fw_major = le16_to_cpu(request->major); @@ -316,7 +315,7 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt, } /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */ - ret = ida_simple_get(&fw_mgmt->id_map, 1, 256, GFP_KERNEL); + ret = ida_alloc_range(&fw_mgmt->id_map, 1, 255, GFP_KERNEL); if (ret < 0) { dev_err(fw_mgmt->parent, "failed to allocate request id (%d)\n", ret); @@ -330,8 +329,7 @@ static int fw_mgmt_backend_fw_update_operation(struct fw_mgmt *fw_mgmt, GB_FW_MGMT_TYPE_BACKEND_FW_UPDATE, &request, sizeof(request), NULL, 0); if (ret) { - ida_simple_remove(&fw_mgmt->id_map, - fw_mgmt->backend_fw_request_id); + ida_free(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id); fw_mgmt->backend_fw_request_id = 0; dev_err(fw_mgmt->parent, "backend %s firmware update request failed (%d)\n", tag, @@ -369,7 +367,7 @@ static int fw_mgmt_backend_fw_updated_operation(struct gb_operation *op) return -ENODEV; } - ida_simple_remove(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id); + ida_free(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id); fw_mgmt->backend_fw_request_id = 0; fw_mgmt->backend_fw_status = request->status; @@ -617,7 +615,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection) if (ret) goto err_list_del; - minor = ida_simple_get(&fw_mgmt_minors_map, 0, NUM_MINORS, GFP_KERNEL); + minor = ida_alloc_max(&fw_mgmt_minors_map, NUM_MINORS - 1, GFP_KERNEL); if (minor < 0) { ret = minor; goto err_connection_disable; @@ -645,7 +643,7 @@ int gb_fw_mgmt_connection_init(struct gb_connection *connection) err_del_cdev: cdev_del(&fw_mgmt->cdev); err_remove_ida: - ida_simple_remove(&fw_mgmt_minors_map, minor); + ida_free(&fw_mgmt_minors_map, minor); err_connection_disable: gb_connection_disable(connection); err_list_del: @@ -669,7 +667,7 @@ void gb_fw_mgmt_connection_exit(struct gb_connection *connection) device_destroy(&fw_mgmt_class, fw_mgmt->dev_num); cdev_del(&fw_mgmt->cdev); - ida_simple_remove(&fw_mgmt_minors_map, MINOR(fw_mgmt->dev_num)); + ida_free(&fw_mgmt_minors_map, MINOR(fw_mgmt->dev_num)); /* * Disallow any new ioctl operations on the char device and wait for diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c index 1c41b008ba39..d827f03f5253 100644 --- a/drivers/staging/greybus/gbphy.c +++ b/drivers/staging/greybus/gbphy.c @@ -46,7 +46,7 @@ static void gbphy_dev_release(struct device *dev) { struct gbphy_device *gbphy_dev = to_gbphy_dev(dev); - ida_simple_remove(&gbphy_id, gbphy_dev->id); + ida_free(&gbphy_id, gbphy_dev->id); kfree(gbphy_dev); } @@ -225,13 +225,13 @@ static struct gbphy_device *gb_gbphy_create_dev(struct gb_bundle *bundle, int retval; int id; - id = ida_simple_get(&gbphy_id, 1, 0, GFP_KERNEL); + id = ida_alloc_min(&gbphy_id, 1, GFP_KERNEL); if (id < 0) return ERR_PTR(id); gbphy_dev = kzalloc(sizeof(*gbphy_dev), GFP_KERNEL); if (!gbphy_dev) { - ida_simple_remove(&gbphy_id, id); + ida_free(&gbphy_id, id); return ERR_PTR(-ENOMEM); } diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index d7b39f3bb652..bb33379b5297 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -1028,7 +1028,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle, gb->file = debugfs_create_file(name, S_IFREG | 0444, gb_dev.root, gb, &gb_loopback_dbgfs_latency_fops); - gb->id = ida_simple_get(&loopback_ida, 0, 0, GFP_KERNEL); + gb->id = ida_alloc(&loopback_ida, GFP_KERNEL); if (gb->id < 0) { retval = gb->id; goto out_debugfs_remove; @@ -1079,7 +1079,7 @@ out_conn: out_connection_disable: gb_connection_disable(connection); out_ida_remove: - ida_simple_remove(&loopback_ida, gb->id); + ida_free(&loopback_ida, gb->id); out_debugfs_remove: debugfs_remove(gb->file); out_connection_destroy: @@ -1121,7 +1121,7 @@ static void gb_loopback_disconnect(struct gb_bundle *bundle) spin_unlock_irqrestore(&gb_dev.lock, flags); device_unregister(gb->dev); - ida_simple_remove(&loopback_ida, gb->id); + ida_free(&loopback_ida, gb->id); gb_connection_destroy(gb->connection); kfree(gb); diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c index b9c6eff7cdc1..836d35e5fa85 100644 --- a/drivers/staging/greybus/raw.c +++ b/drivers/staging/greybus/raw.c @@ -181,7 +181,7 @@ static int gb_raw_probe(struct gb_bundle *bundle, raw->connection = connection; greybus_set_drvdata(bundle, raw); - minor = ida_simple_get(&minors, 0, 0, GFP_KERNEL); + minor = ida_alloc(&minors, GFP_KERNEL); if (minor < 0) { retval = minor; goto error_connection_destroy; @@ -214,7 +214,7 @@ error_connection_disable: gb_connection_disable(connection); error_remove_ida: - ida_simple_remove(&minors, minor); + ida_free(&minors, minor); error_connection_destroy: gb_connection_destroy(connection); @@ -235,7 +235,7 @@ static void gb_raw_disconnect(struct gb_bundle *bundle) device_destroy(&raw_class, raw->dev); cdev_del(&raw->cdev); gb_connection_disable(connection); - ida_simple_remove(&minors, MINOR(raw->dev)); + ida_free(&minors, MINOR(raw->dev)); gb_connection_destroy(connection); mutex_lock(&raw->list_lock); diff --git a/drivers/staging/greybus/vibrator.c b/drivers/staging/greybus/vibrator.c index 227e18d92a95..89bef8045549 100644 --- a/drivers/staging/greybus/vibrator.c +++ b/drivers/staging/greybus/vibrator.c @@ -153,7 +153,7 @@ static int gb_vibrator_probe(struct gb_bundle *bundle, * there is a "real" device somewhere in the kernel for this, but I * can't find it at the moment... */ - vib->minor = ida_simple_get(&minors, 0, 0, GFP_KERNEL); + vib->minor = ida_alloc(&minors, GFP_KERNEL); if (vib->minor < 0) { retval = vib->minor; goto err_connection_disable; @@ -173,7 +173,7 @@ static int gb_vibrator_probe(struct gb_bundle *bundle, return 0; err_ida_remove: - ida_simple_remove(&minors, vib->minor); + ida_free(&minors, vib->minor); err_connection_disable: gb_connection_disable(connection); err_connection_destroy: @@ -197,7 +197,7 @@ static void gb_vibrator_disconnect(struct gb_bundle *bundle) turn_off(vib); device_unregister(vib->dev); - ida_simple_remove(&minors, vib->minor); + ida_free(&minors, vib->minor); gb_connection_disable(vib->connection); gb_connection_destroy(vib->connection); kfree(vib); -- cgit v1.2.3-58-ga151 From 5b4ee6d1e13d0b9df70fc437f50251ff1c034524 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 14 Jan 2024 11:10:15 +0100 Subject: staging: fieldbus: Remove usage of the deprecated ida_simple_xx() API ida_alloc() and ida_free() should be preferred to the deprecated ida_simple_get() and ida_simple_remove(). Note that the upper limit of ida_simple_get() is exclusive, but the one of ida_alloc_max() is inclusive. So a -1 has been added when needed. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/d305b97b1064ba7e026232fb8c2a0783ba1b1098.1705227001.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/anybuss/arcx-anybus.c | 6 +++--- drivers/staging/fieldbus/dev_core.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c b/drivers/staging/fieldbus/anybuss/arcx-anybus.c index 34d18b09bedd..fcd3e3722ae0 100644 --- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c +++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c @@ -285,7 +285,7 @@ static int controller_probe(struct platform_device *pdev) } } - id = ida_simple_get(&controller_index_ida, 0, 0, GFP_KERNEL); + id = ida_alloc(&controller_index_ida, GFP_KERNEL); if (id < 0) { err = id; goto out_reset; @@ -318,7 +318,7 @@ static int controller_probe(struct platform_device *pdev) out_dev: put_device(cd->class_dev); out_ida: - ida_simple_remove(&controller_index_ida, id); + ida_free(&controller_index_ida, id); out_reset: gpiod_set_value_cansleep(cd->reset_gpiod, 1); return err; @@ -330,7 +330,7 @@ static void controller_remove(struct platform_device *pdev) int id = cd->class_dev->id; device_unregister(cd->class_dev); - ida_simple_remove(&controller_index_ida, id); + ida_free(&controller_index_ida, id); gpiod_set_value_cansleep(cd->reset_gpiod, 1); } diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c index bf1812d8924f..370a229443a1 100644 --- a/drivers/staging/fieldbus/dev_core.c +++ b/drivers/staging/fieldbus/dev_core.c @@ -247,7 +247,7 @@ static void __fieldbus_dev_unregister(struct fieldbus_dev *fb) return; device_destroy(&fieldbus_class, fb->cdev.dev); cdev_del(&fb->cdev); - ida_simple_remove(&fieldbus_ida, fb->id); + ida_free(&fieldbus_ida, fb->id); } void fieldbus_dev_unregister(struct fieldbus_dev *fb) @@ -267,7 +267,7 @@ static int __fieldbus_dev_register(struct fieldbus_dev *fb) return -EINVAL; if (!fb->read_area || !fb->write_area || !fb->fieldbus_id_get) return -EINVAL; - fb->id = ida_simple_get(&fieldbus_ida, 0, MAX_FIELDBUSES, GFP_KERNEL); + fb->id = ida_alloc_max(&fieldbus_ida, MAX_FIELDBUSES - 1, GFP_KERNEL); if (fb->id < 0) return fb->id; devno = MKDEV(MAJOR(fieldbus_devt), fb->id); @@ -290,7 +290,7 @@ static int __fieldbus_dev_register(struct fieldbus_dev *fb) err_dev_create: cdev_del(&fb->cdev); err_cdev: - ida_simple_remove(&fieldbus_ida, fb->id); + ida_free(&fieldbus_ida, fb->id); return err; } -- cgit v1.2.3-58-ga151 From cbfeaf08296a9eab0ed043f6ff4ad5519e3952b3 Mon Sep 17 00:00:00 2001 From: Meir Elisha Date: Mon, 15 Jan 2024 10:34:38 +0200 Subject: Staging: rtl8723bs: rtw_ieee80211: Remove extra space Fix checkpatch warning: please, no space before tabs Signed-off-by: Meir Elisha Link: https://lore.kernel.org/r/20240115083438.108901-1-meir6264@Gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 30e7457a9c31..b89e88d6a82d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1035,8 +1035,8 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) u16 wpa_len = 0, rsn_len = 0; struct HT_info_element *pht_info = NULL; struct ieee80211_ht_cap *pht_cap = NULL; - unsigned int len; - unsigned char *p; + unsigned int len; + unsigned char *p; __le16 le_cap; memcpy((u8 *)&le_cap, rtw_get_capability_from_ie(pnetwork->network.ies), 2); -- cgit v1.2.3-58-ga151 From f4b3422ca08159435eab0b2be445ffb39582968f Mon Sep 17 00:00:00 2001 From: Hoorad Farrokh Date: Wed, 17 Jan 2024 22:00:33 +1300 Subject: staging: rtl8712: remove unnecessary braces in while loop Fixed a linux coding style. Reported by checkpath: WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Hoorad Farrokh Link: https://lore.kernel.org/r/4vmxiuz5u2f2vehngdccj5q7bakpujagk72ty5ounfv2nfzxgr@lqkdn5fecc23 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index 1593980d2c6a..0145c4da5ac0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -127,9 +127,8 @@ void kfree_all_stainfo(struct sta_priv *pstapriv) phead = get_list_head(&pstapriv->free_sta_queue); plist = get_next(phead); - while (phead != plist) { + while (phead != plist) plist = get_next(plist); - } spin_unlock_bh(&pstapriv->sta_hash_lock); } -- cgit v1.2.3-58-ga151 From 58dc02750fcca1b16b7b1f3d305ae34ebeafebfd Mon Sep 17 00:00:00 2001 From: Erick Archer Date: Fri, 19 Jan 2024 18:39:00 +0100 Subject: staging: rtl8723bs: Use kcalloc() instead of kzalloc() As noted in the "Deprecated Interfaces, Language Features, Attributes, and Conventions" documentation [1], size calculations (especially multiplication) should not be performed in memory allocator (or similar) function arguments due to the risk of them overflowing. This could lead to values wrapping around and a smaller allocation being made than the caller was expecting. Using those allocations could lead to linear overflows of heap memory and other misbehaviors. So, use the purpose specific kcalloc() function instead of the argument count * size in the kzalloc() function. Also, it is preferred to use sizeof(*pointer) instead of sizeof(type) due to the type of the variable can change and one needs not change the former (unlike the latter). Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Erick Archer Reviewed-by: "Gustavo A. R. Silva" Link: https://lore.kernel.org/r/20240119173900.11035-1-erick.archer@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 1ff763c10064..65a450fcdce7 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1259,8 +1259,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy goto check_need_indicate_scan_done; } - ssid = kzalloc(RTW_SSID_SCAN_AMOUNT * sizeof(struct ndis_802_11_ssid), - GFP_KERNEL); + ssid = kcalloc(RTW_SSID_SCAN_AMOUNT, sizeof(*ssid), GFP_KERNEL); if (!ssid) { ret = -ENOMEM; goto check_need_indicate_scan_done; -- cgit v1.2.3-58-ga151 From 4a46fffc210f246eb513f40a4bc3d4e33e2d23e2 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 22 Jan 2024 15:24:30 +0100 Subject: staging: emxx_udc: Remove EMMA Mobile USB Gadget driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No one stepped up to complete the EMMA Mobile USB Gadget driver, bring it up to non-staging standards, and convert it to device tree. Signed-off-by: Geert Uytterhoeven Acked-by: Wolfram Sang Acked-by: Niklas Söderlund Link: https://lore.kernel.org/r/c7bc2c95458f9710e043cbedee4270dd41fcae29.1705932585.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/emxx_udc/Kconfig | 11 - drivers/staging/emxx_udc/Makefile | 2 - drivers/staging/emxx_udc/TODO | 6 - drivers/staging/emxx_udc/emxx_udc.c | 3223 ----------------------------------- drivers/staging/emxx_udc/emxx_udc.h | 554 ------ 7 files changed, 3799 deletions(-) delete mode 100644 drivers/staging/emxx_udc/Kconfig delete mode 100644 drivers/staging/emxx_udc/Makefile delete mode 100644 drivers/staging/emxx_udc/TODO delete mode 100644 drivers/staging/emxx_udc/emxx_udc.c delete mode 100644 drivers/staging/emxx_udc/emxx_udc.h (limited to 'drivers') diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 784b9f673ead..b8f777036bb2 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -46,8 +46,6 @@ source "drivers/staging/iio/Kconfig" source "drivers/staging/sm750fb/Kconfig" -source "drivers/staging/emxx_udc/Kconfig" - source "drivers/staging/nvec/Kconfig" source "drivers/staging/media/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 2ea99c7b05d9..5bf357782d83 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -14,7 +14,6 @@ obj-$(CONFIG_VT6656) += vt6656/ obj-$(CONFIG_VME_BUS) += vme_user/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_FB_SM750) += sm750fb/ -obj-$(CONFIG_USB_EMXX) += emxx_udc/ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_STAGING_BOARD) += board/ obj-$(CONFIG_LTE_GDM724X) += gdm724x/ diff --git a/drivers/staging/emxx_udc/Kconfig b/drivers/staging/emxx_udc/Kconfig deleted file mode 100644 index e7a95b3b6a2f..000000000000 --- a/drivers/staging/emxx_udc/Kconfig +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config USB_EMXX - tristate "EMXX USB Function Device Controller" - depends on USB_GADGET && (ARCH_RENESAS || COMPILE_TEST) - help - The Emma Mobile series of SoCs from Renesas Electronics and - former NEC Electronics include USB Function hardware. - - Say "y" to link the driver statically, or "m" to build a - dynamically linked module called "emxx_udc" and force all - gadget drivers to also be dynamically linked. diff --git a/drivers/staging/emxx_udc/Makefile b/drivers/staging/emxx_udc/Makefile deleted file mode 100644 index 569c5e9a9bae..000000000000 --- a/drivers/staging/emxx_udc/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_USB_EMXX) := emxx_udc.o diff --git a/drivers/staging/emxx_udc/TODO b/drivers/staging/emxx_udc/TODO deleted file mode 100644 index 471529a470c7..000000000000 --- a/drivers/staging/emxx_udc/TODO +++ /dev/null @@ -1,6 +0,0 @@ -* add clock framework support (platform device with CCF needs special care) -* break out board-specific VBUS GPIO to work with multiplatform -* convert VBUS GPIO to use GPIO descriptors from - and stop using the old GPIO API -* DT bindings -* move driver into drivers/usb/gadget/ diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c deleted file mode 100644 index eb63daaca702..000000000000 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ /dev/null @@ -1,3223 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * drivers/usb/gadget/emxx_udc.c - * EMXX FCD (Function Controller Driver) for USB. - * - * Copyright (C) 2010 Renesas Electronics Corporation - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "emxx_udc.h" - -#define DRIVER_DESC "EMXX UDC driver" -#define DMA_ADDR_INVALID (~(dma_addr_t)0) - -static struct gpio_desc *vbus_gpio; -static int vbus_irq; - -static const char driver_name[] = "emxx_udc"; - -/*===========================================================================*/ -/* Prototype */ -static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *, struct nbu2ss_ep *); -static void _nbu2ss_ep0_enable(struct nbu2ss_udc *); -/*static void _nbu2ss_ep0_disable(struct nbu2ss_udc *);*/ -static void _nbu2ss_ep_done(struct nbu2ss_ep *, struct nbu2ss_req *, int); -static void _nbu2ss_set_test_mode(struct nbu2ss_udc *, u32 mode); -static void _nbu2ss_endpoint_toggle_reset(struct nbu2ss_udc *udc, u8 ep_adrs); - -static int _nbu2ss_pullup(struct nbu2ss_udc *, int); -static void _nbu2ss_fifo_flush(struct nbu2ss_udc *, struct nbu2ss_ep *); - -/*===========================================================================*/ -/* Macro */ -#define _nbu2ss_zero_len_pkt(udc, epnum) \ - _nbu2ss_ep_in_end(udc, epnum, 0, 0) - -/*===========================================================================*/ -/* Global */ -static struct nbu2ss_udc udc_controller; - -/*-------------------------------------------------------------------------*/ -/* Read */ -static inline u32 _nbu2ss_readl(void __iomem *address) -{ - return __raw_readl(address); -} - -/*-------------------------------------------------------------------------*/ -/* Write */ -static inline void _nbu2ss_writel(void __iomem *address, u32 udata) -{ - __raw_writel(udata, address); -} - -/*-------------------------------------------------------------------------*/ -/* Set Bit */ -static inline void _nbu2ss_bitset(void __iomem *address, u32 udata) -{ - u32 reg_dt = __raw_readl(address) | (udata); - - __raw_writel(reg_dt, address); -} - -/*-------------------------------------------------------------------------*/ -/* Clear Bit */ -static inline void _nbu2ss_bitclr(void __iomem *address, u32 udata) -{ - u32 reg_dt = __raw_readl(address) & ~(udata); - - __raw_writel(reg_dt, address); -} - -#ifdef UDC_DEBUG_DUMP -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_dump_register(struct nbu2ss_udc *udc) -{ - int i; - u32 reg_data; - - pr_info("=== %s()\n", __func__); - - if (!udc) { - pr_err("%s udc == NULL\n", __func__); - return; - } - - spin_unlock(&udc->lock); - - dev_dbg(&udc->dev, "\n-USB REG-\n"); - for (i = 0x0 ; i < USB_BASE_SIZE ; i += 16) { - reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i)); - dev_dbg(&udc->dev, "USB%04x =%08x", i, (int)reg_data); - - reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i + 4)); - dev_dbg(&udc->dev, " %08x", (int)reg_data); - - reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i + 8)); - dev_dbg(&udc->dev, " %08x", (int)reg_data); - - reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i + 12)); - dev_dbg(&udc->dev, " %08x\n", (int)reg_data); - } - - spin_lock(&udc->lock); -} -#endif /* UDC_DEBUG_DUMP */ - -/*-------------------------------------------------------------------------*/ -/* Endpoint 0 Callback (Complete) */ -static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req) -{ - u8 recipient; - u16 selector; - u16 wIndex; - u32 test_mode; - struct usb_ctrlrequest *p_ctrl; - struct nbu2ss_udc *udc; - - if (!_ep || !_req) - return; - - udc = (struct nbu2ss_udc *)_req->context; - p_ctrl = &udc->ctrl; - if ((p_ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { - if (p_ctrl->bRequest == USB_REQ_SET_FEATURE) { - /*-------------------------------------------------*/ - /* SET_FEATURE */ - recipient = (u8)(p_ctrl->bRequestType & USB_RECIP_MASK); - selector = le16_to_cpu(p_ctrl->wValue); - if ((recipient == USB_RECIP_DEVICE) && - (selector == USB_DEVICE_TEST_MODE)) { - wIndex = le16_to_cpu(p_ctrl->wIndex); - test_mode = (u32)(wIndex >> 8); - _nbu2ss_set_test_mode(udc, test_mode); - } - } - } -} - -/*-------------------------------------------------------------------------*/ -/* Initialization usb_request */ -static void _nbu2ss_create_ep0_packet(struct nbu2ss_udc *udc, - void *p_buf, unsigned int length) -{ - udc->ep0_req.req.buf = p_buf; - udc->ep0_req.req.length = length; - udc->ep0_req.req.dma = 0; - udc->ep0_req.req.zero = true; - udc->ep0_req.req.complete = _nbu2ss_ep0_complete; - udc->ep0_req.req.status = -EINPROGRESS; - udc->ep0_req.req.context = udc; - udc->ep0_req.req.actual = 0; -} - -/*-------------------------------------------------------------------------*/ -/* Acquisition of the first address of RAM(FIFO) */ -static u32 _nbu2ss_get_begin_ram_address(struct nbu2ss_udc *udc) -{ - u32 num, buf_type; - u32 data, last_ram_adr, use_ram_size; - - struct ep_regs __iomem *p_ep_regs; - - last_ram_adr = (D_RAM_SIZE_CTRL / sizeof(u32)) * 2; - use_ram_size = 0; - - for (num = 0; num < NUM_ENDPOINTS - 1; num++) { - p_ep_regs = &udc->p_regs->EP_REGS[num]; - data = _nbu2ss_readl(&p_ep_regs->EP_PCKT_ADRS); - buf_type = _nbu2ss_readl(&p_ep_regs->EP_CONTROL) & EPN_BUF_TYPE; - if (buf_type == 0) { - /* Single Buffer */ - use_ram_size += (data & EPN_MPKT) / sizeof(u32); - } else { - /* Double Buffer */ - use_ram_size += ((data & EPN_MPKT) / sizeof(u32)) * 2; - } - - if ((data >> 16) > last_ram_adr) - last_ram_adr = data >> 16; - } - - return last_ram_adr + use_ram_size; -} - -/*-------------------------------------------------------------------------*/ -/* Construction of Endpoint */ -static int _nbu2ss_ep_init(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) -{ - u32 num; - u32 data; - u32 begin_adrs; - - if (ep->epnum == 0) - return -EINVAL; - - num = ep->epnum - 1; - - /*-------------------------------------------------------------*/ - /* RAM Transfer Address */ - begin_adrs = _nbu2ss_get_begin_ram_address(udc); - data = (begin_adrs << 16) | ep->ep.maxpacket; - _nbu2ss_writel(&udc->p_regs->EP_REGS[num].EP_PCKT_ADRS, data); - - /*-------------------------------------------------------------*/ - /* Interrupt Enable */ - data = 1 << (ep->epnum + 8); - _nbu2ss_bitset(&udc->p_regs->USB_INT_ENA, data); - - /*-------------------------------------------------------------*/ - /* Endpoint Type(Mode) */ - /* Bulk, Interrupt, ISO */ - switch (ep->ep_type) { - case USB_ENDPOINT_XFER_BULK: - data = EPN_BULK; - break; - - case USB_ENDPOINT_XFER_INT: - data = EPN_BUF_SINGLE | EPN_INTERRUPT; - break; - - case USB_ENDPOINT_XFER_ISOC: - data = EPN_ISO; - break; - - default: - data = 0; - break; - } - - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - _nbu2ss_endpoint_toggle_reset(udc, (ep->epnum | ep->direct)); - - if (ep->direct == USB_DIR_OUT) { - /*---------------------------------------------------------*/ - /* OUT */ - data = EPN_EN | EPN_BCLR | EPN_DIR0; - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_ONAK | EPN_OSTL_EN | EPN_OSTL; - _nbu2ss_bitclr(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_OUT_EN | EPN_OUT_END_EN; - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_INT_ENA, data); - } else { - /*---------------------------------------------------------*/ - /* IN */ - data = EPN_EN | EPN_BCLR | EPN_AUTO; - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_ISTL; - _nbu2ss_bitclr(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_IN_EN | EPN_IN_END_EN; - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_INT_ENA, data); - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -/* Release of Endpoint */ -static int _nbu2ss_epn_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) -{ - u32 num; - u32 data; - - if ((ep->epnum == 0) || (udc->vbus_active == 0)) - return -EINVAL; - - num = ep->epnum - 1; - - /*-------------------------------------------------------------*/ - /* RAM Transfer Address */ - _nbu2ss_writel(&udc->p_regs->EP_REGS[num].EP_PCKT_ADRS, 0); - - /*-------------------------------------------------------------*/ - /* Interrupt Disable */ - data = 1 << (ep->epnum + 8); - _nbu2ss_bitclr(&udc->p_regs->USB_INT_ENA, data); - - if (ep->direct == USB_DIR_OUT) { - /*---------------------------------------------------------*/ - /* OUT */ - data = EPN_ONAK | EPN_BCLR; - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_EN | EPN_DIR0; - _nbu2ss_bitclr(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_OUT_EN | EPN_OUT_END_EN; - _nbu2ss_bitclr(&udc->p_regs->EP_REGS[num].EP_INT_ENA, data); - } else { - /*---------------------------------------------------------*/ - /* IN */ - data = EPN_BCLR; - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_EN | EPN_AUTO; - _nbu2ss_bitclr(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); - - data = EPN_IN_EN | EPN_IN_END_EN; - _nbu2ss_bitclr(&udc->p_regs->EP_REGS[num].EP_INT_ENA, data); - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -/* DMA setting (without Endpoint 0) */ -static void _nbu2ss_ep_dma_init(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) -{ - u32 num; - u32 data; - - data = _nbu2ss_readl(&udc->p_regs->USBSSCONF); - if (((ep->epnum == 0) || (data & (1 << ep->epnum)) == 0)) - return; /* Not Support DMA */ - - num = ep->epnum - 1; - - if (ep->direct == USB_DIR_OUT) { - /*---------------------------------------------------------*/ - /* OUT */ - data = ep->ep.maxpacket; - _nbu2ss_writel(&udc->p_regs->EP_DCR[num].EP_DCR2, data); - - /*---------------------------------------------------------*/ - /* Transfer Direct */ - data = DCR1_EPN_DIR0; - _nbu2ss_bitset(&udc->p_regs->EP_DCR[num].EP_DCR1, data); - - /*---------------------------------------------------------*/ - /* DMA Mode etc. */ - data = EPN_STOP_MODE | EPN_STOP_SET | EPN_DMAMODE0; - _nbu2ss_writel(&udc->p_regs->EP_REGS[num].EP_DMA_CTRL, data); - } else { - /*---------------------------------------------------------*/ - /* IN */ - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, EPN_AUTO); - - /*---------------------------------------------------------*/ - /* DMA Mode etc. */ - data = EPN_BURST_SET | EPN_DMAMODE0; - _nbu2ss_writel(&udc->p_regs->EP_REGS[num].EP_DMA_CTRL, data); - } -} - -/*-------------------------------------------------------------------------*/ -/* DMA setting release */ -static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) -{ - u32 num; - u32 data; - struct fc_regs __iomem *preg = udc->p_regs; - - if (udc->vbus_active == 0) - return; /* VBUS OFF */ - - data = _nbu2ss_readl(&preg->USBSSCONF); - if ((ep->epnum == 0) || ((data & (1 << ep->epnum)) == 0)) - return; /* Not Support DMA */ - - num = ep->epnum - 1; - - _nbu2ss_ep_dma_abort(udc, ep); - - if (ep->direct == USB_DIR_OUT) { - /*---------------------------------------------------------*/ - /* OUT */ - _nbu2ss_writel(&preg->EP_DCR[num].EP_DCR2, 0); - _nbu2ss_bitclr(&preg->EP_DCR[num].EP_DCR1, DCR1_EPN_DIR0); - _nbu2ss_writel(&preg->EP_REGS[num].EP_DMA_CTRL, 0); - } else { - /*---------------------------------------------------------*/ - /* IN */ - _nbu2ss_bitclr(&preg->EP_REGS[num].EP_CONTROL, EPN_AUTO); - _nbu2ss_writel(&preg->EP_REGS[num].EP_DMA_CTRL, 0); - } -} - -/*-------------------------------------------------------------------------*/ -/* Abort DMA */ -static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) -{ - struct fc_regs __iomem *preg = udc->p_regs; - - _nbu2ss_bitclr(&preg->EP_DCR[ep->epnum - 1].EP_DCR1, DCR1_EPN_REQEN); - mdelay(DMA_DISABLE_TIME); /* DCR1_EPN_REQEN Clear */ - _nbu2ss_bitclr(&preg->EP_REGS[ep->epnum - 1].EP_DMA_CTRL, EPN_DMA_EN); -} - -/*-------------------------------------------------------------------------*/ -/* Start IN Transfer */ -static void _nbu2ss_ep_in_end(struct nbu2ss_udc *udc, - u32 epnum, u32 data32, u32 length) -{ - u32 data; - u32 num; - struct fc_regs __iomem *preg = udc->p_regs; - - if (length >= sizeof(u32)) - return; - - if (epnum == 0) { - _nbu2ss_bitclr(&preg->EP0_CONTROL, EP0_AUTO); - - /* Writing of 1-4 bytes */ - if (length) - _nbu2ss_writel(&preg->EP0_WRITE, data32); - - data = ((length << 5) & EP0_DW) | EP0_DEND; - _nbu2ss_writel(&preg->EP0_CONTROL, data); - - _nbu2ss_bitset(&preg->EP0_CONTROL, EP0_AUTO); - } else { - num = epnum - 1; - - _nbu2ss_bitclr(&preg->EP_REGS[num].EP_CONTROL, EPN_AUTO); - - /* Writing of 1-4 bytes */ - if (length) - _nbu2ss_writel(&preg->EP_REGS[num].EP_WRITE, data32); - - data = (((length) << 5) & EPN_DW) | EPN_DEND; - _nbu2ss_bitset(&preg->EP_REGS[num].EP_CONTROL, data); - - _nbu2ss_bitset(&preg->EP_REGS[num].EP_CONTROL, EPN_AUTO); - } -} - -#ifdef USE_DMA -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_dma_map_single(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u8 direct) -{ - if (req->req.dma == DMA_ADDR_INVALID) { - if (req->unaligned) { - req->req.dma = ep->phys_buf; - } else { - req->req.dma = dma_map_single(udc->gadget.dev.parent, - req->req.buf, - req->req.length, - (direct == USB_DIR_IN) - ? DMA_TO_DEVICE - : DMA_FROM_DEVICE); - } - req->mapped = 1; - } else { - if (!req->unaligned) - dma_sync_single_for_device(udc->gadget.dev.parent, - req->req.dma, - req->req.length, - (direct == USB_DIR_IN) - ? DMA_TO_DEVICE - : DMA_FROM_DEVICE); - - req->mapped = 0; - } -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_dma_unmap_single(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u8 direct) -{ - u8 data[4]; - u8 *p; - u32 count = 0; - - if (direct == USB_DIR_OUT) { - count = req->req.actual % 4; - if (count) { - p = req->req.buf; - p += (req->req.actual - count); - memcpy(data, p, count); - } - } - - if (req->mapped) { - if (req->unaligned) { - if (direct == USB_DIR_OUT) - memcpy(req->req.buf, ep->virt_buf, - req->req.actual & 0xfffffffc); - } else { - dma_unmap_single(udc->gadget.dev.parent, - req->req.dma, req->req.length, - (direct == USB_DIR_IN) - ? DMA_TO_DEVICE - : DMA_FROM_DEVICE); - } - req->req.dma = DMA_ADDR_INVALID; - req->mapped = 0; - } else { - if (!req->unaligned) - dma_sync_single_for_cpu(udc->gadget.dev.parent, - req->req.dma, req->req.length, - (direct == USB_DIR_IN) - ? DMA_TO_DEVICE - : DMA_FROM_DEVICE); - } - - if (count) { - p = req->req.buf; - p += (req->req.actual - count); - memcpy(p, data, count); - } -} -#endif - -/*-------------------------------------------------------------------------*/ -/* Endpoint 0 OUT Transfer (PIO) */ -static int ep0_out_pio(struct nbu2ss_udc *udc, u8 *buf, u32 length) -{ - u32 i; - u32 numreads = length / sizeof(u32); - union usb_reg_access *buf32 = (union usb_reg_access *)buf; - - if (!numreads) - return 0; - - /* PIO Read */ - for (i = 0; i < numreads; i++) { - buf32->dw = _nbu2ss_readl(&udc->p_regs->EP0_READ); - buf32++; - } - - return numreads * sizeof(u32); -} - -/*-------------------------------------------------------------------------*/ -/* Endpoint 0 OUT Transfer (PIO, OverBytes) */ -static int ep0_out_overbytes(struct nbu2ss_udc *udc, u8 *p_buf, u32 length) -{ - u32 i; - u32 i_read_size = 0; - union usb_reg_access temp_32; - union usb_reg_access *p_buf_32 = (union usb_reg_access *)p_buf; - - if ((length > 0) && (length < sizeof(u32))) { - temp_32.dw = _nbu2ss_readl(&udc->p_regs->EP0_READ); - for (i = 0 ; i < length ; i++) - p_buf_32->byte.DATA[i] = temp_32.byte.DATA[i]; - i_read_size += length; - } - - return i_read_size; -} - -/*-------------------------------------------------------------------------*/ -/* Endpoint 0 IN Transfer (PIO) */ -static int EP0_in_PIO(struct nbu2ss_udc *udc, u8 *p_buf, u32 length) -{ - u32 i; - u32 i_max_length = EP0_PACKETSIZE; - u32 i_word_length = 0; - u32 i_write_length = 0; - union usb_reg_access *p_buf_32 = (union usb_reg_access *)p_buf; - - /*------------------------------------------------------------*/ - /* Transfer Length */ - if (i_max_length < length) - i_word_length = i_max_length / sizeof(u32); - else - i_word_length = length / sizeof(u32); - - /*------------------------------------------------------------*/ - /* PIO */ - for (i = 0; i < i_word_length; i++) { - _nbu2ss_writel(&udc->p_regs->EP0_WRITE, p_buf_32->dw); - p_buf_32++; - i_write_length += sizeof(u32); - } - - return i_write_length; -} - -/*-------------------------------------------------------------------------*/ -/* Endpoint 0 IN Transfer (PIO, OverBytes) */ -static int ep0_in_overbytes(struct nbu2ss_udc *udc, - u8 *p_buf, - u32 i_remain_size) -{ - u32 i; - union usb_reg_access temp_32; - union usb_reg_access *p_buf_32 = (union usb_reg_access *)p_buf; - - if ((i_remain_size > 0) && (i_remain_size < sizeof(u32))) { - for (i = 0 ; i < i_remain_size ; i++) - temp_32.byte.DATA[i] = p_buf_32->byte.DATA[i]; - _nbu2ss_ep_in_end(udc, 0, temp_32.dw, i_remain_size); - - return i_remain_size; - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -/* Transfer NULL Packet (Epndoint 0) */ -static int EP0_send_NULL(struct nbu2ss_udc *udc, bool pid_flag) -{ - u32 data; - - data = _nbu2ss_readl(&udc->p_regs->EP0_CONTROL); - data &= ~(u32)EP0_INAK; - - if (pid_flag) - data |= (EP0_INAK_EN | EP0_PIDCLR | EP0_DEND); - else - data |= (EP0_INAK_EN | EP0_DEND); - - _nbu2ss_writel(&udc->p_regs->EP0_CONTROL, data); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -/* Receive NULL Packet (Endpoint 0) */ -static int EP0_receive_NULL(struct nbu2ss_udc *udc, bool pid_flag) -{ - u32 data; - - data = _nbu2ss_readl(&udc->p_regs->EP0_CONTROL); - data &= ~(u32)EP0_ONAK; - - if (pid_flag) - data |= EP0_PIDCLR; - - _nbu2ss_writel(&udc->p_regs->EP0_CONTROL, data); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_ep0_in_transfer(struct nbu2ss_udc *udc, - struct nbu2ss_req *req) -{ - u8 *p_buffer; /* IN Data Buffer */ - u32 data; - u32 i_remain_size = 0; - int result = 0; - - /*-------------------------------------------------------------*/ - /* End confirmation */ - if (req->req.actual == req->req.length) { - if ((req->req.actual % EP0_PACKETSIZE) == 0) { - if (req->zero) { - req->zero = false; - EP0_send_NULL(udc, false); - return 1; - } - } - - return 0; /* Transfer End */ - } - - /*-------------------------------------------------------------*/ - /* NAK release */ - data = _nbu2ss_readl(&udc->p_regs->EP0_CONTROL); - data |= EP0_INAK_EN; - data &= ~(u32)EP0_INAK; - _nbu2ss_writel(&udc->p_regs->EP0_CONTROL, data); - - i_remain_size = req->req.length - req->req.actual; - p_buffer = (u8 *)req->req.buf; - p_buffer += req->req.actual; - - /*-------------------------------------------------------------*/ - /* Data transfer */ - result = EP0_in_PIO(udc, p_buffer, i_remain_size); - - req->div_len = result; - i_remain_size -= result; - - if (i_remain_size == 0) { - EP0_send_NULL(udc, false); - return result; - } - - if ((i_remain_size < sizeof(u32)) && (result != EP0_PACKETSIZE)) { - p_buffer += result; - result += ep0_in_overbytes(udc, p_buffer, i_remain_size); - req->div_len = result; - } - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_ep0_out_transfer(struct nbu2ss_udc *udc, - struct nbu2ss_req *req) -{ - u8 *p_buffer; - u32 i_remain_size; - u32 i_recv_length; - int result = 0; - int f_rcv_zero; - - /*-------------------------------------------------------------*/ - /* Receive data confirmation */ - i_recv_length = _nbu2ss_readl(&udc->p_regs->EP0_LENGTH) & EP0_LDATA; - if (i_recv_length != 0) { - f_rcv_zero = 0; - - i_remain_size = req->req.length - req->req.actual; - p_buffer = (u8 *)req->req.buf; - p_buffer += req->req.actual; - - result = ep0_out_pio(udc, p_buffer - , min(i_remain_size, i_recv_length)); - if (result < 0) - return result; - - req->req.actual += result; - i_recv_length -= result; - - if ((i_recv_length > 0) && (i_recv_length < sizeof(u32))) { - p_buffer += result; - i_remain_size -= result; - - result = ep0_out_overbytes(udc, p_buffer - , min(i_remain_size, i_recv_length)); - req->req.actual += result; - } - } else { - f_rcv_zero = 1; - } - - /*-------------------------------------------------------------*/ - /* End confirmation */ - if (req->req.actual == req->req.length) { - if ((req->req.actual % EP0_PACKETSIZE) == 0) { - if (req->zero) { - req->zero = false; - EP0_receive_NULL(udc, false); - return 1; - } - } - - return 0; /* Transfer End */ - } - - if ((req->req.actual % EP0_PACKETSIZE) != 0) - return 0; /* Short Packet Transfer End */ - - if (req->req.actual > req->req.length) { - dev_err(udc->dev, " *** Overrun Error\n"); - return -EOVERFLOW; - } - - if (f_rcv_zero != 0) { - i_remain_size = _nbu2ss_readl(&udc->p_regs->EP0_CONTROL); - if (i_remain_size & EP0_ONAK) { - /*---------------------------------------------------*/ - /* NACK release */ - _nbu2ss_bitclr(&udc->p_regs->EP0_CONTROL, EP0_ONAK); - } - result = 1; - } - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_out_dma(struct nbu2ss_udc *udc, struct nbu2ss_req *req, - u32 num, u32 length) -{ - dma_addr_t p_buffer; - u32 mpkt; - u32 lmpkt; - u32 dmacnt; - u32 burst = 1; - u32 data; - int result; - struct fc_regs __iomem *preg = udc->p_regs; - - if (req->dma_flag) - return 1; /* DMA is forwarded */ - - req->dma_flag = true; - p_buffer = req->req.dma; - p_buffer += req->req.actual; - - /* DMA Address */ - _nbu2ss_writel(&preg->EP_DCR[num].EP_TADR, (u32)p_buffer); - - /* Number of transfer packets */ - mpkt = _nbu2ss_readl(&preg->EP_REGS[num].EP_PCKT_ADRS) & EPN_MPKT; - dmacnt = length / mpkt; - lmpkt = (length % mpkt) & ~(u32)0x03; - - if (dmacnt > DMA_MAX_COUNT) { - dmacnt = DMA_MAX_COUNT; - lmpkt = 0; - } else if (lmpkt != 0) { - if (dmacnt == 0) - burst = 0; /* Burst OFF */ - dmacnt++; - } - - data = mpkt | (lmpkt << 16); - _nbu2ss_writel(&preg->EP_DCR[num].EP_DCR2, data); - - data = ((dmacnt & 0xff) << 16) | DCR1_EPN_DIR0 | DCR1_EPN_REQEN; - _nbu2ss_writel(&preg->EP_DCR[num].EP_DCR1, data); - - if (burst == 0) { - _nbu2ss_writel(&preg->EP_REGS[num].EP_LEN_DCNT, 0); - _nbu2ss_bitclr(&preg->EP_REGS[num].EP_DMA_CTRL, EPN_BURST_SET); - } else { - _nbu2ss_writel(&preg->EP_REGS[num].EP_LEN_DCNT - , (dmacnt << 16)); - _nbu2ss_bitset(&preg->EP_REGS[num].EP_DMA_CTRL, EPN_BURST_SET); - } - _nbu2ss_bitset(&preg->EP_REGS[num].EP_DMA_CTRL, EPN_DMA_EN); - - result = length & ~(u32)0x03; - req->div_len = result; - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_out_pio(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u32 length) -{ - u8 *p_buffer; - u32 i; - u32 data; - u32 i_word_length; - union usb_reg_access temp_32; - union usb_reg_access *p_buf_32; - int result = 0; - struct fc_regs __iomem *preg = udc->p_regs; - - if (req->dma_flag) - return 1; /* DMA is forwarded */ - - if (length == 0) - return 0; - - p_buffer = (u8 *)req->req.buf; - p_buf_32 = (union usb_reg_access *)(p_buffer + req->req.actual); - - i_word_length = length / sizeof(u32); - if (i_word_length > 0) { - /*---------------------------------------------------------*/ - /* Copy of every four bytes */ - for (i = 0; i < i_word_length; i++) { - p_buf_32->dw = - _nbu2ss_readl(&preg->EP_REGS[ep->epnum - 1].EP_READ); - p_buf_32++; - } - result = i_word_length * sizeof(u32); - } - - data = length - result; - if (data > 0) { - /*---------------------------------------------------------*/ - /* Copy of fraction byte */ - temp_32.dw = - _nbu2ss_readl(&preg->EP_REGS[ep->epnum - 1].EP_READ); - for (i = 0 ; i < data ; i++) - p_buf_32->byte.DATA[i] = temp_32.byte.DATA[i]; - result += data; - } - - req->req.actual += result; - - if ((req->req.actual == req->req.length) || - ((req->req.actual % ep->ep.maxpacket) != 0)) { - result = 0; - } - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_out_data(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u32 data_size) -{ - u32 num; - u32 i_buf_size; - int nret = 1; - - if (ep->epnum == 0) - return -EINVAL; - - num = ep->epnum - 1; - - i_buf_size = min((req->req.length - req->req.actual), data_size); - - if ((ep->ep_type != USB_ENDPOINT_XFER_INT) && (req->req.dma != 0) && - (i_buf_size >= sizeof(u32))) { - nret = _nbu2ss_out_dma(udc, req, num, i_buf_size); - } else { - i_buf_size = min_t(u32, i_buf_size, ep->ep.maxpacket); - nret = _nbu2ss_epn_out_pio(udc, ep, req, i_buf_size); - } - - return nret; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_out_transfer(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) -{ - u32 num; - u32 i_recv_length; - int result = 1; - struct fc_regs __iomem *preg = udc->p_regs; - - if (ep->epnum == 0) - return -EINVAL; - - num = ep->epnum - 1; - - /*-------------------------------------------------------------*/ - /* Receive Length */ - i_recv_length = - _nbu2ss_readl(&preg->EP_REGS[num].EP_LEN_DCNT) & EPN_LDATA; - - if (i_recv_length != 0) { - result = _nbu2ss_epn_out_data(udc, ep, req, i_recv_length); - if (i_recv_length < ep->ep.maxpacket) { - if (i_recv_length == result) { - req->req.actual += result; - result = 0; - } - } - } else { - if ((req->req.actual == req->req.length) || - ((req->req.actual % ep->ep.maxpacket) != 0)) { - result = 0; - } - } - - if (result == 0) { - if ((req->req.actual % ep->ep.maxpacket) == 0) { - if (req->zero) { - req->zero = false; - return 1; - } - } - } - - if (req->req.actual > req->req.length) { - dev_err(udc->dev, " Overrun Error\n"); - dev_err(udc->dev, " actual = %d, length = %d\n", - req->req.actual, req->req.length); - result = -EOVERFLOW; - } - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_in_dma(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u32 num, u32 length) -{ - dma_addr_t p_buffer; - u32 mpkt; /* MaxPacketSize */ - u32 lmpkt; /* Last Packet Data Size */ - u32 dmacnt; /* IN Data Size */ - u32 i_write_length; - u32 data; - int result = -EINVAL; - struct fc_regs __iomem *preg = udc->p_regs; - - if (req->dma_flag) - return 1; /* DMA is forwarded */ - -#ifdef USE_DMA - if (req->req.actual == 0) - _nbu2ss_dma_map_single(udc, ep, req, USB_DIR_IN); -#endif - req->dma_flag = true; - - /* MAX Packet Size */ - mpkt = _nbu2ss_readl(&preg->EP_REGS[num].EP_PCKT_ADRS) & EPN_MPKT; - - i_write_length = min(DMA_MAX_COUNT * mpkt, length); - - /*------------------------------------------------------------*/ - /* Number of transmission packets */ - if (mpkt < i_write_length) { - dmacnt = i_write_length / mpkt; - lmpkt = (i_write_length % mpkt) & ~(u32)0x3; - if (lmpkt != 0) - dmacnt++; - else - lmpkt = mpkt & ~(u32)0x3; - - } else { - dmacnt = 1; - lmpkt = i_write_length & ~(u32)0x3; - } - - /* Packet setting */ - data = mpkt | (lmpkt << 16); - _nbu2ss_writel(&preg->EP_DCR[num].EP_DCR2, data); - - /* Address setting */ - p_buffer = req->req.dma; - p_buffer += req->req.actual; - _nbu2ss_writel(&preg->EP_DCR[num].EP_TADR, (u32)p_buffer); - - /* Packet and DMA setting */ - data = ((dmacnt & 0xff) << 16) | DCR1_EPN_REQEN; - _nbu2ss_writel(&preg->EP_DCR[num].EP_DCR1, data); - - /* Packet setting of EPC */ - data = dmacnt << 16; - _nbu2ss_writel(&preg->EP_REGS[num].EP_LEN_DCNT, data); - - /*DMA setting of EPC */ - _nbu2ss_bitset(&preg->EP_REGS[num].EP_DMA_CTRL, EPN_DMA_EN); - - result = i_write_length & ~(u32)0x3; - req->div_len = result; - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_in_pio(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u32 length) -{ - u8 *p_buffer; - u32 i; - u32 data; - u32 i_word_length; - union usb_reg_access temp_32; - union usb_reg_access *p_buf_32 = NULL; - int result = 0; - struct fc_regs __iomem *preg = udc->p_regs; - - if (req->dma_flag) - return 1; /* DMA is forwarded */ - - if (length > 0) { - p_buffer = (u8 *)req->req.buf; - p_buf_32 = (union usb_reg_access *)(p_buffer + req->req.actual); - - i_word_length = length / sizeof(u32); - if (i_word_length > 0) { - for (i = 0; i < i_word_length; i++) { - _nbu2ss_writel(&preg->EP_REGS[ep->epnum - 1].EP_WRITE, - p_buf_32->dw); - - p_buf_32++; - } - result = i_word_length * sizeof(u32); - } - } - - if (result != ep->ep.maxpacket) { - data = length - result; - temp_32.dw = 0; - for (i = 0 ; i < data ; i++) - temp_32.byte.DATA[i] = p_buf_32->byte.DATA[i]; - - _nbu2ss_ep_in_end(udc, ep->epnum, temp_32.dw, data); - result += data; - } - - req->div_len = result; - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_in_data(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, - struct nbu2ss_req *req, u32 data_size) -{ - u32 num; - int nret = 1; - - if (ep->epnum == 0) - return -EINVAL; - - num = ep->epnum - 1; - - if ((ep->ep_type != USB_ENDPOINT_XFER_INT) && (req->req.dma != 0) && - (data_size >= sizeof(u32))) { - nret = _nbu2ss_in_dma(udc, ep, req, num, data_size); - } else { - data_size = min_t(u32, data_size, ep->ep.maxpacket); - nret = _nbu2ss_epn_in_pio(udc, ep, req, data_size); - } - - return nret; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_in_transfer(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, struct nbu2ss_req *req) -{ - u32 num; - u32 i_buf_size; - int result = 0; - u32 status; - - if (ep->epnum == 0) - return -EINVAL; - - num = ep->epnum - 1; - - status = _nbu2ss_readl(&udc->p_regs->EP_REGS[num].EP_STATUS); - - /*-------------------------------------------------------------*/ - /* State confirmation of FIFO */ - if (req->req.actual == 0) { - if ((status & EPN_IN_EMPTY) == 0) - return 1; /* Not Empty */ - - } else { - if ((status & EPN_IN_FULL) != 0) - return 1; /* Not Empty */ - } - - /*-------------------------------------------------------------*/ - /* Start transfer */ - i_buf_size = req->req.length - req->req.actual; - if (i_buf_size > 0) - result = _nbu2ss_epn_in_data(udc, ep, req, i_buf_size); - else if (req->req.length == 0) - _nbu2ss_zero_len_pkt(udc, ep->epnum); - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_start_transfer(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - bool bflag) -{ - int nret = -EINVAL; - - req->dma_flag = false; - req->div_len = 0; - - if (req->req.length == 0) { - req->zero = false; - } else { - if ((req->req.length % ep->ep.maxpacket) == 0) - req->zero = req->req.zero; - else - req->zero = false; - } - - if (ep->epnum == 0) { - /* EP0 */ - switch (udc->ep0state) { - case EP0_IN_DATA_PHASE: - nret = _nbu2ss_ep0_in_transfer(udc, req); - break; - - case EP0_OUT_DATA_PHASE: - nret = _nbu2ss_ep0_out_transfer(udc, req); - break; - - case EP0_IN_STATUS_PHASE: - nret = EP0_send_NULL(udc, true); - break; - - default: - break; - } - - } else { - /* EPN */ - if (ep->direct == USB_DIR_OUT) { - /* OUT */ - if (!bflag) - nret = _nbu2ss_epn_out_transfer(udc, ep, req); - } else { - /* IN */ - nret = _nbu2ss_epn_in_transfer(udc, ep, req); - } - } - - return nret; -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_restert_transfer(struct nbu2ss_ep *ep) -{ - u32 length; - bool bflag = false; - struct nbu2ss_req *req; - - req = list_first_entry_or_null(&ep->queue, struct nbu2ss_req, queue); - if (!req) - return; - - if (ep->epnum > 0) { - length = _nbu2ss_readl(&ep->udc->p_regs->EP_REGS[ep->epnum - 1].EP_LEN_DCNT); - - length &= EPN_LDATA; - if (length < ep->ep.maxpacket) - bflag = true; - } - - _nbu2ss_start_transfer(ep->udc, ep, req, bflag); -} - -/*-------------------------------------------------------------------------*/ -/* Endpoint Toggle Reset */ -static void _nbu2ss_endpoint_toggle_reset(struct nbu2ss_udc *udc, u8 ep_adrs) -{ - u8 num; - u32 data; - - if ((ep_adrs == 0) || (ep_adrs == 0x80)) - return; - - num = (ep_adrs & 0x7F) - 1; - - if (ep_adrs & USB_DIR_IN) - data = EPN_IPIDCLR; - else - data = EPN_BCLR | EPN_OPIDCLR; - - _nbu2ss_bitset(&udc->p_regs->EP_REGS[num].EP_CONTROL, data); -} - -/*-------------------------------------------------------------------------*/ -/* Endpoint STALL set */ -static void _nbu2ss_set_endpoint_stall(struct nbu2ss_udc *udc, - u8 ep_adrs, bool bstall) -{ - u8 num, epnum; - u32 data; - struct nbu2ss_ep *ep; - struct fc_regs __iomem *preg = udc->p_regs; - - if ((ep_adrs == 0) || (ep_adrs == 0x80)) { - if (bstall) { - /* Set STALL */ - _nbu2ss_bitset(&preg->EP0_CONTROL, EP0_STL); - } else { - /* Clear STALL */ - _nbu2ss_bitclr(&preg->EP0_CONTROL, EP0_STL); - } - } else { - epnum = ep_adrs & USB_ENDPOINT_NUMBER_MASK; - num = epnum - 1; - ep = &udc->ep[epnum]; - - if (bstall) { - /* Set STALL */ - ep->halted = true; - - if (ep_adrs & USB_DIR_IN) - data = EPN_BCLR | EPN_ISTL; - else - data = EPN_OSTL_EN | EPN_OSTL; - - _nbu2ss_bitset(&preg->EP_REGS[num].EP_CONTROL, data); - } else { - if (ep_adrs & USB_DIR_IN) { - _nbu2ss_bitclr(&preg->EP_REGS[num].EP_CONTROL - , EPN_ISTL); - } else { - data = - _nbu2ss_readl(&preg->EP_REGS[num].EP_CONTROL); - - data &= ~EPN_OSTL; - data |= EPN_OSTL_EN; - - _nbu2ss_writel(&preg->EP_REGS[num].EP_CONTROL - , data); - } - - /* Clear STALL */ - ep->stalled = false; - if (ep->halted) { - ep->halted = false; - _nbu2ss_restert_transfer(ep); - } - } - } -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_set_test_mode(struct nbu2ss_udc *udc, u32 mode) -{ - u32 data; - - if (mode > MAX_TEST_MODE_NUM) - return; - - dev_info(udc->dev, "SET FEATURE : test mode = %d\n", mode); - - data = _nbu2ss_readl(&udc->p_regs->USB_CONTROL); - data &= ~TEST_FORCE_ENABLE; - data |= mode << TEST_MODE_SHIFT; - - _nbu2ss_writel(&udc->p_regs->USB_CONTROL, data); - _nbu2ss_bitset(&udc->p_regs->TEST_CONTROL, CS_TESTMODEEN); -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_set_feature_device(struct nbu2ss_udc *udc, - u16 selector, u16 wIndex) -{ - int result = -EOPNOTSUPP; - - switch (selector) { - case USB_DEVICE_REMOTE_WAKEUP: - if (wIndex == 0x0000) { - udc->remote_wakeup = U2F_ENABLE; - result = 0; - } - break; - - case USB_DEVICE_TEST_MODE: - wIndex >>= 8; - if (wIndex <= MAX_TEST_MODE_NUM) - result = 0; - break; - - default: - break; - } - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_get_ep_stall(struct nbu2ss_udc *udc, u8 ep_adrs) -{ - u8 epnum; - u32 data = 0, bit_data; - struct fc_regs __iomem *preg = udc->p_regs; - - epnum = ep_adrs & ~USB_ENDPOINT_DIR_MASK; - if (epnum == 0) { - data = _nbu2ss_readl(&preg->EP0_CONTROL); - bit_data = EP0_STL; - - } else { - data = _nbu2ss_readl(&preg->EP_REGS[epnum - 1].EP_CONTROL); - if ((data & EPN_EN) == 0) - return -1; - - if (ep_adrs & USB_ENDPOINT_DIR_MASK) - bit_data = EPN_ISTL; - else - bit_data = EPN_OSTL; - } - - if ((data & bit_data) == 0) - return 0; - return 1; -} - -/*-------------------------------------------------------------------------*/ -static inline int _nbu2ss_req_feature(struct nbu2ss_udc *udc, bool bset) -{ - u8 recipient = (u8)(udc->ctrl.bRequestType & USB_RECIP_MASK); - u8 direction = (u8)(udc->ctrl.bRequestType & USB_DIR_IN); - u16 selector = le16_to_cpu(udc->ctrl.wValue); - u16 wIndex = le16_to_cpu(udc->ctrl.wIndex); - u8 ep_adrs; - int result = -EOPNOTSUPP; - - if ((udc->ctrl.wLength != 0x0000) || - (direction != USB_DIR_OUT)) { - return -EINVAL; - } - - switch (recipient) { - case USB_RECIP_DEVICE: - if (bset) - result = - _nbu2ss_set_feature_device(udc, selector, wIndex); - break; - - case USB_RECIP_ENDPOINT: - if (0x0000 == (wIndex & 0xFF70)) { - if (selector == USB_ENDPOINT_HALT) { - ep_adrs = wIndex & 0xFF; - if (!bset) { - _nbu2ss_endpoint_toggle_reset(udc, - ep_adrs); - } - - _nbu2ss_set_endpoint_stall(udc, ep_adrs, bset); - - result = 0; - } - } - break; - - default: - break; - } - - if (result >= 0) - _nbu2ss_create_ep0_packet(udc, udc->ep0_buf, 0); - - return result; -} - -/*-------------------------------------------------------------------------*/ -static inline enum usb_device_speed _nbu2ss_get_speed(struct nbu2ss_udc *udc) -{ - u32 data; - enum usb_device_speed speed = USB_SPEED_FULL; - - data = _nbu2ss_readl(&udc->p_regs->USB_STATUS); - if (data & HIGH_SPEED) - speed = USB_SPEED_HIGH; - - return speed; -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_epn_set_stall(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep) -{ - u8 ep_adrs; - u32 regdata; - int limit_cnt = 0; - - struct fc_regs __iomem *preg = udc->p_regs; - - if (ep->direct == USB_DIR_IN) { - for (limit_cnt = 0 - ; limit_cnt < IN_DATA_EMPTY_COUNT - ; limit_cnt++) { - regdata = _nbu2ss_readl(&preg->EP_REGS[ep->epnum - 1].EP_STATUS); - - if ((regdata & EPN_IN_DATA) == 0) - break; - - mdelay(1); - } - } - - ep_adrs = ep->epnum | ep->direct; - _nbu2ss_set_endpoint_stall(udc, ep_adrs, 1); -} - -/*-------------------------------------------------------------------------*/ -static int std_req_get_status(struct nbu2ss_udc *udc) -{ - u32 length; - u16 status_data = 0; - u8 recipient = (u8)(udc->ctrl.bRequestType & USB_RECIP_MASK); - u8 direction = (u8)(udc->ctrl.bRequestType & USB_DIR_IN); - u8 ep_adrs; - int result = -EINVAL; - - if ((udc->ctrl.wValue != 0x0000) || (direction != USB_DIR_IN)) - return result; - - length = - min_t(u16, le16_to_cpu(udc->ctrl.wLength), sizeof(status_data)); - switch (recipient) { - case USB_RECIP_DEVICE: - if (udc->ctrl.wIndex == 0x0000) { - if (udc->gadget.is_selfpowered) - status_data |= BIT(USB_DEVICE_SELF_POWERED); - - if (udc->remote_wakeup) - status_data |= BIT(USB_DEVICE_REMOTE_WAKEUP); - - result = 0; - } - break; - - case USB_RECIP_ENDPOINT: - if (0x0000 == (le16_to_cpu(udc->ctrl.wIndex) & 0xFF70)) { - ep_adrs = (u8)(le16_to_cpu(udc->ctrl.wIndex) & 0xFF); - result = _nbu2ss_get_ep_stall(udc, ep_adrs); - - if (result > 0) - status_data |= BIT(USB_ENDPOINT_HALT); - } - break; - - default: - break; - } - - if (result >= 0) { - memcpy(udc->ep0_buf, &status_data, length); - _nbu2ss_create_ep0_packet(udc, udc->ep0_buf, length); - _nbu2ss_ep0_in_transfer(udc, &udc->ep0_req); - - } else { - dev_err(udc->dev, " Error GET_STATUS\n"); - } - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int std_req_clear_feature(struct nbu2ss_udc *udc) -{ - return _nbu2ss_req_feature(udc, false); -} - -/*-------------------------------------------------------------------------*/ -static int std_req_set_feature(struct nbu2ss_udc *udc) -{ - return _nbu2ss_req_feature(udc, true); -} - -/*-------------------------------------------------------------------------*/ -static int std_req_set_address(struct nbu2ss_udc *udc) -{ - int result = 0; - u32 wValue = le16_to_cpu(udc->ctrl.wValue); - - if ((udc->ctrl.bRequestType != 0x00) || - (udc->ctrl.wIndex != 0x0000) || - (udc->ctrl.wLength != 0x0000)) { - return -EINVAL; - } - - if (wValue != (wValue & 0x007F)) - return -EINVAL; - - wValue <<= USB_ADRS_SHIFT; - - _nbu2ss_writel(&udc->p_regs->USB_ADDRESS, wValue); - _nbu2ss_create_ep0_packet(udc, udc->ep0_buf, 0); - - return result; -} - -/*-------------------------------------------------------------------------*/ -static int std_req_set_configuration(struct nbu2ss_udc *udc) -{ - u32 config_value = (u32)(le16_to_cpu(udc->ctrl.wValue) & 0x00ff); - - if ((udc->ctrl.wIndex != 0x0000) || - (udc->ctrl.wLength != 0x0000) || - (udc->ctrl.bRequestType != 0x00)) { - return -EINVAL; - } - - udc->curr_config = config_value; - - if (config_value > 0) { - _nbu2ss_bitset(&udc->p_regs->USB_CONTROL, CONF); - udc->devstate = USB_STATE_CONFIGURED; - - } else { - _nbu2ss_bitclr(&udc->p_regs->USB_CONTROL, CONF); - udc->devstate = USB_STATE_ADDRESS; - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_read_request_data(struct nbu2ss_udc *udc, u32 *pdata) -{ - *pdata = _nbu2ss_readl(&udc->p_regs->SETUP_DATA0); - pdata++; - *pdata = _nbu2ss_readl(&udc->p_regs->SETUP_DATA1); -} - -/*-------------------------------------------------------------------------*/ -static inline int _nbu2ss_decode_request(struct nbu2ss_udc *udc) -{ - bool bcall_back = true; - int nret = -EINVAL; - struct usb_ctrlrequest *p_ctrl; - - p_ctrl = &udc->ctrl; - _nbu2ss_read_request_data(udc, (u32 *)p_ctrl); - - /* ep0 state control */ - if (p_ctrl->wLength == 0) { - udc->ep0state = EP0_IN_STATUS_PHASE; - - } else { - if (p_ctrl->bRequestType & USB_DIR_IN) - udc->ep0state = EP0_IN_DATA_PHASE; - else - udc->ep0state = EP0_OUT_DATA_PHASE; - } - - if ((p_ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { - switch (p_ctrl->bRequest) { - case USB_REQ_GET_STATUS: - nret = std_req_get_status(udc); - bcall_back = false; - break; - - case USB_REQ_CLEAR_FEATURE: - nret = std_req_clear_feature(udc); - bcall_back = false; - break; - - case USB_REQ_SET_FEATURE: - nret = std_req_set_feature(udc); - bcall_back = false; - break; - - case USB_REQ_SET_ADDRESS: - nret = std_req_set_address(udc); - bcall_back = false; - break; - - case USB_REQ_SET_CONFIGURATION: - nret = std_req_set_configuration(udc); - break; - - default: - break; - } - } - - if (!bcall_back) { - if (udc->ep0state == EP0_IN_STATUS_PHASE) { - if (nret >= 0) { - /*--------------------------------------*/ - /* Status Stage */ - nret = EP0_send_NULL(udc, true); - } - } - - } else { - spin_unlock(&udc->lock); - nret = udc->driver->setup(&udc->gadget, &udc->ctrl); - spin_lock(&udc->lock); - } - - if (nret < 0) - udc->ep0state = EP0_IDLE; - - return nret; -} - -/*-------------------------------------------------------------------------*/ -static inline int _nbu2ss_ep0_in_data_stage(struct nbu2ss_udc *udc) -{ - int nret; - struct nbu2ss_req *req; - struct nbu2ss_ep *ep = &udc->ep[0]; - - req = list_first_entry_or_null(&ep->queue, struct nbu2ss_req, queue); - if (!req) - req = &udc->ep0_req; - - req->req.actual += req->div_len; - req->div_len = 0; - - nret = _nbu2ss_ep0_in_transfer(udc, req); - if (nret == 0) { - udc->ep0state = EP0_OUT_STATUS_PAHSE; - EP0_receive_NULL(udc, true); - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static inline int _nbu2ss_ep0_out_data_stage(struct nbu2ss_udc *udc) -{ - int nret; - struct nbu2ss_req *req; - struct nbu2ss_ep *ep = &udc->ep[0]; - - req = list_first_entry_or_null(&ep->queue, struct nbu2ss_req, queue); - if (!req) - req = &udc->ep0_req; - - nret = _nbu2ss_ep0_out_transfer(udc, req); - if (nret == 0) { - udc->ep0state = EP0_IN_STATUS_PHASE; - EP0_send_NULL(udc, true); - - } else if (nret < 0) { - _nbu2ss_bitset(&udc->p_regs->EP0_CONTROL, EP0_BCLR); - req->req.status = nret; - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static inline int _nbu2ss_ep0_status_stage(struct nbu2ss_udc *udc) -{ - struct nbu2ss_req *req; - struct nbu2ss_ep *ep = &udc->ep[0]; - - req = list_first_entry_or_null(&ep->queue, struct nbu2ss_req, queue); - if (!req) { - req = &udc->ep0_req; - if (req->req.complete) - req->req.complete(&ep->ep, &req->req); - - } else { - if (req->req.complete) - _nbu2ss_ep_done(ep, req, 0); - } - - udc->ep0state = EP0_IDLE; - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_ep0_int(struct nbu2ss_udc *udc) -{ - int i; - u32 status; - u32 intr; - int nret = -1; - - status = _nbu2ss_readl(&udc->p_regs->EP0_STATUS); - intr = status & EP0_STATUS_RW_BIT; - _nbu2ss_writel(&udc->p_regs->EP0_STATUS, ~intr); - - status &= (SETUP_INT | EP0_IN_INT | EP0_OUT_INT - | STG_END_INT | EP0_OUT_NULL_INT); - - if (status == 0) { - dev_info(udc->dev, "%s Not Decode Interrupt\n", __func__); - dev_info(udc->dev, "EP0_STATUS = 0x%08x\n", intr); - return; - } - - if (udc->gadget.speed == USB_SPEED_UNKNOWN) - udc->gadget.speed = _nbu2ss_get_speed(udc); - - for (i = 0; i < EP0_END_XFER; i++) { - switch (udc->ep0state) { - case EP0_IDLE: - if (status & SETUP_INT) { - status = 0; - nret = _nbu2ss_decode_request(udc); - } - break; - - case EP0_IN_DATA_PHASE: - if (status & EP0_IN_INT) { - status &= ~EP0_IN_INT; - nret = _nbu2ss_ep0_in_data_stage(udc); - } - break; - - case EP0_OUT_DATA_PHASE: - if (status & EP0_OUT_INT) { - status &= ~EP0_OUT_INT; - nret = _nbu2ss_ep0_out_data_stage(udc); - } - break; - - case EP0_IN_STATUS_PHASE: - if ((status & STG_END_INT) || (status & SETUP_INT)) { - status &= ~(STG_END_INT | EP0_IN_INT); - nret = _nbu2ss_ep0_status_stage(udc); - } - break; - - case EP0_OUT_STATUS_PAHSE: - if ((status & STG_END_INT) || (status & SETUP_INT) || - (status & EP0_OUT_NULL_INT)) { - status &= ~(STG_END_INT - | EP0_OUT_INT - | EP0_OUT_NULL_INT); - - nret = _nbu2ss_ep0_status_stage(udc); - } - - break; - - default: - status = 0; - break; - } - - if (status == 0) - break; - } - - if (nret < 0) { - /* Send Stall */ - _nbu2ss_set_endpoint_stall(udc, 0, true); - } -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_ep_done(struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - int status) -{ - struct nbu2ss_udc *udc = ep->udc; - - list_del_init(&req->queue); - - if (status == -ECONNRESET) - _nbu2ss_fifo_flush(udc, ep); - - if (likely(req->req.status == -EINPROGRESS)) - req->req.status = status; - - if (ep->stalled) { - _nbu2ss_epn_set_stall(udc, ep); - } else { - if (!list_empty(&ep->queue)) - _nbu2ss_restert_transfer(ep); - } - -#ifdef USE_DMA - if ((ep->direct == USB_DIR_OUT) && (ep->epnum > 0) && - (req->req.dma != 0)) - _nbu2ss_dma_unmap_single(udc, ep, req, USB_DIR_OUT); -#endif - - spin_unlock(&udc->lock); - req->req.complete(&ep->ep, &req->req); - spin_lock(&udc->lock); -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_in_int(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) -{ - int result = 0; - u32 status; - - struct fc_regs __iomem *preg = udc->p_regs; - - if (req->dma_flag) - return; /* DMA is forwarded */ - - req->req.actual += req->div_len; - req->div_len = 0; - - if (req->req.actual != req->req.length) { - /*---------------------------------------------------------*/ - /* remainder of data */ - result = _nbu2ss_epn_in_transfer(udc, ep, req); - - } else { - if (req->zero && ((req->req.actual % ep->ep.maxpacket) == 0)) { - status = - _nbu2ss_readl(&preg->EP_REGS[ep->epnum - 1].EP_STATUS); - - if ((status & EPN_IN_FULL) == 0) { - /*-----------------------------------------*/ - /* 0 Length Packet */ - req->zero = false; - _nbu2ss_zero_len_pkt(udc, ep->epnum); - } - return; - } - } - - if (result <= 0) { - /*---------------------------------------------------------*/ - /* Complete */ - _nbu2ss_ep_done(ep, req, result); - } -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_out_int(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) -{ - int result; - - result = _nbu2ss_epn_out_transfer(udc, ep, req); - if (result <= 0) - _nbu2ss_ep_done(ep, req, result); -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_in_dma_int(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) -{ - u32 mpkt; - u32 size; - struct usb_request *preq; - - preq = &req->req; - - if (!req->dma_flag) - return; - - preq->actual += req->div_len; - req->div_len = 0; - req->dma_flag = false; - -#ifdef USE_DMA - _nbu2ss_dma_unmap_single(udc, ep, req, USB_DIR_IN); -#endif - - if (preq->actual != preq->length) { - _nbu2ss_epn_in_transfer(udc, ep, req); - } else { - mpkt = ep->ep.maxpacket; - size = preq->actual % mpkt; - if (size > 0) { - if (((preq->actual & 0x03) == 0) && (size < mpkt)) - _nbu2ss_ep_in_end(udc, ep->epnum, 0, 0); - } else { - _nbu2ss_epn_in_int(udc, ep, req); - } - } -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_out_dma_int(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) -{ - int i; - u32 num; - u32 dmacnt, ep_dmacnt; - u32 mpkt; - struct fc_regs __iomem *preg = udc->p_regs; - - num = ep->epnum - 1; - - if (req->req.actual == req->req.length) { - if ((req->req.length % ep->ep.maxpacket) && !req->zero) { - req->div_len = 0; - req->dma_flag = false; - _nbu2ss_ep_done(ep, req, 0); - return; - } - } - - ep_dmacnt = _nbu2ss_readl(&preg->EP_REGS[num].EP_LEN_DCNT) - & EPN_DMACNT; - ep_dmacnt >>= 16; - - for (i = 0; i < EPC_PLL_LOCK_COUNT; i++) { - dmacnt = _nbu2ss_readl(&preg->EP_DCR[num].EP_DCR1) - & DCR1_EPN_DMACNT; - dmacnt >>= 16; - if (ep_dmacnt == dmacnt) - break; - } - - _nbu2ss_bitclr(&preg->EP_DCR[num].EP_DCR1, DCR1_EPN_REQEN); - - if (dmacnt != 0) { - mpkt = ep->ep.maxpacket; - if ((req->div_len % mpkt) == 0) - req->div_len -= mpkt * dmacnt; - } - - if ((req->req.actual % ep->ep.maxpacket) > 0) { - if (req->req.actual == req->div_len) { - req->div_len = 0; - req->dma_flag = false; - _nbu2ss_ep_done(ep, req, 0); - return; - } - } - - req->req.actual += req->div_len; - req->div_len = 0; - req->dma_flag = false; - - _nbu2ss_epn_out_int(udc, ep, req); -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_int(struct nbu2ss_udc *udc, u32 epnum) -{ - u32 num; - u32 status; - - struct nbu2ss_req *req; - struct nbu2ss_ep *ep = &udc->ep[epnum]; - - num = epnum - 1; - - /* Interrupt Status */ - status = _nbu2ss_readl(&udc->p_regs->EP_REGS[num].EP_STATUS); - - /* Interrupt Clear */ - _nbu2ss_writel(&udc->p_regs->EP_REGS[num].EP_STATUS, ~status); - - req = list_first_entry_or_null(&ep->queue, struct nbu2ss_req, queue); - if (!req) { - /* pr_warn("=== %s(%d) req == NULL\n", __func__, epnum); */ - return; - } - - if (status & EPN_OUT_END_INT) { - status &= ~EPN_OUT_INT; - _nbu2ss_epn_out_dma_int(udc, ep, req); - } - - if (status & EPN_OUT_INT) - _nbu2ss_epn_out_int(udc, ep, req); - - if (status & EPN_IN_END_INT) { - status &= ~EPN_IN_INT; - _nbu2ss_epn_in_dma_int(udc, ep, req); - } - - if (status & EPN_IN_INT) - _nbu2ss_epn_in_int(udc, ep, req); -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_ep_int(struct nbu2ss_udc *udc, u32 epnum) -{ - if (epnum == 0) - _nbu2ss_ep0_int(udc); - else - _nbu2ss_epn_int(udc, epnum); -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_ep0_enable(struct nbu2ss_udc *udc) -{ - _nbu2ss_bitset(&udc->p_regs->EP0_CONTROL, (EP0_AUTO | EP0_BCLR)); - _nbu2ss_writel(&udc->p_regs->EP0_INT_ENA, EP0_INT_EN_BIT); -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_nuke(struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - int status) -{ - struct nbu2ss_req *req, *n; - - /* Endpoint Disable */ - _nbu2ss_epn_exit(udc, ep); - - /* DMA Disable */ - _nbu2ss_ep_dma_exit(udc, ep); - - if (list_empty(&ep->queue)) - return 0; - - /* called with irqs blocked */ - list_for_each_entry_safe(req, n, &ep->queue, queue) { - _nbu2ss_ep_done(ep, req, status); - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_quiesce(struct nbu2ss_udc *udc) -{ - struct nbu2ss_ep *ep; - - udc->gadget.speed = USB_SPEED_UNKNOWN; - - _nbu2ss_nuke(udc, &udc->ep[0], -ESHUTDOWN); - - /* Endpoint n */ - list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { - _nbu2ss_nuke(udc, ep, -ESHUTDOWN); - } -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on) -{ - u32 reg_dt; - - if (udc->vbus_active == 0) - return -ESHUTDOWN; - - if (is_on) { - /* D+ Pullup */ - if (udc->driver) { - reg_dt = (_nbu2ss_readl(&udc->p_regs->USB_CONTROL) - | PUE2) & ~(u32)CONNECTB; - - _nbu2ss_writel(&udc->p_regs->USB_CONTROL, reg_dt); - } - - } else { - /* D+ Pulldown */ - reg_dt = (_nbu2ss_readl(&udc->p_regs->USB_CONTROL) | CONNECTB) - & ~(u32)PUE2; - - _nbu2ss_writel(&udc->p_regs->USB_CONTROL, reg_dt); - udc->gadget.speed = USB_SPEED_UNKNOWN; - } - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_fifo_flush(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) -{ - struct fc_regs __iomem *p = udc->p_regs; - - if (udc->vbus_active == 0) - return; - - if (ep->epnum == 0) { - /* EP0 */ - _nbu2ss_bitset(&p->EP0_CONTROL, EP0_BCLR); - - } else { - /* EPN */ - _nbu2ss_ep_dma_abort(udc, ep); - _nbu2ss_bitset(&p->EP_REGS[ep->epnum - 1].EP_CONTROL, EPN_BCLR); - } -} - -/*-------------------------------------------------------------------------*/ -static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc) -{ - int waitcnt = 0; - - if (udc->udc_enabled) - return 0; - - /* Reset */ - _nbu2ss_bitset(&udc->p_regs->EPCTR, (DIRPD | EPC_RST)); - udelay(EPC_RST_DISABLE_TIME); /* 1us wait */ - - _nbu2ss_bitclr(&udc->p_regs->EPCTR, DIRPD); - mdelay(EPC_DIRPD_DISABLE_TIME); /* 1ms wait */ - - _nbu2ss_bitclr(&udc->p_regs->EPCTR, EPC_RST); - - _nbu2ss_writel(&udc->p_regs->AHBSCTR, WAIT_MODE); - - _nbu2ss_writel(&udc->p_regs->AHBMCTR, - HBUSREQ_MODE | HTRANS_MODE | WBURST_TYPE); - - while (!(_nbu2ss_readl(&udc->p_regs->EPCTR) & PLL_LOCK)) { - waitcnt++; - udelay(1); /* 1us wait */ - if (waitcnt == EPC_PLL_LOCK_COUNT) { - dev_err(udc->dev, "*** Reset Cancel failed\n"); - return -EINVAL; - } - } - - _nbu2ss_bitset(&udc->p_regs->UTMI_CHARACTER_1, USB_SQUSET); - - _nbu2ss_bitset(&udc->p_regs->USB_CONTROL, (INT_SEL | SOF_RCV)); - - /* EP0 */ - _nbu2ss_ep0_enable(udc); - - /* USB Interrupt Enable */ - _nbu2ss_bitset(&udc->p_regs->USB_INT_ENA, USB_INT_EN_BIT); - - udc->udc_enabled = true; - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_reset_controller(struct nbu2ss_udc *udc) -{ - _nbu2ss_bitset(&udc->p_regs->EPCTR, EPC_RST); - _nbu2ss_bitclr(&udc->p_regs->EPCTR, EPC_RST); -} - -/*-------------------------------------------------------------------------*/ -static void _nbu2ss_disable_controller(struct nbu2ss_udc *udc) -{ - if (udc->udc_enabled) { - udc->udc_enabled = false; - _nbu2ss_reset_controller(udc); - _nbu2ss_bitset(&udc->p_regs->EPCTR, (DIRPD | EPC_RST)); - } -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_check_vbus(struct nbu2ss_udc *udc) -{ - int nret; - u32 reg_dt; - - /* chattering */ - mdelay(VBUS_CHATTERING_MDELAY); /* wait (ms) */ - - /* VBUS ON Check*/ - reg_dt = gpiod_get_value(vbus_gpio); - if (reg_dt == 0) { - udc->linux_suspended = 0; - - _nbu2ss_reset_controller(udc); - dev_info(udc->dev, " ----- VBUS OFF\n"); - - if (udc->vbus_active == 1) { - /* VBUS OFF */ - udc->vbus_active = 0; - if (udc->usb_suspended) { - udc->usb_suspended = 0; - /* _nbu2ss_reset_controller(udc); */ - } - udc->devstate = USB_STATE_NOTATTACHED; - - _nbu2ss_quiesce(udc); - if (udc->driver) { - spin_unlock(&udc->lock); - udc->driver->disconnect(&udc->gadget); - spin_lock(&udc->lock); - } - - _nbu2ss_disable_controller(udc); - } - } else { - mdelay(5); /* wait (5ms) */ - reg_dt = gpiod_get_value(vbus_gpio); - if (reg_dt == 0) - return; - - dev_info(udc->dev, " ----- VBUS ON\n"); - - if (udc->linux_suspended) - return; - - if (udc->vbus_active == 0) { - /* VBUS ON */ - udc->vbus_active = 1; - udc->devstate = USB_STATE_POWERED; - - nret = _nbu2ss_enable_controller(udc); - if (nret < 0) { - _nbu2ss_disable_controller(udc); - udc->vbus_active = 0; - return; - } - - _nbu2ss_pullup(udc, 1); - -#ifdef UDC_DEBUG_DUMP - _nbu2ss_dump_register(udc); -#endif /* UDC_DEBUG_DUMP */ - - } else { - if (udc->devstate == USB_STATE_POWERED) - _nbu2ss_pullup(udc, 1); - } - } -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_int_bus_reset(struct nbu2ss_udc *udc) -{ - udc->devstate = USB_STATE_DEFAULT; - udc->remote_wakeup = 0; - - _nbu2ss_quiesce(udc); - - udc->ep0state = EP0_IDLE; -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_int_usb_resume(struct nbu2ss_udc *udc) -{ - if (udc->usb_suspended == 1) { - udc->usb_suspended = 0; - if (udc->driver && udc->driver->resume) { - spin_unlock(&udc->lock); - udc->driver->resume(&udc->gadget); - spin_lock(&udc->lock); - } - } -} - -/*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_int_usb_suspend(struct nbu2ss_udc *udc) -{ - u32 reg_dt; - - if (udc->usb_suspended == 0) { - reg_dt = gpiod_get_value(vbus_gpio); - - if (reg_dt == 0) - return; - - udc->usb_suspended = 1; - if (udc->driver && udc->driver->suspend) { - spin_unlock(&udc->lock); - udc->driver->suspend(&udc->gadget); - spin_lock(&udc->lock); - } - - _nbu2ss_bitset(&udc->p_regs->USB_CONTROL, SUSPEND); - } -} - -/*-------------------------------------------------------------------------*/ -/* VBUS (GPIO153) Interrupt */ -static irqreturn_t _nbu2ss_vbus_irq(int irq, void *_udc) -{ - struct nbu2ss_udc *udc = (struct nbu2ss_udc *)_udc; - - spin_lock(&udc->lock); - _nbu2ss_check_vbus(udc); - spin_unlock(&udc->lock); - - return IRQ_HANDLED; -} - -/*-------------------------------------------------------------------------*/ -/* Interrupt (udc) */ -static irqreturn_t _nbu2ss_udc_irq(int irq, void *_udc) -{ - u8 suspend_flag = 0; - u32 status; - u32 epnum, int_bit; - - struct nbu2ss_udc *udc = (struct nbu2ss_udc *)_udc; - struct fc_regs __iomem *preg = udc->p_regs; - - if (gpiod_get_value(vbus_gpio) == 0) { - _nbu2ss_writel(&preg->USB_INT_STA, ~USB_INT_STA_RW); - _nbu2ss_writel(&preg->USB_INT_ENA, 0); - return IRQ_HANDLED; - } - - spin_lock(&udc->lock); - - for (;;) { - if (gpiod_get_value(vbus_gpio) == 0) { - _nbu2ss_writel(&preg->USB_INT_STA, ~USB_INT_STA_RW); - _nbu2ss_writel(&preg->USB_INT_ENA, 0); - status = 0; - } else { - status = _nbu2ss_readl(&preg->USB_INT_STA); - } - - if (status == 0) - break; - - _nbu2ss_writel(&preg->USB_INT_STA, ~(status & USB_INT_STA_RW)); - - if (status & USB_RST_INT) { - /* USB Reset */ - _nbu2ss_int_bus_reset(udc); - } - - if (status & RSUM_INT) { - /* Resume */ - _nbu2ss_int_usb_resume(udc); - } - - if (status & SPND_INT) { - /* Suspend */ - suspend_flag = 1; - } - - if (status & EPN_INT) { - /* EP INT */ - int_bit = status >> 8; - - for (epnum = 0; epnum < NUM_ENDPOINTS; epnum++) { - if (0x01 & int_bit) - _nbu2ss_ep_int(udc, epnum); - - int_bit >>= 1; - - if (int_bit == 0) - break; - } - } - } - - if (suspend_flag) - _nbu2ss_int_usb_suspend(udc); - - spin_unlock(&udc->lock); - - return IRQ_HANDLED; -} - -/*-------------------------------------------------------------------------*/ -/* usb_ep_ops */ -static int nbu2ss_ep_enable(struct usb_ep *_ep, - const struct usb_endpoint_descriptor *desc) -{ - u8 ep_type; - unsigned long flags; - - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - - if (!_ep || !desc) { - pr_err(" *** %s, bad param\n", __func__); - return -EINVAL; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - if (!ep->udc) { - pr_err(" *** %s, ep == NULL !!\n", __func__); - return -EINVAL; - } - - ep_type = usb_endpoint_type(desc); - if ((ep_type == USB_ENDPOINT_XFER_CONTROL) || - (ep_type == USB_ENDPOINT_XFER_ISOC)) { - pr_err(" *** %s, bat bmAttributes\n", __func__); - return -EINVAL; - } - - udc = ep->udc; - if (udc->vbus_active == 0) - return -ESHUTDOWN; - - if ((!udc->driver) || (udc->gadget.speed == USB_SPEED_UNKNOWN)) { - dev_err(ep->udc->dev, " *** %s, udc !!\n", __func__); - return -ESHUTDOWN; - } - - spin_lock_irqsave(&udc->lock, flags); - - ep->desc = desc; - ep->epnum = usb_endpoint_num(desc); - ep->direct = desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK; - ep->ep_type = ep_type; - ep->wedged = 0; - ep->halted = false; - ep->stalled = false; - - ep->ep.maxpacket = le16_to_cpu(desc->wMaxPacketSize); - - /* DMA setting */ - _nbu2ss_ep_dma_init(udc, ep); - - /* Endpoint setting */ - _nbu2ss_ep_init(udc, ep); - - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_disable(struct usb_ep *_ep) -{ - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - unsigned long flags; - - if (!_ep) { - pr_err(" *** %s, bad param\n", __func__); - return -EINVAL; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - if (!ep->udc) { - pr_err("udc: *** %s, ep == NULL !!\n", __func__); - return -EINVAL; - } - - udc = ep->udc; - if (udc->vbus_active == 0) - return -ESHUTDOWN; - - spin_lock_irqsave(&udc->lock, flags); - _nbu2ss_nuke(udc, ep, -EINPROGRESS); /* dequeue request */ - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static struct usb_request *nbu2ss_ep_alloc_request(struct usb_ep *ep, - gfp_t gfp_flags) -{ - struct nbu2ss_req *req; - - req = kzalloc(sizeof(*req), gfp_flags); - if (!req) - return NULL; - -#ifdef USE_DMA - req->req.dma = DMA_ADDR_INVALID; -#endif - INIT_LIST_HEAD(&req->queue); - - return &req->req; -} - -/*-------------------------------------------------------------------------*/ -static void nbu2ss_ep_free_request(struct usb_ep *_ep, - struct usb_request *_req) -{ - struct nbu2ss_req *req; - - if (_req) { - req = container_of(_req, struct nbu2ss_req, req); - - kfree(req); - } -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_queue(struct usb_ep *_ep, - struct usb_request *_req, gfp_t gfp_flags) -{ - struct nbu2ss_req *req; - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - unsigned long flags; - bool bflag; - int result = -EINVAL; - - /* catch various bogus parameters */ - if (!_ep || !_req) { - if (!_ep) - pr_err("udc: %s --- _ep == NULL\n", __func__); - - if (!_req) - pr_err("udc: %s --- _req == NULL\n", __func__); - - return -EINVAL; - } - - req = container_of(_req, struct nbu2ss_req, req); - if (unlikely(!_req->complete || - !_req->buf || - !list_empty(&req->queue))) { - if (!_req->complete) - pr_err("udc: %s --- !_req->complete\n", __func__); - - if (!_req->buf) - pr_err("udc:%s --- !_req->buf\n", __func__); - - if (!list_empty(&req->queue)) - pr_err("%s --- !list_empty(&req->queue)\n", __func__); - - return -EINVAL; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - udc = ep->udc; - - if (udc->vbus_active == 0) { - dev_info(udc->dev, "Can't ep_queue (VBUS OFF)\n"); - return -ESHUTDOWN; - } - - if (unlikely(!udc->driver)) { - dev_err(udc->dev, "%s, bogus device state %p\n", __func__, - udc->driver); - return -ESHUTDOWN; - } - - spin_lock_irqsave(&udc->lock, flags); - -#ifdef USE_DMA - if ((uintptr_t)req->req.buf & 0x3) - req->unaligned = true; - else - req->unaligned = false; - - if (req->unaligned) { - 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, - req->req.length); - } - } - - if ((ep->epnum > 0) && (ep->direct == USB_DIR_OUT) && - (req->req.dma != 0)) - _nbu2ss_dma_map_single(udc, ep, req, USB_DIR_OUT); -#endif - - _req->status = -EINPROGRESS; - _req->actual = 0; - - bflag = list_empty(&ep->queue); - list_add_tail(&req->queue, &ep->queue); - - if (bflag && !ep->stalled) { - result = _nbu2ss_start_transfer(udc, ep, req, false); - if (result < 0) { - dev_err(udc->dev, " *** %s, result = %d\n", __func__, - result); - list_del(&req->queue); - } else if ((ep->epnum > 0) && (ep->direct == USB_DIR_OUT)) { -#ifdef USE_DMA - if (req->req.length < 4 && - req->req.length == req->req.actual) -#else - if (req->req.length == req->req.actual) -#endif - _nbu2ss_ep_done(ep, req, result); - } - } - - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) -{ - struct nbu2ss_req *req; - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - unsigned long flags; - - /* catch various bogus parameters */ - if (!_ep || !_req) { - /* pr_err("%s, bad param(1)\n", __func__); */ - return -EINVAL; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - - udc = ep->udc; - if (!udc) - return -EINVAL; - - spin_lock_irqsave(&udc->lock, flags); - - /* make sure it's actually queued on this endpoint */ - list_for_each_entry(req, &ep->queue, queue) { - if (&req->req == _req) { - _nbu2ss_ep_done(ep, req, -ECONNRESET); - spin_unlock_irqrestore(&udc->lock, flags); - return 0; - } - } - - spin_unlock_irqrestore(&udc->lock, flags); - - pr_debug("%s no queue(EINVAL)\n", __func__); - - return -EINVAL; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_set_halt(struct usb_ep *_ep, int value) -{ - u8 ep_adrs; - unsigned long flags; - - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - - if (!_ep) { - pr_err("%s, bad param\n", __func__); - return -EINVAL; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - - udc = ep->udc; - if (!udc) { - dev_err(ep->udc->dev, " *** %s, bad udc\n", __func__); - return -EINVAL; - } - - spin_lock_irqsave(&udc->lock, flags); - - ep_adrs = ep->epnum | ep->direct; - if (value == 0) { - _nbu2ss_set_endpoint_stall(udc, ep_adrs, value); - ep->stalled = false; - } else { - if (list_empty(&ep->queue)) - _nbu2ss_epn_set_stall(udc, ep); - else - ep->stalled = true; - } - - if (value == 0) - ep->wedged = 0; - - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -static int nbu2ss_ep_set_wedge(struct usb_ep *_ep) -{ - return nbu2ss_ep_set_halt(_ep, 1); -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_fifo_status(struct usb_ep *_ep) -{ - u32 data; - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - unsigned long flags; - struct fc_regs __iomem *preg; - - if (!_ep) { - pr_err("%s, bad param\n", __func__); - return -EINVAL; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - - udc = ep->udc; - if (!udc) { - dev_err(ep->udc->dev, "%s, bad udc\n", __func__); - return -EINVAL; - } - - preg = udc->p_regs; - - data = gpiod_get_value(vbus_gpio); - if (data == 0) - return -EINVAL; - - spin_lock_irqsave(&udc->lock, flags); - - if (ep->epnum == 0) { - data = _nbu2ss_readl(&preg->EP0_LENGTH) & EP0_LDATA; - - } else { - data = _nbu2ss_readl(&preg->EP_REGS[ep->epnum - 1].EP_LEN_DCNT) - & EPN_LDATA; - } - - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static void nbu2ss_ep_fifo_flush(struct usb_ep *_ep) -{ - u32 data; - struct nbu2ss_ep *ep; - struct nbu2ss_udc *udc; - unsigned long flags; - - if (!_ep) { - pr_err("udc: %s, bad param\n", __func__); - return; - } - - ep = container_of(_ep, struct nbu2ss_ep, ep); - - udc = ep->udc; - if (!udc) { - dev_err(ep->udc->dev, "%s, bad udc\n", __func__); - return; - } - - data = gpiod_get_value(vbus_gpio); - if (data == 0) - return; - - spin_lock_irqsave(&udc->lock, flags); - _nbu2ss_fifo_flush(udc, ep); - spin_unlock_irqrestore(&udc->lock, flags); -} - -/*-------------------------------------------------------------------------*/ -static const struct usb_ep_ops nbu2ss_ep_ops = { - .enable = nbu2ss_ep_enable, - .disable = nbu2ss_ep_disable, - - .alloc_request = nbu2ss_ep_alloc_request, - .free_request = nbu2ss_ep_free_request, - - .queue = nbu2ss_ep_queue, - .dequeue = nbu2ss_ep_dequeue, - - .set_halt = nbu2ss_ep_set_halt, - .set_wedge = nbu2ss_ep_set_wedge, - - .fifo_status = nbu2ss_ep_fifo_status, - .fifo_flush = nbu2ss_ep_fifo_flush, -}; - -/*-------------------------------------------------------------------------*/ -/* usb_gadget_ops */ - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_get_frame(struct usb_gadget *pgadget) -{ - u32 data; - struct nbu2ss_udc *udc; - - if (!pgadget) { - pr_err("udc: %s, bad param\n", __func__); - return -EINVAL; - } - - udc = container_of(pgadget, struct nbu2ss_udc, gadget); - data = gpiod_get_value(vbus_gpio); - if (data == 0) - return -EINVAL; - - return _nbu2ss_readl(&udc->p_regs->USB_ADDRESS) & FRAME; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_wakeup(struct usb_gadget *pgadget) -{ - int i; - u32 data; - - struct nbu2ss_udc *udc; - - if (!pgadget) { - pr_err("%s, bad param\n", __func__); - return -EINVAL; - } - - udc = container_of(pgadget, struct nbu2ss_udc, gadget); - - data = gpiod_get_value(vbus_gpio); - if (data == 0) { - dev_warn(&pgadget->dev, "VBUS LEVEL = %d\n", data); - return -EINVAL; - } - - _nbu2ss_bitset(&udc->p_regs->EPCTR, PLL_RESUME); - - for (i = 0; i < EPC_PLL_LOCK_COUNT; i++) { - data = _nbu2ss_readl(&udc->p_regs->EPCTR); - - if (data & PLL_LOCK) - break; - } - - _nbu2ss_bitclr(&udc->p_regs->EPCTR, PLL_RESUME); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_set_selfpowered(struct usb_gadget *pgadget, - int is_selfpowered) -{ - struct nbu2ss_udc *udc; - unsigned long flags; - - if (!pgadget) { - pr_err("%s, bad param\n", __func__); - return -EINVAL; - } - - udc = container_of(pgadget, struct nbu2ss_udc, gadget); - - spin_lock_irqsave(&udc->lock, flags); - pgadget->is_selfpowered = (is_selfpowered != 0); - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_vbus_session(struct usb_gadget *pgadget, int is_active) -{ - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_vbus_draw(struct usb_gadget *pgadget, unsigned int mA) -{ - struct nbu2ss_udc *udc; - unsigned long flags; - - if (!pgadget) { - pr_err("%s, bad param\n", __func__); - return -EINVAL; - } - - udc = container_of(pgadget, struct nbu2ss_udc, gadget); - - spin_lock_irqsave(&udc->lock, flags); - udc->mA = mA; - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_pullup(struct usb_gadget *pgadget, int is_on) -{ - struct nbu2ss_udc *udc; - unsigned long flags; - - if (!pgadget) { - pr_err("%s, bad param\n", __func__); - return -EINVAL; - } - - udc = container_of(pgadget, struct nbu2ss_udc, gadget); - - if (!udc->driver) { - pr_warn("%s, Not Regist Driver\n", __func__); - return -EINVAL; - } - - if (udc->vbus_active == 0) - return -ESHUTDOWN; - - spin_lock_irqsave(&udc->lock, flags); - _nbu2ss_pullup(udc, is_on); - spin_unlock_irqrestore(&udc->lock, flags); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_ioctl(struct usb_gadget *pgadget, - unsigned int code, unsigned long param) -{ - return 0; -} - -static const struct usb_gadget_ops nbu2ss_gadget_ops = { - .get_frame = nbu2ss_gad_get_frame, - .wakeup = nbu2ss_gad_wakeup, - .set_selfpowered = nbu2ss_gad_set_selfpowered, - .vbus_session = nbu2ss_gad_vbus_session, - .vbus_draw = nbu2ss_gad_vbus_draw, - .pullup = nbu2ss_gad_pullup, - .ioctl = nbu2ss_gad_ioctl, -}; - -static const struct { - const char *name; - const struct usb_ep_caps caps; -} ep_info[NUM_ENDPOINTS] = { -#define EP_INFO(_name, _caps) \ - { \ - .name = _name, \ - .caps = _caps, \ - } - - EP_INFO("ep0", - USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep1-bulk", - USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep2-bulk", - USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep3in-int", - USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), - EP_INFO("ep4-iso", - USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep5-iso", - USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep6-bulk", - USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep7-bulk", - USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), - EP_INFO("ep8in-int", - USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), - EP_INFO("ep9-iso", - USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), - EP_INFO("epa-iso", - USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, USB_EP_CAPS_DIR_ALL)), - EP_INFO("epb-bulk", - USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), - EP_INFO("epc-bulk", - USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, USB_EP_CAPS_DIR_ALL)), - EP_INFO("epdin-int", - USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, USB_EP_CAPS_DIR_IN)), - -#undef EP_INFO -}; - -/*-------------------------------------------------------------------------*/ -static void nbu2ss_drv_ep_init(struct nbu2ss_udc *udc) -{ - int i; - - INIT_LIST_HEAD(&udc->gadget.ep_list); - udc->gadget.ep0 = &udc->ep[0].ep; - - for (i = 0; i < NUM_ENDPOINTS; i++) { - struct nbu2ss_ep *ep = &udc->ep[i]; - - ep->udc = udc; - ep->desc = NULL; - - ep->ep.driver_data = NULL; - ep->ep.name = ep_info[i].name; - ep->ep.caps = ep_info[i].caps; - ep->ep.ops = &nbu2ss_ep_ops; - - usb_ep_set_maxpacket_limit(&ep->ep, - i == 0 ? EP0_PACKETSIZE - : EP_PACKETSIZE); - - list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); - INIT_LIST_HEAD(&ep->queue); - } - - list_del_init(&udc->ep[0].ep.ep_list); -} - -/*-------------------------------------------------------------------------*/ -/* platform_driver */ -static int nbu2ss_drv_contest_init(struct platform_device *pdev, - struct nbu2ss_udc *udc) -{ - spin_lock_init(&udc->lock); - udc->dev = &pdev->dev; - - udc->gadget.is_selfpowered = 1; - udc->devstate = USB_STATE_NOTATTACHED; - udc->pdev = pdev; - udc->mA = 0; - - udc->pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); - - /* init Endpoint */ - nbu2ss_drv_ep_init(udc); - - /* init Gadget */ - udc->gadget.ops = &nbu2ss_gadget_ops; - udc->gadget.ep0 = &udc->ep[0].ep; - udc->gadget.speed = USB_SPEED_UNKNOWN; - udc->gadget.name = driver_name; - /* udc->gadget.is_dualspeed = 1; */ - - device_initialize(&udc->gadget.dev); - - dev_set_name(&udc->gadget.dev, "gadget"); - udc->gadget.dev.parent = &pdev->dev; - udc->gadget.dev.dma_mask = pdev->dev.dma_mask; - - return 0; -} - -/* - * probe - binds to the platform device - */ -static int nbu2ss_drv_probe(struct platform_device *pdev) -{ - int status; - struct nbu2ss_udc *udc; - int irq; - void __iomem *mmio_base; - - udc = &udc_controller; - memset(udc, 0, sizeof(struct nbu2ss_udc)); - - platform_set_drvdata(pdev, udc); - - /* require I/O memory and IRQ to be provided as resources */ - mmio_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(mmio_base)) - return PTR_ERR(mmio_base); - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - status = devm_request_irq(&pdev->dev, irq, _nbu2ss_udc_irq, - 0, driver_name, udc); - - /* IO Memory */ - udc->p_regs = (struct fc_regs __iomem *)mmio_base; - - /* USB Function Controller Interrupt */ - if (status != 0) { - dev_err(udc->dev, "request_irq(USB_UDC_IRQ_1) failed\n"); - return status; - } - - /* Driver Initialization */ - status = nbu2ss_drv_contest_init(pdev, udc); - if (status < 0) { - /* Error */ - return status; - } - - /* VBUS Interrupt */ - vbus_irq = gpiod_to_irq(vbus_gpio); - irq_set_irq_type(vbus_irq, IRQ_TYPE_EDGE_BOTH); - status = request_irq(vbus_irq, - _nbu2ss_vbus_irq, IRQF_SHARED, driver_name, udc); - - if (status != 0) { - dev_err(udc->dev, "request_irq(vbus_irq) failed\n"); - return status; - } - - return status; -} - -/*-------------------------------------------------------------------------*/ -static void nbu2ss_drv_shutdown(struct platform_device *pdev) -{ - struct nbu2ss_udc *udc; - - udc = platform_get_drvdata(pdev); - if (!udc) - return; - - _nbu2ss_disable_controller(udc); -} - -/*-------------------------------------------------------------------------*/ -static void nbu2ss_drv_remove(struct platform_device *pdev) -{ - struct nbu2ss_udc *udc; - struct nbu2ss_ep *ep; - int i; - - udc = &udc_controller; - - for (i = 0; i < NUM_ENDPOINTS; i++) { - ep = &udc->ep[i]; - if (ep->virt_buf) - dma_free_coherent(udc->dev, PAGE_SIZE, (void *)ep->virt_buf, - ep->phys_buf); - } - - /* Interrupt Handler - Release */ - free_irq(vbus_irq, udc); -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_drv_suspend(struct platform_device *pdev, pm_message_t state) -{ - struct nbu2ss_udc *udc; - - udc = platform_get_drvdata(pdev); - if (!udc) - return 0; - - if (udc->vbus_active) { - udc->vbus_active = 0; - udc->devstate = USB_STATE_NOTATTACHED; - udc->linux_suspended = 1; - - if (udc->usb_suspended) { - udc->usb_suspended = 0; - _nbu2ss_reset_controller(udc); - } - - _nbu2ss_quiesce(udc); - } - _nbu2ss_disable_controller(udc); - - return 0; -} - -/*-------------------------------------------------------------------------*/ -static int nbu2ss_drv_resume(struct platform_device *pdev) -{ - u32 data; - struct nbu2ss_udc *udc; - - udc = platform_get_drvdata(pdev); - if (!udc) - return 0; - - data = gpiod_get_value(vbus_gpio); - if (data) { - udc->vbus_active = 1; - udc->devstate = USB_STATE_POWERED; - _nbu2ss_enable_controller(udc); - _nbu2ss_pullup(udc, 1); - } - - udc->linux_suspended = 0; - - return 0; -} - -static struct platform_driver udc_driver = { - .probe = nbu2ss_drv_probe, - .shutdown = nbu2ss_drv_shutdown, - .remove_new = nbu2ss_drv_remove, - .suspend = nbu2ss_drv_suspend, - .resume = nbu2ss_drv_resume, - .driver = { - .name = driver_name, - }, -}; - -module_platform_driver(udc_driver); - -MODULE_DESCRIPTION(DRIVER_DESC); -MODULE_AUTHOR("Renesas Electronics Corporation"); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h deleted file mode 100644 index c9e37a1b8139..000000000000 --- a/drivers/staging/emxx_udc/emxx_udc.h +++ /dev/null @@ -1,554 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * EMXX FCD (Function Controller Driver) for USB. - * - * Copyright (C) 2010 Renesas Electronics Corporation - */ - -#ifndef _LINUX_EMXX_H -#define _LINUX_EMXX_H - -/*---------------------------------------------------------------------------*/ - -/*----------------- Default define */ -#define USE_DMA 1 -#define USE_SUSPEND_WAIT 1 - -/*------------ Board dependence(Resource) */ -#define VBUS_VALUE GPIO_VBUS - -/* below hacked up for staging integration */ -#define GPIO_VBUS 0 /* GPIO_P153 on KZM9D */ -#define INT_VBUS 0 /* IRQ for GPIO_P153 */ - -/*------------ Board dependence(Wait) */ - -/* CHATTERING wait time ms */ -#define VBUS_CHATTERING_MDELAY 1 -/* DMA Abort wait time ms */ -#define DMA_DISABLE_TIME 10 - -/*------------ Controller dependence */ -#define NUM_ENDPOINTS 14 /* Endpoint */ -#define REG_EP_NUM 15 /* Endpoint Register */ -#define DMA_MAX_COUNT 256 /* DMA Block */ - -#define EPC_RST_DISABLE_TIME 1 /* 1 usec */ -#define EPC_DIRPD_DISABLE_TIME 1 /* 1 msec */ -#define EPC_PLL_LOCK_COUNT 1000 /* 1000 */ -#define IN_DATA_EMPTY_COUNT 1000 /* 1000 */ - -#define CHATGER_TIME 700 /* 700msec */ -#define USB_SUSPEND_TIME 2000 /* 2 sec */ - -/* U2F FLAG */ -#define U2F_ENABLE 1 -#define U2F_DISABLE 0 - -#define TEST_FORCE_ENABLE (BIT(18) | BIT(16)) - -#define INT_SEL BIT(10) -#define CONSTFS BIT(9) -#define SOF_RCV BIT(8) -#define RSUM_IN BIT(7) -#define SUSPEND BIT(6) -#define CONF BIT(5) -#define DEFAULT BIT(4) -#define CONNECTB BIT(3) -#define PUE2 BIT(2) - -#define MAX_TEST_MODE_NUM 0x05 -#define TEST_MODE_SHIFT 16 - -/*------- (0x0004) USB Status Register */ -#define SPEED_MODE BIT(6) -#define HIGH_SPEED BIT(6) - -#define CONF BIT(5) -#define DEFAULT BIT(4) -#define USB_RST BIT(3) -#define SPND_OUT BIT(2) -#define RSUM_OUT BIT(1) - -/*------- (0x0008) USB Address Register */ -#define USB_ADDR 0x007F0000 -#define SOF_STATUS BIT(15) -#define UFRAME (BIT(14) | BIT(13) | BIT(12)) -#define FRAME 0x000007FF - -#define USB_ADRS_SHIFT 16 - -/*------- (0x000C) UTMI Characteristic 1 Register */ -#define SQUSET (BIT(7) | BIT(6) | BIT(5) | BIT(4)) - -#define USB_SQUSET (BIT(6) | BIT(5) | BIT(4)) - -/*------- (0x0010) TEST Control Register */ -#define FORCEHS BIT(2) -#define CS_TESTMODEEN BIT(1) -#define LOOPBACK BIT(0) - -/*------- (0x0018) Setup Data 0 Register */ -/*------- (0x001C) Setup Data 1 Register */ - -/*------- (0x0020) USB Interrupt Status Register */ -#define EPN_INT 0x00FFFF00 -#define EP15_INT BIT(23) -#define EP14_INT BIT(22) -#define EP13_INT BIT(21) -#define EP12_INT BIT(20) -#define EP11_INT BIT(19) -#define EP10_INT BIT(18) -#define EP9_INT BIT(17) -#define EP8_INT BIT(16) -#define EP7_INT BIT(15) -#define EP6_INT BIT(14) -#define EP5_INT BIT(13) -#define EP4_INT BIT(12) -#define EP3_INT BIT(11) -#define EP2_INT BIT(10) -#define EP1_INT BIT(9) -#define EP0_INT BIT(8) -#define SPEED_MODE_INT BIT(6) -#define SOF_ERROR_INT BIT(5) -#define SOF_INT BIT(4) -#define USB_RST_INT BIT(3) -#define SPND_INT BIT(2) -#define RSUM_INT BIT(1) - -#define USB_INT_STA_RW 0x7E - -/*------- (0x0024) USB Interrupt Enable Register */ -#define EP15_0_EN 0x00FFFF00 -#define EP15_EN BIT(23) -#define EP14_EN BIT(22) -#define EP13_EN BIT(21) -#define EP12_EN BIT(20) -#define EP11_EN BIT(19) -#define EP10_EN BIT(18) -#define EP9_EN BIT(17) -#define EP8_EN BIT(16) -#define EP7_EN BIT(15) -#define EP6_EN BIT(14) -#define EP5_EN BIT(13) -#define EP4_EN BIT(12) -#define EP3_EN BIT(11) -#define EP2_EN BIT(10) -#define EP1_EN BIT(9) -#define EP0_EN BIT(8) -#define SPEED_MODE_EN BIT(6) -#define SOF_ERROR_EN BIT(5) -#define SOF_EN BIT(4) -#define USB_RST_EN BIT(3) -#define SPND_EN BIT(2) -#define RSUM_EN BIT(1) - -#define USB_INT_EN_BIT \ - (EP0_EN | SPEED_MODE_EN | USB_RST_EN | SPND_EN | RSUM_EN) - -/*------- (0x0028) EP0 Control Register */ -#define EP0_STGSEL BIT(18) -#define EP0_OVERSEL BIT(17) -#define EP0_AUTO BIT(16) -#define EP0_PIDCLR BIT(9) -#define EP0_BCLR BIT(8) -#define EP0_DEND BIT(7) -#define EP0_DW (BIT(6) | BIT(5)) -#define EP0_DW4 0 -#define EP0_DW3 (BIT(6) | BIT(5)) -#define EP0_DW2 BIT(6) -#define EP0_DW1 BIT(5) - -#define EP0_INAK_EN BIT(4) -#define EP0_PERR_NAK_CLR BIT(3) -#define EP0_STL BIT(2) -#define EP0_INAK BIT(1) -#define EP0_ONAK BIT(0) - -/*------- (0x002C) EP0 Status Register */ -#define EP0_PID BIT(18) -#define EP0_PERR_NAK BIT(17) -#define EP0_PERR_NAK_INT BIT(16) -#define EP0_OUT_NAK_INT BIT(15) -#define EP0_OUT_NULL BIT(14) -#define EP0_OUT_FULL BIT(13) -#define EP0_OUT_EMPTY BIT(12) -#define EP0_IN_NAK_INT BIT(11) -#define EP0_IN_DATA BIT(10) -#define EP0_IN_FULL BIT(9) -#define EP0_IN_EMPTY BIT(8) -#define EP0_OUT_NULL_INT BIT(7) -#define EP0_OUT_OR_INT BIT(6) -#define EP0_OUT_INT BIT(5) -#define EP0_IN_INT BIT(4) -#define EP0_STALL_INT BIT(3) -#define STG_END_INT BIT(2) -#define STG_START_INT BIT(1) -#define SETUP_INT BIT(0) - -#define EP0_STATUS_RW_BIT (BIT(16) | BIT(15) | BIT(11) | 0xFF) - -/*------- (0x0030) EP0 Interrupt Enable Register */ -#define EP0_PERR_NAK_EN BIT(16) -#define EP0_OUT_NAK_EN BIT(15) - -#define EP0_IN_NAK_EN BIT(11) - -#define EP0_OUT_NULL_EN BIT(7) -#define EP0_OUT_OR_EN BIT(6) -#define EP0_OUT_EN BIT(5) -#define EP0_IN_EN BIT(4) -#define EP0_STALL_EN BIT(3) -#define STG_END_EN BIT(2) -#define STG_START_EN BIT(1) -#define SETUP_EN BIT(0) - -#define EP0_INT_EN_BIT \ - (EP0_OUT_OR_EN | EP0_OUT_EN | EP0_IN_EN | STG_END_EN | SETUP_EN) - -/*------- (0x0034) EP0 Length Register */ -#define EP0_LDATA 0x0000007F - -/*------- (0x0038) EP0 Read Register */ -/*------- (0x003C) EP0 Write Register */ - -/*------- (0x0040:) EPN Control Register */ -#define EPN_EN BIT(31) -#define EPN_BUF_TYPE BIT(30) -#define EPN_BUF_SINGLE BIT(30) - -#define EPN_DIR0 BIT(26) -#define EPN_MODE (BIT(25) | BIT(24)) -#define EPN_BULK 0 -#define EPN_INTERRUPT BIT(24) -#define EPN_ISO BIT(25) - -#define EPN_OVERSEL BIT(17) -#define EPN_AUTO BIT(16) - -#define EPN_IPIDCLR BIT(11) -#define EPN_OPIDCLR BIT(10) -#define EPN_BCLR BIT(9) -#define EPN_CBCLR BIT(8) -#define EPN_DEND BIT(7) -#define EPN_DW (BIT(6) | BIT(5)) -#define EPN_DW4 0 -#define EPN_DW3 (BIT(6) | BIT(5)) -#define EPN_DW2 BIT(6) -#define EPN_DW1 BIT(5) - -#define EPN_OSTL_EN BIT(4) -#define EPN_ISTL BIT(3) -#define EPN_OSTL BIT(2) - -#define EPN_ONAK BIT(0) - -/*------- (0x0044:) EPN Status Register */ -#define EPN_ISO_PIDERR BIT(29) /* R */ -#define EPN_OPID BIT(28) /* R */ -#define EPN_OUT_NOTKN BIT(27) /* R */ -#define EPN_ISO_OR BIT(26) /* R */ - -#define EPN_ISO_CRC BIT(24) /* R */ -#define EPN_OUT_END_INT BIT(23) /* RW */ -#define EPN_OUT_OR_INT BIT(22) /* RW */ -#define EPN_OUT_NAK_ERR_INT BIT(21) /* RW */ -#define EPN_OUT_STALL_INT BIT(20) /* RW */ -#define EPN_OUT_INT BIT(19) /* RW */ -#define EPN_OUT_NULL_INT BIT(18) /* RW */ -#define EPN_OUT_FULL BIT(17) /* R */ -#define EPN_OUT_EMPTY BIT(16) /* R */ - -#define EPN_IPID BIT(10) /* R */ -#define EPN_IN_NOTKN BIT(9) /* R */ -#define EPN_ISO_UR BIT(8) /* R */ -#define EPN_IN_END_INT BIT(7) /* RW */ - -#define EPN_IN_NAK_ERR_INT BIT(5) /* RW */ -#define EPN_IN_STALL_INT BIT(4) /* RW */ -#define EPN_IN_INT BIT(3) /* RW */ -#define EPN_IN_DATA BIT(2) /* R */ -#define EPN_IN_FULL BIT(1) /* R */ -#define EPN_IN_EMPTY BIT(0) /* R */ - -#define EPN_INT_EN \ - (EPN_OUT_END_INT | EPN_OUT_INT | EPN_IN_END_INT | EPN_IN_INT) - -/*------- (0x0048:) EPN Interrupt Enable Register */ -#define EPN_OUT_END_EN BIT(23) /* RW */ -#define EPN_OUT_OR_EN BIT(22) /* RW */ -#define EPN_OUT_NAK_ERR_EN BIT(21) /* RW */ -#define EPN_OUT_STALL_EN BIT(20) /* RW */ -#define EPN_OUT_EN BIT(19) /* RW */ -#define EPN_OUT_NULL_EN BIT(18) /* RW */ - -#define EPN_IN_END_EN BIT(7) /* RW */ - -#define EPN_IN_NAK_ERR_EN BIT(5) /* RW */ -#define EPN_IN_STALL_EN BIT(4) /* RW */ -#define EPN_IN_EN BIT(3) /* RW */ - -/*------- (0x004C:) EPN Interrupt Enable Register */ -#define EPN_STOP_MODE BIT(11) -#define EPN_DEND_SET BIT(10) -#define EPN_BURST_SET BIT(9) -#define EPN_STOP_SET BIT(8) - -#define EPN_DMA_EN BIT(4) - -#define EPN_DMAMODE0 BIT(0) - -/*------- (0x0050:) EPN MaxPacket & BaseAddress Register */ -#define EPN_BASEAD 0x1FFF0000 -#define EPN_MPKT 0x000007FF - -/*------- (0x0054:) EPN Length & DMA Count Register */ -#define EPN_DMACNT 0x01FF0000 -#define EPN_LDATA 0x000007FF - -/*------- (0x0058:) EPN Read Register */ -/*------- (0x005C:) EPN Write Register */ - -/*------- (0x1000) AHBSCTR Register */ -#define WAIT_MODE BIT(0) - -/*------- (0x1004) AHBMCTR Register */ -#define ARBITER_CTR BIT(31) /* RW */ -#define MCYCLE_RST BIT(12) /* RW */ - -#define ENDIAN_CTR (BIT(9) | BIT(8)) /* RW */ -#define ENDIAN_BYTE_SWAP BIT(9) -#define ENDIAN_HALF_WORD_SWAP ENDIAN_CTR - -#define HBUSREQ_MODE BIT(5) /* RW */ -#define HTRANS_MODE BIT(4) /* RW */ - -#define WBURST_TYPE BIT(2) /* RW */ -#define BURST_TYPE (BIT(1) | BIT(0)) /* RW */ -#define BURST_MAX_16 0 -#define BURST_MAX_8 BIT(0) -#define BURST_MAX_4 BIT(1) -#define BURST_SINGLE BURST_TYPE - -/*------- (0x1008) AHBBINT Register */ -#define DMA_ENDINT 0xFFFE0000 /* RW */ - -#define AHB_VBUS_INT BIT(13) /* RW */ - -#define MBUS_ERRINT BIT(6) /* RW */ - -#define SBUS_ERRINT0 BIT(4) /* RW */ -#define ERR_MASTER 0x0000000F /* R */ - -/*------- (0x100C) AHBBINTEN Register */ -#define DMA_ENDINTEN 0xFFFE0000 /* RW */ - -#define VBUS_INTEN BIT(13) /* RW */ - -#define MBUS_ERRINTEN BIT(6) /* RW */ - -#define SBUS_ERRINT0EN BIT(4) /* RW */ - -/*------- (0x1010) EPCTR Register */ -#define DIRPD BIT(12) /* RW */ - -#define VBUS_LEVEL BIT(8) /* R */ - -#define PLL_RESUME BIT(5) /* RW */ -#define PLL_LOCK BIT(4) /* R */ - -#define EPC_RST BIT(0) /* RW */ - -/*------- (0x1014) USBF_EPTEST Register */ -#define LINESTATE (BIT(9) | BIT(8)) /* R */ -#define DM_LEVEL BIT(9) /* R */ -#define DP_LEVEL BIT(8) /* R */ - -#define PHY_TST BIT(1) /* RW */ -#define PHY_TSTCLK BIT(0) /* RW */ - -/*------- (0x1020) USBSSVER Register */ -#define AHBB_VER 0x00FF0000 /* R */ -#define EPC_VER 0x0000FF00 /* R */ -#define SS_VER 0x000000FF /* R */ - -/*------- (0x1024) USBSSCONF Register */ -#define EP_AVAILABLE 0xFFFF0000 /* R */ -#define DMA_AVAILABLE 0x0000FFFF /* R */ - -/*------- (0x1110:) EPNDCR1 Register */ -#define DCR1_EPN_DMACNT 0x00FF0000 /* RW */ - -#define DCR1_EPN_DIR0 BIT(1) /* RW */ -#define DCR1_EPN_REQEN BIT(0) /* RW */ - -/*------- (0x1114:) EPNDCR2 Register */ -#define DCR2_EPN_LMPKT 0x07FF0000 /* RW */ - -#define DCR2_EPN_MPKT 0x000007FF /* RW */ - -/*------- (0x1118:) EPNTADR Register */ -#define EPN_TADR 0xFFFFFFFF /* RW */ - -/*===========================================================================*/ -/* Struct */ -/*------- ep_regs */ -struct ep_regs { - u32 EP_CONTROL; /* EP Control */ - u32 EP_STATUS; /* EP Status */ - u32 EP_INT_ENA; /* EP Interrupt Enable */ - u32 EP_DMA_CTRL; /* EP DMA Control */ - u32 EP_PCKT_ADRS; /* EP Maxpacket & BaseAddress */ - u32 EP_LEN_DCNT; /* EP Length & DMA count */ - u32 EP_READ; /* EP Read */ - u32 EP_WRITE; /* EP Write */ -}; - -/*------- ep_dcr */ -struct ep_dcr { - u32 EP_DCR1; /* EP_DCR1 */ - u32 EP_DCR2; /* EP_DCR2 */ - u32 EP_TADR; /* EP_TADR */ - u32 Reserved; /* Reserved */ -}; - -/*------- Function Registers */ -struct fc_regs { - u32 USB_CONTROL; /* (0x0000) USB Control */ - u32 USB_STATUS; /* (0x0004) USB Status */ - u32 USB_ADDRESS; /* (0x0008) USB Address */ - u32 UTMI_CHARACTER_1; /* (0x000C) UTMI Setting */ - u32 TEST_CONTROL; /* (0x0010) TEST Control */ - u32 reserved_14; /* (0x0014) Reserved */ - u32 SETUP_DATA0; /* (0x0018) Setup Data0 */ - u32 SETUP_DATA1; /* (0x001C) Setup Data1 */ - u32 USB_INT_STA; /* (0x0020) USB Interrupt Status */ - u32 USB_INT_ENA; /* (0x0024) USB Interrupt Enable */ - u32 EP0_CONTROL; /* (0x0028) EP0 Control */ - u32 EP0_STATUS; /* (0x002C) EP0 Status */ - u32 EP0_INT_ENA; /* (0x0030) EP0 Interrupt Enable */ - u32 EP0_LENGTH; /* (0x0034) EP0 Length */ - u32 EP0_READ; /* (0x0038) EP0 Read */ - u32 EP0_WRITE; /* (0x003C) EP0 Write */ - - struct ep_regs EP_REGS[REG_EP_NUM]; /* Endpoint Register */ - - u8 reserved_220[0x1000 - 0x220]; /* (0x0220:0x0FFF) Reserved */ - - u32 AHBSCTR; /* (0x1000) AHBSCTR */ - u32 AHBMCTR; /* (0x1004) AHBMCTR */ - u32 AHBBINT; /* (0x1008) AHBBINT */ - u32 AHBBINTEN; /* (0x100C) AHBBINTEN */ - u32 EPCTR; /* (0x1010) EPCTR */ - u32 USBF_EPTEST; /* (0x1014) USBF_EPTEST */ - - u8 reserved_1018[0x20 - 0x18]; /* (0x1018:0x101F) Reserved */ - - u32 USBSSVER; /* (0x1020) USBSSVER */ - u32 USBSSCONF; /* (0x1024) USBSSCONF */ - - u8 reserved_1028[0x110 - 0x28]; /* (0x1028:0x110F) Reserved */ - - struct ep_dcr EP_DCR[REG_EP_NUM]; /* */ - - u8 reserved_1200[0x1000 - 0x200]; /* Reserved */ -} __aligned(32); - -#define EP0_PACKETSIZE 64 -#define EP_PACKETSIZE 1024 - -/* EPN RAM SIZE */ -#define D_RAM_SIZE_CTRL 64 - -/* EPN Bulk Endpoint Max Packet Size */ -#define D_FS_RAM_SIZE_BULK 64 -#define D_HS_RAM_SIZE_BULK 512 - -struct nbu2ss_udc; - -enum ep0_state { - EP0_IDLE, - EP0_IN_DATA_PHASE, - EP0_OUT_DATA_PHASE, - EP0_IN_STATUS_PHASE, - EP0_OUT_STATUS_PAHSE, - EP0_END_XFER, - EP0_SUSPEND, - EP0_STALL, -}; - -struct nbu2ss_req { - struct usb_request req; - struct list_head queue; - - u32 div_len; - bool dma_flag; - bool zero; - - bool unaligned; - - unsigned mapped:1; -}; - -struct nbu2ss_ep { - struct usb_ep ep; - struct list_head queue; - - struct nbu2ss_udc *udc; - - const struct usb_endpoint_descriptor *desc; - - u8 epnum; - u8 direct; - u8 ep_type; - - unsigned wedged:1; - unsigned halted:1; - unsigned stalled:1; - - u8 *virt_buf; - dma_addr_t phys_buf; -}; - -struct nbu2ss_udc { - struct usb_gadget gadget; - struct usb_gadget_driver *driver; - struct platform_device *pdev; - struct device *dev; - spinlock_t lock; /* Protects nbu2ss_udc structure fields */ - struct completion *pdone; - - enum ep0_state ep0state; - enum usb_device_state devstate; - struct usb_ctrlrequest ctrl; - struct nbu2ss_req ep0_req; - u8 ep0_buf[EP0_PACKETSIZE]; - - struct nbu2ss_ep ep[NUM_ENDPOINTS]; - - unsigned softconnect:1; - unsigned vbus_active:1; - unsigned linux_suspended:1; - unsigned linux_resume:1; - unsigned usb_suspended:1; - unsigned remote_wakeup:1; - unsigned udc_enabled:1; - - unsigned int mA; - - u32 curr_config; /* Current Configuration Number */ - - struct fc_regs __iomem *p_regs; -}; - -/* USB register access structure */ -union usb_reg_access { - struct { - unsigned char DATA[4]; - } byte; - unsigned int dw; -}; - -/*-------------------------------------------------------------------------*/ - -#endif /* _LINUX_EMXX_H */ -- cgit v1.2.3-58-ga151 From cc13301acc39f04a8de0a58e6915731829f5e436 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 22 Jan 2024 15:24:31 +0100 Subject: staging: board: Remove KZM9D board staging code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the EMMA Mobile USB Gadget staging driver removed, there is no longer any use for the EMEV2 KZM9D board staging code. Signed-off-by: Geert Uytterhoeven Acked-by: Wolfram Sang Acked-by: Niklas Söderlund Link: https://lore.kernel.org/r/f54fe56524e0266a3c705315f04870988912cfcf.1705932585.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/Makefile | 1 - drivers/staging/board/kzm9d.c | 26 -------------------------- 2 files changed, 27 deletions(-) delete mode 100644 drivers/staging/board/kzm9d.c (limited to 'drivers') diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile index ed7839752e12..5db091b5ca01 100644 --- a/drivers/staging/board/Makefile +++ b/drivers/staging/board/Makefile @@ -1,4 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := board.o -obj-$(CONFIG_ARCH_EMEV2) += kzm9d.o obj-$(CONFIG_ARCH_R8A7740) += armadillo800eva.o diff --git a/drivers/staging/board/kzm9d.c b/drivers/staging/board/kzm9d.c deleted file mode 100644 index d449a837414e..000000000000 --- a/drivers/staging/board/kzm9d.c +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Staging board support for KZM9D. Enable not-yet-DT-capable devices here. */ - -#include -#include -#include "board.h" - -static struct resource usbs1_res[] __initdata = { - DEFINE_RES_MEM(0xe2800000, 0x2000), - DEFINE_RES_IRQ(159), -}; - -static void __init kzm9d_init(void) -{ - board_staging_gic_setup_xlate("arm,pl390", 32); - - if (!board_staging_dt_node_available(usbs1_res, - ARRAY_SIZE(usbs1_res))) { - board_staging_gic_fixup_resources(usbs1_res, - ARRAY_SIZE(usbs1_res)); - platform_device_register_simple("emxx_udc", -1, usbs1_res, - ARRAY_SIZE(usbs1_res)); - } -} - -board_staging("renesas,kzm9d", kzm9d_init); -- cgit v1.2.3-58-ga151 From f402f7a02af6956d3fd4ce17d6bd08054231f72d Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 22 Jan 2024 15:24:32 +0100 Subject: staging: board: Remove Armadillo-800-EVA board staging code Since commits 1399ebacbf590dfb ("drm: renesas: shmobile: Add DT support"), 138588e9fa237f97 ("ARM: dts: renesas: r8a7740: Add LCDC nodes"), and c9a0ed13382660c9 ("ARM: dts: renesas: armadillo800eva: Add LCD panel"), there is no longer any use for the Atmark Techno Armadillo-800-EVA board staging code. Signed-off-by: Geert Uytterhoeven Acked-by: Wolfram Sang Link: https://lore.kernel.org/r/6d51e06a8586997b31eecead55a369f01c5696a7.1705932585.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/Makefile | 1 - drivers/staging/board/armadillo800eva.c | 88 --------------------------------- 2 files changed, 89 deletions(-) delete mode 100644 drivers/staging/board/armadillo800eva.c (limited to 'drivers') diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile index 5db091b5ca01..b6a00c93c2cc 100644 --- a/drivers/staging/board/Makefile +++ b/drivers/staging/board/Makefile @@ -1,3 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := board.o -obj-$(CONFIG_ARCH_R8A7740) += armadillo800eva.o diff --git a/drivers/staging/board/armadillo800eva.c b/drivers/staging/board/armadillo800eva.c deleted file mode 100644 index 0225234dd7aa..000000000000 --- a/drivers/staging/board/armadillo800eva.c +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Staging board support for Armadillo 800 eva. - * Enable not-yet-DT-capable devices here. - * - * Based on board-armadillo800eva.c - * - * Copyright (C) 2012 Renesas Solutions Corp. - * Copyright (C) 2012 Kuninori Morimoto - */ - -#include -#include -#include -#include -#include - -#include