path: root/drivers/mfd/rtsx_pcr.c
diff options
authorKent Overstreet <>2013-07-08 15:19:18 -0700
committerKent Overstreet <>2013-08-07 10:54:17 -0700
commit78742d998597406b336a6d8b3483b060469ebc79 (patch)
treef33f8d8ca570e9725ebb1ba3990fd99d33be7d81 /drivers/mfd/rtsx_pcr.c
parent3d52184ce9963200614691780d8e045817f847fb (diff)
idr: Remove unneeded idr locking, idr_preload() usage
Our new idr implementation does its own locking, instead of forcing it onto the callers like the old implementation. Many of the existing idr users need locking for more than just idr_alloc()/idr_remove()/idr_find() - they're taking refcounts and such under their locks and we can't touch those. But a significant number of users had locks that protected nothing more than the idr data structures itself - those we can get rid of. Note that we have to be careful when removing locks; in some places, locks appear to only be protecting idr_alloc()/idr_remove() calls but they're also used by other code that needs to ensure the idr isn't modified while it's doing something else - so ideally we want to delete the lock that protected the idr, or else we have to carefully audit all the other places it's used. There's also a fair number of places where things were being done under the idr lock unnecessarily; drivers/dca/dca-sysfs.c is a good example. dca->id is set to the id idr_alloc() returns under the lock - but there's no idr_find() calls under the lock, and dca->id isn't touched in the idr_remove() paths. So the lock can be safely deleted. The really nice thing about deleting this unnecessary locking is that it lets us trivially delete a lot of now unnecessary idr_preload() - with idr doing its own locking, we can pass GFP_KERNEL to idr_alloc() just fine. Signed-off-by: Kent Overstreet <> Cc: Andrew Morton <> Cc: Tejun Heo <> Cc: David Airlie <> Cc: Tom Tucker <> Cc: Steve Wise <> Cc: Roland Dreier <> Cc: Sean Hefty <> Cc: Hal Rosenstock <> Cc: Alasdair Kergon <> Cc: Cc: Samuel Ortiz <> Cc: Alex Dubov <> Cc: Arnd Bergmann <> Cc: Greg Kroah-Hartman <> Cc: Chris Ball <> Cc: "James E.J. Bottomley" <> Cc: Willem Riede <> Cc: "Kai Mäkisara" <> Cc: "Nicholas A. Bellinger" <> Cc: Li Zefan <> Cc: Vlad Yasevich <> Cc: Neil Horman <> Cc: "David S. Miller" <> Cc: Dave Airlie <> Cc: Alon Levy <> Cc: Guennadi Liakhovetski <> Cc: Christoph Hellwig <> Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc:
Diffstat (limited to 'drivers/mfd/rtsx_pcr.c')
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index 862deedbe631..be5913a9f48d 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -40,7 +40,6 @@ 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 struct mfd_cell rtsx_pcr_cells[] = {
@@ -1101,16 +1100,12 @@ 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, GFP_NOWAIT);
- if (ret >= 0)
- pcr->id = ret;
- spin_unlock(&rtsx_pci_lock);
- idr_preload_end();
+ ret = idr_alloc(&rtsx_pci_idr, pcr, GFP_KERNEL);
if (ret < 0)
goto free_handle;
+ pcr->id = ret;
pcr->pci = pcidev;
dev_set_drvdata(&pcidev->dev, handle);
@@ -1216,9 +1211,7 @@ static void rtsx_pci_remove(struct pci_dev *pcidev)
- spin_lock(&rtsx_pci_lock);
idr_remove(&rtsx_pci_idr, pcr->id);
- spin_unlock(&rtsx_pci_lock);