lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1443942594-7189-5-git-send-email-itai.katz@freescale.com>
Date:	Sun, 4 Oct 2015 10:09:53 +0300
From:	<itai.katz@...escale.com>
To:	<gregkh@...uxfoundation.org>, <arnd@...db.de>,
	<devel@...verdev.osuosl.org>, <linux-kernel@...r.kernel.org>
CC:	<stuart.yoder@...escale.com>, <german.rivera@...escale.com>,
	<lijun.pan@...escale.com>, <scottwood@...escale.com>,
	<agraf@...e.de>, <bhamciu1@...escale.com>, <R89243@...escale.com>,
	<bhupesh.sharma@...escale.com>, <nir.erez@...escale.com>,
	<richard.schmitt@...escale.com>, <dan.carpenter@...cle.com>,
	Itai Katz <itai.katz@...escale.com>
Subject: [PATCH 4/5] staging: fsl-mc: add counter to track number of root DPRCs

From: Itai Katz <itai.katz@...escale.com>

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@...escale.com>
---
 drivers/staging/fsl-mc/bus/mc-bus.c |   13 +++++++++++--
 1 file 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 37f51f3..8a2b99c 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)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ