Skip to content

Commit 510c8f1

Browse files
Philipp Hortmanngregkh
authored andcommitted
staging: rtl8192e: Remove loops with constant MAX_RX_QUEUE
MAX_RX_QUEUE is set to 1. All loops with MAX_RX_QUEUE run only one cycle. Remove loops. Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/8bc9d3c15fba082a928ea2c0916a6aef5f76f456.1698295861.git.philipp.g.hortmann@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ac32633 commit 510c8f1

1 file changed

Lines changed: 58 additions & 62 deletions

File tree

drivers/staging/rtl8192e/rtl8192e/rtl_core.c

Lines changed: 58 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,28 +1141,26 @@ void rtl92e_tx_enable(struct net_device *dev)
11411141
static void _rtl92e_free_rx_ring(struct net_device *dev)
11421142
{
11431143
struct r8192_priv *priv = rtllib_priv(dev);
1144-
int i, rx_queue_idx;
1145-
1146-
for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE;
1147-
rx_queue_idx++) {
1148-
for (i = 0; i < priv->rxringcount; i++) {
1149-
struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
1144+
int i;
1145+
int rx_queue_idx = 0;
11501146

1151-
if (!skb)
1152-
continue;
1147+
for (i = 0; i < priv->rxringcount; i++) {
1148+
struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
11531149

1154-
dma_unmap_single(&priv->pdev->dev,
1155-
*((dma_addr_t *)skb->cb),
1156-
priv->rxbuffersize, DMA_FROM_DEVICE);
1157-
kfree_skb(skb);
1158-
}
1150+
if (!skb)
1151+
continue;
11591152

1160-
dma_free_coherent(&priv->pdev->dev,
1161-
sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
1162-
priv->rx_ring[rx_queue_idx],
1163-
priv->rx_ring_dma[rx_queue_idx]);
1164-
priv->rx_ring[rx_queue_idx] = NULL;
1153+
dma_unmap_single(&priv->pdev->dev,
1154+
*((dma_addr_t *)skb->cb),
1155+
priv->rxbuffersize, DMA_FROM_DEVICE);
1156+
kfree_skb(skb);
11651157
}
1158+
1159+
dma_free_coherent(&priv->pdev->dev,
1160+
sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
1161+
priv->rx_ring[rx_queue_idx],
1162+
priv->rx_ring_dma[rx_queue_idx]);
1163+
priv->rx_ring[rx_queue_idx] = NULL;
11661164
}
11671165

11681166
static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio)
@@ -1353,47 +1351,46 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
13531351
{
13541352
struct r8192_priv *priv = rtllib_priv(dev);
13551353
struct rx_desc *entry = NULL;
1356-
int i, rx_queue_idx;
1357-
1358-
for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
1359-
priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
1360-
sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
1361-
&priv->rx_ring_dma[rx_queue_idx],
1362-
GFP_ATOMIC);
1363-
if (!priv->rx_ring[rx_queue_idx] ||
1364-
(unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
1365-
netdev_warn(dev, "Cannot allocate RX ring\n");
1366-
return -ENOMEM;
1367-
}
1368-
1369-
priv->rx_idx[rx_queue_idx] = 0;
1354+
int i;
1355+
int rx_queue_idx = 0;
1356+
1357+
priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
1358+
sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
1359+
&priv->rx_ring_dma[rx_queue_idx],
1360+
GFP_ATOMIC);
1361+
if (!priv->rx_ring[rx_queue_idx] ||
1362+
(unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
1363+
netdev_warn(dev, "Cannot allocate RX ring\n");
1364+
return -ENOMEM;
1365+
}
13701366

1371-
for (i = 0; i < priv->rxringcount; i++) {
1372-
struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
1373-
dma_addr_t *mapping;
1367+
priv->rx_idx[rx_queue_idx] = 0;
13741368

1375-
entry = &priv->rx_ring[rx_queue_idx][i];
1376-
if (!skb)
1377-
return 0;
1378-
skb->dev = dev;
1379-
priv->rx_buf[rx_queue_idx][i] = skb;
1380-
mapping = (dma_addr_t *)skb->cb;
1381-
*mapping = dma_map_single(&priv->pdev->dev,
1382-
skb_tail_pointer(skb),
1383-
priv->rxbuffersize, DMA_FROM_DEVICE);
1384-
if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
1385-
dev_kfree_skb_any(skb);
1386-
return -1;
1387-
}
1388-
entry->BufferAddress = *mapping;
1369+
for (i = 0; i < priv->rxringcount; i++) {
1370+
struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
1371+
dma_addr_t *mapping;
13891372

1390-
entry->Length = priv->rxbuffersize;
1391-
entry->OWN = 1;
1373+
entry = &priv->rx_ring[rx_queue_idx][i];
1374+
if (!skb)
1375+
return 0;
1376+
skb->dev = dev;
1377+
priv->rx_buf[rx_queue_idx][i] = skb;
1378+
mapping = (dma_addr_t *)skb->cb;
1379+
*mapping = dma_map_single(&priv->pdev->dev,
1380+
skb_tail_pointer(skb),
1381+
priv->rxbuffersize, DMA_FROM_DEVICE);
1382+
if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
1383+
dev_kfree_skb_any(skb);
1384+
return -1;
13921385
}
1386+
entry->BufferAddress = *mapping;
13931387

1394-
if (entry)
1395-
entry->EOR = 1;
1388+
entry->Length = priv->rxbuffersize;
1389+
entry->OWN = 1;
13961390
}
1391+
1392+
if (entry)
1393+
entry->EOR = 1;
13971394
return 0;
13981395
}
13991396

@@ -1455,19 +1452,18 @@ static short _rtl92e_pci_initdescring(struct net_device *dev)
14551452
void rtl92e_reset_desc_ring(struct net_device *dev)
14561453
{
14571454
struct r8192_priv *priv = rtllib_priv(dev);
1458-
int i, rx_queue_idx;
1455+
int i;
1456+
int rx_queue_idx = 0;
14591457
unsigned long flags = 0;
14601458

1461-
for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
1462-
if (priv->rx_ring[rx_queue_idx]) {
1463-
struct rx_desc *entry = NULL;
1459+
if (priv->rx_ring[rx_queue_idx]) {
1460+
struct rx_desc *entry = NULL;
14641461

1465-
for (i = 0; i < priv->rxringcount; i++) {
1466-
entry = &priv->rx_ring[rx_queue_idx][i];
1467-
entry->OWN = 1;
1468-
}
1469-
priv->rx_idx[rx_queue_idx] = 0;
1462+
for (i = 0; i < priv->rxringcount; i++) {
1463+
entry = &priv->rx_ring[rx_queue_idx][i];
1464+
entry->OWN = 1;
14701465
}
1466+
priv->rx_idx[rx_queue_idx] = 0;
14711467
}
14721468

14731469
spin_lock_irqsave(&priv->irq_th_lock, flags);

0 commit comments

Comments
 (0)