Re: [PATCH v4 02/41] ata: add HAS_IOPORT dependencies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2023-05-16 at 22:23 +0900, Damien Le Moal wrote:
> On 5/16/23 22:18, Damien Le Moal wrote:
> > On 5/16/23 19:59, Niklas Schnelle wrote:
> > > In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
> > > not being declared. We thus need to add HAS_IOPORT as dependency for
> > > those drivers using them.
> > > 
> > > Co-developed-by: Arnd Bergmann <arnd@xxxxxxxxxx>
> > > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxxxx>
> > > Acked-by: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
> > > Signed-off-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
> > > ---
> > > 
---8<---
> > > +++ b/drivers/ata/libata-sff.c
> > > @@ -3031,6 +3031,7 @@ EXPORT_SYMBOL_GPL(ata_bmdma_port_start32);
> > >  
> > >  #ifdef CONFIG_PCI
> > >  
> > > +#ifdef CONFIG_HAS_IOPORT
> > >  /**
> > >   *	ata_pci_bmdma_clear_simplex -	attempt to kick device out of simplex
> > >   *	@pdev: PCI device
> > > @@ -3056,6 +3057,7 @@ int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev)
> > >  	return 0;
> > >  }
> > >  EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex);
> > > +#endif /* CONFIG_HAS_IOPORT */
> > 
> > ...you move the #ifdef CONFIG_HAS_IOPORT inside the function as the first line
> > and have the #endif right before the last "return 0;" (so the function only does
> > return 0 for the !CONFIG_HAS_IOPORT case).
> > 
> > >  
> > >  static void ata_bmdma_nodma(struct ata_host *host, const char *reason)
> > >  {
> > > diff --git a/include/linux/libata.h b/include/linux/libata.h
> > > index 311cd93377c7..90002d4a785b 100644
> > > --- a/include/linux/libata.h
> > > +++ b/include/linux/libata.h
> > > @@ -2012,7 +2012,9 @@ extern int ata_bmdma_port_start(struct ata_port *ap);
> > >  extern int ata_bmdma_port_start32(struct ata_port *ap);
> > >  
> > >  #ifdef CONFIG_PCI
> > > +#ifdef CONFIG_HAS_IOPORT
> > >  extern int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev);
> > > +#endif /* CONFIG_HAS_IOPORT */
> > 
> > And then you do not need these #ifdef/endif here. Overall, a lot less of #ifdef
> > which I personally really dislike to see in .c files :)
> 
> Actually, thinking more about this, the function should probably be:
> 
> int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev)
> {
> #ifdef CONFIG_HAS_IOPORT
> 	unsigned long bmdma = pci_resource_start(pdev, 4);
> 	u8 simplex;
> 
> 	if (bmdma == 0)
> 		return -ENOENT;
> 
> 	simplex = inb(bmdma + 0x02);
> 	outb(simplex & 0x60, bmdma + 0x02);
> 	simplex = inb(bmdma + 0x02);
> 	if (simplex & 0x80)
> 		return -EOPNOTSUPP;
> 	return 0;
> #else
> 	return -ENOENT;
> #endif
> }
> 
> And then no other "#ifdef CONFIG_HAS_IOPORT" needed.
> 
> 

Ok I went with this for v5. It's a bit of a matter of taste. For the
video subsystem I just went the other direction #ifdeffingthe whole
helper and its callsites much as I had here. They were all in headers
and prefixed with "vga_io.." though. Either way I'm fine with either
and will go with the subsystem maintainer's preference.

Thanks,
Niklas




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux