Commit bb29ab86 authored by Jens Taprogge's avatar Jens Taprogge Committed by Greg Kroah-Hartman

Staging: ipack/bridges/tpci200: change tpci200_slot->*_phys type.

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: default avatarJens Taprogge <jens.taprogge@taprogge.org>
Signed-off-by: default avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b412e893
...@@ -89,13 +89,13 @@ static void tpci200_unregister(struct tpci200_board *tpci200) ...@@ -89,13 +89,13 @@ static void tpci200_unregister(struct tpci200_board *tpci200)
pci_dev_put(tpci200->info->pdev); pci_dev_put(tpci200->info->pdev);
for (i = 0; i < TPCI200_NB_SLOT; i++) { 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].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].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].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; tpci200->slots[i].mem_phys.size = 0;
} }
} }
...@@ -241,8 +241,8 @@ static int tpci200_register(struct tpci200_board *tpci200) ...@@ -241,8 +241,8 @@ static int tpci200_register(struct tpci200_board *tpci200)
{ {
int i; int i;
int res; int res;
unsigned long ioidint_base; phys_addr_t ioidint_base;
unsigned long mem_base; phys_addr_t mem_base;
unsigned short slot_ctrl; unsigned short slot_ctrl;
if (pci_enable_device(tpci200->info->pdev) < 0) if (pci_enable_device(tpci200->info->pdev) < 0)
...@@ -308,23 +308,20 @@ static int tpci200_register(struct tpci200_board *tpci200) ...@@ -308,23 +308,20 @@ static int tpci200_register(struct tpci200_board *tpci200)
/* Set all slot physical address space */ /* Set all slot physical address space */
for (i = 0; i < TPCI200_NB_SLOT; i++) { for (i = 0; i < TPCI200_NB_SLOT; i++) {
tpci200->slots[i].io_phys.address = tpci200->slots[i].io_phys.start = ioidint_base +
(void __iomem *)ioidint_base +
TPCI200_IO_SPACE_OFF + TPCI200_IO_SPACE_GAP*i; TPCI200_IO_SPACE_OFF + TPCI200_IO_SPACE_GAP*i;
tpci200->slots[i].io_phys.size = TPCI200_IO_SPACE_SIZE; tpci200->slots[i].io_phys.size = TPCI200_IO_SPACE_SIZE;
tpci200->slots[i].id_phys.address = tpci200->slots[i].id_phys.start = ioidint_base +
(void __iomem *)ioidint_base +
TPCI200_ID_SPACE_OFF + TPCI200_ID_SPACE_GAP*i; TPCI200_ID_SPACE_OFF + TPCI200_ID_SPACE_GAP*i;
tpci200->slots[i].id_phys.size = TPCI200_ID_SPACE_SIZE; tpci200->slots[i].id_phys.size = TPCI200_ID_SPACE_SIZE;
tpci200->slots[i].int_phys.address = tpci200->slots[i].int_phys.start = ioidint_base +
(void __iomem *)ioidint_base +
TPCI200_INT_SPACE_OFF + TPCI200_INT_SPACE_GAP * i; TPCI200_INT_SPACE_OFF + TPCI200_INT_SPACE_GAP * i;
tpci200->slots[i].int_phys.size = TPCI200_INT_SPACE_SIZE; tpci200->slots[i].int_phys.size = TPCI200_INT_SPACE_SIZE;
tpci200->slots[i].mem_phys.address = tpci200->slots[i].mem_phys.start = mem_base +
(void __iomem *)mem_base + TPCI200_MEM8_GAP*i; TPCI200_MEM8_GAP * i;
tpci200->slots[i].mem_phys.size = TPCI200_MEM8_SIZE; tpci200->slots[i].mem_phys.size = TPCI200_MEM8_SIZE;
writew(slot_ctrl, &tpci200->info->interface_regs->control[i]); writew(slot_ctrl, &tpci200->info->interface_regs->control[i]);
...@@ -419,11 +416,11 @@ static int tpci200_slot_unmap_space(struct ipack_device *dev, int space) ...@@ -419,11 +416,11 @@ static int tpci200_slot_unmap_space(struct ipack_device *dev, int space)
} }
static int tpci200_slot_map_space(struct ipack_device *dev, 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; int res = 0;
unsigned int size_to_map; size_t size_to_map;
void __iomem *phys_address; phys_addr_t phys_address;
struct ipack_addr_space *virt_addr_space; struct ipack_addr_space *virt_addr_space;
struct tpci200_board *tpci200; struct tpci200_board *tpci200;
...@@ -445,7 +442,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev, ...@@ -445,7 +442,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
} }
virt_addr_space = &dev->io_space; 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; size_to_map = tpci200->slots[dev->slot].io_phys.size;
break; break;
case IPACK_ID_SPACE: case IPACK_ID_SPACE:
...@@ -458,7 +455,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev, ...@@ -458,7 +455,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
} }
virt_addr_space = &dev->id_space; 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; size_to_map = tpci200->slots[dev->slot].id_phys.size;
break; break;
case IPACK_INT_SPACE: case IPACK_INT_SPACE:
...@@ -471,7 +468,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev, ...@@ -471,7 +468,7 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
} }
virt_addr_space = &dev->int_space; 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; size_to_map = tpci200->slots[dev->slot].int_phys.size;
break; break;
case IPACK_MEM_SPACE: case IPACK_MEM_SPACE:
...@@ -486,14 +483,14 @@ static int tpci200_slot_map_space(struct ipack_device *dev, ...@@ -486,14 +483,14 @@ static int tpci200_slot_map_space(struct ipack_device *dev,
if (memory_size > tpci200->slots[dev->slot].mem_phys.size) { if (memory_size > tpci200->slots[dev->slot].mem_phys.size) {
dev_err(&dev->dev, 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, dev->bus->bus_nr, dev->slot, memory_size,
tpci200->slots[dev->slot].mem_phys.size); tpci200->slots[dev->slot].mem_phys.size);
res = -EINVAL; res = -EINVAL;
goto out_unlock; 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; size_to_map = memory_size;
break; break;
default: default:
......
...@@ -138,10 +138,10 @@ struct slot_irq { ...@@ -138,10 +138,10 @@ struct slot_irq {
*/ */
struct tpci200_slot { struct tpci200_slot {
struct slot_irq *irq; struct slot_irq *irq;
struct ipack_addr_space io_phys; struct ipack_region io_phys;
struct ipack_addr_space id_phys; struct ipack_region id_phys;
struct ipack_addr_space int_phys; struct ipack_region int_phys;
struct ipack_addr_space mem_phys; struct ipack_region mem_phys;
}; };
/** /**
......
...@@ -49,6 +49,13 @@ struct ipack_addr_space { ...@@ -49,6 +49,13 @@ struct ipack_addr_space {
unsigned int size; unsigned int size;
}; };
/**
*/
struct ipack_region {
phys_addr_t start;
size_t size;
};
/** /**
* struct ipack_device * struct ipack_device
* *
...@@ -124,7 +131,7 @@ struct ipack_driver { ...@@ -124,7 +131,7 @@ struct ipack_driver {
* @reset_timeout: Resets the state returned by get_timeout. * @reset_timeout: Resets the state returned by get_timeout.
*/ */
struct ipack_bus_ops { 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 (*unmap_space) (struct ipack_device *dev, int space);
int (*request_irq) (struct ipack_device *dev, int (*request_irq) (struct ipack_device *dev,
irqreturn_t (*handler)(void *), void *arg); irqreturn_t (*handler)(void *), void *arg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment