* [PATCH] gpib: tnt4882: set iobase for the ISA and PCMCIA boards
@ 2026-10-27 16:29 Greg Kroah-Hartman
0 siblings, 0 replies; only message in thread
From: Greg Kroah-Hartman @ 2026-10-27 16:29 UTC (permalink / raw)
To: dpenkler
Cc: linux-kernel, Josef Bacik, stable, Dominik Karol Piątkowski,
Uwe Kleine-König (The Capable Hub),
Greg Kroah-Hartman
From: Josef Bacik <josef@toxicpanda.com>
The fix for the address space mixup split nec7210_priv.iobase, which was
used for port numbers and for __iomem cookies alike, into iobase and
mmiobase. In ni_isa_attach_common() and ni_pcmcia_attach() the result of
ioport_map() now goes to mmiobase, as it should, but nothing assigns iobase
any more. It stays 0, and three users still rely on it:
- Both functions install nec7210_locking_ioport_read_byte() and
nec7210_locking_ioport_write_byte() as the register accessors of the
nec7210 library. They do inb() and outb() on iobase + register, that is
on ports 0x00 to 0x0e, which belong to the first DMA controller.
- Both detach functions call release_region() only if iobase is set. The
region is never released, so the board cannot be put online a second
time: request_region() fails with -EBUSY until the next boot.
- Both detach functions reset the board only if iobase is set.
Store the port number. The reset uses mmiobase as well, so make it depend
on that one, and do it in ni_pcmcia_detach() before the interrupt is freed
and the ports are unmapped, as ni_isa_detach() does. The PCMCIA variant
requests the whole I/O window of the card but releases a fixed 32 bytes:
remember the size.
Fixes: baf8855c9160 ("staging: gpib: fix address space mixup")
Cc: stable <stable@kernel.org>
Cc: Dave Penkler <dpenkler@gmail.com>
Cc: "Dominik Karol Piątkowski" <dominik.karol.piatkowski@protonmail.com>
Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/gpib/tnt4882/tnt4882_gpib.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/gpib/tnt4882/tnt4882_gpib.c b/drivers/gpib/tnt4882/tnt4882_gpib.c
index 3cd13f637ed4..3f30812866ca 100644
--- a/drivers/gpib/tnt4882/tnt4882_gpib.c
+++ b/drivers/gpib/tnt4882/tnt4882_gpib.c
@@ -46,6 +46,7 @@ struct tnt4882_priv {
struct mite_struct *mite;
struct pnp_dev *pnp_dev;
unsigned int irq;
+ unsigned int iosize; // size of the PCMCIA I/O window
unsigned short imr0_bits;
unsigned short imr3_bits;
unsigned short auxg_bits; // bits written to auxiliary register G
@@ -1066,6 +1067,7 @@ static int ni_isa_attach_common(struct gpib_board *board, const struct gpib_boar
// allocate ioports
if (!request_region(iobase, atgpib_iosize, "atgpib"))
return -EBUSY;
+ nec_priv->iobase = iobase;
nec_priv->mmiobase = ioport_map(iobase, atgpib_iosize);
if (!nec_priv->mmiobase)
@@ -1106,7 +1108,7 @@ static void ni_isa_detach(struct gpib_board *board)
if (tnt_priv) {
nec_priv = &tnt_priv->nec7210_priv;
- if (nec_priv->iobase)
+ if (nec_priv->mmiobase)
tnt4882_board_reset(tnt_priv, board);
if (tnt_priv->irq)
free_irq(tnt_priv->irq, board);
@@ -1708,8 +1710,6 @@ static void __exit exit_ni_gpib_cs(void)
pcmcia_unregister_driver(&ni_gpib_cs_driver);
}
-static const int pcmcia_gpib_iosize = 32;
-
static int ni_pcmcia_attach(struct gpib_board *board, const struct gpib_board_config *config)
{
struct local_info_t *info;
@@ -1740,6 +1740,8 @@ static int ni_pcmcia_attach(struct gpib_board *board, const struct gpib_board_co
if (!request_region(curr_dev->resource[0]->start, resource_size(curr_dev->resource[0]),
DRV_NAME))
return -ENOMEM;
+ nec_priv->iobase = curr_dev->resource[0]->start;
+ tnt_priv->iosize = resource_size(curr_dev->resource[0]);
nec_priv->mmiobase = ioport_map(curr_dev->resource[0]->start,
resource_size(curr_dev->resource[0]));
@@ -1766,14 +1768,14 @@ static void ni_pcmcia_detach(struct gpib_board *board)
if (tnt_priv) {
nec_priv = &tnt_priv->nec7210_priv;
+ if (nec_priv->mmiobase)
+ tnt4882_board_reset(tnt_priv, board);
if (tnt_priv->irq)
free_irq(tnt_priv->irq, board);
if (nec_priv->mmiobase)
ioport_unmap(nec_priv->mmiobase);
- if (nec_priv->iobase) {
- tnt4882_board_reset(tnt_priv, board);
- release_region(nec_priv->iobase, pcmcia_gpib_iosize);
- }
+ if (nec_priv->iobase)
+ release_region(nec_priv->iobase, tnt_priv->iosize);
}
tnt4882_free_private(board);
}
--
2.56.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-27 16:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 16:29 [PATCH] gpib: tnt4882: set iobase for the ISA and PCMCIA boards Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®