Skip to content

Commit

Permalink
mcb: introduce mcb_get_resource()
Browse files Browse the repository at this point in the history
Introduce mcb_get_resource() as a common accessor to a mcb device's memory or
IRQ resources.

Signed-off-by: Johannes Thumshirn <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Johannes Thumshirn authored and gregkh committed Aug 28, 2017
1 parent 5aabd3b commit 2ce8008
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 19 additions & 1 deletion drivers/mcb/mcb-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,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
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions include/linux/mcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 2ce8008

Please sign in to comment.