diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:17 -0500 |
commit | 3ab4ee8f809cac9587e6795243349beda179f6ff (patch) | |
tree | 0bf83257812f99cc3341d3e6c49a1741c3d47cd4 | |
parent | 9f12563db1e079aaf9821104e6dfff4873b3f4b6 (diff) |
misc/c2port: convert to idr_alloc()
Convert to the much saner new idr interface.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/misc/c2port/core.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c index f428d86bfc10..f32550a74bdd 100644 --- a/drivers/misc/c2port/core.c +++ b/drivers/misc/c2port/core.c | |||
@@ -885,7 +885,7 @@ struct c2port_device *c2port_device_register(char *name, | |||
885 | struct c2port_ops *ops, void *devdata) | 885 | struct c2port_ops *ops, void *devdata) |
886 | { | 886 | { |
887 | struct c2port_device *c2dev; | 887 | struct c2port_device *c2dev; |
888 | int id, ret; | 888 | int ret; |
889 | 889 | ||
890 | if (unlikely(!ops) || unlikely(!ops->access) || \ | 890 | if (unlikely(!ops) || unlikely(!ops->access) || \ |
891 | unlikely(!ops->c2d_dir) || unlikely(!ops->c2ck_set) || \ | 891 | unlikely(!ops->c2d_dir) || unlikely(!ops->c2ck_set) || \ |
@@ -897,22 +897,18 @@ struct c2port_device *c2port_device_register(char *name, | |||
897 | if (unlikely(!c2dev)) | 897 | if (unlikely(!c2dev)) |
898 | return ERR_PTR(-ENOMEM); | 898 | return ERR_PTR(-ENOMEM); |
899 | 899 | ||
900 | ret = idr_pre_get(&c2port_idr, GFP_KERNEL); | 900 | idr_preload(GFP_KERNEL); |
901 | if (!ret) { | ||
902 | ret = -ENOMEM; | ||
903 | goto error_idr_get_new; | ||
904 | } | ||
905 | |||
906 | spin_lock_irq(&c2port_idr_lock); | 901 | spin_lock_irq(&c2port_idr_lock); |
907 | ret = idr_get_new(&c2port_idr, c2dev, &id); | 902 | ret = idr_alloc(&c2port_idr, c2dev, 0, 0, GFP_NOWAIT); |
908 | spin_unlock_irq(&c2port_idr_lock); | 903 | spin_unlock_irq(&c2port_idr_lock); |
904 | idr_preload_end(); | ||
909 | 905 | ||
910 | if (ret < 0) | 906 | if (ret < 0) |
911 | goto error_idr_get_new; | 907 | goto error_idr_alloc; |
912 | c2dev->id = id; | 908 | c2dev->id = ret; |
913 | 909 | ||
914 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, | 910 | c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, |
915 | "c2port%d", id); | 911 | "c2port%d", c2dev->id); |
916 | if (unlikely(IS_ERR(c2dev->dev))) { | 912 | if (unlikely(IS_ERR(c2dev->dev))) { |
917 | ret = PTR_ERR(c2dev->dev); | 913 | ret = PTR_ERR(c2dev->dev); |
918 | goto error_device_create; | 914 | goto error_device_create; |
@@ -946,10 +942,10 @@ error_device_create_bin_file: | |||
946 | 942 | ||
947 | error_device_create: | 943 | error_device_create: |
948 | spin_lock_irq(&c2port_idr_lock); | 944 | spin_lock_irq(&c2port_idr_lock); |
949 | idr_remove(&c2port_idr, id); | 945 | idr_remove(&c2port_idr, c2dev->id); |
950 | spin_unlock_irq(&c2port_idr_lock); | 946 | spin_unlock_irq(&c2port_idr_lock); |
951 | 947 | ||
952 | error_idr_get_new: | 948 | error_idr_alloc: |
953 | kfree(c2dev); | 949 | kfree(c2dev); |
954 | 950 | ||
955 | return ERR_PTR(ret); | 951 | return ERR_PTR(ret); |