]> www.infradead.org Git - users/willy/xarray.git/commitdiff
rtsx_pcr: Convert to IDA
authorMatthew Wilcox <willy@infradead.org>
Tue, 12 Feb 2019 18:48:38 +0000 (13:48 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:16 +0000 (21:38 -0400)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/misc/cardreader/rtsx_pcr.c

index b4a66b64f74229486a73ca86783a7f1eb341a2c6..d376a204c948e65212d014c0b44f689fe61135f0 100644 (file)
@@ -27,8 +27,7 @@ static bool msi_en = true;
 module_param(msi_en, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(msi_en, "Enable MSI");
 
-static DEFINE_IDR(rtsx_pci_idr);
-static DEFINE_SPINLOCK(rtsx_pci_lock);
+static DEFINE_IDA(rtsx_ids);
 
 static struct mfd_cell rtsx_pcr_cells[] = {
        [RTSX_SD_CARD] = {
@@ -1466,16 +1465,11 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
        }
        handle->pcr = pcr;
 
-       idr_preload(GFP_KERNEL);
-       spin_lock(&rtsx_pci_lock);
-       ret = idr_alloc(&rtsx_pci_idr, pcr, 0, 0, GFP_NOWAIT);
-       if (ret >= 0)
-               pcr->id = ret;
-       spin_unlock(&rtsx_pci_lock);
-       idr_preload_end();
+       ret = ida_alloc(&rtsx_ids, GFP_KERNEL);
        if (ret < 0)
                goto free_handle;
 
+       pcr->id = ret;
        pcr->pci = pcidev;
        dev_set_drvdata(&pcidev->dev, handle);
 
@@ -1586,9 +1580,7 @@ static void rtsx_pci_remove(struct pci_dev *pcidev)
        pci_release_regions(pcidev);
        pci_disable_device(pcidev);
 
-       spin_lock(&rtsx_pci_lock);
-       idr_remove(&rtsx_pci_idr, pcr->id);
-       spin_unlock(&rtsx_pci_lock);
+       ida_free(&rtsx_ids, pcr->id);
 
        kfree(pcr->slots);
        kfree(pcr);