Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Lee Duncan and committed by
Greg Kroah-Hartman
cfcf6a91 fa40ae34

+5 -16
+5 -16
drivers/base/soc.c
··· 16 16 #include <linux/err.h> 17 17 18 18 static DEFINE_IDA(soc_ida); 19 - static DEFINE_SPINLOCK(soc_lock); 20 19 21 20 static ssize_t soc_info_get(struct device *dev, 22 21 struct device_attribute *attr, ··· 121 122 } 122 123 123 124 /* Fetch a unique (reclaimable) SOC ID. */ 124 - do { 125 - if (!ida_pre_get(&soc_ida, GFP_KERNEL)) { 126 - ret = -ENOMEM; 127 - goto out2; 128 - } 129 - 130 - spin_lock(&soc_lock); 131 - ret = ida_get_new(&soc_ida, &soc_dev->soc_dev_num); 132 - spin_unlock(&soc_lock); 133 - 134 - } while (ret == -EAGAIN); 135 - 136 - if (ret) 125 + ret = ida_simple_get(&soc_ida, 0, 0, GFP_KERNEL); 126 + if (ret < 0) 137 127 goto out2; 128 + soc_dev->soc_dev_num = ret; 138 129 139 130 soc_dev->attr = soc_dev_attr; 140 131 soc_dev->dev.bus = &soc_bus_type; ··· 140 151 return soc_dev; 141 152 142 153 out3: 143 - ida_remove(&soc_ida, soc_dev->soc_dev_num); 154 + ida_simple_remove(&soc_ida, soc_dev->soc_dev_num); 144 155 out2: 145 156 kfree(soc_dev); 146 157 out1: ··· 150 161 /* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */ 151 162 void soc_device_unregister(struct soc_device *soc_dev) 152 163 { 153 - ida_remove(&soc_ida, soc_dev->soc_dev_num); 164 + ida_simple_remove(&soc_ida, soc_dev->soc_dev_num); 154 165 155 166 device_unregister(&soc_dev->dev); 156 167 }