From: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx> The IDR now has its own locking, so remove the dca lock and calls to idr_preload. Also, there is no need to call idr_destroy on a freshly initialised IDR. Signed-off-by: Matthew Wilcox <mawilcox@xxxxxxxxxxxxx> --- drivers/dca/dca-sysfs.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/dca/dca-sysfs.c b/drivers/dca/dca-sysfs.c index 126cf295b198..afa1d5c0f55e 100644 --- a/drivers/dca/dca-sysfs.c +++ b/drivers/dca/dca-sysfs.c @@ -31,7 +31,6 @@ static struct class *dca_class; static struct idr dca_idr; -static spinlock_t dca_idr_lock; int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot) { @@ -55,23 +54,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_alloc(&dca_idr, dca, 0, 0, GFP_KERNEL); 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); return PTR_ERR(cd); } dca->cd = cd; @@ -82,21 +72,17 @@ 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); } int __init dca_sysfs_init(void) { idr_init(&dca_idr); - spin_lock_init(&dca_idr_lock); dca_class = class_create(THIS_MODULE, "dca"); - if (IS_ERR(dca_class)) { - idr_destroy(&dca_idr); + if (IS_ERR(dca_class)) return PTR_ERR(dca_class); - } + return 0; } -- 2.15.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>