Skip to content

Commit

Permalink
vme: add vme_init_bridge for common bridge init
Browse files Browse the repository at this point in the history
Consolidate vme_bridge structure setup that every bridge was required
to do itself. This came about because .irq_mtx is only used within the
VME core, but was required to be setup externally.

This returns the structure passed in to support shorthand like this:

    bridge = vme_init_bridge(&priv->bridge);

Signed-off-by: Aaron Sierra <asierra@xes-inc.com>
Acked-by: Martyn Welch <martyn@welchs.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Aaron Sierra authored and Greg Kroah-Hartman committed May 1, 2016
1 parent 2ce7aed commit 326071b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
9 changes: 1 addition & 8 deletions drivers/vme/bridges/vme_ca91cx42.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ static int ca91cx42_irq_init(struct vme_bridge *ca91cx42_bridge)
/* Need pdev */
pdev = to_pci_dev(ca91cx42_bridge->parent);

INIT_LIST_HEAD(&ca91cx42_bridge->vme_error_handlers);

mutex_init(&ca91cx42_bridge->irq_mtx);

/* Disable interrupts from PCI to VME */
iowrite32(0, bridge->base + VINT_EN);

Expand Down Expand Up @@ -1626,6 +1622,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
retval = -ENOMEM;
goto err_struct;
}
vme_init_bridge(ca91cx42_bridge);

ca91cx42_device = kzalloc(sizeof(struct ca91cx42_driver), GFP_KERNEL);

Expand Down Expand Up @@ -1686,7 +1683,6 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add master windows to list */
INIT_LIST_HEAD(&ca91cx42_bridge->master_resources);
for (i = 0; i < CA91C142_MAX_MASTER; i++) {
master_image = kmalloc(sizeof(struct vme_master_resource),
GFP_KERNEL);
Expand All @@ -1713,7 +1709,6 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add slave windows to list */
INIT_LIST_HEAD(&ca91cx42_bridge->slave_resources);
for (i = 0; i < CA91C142_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(struct vme_slave_resource),
GFP_KERNEL);
Expand Down Expand Up @@ -1741,7 +1736,6 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add dma engines to list */
INIT_LIST_HEAD(&ca91cx42_bridge->dma_resources);
for (i = 0; i < CA91C142_MAX_DMA; i++) {
dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
GFP_KERNEL);
Expand All @@ -1764,7 +1758,6 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add location monitor to list */
INIT_LIST_HEAD(&ca91cx42_bridge->lm_resources);
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
if (lm == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
Expand Down
9 changes: 1 addition & 8 deletions drivers/vme/bridges/vme_tsi148.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,6 @@ static int tsi148_irq_init(struct vme_bridge *tsi148_bridge)

bridge = tsi148_bridge->driver_priv;

INIT_LIST_HEAD(&tsi148_bridge->vme_error_handlers);

mutex_init(&tsi148_bridge->irq_mtx);

result = request_irq(pdev->irq,
tsi148_irqhandler,
IRQF_SHARED,
Expand Down Expand Up @@ -2301,6 +2297,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
retval = -ENOMEM;
goto err_struct;
}
vme_init_bridge(tsi148_bridge);

tsi148_device = kzalloc(sizeof(struct tsi148_driver), GFP_KERNEL);
if (tsi148_device == NULL) {
Expand Down Expand Up @@ -2387,7 +2384,6 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add master windows to list */
INIT_LIST_HEAD(&tsi148_bridge->master_resources);
for (i = 0; i < master_num; i++) {
master_image = kmalloc(sizeof(struct vme_master_resource),
GFP_KERNEL);
Expand Down Expand Up @@ -2417,7 +2413,6 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add slave windows to list */
INIT_LIST_HEAD(&tsi148_bridge->slave_resources);
for (i = 0; i < TSI148_MAX_SLAVE; i++) {
slave_image = kmalloc(sizeof(struct vme_slave_resource),
GFP_KERNEL);
Expand All @@ -2442,7 +2437,6 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add dma engines to list */
INIT_LIST_HEAD(&tsi148_bridge->dma_resources);
for (i = 0; i < TSI148_MAX_DMA; i++) {
dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource),
GFP_KERNEL);
Expand All @@ -2467,7 +2461,6 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}

/* Add location monitor to list */
INIT_LIST_HEAD(&tsi148_bridge->lm_resources);
lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL);
if (lm == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory for "
Expand Down
14 changes: 14 additions & 0 deletions drivers/vme/vme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,20 @@ static void vme_dev_release(struct device *dev)
kfree(dev_to_vme_dev(dev));
}

/* Common bridge initialization */
struct vme_bridge *vme_init_bridge(struct vme_bridge *bridge)
{
INIT_LIST_HEAD(&bridge->vme_error_handlers);
INIT_LIST_HEAD(&bridge->master_resources);
INIT_LIST_HEAD(&bridge->slave_resources);
INIT_LIST_HEAD(&bridge->dma_resources);
INIT_LIST_HEAD(&bridge->lm_resources);
mutex_init(&bridge->irq_mtx);

return bridge;
}
EXPORT_SYMBOL(vme_init_bridge);

int vme_register_bridge(struct vme_bridge *bridge)
{
int i;
Expand Down
1 change: 1 addition & 0 deletions drivers/vme/vme_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ void vme_bus_error_handler(struct vme_bridge *bridge,
unsigned long long address, int am);
void vme_irq_handler(struct vme_bridge *, int, int);

struct vme_bridge *vme_init_bridge(struct vme_bridge *);
int vme_register_bridge(struct vme_bridge *);
void vme_unregister_bridge(struct vme_bridge *);
struct vme_error_handler *vme_register_error_handler(
Expand Down

0 comments on commit 326071b

Please sign in to comment.