netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Florian Fainelli <florian.fainelli@telecomint.eu>
Cc: netdev@vger.kernel.org, Jeff Garzik <jeff@garzik.org>
Subject: Re: [PATCH][RFC take 2] Add support for the RDC R6040 Fast Ethernet controller
Date: Sat, 10 Nov 2007 14:33:32 -0500	[thread overview]
Message-ID: <20071110143332.72b84119@shemminger-laptop> (raw)
In-Reply-To: <200711101922.19004.florian.fainelli@telecomint.eu>


> +static int __devinit r6040_init_one(struct pci_dev *pdev,
> +					 const struct pci_device_id *ent)
> +{
> +	struct net_device *dev;
> +	struct r6040_private *lp;
> +	void __iomem *ioaddr;
> +	int err, io_size = R6040_IO_SIZE;
> +	static int card_idx = -1;
> +	int bar = 0;
> +	long pioaddr;
> +
> +	printk(KERN_INFO "%s\n", version);
> +
> +	err = pci_enable_device(pdev);
> +	if (err)
> +		return err;
> +
> +	/* this should always be supported */
> +	if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
> +		printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses"
> +				"not supported by the card\n");
> +		return -ENODEV;
> +	}
> +
> +	/* IO Size check */
> +	if (pci_resource_len(pdev, 0) < io_size) {
> +		printk(KERN_ERR "Insufficient PCI resources, aborting\n");
> +		return -EIO;
> +	}
> +
> +	pioaddr = pci_resource_start(pdev, 0);	/* IO map base address */
> +	pci_set_master(pdev);
> +
> +	dev = alloc_etherdev(sizeof(struct r6040_private));
> +	if (!dev) {
> +		printk(KERN_ERR "Failed to allocate etherdev\n");
> +		return -ENOMEM;
> +	}
> +	SET_NETDEV_DEV(dev, &pdev->dev);
> +	lp = netdev_priv(dev);
> +	lp->pdev = pdev;
> +
> +	if (pci_request_regions(pdev, DRV_NAME)) {
> +		printk(KERN_ERR DRV_NAME ": Failed to request PCI regions\n");
> +		err = -ENODEV;
> +		goto err_out_disable;
> +	}
> +
> +	ioaddr = pci_iomap(pdev, bar, io_size);
> +	if (!ioaddr) {
> +		printk(KERN_ERR "ioremap failed for device %s\n",
> +			pci_name(pdev));
> +		return -EIO;
> +	}
> +
> +	/* Init system & device */
> +	dev->base_addr = (unsigned long)ioaddr;
> +	lp->base = ioaddr;
> +	dev->irq = pdev->irq;
> +
> +	spin_lock_init(&lp->lock);
> +	pci_set_drvdata(pdev, dev);
> +
> +	/* Set MAC address */
> +	card_idx++;
> +
> +	/* Check if the MAC address is 0xFFFFFFFFFFFF or 0 */
> +	if (!is_valid_ether_addr(dev->dev_addr)) {
> +		u16 *adrp;
> +		adrp = (u16 *) dev->dev_addr;
> +		adrp[0] = ioread16(ioaddr + MID_0L);
> +		adrp[1] = ioread16(ioaddr + MID_0M);
> +		adrp[2] = ioread16(ioaddr + MID_0H);
> +	}


The is_valid_ether_addr is superflous.
 dev->dev_addr will always be zero (since it is part of just allocated structure).

  reply	other threads:[~2007-11-10 19:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-29 21:51 [PATCH][RFC] Add support for the RDC R6040 Fast Ethernet controller Florian Fainelli
2007-10-30  8:29 ` Ilpo Järvinen
2007-10-31  8:57 ` Jeff Garzik
2007-10-31 16:07 ` Stephen Hemminger
2007-11-10 18:22 ` [PATCH][RFC take 2] " Florian Fainelli
2007-11-10 19:33   ` Stephen Hemminger [this message]
2007-11-13 19:09   ` Stephen Hemminger

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=20071110143332.72b84119@shemminger-laptop \
    --to=shemminger@linux-foundation.org \
    --cc=florian.fainelli@telecomint.eu \
    --cc=jeff@garzik.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).