Skip to contentSkip to conversation

staging: rts5208: Replace pci_enable_device with pcim_enable_device

PATCH Superseded Amitoj Kaur Chawla 2 participants 3 messages Feb 23, 2016 – Mar 11, 2016 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: rts5208: Replace pci_enable_device with pcim_enable_device

Devm_ functions allocate memory that is automatically freed when a driver detaches.

Replace pci_enable_device with pcim_enable_device. Remove unnecessary pci_disable_device and pci_release_regions from probe and remove functions in rts5208 driver.

---
Changes in v2:
-Removal of pci_set_drvdata will be sent in a later patch series

 drivers/staging/rts5208/rtsx.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/staging/rts5208/rtsx.c +2 -10
index 5dfcdfb..7882193 100644
@@ -329,7 +329,6 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state)
 
 	pci_save_state(pci);
 	pci_enable_wake(pci, pci_choose_state(pci, state), 1);
-	pci_disable_device(pci);
 	pci_set_power_state(pci, pci_choose_state(pci, state));
 
 	/* unlock the device pointers */
@@ -353,7 +352,7 @@ static int rtsx_resume(struct pci_dev *pci)
 
 	pci_set_power_state(pci, PCI_D0);
 	pci_restore_state(pci);
-	if (pci_enable_device(pci) < 0) {
+	if (pcim_enable_device(pci) < 0) {
 		dev_err(&dev->pci->dev,
 			"%s: pci_enable_device failed, disabling device\n",
 			CR_DRIVER_NAME);
@@ -403,8 +402,6 @@ static void rtsx_shutdown(struct pci_dev *pci)
 
 	if (chip->msi_en)
 		pci_disable_msi(pci);
-
-	pci_disable_device(pci);
 }
 
 static int rtsx_control_thread(void *__dev)
@@ -656,9 +653,6 @@ static void rtsx_release_resources(struct rtsx_dev *dev)
 	if (dev->remap_addr)
 		iounmap(dev->remap_addr);
 
-	pci_disable_device(dev->pci);
-	pci_release_regions(dev->pci);
-
 	rtsx_release_chip(dev->chip);
 	kfree(dev->chip);
 }
@@ -850,7 +844,7 @@ static int rtsx_probe(struct pci_dev *pci,
 
 	dev_dbg(&pci->dev, "Realtek PCI-E card reader detected\n");
 
-	err = pci_enable_device(pci);
+	err = pcim_enable_device(pci);
 	if (err < 0) {
 		dev_err(&pci->dev, "PCI enable device failed!\n");
 		return err;
@@ -871,8 +865,6 @@ static int rtsx_probe(struct pci_dev *pci,
 	host = scsi_host_alloc(&rtsx_host_template, sizeof(*dev));
 	if (!host) {
 		dev_err(&pci->dev, "Unable to allocate the scsi host\n");
-		pci_release_regions(pci);
-		pci_disable_device(pci);
 		return -ENOMEM;
 	}
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 20 lines · Amitoj Kaur Chawla

Devm_ functions allocate memory that is automatically freed when a driver detaches.

Replace pci_enable_device with pcim_enable_device. Remove unnecessary pci_disable_device and pci_release_regions from probe and remove functions in rts5208 driver.

---
Changes in v2:
-Removal of pci_set_drvdata will be sent in a later patch series

 drivers/staging/rts5208/rtsx.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/staging/rts5208/rtsx.c +0 -0
index 5dfcdfb..7882193 100644

drivers/staging/rts5208/rtsx.c static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) · line 334

Quoted 7 lines
drivers/staging/rts5208/rtsx.c +0 -1
@@ -329,7 +329,6 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state)
 
 	pci_save_state(pci);
 	pci_enable_wake(pci, pci_choose_state(pci, state), 1);
-	pci_disable_device(pci);
 	pci_set_power_state(pci, pci_choose_state(pci, state));
 
 	/* unlock the device pointers */

Are you sure this works? Does the PCI core now control the disable/enable of the device in the suspend/resume code paths just because pcim_enable_device() is called? I can't see that in the PCI core code, but I might be missing something...

thanks,

greg k-h

#2 lore raw
Quoted 18 lines · Greg KH

drivers/staging/rts5208/rtsx.c static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) · line 334

Quoted 12 lines
drivers/staging/rts5208/rtsx.c +0 -1
index 5dfcdfb..7882193 100644
@@ -329,7 +329,6 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state)
 
      pci_save_state(pci);
      pci_enable_wake(pci, pci_choose_state(pci, state), 1);
-     pci_disable_device(pci);
      pci_set_power_state(pci, pci_choose_state(pci, state));
 
      /* unlock the device pointers */

Are you sure this works? Does the PCI core now control the disable/enable of the device in the suspend/resume code paths just because pcim_enable_device() is called? I can't see that in the PCI core code, but I might be missing something...

Quoted 3 lines

thanks,

greg k-h

I checked previous commits related to pcim_enable_device, no one is modifying the suspend and resume code paths so I think I am wrong here. Sorry about that. I should have checked this beforehand.

I'll send v3 modifying only probe/remove paths for pcim_enable_device.

Amitoj