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: <77238f931cd168e25f836e0d0fdf0eeab4eb9056.1442263512.git.lduncan@suse.com>
Date:	Tue, 15 Sep 2015 09:46:10 -0700
From:	Lee Duncan <lduncan@...e.com>
To:	<linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Cc:	Hannes Reinecke <hare@...e.com>,
	Johannes Thumshirn <jthumshirn@...e.de>,
	Christoph Hellwig <hch@...radead.org>,
	Lee Duncan <lduncan@...e.com>
Subject: [PATCH 10/17] Update the DCA DMA driver to use idr helper functions.

Signed-off-by: Lee Duncan <lduncan@...e.com>
---
 drivers/dca/dca-sysfs.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c
index 126cf295b198..8930707df295 100644
--- a/drivers/dca/dca-sysfs.c
+++ b/drivers/dca/dca-sysfs.c
@@ -55,23 +55,14 @@ int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev)
 	struct device *cd;
 	int ret;
 
-	idr_preload(GFP_KERNEL);
-	spin_lock(&dca_idr_lock);
-
-	ret = idr_alloc(&dca_idr, dca, 0, 0, GFP_NOWAIT);
-	if (ret >= 0)
-		dca->id = ret;
-
-	spin_unlock(&dca_idr_lock);
-	idr_preload_end();
+	ret = idr_get_index(&dca_idr, &dca_idr_lock, dca);
 	if (ret < 0)
 		return ret;
+	dca->id = ret;
 
 	cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
 	if (IS_ERR(cd)) {
-		spin_lock(&dca_idr_lock);
-		idr_remove(&dca_idr, dca->id);
-		spin_unlock(&dca_idr_lock);
+		idr_put_index(&dca_idr, &dca_idr_lock, dca->id);
 		return PTR_ERR(cd);
 	}
 	dca->cd = cd;
@@ -82,9 +73,7 @@ void dca_sysfs_remove_provider(struct dca_provider *dca)
 {
 	device_unregister(dca->cd);
 	dca->cd = NULL;
-	spin_lock(&dca_idr_lock);
-	idr_remove(&dca_idr, dca->id);
-	spin_unlock(&dca_idr_lock);
+	idr_put_index(&dca_idr, &dca_idr_lock, dca->id);
 }
 
 int __init dca_sysfs_init(void)
-- 
2.1.4

--
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