Skip to content
Permalink
Browse files
ethernet: constify references to netdev->dev_addr in drivers
This big patch sprinkles const on local variables and
function arguments which may refer to netdev->dev_addr.

Commit 406f42f ("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.

Some of the changes here are not strictly required - const
is sometimes cast off but pointer is not used for writing.
It seems like it's still better to add the const in case
the code changes later or relevant -W flags get enabled
for the build.

No functional changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski authored and intel-lab-lkp committed Oct 13, 2021
1 parent 5f3b8ac commit 6ead16677b0e7c54f6a7679276c70ffa1bbc17f3
Show file tree
Hide file tree
Showing 134 changed files with 202 additions and 187 deletions.
@@ -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];
@@ -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;
@@ -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;
@@ -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));
@@ -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;
@@ -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;
@@ -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],
@@ -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;
@@ -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;
@@ -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;

@@ -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 *);
@@ -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) |
@@ -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];
@@ -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];
@@ -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];
@@ -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")); */
@@ -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);
@@ -522,7 +522,7 @@ 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;

@@ -533,7 +533,7 @@ static int bmac_set_address(struct net_device *dev, void *addr)
dev->dev_addr[i] = p[i];
}
/* 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);
@@ -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);

@@ -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);

@@ -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,
@@ -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 };

@@ -322,7 +322,7 @@ static int hw_atl_a0_hw_init_rx_path(struct aq_hw_s *self)
return aq_hw_err_from_flags(self);
}

static int hw_atl_a0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
static int hw_atl_a0_hw_mac_addr_set(struct aq_hw_s *self, const u8 *mac_addr)
{
unsigned int h = 0U;
unsigned int l = 0U;
@@ -348,7 +348,7 @@ static int hw_atl_a0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
return err;
}

static int hw_atl_a0_hw_init(struct aq_hw_s *self, u8 *mac_addr)
static int hw_atl_a0_hw_init(struct aq_hw_s *self, const u8 *mac_addr)
{
static u32 aq_hw_atl_igcr_table_[4][2] = {
[AQ_HW_IRQ_INVALID] = { 0x20000000U, 0x20000000U },
@@ -533,7 +533,7 @@ static int hw_atl_b0_hw_init_rx_path(struct aq_hw_s *self)
return aq_hw_err_from_flags(self);
}

int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, const u8 *mac_addr)
{
unsigned int h = 0U;
unsigned int l = 0U;
@@ -558,7 +558,7 @@ int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr)
return err;
}

static int hw_atl_b0_hw_init(struct aq_hw_s *self, u8 *mac_addr)
static int hw_atl_b0_hw_init(struct aq_hw_s *self, const u8 *mac_addr)
{
static u32 aq_hw_atl_igcr_table_[4][2] = {
[AQ_HW_IRQ_INVALID] = { 0x20000000U, 0x20000000U },
@@ -58,7 +58,7 @@ int hw_atl_b0_hw_ring_rx_stop(struct aq_hw_s *self, struct aq_ring_s *ring);

void hw_atl_b0_hw_init_rx_rss_ctrl1(struct aq_hw_s *self);

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

int hw_atl_b0_set_fc(struct aq_hw_s *self, u32 fc, u32 tc);
int hw_atl_b0_set_loopback(struct aq_hw_s *self, u32 mode, bool enable);
@@ -944,7 +944,7 @@ u32 hw_atl_utils_get_fw_version(struct aq_hw_s *self)
}

static int aq_fw1x_set_wake_magic(struct aq_hw_s *self, bool wol_enabled,
u8 *mac)
const u8 *mac)
{
struct hw_atl_utils_fw_rpc *prpc = NULL;
unsigned int rpc_size = 0U;
@@ -987,7 +987,7 @@ static int aq_fw1x_set_wake_magic(struct aq_hw_s *self, bool wol_enabled,
}

static int aq_fw1x_set_power(struct aq_hw_s *self, unsigned int power_state,
u8 *mac)
const u8 *mac)
{
struct hw_atl_utils_fw_rpc *prpc = NULL;
unsigned int rpc_size = 0U;
@@ -358,7 +358,7 @@ static int aq_fw2x_get_phy_temp(struct aq_hw_s *self, int *temp)
return 0;
}

static int aq_fw2x_set_wol(struct aq_hw_s *self, u8 *mac)
static int aq_fw2x_set_wol(struct aq_hw_s *self, const u8 *mac)
{
struct hw_atl_utils_fw_rpc *rpc = NULL;
struct offload_info *info = NULL;
@@ -404,7 +404,7 @@ static int aq_fw2x_set_wol(struct aq_hw_s *self, u8 *mac)
}

static int aq_fw2x_set_power(struct aq_hw_s *self, unsigned int power_state,
u8 *mac)
const u8 *mac)
{
int err = 0;

@@ -516,7 +516,7 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)
return aq_hw_err_from_flags(self);
}

static int hw_atl2_hw_init(struct aq_hw_s *self, u8 *mac_addr)
static int hw_atl2_hw_init(struct aq_hw_s *self, const u8 *mac_addr)
{
static u32 aq_hw_atl2_igcr_table_[4][2] = {
[AQ_HW_IRQ_INVALID] = { 0x20000000U, 0x20000000U },
@@ -218,7 +218,8 @@ static inline void __b44_cam_read(struct b44 *bp, unsigned char *data, int index
data[1] = (val >> 0) & 0xFF;
}

static inline void __b44_cam_write(struct b44 *bp, unsigned char *data, int index)
static inline void __b44_cam_write(struct b44 *bp,
const unsigned char *data, int index)
{
u32 val;

@@ -1507,7 +1508,8 @@ static void bwfilter_table(struct b44 *bp, u8 *pp, u32 bytes, u32 table_offset)
}
}

static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
static int b44_magic_pattern(const u8 *macaddr, u8 *ppattern, u8 *pmask,
int offset)
{
int magicsync = 6;
int k, j, len = offset;
@@ -1818,7 +1818,7 @@ static inline void umac_reset(struct bcm_sysport_priv *priv)
}

static void umac_set_hw_addr(struct bcm_sysport_priv *priv,
unsigned char *addr)
const unsigned char *addr)
{
u32 mac0 = (addr[0] << 24) | (addr[1] << 16) | (addr[2] << 8) |
addr[3];
@@ -768,7 +768,7 @@ static void bgmac_umac_cmd_maskset(struct bgmac *bgmac, u32 mask, u32 set,
udelay(2);
}

static void bgmac_write_mac_address(struct bgmac *bgmac, u8 *addr)
static void bgmac_write_mac_address(struct bgmac *bgmac, const u8 *addr)
{
u32 tmp;

@@ -2704,7 +2704,7 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp)
}

static void
bnx2_set_mac_addr(struct bnx2 *bp, u8 *mac_addr, u32 pos)
bnx2_set_mac_addr(struct bnx2 *bp, const u8 *mac_addr, u32 pos)
{
u32 val;

@@ -1994,7 +1994,7 @@ int bnx2x_idle_chk(struct bnx2x *bp);
* operation has been successfully scheduled and a negative - if a requested
* operations has failed.
*/
int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
int bnx2x_set_mac_one(struct bnx2x *bp, const u8 *mac,
struct bnx2x_vlan_mac_obj *obj, bool set,
int mac_type, unsigned long *ramrod_flags);

@@ -8417,7 +8417,7 @@ int bnx2x_alloc_mem(struct bnx2x *bp)
* Init service functions
*/

int bnx2x_set_mac_one(struct bnx2x *bp, u8 *mac,
int bnx2x_set_mac_one(struct bnx2x *bp, const u8 *mac,
struct bnx2x_vlan_mac_obj *obj, bool set,
int mac_type, unsigned long *ramrod_flags)
{
@@ -9146,7 +9146,7 @@ u32 bnx2x_send_unload_req(struct bnx2x *bp, int unload_mode)

else if (bp->wol) {
u32 emac_base = port ? GRCBASE_EMAC1 : GRCBASE_EMAC0;
u8 *mac_addr = bp->dev->dev_addr;
const u8 *mac_addr = bp->dev->dev_addr;
struct pci_dev *pdev = bp->pdev;
u32 val;
u16 pmc;

0 comments on commit 6ead166

Please sign in to comment.