Skip to content

Commit

Permalink
Input: gameport - add ISA and HAS_IOPORT dependencies
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Niklas Schnelle <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
niklas88 authored and dtor committed Jul 6, 2023
1 parent 8c9cce9 commit 650cda2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 3 additions & 1 deletion drivers/input/gameport/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

Expand All @@ -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,
Expand Down
26 changes: 21 additions & 5 deletions drivers/input/gameport/gameport.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,32 @@ 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) &&
!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;
}

/*
Expand All @@ -545,11 +565,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);
Expand Down

0 comments on commit 650cda2

Please sign in to comment.