diff options
Diffstat (limited to 'drivers/misc/mic/bus/mic_bus.c')
-rw-r--r-- | drivers/misc/mic/bus/mic_bus.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/misc/mic/bus/mic_bus.c b/drivers/misc/mic/bus/mic_bus.c index 961ae90aae47..be37890abb93 100644 --- a/drivers/misc/mic/bus/mic_bus.c +++ b/drivers/misc/mic/bus/mic_bus.c | |||
@@ -25,9 +25,6 @@ | |||
25 | #include <linux/idr.h> | 25 | #include <linux/idr.h> |
26 | #include <linux/mic_bus.h> | 26 | #include <linux/mic_bus.h> |
27 | 27 | ||
28 | /* Unique numbering for mbus devices. */ | ||
29 | static DEFINE_IDA(mbus_index_ida); | ||
30 | |||
31 | static ssize_t device_show(struct device *d, | 28 | static ssize_t device_show(struct device *d, |
32 | struct device_attribute *attr, char *buf) | 29 | struct device_attribute *attr, char *buf) |
33 | { | 30 | { |
@@ -147,7 +144,8 @@ static void mbus_release_dev(struct device *d) | |||
147 | 144 | ||
148 | struct mbus_device * | 145 | struct mbus_device * |
149 | mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, | 146 | mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, |
150 | struct mbus_hw_ops *hw_ops, void __iomem *mmio_va) | 147 | struct mbus_hw_ops *hw_ops, int index, |
148 | void __iomem *mmio_va) | ||
151 | { | 149 | { |
152 | int ret; | 150 | int ret; |
153 | struct mbus_device *mbdev; | 151 | struct mbus_device *mbdev; |
@@ -166,13 +164,7 @@ mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, | |||
166 | mbdev->dev.release = mbus_release_dev; | 164 | mbdev->dev.release = mbus_release_dev; |
167 | mbdev->hw_ops = hw_ops; | 165 | mbdev->hw_ops = hw_ops; |
168 | mbdev->dev.bus = &mic_bus; | 166 | mbdev->dev.bus = &mic_bus; |
169 | 167 | mbdev->index = index; | |
170 | /* Assign a unique device index and hence name. */ | ||
171 | ret = ida_simple_get(&mbus_index_ida, 0, 0, GFP_KERNEL); | ||
172 | if (ret < 0) | ||
173 | goto free_mbdev; | ||
174 | |||
175 | mbdev->index = ret; | ||
176 | dev_set_name(&mbdev->dev, "mbus-dev%u", mbdev->index); | 168 | dev_set_name(&mbdev->dev, "mbus-dev%u", mbdev->index); |
177 | /* | 169 | /* |
178 | * device_register() causes the bus infrastructure to look for a | 170 | * device_register() causes the bus infrastructure to look for a |
@@ -180,22 +172,17 @@ mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, | |||
180 | */ | 172 | */ |
181 | ret = device_register(&mbdev->dev); | 173 | ret = device_register(&mbdev->dev); |
182 | if (ret) | 174 | if (ret) |
183 | goto ida_remove; | 175 | goto free_mbdev; |
184 | return mbdev; | 176 | return mbdev; |
185 | ida_remove: | ||
186 | ida_simple_remove(&mbus_index_ida, mbdev->index); | ||
187 | free_mbdev: | 177 | free_mbdev: |
188 | kfree(mbdev); | 178 | put_device(&mbdev->dev); |
189 | return ERR_PTR(ret); | 179 | return ERR_PTR(ret); |
190 | } | 180 | } |
191 | EXPORT_SYMBOL_GPL(mbus_register_device); | 181 | EXPORT_SYMBOL_GPL(mbus_register_device); |
192 | 182 | ||
193 | void mbus_unregister_device(struct mbus_device *mbdev) | 183 | void mbus_unregister_device(struct mbus_device *mbdev) |
194 | { | 184 | { |
195 | int index = mbdev->index; /* save for after device release */ | ||
196 | |||
197 | device_unregister(&mbdev->dev); | 185 | device_unregister(&mbdev->dev); |
198 | ida_simple_remove(&mbus_index_ida, index); | ||
199 | } | 186 | } |
200 | EXPORT_SYMBOL_GPL(mbus_unregister_device); | 187 | EXPORT_SYMBOL_GPL(mbus_unregister_device); |
201 | 188 | ||
@@ -207,7 +194,6 @@ static int __init mbus_init(void) | |||
207 | static void __exit mbus_exit(void) | 194 | static void __exit mbus_exit(void) |
208 | { | 195 | { |
209 | bus_unregister(&mic_bus); | 196 | bus_unregister(&mic_bus); |
210 | ida_destroy(&mbus_index_ida); | ||
211 | } | 197 | } |
212 | 198 | ||
213 | core_initcall(mbus_init); | 199 | core_initcall(mbus_init); |