[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14413c00b3fb8cc2e10a10292ac5c07346b29a10.camel@linux.ibm.com>
Date: Fri, 19 May 2023 14:46:36 +0200
From: Niklas Schnelle <schnelle@...ux.ibm.com>
To: Damien Le Moal <dlemoal@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Sergey Shtylyov <s.shtylyov@....ru>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Alan Stern <stern@...land.harvard.edu>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
linux-pci@...r.kernel.org, Arnd Bergmann <arnd@...nel.org>,
linux-ide@...r.kernel.org
Subject: Re: [PATCH v4 02/41] ata: add HAS_IOPORT dependencies
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@...nel.org>
> > > Signed-off-by: Arnd Bergmann <arnd@...nel.org>
> > > Acked-by: Damien Le Moal <damien.lemoal@...nsource.wdc.com>
> > > Signed-off-by: Niklas Schnelle <schnelle@...ux.ibm.com>
> > > ---
> > >
---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
Powered by blists - more mailing lists