diff mbox series

[v1] netdevice: use ifmap isteand of plain fields

Message ID 20230303150818.132386-1-vincenzopalazzodev@gmail.com
State Handled Elsewhere
Headers show
Series [v1] netdevice: use ifmap isteand of plain fields | expand

Commit Message

Vincenzo Palazzo March 3, 2023, 3:08 p.m. UTC
clean the code by using the ifmap instead of plain fields,
and avoid code duplication.

P.S: I'm giving credit to the author of the FIXME commit.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c |  4 ++--
 include/linux/netdevice.h                  |  8 +-------
 net/core/dev_ioctl.c                       | 12 ++++++------
 net/core/rtnetlink.c                       |  6 +++---
 4 files changed, 12 insertions(+), 18 deletions(-)

Comments

Paul Menzel March 3, 2023, 4:48 p.m. UTC | #1
Dear Vincenzo,


Thank you for your patch. There is a small typo in the commit message 
summary in *instead*.

Am 03.03.23 um 16:08 schrieb Vincenzo Palazzo:
> clean the code by using the ifmap instead of plain fields,
> and avoid code duplication.
> 
> P.S: I'm giving credit to the author of the FIXME commit.

No idea, what you mean exactly, but you can do that by adding From: in 
the first line of the commit message body.


Kind regards,

Paul


> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
> ---
>   drivers/net/ethernet/intel/e1000e/netdev.c |  4 ++--
>   include/linux/netdevice.h                  |  8 +-------
>   net/core/dev_ioctl.c                       | 12 ++++++------
>   net/core/rtnetlink.c                       |  6 +++---
>   4 files changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
> index e1eb1de88bf9..059ff8bcdbbc 100644
> --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> @@ -7476,8 +7476,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	netif_napi_add(netdev, &adapter->napi, e1000e_poll);
>   	strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
>   
> -	netdev->mem_start = mmio_start;
> -	netdev->mem_end = mmio_start + mmio_len;
> +	netdev->dev_mapping.mem_start = mmio_start;
> +	netdev->dev_mapping.mem_end = mmio_start + mmio_len;
>   
>   	adapter->bd_number = cards_found++;
>   
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 6a14b7b11766..c5987e90a078 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2031,13 +2031,7 @@ struct net_device {
>   	char			name[IFNAMSIZ];
>   	struct netdev_name_node	*name_node;
>   	struct dev_ifalias	__rcu *ifalias;
> -	/*
> -	 *	I/O specific fields
> -	 *	FIXME: Merge these and struct ifmap into one
> -	 */
> -	unsigned long		mem_end;
> -	unsigned long		mem_start;
> -	unsigned long		base_addr;
> +	struct ifmap dev_mapping;
>   
>   	/*
>   	 *	Some hardware also needs these fields (state,dev_list,
> diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
> index 5cdbfbf9a7dc..89469cb97e35 100644
> --- a/net/core/dev_ioctl.c
> +++ b/net/core/dev_ioctl.c
> @@ -88,9 +88,9 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
>   	if (in_compat_syscall()) {
>   		struct compat_ifmap *cifmap = (struct compat_ifmap *)ifmap;
>   
> -		cifmap->mem_start = dev->mem_start;
> -		cifmap->mem_end   = dev->mem_end;
> -		cifmap->base_addr = dev->base_addr;
> +		cifmap->mem_start = dev->dev_mapping.mem_start;
> +		cifmap->mem_end   = dev->dev_mapping.mem_end;
> +		cifmap->base_addr = dev->dev_mapping.base_addr;
>   		cifmap->irq       = dev->irq;
>   		cifmap->dma       = dev->dma;
>   		cifmap->port      = dev->if_port;
> @@ -98,9 +98,9 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
>   		return 0;
>   	}
>   
> -	ifmap->mem_start  = dev->mem_start;
> -	ifmap->mem_end    = dev->mem_end;
> -	ifmap->base_addr  = dev->base_addr;
> +	ifmap->mem_start  = dev->dev_mapping.mem_start;
> +	ifmap->mem_end    = dev->dev_mapping.mem_end;
> +	ifmap->base_addr  = dev->dev_mapping.base_addr;
>   	ifmap->irq        = dev->irq;
>   	ifmap->dma        = dev->dma;
>   	ifmap->port       = dev->if_port;
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 5d8eb57867a9..ff8fc1bbda31 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1445,9 +1445,9 @@ static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)
>   	struct rtnl_link_ifmap map;
>   
>   	memset(&map, 0, sizeof(map));
> -	map.mem_start   = dev->mem_start;
> -	map.mem_end     = dev->mem_end;
> -	map.base_addr   = dev->base_addr;
> +	map.mem_start   = dev->dev_mapping.mem_start;
> +	map.mem_end     = dev->dev_mapping.mem_end;
> +	map.base_addr   = dev->dev_mapping.base_addr;
>   	map.irq         = dev->irq;
>   	map.dma         = dev->dma;
>   	map.port        = dev->if_port;
Linus Torvalds March 3, 2023, 5:15 p.m. UTC | #2
On Fri, Mar 3, 2023 at 7:09 AM Vincenzo Palazzo
<vincenzopalazzodev@gmail.com> wrote:
>
> P.S: I'm giving credit to the author of the FIXME commit.

That isn't actually me.

Yes, 'git blame' claims it's me, but that's just because the comment
goes back to the original git import.

In fact, it goes back even to before the BitKeeper days, so it goes
back to some time before 2002. It might be discoverable through some
old networking code CVS tree or trawling old newsgroups for the
original patch before 2002 or something like that, but that's more
archaeology than I'm willing to do.

               Linus
Vincenzo Palazzo March 3, 2023, 6:01 p.m. UTC | #3
On Fri Mar 3, 2023 at 5:48 PM CET, Paul Menzel wrote:
> Dear Vincenzo,
>
>
> Thank you for your patch. There is a small typo in the commit message 
> summary in *instead*.
>
Ah, I also tried to pay attention to avoid typo! Sorry, I will made a v2.

> Am 03.03.23 um 16:08 schrieb Vincenzo Palazzo:
> > clean the code by using the ifmap instead of plain fields,
> > and avoid code duplication.
> > 
> > P.S: I'm giving credit to the author of the FIXME commit.
>
> No idea, what you mean exactly, but you can do that by adding From: in 
> the first line of the commit message body.
>

I ran git blame to find the comment author because the 
refactoring was suggested by the FIXME, but it turn out that was a very
historical one (before git) as Linus point out git blame is wrong in
this case. I will also fix this in the v2

Cheers!

Vincent.


>
> > Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> > Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
> > ---
> >   drivers/net/ethernet/intel/e1000e/netdev.c |  4 ++--
> >   include/linux/netdevice.h                  |  8 +-------
> >   net/core/dev_ioctl.c                       | 12 ++++++------
> >   net/core/rtnetlink.c                       |  6 +++---
> >   4 files changed, 12 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
> > index e1eb1de88bf9..059ff8bcdbbc 100644
> > --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> > +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> > @@ -7476,8 +7476,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >   	netif_napi_add(netdev, &adapter->napi, e1000e_poll);
> >   	strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
> >   
> > -	netdev->mem_start = mmio_start;
> > -	netdev->mem_end = mmio_start + mmio_len;
> > +	netdev->dev_mapping.mem_start = mmio_start;
> > +	netdev->dev_mapping.mem_end = mmio_start + mmio_len;
> >   
> >   	adapter->bd_number = cards_found++;
> >   
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index 6a14b7b11766..c5987e90a078 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2031,13 +2031,7 @@ struct net_device {
> >   	char			name[IFNAMSIZ];
> >   	struct netdev_name_node	*name_node;
> >   	struct dev_ifalias	__rcu *ifalias;
> > -	/*
> > -	 *	I/O specific fields
> > -	 *	FIXME: Merge these and struct ifmap into one
> > -	 */
> > -	unsigned long		mem_end;
> > -	unsigned long		mem_start;
> > -	unsigned long		base_addr;
> > +	struct ifmap dev_mapping;
> >   
> >   	/*
> >   	 *	Some hardware also needs these fields (state,dev_list,
> > diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
> > index 5cdbfbf9a7dc..89469cb97e35 100644
> > --- a/net/core/dev_ioctl.c
> > +++ b/net/core/dev_ioctl.c
> > @@ -88,9 +88,9 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
> >   	if (in_compat_syscall()) {
> >   		struct compat_ifmap *cifmap = (struct compat_ifmap *)ifmap;
> >   
> > -		cifmap->mem_start = dev->mem_start;
> > -		cifmap->mem_end   = dev->mem_end;
> > -		cifmap->base_addr = dev->base_addr;
> > +		cifmap->mem_start = dev->dev_mapping.mem_start;
> > +		cifmap->mem_end   = dev->dev_mapping.mem_end;
> > +		cifmap->base_addr = dev->dev_mapping.base_addr;
> >   		cifmap->irq       = dev->irq;
> >   		cifmap->dma       = dev->dma;
> >   		cifmap->port      = dev->if_port;
> > @@ -98,9 +98,9 @@ static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
> >   		return 0;
> >   	}
> >   
> > -	ifmap->mem_start  = dev->mem_start;
> > -	ifmap->mem_end    = dev->mem_end;
> > -	ifmap->base_addr  = dev->base_addr;
> > +	ifmap->mem_start  = dev->dev_mapping.mem_start;
> > +	ifmap->mem_end    = dev->dev_mapping.mem_end;
> > +	ifmap->base_addr  = dev->dev_mapping.base_addr;
> >   	ifmap->irq        = dev->irq;
> >   	ifmap->dma        = dev->dma;
> >   	ifmap->port       = dev->if_port;
> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> > index 5d8eb57867a9..ff8fc1bbda31 100644
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -1445,9 +1445,9 @@ static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)
> >   	struct rtnl_link_ifmap map;
> >   
> >   	memset(&map, 0, sizeof(map));
> > -	map.mem_start   = dev->mem_start;
> > -	map.mem_end     = dev->mem_end;
> > -	map.base_addr   = dev->base_addr;
> > +	map.mem_start   = dev->dev_mapping.mem_start;
> > +	map.mem_end     = dev->dev_mapping.mem_end;
> > +	map.base_addr   = dev->dev_mapping.base_addr;
> >   	map.irq         = dev->irq;
> >   	map.dma         = dev->dma;
> >   	map.port        = dev->if_port;
kernel test robot March 3, 2023, 7:46 p.m. UTC | #4
Hi Vincenzo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on net-next/master horms-ipvs/master linus/master v6.2 next-20230303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vincenzo-Palazzo/netdevice-use-ifmap-isteand-of-plain-fields/20230303-231003
patch link:    https://lore.kernel.org/r/20230303150818.132386-1-vincenzopalazzodev%40gmail.com
patch subject: [PATCH v1] netdevice: use ifmap isteand of plain fields
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20230304/202303040357.BP5TQ4vl-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/4efa870f9b2112fdebe7d1fffe30f5626b8d5229
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Vincenzo-Palazzo/netdevice-use-ifmap-isteand-of-plain-fields/20230303-231003
        git checkout 4efa870f9b2112fdebe7d1fffe30f5626b8d5229
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303040357.BP5TQ4vl-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/hamradio/baycom_epp.c: In function 'epp_open':
>> drivers/net/hamradio/baycom_epp.c:818:51: error: 'struct net_device' has no member named 'base_addr'
     818 |         struct parport *pp = parport_find_base(dev->base_addr);
         |                                                   ^~
   In file included from include/linux/kernel.h:29,
                    from include/linux/cpumask.h:10,
                    from include/linux/mm_types_task.h:14,
                    from include/linux/mm_types.h:5,
                    from include/linux/buildid.h:5,
                    from include/linux/module.h:14,
                    from drivers/net/hamradio/baycom_epp.c:29:
   drivers/net/hamradio/baycom_epp.c:826:82: error: 'struct net_device' has no member named 'base_addr'
     826 |                 printk(KERN_ERR "%s: parport at 0x%lx unknown\n", bc_drvname, dev->base_addr);
         |                                                                                  ^~
   include/linux/printk.h:427:33: note: in definition of macro 'printk_index_wrap'
     427 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                                 ^~~~~~~~~~~
   drivers/net/hamradio/baycom_epp.c:826:17: note: in expansion of macro 'printk'
     826 |                 printk(KERN_ERR "%s: parport at 0x%lx unknown\n", bc_drvname, dev->base_addr);
         |                 ^~~~~~
   drivers/net/hamradio/baycom_epp.c: In function 'epp_close':
   drivers/net/hamradio/baycom_epp.c:961:31: error: 'struct net_device' has no member named 'base_addr'
     961 |                bc_drvname, dev->base_addr, dev->irq);
         |                               ^~
   include/linux/printk.h:427:33: note: in definition of macro 'printk_index_wrap'
     427 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                                 ^~~~~~~~~~~
   drivers/net/hamradio/baycom_epp.c:960:9: note: in expansion of macro 'printk'
     960 |         printk(KERN_INFO "%s: close epp at iobase 0x%lx irq %u\n",
         |         ^~~~~~
   drivers/net/hamradio/baycom_epp.c: In function 'baycom_siocdevprivate':
   drivers/net/hamradio/baycom_epp.c:1037:40: error: 'struct net_device' has no member named 'base_addr'
    1037 |                 hi.data.mp.iobase = dev->base_addr;
         |                                        ^~
   drivers/net/hamradio/baycom_epp.c:1049:20: error: 'struct net_device' has no member named 'base_addr'
    1049 |                 dev->base_addr = hi.data.mp.iobase;
         |                    ^~
   drivers/net/hamradio/baycom_epp.c: In function 'init_baycomepp':
   drivers/net/hamradio/baycom_epp.c:1242:20: error: 'struct net_device' has no member named 'base_addr'
    1242 |                 dev->base_addr = iobase[i];
         |                    ^~
--
   drivers/net/ethernet/8390/stnic.c: In function 'STNIC_DELAY':
   drivers/net/ethernet/8390/stnic.c:81:9: warning: variable 'trash' set but not used [-Wunused-but-set-variable]
      81 |   vword trash;
         |         ^~~~~
   drivers/net/ethernet/8390/stnic.c: In function 'stnic_probe':
>> drivers/net/ethernet/8390/stnic.c:125:6: error: 'struct net_device' has no member named 'base_addr'
     125 |   dev->base_addr = 0x1000;
         |      ^~


vim +818 drivers/net/hamradio/baycom_epp.c

^1da177e4c3f41 Linus Torvalds         2005-04-16  805  
^1da177e4c3f41 Linus Torvalds         2005-04-16  806  /*
^1da177e4c3f41 Linus Torvalds         2005-04-16  807   * Open/initialize the board. This is called (in the current kernel)
^1da177e4c3f41 Linus Torvalds         2005-04-16  808   * sometime after booting when the 'ifconfig' program is run.
^1da177e4c3f41 Linus Torvalds         2005-04-16  809   *
^1da177e4c3f41 Linus Torvalds         2005-04-16  810   * This routine should set everything up anew at each open, even
^1da177e4c3f41 Linus Torvalds         2005-04-16  811   * registers that "should" only need to be set once at boot, so that
^1da177e4c3f41 Linus Torvalds         2005-04-16  812   * there is non-reboot way to recover if something goes wrong.
^1da177e4c3f41 Linus Torvalds         2005-04-16  813   */
^1da177e4c3f41 Linus Torvalds         2005-04-16  814  
^1da177e4c3f41 Linus Torvalds         2005-04-16  815  static int epp_open(struct net_device *dev)
^1da177e4c3f41 Linus Torvalds         2005-04-16  816  {
^1da177e4c3f41 Linus Torvalds         2005-04-16  817  	struct baycom_state *bc = netdev_priv(dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16 @818          struct parport *pp = parport_find_base(dev->base_addr);
^1da177e4c3f41 Linus Torvalds         2005-04-16  819  	unsigned int i, j;
^1da177e4c3f41 Linus Torvalds         2005-04-16  820  	unsigned char tmp[128];
^1da177e4c3f41 Linus Torvalds         2005-04-16  821  	unsigned char stat;
^1da177e4c3f41 Linus Torvalds         2005-04-16  822  	unsigned long tstart;
ca444073a2de97 Sudip Mukherjee        2017-09-17  823  	struct pardev_cb par_cb;
^1da177e4c3f41 Linus Torvalds         2005-04-16  824  	
^1da177e4c3f41 Linus Torvalds         2005-04-16  825          if (!pp) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  826                  printk(KERN_ERR "%s: parport at 0x%lx unknown\n", bc_drvname, dev->base_addr);
^1da177e4c3f41 Linus Torvalds         2005-04-16  827                  return -ENXIO;
^1da177e4c3f41 Linus Torvalds         2005-04-16  828          }
^1da177e4c3f41 Linus Torvalds         2005-04-16  829  #if 0
^1da177e4c3f41 Linus Torvalds         2005-04-16  830          if (pp->irq < 0) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  831                  printk(KERN_ERR "%s: parport at 0x%lx has no irq\n", bc_drvname, pp->base);
^1da177e4c3f41 Linus Torvalds         2005-04-16  832  		parport_put_port(pp);
^1da177e4c3f41 Linus Torvalds         2005-04-16  833                  return -ENXIO;
^1da177e4c3f41 Linus Torvalds         2005-04-16  834          }
^1da177e4c3f41 Linus Torvalds         2005-04-16  835  #endif
^1da177e4c3f41 Linus Torvalds         2005-04-16  836  	if ((~pp->modes) & (PARPORT_MODE_TRISTATE | PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT)) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  837                  printk(KERN_ERR "%s: parport at 0x%lx cannot be used\n",
^1da177e4c3f41 Linus Torvalds         2005-04-16  838  		       bc_drvname, pp->base);
^1da177e4c3f41 Linus Torvalds         2005-04-16  839  		parport_put_port(pp);
^1da177e4c3f41 Linus Torvalds         2005-04-16  840                  return -EIO;
^1da177e4c3f41 Linus Torvalds         2005-04-16  841  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  842  	memset(&bc->modem, 0, sizeof(bc->modem));
ca444073a2de97 Sudip Mukherjee        2017-09-17  843  	memset(&par_cb, 0, sizeof(par_cb));
ca444073a2de97 Sudip Mukherjee        2017-09-17  844  	par_cb.wakeup = epp_wakeup;
ca444073a2de97 Sudip Mukherjee        2017-09-17  845  	par_cb.private = (void *)dev;
ca444073a2de97 Sudip Mukherjee        2017-09-17  846  	par_cb.flags = PARPORT_DEV_EXCL;
ca444073a2de97 Sudip Mukherjee        2017-09-17  847  	for (i = 0; i < NR_PORTS; i++)
ca444073a2de97 Sudip Mukherjee        2017-09-17  848  		if (baycom_device[i] == dev)
ca444073a2de97 Sudip Mukherjee        2017-09-17  849  			break;
ca444073a2de97 Sudip Mukherjee        2017-09-17  850  
ca444073a2de97 Sudip Mukherjee        2017-09-17  851  	if (i == NR_PORTS) {
ca444073a2de97 Sudip Mukherjee        2017-09-17  852  		pr_err("%s: no device found\n", bc_drvname);
ca444073a2de97 Sudip Mukherjee        2017-09-17  853  		parport_put_port(pp);
ca444073a2de97 Sudip Mukherjee        2017-09-17  854  		return -ENODEV;
ca444073a2de97 Sudip Mukherjee        2017-09-17  855  	}
ca444073a2de97 Sudip Mukherjee        2017-09-17  856  
ca444073a2de97 Sudip Mukherjee        2017-09-17  857  	bc->pdev = parport_register_dev_model(pp, dev->name, &par_cb, i);
^1da177e4c3f41 Linus Torvalds         2005-04-16  858  	parport_put_port(pp);
^1da177e4c3f41 Linus Torvalds         2005-04-16  859          if (!bc->pdev) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  860                  printk(KERN_ERR "%s: cannot register parport at 0x%lx\n", bc_drvname, pp->base);
^1da177e4c3f41 Linus Torvalds         2005-04-16  861                  return -ENXIO;
^1da177e4c3f41 Linus Torvalds         2005-04-16  862          }
^1da177e4c3f41 Linus Torvalds         2005-04-16  863          if (parport_claim(bc->pdev)) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  864                  printk(KERN_ERR "%s: parport at 0x%lx busy\n", bc_drvname, pp->base);
^1da177e4c3f41 Linus Torvalds         2005-04-16  865                  parport_unregister_device(bc->pdev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  866                  return -EBUSY;
^1da177e4c3f41 Linus Torvalds         2005-04-16  867          }
^1da177e4c3f41 Linus Torvalds         2005-04-16  868          dev->irq = /*pp->irq*/ 0;
c4028958b6ecad David Howells          2006-11-22  869  	INIT_DELAYED_WORK(&bc->run_work, epp_bh);
^1da177e4c3f41 Linus Torvalds         2005-04-16  870  	bc->work_running = 1;
^1da177e4c3f41 Linus Torvalds         2005-04-16  871  	bc->modem = EPP_CONVENTIONAL;
^1da177e4c3f41 Linus Torvalds         2005-04-16  872  	if (eppconfig(bc))
^1da177e4c3f41 Linus Torvalds         2005-04-16  873  		printk(KERN_INFO "%s: no FPGA detected, assuming conventional EPP modem\n", bc_drvname);
^1da177e4c3f41 Linus Torvalds         2005-04-16  874  	else
^1da177e4c3f41 Linus Torvalds         2005-04-16  875  		bc->modem = /*EPP_FPGA*/ EPP_FPGAEXTSTATUS;
^1da177e4c3f41 Linus Torvalds         2005-04-16  876  	parport_write_control(pp, LPTCTRL_PROGRAM); /* prepare EPP mode; we aren't using interrupts */
^1da177e4c3f41 Linus Torvalds         2005-04-16  877  	/* reset the modem */
^1da177e4c3f41 Linus Torvalds         2005-04-16  878  	tmp[0] = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  879  	tmp[1] = EPP_TX_FIFO_ENABLE|EPP_RX_FIFO_ENABLE|EPP_MODEM_ENABLE;
^1da177e4c3f41 Linus Torvalds         2005-04-16  880  	if (pp->ops->epp_write_addr(pp, tmp, 2, 0) != 2)
^1da177e4c3f41 Linus Torvalds         2005-04-16  881  		goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  882  	/* autoprobe baud rate */
^1da177e4c3f41 Linus Torvalds         2005-04-16  883  	tstart = jiffies;
^1da177e4c3f41 Linus Torvalds         2005-04-16  884  	i = 0;
ff5688ae1cedfb Marcelo Feitoza Parisi 2006-01-09  885  	while (time_before(jiffies, tstart + HZ/3)) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  886  		if (pp->ops->epp_read_addr(pp, &stat, 1, 0) != 1)
^1da177e4c3f41 Linus Torvalds         2005-04-16  887  			goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  888  		if ((stat & (EPP_NRAEF|EPP_NRHF)) == EPP_NRHF) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  889  			schedule();
^1da177e4c3f41 Linus Torvalds         2005-04-16  890  			continue;
^1da177e4c3f41 Linus Torvalds         2005-04-16  891  		}
^1da177e4c3f41 Linus Torvalds         2005-04-16  892  		if (pp->ops->epp_read_data(pp, tmp, 128, 0) != 128)
^1da177e4c3f41 Linus Torvalds         2005-04-16  893  			goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  894  		if (pp->ops->epp_read_data(pp, tmp, 128, 0) != 128)
^1da177e4c3f41 Linus Torvalds         2005-04-16  895  			goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  896  		i += 256;
^1da177e4c3f41 Linus Torvalds         2005-04-16  897  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  898  	for (j = 0; j < 256; j++) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  899  		if (pp->ops->epp_read_addr(pp, &stat, 1, 0) != 1)
^1da177e4c3f41 Linus Torvalds         2005-04-16  900  			goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  901  		if (!(stat & EPP_NREF))
^1da177e4c3f41 Linus Torvalds         2005-04-16  902  			break;
^1da177e4c3f41 Linus Torvalds         2005-04-16  903  		if (pp->ops->epp_read_data(pp, tmp, 1, 0) != 1)
^1da177e4c3f41 Linus Torvalds         2005-04-16  904  			goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  905  		i++;
^1da177e4c3f41 Linus Torvalds         2005-04-16  906  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  907  	tstart = jiffies - tstart;
^1da177e4c3f41 Linus Torvalds         2005-04-16  908  	bc->bitrate = i * (8 * HZ) / tstart;
^1da177e4c3f41 Linus Torvalds         2005-04-16  909  	j = 1;
^1da177e4c3f41 Linus Torvalds         2005-04-16  910  	i = bc->bitrate >> 3;
^1da177e4c3f41 Linus Torvalds         2005-04-16  911  	while (j < 7 && i > 150) {
^1da177e4c3f41 Linus Torvalds         2005-04-16  912  		j++;
^1da177e4c3f41 Linus Torvalds         2005-04-16  913  		i >>= 1;
^1da177e4c3f41 Linus Torvalds         2005-04-16  914  	}
^1da177e4c3f41 Linus Torvalds         2005-04-16  915  	printk(KERN_INFO "%s: autoprobed bitrate: %d  int divider: %d  int rate: %d\n", 
^1da177e4c3f41 Linus Torvalds         2005-04-16  916  	       bc_drvname, bc->bitrate, j, bc->bitrate >> (j+2));
^1da177e4c3f41 Linus Torvalds         2005-04-16  917  	tmp[0] = EPP_TX_FIFO_ENABLE|EPP_RX_FIFO_ENABLE|EPP_MODEM_ENABLE/*|j*/;
^1da177e4c3f41 Linus Torvalds         2005-04-16  918  	if (pp->ops->epp_write_addr(pp, tmp, 1, 0) != 1)
^1da177e4c3f41 Linus Torvalds         2005-04-16  919  		goto epptimeout;
^1da177e4c3f41 Linus Torvalds         2005-04-16  920  	/*
^1da177e4c3f41 Linus Torvalds         2005-04-16  921  	 * initialise hdlc variables
^1da177e4c3f41 Linus Torvalds         2005-04-16  922  	 */
^1da177e4c3f41 Linus Torvalds         2005-04-16  923  	bc->hdlcrx.state = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  924  	bc->hdlcrx.numbits = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  925  	bc->hdlctx.state = tx_idle;
^1da177e4c3f41 Linus Torvalds         2005-04-16  926  	bc->hdlctx.bufcnt = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  927  	bc->hdlctx.slotcnt = bc->ch_params.slottime;
^1da177e4c3f41 Linus Torvalds         2005-04-16  928  	bc->hdlctx.calibrate = 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  929  	/* start the bottom half stuff */
^1da177e4c3f41 Linus Torvalds         2005-04-16  930  	schedule_delayed_work(&bc->run_work, 1);
^1da177e4c3f41 Linus Torvalds         2005-04-16  931  	netif_start_queue(dev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  932  	return 0;
^1da177e4c3f41 Linus Torvalds         2005-04-16  933  
^1da177e4c3f41 Linus Torvalds         2005-04-16  934   epptimeout:
^1da177e4c3f41 Linus Torvalds         2005-04-16  935  	printk(KERN_ERR "%s: epp timeout during bitrate probe\n", bc_drvname);
^1da177e4c3f41 Linus Torvalds         2005-04-16  936  	parport_write_control(pp, 0); /* reset the adapter */
^1da177e4c3f41 Linus Torvalds         2005-04-16  937          parport_release(bc->pdev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  938          parport_unregister_device(bc->pdev);
^1da177e4c3f41 Linus Torvalds         2005-04-16  939  	return -EIO;
^1da177e4c3f41 Linus Torvalds         2005-04-16  940  }
^1da177e4c3f41 Linus Torvalds         2005-04-16  941
kernel test robot March 4, 2023, 2:04 a.m. UTC | #5
Hi Vincenzo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on net-next/master horms-ipvs/master linus/master v6.2 next-20230303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vincenzo-Palazzo/netdevice-use-ifmap-isteand-of-plain-fields/20230303-231003
patch link:    https://lore.kernel.org/r/20230303150818.132386-1-vincenzopalazzodev%40gmail.com
patch subject: [PATCH v1] netdevice: use ifmap isteand of plain fields
config: hexagon-randconfig-r001-20230303 (https://download.01.org/0day-ci/archive/20230304/202303040937.SrzjrYMQ-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
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/intel-lab-lkp/linux/commit/4efa870f9b2112fdebe7d1fffe30f5626b8d5229
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Vincenzo-Palazzo/netdevice-use-ifmap-isteand-of-plain-fields/20230303-231003
        git checkout 4efa870f9b2112fdebe7d1fffe30f5626b8d5229
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/net/hamradio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303040937.SrzjrYMQ-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/net/hamradio/baycom_ser_hdx.c:53:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/net/hamradio/baycom_ser_hdx.c:53:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/net/hamradio/baycom_ser_hdx.c:53:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> drivers/net/hamradio/baycom_ser_hdx.c:158:22: error: no member named 'base_addr' in 'struct net_device'
           outb(0x81, LCR(dev->base_addr));        /* DLAB = 1 */
                          ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:83:22: note: expanded from macro 'LCR'
   #define LCR(iobase) (iobase+3)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:159:25: error: no member named 'base_addr' in 'struct net_device'
           outb(divisor, DLL(dev->base_addr));
                             ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:88:22: note: expanded from macro 'DLL'
   #define DLL(iobase) (iobase+0)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:160:19: error: no member named 'base_addr' in 'struct net_device'
           outb(0, DLM(dev->base_addr));
                       ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:89:22: note: expanded from macro 'DLM'
   #define DLM(iobase) (iobase+1)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:161:22: error: no member named 'base_addr' in 'struct net_device'
           outb(0x01, LCR(dev->base_addr));        /* word length = 6 */
                          ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:83:22: note: expanded from macro 'LCR'
   #define LCR(iobase) (iobase+3)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:167:22: error: no member named 'base_addr' in 'struct net_device'
           outb(0x00, THR(dev->base_addr));
                          ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:79:22: note: expanded from macro 'THR'
   #define THR(iobase) (iobase+0)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:193:51: error: no member named 'base_addr' in 'struct net_device'
           outb(0x0e | (!!bc->modem.ser12.tx_bit), MCR(dev->base_addr));
                                                       ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:84:22: note: expanded from macro 'MCR'
   #define MCR(iobase) (iobase+4)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:209:23: error: no member named 'base_addr' in 'struct net_device'
           cur_s = inb(MSR(dev->base_addr)) & 0x10;        /* the CTS line */
                           ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:86:22: note: expanded from macro 'MSR'
   #define MSR(iobase) (iobase+6)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:339:22: error: no member named 'base_addr' in 'struct net_device'
           outb(0x0d, MCR(dev->base_addr));                /* transmitter off */
                          ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:84:22: note: expanded from macro 'MCR'
   #define MCR(iobase) (iobase+4)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:346:46: error: no member named 'base_addr' in 'struct net_device'
                           hdlcdrv_setdcd(&bc->hdrv, !((inb(MSR(dev->base_addr)) ^ bc->opt_dcd) & 0x80));
                                                                ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:86:22: note: expanded from macro 'MSR'
   #define MSR(iobase) (iobase+6)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:371:26: error: no member named 'base_addr' in 'struct net_device'
           if ((iir = inb(IIR(dev->base_addr))) & 1)
                              ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:81:22: note: expanded from macro 'IIR'
   #define IIR(iobase) (iobase+2)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:377:17: error: no member named 'base_addr' in 'struct net_device'
                           inb(LSR(dev->base_addr));
                                   ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:85:22: note: expanded from macro 'LSR'
   #define LSR(iobase) (iobase+5)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:381:17: error: no member named 'base_addr' in 'struct net_device'
                           inb(RBR(dev->base_addr));
                                   ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:78:22: note: expanded from macro 'RBR'
   #define RBR(iobase) (iobase+0)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:394:24: error: no member named 'base_addr' in 'struct net_device'
                           outb(0x00, THR(dev->base_addr));
                                          ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:79:22: note: expanded from macro 'THR'
   #define THR(iobase) (iobase+0)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:398:17: error: no member named 'base_addr' in 'struct net_device'
                           inb(MSR(dev->base_addr));
                                   ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:86:22: note: expanded from macro 'MSR'
   #define MSR(iobase) (iobase+6)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:401:22: error: no member named 'base_addr' in 'struct net_device'
                   iir = inb(IIR(dev->base_addr));
                                 ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:81:22: note: expanded from macro 'IIR'
   #define IIR(iobase) (iobase+2)
                        ^~~~~~
   drivers/net/hamradio/baycom_ser_hdx.c:463:12: error: no member named 'base_addr' in 'struct net_device'
           if (!dev->base_addr || dev->base_addr > 0x1000-SER12_EXTENT ||
                ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:463:30: error: no member named 'base_addr' in 'struct net_device'
           if (!dev->base_addr || dev->base_addr > 0x1000-SER12_EXTENT ||
                                  ~~~  ^
   drivers/net/hamradio/baycom_ser_hdx.c:466:27: error: no member named 'base_addr' in 'struct net_device'
           if (!request_region(dev->base_addr, SER12_EXTENT, "baycom_ser12"))
                               ~~~  ^
   include/linux/ioport.h:268:75: note: expanded from macro 'request_region'
   #define request_region(start,n,name)            __request_region(&ioport_resource, (start), (n), (name), 0)
--
   In file included from drivers/net/hamradio/hdlcdrv.c:43:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __raw_readb(PCI_IOBASE + addr);
                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/net/hamradio/hdlcdrv.c:43:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
                                                           ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/net/hamradio/hdlcdrv.c:43:
   In file included from include/linux/netdevice.h:38:
   In file included from include/net/net_namespace.h:43:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/hexagon/include/asm/io.h:334:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writeb(value, PCI_IOBASE + addr);
                               ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
                                                         ~~~~~~~~~~ ^
>> drivers/net/hamradio/hdlcdrv.c:528:28: error: no member named 'base_addr' in 'struct net_device'
                   bi.data.mp.iobase = dev->base_addr;
                                       ~~~  ^
   drivers/net/hamradio/hdlcdrv.c:540:8: error: no member named 'base_addr' in 'struct net_device'
                   dev->base_addr = bi.data.mp.iobase;
                   ~~~  ^
   drivers/net/hamradio/hdlcdrv.c:706:7: error: no member named 'base_addr' in 'struct net_device'
           dev->base_addr = baseaddr;
           ~~~  ^
   6 warnings and 3 errors generated.


vim +158 drivers/net/hamradio/baycom_ser_hdx.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  149  
^1da177e4c3f41 Linus Torvalds 2005-04-16  150  /* --------------------------------------------------------------------- */
^1da177e4c3f41 Linus Torvalds 2005-04-16  151  /*
^1da177e4c3f41 Linus Torvalds 2005-04-16  152   * ===================== SER12 specific routines =========================
^1da177e4c3f41 Linus Torvalds 2005-04-16  153   */
^1da177e4c3f41 Linus Torvalds 2005-04-16  154  
^1da177e4c3f41 Linus Torvalds 2005-04-16  155  static inline void ser12_set_divisor(struct net_device *dev,
^1da177e4c3f41 Linus Torvalds 2005-04-16  156  				     unsigned char divisor)
^1da177e4c3f41 Linus Torvalds 2005-04-16  157  {
^1da177e4c3f41 Linus Torvalds 2005-04-16 @158  	outb(0x81, LCR(dev->base_addr));	/* DLAB = 1 */
^1da177e4c3f41 Linus Torvalds 2005-04-16  159  	outb(divisor, DLL(dev->base_addr));
^1da177e4c3f41 Linus Torvalds 2005-04-16  160  	outb(0, DLM(dev->base_addr));
^1da177e4c3f41 Linus Torvalds 2005-04-16  161  	outb(0x01, LCR(dev->base_addr));	/* word length = 6 */
^1da177e4c3f41 Linus Torvalds 2005-04-16  162  	/*
^1da177e4c3f41 Linus Torvalds 2005-04-16  163  	 * make sure the next interrupt is generated;
^1da177e4c3f41 Linus Torvalds 2005-04-16  164  	 * 0 must be used to power the modem; the modem draws its
^1da177e4c3f41 Linus Torvalds 2005-04-16  165  	 * power from the TxD line
^1da177e4c3f41 Linus Torvalds 2005-04-16  166  	 */
^1da177e4c3f41 Linus Torvalds 2005-04-16  167  	outb(0x00, THR(dev->base_addr));
^1da177e4c3f41 Linus Torvalds 2005-04-16  168  	/*
^1da177e4c3f41 Linus Torvalds 2005-04-16  169  	 * it is important not to set the divider while transmitting;
^1da177e4c3f41 Linus Torvalds 2005-04-16  170  	 * this reportedly makes some UARTs generating interrupts
^1da177e4c3f41 Linus Torvalds 2005-04-16  171  	 * in the hundredthousands per second region
^1da177e4c3f41 Linus Torvalds 2005-04-16  172  	 * Reported by: Ignacio.Arenaza@studi.epfl.ch (Ignacio Arenaza Nuno)
^1da177e4c3f41 Linus Torvalds 2005-04-16  173  	 */
^1da177e4c3f41 Linus Torvalds 2005-04-16  174  }
^1da177e4c3f41 Linus Torvalds 2005-04-16  175
kernel test robot March 4, 2023, 2:15 a.m. UTC | #6
Hi Vincenzo,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Vincenzo-Palazzo/netdevice-use-ifmap-isteand-of-plain-fields/20230303-231003
patch link:    https://lore.kernel.org/r/20230303150818.132386-1-vincenzopalazzodev%40gmail.com
patch subject: [PATCH v1] netdevice: use ifmap isteand of plain fields
config: riscv-randconfig-r006-20230303 (https://download.01.org/0day-ci/archive/20230304/202303041014.jTNcXi96-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/4efa870f9b2112fdebe7d1fffe30f5626b8d5229
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Vincenzo-Palazzo/netdevice-use-ifmap-isteand-of-plain-fields/20230303-231003
        git checkout 4efa870f9b2112fdebe7d1fffe30f5626b8d5229
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/net/ethernet/ drivers/net/fddi/ drivers/net/plip/ drivers/net/slip/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303041014.jTNcXi96-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:13123:7: error: no member named 'mem_start' in 'struct net_device'
           dev->mem_start = pci_resource_start(pdev, 0);
           ~~~  ^
   drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:13124:7: error: no member named 'base_addr' in 'struct net_device'
           dev->base_addr = dev->mem_start;
           ~~~  ^
   drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:13124:24: error: no member named 'mem_start' in 'struct net_device'
           dev->base_addr = dev->mem_start;
                            ~~~  ^
   drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:13125:7: error: no member named 'mem_end' in 'struct net_device'
           dev->mem_end = pci_resource_end(pdev, 0);
           ~~~  ^
   drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:13117:49: warning: shift count >= width of type [-Wshift-count-overflow]
           rc = dma_set_mask_and_coherent(&bp->pdev->dev, DMA_BIT_MASK(64));
                                                          ^~~~~~~~~~~~~~~~
   include/linux/dma-mapping.h:76:54: note: expanded from macro 'DMA_BIT_MASK'
   #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
                                                        ^ ~~~
   drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:14011:14: error: no member named 'base_addr' in 'struct net_device'
                  dev->base_addr, bp->pdev->irq, dev->dev_addr);
                  ~~~  ^
   drivers/net/ethernet/broadcom/bnx2x/bnx2x.h:141:35: note: expanded from macro 'BNX2X_DEV_INFO'
                   dev_info(&bp->pdev->dev, fmt, ##__VA_ARGS__);    \
                                                   ^~~~~~~~~~~
   include/linux/dev_printk.h:150:67: note: expanded from macro 'dev_info'
           dev_printk_index_wrap(_dev_info, KERN_INFO, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                            ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                   _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                       ^~~~~~~~~~~
>> drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c:15206:26: warning: shift count >= width of type [-Wshift-count-overflow]
           bp->cyclecounter.mask = CYCLECOUNTER_MASK(64);
                                   ^~~~~~~~~~~~~~~~~~~~~
   include/linux/timecounter.h:14:59: note: expanded from macro 'CYCLECOUNTER_MASK'
   #define CYCLECOUNTER_MASK(bits) (u64)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
                                                             ^ ~~~~~~
   2 warnings and 5 errors generated.


vim +15206 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

eeed018cbfa30c Michal Kalderon         2014-08-17  15201  
eeed018cbfa30c Michal Kalderon         2014-08-17  15202  static void bnx2x_init_cyclecounter(struct bnx2x *bp)
eeed018cbfa30c Michal Kalderon         2014-08-17  15203  {
eeed018cbfa30c Michal Kalderon         2014-08-17  15204  	memset(&bp->cyclecounter, 0, sizeof(bp->cyclecounter));
eeed018cbfa30c Michal Kalderon         2014-08-17  15205  	bp->cyclecounter.read = bnx2x_cyclecounter_read;
f28ba401dbd9e9 Richard Cochran         2015-01-02 @15206  	bp->cyclecounter.mask = CYCLECOUNTER_MASK(64);
a6e2846cacf97d Sudarsana Reddy Kalluru 2016-10-21  15207  	bp->cyclecounter.shift = 0;
eeed018cbfa30c Michal Kalderon         2014-08-17  15208  	bp->cyclecounter.mult = 1;
eeed018cbfa30c Michal Kalderon         2014-08-17  15209  }
eeed018cbfa30c Michal Kalderon         2014-08-17  15210
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index e1eb1de88bf9..059ff8bcdbbc 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -7476,8 +7476,8 @@  static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	netif_napi_add(netdev, &adapter->napi, e1000e_poll);
 	strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
 
-	netdev->mem_start = mmio_start;
-	netdev->mem_end = mmio_start + mmio_len;
+	netdev->dev_mapping.mem_start = mmio_start;
+	netdev->dev_mapping.mem_end = mmio_start + mmio_len;
 
 	adapter->bd_number = cards_found++;
 
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6a14b7b11766..c5987e90a078 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2031,13 +2031,7 @@  struct net_device {
 	char			name[IFNAMSIZ];
 	struct netdev_name_node	*name_node;
 	struct dev_ifalias	__rcu *ifalias;
-	/*
-	 *	I/O specific fields
-	 *	FIXME: Merge these and struct ifmap into one
-	 */
-	unsigned long		mem_end;
-	unsigned long		mem_start;
-	unsigned long		base_addr;
+	struct ifmap dev_mapping;
 
 	/*
 	 *	Some hardware also needs these fields (state,dev_list,
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 5cdbfbf9a7dc..89469cb97e35 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -88,9 +88,9 @@  static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
 	if (in_compat_syscall()) {
 		struct compat_ifmap *cifmap = (struct compat_ifmap *)ifmap;
 
-		cifmap->mem_start = dev->mem_start;
-		cifmap->mem_end   = dev->mem_end;
-		cifmap->base_addr = dev->base_addr;
+		cifmap->mem_start = dev->dev_mapping.mem_start;
+		cifmap->mem_end   = dev->dev_mapping.mem_end;
+		cifmap->base_addr = dev->dev_mapping.base_addr;
 		cifmap->irq       = dev->irq;
 		cifmap->dma       = dev->dma;
 		cifmap->port      = dev->if_port;
@@ -98,9 +98,9 @@  static int dev_getifmap(struct net_device *dev, struct ifreq *ifr)
 		return 0;
 	}
 
-	ifmap->mem_start  = dev->mem_start;
-	ifmap->mem_end    = dev->mem_end;
-	ifmap->base_addr  = dev->base_addr;
+	ifmap->mem_start  = dev->dev_mapping.mem_start;
+	ifmap->mem_end    = dev->dev_mapping.mem_end;
+	ifmap->base_addr  = dev->dev_mapping.base_addr;
 	ifmap->irq        = dev->irq;
 	ifmap->dma        = dev->dma;
 	ifmap->port       = dev->if_port;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 5d8eb57867a9..ff8fc1bbda31 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1445,9 +1445,9 @@  static int rtnl_fill_link_ifmap(struct sk_buff *skb, struct net_device *dev)
 	struct rtnl_link_ifmap map;
 
 	memset(&map, 0, sizeof(map));
-	map.mem_start   = dev->mem_start;
-	map.mem_end     = dev->mem_end;
-	map.base_addr   = dev->base_addr;
+	map.mem_start   = dev->dev_mapping.mem_start;
+	map.mem_end     = dev->dev_mapping.mem_end;
+	map.base_addr   = dev->dev_mapping.base_addr;
 	map.irq         = dev->irq;
 	map.dma         = dev->dma;
 	map.port        = dev->if_port;