Skip to content

Commit

Permalink
mcb: Add support for shared PCI IRQs
Browse files Browse the repository at this point in the history
Add support for shared PCI IRQs to mcb and mcb-pci.

Signed-off-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Johannes Thumshirn authored and gregkh committed May 28, 2014
1 parent 2e1c951 commit 4ec65b7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
20 changes: 15 additions & 5 deletions drivers/mcb/mcb-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ EXPORT_SYMBOL_GPL(mcb_device_register);
*
* Allocate a new @mcb_bus.
*/
struct mcb_bus *mcb_alloc_bus(void)
struct mcb_bus *mcb_alloc_bus(struct device *carrier)
{
struct mcb_bus *bus;
int bus_nr;

bus = kzalloc(sizeof(struct mcb_bus), GFP_KERNEL);
if (!bus)
return NULL;
return ERR_PTR(-ENOMEM);

bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL);
if (bus_nr < 0) {
Expand All @@ -200,7 +200,7 @@ struct mcb_bus *mcb_alloc_bus(void)

INIT_LIST_HEAD(&bus->children);
bus->bus_nr = bus_nr;

bus->carrier = carrier;
return bus;
}
EXPORT_SYMBOL_GPL(mcb_alloc_bus);
Expand Down Expand Up @@ -378,6 +378,13 @@ void mcb_release_mem(struct resource *mem)
}
EXPORT_SYMBOL_GPL(mcb_release_mem);

static int __mcb_get_irq(struct mcb_device *dev)
{
struct resource *irq = &dev->irq;

return irq->start;
}

/**
* mcb_get_irq() - Get device's IRQ number
* @dev: The @mcb_device the IRQ is for
Expand All @@ -386,9 +393,12 @@ EXPORT_SYMBOL_GPL(mcb_release_mem);
*/
int mcb_get_irq(struct mcb_device *dev)
{
struct resource *irq = &dev->irq;
struct mcb_bus *bus = dev->bus;

return irq->start;
if (bus->get_irq)
return bus->get_irq(dev);

return __mcb_get_irq(dev);
}
EXPORT_SYMBOL_GPL(mcb_get_irq);

Expand Down
17 changes: 16 additions & 1 deletion drivers/mcb/mcb-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ struct priv {
void __iomem *base;
};

static int mcb_pci_get_irq(struct mcb_device *mdev)
{
struct mcb_bus *mbus = mdev->bus;
struct device *dev = mbus->carrier;
struct pci_dev *pdev = to_pci_dev(dev);

return pdev->irq;
}

static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct priv *priv;
Expand Down Expand Up @@ -67,7 +76,13 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)

pci_set_drvdata(pdev, priv);

priv->bus = mcb_alloc_bus();
priv->bus = mcb_alloc_bus(&pdev->dev);
if (IS_ERR(priv->bus)) {
ret = PTR_ERR(priv->bus);
goto err_drvdata;
}

priv->bus->get_irq = mcb_pci_get_irq;

ret = chameleon_parse_cells(priv->bus, mapbase, priv->base);
if (ret < 0)
Expand Down
6 changes: 5 additions & 1 deletion include/linux/mcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@
#include <linux/irqreturn.h>

struct mcb_driver;
struct mcb_device;

/**
* struct mcb_bus - MEN Chameleon Bus
*
* @dev: pointer to carrier device
* @children: the child busses
* @bus_nr: mcb bus number
* @get_irq: callback to get IRQ number
*/
struct mcb_bus {
struct list_head children;
struct device dev;
struct device *carrier;
int bus_nr;
int (*get_irq)(struct mcb_device *dev);
};
#define to_mcb_bus(b) container_of((b), struct mcb_bus, dev)

Expand Down Expand Up @@ -105,7 +109,7 @@ extern void mcb_unregister_driver(struct mcb_driver *driver);
module_driver(__mcb_driver, mcb_register_driver, mcb_unregister_driver);
extern void mcb_bus_add_devices(const struct mcb_bus *bus);
extern int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev);
extern struct mcb_bus *mcb_alloc_bus(void);
extern struct mcb_bus *mcb_alloc_bus(struct device *carrier);
extern struct mcb_bus *mcb_bus_get(struct mcb_bus *bus);
extern void mcb_bus_put(struct mcb_bus *bus);
extern struct mcb_device *mcb_alloc_dev(struct mcb_bus *bus);
Expand Down

0 comments on commit 4ec65b7

Please sign in to comment.