diff options
author | Yuanyuan Liu <yuanliu@codeaurora.org> | 2016-05-25 16:26:40 -0700 |
---|---|---|
committer | Vishwajith Upendra <vishwaji@codeaurora.org> | 2016-06-14 14:28:17 -0700 |
commit | 5e25f531b5028e7fa2317054cb1d6142a25f4b6d (patch) | |
tree | 1f73db1cfa6b6166c391d89943988b05f6e42f26 /core/pld/src/pld_common.c | |
parent | 59f81e020e22ddd35b43632a7c1a911b04f43ae9 (diff) | |
download | qcacld-5e25f531b5028e7fa2317054cb1d6142a25f4b6d.tar.gz |
qcacld-3.0: Provide common functions of adding/deleting dev node
Provide common functions of adding/deleting dev node from PLD
global context. These two APIs should be called in probe/remove
callback functions.
CRs-Fixed: 1023650
Change-Id: Iff8157ab4396266ffb013700076d4107a3a21566
Diffstat (limited to 'core/pld/src/pld_common.c')
-rw-r--r-- | core/pld/src/pld_common.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/core/pld/src/pld_common.c b/core/pld/src/pld_common.c index 812f002039..89dcdd9ef3 100644 --- a/core/pld/src/pld_common.c +++ b/core/pld/src/pld_common.c @@ -117,6 +117,58 @@ struct pld_context *pld_get_global_context(void) } /** + * pld_add_dev() - Add dev node to global context + * @pld_context: PLD global context + * @dev: device + * @type: Bus type + * + * Return: 0 for success + * Non zero failure code for errors + */ +int pld_add_dev(struct pld_context *pld_context, + struct device *dev, enum pld_bus_type type) +{ + unsigned long flags; + struct dev_node *dev_node; + + dev_node = kzalloc(sizeof(*dev_node), GFP_KERNEL); + if (dev_node == NULL) + return -ENOMEM; + + dev_node->dev = dev; + dev_node->bus_type = type; + + spin_lock_irqsave(&pld_context->pld_lock, flags); + list_add_tail(&dev_node->list, &pld_context->dev_list); + spin_unlock_irqrestore(&pld_context->pld_lock, flags); + + return 0; +} + +/** + * pld_del_dev() - Delete dev node from global context + * @pld_context: PLD global context + * @dev: device + * + * Return: void + */ +void pld_del_dev(struct pld_context *pld_context, + struct device *dev) +{ + unsigned long flags; + struct dev_node *dev_node, *tmp; + + spin_lock_irqsave(&pld_context->pld_lock, flags); + list_for_each_entry_safe(dev_node, tmp, &pld_context->dev_list, list) { + if (dev_node->dev == dev) { + list_del(&dev_node->list); + kfree(dev_node); + } + } + spin_unlock_irqrestore(&pld_context->pld_lock, flags); +} + +/** * pld_get_bus_type() - Bus type of the device * @dev: device * |