diff options
author | Lee Duncan <lduncan@suse.com> | 2015-10-01 14:59:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-10-04 14:42:22 -0400 |
commit | cfcf6a91aa0d59faddb423a65230eea7f230d057 (patch) | |
tree | 3a5b491e7a888ffcff76ea1df505a49dc794a31b /drivers/base | |
parent | fa40ae34441286b2cb595468ef781e24573e9e7d (diff) |
base: soc: siplify ida usage
Simplify ida index allocation and removal by
using the ida_simple_* helper functions
Signed-off-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/soc.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 39fca01c8fa1..75b98aad6faf 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | 17 | ||
18 | static DEFINE_IDA(soc_ida); | 18 | static DEFINE_IDA(soc_ida); |
19 | static DEFINE_SPINLOCK(soc_lock); | ||
20 | 19 | ||
21 | static ssize_t soc_info_get(struct device *dev, | 20 | static ssize_t soc_info_get(struct device *dev, |
22 | struct device_attribute *attr, | 21 | struct device_attribute *attr, |
@@ -122,20 +121,10 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr | |||
122 | } | 121 | } |
123 | 122 | ||
124 | /* Fetch a unique (reclaimable) SOC ID. */ | 123 | /* Fetch a unique (reclaimable) SOC ID. */ |
125 | do { | 124 | ret = ida_simple_get(&soc_ida, 0, 0, GFP_KERNEL); |
126 | if (!ida_pre_get(&soc_ida, GFP_KERNEL)) { | 125 | if (ret < 0) |
127 | ret = -ENOMEM; | ||
128 | goto out2; | ||
129 | } | ||
130 | |||
131 | spin_lock(&soc_lock); | ||
132 | ret = ida_get_new(&soc_ida, &soc_dev->soc_dev_num); | ||
133 | spin_unlock(&soc_lock); | ||
134 | |||
135 | } while (ret == -EAGAIN); | ||
136 | |||
137 | if (ret) | ||
138 | goto out2; | 126 | goto out2; |
127 | soc_dev->soc_dev_num = ret; | ||
139 | 128 | ||
140 | soc_dev->attr = soc_dev_attr; | 129 | soc_dev->attr = soc_dev_attr; |
141 | soc_dev->dev.bus = &soc_bus_type; | 130 | soc_dev->dev.bus = &soc_bus_type; |
@@ -151,7 +140,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr | |||
151 | return soc_dev; | 140 | return soc_dev; |
152 | 141 | ||
153 | out3: | 142 | out3: |
154 | ida_remove(&soc_ida, soc_dev->soc_dev_num); | 143 | ida_simple_remove(&soc_ida, soc_dev->soc_dev_num); |
155 | out2: | 144 | out2: |
156 | kfree(soc_dev); | 145 | kfree(soc_dev); |
157 | out1: | 146 | out1: |
@@ -161,7 +150,7 @@ out1: | |||
161 | /* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */ | 150 | /* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */ |
162 | void soc_device_unregister(struct soc_device *soc_dev) | 151 | void soc_device_unregister(struct soc_device *soc_dev) |
163 | { | 152 | { |
164 | ida_remove(&soc_ida, soc_dev->soc_dev_num); | 153 | ida_simple_remove(&soc_ida, soc_dev->soc_dev_num); |
165 | 154 | ||
166 | device_unregister(&soc_dev->dev); | 155 | device_unregister(&soc_dev->dev); |
167 | } | 156 | } |