diff options
author | Itai Katz <itai.katz@freescale.com> | 2015-10-04 10:09:53 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-04 09:55:45 +0100 |
commit | 565b94506f7e2f77dc0d94b4722532358d5965c7 (patch) | |
tree | d43c73ceb7ed3852475b8906785730f0d0da455e /drivers/staging/fsl-mc/bus | |
parent | e4ea40f98d2fd9ec01893c0c1a4718f92adac800 (diff) |
staging: fsl-mc: add counter to track number of root DPRCs
Add a counter to track the number of root DPRCs.
When this counter is greater then 0 it means that at least
one root DPRC device exists.
Signed-off-by: Itai Katz <itai.katz@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/fsl-mc/bus')
-rw-r--r-- | drivers/staging/fsl-mc/bus/mc-bus.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index 37f51f30be98..8a2b99c9f822 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -109,6 +109,8 @@ struct bus_type fsl_mc_bus_type = { }; EXPORT_SYMBOL_GPL(fsl_mc_bus_type); +static atomic_t root_dprc_count = ATOMIC_INIT(0); + static int fsl_mc_driver_probe(struct device *dev) { struct fsl_mc_driver *mc_drv; @@ -213,7 +215,7 @@ EXPORT_SYMBOL_GPL(fsl_mc_driver_unregister); */ bool fsl_mc_bus_exists(void) { - return fsl_mc_bus_type.dev_root; + return atomic_read(&root_dprc_count) > 0; } EXPORT_SYMBOL_GPL(fsl_mc_bus_exists); @@ -458,6 +460,8 @@ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc, if (!fsl_mc_bus_exists()) fsl_mc_bus_type.dev_root = &mc_dev->dev; + + atomic_inc(&root_dprc_count); } error = get_dprc_icid(mc_io2, obj_desc->id, &mc_dev->icid); @@ -540,8 +544,13 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev) mc_dev->mc_io = NULL; } - if (fsl_mc_is_root_dprc(&mc_dev->dev)) + if (fsl_mc_is_root_dprc(&mc_dev->dev)) { fsl_mc_bus_type.dev_root = NULL; + if (atomic_read(&root_dprc_count) > 0) + atomic_dec(&root_dprc_count); + else + WARN_ON(1); + } } if (mc_bus) |