Staging: ipack/bridges/tpci200: Store beginning of module memory regions in struct...
authorJens Taprogge <jens.taprogge@taprogge.org>
Thu, 27 Sep 2012 10:37:29 +0000 (12:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Oct 2012 18:45:09 +0000 (11:45 -0700)
tpci200_register is converted to use this.

A later patch will build on this.

Signed-off-by: Jens Taprogge <jens.taprogge@taprogge.org>
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ipack/bridges/tpci200.c
drivers/staging/ipack/bridges/tpci200.h
drivers/staging/ipack/ipack.h

index 47b8a1b41771a4659e8daad57a3ed99795bb7b25..5acaea2e8f45274c52a84e057951f3cc2cdcb698 100644 (file)
@@ -242,7 +242,6 @@ static int tpci200_register(struct tpci200_board *tpci200)
        int i;
        int res;
        phys_addr_t ioidint_base;
-       phys_addr_t mem_base;
        unsigned short slot_ctrl;
 
        if (pci_enable_device(tpci200->info->pdev) < 0)
@@ -293,7 +292,12 @@ static int tpci200_register(struct tpci200_board *tpci200)
 
        ioidint_base = pci_resource_start(tpci200->info->pdev,
                                          TPCI200_IO_ID_INT_SPACES_BAR);
-       mem_base = pci_resource_start(tpci200->info->pdev,
+       tpci200->mod_mem[IPACK_IO_SPACE] = ioidint_base + TPCI200_IO_SPACE_OFF;
+       tpci200->mod_mem[IPACK_ID_SPACE] = ioidint_base + TPCI200_ID_SPACE_OFF;
+       tpci200->mod_mem[IPACK_INT_SPACE] =
+               ioidint_base + TPCI200_INT_SPACE_OFF;
+       tpci200->mod_mem[IPACK_MEM_SPACE] =
+               pci_resource_start(tpci200->info->pdev,
                                      TPCI200_MEM8_SPACE_BAR);
 
        /* Set the default parameters of the slot
@@ -308,19 +312,23 @@ static int tpci200_register(struct tpci200_board *tpci200)
 
        /* Set all slot physical address space */
        for (i = 0; i < TPCI200_NB_SLOT; i++) {
-               tpci200->slots[i].io_phys.start = ioidint_base +
-                       TPCI200_IO_SPACE_OFF + TPCI200_IO_SPACE_GAP*i;
+               tpci200->slots[i].io_phys.start =
+                       tpci200->mod_mem[IPACK_IO_SPACE] +
+                       TPCI200_IO_SPACE_GAP * i;
                tpci200->slots[i].io_phys.size = TPCI200_IO_SPACE_SIZE;
 
-               tpci200->slots[i].id_phys.start = ioidint_base +
-                       TPCI200_ID_SPACE_OFF + TPCI200_ID_SPACE_GAP*i;
+               tpci200->slots[i].id_phys.start =
+                       tpci200->mod_mem[IPACK_ID_SPACE] +
+                       TPCI200_ID_SPACE_GAP * i;
                tpci200->slots[i].id_phys.size = TPCI200_ID_SPACE_SIZE;
 
-               tpci200->slots[i].int_phys.start = ioidint_base +
-                       TPCI200_INT_SPACE_OFF + TPCI200_INT_SPACE_GAP * i;
+               tpci200->slots[i].int_phys.start =
+                       tpci200->mod_mem[IPACK_INT_SPACE] +
+                       TPCI200_INT_SPACE_GAP * i;
                tpci200->slots[i].int_phys.size = TPCI200_INT_SPACE_SIZE;
 
-               tpci200->slots[i].mem_phys.start = mem_base +
+               tpci200->slots[i].mem_phys.start =
+                       tpci200->mod_mem[IPACK_MEM_SPACE] +
                        TPCI200_MEM8_GAP * i;
                tpci200->slots[i].mem_phys.size = TPCI200_MEM8_SIZE;
 
index 59cb5b7dbc47d032a95c41ce338db6abd02bff00..6b7c7003f6c3818777cf3c22578ec362ebc88718 100644 (file)
@@ -165,6 +165,7 @@ struct tpci200_board {
        spinlock_t              regs_lock;
        struct tpci200_slot     *slots;
        struct tpci200_infos    *info;
+       phys_addr_t             mod_mem[IPACK_SPACE_COUNT];
 };
 
 #endif /* _TPCI200_H_ */
index 9e543a585fd1ec4ccce859aef5ab673a310e5ee0..a842eeaf5348562c6365b3424823e0c1b06ce356 100644 (file)
@@ -33,9 +33,12 @@ struct ipack_driver;
 
 enum ipack_space {
        IPACK_IO_SPACE    = 0,
-       IPACK_ID_SPACE    = 1,
-       IPACK_MEM_SPACE   = 2,
+       IPACK_ID_SPACE,
+       IPACK_MEM_SPACE,
        IPACK_INT_SPACE,
+       /* Dummy for counting the number of entries.  Must remain the last
+        * entry */
+       IPACK_SPACE_COUNT,
 };
 
 /**