]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dca: convert to idr_alloc()
authorTejun Heo <tj@kernel.org>
Wed, 20 Feb 2013 02:16:11 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:44 +0000 (16:53 +1100)
Convert to the much saner new idr interface.

Only compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
Cc: Shannon Nelson <shannon.nelson@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/dca/dca-sysfs.c

index 591b6597c00a68eee807559bb1237727a2f2e14a..126cf295b19847e1ccd6d571e6496cb297683c4e 100644 (file)
@@ -53,22 +53,19 @@ void dca_sysfs_remove_req(struct dca_provider *dca, int slot)
 int dca_sysfs_add_provider(struct dca_provider *dca, struct device *dev)
 {
        struct device *cd;
-       int err = 0;
+       int ret;
 
-idr_try_again:
-       if (!idr_pre_get(&dca_idr, GFP_KERNEL))
-               return -ENOMEM;
+       idr_preload(GFP_KERNEL);
        spin_lock(&dca_idr_lock);
-       err = idr_get_new(&dca_idr, dca, &dca->id);
+
+       ret = idr_alloc(&dca_idr, dca, 0, 0, GFP_NOWAIT);
+       if (ret >= 0)
+               dca->id = ret;
+
        spin_unlock(&dca_idr_lock);
-       switch (err) {
-       case 0:
-               break;
-       case -EAGAIN:
-               goto idr_try_again;
-       default:
-               return err;
-       }
+       idr_preload_end();
+       if (ret < 0)
+               return ret;
 
        cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id);
        if (IS_ERR(cd)) {