提交 0c0b0aca 编写于 作者: M Mike Travis 提交者: David S. Miller

net: remove NR_CPUS arrays in net/core/dev.c

Remove the fixed size channels[NR_CPUS] array in net/core/dev.c and
dynamically allocate array based on nr_cpu_ids.
Signed-off-by: NMike Travis <travis@sgi.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 d3e2ce3b
...@@ -162,7 +162,7 @@ struct net_dma { ...@@ -162,7 +162,7 @@ struct net_dma {
struct dma_client client; struct dma_client client;
spinlock_t lock; spinlock_t lock;
cpumask_t channel_mask; cpumask_t channel_mask;
struct dma_chan *channels[NR_CPUS]; struct dma_chan **channels;
}; };
static enum dma_state_client static enum dma_state_client
...@@ -2444,7 +2444,7 @@ static struct netif_rx_stats *softnet_get_online(loff_t *pos) ...@@ -2444,7 +2444,7 @@ static struct netif_rx_stats *softnet_get_online(loff_t *pos)
{ {
struct netif_rx_stats *rc = NULL; struct netif_rx_stats *rc = NULL;
while (*pos < NR_CPUS) while (*pos < nr_cpu_ids)
if (cpu_online(*pos)) { if (cpu_online(*pos)) {
rc = &per_cpu(netdev_rx_stat, *pos); rc = &per_cpu(netdev_rx_stat, *pos);
break; break;
...@@ -4324,7 +4324,7 @@ netdev_dma_event(struct dma_client *client, struct dma_chan *chan, ...@@ -4324,7 +4324,7 @@ netdev_dma_event(struct dma_client *client, struct dma_chan *chan,
spin_lock(&net_dma->lock); spin_lock(&net_dma->lock);
switch (state) { switch (state) {
case DMA_RESOURCE_AVAILABLE: case DMA_RESOURCE_AVAILABLE:
for (i = 0; i < NR_CPUS; i++) for (i = 0; i < nr_cpu_ids; i++)
if (net_dma->channels[i] == chan) { if (net_dma->channels[i] == chan) {
found = 1; found = 1;
break; break;
...@@ -4339,7 +4339,7 @@ netdev_dma_event(struct dma_client *client, struct dma_chan *chan, ...@@ -4339,7 +4339,7 @@ netdev_dma_event(struct dma_client *client, struct dma_chan *chan,
} }
break; break;
case DMA_RESOURCE_REMOVED: case DMA_RESOURCE_REMOVED:
for (i = 0; i < NR_CPUS; i++) for (i = 0; i < nr_cpu_ids; i++)
if (net_dma->channels[i] == chan) { if (net_dma->channels[i] == chan) {
found = 1; found = 1;
pos = i; pos = i;
...@@ -4366,6 +4366,13 @@ netdev_dma_event(struct dma_client *client, struct dma_chan *chan, ...@@ -4366,6 +4366,13 @@ netdev_dma_event(struct dma_client *client, struct dma_chan *chan,
*/ */
static int __init netdev_dma_register(void) static int __init netdev_dma_register(void)
{ {
net_dma.channels = kzalloc(nr_cpu_ids * sizeof(struct net_dma),
GFP_KERNEL);
if (unlikely(!net_dma.channels)) {
printk(KERN_NOTICE
"netdev_dma: no memory for net_dma.channels\n");
return -ENOMEM;
}
spin_lock_init(&net_dma.lock); spin_lock_init(&net_dma.lock);
dma_cap_set(DMA_MEMCPY, net_dma.client.cap_mask); dma_cap_set(DMA_MEMCPY, net_dma.client.cap_mask);
dma_async_client_register(&net_dma.client); dma_async_client_register(&net_dma.client);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册