diff options
author | Johannes Thumshirn <jthumshirn@suse.de> | 2017-08-02 09:58:52 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-08-28 20:51:22 +0200 |
commit | 2ce8008711e4837c11e99a94df55406085d0d098 (patch) | |
tree | 361894dfa3ace1606927188629a777e6e5debb83 | |
parent | 5aabd3b0077e0577f60a1ca6b8bdad62f23353d8 (diff) | |
download | linux-2ce8008711e4837c11e99a94df55406085d0d098.tar.bz2 |
mcb: introduce mcb_get_resource()
Introduce mcb_get_resource() as a common accessor to a mcb device's memory or
IRQ resources.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/mcb/mcb-core.c | 20 | ||||
-rw-r--r-- | include/linux/mcb.h | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c index 921a5d2a802b..bb5c5692dedc 100644 --- a/drivers/mcb/mcb-core.c +++ b/drivers/mcb/mcb-core.c @@ -418,6 +418,22 @@ void mcb_bus_add_devices(const struct mcb_bus *bus) EXPORT_SYMBOL_GPL(mcb_bus_add_devices); /** + * mcb_get_resource() - get a resource for a mcb device + * @dev: the mcb device + * @type: the type of resource + */ +struct resource *mcb_get_resource(struct mcb_device *dev, unsigned int type) +{ + if (type == IORESOURCE_MEM) + return &dev->mem; + else if (type == IORESOURCE_IRQ) + return &dev->irq; + else + return NULL; +} +EXPORT_SYMBOL_GPL(mcb_get_resource); + +/** * mcb_request_mem() - Request memory * @dev: The @mcb_device the memory is for * @name: The name for the memory reference. @@ -460,7 +476,9 @@ EXPORT_SYMBOL_GPL(mcb_release_mem); static int __mcb_get_irq(struct mcb_device *dev) { - struct resource *irq = &dev->irq; + struct resource *irq; + + irq = mcb_get_resource(dev, IORESOURCE_IRQ); return irq->start; } diff --git a/include/linux/mcb.h b/include/linux/mcb.h index 4097ac9ea13a..b1a0ad9d23b3 100644 --- a/include/linux/mcb.h +++ b/include/linux/mcb.h @@ -136,5 +136,7 @@ extern struct resource *mcb_request_mem(struct mcb_device *dev, const char *name); extern void mcb_release_mem(struct resource *mem); extern int mcb_get_irq(struct mcb_device *dev); +extern struct resource *mcb_get_resource(struct mcb_device *dev, + unsigned int type); #endif /* _LINUX_MCB_H */ |