Skip to content

Commit

Permalink
Merge branch 'ethernet-more-netdev-dev_addr-write-removals'
Browse files Browse the repository at this point in the history
Jakub Kicinski says:

====================
ethernet: more netdev->dev_addr write removals

Another series removing direct writes to netdev->dev_addr.
====================

Link: https://lore.kernel.org/r/20211013204435.322561-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Oct 14, 2021
2 parents 201f1a2 + 923ca6f commit 2b4731b
Show file tree
Hide file tree
Showing 164 changed files with 295 additions and 277 deletions.
5 changes: 3 additions & 2 deletions drivers/net/ethernet/3com/3c515.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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. */
Expand All @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions drivers/net/ethernet/3com/3c574_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/ethernet/3com/3c589_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,15 @@ 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;
size_t len;

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");
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/ethernet/3com/3c59x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/actions/owl-emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static u32 owl_emac_dma_cmd_stop(struct owl_emac_priv *priv)
static void owl_emac_set_hw_mac_addr(struct net_device *netdev)
{
struct owl_emac_priv *priv = netdev_priv(netdev);
u8 *mac_addr = netdev->dev_addr;
const u8 *mac_addr = netdev->dev_addr;
u32 addr_high, addr_low;

addr_high = mac_addr[0] << 8 | mac_addr[1];
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/ethernet/adaptec/starfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ static int netdev_open(struct net_device *dev)
writew(0, ioaddr + PerfFilterTable + 4);
writew(0, ioaddr + PerfFilterTable + 8);
for (i = 1; i < 16; i++) {
__be16 *eaddrs = (__be16 *)dev->dev_addr;
const __be16 *eaddrs = (const __be16 *)dev->dev_addr;
void __iomem *setup_frm = ioaddr + PerfFilterTable + i * 16;
writew(be16_to_cpu(eaddrs[2]), setup_frm); setup_frm += 4;
writew(be16_to_cpu(eaddrs[1]), setup_frm); setup_frm += 4;
Expand Down Expand Up @@ -1787,14 +1787,14 @@ static void set_rx_mode(struct net_device *dev)
} else if (netdev_mc_count(dev) <= 14) {
/* Use the 16 element perfect filter, skip first two entries. */
void __iomem *filter_addr = ioaddr + PerfFilterTable + 2 * 16;
__be16 *eaddrs;
const __be16 *eaddrs;
netdev_for_each_mc_addr(ha, dev) {
eaddrs = (__be16 *) ha->addr;
writew(be16_to_cpu(eaddrs[2]), filter_addr); filter_addr += 4;
writew(be16_to_cpu(eaddrs[1]), filter_addr); filter_addr += 4;
writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 8;
}
eaddrs = (__be16 *)dev->dev_addr;
eaddrs = (const __be16 *)dev->dev_addr;
i = netdev_mc_count(dev) + 2;
while (i++ < 16) {
writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 4;
Expand All @@ -1805,7 +1805,7 @@ static void set_rx_mode(struct net_device *dev)
} else {
/* Must use a multicast hash table. */
void __iomem *filter_addr;
__be16 *eaddrs;
const __be16 *eaddrs;
__le16 mc_filter[32] __attribute__ ((aligned(sizeof(long)))); /* Multicast hash filter */

memset(mc_filter, 0, sizeof(mc_filter));
Expand All @@ -1819,7 +1819,7 @@ static void set_rx_mode(struct net_device *dev)
}
/* Clear the perfect filter list, skip first two entries. */
filter_addr = ioaddr + PerfFilterTable + 2 * 16;
eaddrs = (__be16 *)dev->dev_addr;
eaddrs = (const __be16 *)dev->dev_addr;
for (i = 2; i < 16; i++) {
writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 4;
writew(be16_to_cpu(eaddrs[1]), filter_addr); filter_addr += 4;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/alacritech/slicoss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ static void slic_set_link_autoneg(struct slic_device *sdev)

static void slic_set_mac_address(struct slic_device *sdev)
{
u8 *addr = sdev->netdev->dev_addr;
const u8 *addr = sdev->netdev->dev_addr;
u32 val;

val = addr[5] | addr[4] << 8 | addr[3] << 16 | addr[2] << 24;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/alteon/acenic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2712,15 +2712,15 @@ static int ace_set_mac_addr(struct net_device *dev, void *p)
struct ace_private *ap = netdev_priv(dev);
struct ace_regs __iomem *regs = ap->regs;
struct sockaddr *addr=p;
u8 *da;
const u8 *da;
struct cmd cmd;

if(netif_running(dev))
return -EBUSY;

eth_hw_addr_set(dev, addr->sa_data);

da = (u8 *)dev->dev_addr;
da = (const u8 *)dev->dev_addr;

writel(da[0] << 8 | da[1], &regs->MacAddrHi);
writel((da[2] << 24) | (da[3] << 16) | (da[4] << 8) | da[5],
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/altera/altera_tse_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ static int init_phy(struct net_device *dev)
return 0;
}

static void tse_update_mac_addr(struct altera_tse_private *priv, u8 *addr)
static void tse_update_mac_addr(struct altera_tse_private *priv, const u8 *addr)
{
u32 msb;
u32 lsb;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/amd/nmclan_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ static void mace_write(mace_private *lp, unsigned int ioaddr, int reg,
mace_init
Resets the MACE chip.
---------------------------------------------------------------------------- */
static int mace_init(mace_private *lp, unsigned int ioaddr, char *enet_addr)
static int mace_init(mace_private *lp, unsigned int ioaddr,
const char *enet_addr)
{
int i;
int ct = 0;
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/amd/sun3lance.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ static int __init lance_probe( struct net_device *dev)
unsigned long ioaddr;

struct lance_private *lp;
int i;
static int did_version;
volatile unsigned short *ioaddr_probe;
unsigned short tmp1, tmp2;
Expand Down Expand Up @@ -373,8 +372,7 @@ static int __init lance_probe( struct net_device *dev)
dev->irq);

/* copy in the ethernet address from the prom */
for(i = 0; i < 6 ; i++)
dev->dev_addr[i] = idprom->id_ethaddr[i];
eth_hw_addr_set(dev, idprom->id_ethaddr);

/* tell the card it's ether address, bytes swapped */
MEM->init.hwaddr[0] = dev->dev_addr[1];
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/amd/sunlance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,6 @@ static int sparc_lance_probe_one(struct platform_device *op,
struct device_node *dp = op->dev.of_node;
struct lance_private *lp;
struct net_device *dev;
int i;

dev = alloc_etherdev(sizeof(struct lance_private) + 8);
if (!dev)
Expand All @@ -1315,8 +1314,7 @@ static int sparc_lance_probe_one(struct platform_device *op,
* will copy the address in the device structure to the lance
* initialization block.
*/
for (i = 0; i < 6; i++)
dev->dev_addr[i] = idprom->id_ethaddr[i];
eth_hw_addr_set(dev, idprom->id_ethaddr);

/* Get the IO region */
lp->lregs = of_ioremap(&op->resource[0], 0,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/amd/xgbe/xgbe-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ static int xgbe_add_mac_addresses(struct xgbe_prv_data *pdata)
return 0;
}

static int xgbe_set_mac_address(struct xgbe_prv_data *pdata, u8 *addr)
static int xgbe_set_mac_address(struct xgbe_prv_data *pdata, const u8 *addr)
{
unsigned int mac_addr_hi, mac_addr_lo;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/amd/xgbe/xgbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ struct xgbe_ext_stats {
struct xgbe_hw_if {
int (*tx_complete)(struct xgbe_ring_desc *);

int (*set_mac_address)(struct xgbe_prv_data *, u8 *addr);
int (*set_mac_address)(struct xgbe_prv_data *, const u8 *addr);
int (*config_rx_mode)(struct xgbe_prv_data *);

int (*enable_rx_csum)(struct xgbe_prv_data *);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/apm/xgene-v2/mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void xge_mac_set_speed(struct xge_pdata *pdata)

void xge_mac_set_station_addr(struct xge_pdata *pdata)
{
u8 *dev_addr = pdata->ndev->dev_addr;
const u8 *dev_addr = pdata->ndev->dev_addr;
u32 addr0, addr1;

addr0 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ u32 xgene_enet_rd_stat(struct xgene_enet_pdata *pdata, u32 rd_addr)

static void xgene_gmac_set_mac_addr(struct xgene_enet_pdata *pdata)
{
const u8 *dev_addr = pdata->ndev->dev_addr;
u32 addr0, addr1;
u8 *dev_addr = pdata->ndev->dev_addr;

addr0 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
(dev_addr[1] << 8) | dev_addr[0];
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ static void xgene_sgmac_reset(struct xgene_enet_pdata *p)

static void xgene_sgmac_set_mac_addr(struct xgene_enet_pdata *p)
{
const u8 *dev_addr = p->ndev->dev_addr;
u32 addr0, addr1;
u8 *dev_addr = p->ndev->dev_addr;

addr0 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
(dev_addr[1] << 8) | dev_addr[0];
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ static void xgene_pcs_reset(struct xgene_enet_pdata *pdata)

static void xgene_xgmac_set_mac_addr(struct xgene_enet_pdata *pdata)
{
const u8 *dev_addr = pdata->ndev->dev_addr;
u32 addr0, addr1;
u8 *dev_addr = pdata->ndev->dev_addr;

addr0 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
(dev_addr[1] << 8) | dev_addr[0];
Expand Down
15 changes: 6 additions & 9 deletions drivers/net/ethernet/apple/bmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ bmac_init_registers(struct net_device *dev)
{
struct bmac_data *bp = netdev_priv(dev);
volatile unsigned short regValue;
unsigned short *pWord16;
const unsigned short *pWord16;
int i;

/* XXDEBUG(("bmac: enter init_registers\n")); */
Expand Down Expand Up @@ -371,7 +371,7 @@ bmac_init_registers(struct net_device *dev)
bmwrite(dev, BHASH1, bp->hash_table_mask[2]); /* bits 47 - 32 */
bmwrite(dev, BHASH0, bp->hash_table_mask[3]); /* bits 63 - 48 */

pWord16 = (unsigned short *)dev->dev_addr;
pWord16 = (const unsigned short *)dev->dev_addr;
bmwrite(dev, MADD0, *pWord16++);
bmwrite(dev, MADD1, *pWord16++);
bmwrite(dev, MADD2, *pWord16);
Expand Down Expand Up @@ -521,19 +521,16 @@ static int bmac_resume(struct macio_dev *mdev)
static int bmac_set_address(struct net_device *dev, void *addr)
{
struct bmac_data *bp = netdev_priv(dev);
unsigned char *p = addr;
unsigned short *pWord16;
const unsigned short *pWord16;
unsigned long flags;
int i;

XXDEBUG(("bmac: enter set_address\n"));
spin_lock_irqsave(&bp->lock, flags);

for (i = 0; i < 6; ++i) {
dev->dev_addr[i] = p[i];
}
eth_hw_addr_set(dev, addr);

/* load up the hardware address */
pWord16 = (unsigned short *)dev->dev_addr;
pWord16 = (const unsigned short *)dev->dev_addr;
bmwrite(dev, MADD0, *pWord16++);
bmwrite(dev, MADD1, *pWord16++);
bmwrite(dev, MADD2, *pWord16);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethernet/aquantia/atlantic/aq_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ struct aq_hw_ops {
int (*hw_ring_tx_head_update)(struct aq_hw_s *self,
struct aq_ring_s *aq_ring);

int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
int (*hw_set_mac_address)(struct aq_hw_s *self, const u8 *mac_addr);

int (*hw_soft_reset)(struct aq_hw_s *self);

Expand All @@ -226,7 +226,7 @@ struct aq_hw_ops {

int (*hw_reset)(struct aq_hw_s *self);

int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
int (*hw_init)(struct aq_hw_s *self, const u8 *mac_addr);

int (*hw_start)(struct aq_hw_s *self);

Expand Down Expand Up @@ -373,7 +373,7 @@ struct aq_fw_ops {
int (*set_phyloopback)(struct aq_hw_s *self, u32 mode, bool enable);

int (*set_power)(struct aq_hw_s *self, unsigned int power_state,
u8 *mac);
const u8 *mac);

int (*send_fw_request)(struct aq_hw_s *self,
const struct hw_fw_request_iface *fw_req,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/aquantia/atlantic/aq_macsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static int aq_apply_macsec_cfg(struct aq_nic_s *nic);
static int aq_apply_secy_cfg(struct aq_nic_s *nic,
const struct macsec_secy *secy);

static void aq_ether_addr_to_mac(u32 mac[2], unsigned char *emac)
static void aq_ether_addr_to_mac(u32 mac[2], const unsigned char *emac)
{
u32 tmp[2] = { 0 };

Expand Down
Loading

0 comments on commit 2b4731b

Please sign in to comment.