* [PATCH v6 0/1] Input: gameport: Handle HAS_IOPORT dependencies @ 2023-07-03 15:23 Niklas Schnelle 2023-07-03 15:23 ` [PATCH v6 1/1] Input: gameport: add ISA and " Niklas Schnelle 0 siblings, 1 reply; 3+ messages in thread From: Niklas Schnelle @ 2023-07-03 15:23 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: Arnd Bergmann, linux-input, linux-kernel This is a follow up to my ongoing effort of making the inb()/outb() and similar I/O port accessors compile-time optional. Previously I sent this as a complete treewide series titled "treewide: Remove I/O port accessors for HAS_IOPORT=n" with the latest being its 5th version[0]. Now about half of the per-subsystem patches have been merged so I'm changing over to stand alone subsystem patches. These series are stand alone and should be merged via the relevant tree such that with all subsystems complete we can follow this up with the last patch[1] that will make the I/O port accessors compile-time optional. Thanks, Niklas Changes since v5 for Gameport: - Added a dev_err() print when registering a port without .trigger() || .read() and disabled CONFIG_HAS_IOPORT (Dmitry Torokhov). I added this where the default functions are set instead of in the handlers themselves so there is naturally one error print per port. - Rebased to deal with default handler functions. [0] https://lore.kernel.org/all/20230516110038.2413224-1-schnelle@linux.ibm.com/ [1] https://lore.kernel.org/all/20230516110038.2413224-42-schnelle@linux.ibm.com/ [2] https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/ Niklas Schnelle (1): Input: gameport: add ISA and HAS_IOPORT dependencies drivers/input/gameport/Kconfig | 4 +++- drivers/input/gameport/gameport.c | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) base-commit: a901a3568fd26ca9c4a82d8bc5ed5b3ed844d451 -- 2.39.2 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v6 1/1] Input: gameport: add ISA and HAS_IOPORT dependencies 2023-07-03 15:23 [PATCH v6 0/1] Input: gameport: Handle HAS_IOPORT dependencies Niklas Schnelle @ 2023-07-03 15:23 ` Niklas Schnelle 2023-07-06 0:34 ` Dmitry Torokhov 0 siblings, 1 reply; 3+ messages in thread From: Niklas Schnelle @ 2023-07-03 15:23 UTC (permalink / raw) To: Dmitry Torokhov; +Cc: Arnd Bergmann, linux-input, linux-kernel In a future patch HAS_IOPORT=n will result in inb()/outb() and friends not being declared. As ISA already implies HAS_IOPORT we can simply add this dependency and guard sections of code using inb()/outb() as alternative access methods. Co-developed-by: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> --- drivers/input/gameport/Kconfig | 4 +++- drivers/input/gameport/gameport.c | 28 +++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/input/gameport/Kconfig b/drivers/input/gameport/Kconfig index 5a2c2fb3217d..fe73b26e647a 100644 --- a/drivers/input/gameport/Kconfig +++ b/drivers/input/gameport/Kconfig @@ -25,6 +25,7 @@ if GAMEPORT config GAMEPORT_NS558 tristate "Classic ISA and PnP gameport support" + depends on ISA help Say Y here if you have an ISA or PnP gameport. @@ -35,6 +36,7 @@ config GAMEPORT_NS558 config GAMEPORT_L4 tristate "PDPI Lightning 4 gamecard support" + depends on ISA help Say Y here if you have a PDPI Lightning 4 gamecard. @@ -53,7 +55,7 @@ config GAMEPORT_EMU10K1 config GAMEPORT_FM801 tristate "ForteMedia FM801 gameport support" - depends on PCI + depends on PCI && HAS_IOPORT help Say Y here if you have ForteMedia FM801 PCI audio controller (Abit AU10, Genius Sound Maker, HP Workstation zx2000, diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index a1443320b419..bee935211554 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c @@ -519,12 +519,34 @@ EXPORT_SYMBOL(gameport_set_phys); static void gameport_default_trigger(struct gameport *gameport) { +#ifdef CONFIG_HAS_IOPORT outb(0xff, gameport->io); +#endif } static unsigned char gameport_default_read(struct gameport *gameport) { +#ifdef CONFIG_HAS_IOPORT return inb(gameport->io); +#else + return 0xff; +#endif +} + +static void gameport_setup_default_handlers(struct gameport *gameport) +{ + if (gameport->trigger && gameport->read) + return; + + if (!IS_ENABLED(CONFIG_HAS_IOPORT)) + dev_err(&gameport->dev, + "I/O port access is required for %s (%s) but is not available\n", + gameport->phys, gameport->name); + + if (!gameport->trigger) + gameport->trigger = gameport_default_trigger; + if (!gameport->read) + gameport->read = gameport_default_read; } /* @@ -545,11 +567,7 @@ static void gameport_init_port(struct gameport *gameport) if (gameport->parent) gameport->dev.parent = &gameport->parent->dev; - if (!gameport->trigger) - gameport->trigger = gameport_default_trigger; - if (!gameport->read) - gameport->read = gameport_default_read; - + gameport_setup_default_handlers(gameport); INIT_LIST_HEAD(&gameport->node); spin_lock_init(&gameport->timer_lock); timer_setup(&gameport->poll_timer, gameport_run_poll_handler, 0); -- 2.39.2 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v6 1/1] Input: gameport: add ISA and HAS_IOPORT dependencies 2023-07-03 15:23 ` [PATCH v6 1/1] Input: gameport: add ISA and " Niklas Schnelle @ 2023-07-06 0:34 ` Dmitry Torokhov 0 siblings, 0 replies; 3+ messages in thread From: Dmitry Torokhov @ 2023-07-06 0:34 UTC (permalink / raw) To: Niklas Schnelle; +Cc: Arnd Bergmann, linux-input, linux-kernel Hi Niklas, On Mon, Jul 03, 2023 at 05:23:55PM +0200, Niklas Schnelle wrote: > +static void gameport_setup_default_handlers(struct gameport *gameport) > +{ > + if (gameport->trigger && gameport->read) > + return; > + > + if (!IS_ENABLED(CONFIG_HAS_IOPORT)) > + dev_err(&gameport->dev, > + "I/O port access is required for %s (%s) but is not available\n", > + gameport->phys, gameport->name); I combined these 2 conditions into one and applied, thank you. -- Dmitry ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-06 0:34 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-03 15:23 [PATCH v6 0/1] Input: gameport: Handle HAS_IOPORT dependencies Niklas Schnelle 2023-07-03 15:23 ` [PATCH v6 1/1] Input: gameport: add ISA and " Niklas Schnelle 2023-07-06 0:34 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).