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

cb710: Convert to new IDA API

Eliminates the custom spinlock and the call to ida_pre_get.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
Acked-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

+5 -18
+5 -18
drivers/misc/cb710/core.c
··· 16 16 #include <linux/gfp.h> 17 17 18 18 static DEFINE_IDA(cb710_ida); 19 - static DEFINE_SPINLOCK(cb710_ida_lock); 20 19 21 20 void cb710_pci_update_config_reg(struct pci_dev *pdev, 22 21 int reg, uint32_t mask, uint32_t xor) ··· 204 205 const struct pci_device_id *ent) 205 206 { 206 207 struct cb710_chip *chip; 207 - unsigned long flags; 208 208 u32 val; 209 209 int err; 210 210 int n = 0; ··· 254 256 if (err) 255 257 return err; 256 258 257 - do { 258 - if (!ida_pre_get(&cb710_ida, GFP_KERNEL)) 259 - return -ENOMEM; 260 - 261 - spin_lock_irqsave(&cb710_ida_lock, flags); 262 - err = ida_get_new(&cb710_ida, &chip->platform_id); 263 - spin_unlock_irqrestore(&cb710_ida_lock, flags); 264 - 265 - if (err && err != -EAGAIN) 266 - return err; 267 - } while (err); 268 - 259 + err = ida_alloc(&cb710_ida, GFP_KERNEL); 260 + if (err < 0) 261 + return err; 262 + chip->platform_id = err; 269 263 270 264 dev_info(&pdev->dev, "id %d, IO 0x%p, IRQ %d\n", 271 265 chip->platform_id, chip->iobase, pdev->irq); ··· 298 308 static void cb710_remove_one(struct pci_dev *pdev) 299 309 { 300 310 struct cb710_chip *chip = pci_get_drvdata(pdev); 301 - unsigned long flags; 302 311 303 312 cb710_unregister_slot(chip, CB710_SLOT_SM); 304 313 cb710_unregister_slot(chip, CB710_SLOT_MS); ··· 306 317 BUG_ON(atomic_read(&chip->slot_refs_count) != 0); 307 318 #endif 308 319 309 - spin_lock_irqsave(&cb710_ida_lock, flags); 310 - ida_remove(&cb710_ida, chip->platform_id); 311 - spin_unlock_irqrestore(&cb710_ida_lock, flags); 320 + ida_free(&cb710_ida, chip->platform_id); 312 321 } 313 322 314 323 static const struct pci_device_id cb710_pci_tbl[] = {