Commit 923ca6f6 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

ethernet: replace netdev->dev_addr 16bit writes



Commit 406f42fa ("net-next: When a bond have a massive amount
of VLANs...") introduced a rbtree for faster Ethernet address look
up. To maintain netdev->dev_addr in this tree we need to make all
the writes to it got through appropriate helpers.

This patch takes care of drivers which cast netdev->dev_addr to
a 16bit type, often with an explicit byte order.

Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 562ef98a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -567,6 +567,7 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
{
	struct corkscrew_private *vp = netdev_priv(dev);
	unsigned int eeprom[0x40], checksum = 0;	/* EEPROM contents */
	__be16 addr[ETH_ALEN / 2];
	int i;
	int irq;

@@ -619,7 +620,6 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
	/* Read the station address from the EEPROM. */
	EL3WINDOW(0);
	for (i = 0; i < 0x18; i++) {
		__be16 *phys_addr = (__be16 *) dev->dev_addr;
		int timer;
		outw(EEPROM_Read + i, ioaddr + Wn0EepromCmd);
		/* Pause for at least 162 us. for the read to take place. */
@@ -631,8 +631,9 @@ static int corkscrew_setup(struct net_device *dev, int ioaddr,
		eeprom[i] = inw(ioaddr + Wn0EepromData);
		checksum ^= eeprom[i];
		if (i < 3)
			phys_addr[i] = htons(eeprom[i]);
			addr[i] = htons(eeprom[i]);
	}
	eth_hw_addr_set(dev, (u8 *)addr);
	checksum = (checksum ^ (checksum >> 8)) & 0xff;
	if (checksum != 0x00)
		pr_cont(" ***INVALID CHECKSUM %4.4x*** ", checksum);
+5 −6
Original line number Diff line number Diff line
@@ -305,15 +305,13 @@ static int tc574_config(struct pcmcia_device *link)
	struct net_device *dev = link->priv;
	struct el3_private *lp = netdev_priv(dev);
	int ret, i, j;
	__be16 addr[ETH_ALEN / 2];
	unsigned int ioaddr;
	__be16 *phys_addr;
	char *cardname;
	__u32 config;
	u8 *buf;
	size_t len;

	phys_addr = (__be16 *)dev->dev_addr;

	dev_dbg(&link->dev, "3c574_config()\n");

	link->io_lines = 16;
@@ -347,19 +345,20 @@ static int tc574_config(struct pcmcia_device *link)
	len = pcmcia_get_tuple(link, 0x88, &buf);
	if (buf && len >= 6) {
		for (i = 0; i < 3; i++)
			phys_addr[i] = htons(le16_to_cpu(buf[i * 2]));
			addr[i] = htons(le16_to_cpu(buf[i * 2]));
		kfree(buf);
	} else {
		kfree(buf); /* 0 < len < 6 */
		EL3WINDOW(0);
		for (i = 0; i < 3; i++)
			phys_addr[i] = htons(read_eeprom(ioaddr, i + 10));
		if (phys_addr[0] == htons(0x6060)) {
			addr[i] = htons(read_eeprom(ioaddr, i + 10));
		if (addr[0] == htons(0x6060)) {
			pr_notice("IO port conflict at 0x%03lx-0x%03lx\n",
				  dev->base_addr, dev->base_addr+15);
			goto failed;
		}
	}
	eth_hw_addr_set(dev, (u8 *)addr);
	if (link->prod_id[1])
		cardname = link->prod_id[1];
	else
+5 −5
Original line number Diff line number Diff line
@@ -237,8 +237,8 @@ static void tc589_detach(struct pcmcia_device *link)
static int tc589_config(struct pcmcia_device *link)
{
	struct net_device *dev = link->priv;
	__be16 *phys_addr;
	int ret, i, j, multi = 0, fifo;
	__be16 addr[ETH_ALEN / 2];
	unsigned int ioaddr;
	static const char * const ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
	u8 *buf;
@@ -246,7 +246,6 @@ static int tc589_config(struct pcmcia_device *link)

	dev_dbg(&link->dev, "3c589_config\n");

	phys_addr = (__be16 *)dev->dev_addr;
	/* Is this a 3c562? */
	if (link->manf_id != MANFID_3COM)
		dev_info(&link->dev, "hmmm, is this really a 3Com card??\n");
@@ -285,18 +284,19 @@ static int tc589_config(struct pcmcia_device *link)
	len = pcmcia_get_tuple(link, 0x88, &buf);
	if (buf && len >= 6) {
		for (i = 0; i < 3; i++)
			phys_addr[i] = htons(le16_to_cpu(buf[i*2]));
			addr[i] = htons(le16_to_cpu(buf[i*2]));
		kfree(buf);
	} else {
		kfree(buf); /* 0 < len < 6 */
		for (i = 0; i < 3; i++)
			phys_addr[i] = htons(read_eeprom(ioaddr, i));
		if (phys_addr[0] == htons(0x6060)) {
			addr[i] = htons(read_eeprom(ioaddr, i));
		if (addr[0] == htons(0x6060)) {
			dev_err(&link->dev, "IO port conflict at 0x%03lx-0x%03lx\n",
					dev->base_addr, dev->base_addr+15);
			goto failed;
		}
	}
	eth_hw_addr_set(dev, (u8 *)addr);

	/* The address and resource configuration register aren't loaded from
	 * the EEPROM and *must* be set to 0 and IRQ3 for the PCMCIA version.
+3 −1
Original line number Diff line number Diff line
@@ -1091,6 +1091,7 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
	struct vortex_private *vp;
	int option;
	unsigned int eeprom[0x40], checksum = 0;		/* EEPROM contents */
	__be16 addr[ETH_ALEN / 2];
	int i, step;
	struct net_device *dev;
	static int printed_version;
@@ -1284,7 +1285,8 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
	if ((checksum != 0x00) && !(vci->drv_flags & IS_TORNADO))
		pr_cont(" ***INVALID CHECKSUM %4.4x*** ", checksum);
	for (i = 0; i < 3; i++)
		((__be16 *)dev->dev_addr)[i] = htons(eeprom[i + 10]);
		addr[i] = htons(eeprom[i + 10]);
	eth_hw_addr_set(dev, (u8 *)addr);
	if (print_info)
		pr_cont(" %pM", dev->dev_addr);
	/* Unfortunately an all zero eeprom passes the checksum and this
+3 −1
Original line number Diff line number Diff line
@@ -355,6 +355,7 @@ static int w840_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
	int chip_idx = ent->driver_data;
	int irq;
	int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
	__le16 addr[ETH_ALEN / 2];
	void __iomem *ioaddr;

	i = pcim_enable_device(pdev);
@@ -382,7 +383,8 @@ static int w840_probe1(struct pci_dev *pdev, const struct pci_device_id *ent)
		goto err_out_netdev;

	for (i = 0; i < 3; i++)
		((__le16 *)dev->dev_addr)[i] = cpu_to_le16(eeprom_read(ioaddr, i));
		addr[i] = cpu_to_le16(eeprom_read(ioaddr, i));
	eth_hw_addr_set(dev, (u8 *)addr);

	/* Reset the chip to erase previous misconfiguration.
	   No hold time required! */
Loading