Subject: Re: [PATCH net-next 5/9] net: constify netdev->dev_addr

From: kernel test robot <[email-masked]>
Date: Thu, 18 Nov 2021 14:15:56 +0800

Hi Jakub,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jakub-Kicinski/net-constify-netdev-dev_addr/20211118-121649
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 75082e7f46809432131749f4ecea66864d0f7438
config: m68k-defconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/ea5373ba01c0915c0dceb67e2df2b05343642b84
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jakub-Kicinski/net-constify-netdev-dev_addr/20211118-121649
        git checkout ea5373ba01c0915c0dceb67e2df2b05343642b84
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=m68k 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/8390/mac8390.c: In function 'mac8390_rsrc_init':
>> drivers/net/ethernet/8390/mac8390.c:317:31: warning: passing argument 1 of 'nubus_get_rsrc_mem' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     317 |         nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
         |                            ~~~^~~~~~~~~~
   In file included from drivers/net/ethernet/8390/mac8390.c:29:
   include/linux/nubus.h:156:31: note: expected 'void *' but argument is of type 'const unsigned char *'
     156 | void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent,
         |                         ~~~~~~^~~~
--
   drivers/net/ethernet/amd/atarilance.c:370:28: warning: no previous prototype for 'atarilance_probe' [-Wmissing-prototypes]
     370 | struct net_device * __init atarilance_probe(void)
         |                            ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/amd/atarilance.c: In function 'lance_probe1':
>> drivers/net/ethernet/amd/atarilance.c:588:33: warning: passing argument 1 of 'lp->memcpy_f' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     588 |                 lp->memcpy_f(dev->dev_addr, RIEBL_HWADDR_ADDR, ETH_ALEN);
         |                              ~~~^~~~~~~~~~
   drivers/net/ethernet/amd/atarilance.c:588:33: note: expected 'void *' but argument is of type 'const unsigned char *'
   drivers/net/ethernet/amd/atarilance.c:593:42: error: assignment of read-only location '*(dev->dev_addr + (sizetype)i)'
     593 |                         dev->dev_addr[i] =
         |                                          ^
--
   drivers/net/ethernet/apple/macmace.c: In function 'mace_probe':
   drivers/net/ethernet/apple/macmace.c:232:34: error: assignment of read-only location '*(dev->dev_addr + (sizetype)j)'
     232 |                 dev->dev_addr[j] = v;
         |                                  ^
   drivers/net/ethernet/apple/macmace.c: In function 'mace_reset':
>> drivers/net/ethernet/apple/macmace.c:294:36: warning: passing argument 2 of '__mace_set_address' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     294 |         __mace_set_address(dev, dev->dev_addr);
         |                                 ~~~^~~~~~~~~~
   drivers/net/ethernet/apple/macmace.c:95:62: note: expected 'void *' but argument is of type 'const unsigned char *'
      95 | static void __mace_set_address(struct net_device *dev, void *addr);
         |                                                        ~~~~~~^~~~
   drivers/net/ethernet/apple/macmace.c: In function '__mace_set_address':
   drivers/net/ethernet/apple/macmace.c:334:45: error: assignment of read-only location '*(dev->dev_addr + (sizetype)i)'
     334 |                 mb->padr = dev->dev_addr[i] = p[i];
         |                                             ^
--
   drivers/net/ethernet/natsemi/macsonic.c: In function 'mac_onboard_sonic_ethernet_addr':
   drivers/net/ethernet/natsemi/macsonic.c:216:42: error: assignment of read-only location '*(dev->dev_addr + (sizetype)i)'
     216 |                         dev->dev_addr[i] = SONIC_READ_PROM(i);
         |                                          ^
>> drivers/net/ethernet/natsemi/macsonic.c:225:37: warning: passing argument 1 of 'bit_reverse_addr' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     225 |                 bit_reverse_addr(dev->dev_addr);
         |                                  ~~~^~~~~~~~~~
   drivers/net/ethernet/natsemi/macsonic.c:109:51: note: expected 'unsigned char *' but argument is of type 'const unsigned char *'
     109 | static inline void bit_reverse_addr(unsigned char addr[6])
         |                                     ~~~~~~~~~~~~~~^~~~~~~
   drivers/net/ethernet/natsemi/macsonic.c:246:26: error: assignment of read-only location '*(dev->dev_addr + 5)'
     246 |         dev->dev_addr[5] = val >> 8;
         |                          ^
   drivers/net/ethernet/natsemi/macsonic.c:247:26: error: assignment of read-only location '*(dev->dev_addr + 4)'
     247 |         dev->dev_addr[4] = val & 0xff;
         |                          ^
   drivers/net/ethernet/natsemi/macsonic.c:249:26: error: assignment of read-only location '*(dev->dev_addr + 3)'
     249 |         dev->dev_addr[3] = val >> 8;
         |                          ^
   drivers/net/ethernet/natsemi/macsonic.c:250:26: error: assignment of read-only location '*(dev->dev_addr + 2)'
     250 |         dev->dev_addr[2] = val & 0xff;
         |                          ^
   drivers/net/ethernet/natsemi/macsonic.c:252:26: error: assignment of read-only location '*(dev->dev_addr + 1)'
     252 |         dev->dev_addr[1] = val >> 8;
         |                          ^
   drivers/net/ethernet/natsemi/macsonic.c:253:26: error: assignment of read-only location '*dev->dev_addr'
     253 |         dev->dev_addr[0] = val & 0xff;
         |                          ^
   drivers/net/ethernet/natsemi/macsonic.c: In function 'mac_sonic_nubus_ethernet_addr':
   drivers/net/ethernet/natsemi/macsonic.c:360:34: error: assignment of read-only location '*(dev->dev_addr + (sizetype)i)'
     360 |                 dev->dev_addr[i] = SONIC_READ_PROM(i);
         |                                  ^
   drivers/net/ethernet/natsemi/macsonic.c:364:37: warning: passing argument 1 of 'bit_reverse_addr' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     364 |                 bit_reverse_addr(dev->dev_addr);
         |                                  ~~~^~~~~~~~~~
   drivers/net/ethernet/natsemi/macsonic.c:109:51: note: expected 'unsigned char *' but argument is of type 'const unsigned char *'
     109 | static inline void bit_reverse_addr(unsigned char addr[6])
         |                                     ~~~~~~~~~~~~~~^~~~~~~

vim +317 drivers/net/ethernet/8390/mac8390.c

^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  285  
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  286  static bool mac8390_rsrc_init(struct net_device *dev,
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  287  			      struct nubus_rsrc *fres,
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  288  			      enum mac8390_type cardtype)
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  289  {
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  290  	struct nubus_board *board = fres->board;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  291  	struct nubus_dir dir;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  292  	struct nubus_dirent ent;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  293  	int offset;
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  294  	volatile unsigned short *i;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  295  
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  296  	dev->irq = SLOT2IRQ(board->slot);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  297  	/* This is getting to be a habit */
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  298  	dev->base_addr = board->slot_addr | ((board->slot & 0xf) << 20);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  299  
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  300  	/*
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  301  	 * Get some Nubus info - we will trust the card's idea
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  302  	 * of where its memory and registers are.
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  303  	 */
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  304  
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  305  	if (nubus_get_func_dir(fres, &dir) == -1) {
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  306  		dev_err(&board->dev,
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  307  			"Unable to get Nubus functional directory\n");
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  308  		return false;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  309  	}
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  310  
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  311  	/* Get the MAC address */
8e4d9696b45d96 drivers/net/mac8390.c               Joe Perches    2010-01-04  312  	if (nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent) == -1) {
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  313  		dev_info(&board->dev, "MAC address resource not found\n");
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  314  		return false;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  315  	}
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  316  
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04 @317  	nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  318  
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  319  	if (useresources[cardtype] == 1) {
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  320  		nubus_rewinddir(&dir);
8e4d9696b45d96 drivers/net/mac8390.c               Joe Perches    2010-01-04  321  		if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS,
8e4d9696b45d96 drivers/net/mac8390.c               Joe Perches    2010-01-04  322  				    &ent) == -1) {
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  323  			dev_err(&board->dev,
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  324  				"Memory offset resource not found\n");
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  325  			return false;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  326  		}
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  327  		nubus_get_rsrc_mem(&offset, &ent, 4);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  328  		dev->mem_start = dev->base_addr + offset;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  329  		/* yes, this is how the Apple driver does it */
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  330  		dev->base_addr = dev->mem_start + 0x10000;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  331  		nubus_rewinddir(&dir);
8e4d9696b45d96 drivers/net/mac8390.c               Joe Perches    2010-01-04  332  		if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH,
8e4d9696b45d96 drivers/net/mac8390.c               Joe Perches    2010-01-04  333  				    &ent) == -1) {
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  334  			dev_info(&board->dev,
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  335  				 "Memory length resource not found, probing\n");
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  336  			offset = mac8390_memsize(dev->mem_start);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  337  		} else {
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  338  			nubus_get_rsrc_mem(&offset, &ent, 4);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  339  		}
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  340  		dev->mem_end = dev->mem_start + offset;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  341  	} else {
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  342  		switch (cardtype) {
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  343  		case MAC8390_KINETICS:
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  344  		case MAC8390_DAYNA: /* it's the same */
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  345  			dev->base_addr = (int)(board->slot_addr +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  346  					       DAYNA_8390_BASE);
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  347  			dev->mem_start = (int)(board->slot_addr +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  348  					       DAYNA_8390_MEM);
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  349  			dev->mem_end = dev->mem_start +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  350  				       mac8390_memsize(dev->mem_start);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  351  			break;
2964db0f590437 drivers/net/mac8390.c               Finn Thain     2007-05-01  352  		case MAC8390_INTERLAN:
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  353  			dev->base_addr = (int)(board->slot_addr +
2964db0f590437 drivers/net/mac8390.c               Finn Thain     2007-05-01  354  					       INTERLAN_8390_BASE);
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  355  			dev->mem_start = (int)(board->slot_addr +
2964db0f590437 drivers/net/mac8390.c               Finn Thain     2007-05-01  356  					       INTERLAN_8390_MEM);
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  357  			dev->mem_end = dev->mem_start +
2964db0f590437 drivers/net/mac8390.c               Finn Thain     2007-05-01  358  				       mac8390_memsize(dev->mem_start);
2964db0f590437 drivers/net/mac8390.c               Finn Thain     2007-05-01  359  			break;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  360  		case MAC8390_CABLETRON:
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  361  			dev->base_addr = (int)(board->slot_addr +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  362  					       CABLETRON_8390_BASE);
494a973e229542 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  363  			dev->mem_start = (int)(board->slot_addr +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  364  					       CABLETRON_8390_MEM);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  365  			/* The base address is unreadable if 0x00
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  366  			 * has been written to the command register
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  367  			 * Reset the chip by writing E8390_NODMA +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  368  			 *   E8390_PAGE0 + E8390_STOP just to be
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  369  			 *   sure
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  370  			 */
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  371  			i = (void *)dev->base_addr;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  372  			*i = 0x21;
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  373  			dev->mem_end = dev->mem_start +
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  374  				       mac8390_memsize(dev->mem_start);
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  375  			break;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  376  
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  377  		default:
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  378  			dev_err(&board->dev,
4a1b27c9e32c39 drivers/net/ethernet/8390/mac8390.c Finn Thain     2018-02-18  379  				"No known base address for card type\n");
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  380  			return false;
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  381  		}
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  382  	}
^1da177e4c3f41 drivers/net/mac8390.c               Linus Torvalds 2005-04-16  383  
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  384  	return true;
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  385  }
f6de7acc42de90 drivers/net/mac8390.c               Joe Perches    2010-01-04  386  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]