All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 07/15] net: pcnet: Move initialize function at the end
Date: Sun, 17 May 2020 18:24:17 +0200	[thread overview]
Message-ID: <20200517162425.76584-7-marek.vasut+renesas@gmail.com> (raw)
In-Reply-To: <20200517162425.76584-1-marek.vasut+renesas@gmail.com>

Move the function at the end of the driver, so we could drop
various forward declarations later. No functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 drivers/net/pcnet.c | 180 ++++++++++++++++++++++----------------------
 1 file changed, 89 insertions(+), 91 deletions(-)

diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index 3a9f20a7f0..ec8d080794 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -158,97 +158,6 @@ static struct pci_device_id supported[] = {
 	{}
 };
 
-
-int pcnet_initialize(bd_t *bis)
-{
-	pci_dev_t devbusfn;
-	struct eth_device *dev;
-	u16 command, status;
-	int dev_nr = 0;
-	u32 bar;
-
-	PCNET_DEBUG1("\npcnet_initialize...\n");
-
-	for (dev_nr = 0;; dev_nr++) {
-
-		/*
-		 * Find the PCnet PCI device(s).
-		 */
-		devbusfn = pci_find_devices(supported, dev_nr);
-		if (devbusfn < 0)
-			break;
-
-		/*
-		 * Allocate and pre-fill the device structure.
-		 */
-		dev = calloc(1, sizeof(*dev));
-		if (!dev) {
-			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);
-
-		/*
-		 * Setup the PCI device.
-		 */
-		pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, &bar);
-		dev->iobase = pci_mem_to_phys(devbusfn, bar);
-		dev->iobase &= ~0xf;
-
-		PCNET_DEBUG1("%s: devbusfn=0x%x iobase=0x%lx: ",
-			     dev->name, devbusfn, (unsigned long)dev->iobase);
-
-		command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
-		pci_write_config_word(devbusfn, PCI_COMMAND, command);
-		pci_read_config_word(devbusfn, PCI_COMMAND, &status);
-		if ((status & command) != command) {
-			printf("%s: Couldn't enable IO access or Bus Mastering\n",
-			       dev->name);
-			free(dev);
-			continue;
-		}
-
-		pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x40);
-
-		/*
-		 * Probe the PCnet chip.
-		 */
-		if (pcnet_probe(dev, bis, dev_nr) < 0) {
-			free(dev);
-			continue;
-		}
-
-		/*
-		 * Setup device structure and register the driver.
-		 */
-		dev->init = pcnet_init;
-		dev->halt = pcnet_halt;
-		dev->send = pcnet_send;
-		dev->recv = pcnet_recv;
-
-		eth_register(dev);
-	}
-
-	udelay(10 * 1000);
-
-	return dev_nr;
-}
-
 static int pcnet_probe(struct eth_device *dev, bd_t *bis, int dev_nr)
 {
 	int chip_version;
@@ -545,3 +454,92 @@ static void pcnet_halt(struct eth_device *dev)
 	if (i <= 0)
 		printf("%s: TIMEOUT: controller reset failed\n", dev->name);
 }
+
+int pcnet_initialize(bd_t *bis)
+{
+	pci_dev_t devbusfn;
+	struct eth_device *dev;
+	u16 command, status;
+	int dev_nr = 0;
+	u32 bar;
+
+	PCNET_DEBUG1("\npcnet_initialize...\n");
+
+	for (dev_nr = 0; ; dev_nr++) {
+		/*
+		 * Find the PCnet PCI device(s).
+		 */
+		devbusfn = pci_find_devices(supported, dev_nr);
+		if (devbusfn < 0)
+			break;
+
+		/*
+		 * Allocate and pre-fill the device structure.
+		 */
+		dev = calloc(1, sizeof(*dev));
+		if (!dev) {
+			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);
+
+		/*
+		 * Setup the PCI device.
+		 */
+		pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_1, &bar);
+		dev->iobase = pci_mem_to_phys(devbusfn, bar);
+		dev->iobase &= ~0xf;
+
+		PCNET_DEBUG1("%s: devbusfn=0x%x iobase=0x%lx: ",
+			     dev->name, devbusfn, (unsigned long)dev->iobase);
+
+		command = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
+		pci_write_config_word(devbusfn, PCI_COMMAND, command);
+		pci_read_config_word(devbusfn, PCI_COMMAND, &status);
+		if ((status & command) != command) {
+			printf("%s: Couldn't enable IO access or Bus Mastering\n",
+			       dev->name);
+			free(dev);
+			continue;
+		}
+
+		pci_write_config_byte(devbusfn, PCI_LATENCY_TIMER, 0x40);
+
+		/*
+		 * Probe the PCnet chip.
+		 */
+		if (pcnet_probe(dev, bis, dev_nr) < 0) {
+			free(dev);
+			continue;
+		}
+
+		/*
+		 * Setup device structure and register the driver.
+		 */
+		dev->init = pcnet_init;
+		dev->halt = pcnet_halt;
+		dev->send = pcnet_send;
+		dev->recv = pcnet_recv;
+
+		eth_register(dev);
+	}
+
+	udelay(10 * 1000);
+
+	return dev_nr;
+}
-- 
2.25.1

  parent reply	other threads:[~2020-05-17 16:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 16:24 [PATCH 01/15] net: pcnet: Drop typedef struct pcnet_priv_t Marek Vasut
2020-05-17 16:24 ` [PATCH 02/15] net: pcnet: Drop PCNET_HAS_PROM Marek Vasut
2020-05-17 16:24 ` [PATCH 03/15] net: pcnet: Use PCI_DEVICE() to define PCI device compat list Marek Vasut
2020-05-17 16:24 ` [PATCH 04/15] net: pcnet: Simplify private data allocation Marek Vasut
2020-05-17 16:24 ` [PATCH 05/15] net: pcnet: Replace memset+malloc with calloc Marek Vasut
2020-05-17 16:24 ` [PATCH 06/15] net: pcnet: Move private data allocation to initialize Marek Vasut
2020-05-17 16:24 ` Marek Vasut [this message]
2020-05-17 16:24 ` [PATCH 08/15] net: pcnet: Drop useless forward declarations Marek Vasut
2020-05-17 16:24 ` [PATCH 09/15] net: pcnet: Wrap devbusfn into private data Marek Vasut
2020-05-17 16:24 ` [PATCH 10/15] net: pcnet: Pass private data through dev->priv Marek Vasut
2020-05-17 16:24 ` [PATCH 11/15] net: pcnet: Wrap iobase into private data Marek Vasut
2020-05-17 16:24 ` [PATCH 12/15] net: pcnet: Wrap name and enetaddr " Marek Vasut
2020-05-17 16:24 ` [PATCH 13/15] net: pcnet: Split common and non-DM functions Marek Vasut
2020-05-17 16:24 ` [PATCH 14/15] net: pcnet: Add DM support Marek Vasut
2020-05-17 16:24 ` [PATCH 15/15] net: pcnet: Add Kconfig entries Marek Vasut
2020-05-18  9:18   ` Daniel Schwierzeck
2020-05-18  9:54     ` Marek Vasut
2020-05-18 16:03       ` Daniel Schwierzeck
2020-06-05 15:28 ` [PATCH 01/15] net: pcnet: Drop typedef struct pcnet_priv_t Daniel Schwierzeck
2020-06-05 16:22   ` Marek Vasut
2020-06-05 16:38     ` Daniel Schwierzeck
2020-06-05 17:50       ` Marek Vasut
2020-06-05 23:56         ` Daniel Schwierzeck
2020-06-06 12:00           ` Marek Vasut

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=20200517162425.76584-7-marek.vasut+renesas@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 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.