Skip to content

Commit 4c9ca2f

Browse files
author
Matthew Wilcox
committed
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>
1 parent 37ae133 commit 4c9ca2f

1 file changed

Lines changed: 5 additions & 18 deletions

File tree

‎drivers/misc/cb710/core.c‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/gfp.h>
1717

1818
static DEFINE_IDA(cb710_ida);
19-
static DEFINE_SPINLOCK(cb710_ida_lock);
2019

2120
void cb710_pci_update_config_reg(struct pci_dev *pdev,
2221
int reg, uint32_t mask, uint32_t xor)
@@ -205,7 +204,6 @@ static int cb710_probe(struct pci_dev *pdev,
205204
const struct pci_device_id *ent)
206205
{
207206
struct cb710_chip *chip;
208-
unsigned long flags;
209207
u32 val;
210208
int err;
211209
int n = 0;
@@ -256,18 +254,10 @@ static int cb710_probe(struct pci_dev *pdev,
256254
if (err)
257255
return err;
258256

259-
do {
260-
if (!ida_pre_get(&cb710_ida, GFP_KERNEL))
261-
return -ENOMEM;
262-
263-
spin_lock_irqsave(&cb710_ida_lock, flags);
264-
err = ida_get_new(&cb710_ida, &chip->platform_id);
265-
spin_unlock_irqrestore(&cb710_ida_lock, flags);
266-
267-
if (err && err != -EAGAIN)
268-
return err;
269-
} while (err);
270-
257+
err = ida_alloc(&cb710_ida, GFP_KERNEL);
258+
if (err < 0)
259+
return err;
260+
chip->platform_id = err;
271261

272262
dev_info(&pdev->dev, "id %d, IO 0x%p, IRQ %d\n",
273263
chip->platform_id, chip->iobase, pdev->irq);
@@ -308,7 +298,6 @@ static int cb710_probe(struct pci_dev *pdev,
308298
static void cb710_remove_one(struct pci_dev *pdev)
309299
{
310300
struct cb710_chip *chip = pci_get_drvdata(pdev);
311-
unsigned long flags;
312301

313302
cb710_unregister_slot(chip, CB710_SLOT_SM);
314303
cb710_unregister_slot(chip, CB710_SLOT_MS);
@@ -317,9 +306,7 @@ static void cb710_remove_one(struct pci_dev *pdev)
317306
BUG_ON(atomic_read(&chip->slot_refs_count) != 0);
318307
#endif
319308

320-
spin_lock_irqsave(&cb710_ida_lock, flags);
321-
ida_remove(&cb710_ida, chip->platform_id);
322-
spin_unlock_irqrestore(&cb710_ida_lock, flags);
309+
ida_free(&cb710_ida, chip->platform_id);
323310
}
324311

325312
static const struct pci_device_id cb710_pci_tbl[] = {

0 commit comments

Comments
 (0)