aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/pcnet.c
diff options
context:
space:
mode:
authorMarek Vasut2020-05-17 16:26:00 +0200
committerMarek Vasut2020-06-18 19:34:40 +0200
commit246d2bfcf244326c43dcfffcecfdf684b8a4513d (patch)
treeb889a5e12f744c9b9b2c0ccb742c67017a4ff85a /drivers/net/pcnet.c
parentae38e96c23f3d08e2ec49206a99271252f5b3dc2 (diff)
net: pcnet: Move private data allocation to initialize
The private data allocation does not have to be done every time the NIC is initialized at run time, move the allocation to initialize function, which means it will be done only once when the driver starts. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Cc: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net/pcnet.c')
-rw-r--r--drivers/net/pcnet.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index b670cff2aae..073ffca6b62 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -189,6 +189,20 @@ int pcnet_initialize(bd_t *bis)
printf("pcnet: Can not allocate memory\n");
break;
}
+
+ /*
+ * We only maintain one structure because the drivers will
+ * never be used concurrently. In 32bit mode the RX and TX
+ * ring entries must be aligned on 16-byte boundaries.
+ */
+ if (!lp) {
+ lp = malloc_cache_aligned(sizeof(*lp));
+ lp->uc = map_physmem((phys_addr_t)&lp->ucp,
+ sizeof(lp->ucp), MAP_NOCACHE);
+ flush_dcache_range((unsigned long)lp,
+ (unsigned long)lp + sizeof(*lp));
+ }
+
dev->priv = (void *)(unsigned long)devbusfn;
sprintf(dev->name, "pcnet#%d", dev_nr);
@@ -330,19 +344,6 @@ static int pcnet_init(struct eth_device *dev, bd_t *bis)
val |= 0x3 << 10;
pcnet_write_csr(dev, 80, val);
- /*
- * We only maintain one structure because the drivers will never
- * be used concurrently. In 32bit mode the RX and TX ring entries
- * must be aligned on 16-byte boundaries.
- */
- if (lp == NULL) {
- lp = malloc_cache_aligned(sizeof(*lp));
- lp->uc = map_physmem((phys_addr_t)&lp->ucp,
- sizeof(lp->ucp), MAP_NOCACHE);
- flush_dcache_range((unsigned long)lp,
- (unsigned long)lp + sizeof(*lp));
- }
-
uc = lp->uc;
uc->init_block.mode = cpu_to_le16(0x0000);