* [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate
@ 2007-03-06 16:58 Auke Kok
2007-03-06 16:58 ` [PATCH 2/3] e1000: Use kcalloc() Auke Kok
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Auke Kok @ 2007-03-06 16:58 UTC (permalink / raw)
To: jgarzik; +Cc: netdev, john.ronciak, jesse.brandeburg
From: Ahmed S. Darwish <darwish.07@gmail.com>
A patch to use ARRAY_SIZE macro already defined in kernel.h.
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---
drivers/net/e1000/e1000_ethtool.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 6777887..a094288 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -742,7 +742,7 @@ err_setup:
uint32_t pat, value; \
uint32_t test[] = \
{0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \
- for (pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) { \
+ for (pat = 0; pat < ARRAY_SIZE(test); pat++) { \
E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
value = E1000_READ_REG(&adapter->hw, R); \
if (value != (test[pat] & W & M)) { \
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] e1000: Use kcalloc()
2007-03-06 16:58 [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Auke Kok
@ 2007-03-06 16:58 ` Auke Kok
2007-03-06 16:58 ` [PATCH 3/3] e1000: list e1000-devel mailing list in MAINTAINERS Auke Kok
2007-03-09 17:00 ` [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Jeff Garzik
2 siblings, 0 replies; 4+ messages in thread
From: Auke Kok @ 2007-03-06 16:58 UTC (permalink / raw)
To: jgarzik; +Cc: netdev, john.ronciak, jesse.brandeburg
From: Yan Burman <burman.yan@gmail.com>
Replace kmalloc+memsetout the driver. Slightly modified by Auke Kok.
Signed-off-by: Yan Burman <burman.yan@gmail.com>
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---
drivers/net/e1000/e1000_ethtool.c | 26 ++++++++++++--------------
drivers/net/e1000/e1000_main.c | 29 ++++++++++++-----------------
2 files changed, 24 insertions(+), 31 deletions(-)
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index a094288..2881da1 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -654,14 +654,11 @@ e1000_set_ringparam(struct net_device *netdev,
e1000_mac_type mac_type = adapter->hw.mac_type;
struct e1000_tx_ring *txdr, *tx_old;
struct e1000_rx_ring *rxdr, *rx_old;
- int i, err, tx_ring_size, rx_ring_size;
+ int i, err;
if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
return -EINVAL;
- tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
- rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
-
while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
msleep(1);
@@ -672,11 +669,11 @@ e1000_set_ringparam(struct net_device *netdev,
rx_old = adapter->rx_ring;
err = -ENOMEM;
- txdr = kzalloc(tx_ring_size, GFP_KERNEL);
+ txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL);
if (!txdr)
goto err_alloc_tx;
- rxdr = kzalloc(rx_ring_size, GFP_KERNEL);
+ rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL);
if (!rxdr)
goto err_alloc_rx;
@@ -1053,23 +1050,24 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
struct pci_dev *pdev = adapter->pdev;
uint32_t rctl;
- int size, i, ret_val;
+ int i, ret_val;
/* Setup Tx descriptor ring and Tx buffers */
if (!txdr->count)
txdr->count = E1000_DEFAULT_TXD;
- size = txdr->count * sizeof(struct e1000_buffer);
- if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+ if (!(txdr->buffer_info = kcalloc(txdr->count,
+ sizeof(struct e1000_buffer),
+ GFP_KERNEL))) {
ret_val = 1;
goto err_nomem;
}
- memset(txdr->buffer_info, 0, size);
txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
E1000_ROUNDUP(txdr->size, 4096);
- if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
+ if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size,
+ &txdr->dma))) {
ret_val = 2;
goto err_nomem;
}
@@ -1116,12 +1114,12 @@ e1000_setup_desc_rings(struct e1000_adapter *adapter)
if (!rxdr->count)
rxdr->count = E1000_DEFAULT_RXD;
- size = rxdr->count * sizeof(struct e1000_buffer);
- if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
+ if (!(rxdr->buffer_info = kcalloc(rxdr->count,
+ sizeof(struct e1000_buffer),
+ GFP_KERNEL))) {
ret_val = 4;
goto err_nomem;
}
- memset(rxdr->buffer_info, 0, size);
rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7bbefca..530d5d7 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1354,31 +1354,27 @@ e1000_sw_init(struct e1000_adapter *adapter)
static int __devinit
e1000_alloc_queues(struct e1000_adapter *adapter)
{
- int size;
-
- size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
- adapter->tx_ring = kmalloc(size, GFP_KERNEL);
+ adapter->tx_ring = kcalloc(adapter->num_tx_queues,
+ sizeof(struct e1000_tx_ring), GFP_KERNEL);
if (!adapter->tx_ring)
return -ENOMEM;
- memset(adapter->tx_ring, 0, size);
- size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
- adapter->rx_ring = kmalloc(size, GFP_KERNEL);
+ adapter->rx_ring = kcalloc(adapter->num_rx_queues,
+ sizeof(struct e1000_rx_ring), GFP_KERNEL);
if (!adapter->rx_ring) {
kfree(adapter->tx_ring);
return -ENOMEM;
}
- memset(adapter->rx_ring, 0, size);
#ifdef CONFIG_E1000_NAPI
- size = sizeof(struct net_device) * adapter->num_rx_queues;
- adapter->polling_netdev = kmalloc(size, GFP_KERNEL);
+ adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
+ sizeof(struct net_device),
+ GFP_KERNEL);
if (!adapter->polling_netdev) {
kfree(adapter->tx_ring);
kfree(adapter->rx_ring);
return -ENOMEM;
}
- memset(adapter->polling_netdev, 0, size);
#endif
return E1000_SUCCESS;
@@ -1774,18 +1770,18 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
}
memset(rxdr->buffer_info, 0, size);
- size = sizeof(struct e1000_ps_page) * rxdr->count;
- rxdr->ps_page = kmalloc(size, GFP_KERNEL);
+ rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct e1000_ps_page),
+ GFP_KERNEL);
if (!rxdr->ps_page) {
vfree(rxdr->buffer_info);
DPRINTK(PROBE, ERR,
"Unable to allocate memory for the receive descriptor ring\n");
return -ENOMEM;
}
- memset(rxdr->ps_page, 0, size);
- size = sizeof(struct e1000_ps_page_dma) * rxdr->count;
- rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL);
+ rxdr->ps_page_dma = kcalloc(rxdr->count,
+ sizeof(struct e1000_ps_page_dma),
+ GFP_KERNEL);
if (!rxdr->ps_page_dma) {
vfree(rxdr->buffer_info);
kfree(rxdr->ps_page);
@@ -1793,7 +1789,6 @@ e1000_setup_rx_resources(struct e1000_adapter *adapter,
"Unable to allocate memory for the receive descriptor ring\n");
return -ENOMEM;
}
- memset(rxdr->ps_page_dma, 0, size);
if (adapter->hw.mac_type <= e1000_82547_rev_2)
desc_len = sizeof(struct e1000_rx_desc);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] e1000: list e1000-devel mailing list in MAINTAINERS
2007-03-06 16:58 [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Auke Kok
2007-03-06 16:58 ` [PATCH 2/3] e1000: Use kcalloc() Auke Kok
@ 2007-03-06 16:58 ` Auke Kok
2007-03-09 17:00 ` [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Jeff Garzik
2 siblings, 0 replies; 4+ messages in thread
From: Auke Kok @ 2007-03-06 16:58 UTC (permalink / raw)
To: jgarzik; +Cc: netdev, john.ronciak, jesse.brandeburg
From: Auke Kok <auke-jan.h.kok@intel.com>
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---
MAINTAINERS | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS
index 1dfba85..51efc71 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1797,6 +1797,7 @@ P: Jeff Kirsher
M: jeffrey.t.kirsher@intel.com
P: Auke Kok
M: auke-jan.h.kok@intel.com
+L: e1000-devel@lists.sourceforge.net
W: http://sourceforge.net/projects/e1000/
S: Supported
@@ -1811,6 +1812,7 @@ P: Jeff Kirsher
M: jeffrey.t.kirsher@intel.com
P: Auke Kok
M: auke-jan.h.kok@intel.com
+L: e1000-devel@lists.sourceforge.net
W: http://sourceforge.net/projects/e1000/
S: Supported
@@ -1825,6 +1827,7 @@ P: Jesse Brandeburg
M: jesse.brandeburg@intel.com
P: Auke Kok
M: auke-jan.h.kok@intel.com
+L: e1000-devel@lists.sourceforge.net
W: http://sourceforge.net/projects/e1000/
S: Supported
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate
2007-03-06 16:58 [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Auke Kok
2007-03-06 16:58 ` [PATCH 2/3] e1000: Use kcalloc() Auke Kok
2007-03-06 16:58 ` [PATCH 3/3] e1000: list e1000-devel mailing list in MAINTAINERS Auke Kok
@ 2007-03-09 17:00 ` Jeff Garzik
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Garzik @ 2007-03-09 17:00 UTC (permalink / raw)
To: Auke Kok; +Cc: netdev, john.ronciak, jesse.brandeburg
Auke Kok wrote:
> From: Ahmed S. Darwish <darwish.07@gmail.com>
>
> A patch to use ARRAY_SIZE macro already defined in kernel.h.
>
> Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
> Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
> ---
>
> drivers/net/e1000/e1000_ethtool.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
applied 1-3 to #upstream
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-03-09 17:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06 16:58 [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Auke Kok
2007-03-06 16:58 ` [PATCH 2/3] e1000: Use kcalloc() Auke Kok
2007-03-06 16:58 ` [PATCH 3/3] e1000: list e1000-devel mailing list in MAINTAINERS Auke Kok
2007-03-09 17:00 ` [PATCH 1/3] e1000: Use ARRAY_SIZE macro when appropriate Jeff Garzik
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.