Staging: ipack/bridges/tpci200: change tpci200_slot->*_phys type.
authorJens Taprogge <jens.taprogge@taprogge.org>
Thu, 27 Sep 2012 10:37:28 +0000 (12:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 19 Oct 2012 18:45:09 +0000 (11:45 -0700)
Previously the *_phys fields were of type ipack_addr_space, which use
void pointers to refer to memory addresses.  Since the *_phys fields
refer to unmapped memory, this is not correct.  Introduce a new struct
ipack_region (which uses phys_addr_t to refer to the start of a region)
and use that as a replacement for struct ipack_addr_space.

struct ipack_region is defined in ipack.h because it is planned to later
expose the physical addressed to the IPack Module drivers.

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 a804290..47b8a1b 100644 (file)
@@ -89,13 +89,13 @@ static void tpci200_unregister(struct tpci200_board *tpci200)
        pci_dev_put(tpci200->info->pdev);
 
        for (i = 0; i < TPCI200_NB_SLOT; i++) {
-               tpci200->slots[i].io_phys.address = NULL;
+               tpci200->slots[i].io_phys.start = 0;
                tpci200->slots[i].io_phys.size = 0;
-               tpci200->slots[i].id_phys.address = NULL;
+               tpci200->slots[i].id_phys.start = 0;
                tpci200->slots[i].id_phys.size = 0;
-               tpci200->slots[i].int_phys.address = NULL;
+               tpci200->slots[i].int_phys.start = 0;
                tpci200->slots[i].int_phys.size = 0;
-               tpci200->slots[i].mem_phys.address = NULL;
+               tpci200->slots[i].mem_phys.start = 0;
                tpci200->slots[i].mem_phys.size = 0;
        }
 }
@@ -241,8 +241,8 @@ static int tpci200_register(struct tpci200_board *tpci200)
 {
        int i;
        int res;
-       unsigned long ioidint_base;
-       unsigned long mem_base;
+       phys_addr_t ioidint_base;
+       phys_addr_t mem_base;
        unsigned short slot_ctrl;
 
        if (pci_enable_device(tpci200->info->pdev) < 0)
@@ -308,23 +308,20 @@ 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.address =
-                       (void __iomem *)ioidint_base +
+               tpci200->slots[i].io_phys.start = ioidint_base +
                        TPCI200_IO_SPACE_OFF + TPCI200_IO_SPACE_GAP*i;
                tpci200->slots[i].io_phys.size = TPCI200_IO_SPACE_SIZE;
 
-               tpci200->slots[i].id_phys.address =
-                       (void __iomem *)ioidint_base +
+               tpci200->slots[i].id_phys.start = ioidint_base +
                        TPCI200_ID_SPACE_OFF + TPCI200_ID_SPACE_GAP*i;
                tpci200->slots[i].id_phys.size = TPCI200_ID_SPACE_SIZE;
 
-               tpci200->slots[i].int_phys.address =
-                       (void __iomem *)ioidint_base +
+               tpci200->slots[i].int_phys.start = ioidint_base +
                        TPCI200_INT_SPACE_OFF + TPCI200_INT_SPACE_GAP * i;
                tpci200->slots[i].int_phys.size = TPCI200_INT_SPACE_SIZE;
 
-               tpci200->slots[i].mem_phys.address =
-                       (void __iomem *)mem_base + TPCI200_MEM8_GAP*i;
+               tpci200->slots[i].mem_phys.start = mem_base +
+                       TPCI200_MEM8_GAP * i;
                tpci200->slots[i].mem_phys.size = TPCI200_MEM8_SIZE;
 
                writew(slot_ctrl, &tpci200->info->interface_regs->control[i]);
@@ -419,11 +416,11 @@ out_unlock:
 }
 
 static int tpci200_slot_map_space(struct ipack_device *dev,
-                                 unsigned int memory_size, int space)
+                                 ssize_t memory_size, int space)
 {
        int res = 0;
-       unsigned int size_to_map;
-       void __iomem *phys_address;
+       size_t size_to_map;
+       phys_addr_t phys_address;
        struct ipack_addr_space *virt_addr_space;
        struct tpci200_board *tpci200;
 
@@ -445,7 +442,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
                }
                virt_addr_space = &dev->io_space;
 
-               phys_address = tpci200->slots[dev->slot].io_phys.address;
+               phys_address = tpci200->slots[dev->slot].io_phys.start;
                size_to_map = tpci200->slots[dev->slot].io_phys.size;
                break;
        case IPACK_ID_SPACE:
@@ -458,7 +455,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
                }
                virt_addr_space = &dev->id_space;
 
-               phys_address = tpci200->slots[dev->slot].id_phys.address;
+               phys_address = tpci200->slots[dev->slot].id_phys.start;
                size_to_map = tpci200->slots[dev->slot].id_phys.size;
                break;
        case IPACK_INT_SPACE:
@@ -471,7 +468,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
                }
                virt_addr_space = &dev->int_space;
 
-               phys_address = tpci200->slots[dev->slot].int_phys.address;
+               phys_address = tpci200->slots[dev->slot].int_phys.start;
                size_to_map = tpci200->slots[dev->slot].int_phys.size;
                break;
        case IPACK_MEM_SPACE:
@@ -486,14 +483,14 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
 
                if (memory_size > tpci200->slots[dev->slot].mem_phys.size) {
                        dev_err(&dev->dev,
-                               "Slot [%d:%d] request is 0x%X memory, only 0x%X available !\n",
+                               "Slot [%d:%d] request is 0x%zX memory, only 0x%zX available !\n",
                                dev->bus->bus_nr, dev->slot, memory_size,
                                tpci200->slots[dev->slot].mem_phys.size);
                        res = -EINVAL;
                        goto out_unlock;
                }
 
-               phys_address = tpci200->slots[dev->slot].mem_phys.address;
+               phys_address = tpci200->slots[dev->slot].mem_phys.start;
                size_to_map = memory_size;
                break;
        default:
index e4ed0a3..59cb5b7 100644 (file)
@@ -137,11 +137,11 @@ struct slot_irq {
  *
  */
 struct tpci200_slot {
-       struct slot_irq         *irq;
-       struct ipack_addr_space io_phys;
-       struct ipack_addr_space id_phys;
-       struct ipack_addr_space int_phys;
-       struct ipack_addr_space mem_phys;
+       struct slot_irq     *irq;
+       struct ipack_region  io_phys;
+       struct ipack_region  id_phys;
+       struct ipack_region  int_phys;
+       struct ipack_region  mem_phys;
 };
 
 /**
index e2987d5..9e543a5 100644 (file)
@@ -50,6 +50,13 @@ struct ipack_addr_space {
 };
 
 /**
+ */
+struct ipack_region {
+       phys_addr_t start;
+       size_t      size;
+};
+
+/**
  *     struct ipack_device
  *
  *     @slot: Slot where the device is plugged in the carrier board
@@ -124,7 +131,7 @@ struct ipack_driver {
  *     @reset_timeout: Resets the state returned by get_timeout.
  */
 struct ipack_bus_ops {
-       int (*map_space) (struct ipack_device *dev, unsigned int memory_size, int space);
+       int (*map_space) (struct ipack_device *dev, ssize_t memory_size, int space);
        int (*unmap_space) (struct ipack_device *dev, int space);
        int (*request_irq) (struct ipack_device *dev,
                            irqreturn_t (*handler)(void *), void *arg);