From: Philipp Hortmann <philipp.g.hortmann@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 05/10] staging: rtl8192e: Remove loops with constant MAX_RX_QUEUE
Date: Thu, 26 Oct 2023 07:43:59 +0200 [thread overview]
Message-ID: <8bc9d3c15fba082a928ea2c0916a6aef5f76f456.1698295861.git.philipp.g.hortmann@gmail.com> (raw)
In-Reply-To: <cover.1698295861.git.philipp.g.hortmann@gmail.com>
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>
---
drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 120 +++++++++----------
1 file changed, 58 insertions(+), 62 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index ba35ae4a21fa..2f0fc7c0f216 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -1141,28 +1141,26 @@ void rtl92e_tx_enable(struct net_device *dev)
static void _rtl92e_free_rx_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- int i, rx_queue_idx;
-
- for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE;
- rx_queue_idx++) {
- for (i = 0; i < priv->rxringcount; i++) {
- struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
+ int i;
+ int rx_queue_idx = 0;
- if (!skb)
- continue;
+ for (i = 0; i < priv->rxringcount; i++) {
+ struct sk_buff *skb = priv->rx_buf[rx_queue_idx][i];
- dma_unmap_single(&priv->pdev->dev,
- *((dma_addr_t *)skb->cb),
- priv->rxbuffersize, DMA_FROM_DEVICE);
- kfree_skb(skb);
- }
+ if (!skb)
+ continue;
- dma_free_coherent(&priv->pdev->dev,
- sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
- priv->rx_ring[rx_queue_idx],
- priv->rx_ring_dma[rx_queue_idx]);
- priv->rx_ring[rx_queue_idx] = NULL;
+ dma_unmap_single(&priv->pdev->dev,
+ *((dma_addr_t *)skb->cb),
+ priv->rxbuffersize, DMA_FROM_DEVICE);
+ kfree_skb(skb);
}
+
+ dma_free_coherent(&priv->pdev->dev,
+ sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
+ priv->rx_ring[rx_queue_idx],
+ priv->rx_ring_dma[rx_queue_idx]);
+ priv->rx_ring[rx_queue_idx] = NULL;
}
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)
{
struct r8192_priv *priv = rtllib_priv(dev);
struct rx_desc *entry = NULL;
- int i, rx_queue_idx;
-
- for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
- priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
- sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
- &priv->rx_ring_dma[rx_queue_idx],
- GFP_ATOMIC);
- if (!priv->rx_ring[rx_queue_idx] ||
- (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
- netdev_warn(dev, "Cannot allocate RX ring\n");
- return -ENOMEM;
- }
-
- priv->rx_idx[rx_queue_idx] = 0;
+ int i;
+ int rx_queue_idx = 0;
+
+ priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev,
+ sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
+ &priv->rx_ring_dma[rx_queue_idx],
+ GFP_ATOMIC);
+ if (!priv->rx_ring[rx_queue_idx] ||
+ (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
+ netdev_warn(dev, "Cannot allocate RX ring\n");
+ return -ENOMEM;
+ }
- for (i = 0; i < priv->rxringcount; i++) {
- struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
- dma_addr_t *mapping;
+ priv->rx_idx[rx_queue_idx] = 0;
- entry = &priv->rx_ring[rx_queue_idx][i];
- if (!skb)
- return 0;
- skb->dev = dev;
- priv->rx_buf[rx_queue_idx][i] = skb;
- mapping = (dma_addr_t *)skb->cb;
- *mapping = dma_map_single(&priv->pdev->dev,
- skb_tail_pointer(skb),
- priv->rxbuffersize, DMA_FROM_DEVICE);
- if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
- dev_kfree_skb_any(skb);
- return -1;
- }
- entry->BufferAddress = *mapping;
+ for (i = 0; i < priv->rxringcount; i++) {
+ struct sk_buff *skb = dev_alloc_skb(priv->rxbuffersize);
+ dma_addr_t *mapping;
- entry->Length = priv->rxbuffersize;
- entry->OWN = 1;
+ entry = &priv->rx_ring[rx_queue_idx][i];
+ if (!skb)
+ return 0;
+ skb->dev = dev;
+ priv->rx_buf[rx_queue_idx][i] = skb;
+ mapping = (dma_addr_t *)skb->cb;
+ *mapping = dma_map_single(&priv->pdev->dev,
+ skb_tail_pointer(skb),
+ priv->rxbuffersize, DMA_FROM_DEVICE);
+ if (dma_mapping_error(&priv->pdev->dev, *mapping)) {
+ dev_kfree_skb_any(skb);
+ return -1;
}
+ entry->BufferAddress = *mapping;
- if (entry)
- entry->EOR = 1;
+ entry->Length = priv->rxbuffersize;
+ entry->OWN = 1;
}
+
+ if (entry)
+ entry->EOR = 1;
return 0;
}
@@ -1455,19 +1452,18 @@ static short _rtl92e_pci_initdescring(struct net_device *dev)
void rtl92e_reset_desc_ring(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- int i, rx_queue_idx;
+ int i;
+ int rx_queue_idx = 0;
unsigned long flags = 0;
- for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
- if (priv->rx_ring[rx_queue_idx]) {
- struct rx_desc *entry = NULL;
+ if (priv->rx_ring[rx_queue_idx]) {
+ struct rx_desc *entry = NULL;
- for (i = 0; i < priv->rxringcount; i++) {
- entry = &priv->rx_ring[rx_queue_idx][i];
- entry->OWN = 1;
- }
- priv->rx_idx[rx_queue_idx] = 0;
+ for (i = 0; i < priv->rxringcount; i++) {
+ entry = &priv->rx_ring[rx_queue_idx][i];
+ entry->OWN = 1;
}
+ priv->rx_idx[rx_queue_idx] = 0;
}
spin_lock_irqsave(&priv->irq_th_lock, flags);
--
2.42.0
next prev parent reply other threads:[~2023-10-26 5:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 5:43 [PATCH 00/10] staging: rtl8192e: Convert array rx_ring[] to rx_ring Philipp Hortmann
2023-10-26 5:43 ` [PATCH 01/10] staging: rtl8192e: Remove HTIOTActIsDisableMCS14() Philipp Hortmann
2023-10-26 5:43 ` [PATCH 02/10] staging: rtl8192e: Remove HTIOTActIsDisableMCS15() Philipp Hortmann
2023-10-26 5:43 ` [PATCH 03/10] staging: rtl8192e: Remove HTIOTActIsDisableMCSTwoSpatialStream() Philipp Hortmann
2023-10-26 5:43 ` [PATCH 04/10] staging: rtl8192e: Remove HTIOTActIsDisableEDCATurbo() Philipp Hortmann
2023-10-26 5:43 ` Philipp Hortmann [this message]
2023-10-26 5:44 ` [PATCH 06/10] staging: rtl8192e: Convert array rx_ring[] to variable rx_ring Philipp Hortmann
2023-10-26 5:44 ` [PATCH 07/10] staging: rtl8192e: Convert array rx_buf[][] to array rx_buf[] Philipp Hortmann
2023-10-26 5:44 ` [PATCH 08/10] staging: rtl8192e: Convert array rx_ring_dma[] to variable rx_ring_dma Philipp Hortmann
2023-10-26 5:44 ` [PATCH 09/10] staging: rtl8192e: Convert array rx_idx[] to variable rx_idx Philipp Hortmann
2023-10-26 7:09 ` Dan Carpenter
2023-10-26 5:44 ` [PATCH 10/10] staging: rtl8192e: Remove unused constants starting with MAX_RX_QUEUE Philipp Hortmann
2023-10-26 7:09 ` [PATCH 00/10] staging: rtl8192e: Convert array rx_ring[] to rx_ring Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8bc9d3c15fba082a928ea2c0916a6aef5f76f456.1698295861.git.philipp.g.hortmann@gmail.com \
--to=philipp.g.hortmann@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®