gpib: tnt4882: set iobase for the ISA and PCMCIA boards
Greg Kroah-Hartman
maintainerPATCH 1/1 gpib: tnt4882: set iobase for the ISA and PCMCIA boards
From: Josef Bacik <[email protected]>
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.
--- drivers/gpib/tnt4882/tnt4882_gpib.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpib/tnt4882/tnt4882_gpib.c +9 -7
@@ -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_coif (!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); }
Signature · 1 line
2.56.0
Quoted 3 lines · Greg Kroah-Hartman
- 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-EBUSYuntil the next boot.
Hi Greg, Josef, thanks for the fix.
I applied this patch and tested it on a National Instruments AT-GPIB/TNT (ISA) board. REN is asserted again and I can take the board offline and back online without getting -EBUSY.
I don't have a GPIB-PCMCIA card, so I could not test the PCMCIA part (including the new iosize field).
There is no gpib list, so you may have missed it: I posted this fix in August as a two-patch series (ISA and PCMCIA). I won't resend mine. Feel free to add the Link: below to the commit if you think it's useful for the history, or just drop it.
Tommaso