Skip to content

Commit 8e842c4

Browse files
Philipp Hortmanngregkh
authored andcommitted
staging: rtl8192e: Convert array rx_ring[] to variable rx_ring
Convert array rx_ring[] to variable rx_ring as index is always 0. This increases readability. Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/c53ff4251eba0adae6d8279a918c8ab4914b4780.1698295861.git.philipp.g.hortmann@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 510c8f1 commit 8e842c4

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

drivers/staging/rtl8192e/rtl8192e/rtl_core.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,10 +1157,10 @@ static void _rtl92e_free_rx_ring(struct net_device *dev)
11571157
}
11581158

11591159
dma_free_coherent(&priv->pdev->dev,
1160-
sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
1161-
priv->rx_ring[rx_queue_idx],
1160+
sizeof(*priv->rx_ring) * priv->rxringcount,
1161+
priv->rx_ring,
11621162
priv->rx_ring_dma[rx_queue_idx]);
1163-
priv->rx_ring[rx_queue_idx] = NULL;
1163+
priv->rx_ring = NULL;
11641164
}
11651165

11661166
static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio)
@@ -1354,12 +1354,11 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
13541354
int i;
13551355
int rx_queue_idx = 0;
13561356

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) {
1357+
priv->rx_ring = dma_alloc_coherent(&priv->pdev->dev,
1358+
sizeof(*priv->rx_ring) * priv->rxringcount,
1359+
&priv->rx_ring_dma[rx_queue_idx],
1360+
GFP_ATOMIC);
1361+
if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) {
13631362
netdev_warn(dev, "Cannot allocate RX ring\n");
13641363
return -ENOMEM;
13651364
}
@@ -1370,7 +1369,7 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev)
13701369
struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
13711370
dma_addr_t *mapping;
13721371

1373-
entry = &priv->rx_ring[rx_queue_idx][i];
1372+
entry = &priv->rx_ring[i];
13741373
if (!skb)
13751374
return 0;
13761375
skb->dev = dev;
@@ -1456,11 +1455,11 @@ void rtl92e_reset_desc_ring(struct net_device *dev)
14561455
int rx_queue_idx = 0;
14571456
unsigned long flags = 0;
14581457

1459-
if (priv->rx_ring[rx_queue_idx]) {
1458+
if (priv->rx_ring) {
14601459
struct rx_desc *entry = NULL;
14611460

14621461
for (i = 0; i < priv->rxringcount; i++) {
1463-
entry = &priv->rx_ring[rx_queue_idx][i];
1462+
entry = &priv->rx_ring[i];
14641463
entry->OWN = 1;
14651464
}
14661465
priv->rx_idx[rx_queue_idx] = 0;
@@ -1574,7 +1573,7 @@ static void _rtl92e_rx_normal(struct net_device *dev)
15741573
stats.nic_type = NIC_8192E;
15751574

15761575
while (count--) {
1577-
struct rx_desc *pdesc = &priv->rx_ring[rx_queue_idx]
1576+
struct rx_desc *pdesc = &priv->rx_ring
15781577
[priv->rx_idx[rx_queue_idx]];
15791578
struct sk_buff *skb = priv->rx_buf[rx_queue_idx]
15801579
[priv->rx_idx[rx_queue_idx]];

drivers/staging/rtl8192e/rtl8192e/rtl_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ struct r8192_priv {
232232

233233
u8 (*rf_set_chan)(struct net_device *dev, u8 ch);
234234

235-
struct rx_desc *rx_ring[MAX_RX_QUEUE];
235+
struct rx_desc *rx_ring;
236236
struct sk_buff *rx_buf[MAX_RX_QUEUE][MAX_RX_COUNT];
237237
dma_addr_t rx_ring_dma[MAX_RX_QUEUE];
238238
unsigned int rx_idx[MAX_RX_QUEUE];

0 commit comments

Comments
 (0)