staging: gpib: fix pcmcia dependencies
PATCH 1/3 staging: gpib: fix pcmcia dependencies
From: Arnd Bergmann <[email protected]>
With CONFIG_PCMCIA=m, the gpib drivers that optionally support PCMCIA cannot be built-in.
Add a Kconfig dependency to force these to be loadable modules as well, and change the GPIB_PCMCIA symbol to have the correct state for that.
--- drivers/staging/gpib/Kconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/staging/gpib/Kconfig +5 -2
@@ -65,6 +65,7 @@ config GPIB_NI_PCI_ISA depends on ISA_BUS || PCI || PCMCIA depends on HAS_IOPORT depends on !X86_PAE + depends on PCMCIA || !PCMCIA select GPIB_COMMON select GPIB_NEC7210 help
@@ -89,6 +90,7 @@ config GPIB_CB7210 depends on HAS_IOPORT depends on ISA_BUS || PCI || PCMCIA depends on !X86_PAE + depends on PCMCIA || !PCMCIA select GPIB_COMMON select GPIB_NEC7210 help
@@ -177,6 +179,7 @@ config GPIB_HP82341 config GPIB_INES tristate "INES" depends on PCI || ISA_BUS || PCMCIA + depends on PCMCIA || !PCMCIA depends on HAS_IOPORT depends on !X86_PAE select GPIB_COMMON
@@ -199,8 +202,8 @@ config GPIB_INES called cb7210. config GPIB_PCMCIA - bool "PCMCIA/Cardbus support for NI MC and Ines boards" - depends on PCCARD && (GPIB_NI_PCI_ISA || GPIB_CB7210 || GPIB_INES) + def_bool y + depends on PCMCIA && (GPIB_NI_PCI_ISA || GPIB_CB7210 || GPIB_INES) help Enable PCMCIA/CArdbus support for National Instruments, measurement computing boards and Ines boards.
Signature · 1 line
2.39.5
PATCH 2/3 staging: gpib: use ioport_map
From: Arnd Bergmann <[email protected]>
The tnt4882 backend has a rather elabolate way of abstracting the PIO and MMIO based hardware variants, duplicating the functionality of ioport_map() in a less portable way.
Change it to use ioport_map() with ioread8()/iowrite8() to do this more easily.
--- drivers/staging/gpib/Kconfig | 1 + drivers/staging/gpib/common/gpib_os.c | 50 --------------------- drivers/staging/gpib/include/gpibP.h | 12 +---- drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 49 +++++++++----------- 4 files changed, 23 insertions(+), 89 deletions(-)
drivers/staging/gpib/Kconfig +1 -0
@@ -66,6 +66,7 @@ config GPIB_NI_PCI_ISA depends on HAS_IOPORT depends on !X86_PAE depends on PCMCIA || !PCMCIA + depends on HAS_IOPORT_MAP select GPIB_COMMON select GPIB_NEC7210 help
drivers/staging/gpib/common/gpib_os.c +0 -50
56 lines not on this page · raw message
drivers/staging/gpib/include/gpibP.h +1 -11
@@ -16,6 +16,7 @@#include <linux/fs.h> #include <linux/interrupt.h> +#include <linux/io.h> void gpib_register_driver (gpib_interface_t *interface,struct module *mod);void gpib_unregister_driver (gpib_interface_t *interface);
@@ -35,16 +36,5 @@ extern gpib_board_t board_array[GPIB_MAX_NUM_BOARDS];extern struct list_head registered_drivers; -#include <linux/io.h> - -void writeb_wrapper (unsigned int value,void *address); -unsigned int readb_wrapper (void *address); -void outb_wrapper (unsigned int value,void *address); -unsigned int inb_wrapper (void *address); -void writew_wrapper (unsigned int value,void *address); -unsigned int readw_wrapper (void *address); -void outw_wrapper (unsigned int value,void *address); -unsigned int inw_wrapper (void *address); -#endif // _GPIB_P_H
drivers/staging/gpib/tnt4882/tnt4882_gpib.c +21 -28
146 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH 3/3 staging: gpib: fix address space mixup
In reply to Arnd BergmannFrom: Arnd Bergmann <[email protected]>
Throughout the gpib drivers, a 'void *' struct member is used in place of either port numbers or __iomem pointers, which leads to lots of extra type casts, sparse warnings and less portable code.
Split the struct member in two separate ones with the correct types, so each driver can pick which one to use.
--- .../gpib/agilent_82350b/agilent_82350b.c | 4 +- drivers/staging/gpib/cb7210/cb7210.c | 12 ++--- drivers/staging/gpib/cb7210/cb7210.h | 4 +- drivers/staging/gpib/cec/cec_gpib.c | 4 +- drivers/staging/gpib/common/gpib_os.c | 2 +- drivers/staging/gpib/eastwood/fluke_gpib.c | 12 ++--- drivers/staging/gpib/eastwood/fluke_gpib.h | 4 +- drivers/staging/gpib/fmh_gpib/fmh_gpib.c | 25 +++++----- drivers/staging/gpib/fmh_gpib/fmh_gpib.h | 4 +- drivers/staging/gpib/hp_82335/hp82335.c | 21 +++++---- drivers/staging/gpib/hp_82341/hp_82341.c | 16 +++---- drivers/staging/gpib/include/gpib_types.h | 3 +- drivers/staging/gpib/include/nec7210.h | 5 +- drivers/staging/gpib/include/tms9914.h | 5 +- drivers/staging/gpib/ines/ines.h | 4 +- drivers/staging/gpib/ines/ines_gpib.c | 22 ++++----- .../gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 2 +- drivers/staging/gpib/nec7210/nec7210.c | 16 +++---- drivers/staging/gpib/pc2/pc2_gpib.c | 16 +++---- drivers/staging/gpib/tms9914/tms9914.c | 8 ++-- drivers/staging/gpib/tnt4882/mite.h | 4 +- drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 46 +++++++++---------- 22 files changed, 123 insertions(+), 116 deletions(-)
drivers/staging/gpib/agilent_82350b/agilent_82350b.c +2 -2
@@ -700,7 +700,7 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c GPIB_82350A_REGION));dev_dbg (board->gpib_dev,"%s: gpib base address remapped to 0x%p\n" , driver_name, a_priv->gpib_base); - tms_priv->iobase = a_priv->gpib_base +TMS9914_BASE_REG ; + tms_priv->mmiobase = a_priv->gpib_base +TMS9914_BASE_REG ; a_priv->sram_base = ioremap(pci_resource_start(a_priv->pci_device, SRAM_82350A_REGION), pci_resource_len(a_priv->pci_device,
@@ -724,7 +724,7 @@ static int agilent_82350b_generic_attach(gpib_board_t *board, const gpib_board_c pci_resource_len(a_priv->pci_device, GPIB_REGION));dev_dbg (board->gpib_dev,"%s: gpib base address remapped to 0x%p\n" , driver_name, a_priv->gpib_base); - tms_priv->iobase = a_priv->gpib_base +TMS9914_BASE_REG ; + tms_priv->mmiobase = a_priv->gpib_base +TMS9914_BASE_REG ; a_priv->sram_base =ioremap (pci_resource_start (a_priv->pci_device,SRAM_REGION ),pci_resource_len (a_priv->pci_device,SRAM_REGION )); dev_dbg(board->gpib_dev, "%s: sram base address remapped to 0x%p\n",
drivers/staging/gpib/cb7210/cb7210.c +6 -6
@@ -971,12 +971,12 @@ int cb_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)switch (cb_priv->pci_chip) {case PCI_CHIP_AMCC_S5933 : cb_priv->amcc_iobase =pci_resource_start (cb_priv->pci_device,0 ); - nec_priv->iobase = (void *)(pci_resource_start (cb_priv->pci_device,1 )); + nec_priv->iobase =pci_resource_start (cb_priv->pci_device,1 ); cb_priv->fifo_iobase =pci_resource_start (cb_priv->pci_device,2 );break ;case PCI_CHIP_QUANCOM : - nec_priv->iobase = (void *)(pci_resource_start (cb_priv->pci_device,0 )); - cb_priv->fifo_iobase = (unsigned long )nec_priv->iobase; + nec_priv->iobase =pci_resource_start (cb_priv->pci_device,0 ); + cb_priv->fifo_iobase = nec_priv->iobase;break ;default :pr_err ("cb7210: bug! unhandled pci_chip=%i\n" , cb_priv->pci_chip);
@@ -1040,8 +1040,8 @@ int cb_isa_attach(gpib_board_t *board, const gpib_board_config_t *config)return retval; cb_priv = board->private_data; nec_priv = &cb_priv->nec7210_priv; -if (request_region ((unsigned long )config->ibbase, cb7210_iosize,"cb7210" ) ==0 ) { -pr_err ("gpib: ioports starting at 0x%p are already in use\n" , config->ibbase); +if (request_region (config->ibbase, cb7210_iosize,"cb7210" ) ==0 ) { +pr_err ("gpib: ioports starting at 0x%u are already in use\n" , config->ibbase);return -EIO ; } nec_priv->iobase = config->ibbase;
@@ -1471,7 +1471,7 @@ int cb_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config) (unsigned long)curr_dev->resource[0]->start);return -EIO ; } - nec_priv->iobase = (void *)(unsigned long )curr_dev->resource[0 ]->start; + nec_priv->iobase = curr_dev->resource[0 ]->start; cb_priv->fifo_iobase = curr_dev->resource[0 ]->start; if (request_irq(curr_dev->irq, cb7210_interrupt, IRQF_SHARED,
drivers/staging/gpib/cb7210/cb7210.h +2 -2
@@ -113,9 +113,9 @@ enum hs_regs { HS_STATUS = 0x8, /* HS_STATUS register */ }; -static inline unsigned long nec7210_iobase (const struct cb7210_priv *cb_priv) +static inline u32 nec7210_iobase (const struct cb7210_priv *cb_priv) { -return (unsigned long )(cb_priv->nec7210_priv.iobase); +return cb_priv->nec7210_priv.iobase; }static inline int cb7210_page_in_bits (unsigned int page)
drivers/staging/gpib/cec/cec_gpib.c +2 -2
@@ -297,8 +297,8 @@ int cec_pci_attach(gpib_board_t *board, const gpib_board_config_t *config) cec_priv->plx_iobase =pci_resource_start (cec_priv->pci_device,1 );pr_info (" plx9050 base address 0x%lx\n" , cec_priv->plx_iobase); - nec_priv->iobase = (void *)(pci_resource_start (cec_priv->pci_device,3 )); -pr_info (" nec7210 base address 0x%p\n" , nec_priv->iobase); + nec_priv->iobase =pci_resource_start (cec_priv->pci_device,3 ); +pr_info (" nec7210 base address 0x%x\n" , nec_priv->iobase); isr_flags |=IRQF_SHARED ;if (request_irq (cec_priv->pci_device->irq, cec_interrupt, isr_flags,"pci-gpib" , board)) {
drivers/staging/gpib/common/gpib_os.c +1 -1
@@ -1573,7 +1573,7 @@ static int iobase_ioctl(gpib_board_config_t *config, unsigned long arg)if (WARN_ON_ONCE (sizeof (void *) >sizeof (base_addr)))return -EFAULT ; - config->ibbase = (void *)(unsigned long )(base_addr); + config->ibbase = base_addr;return 0 ; }
drivers/staging/gpib/eastwood/fluke_gpib.c +6 -6
@@ -1011,12 +1011,12 @@ static int fluke_attach_impl(gpib_board_t *board, const gpib_board_config_t *con } e_priv->gpib_iomem_res = res; - nec_priv->iobase =ioremap (e_priv->gpib_iomem_res->start, + nec_priv->mmiobase =ioremap (e_priv->gpib_iomem_res->start,resource_size (e_priv->gpib_iomem_res)); -pr_info ("gpib: iobase %lx remapped to %p, length=%d\n" , - (unsigned long )e_priv->gpib_iomem_res->start, - nec_priv->iobase, (int )resource_size (e_priv->gpib_iomem_res)); -if (!nec_priv->iobase) { +pr_info ("gpib: mmiobase %llx remapped to %p, length=%d\n" , + (u64 )e_priv->gpib_iomem_res->start, + nec_priv->mmiobase, (int )resource_size (e_priv->gpib_iomem_res)); +if (!nec_priv->mmiobase) {dev_err (&fluke_gpib_pdev->dev,"Could not map I/O memory\n" );return -ENOMEM ; }
@@ -1107,7 +1107,7 @@ void fluke_detach(gpib_board_t *board)gpib_free_pseudo_irq (board); nec_priv = &e_priv->nec7210_priv; -if (nec_priv->iobase) { +if (nec_priv->mmiobase) {fluke_paged_write_byte (e_priv,0 ,ISR0_IMR0 ,ISR0_IMR0_PAGE );nec7210_board_reset (nec_priv, board); }
drivers/staging/gpib/eastwood/fluke_gpib.h +2 -2
@@ -72,7 +72,7 @@ static inline uint8_t fluke_read_byte_nolock(struct nec7210_priv *nec_priv, {u8 retval; - retval =readl (nec_priv->iobase + register_num * nec_priv->offset); + retval =readl (nec_priv->mmiobase + register_num * nec_priv->offset);return retval; }
@@ -80,7 +80,7 @@ static inline uint8_t fluke_read_byte_nolock(struct nec7210_priv *nec_priv,static inline void fluke_write_byte_nolock (struct nec7210_priv *nec_priv,uint8_t data,int register_num) { -writel (data, nec_priv->iobase + register_num * nec_priv->offset); +writel (data, nec_priv->mmiobase + register_num * nec_priv->offset); } static inline uint8_t fluke_paged_read_byte(struct fluke_priv *e_priv,
drivers/staging/gpib/fmh_gpib/fmh_gpib.c +12 -13
@@ -1419,15 +1419,14 @@ static int fmh_gpib_attach_impl(gpib_board_t *board, const gpib_board_config_t * } e_priv->gpib_iomem_res = res; - nec_priv->iobase =ioremap (e_priv->gpib_iomem_res->start, + nec_priv->mmiobase =ioremap (e_priv->gpib_iomem_res->start,resource_size (e_priv->gpib_iomem_res)); -if (!nec_priv->iobase) { +if (!nec_priv->mmiobase) {dev_err (board->dev,"Could not map I/O memory for gpib\n" );return -ENOMEM ; } -dev_info (board->dev,"iobase 0x%lx remapped to %p, length=%ld\n" , - (unsigned long )e_priv->gpib_iomem_res->start, - nec_priv->iobase, (unsigned long )resource_size (e_priv->gpib_iomem_res)); +dev_info (board->dev,"iobase %pr remapped to %p\n" , + e_priv->gpib_iomem_res, nec_priv->mmiobase); res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"dma_fifos" );if (!res) {
@@ -1507,14 +1506,14 @@ void fmh_gpib_detach(gpib_board_t *board)free_irq (e_priv->irq, board);if (e_priv->fifo_base)fifos_write (e_priv,0 ,FIFO_CONTROL_STATUS_REG ); -if (nec_priv->iobase) { +if (nec_priv->mmiobase) {write_byte (nec_priv,0 ,ISR0_IMR0_REG );nec7210_board_reset (nec_priv, board); }if (e_priv->fifo_base)iounmap (e_priv->fifo_base); -if (nec_priv->iobase) -iounmap (nec_priv->iobase); +if (nec_priv->mmiobase) +iounmap (nec_priv->mmiobase);if (e_priv->dma_port_res) {release_mem_region (e_priv->dma_port_res->start,resource_size (e_priv->dma_port_res));
@@ -1564,12 +1563,12 @@ static int fmh_gpib_pci_attach_impl(gpib_board_t *board, const gpib_board_config e_priv->gpib_iomem_res = &pci_device->resource[gpib_control_status_pci_resource_index]; e_priv->dma_port_res = &pci_device->resource[gpib_fifo_pci_resource_index]; - nec_priv->iobase =ioremap (pci_resource_start (pci_device, + nec_priv->mmiobase =ioremap (pci_resource_start (pci_device, gpib_control_status_pci_resource_index),pci_resource_len (pci_device, gpib_control_status_pci_resource_index));dev_info (board->dev,"base address for gpib control/status registers remapped to 0x%p\n" , - nec_priv->iobase); + nec_priv->mmiobase);if (e_priv->dma_port_res->flags &IORESOURCE_MEM ) { e_priv->fifo_base = ioremap(pci_resource_start(pci_device,
@@ -1632,14 +1631,14 @@ void fmh_gpib_pci_detach(gpib_board_t *board)free_irq (e_priv->irq, board);if (e_priv->fifo_base)fifos_write (e_priv,0 ,FIFO_CONTROL_STATUS_REG ); -if (nec_priv->iobase) { +if (nec_priv->mmiobase) {write_byte (nec_priv,0 ,ISR0_IMR0_REG );nec7210_board_reset (nec_priv, board); }if (e_priv->fifo_base)iounmap (e_priv->fifo_base); -if (nec_priv->iobase) -iounmap (nec_priv->iobase); +if (nec_priv->mmiobase) +iounmap (nec_priv->mmiobase);if (e_priv->dma_port_res || e_priv->gpib_iomem_res)pci_release_regions (to_pci_dev (board->dev));if (board->dev)
drivers/staging/gpib/fmh_gpib/fmh_gpib.h +2 -2
@@ -127,13 +127,13 @@ static const unsigned int fifo_max_burst_length_mask = 0x00ff;static inline uint8_t gpib_cs_read_byte (struct nec7210_priv *nec_priv,unsigned int register_num) { -return readb (nec_priv->iobase + register_num * nec_priv->offset); +return readb (nec_priv->mmiobase + register_num * nec_priv->offset); }static inline void gpib_cs_write_byte (struct nec7210_priv *nec_priv,uint8_t data,unsigned int register_num) { -writeb (data, nec_priv->iobase + register_num * nec_priv->offset); +writeb (data, nec_priv->mmiobase + register_num * nec_priv->offset); }static inline uint16_t fifos_read (struct fmh_priv *fmh_priv,int register_num)
drivers/staging/gpib/hp_82335/hp82335.c +11 -10
@@ -9,6 +9,7 @@*/ #include "hp82335.h" +#include <linux/io.h> #include <linux/ioport.h> #include <linux/sched.h> #include <linux/module.h>
@@ -233,7 +234,7 @@ static void hp82335_clear_interrupt(struct hp82335_priv *hp_priv) {struct tms9914_priv *tms_priv = &hp_priv->tms9914_priv; -writeb (0 , tms_priv->iobase +HPREG_INTR_CLEAR ); +writeb (0 , tms_priv->mmiobase +HPREG_INTR_CLEAR ); }int hp82335_attach (gpib_board_t *board,const gpib_board_config_t *config)
@@ -241,7 +242,7 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)struct hp82335_priv *hp_priv;struct tms9914_priv *tms_priv;int retval; -const unsigned long upper_iomem_base = (unsigned long )config->ibbase + hp82335_rom_size; +const unsigned long upper_iomem_base = config->ibbase + hp82335_rom_size; board->status =0 ;
@@ -253,7 +254,7 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config) tms_priv->write_byte = hp82335_write_byte; tms_priv->offset =1 ; -switch ((unsigned long )(config->ibbase)) { +switch (config->ibbase) {case 0xc4000 :case 0xc8000 :case 0xcc000 :
@@ -271,7 +272,7 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)case 0xfc000 :break ;default : -pr_err ("hp82335: invalid base io address 0x%p\n" , config->ibbase); +pr_err ("hp82335: invalid base io address 0x%u\n" , config->ibbase);return -EINVAL ; }if (!request_mem_region (upper_iomem_base, hp82335_upper_iomem_size,"hp82335" )) {
@@ -280,9 +281,9 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)return -EBUSY ; } hp_priv->raw_iobase = upper_iomem_base; - tms_priv->iobase =ioremap (upper_iomem_base, hp82335_upper_iomem_size); + tms_priv->mmiobase =ioremap (upper_iomem_base, hp82335_upper_iomem_size);pr_info ("hp82335: upper half of 82335 iomem region 0x%lx remapped to 0x%p\n" , - hp_priv->raw_iobase, tms_priv->iobase); + hp_priv->raw_iobase, tms_priv->mmiobase); retval =request_irq (config->ibirq, hp82335_interrupt,0 ,"hp82335" , board);if (retval) {
@@ -296,7 +297,7 @@ int hp82335_attach(gpib_board_t *board, const gpib_board_config_t *config)hp82335_clear_interrupt (hp_priv); -writeb (INTR_ENABLE , tms_priv->iobase +HPREG_CCR ); +writeb (INTR_ENABLE , tms_priv->mmiobase +HPREG_CCR );tms9914_online (board, tms_priv);
@@ -312,10 +313,10 @@ void hp82335_detach(gpib_board_t *board) tms_priv = &hp_priv->tms9914_priv;if (hp_priv->irq)free_irq (hp_priv->irq, board); -if (tms_priv->iobase) { -writeb (0 , tms_priv->iobase +HPREG_CCR ); +if (tms_priv->mmiobase) { +writeb (0 , tms_priv->mmiobase +HPREG_CCR );tms9914_board_reset (tms_priv); -iounmap ((void *)tms_priv->iobase); +iounmap (tms_priv->mmiobase); }if (hp_priv->raw_iobase)release_mem_region (hp_priv->raw_iobase, hp82335_upper_iomem_size);
drivers/staging/gpib/hp_82341/hp_82341.c +8 -8
@@ -473,12 +473,12 @@ void hp_82341_free_private(gpib_board_t *board)static uint8_t hp_82341_read_byte (struct tms9914_priv *priv,unsigned int register_num) { -return inb ((unsigned long )(priv->iobase) + register_num); +return inb (priv->iobase + register_num); }static void hp_82341_write_byte (struct tms9914_priv *priv,uint8_t data,unsigned int register_num) { -outb (data, (unsigned long )(priv->iobase) + register_num); +outb (data, priv->iobase + register_num); }static int hp_82341_find_isapnp_board (struct pnp_dev **dev)
@@ -682,8 +682,8 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config) {struct hp_82341_priv *hp_priv;struct tms9914_priv *tms_priv; -unsigned long start_addr; -void *iobase; +u32 start_addr; +u32 iobase;int irq;int i;int retval;
@@ -704,7 +704,7 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config)if (retval <0 )return retval; hp_priv->pnp_dev = dev; - iobase = (void *)(pnp_port_start (dev,0 )); + iobase =pnp_port_start (dev,0 ); irq =pnp_irq (dev,0 ); hp_priv->hw_version =HW_VERSION_82341D ; hp_priv->io_region_offset =0x8 ;
@@ -714,9 +714,9 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config) hp_priv->hw_version =HW_VERSION_82341C ; hp_priv->io_region_offset =0x400 ; } -pr_info ("hp_82341: base io 0x%p\n" , iobase); +pr_info ("hp_82341: base io 0x%u\n" , iobase);for (i =0 ; i < hp_82341_num_io_regions; ++i) { - start_addr = (unsigned long )(iobase ) + i * hp_priv->io_region_offset; + start_addr = iobase + i * hp_priv->io_region_offset;if (!request_region (start_addr, hp_82341_region_iosize,"hp_82341" )) { pr_err("hp_82341: failed to allocate io ports 0x%lx-0x%lx\n", start_addr,
@@ -725,7 +725,7 @@ int hp_82341_attach(gpib_board_t *board, const gpib_board_config_t *config) } hp_priv->iobase[i] = start_addr; } - tms_priv->iobase = (void *)(hp_priv->iobase[2 ]); + tms_priv->iobase = hp_priv->iobase[2 ];if (hp_priv->hw_version ==HW_VERSION_82341D ) { retval =isapnp_cfg_begin (hp_priv->pnp_dev->card->number, hp_priv->pnp_dev->number);
drivers/staging/gpib/include/gpib_types.h +2 -1
@@ -31,7 +31,8 @@ typedef struct {void *init_data;int init_data_length;/* IO base address to use for non-pnp cards (set by core, driver should make local copy) */ -void *ibbase; +u32 ibbase; +void __iomem *mmibbase;/* IRQ to use for non-pnp cards (set by core, driver should make local copy) */ unsigned int ibirq;/* dma channel to use for non-pnp cards (set by core, driver should make local copy) */
drivers/staging/gpib/include/nec7210.h +4 -1
@@ -18,7 +18,10 @@/* struct used to provide variables local to a nec7210 chip */ struct nec7210_priv { -void *iobase; +#ifdef CONFIG_HAS_IOPORT +u32 iobase; +#endif +void __iomem *mmiobase;unsigned int offset;// offset between successive nec7210 io addresses unsigned int dma_channel;u8 *dma_buffer;
drivers/staging/gpib/include/tms9914.h +4 -1
@@ -20,7 +20,10 @@ enum tms9914_holdoff_mode {/* struct used to provide variables local to a tms9914 chip */ struct tms9914_priv { -void *iobase; +#ifdef CONFIG_HAS_IOPORT +u32 iobase; +#endif +void __iomem *mmiobase;unsigned int offset;// offset between successive tms9914 io addresses unsigned int dma_channel;// software copy of bits written to interrupt mask registers
drivers/staging/gpib/ines/ines.h +2 -2
@@ -83,14 +83,14 @@ void ines_set_xfer_counter(struct ines_priv *priv, unsigned int count);/* inb/outb wrappers */ static inline unsigned int ines_inb (struct ines_priv *priv,unsigned int register_number) { -return inb ((unsigned long )(priv->nec7210_priv.iobase) + +return inb (priv->nec7210_priv.iobase + register_number * priv->nec7210_priv.offset); }static inline void ines_outb (struct ines_priv *priv,unsigned int value,unsigned int register_number) { -outb (value, (unsigned long )(priv->nec7210_priv.iobase) + +outb (value, priv->nec7210_priv.iobase + register_number * priv->nec7210_priv.offset); }
drivers/staging/gpib/ines/ines_gpib.c +11 -11
@@ -273,10 +273,10 @@ irqreturn_t ines_pci_interrupt(int irq, void *arg)struct nec7210_priv *nec_priv = &priv->nec7210_priv;if (priv->pci_chip_type ==PCI_CHIP_QUANCOM ) { -if ((inb ((unsigned long )nec_priv->iobase + +if ((inb (nec_priv->iobase +QUANCOM_IRQ_CONTROL_STATUS_REG ) &QUANCOM_IRQ_ASSERTED_BIT )) -outb (QUANCOM_IRQ_ENABLE_BIT , (unsigned long )(nec_priv->iobase) + +outb (QUANCOM_IRQ_ENABLE_BIT , nec_priv->iobase +QUANCOM_IRQ_CONTROL_STATUS_REG ); }
@@ -780,8 +780,8 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_tif (pci_request_regions (ines_priv->pci_device,"ines-gpib" ))return -1 ; - nec_priv->iobase = (void *)(pci_resource_start (ines_priv->pci_device, - found_id.gpib_region)); + nec_priv->iobase =pci_resource_start (ines_priv->pci_device, + found_id.gpib_region); ines_priv->pci_chip_type = found_id.pci_chip_type; nec_priv->offset = found_id.io_offset;
@@ -840,7 +840,7 @@ static int ines_common_pci_attach(gpib_board_t *board, const gpib_board_config_t }break ;case PCI_CHIP_QUANCOM : -outb (QUANCOM_IRQ_ENABLE_BIT , (unsigned long )(nec_priv->iobase) + +outb (QUANCOM_IRQ_ENABLE_BIT , nec_priv->iobase +QUANCOM_IRQ_CONTROL_STATUS_REG );break ;case PCI_CHIP_QUICKLOGIC5030 :
@@ -899,8 +899,8 @@ int ines_isa_attach(gpib_board_t *board, const gpib_board_config_t *config) ines_priv = board->private_data; nec_priv = &ines_priv->nec7210_priv; -if (!request_region ((unsigned long )config->ibbase, ines_isa_iosize,"ines_gpib" )) { -pr_err ("ines_gpib: ioports at 0x%p already in use\n" , config->ibbase); +if (!request_region (config->ibbase, ines_isa_iosize,"ines_gpib" )) { +pr_err ("ines_gpib: ioports at 0x%x already in use\n" , config->ibbase);return -1 ; } nec_priv->iobase = config->ibbase;
@@ -931,7 +931,7 @@ void ines_pci_detach(gpib_board_t *board)break ;case PCI_CHIP_QUANCOM :if (nec_priv->iobase) -outb (0 , (unsigned long )(nec_priv->iobase) + +outb (0 , nec_priv->iobase +QUANCOM_IRQ_CONTROL_STATUS_REG );break ;default :
@@ -960,7 +960,7 @@ void ines_isa_detach(gpib_board_t *board)free_irq (ines_priv->irq, board);if (nec_priv->iobase) {nec7210_board_reset (nec_priv, board); -release_region ((unsigned long )(nec_priv->iobase), ines_isa_iosize); +release_region (nec_priv->iobase, ines_isa_iosize); } }ines_free_private (board);
@@ -1355,7 +1355,7 @@ int ines_common_pcmcia_attach(gpib_board_t *board)return -1 ; } - nec_priv->iobase = (void *)(unsigned long )curr_dev->resource[0 ]->start; + nec_priv->iobase = curr_dev->resource[0 ]->start;nec7210_board_reset (nec_priv, board);
@@ -1410,7 +1410,7 @@ void ines_pcmcia_detach(gpib_board_t *board)free_irq (ines_priv->irq, board);if (nec_priv->iobase) {nec7210_board_reset (nec_priv, board); -release_region ((unsigned long )(nec_priv->iobase), ines_pcmcia_iosize); +release_region (nec_priv->iobase, ines_pcmcia_iosize); } }ines_free_private (board);
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c +1 -1
@@ -434,7 +434,7 @@ static void set_timeout(gpib_board_t *board)static int usb_gpib_attach (gpib_board_t *board,const gpib_board_config_t *config) {int retval, j; -int base = (long )config->ibbase; +u32 base = config->ibbase;char *device_path;int match;struct usb_device *udev;
drivers/staging/gpib/nec7210/nec7210.c +8 -8
@@ -1035,7 +1035,7 @@ EXPORT_SYMBOL(nec7210_board_online);/* wrappers for io */ uint8_t nec7210_ioport_read_byte (struct nec7210_priv *priv,unsigned int register_num) { -return inb ((unsigned long )(priv->iobase) + register_num * priv->offset); +return inb (priv->iobase + register_num * priv->offset); }EXPORT_SYMBOL (nec7210_ioport_read_byte);
@@ -1047,7 +1047,7 @@ void nec7210_ioport_write_byte(struct nec7210_priv *priv, uint8_t data, unsigned*/ nec7210_locking_ioport_write_byte (priv, data, register_num); else - outb(data, (unsigned long)(priv->iobase) + register_num * priv->offset); + outb(data, priv->iobase + register_num * priv->offset); }EXPORT_SYMBOL (nec7210_ioport_write_byte);
@@ -1058,7 +1058,7 @@ uint8_t nec7210_locking_ioport_read_byte(struct nec7210_priv *priv, unsigned intunsigned long flags;spin_lock_irqsave (&priv->register_page_lock, flags); - retval =inb ((unsigned long )(priv->iobase) + register_num * priv->offset); + retval =inb (priv->iobase + register_num * priv->offset);spin_unlock_irqrestore (&priv->register_page_lock, flags);return retval; }
@@ -1072,7 +1072,7 @@ void nec7210_locking_ioport_write_byte(struct nec7210_priv *priv, uint8_t data,spin_lock_irqsave (&priv->register_page_lock, flags);if (register_num ==AUXMR )udelay (1 ); -outb (data, (unsigned long )(priv->iobase) + register_num * priv->offset); +outb (data, priv->iobase + register_num * priv->offset);spin_unlock_irqrestore (&priv->register_page_lock, flags); }EXPORT_SYMBOL (nec7210_locking_ioport_write_byte);
@@ -1080,7 +1080,7 @@ EXPORT_SYMBOL(nec7210_locking_ioport_write_byte);uint8_t nec7210_iomem_read_byte (struct nec7210_priv *priv,unsigned int register_num) { -return readb (priv->iobase + register_num * priv->offset); +return readb (priv->mmiobase + register_num * priv->offset); }EXPORT_SYMBOL (nec7210_iomem_read_byte);
@@ -1092,7 +1092,7 @@ void nec7210_iomem_write_byte(struct nec7210_priv *priv, uint8_t data, unsigned*/ nec7210_locking_iomem_write_byte (priv, data, register_num); else - writeb(data, priv->iobase + register_num * priv->offset); + writeb(data, priv->mmiobase + register_num * priv->offset); }EXPORT_SYMBOL (nec7210_iomem_write_byte);
@@ -1102,7 +1102,7 @@ uint8_t nec7210_locking_iomem_read_byte(struct nec7210_priv *priv, unsigned intunsigned long flags;spin_lock_irqsave (&priv->register_page_lock, flags); - retval =readb (priv->iobase + register_num * priv->offset); + retval =readb (priv->mmiobase + register_num * priv->offset);spin_unlock_irqrestore (&priv->register_page_lock, flags);return retval; }
@@ -1116,7 +1116,7 @@ void nec7210_locking_iomem_write_byte(struct nec7210_priv *priv, uint8_t data,spin_lock_irqsave (&priv->register_page_lock, flags);if (register_num ==AUXMR )udelay (1 ); -writeb (data, priv->iobase + register_num * priv->offset); +writeb (data, priv->mmiobase + register_num * priv->offset);spin_unlock_irqrestore (&priv->register_page_lock, flags); }EXPORT_SYMBOL (nec7210_locking_iomem_write_byte);
drivers/staging/gpib/pc2/pc2_gpib.c +8 -8
@@ -426,7 +426,7 @@ int pc2_attach(gpib_board_t *board, const gpib_board_config_t *config) nec_priv = &pc2_priv->nec7210_priv; nec_priv->offset = pc2_reg_offset; -if (request_region ((unsigned long )config->ibbase, pc2_iosize,"pc2" ) ==0 ) { +if (request_region (config->ibbase, pc2_iosize,"pc2" ) ==0 ) {pr_err ("gpib: ioports are already in use\n" );return -1 ; }
@@ -471,7 +471,7 @@ void pc2_detach(gpib_board_t *board)free_irq (pc2_priv->irq, board);if (nec_priv->iobase) {nec7210_board_reset (nec_priv, board); -release_region ((unsigned long )(nec_priv->iobase), pc2_iosize); +release_region (nec_priv->iobase, pc2_iosize); }if (nec_priv->dma_buffer) { dma_free_coherent(board->dev, nec_priv->dma_buffer_length,
@@ -498,14 +498,14 @@ static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *co nec_priv = &pc2_priv->nec7210_priv; nec_priv->offset = pc2a_reg_offset; -switch ((unsigned long )(config->ibbase)) { +switch (config->ibbase) {case 0x02e1 :case 0x22e1 :case 0x42e1 :case 0x62e1 :break ;default : -pr_err ("PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%p\n" , +pr_err ("PCIIa base range invalid, must be one of 0x[0246]2e1, but is 0x%d\n" , config->ibbase);return -1 ; }
@@ -522,7 +522,7 @@ static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *counsigned int err =0 ;for (i =0 ; i < num_registers; i++) { -if (check_region ((unsigned long )config->ibbase + i * pc2a_reg_offset,1 )) +if (check_region (config->ibbase + i * pc2a_reg_offset,1 )) err++; }if (config->ibirq &&check_region (pc2a_clear_intr_iobase + config->ibirq,1 ))
@@ -533,11 +533,11 @@ static int pc2a_common_attach(gpib_board_t *board, const gpib_board_config_t *co }#endif for (i =0 ; i < num_registers; i++) { -if (!request_region ((unsigned long )config->ibbase + +if (!request_region (config->ibbase + i * pc2a_reg_offset,1 ,"pc2a" )) {pr_err ("gpib: ioports are already in use" );for (j =0 ; j < i; j++) -release_region ((unsigned long )(config->ibbase) + +release_region (config->ibbase + j * pc2a_reg_offset,1 );return -1 ; }
@@ -608,7 +608,7 @@ static void pc2a_common_detach(gpib_board_t *board, unsigned int num_registers)if (nec_priv->iobase) {nec7210_board_reset (nec_priv, board);for (i =0 ; i < num_registers; i++) -release_region ((unsigned long )nec_priv->iobase + +release_region (nec_priv->iobase + i * pc2a_reg_offset,1 ); }if (pc2_priv->clear_intr_addr)
drivers/staging/gpib/tms9914/tms9914.c +4 -4
@@ -866,14 +866,14 @@ EXPORT_SYMBOL_GPL(tms9914_online);// wrapper for inb uint8_t tms9914_ioport_read_byte (struct tms9914_priv *priv,unsigned int register_num) { -return inb ((unsigned long )(priv->iobase) + register_num * priv->offset); +return inb (priv->iobase + register_num * priv->offset); }EXPORT_SYMBOL_GPL (tms9914_ioport_read_byte);// wrapper for outb void tms9914_ioport_write_byte (struct tms9914_priv *priv,uint8_t data,unsigned int register_num) { -outb (data, (unsigned long )(priv->iobase) + register_num * priv->offset); +outb (data, priv->iobase + register_num * priv->offset);if (register_num ==AUXCR )udelay (1 ); }
@@ -883,14 +883,14 @@ EXPORT_SYMBOL_GPL(tms9914_ioport_write_byte);// wrapper for readb uint8_t tms9914_iomem_read_byte (struct tms9914_priv *priv,unsigned int register_num) { -return readb (priv->iobase + register_num * priv->offset); +return readb (priv->mmiobase + register_num * priv->offset); }EXPORT_SYMBOL_GPL (tms9914_iomem_read_byte);// wrapper for writeb void tms9914_iomem_write_byte (struct tms9914_priv *priv,uint8_t data,unsigned int register_num) { -writeb (data, priv->iobase + register_num * priv->offset); +writeb (data, priv->mmiobase + register_num * priv->offset);if (register_num ==AUXCR )udelay (1 ); }
drivers/staging/gpib/tnt4882/mite.h +2 -2
@@ -34,9 +34,9 @@ struct mite_struct {struct pci_dev *pcidev;unsigned long mite_phys_addr; -void *mite_io_addr; +void __iomem *mite_io_addr;unsigned long daq_phys_addr; -void *daq_io_addr; +void __iomem *daq_io_addr;int DMA_CheckNearEnd;
drivers/staging/gpib/tnt4882/tnt4882_gpib.c +23 -23
137 lines not on this page · raw message
Signature · 1 line
2.39.5
Re: [PATCH 3/3] staging: gpib: fix address space mixup
Quoted 26 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Throughout the gpib drivers, a 'void *' struct member is used in place of either port numbers or
__iomempointers, which leads to lots of extra type casts, sparse warnings and less portable code.Split the struct member in two separate ones with the correct types, so each driver can pick which one to use.
Signed-off-by Arnd Bergmann <[email protected]>--- .../gpib/agilent_82350b/agilent_82350b.c | 4 +- drivers/staging/gpib/cb7210/cb7210.c | 12 ++--- drivers/staging/gpib/cb7210/cb7210.h | 4 +- drivers/staging/gpib/cec/cec_gpib.c | 4 +- drivers/staging/gpib/common/gpib_os.c | 2 +- drivers/staging/gpib/eastwood/fluke_gpib.c | 12 ++--- drivers/staging/gpib/eastwood/fluke_gpib.h | 4 +- drivers/staging/gpib/fmh_gpib/fmh_gpib.c | 25 +++++----- drivers/staging/gpib/fmh_gpib/fmh_gpib.h | 4 +- drivers/staging/gpib/hp_82335/hp82335.c | 21 +++++---- drivers/staging/gpib/hp_82341/hp_82341.c | 16 +++---- drivers/staging/gpib/include/gpib_types.h | 3 +- drivers/staging/gpib/include/nec7210.h | 5 +- drivers/staging/gpib/include/tms9914.h | 5 +- drivers/staging/gpib/ines/ines.h | 4 +-
Quoted 9 lines
drivers/staging/gpib/ines/ines_gpib.c | 22 ++++----- .../gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 2 +- drivers/staging/gpib/nec7210/nec7210.c | 16 +++---- drivers/staging/gpib/pc2/pc2_gpib.c | 16 +++---- drivers/staging/gpib/tms9914/tms9914.c | 8 ++-- drivers/staging/gpib/tnt4882/mite.h | 4 +- drivers/staging/gpib/tnt4882/tnt4882_gpib.c | 46 +++++++++---------- 22 files changed, 123 insertions(+), 116 deletions(-)
[ skip ]
Hi Arnd,
Thank you so much for these valuable patches.
I have successfully tested them on the agilent and ni pci boards on an amd x86_64 system.
This exercises the agilent_82350b, tms9914 and tnt4882 modules. Your patches have also fixed the i386 build issue as far as I can tell.
cheers,
-Dave