Skip to contentSkip to conversation

staging: rts5208: Replace pci_enable_device with pcim_enable_device

PATCH Superseded Amitoj Kaur Chawla 2 participants 7 messages Feb 22, 2016 – Feb 23, 2016 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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

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.

Additionally, an unnecessary platform_set_drvdata() has been removed since the driver core clears the driver data to NULL after device release or on probe failure. There is no need to manually clear the device driver data to NULL.

---
 drivers/staging/rts5208/rtsx.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/staging/rts5208/rtsx.c +2 -13
index 5dfcdfb..b829c42 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;
@@ -860,7 +854,6 @@ static int rtsx_probe(struct pci_dev *pci,
 	if (err < 0) {
 		dev_err(&pci->dev, "PCI request regions for %s failed!\n",
 			CR_DRIVER_NAME);
-		pci_disable_device(pci);
 		return err;
 	}
 
@@ -871,8 +864,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;
 	}
 
@@ -1009,8 +1000,6 @@ static void rtsx_remove(struct pci_dev *pci)
 
 	quiesce_and_remove_host(dev);
 	release_everything(dev);
-
-	pci_set_drvdata(pci, NULL);
 }
 
 /* PCI IDs */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 8 lines · Amitoj Kaur Chawla

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.

Additionally, an unnecessary platform_set_drvdata() has been removed since the driver core clears the driver data to NULL after device release or on probe failure. There is no need to manually clear the device driver data to NULL.

Aren't these completely separate issues? The latter could be good to automate.

julia

Quoted 90 lines
---
 drivers/staging/rts5208/rtsx.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/staging/rts5208/rtsx.c +2 -13
index 5dfcdfb..b829c42 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;
@@ -860,7 +854,6 @@ static int rtsx_probe(struct pci_dev *pci,
 	if (err < 0) {
 		dev_err(&pci->dev, "PCI request regions for %s failed!\n",
 			CR_DRIVER_NAME);
-		pci_disable_device(pci);
 		return err;
 	}
 
@@ -871,8 +864,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;
 	}
 
@@ -1009,8 +1000,6 @@ static void rtsx_remove(struct pci_dev *pci)
 
 	quiesce_and_remove_host(dev);
 	release_everything(dev);
-
-	pci_set_drvdata(pci, NULL);
 }
 
 /* PCI IDs */
Signature · 8 lines
1.9.1

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160222184544.GA29097%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.
#2 lore raw
Quoted 11 lines · Julia Lawall
Quoted 8 lines · Amitoj Kaur Chawla

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.

Additionally, an unnecessary platform_set_drvdata() has been removed since the driver core clears the driver data to NULL after device release or on probe failure. There is no need to manually clear the device driver data to NULL.

Quoted 5 lines

Aren't these completely separate issues? The latter could be good to automate.

julia

I'll write a separate script for the latter, though a lot of people have submitted patches for this change so there'll be less occurences I think, nonetheless will write one.

One of my previous patches that Greg accepted for switching to devm functions had a similar thing so I thought it was okay. I can divide the changes into 2 patches and send as a series separately if you prefer.

Amitoj

#3 lore raw
Quoted 17 lines · Amitoj Kaur Chawla
Quoted 11 lines · Julia Lawall
Quoted 8 lines · Amitoj Kaur Chawla

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.

Additionally, an unnecessary platform_set_drvdata() has been removed since the driver core clears the driver data to NULL after device release or on probe failure. There is no need to manually clear the device driver data to NULL.

Quoted 5 lines

Aren't these completely separate issues? The latter could be good to automate.

julia

Quoted 8 lines

I'll write a separate script for the latter, though a lot of people have submitted patches for this change so there'll be less occurences I think, nonetheless will write one.

One of my previous patches that Greg accepted for switching to devm functions had a similar thing so I thought it was okay. I can divide the changes into 2 patches and send as a series separately if you prefer.

I think it would be better. There is no relation to the devm issue.

julia

#4 lore raw
Quoted 6 lines · Julia Lawall
Quoted 6 lines
Quoted 2 lines

I'll write a separate script for the latter, though a lot of people have submitted patches for this change so there'll be less occurences I think, nonetheless will write one.

Quoted 8 lines
Quoted 4 lines

One of my previous patches that Greg accepted for switching to devm functions had a similar thing so I thought it was okay. I can divide the changes into 2 patches and send as a series separately if you prefer.

I think it would be better. There is no relation to the devm issue.

julia

Will do.

Amitoj

#5 lore raw
Quoted 7 lines · Amitoj Kaur Chawla
Quoted 6 lines · Julia Lawall
Quoted 6 lines
Quoted 2 lines

I'll write a separate script for the latter, though a lot of people have submitted patches for this change so there'll be less occurences I think, nonetheless will write one.

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

One of my previous patches that Greg accepted for switching to devm functions had a similar thing so I thought it was okay. I can divide the changes into 2 patches and send as a series separately if you prefer.

I think it would be better. There is no relation to the devm issue.

julia

I'll resend this patch without the pci_set_drvdata removal and send the removal in a different series which will be using the semantic patch I've written to remove these occurrences.

Amitoj

#6 lore raw
Quoted 14 lines · Amitoj Kaur Chawla
Quoted 12 lines · Amitoj Kaur Chawla
Quoted 11 lines · Julia Lawall
Quoted 10 lines
Quoted 2 lines

I'll write a separate script for the latter, though a lot of people have submitted patches for this change so there'll be less occurences I think, nonetheless will write one.

One of my previous patches that Greg accepted for switching to devm functions had a similar thing so I thought it was okay. I can divide the changes into 2 patches and send as a series separately if you prefer.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

I think it would be better. There is no relation to the devm issue.

julia

I'll resend this patch without the pci_set_drvdata removal and send the removal in a different series which will be using the semantic patch I've written to remove these occurrences.

Sounds good.

julia

Quoted 10 lines

Amitoj

Signature · 5 lines
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CA%2B5yK5FR5jANUfhtpaOJ_Twk8zKMwztWO5ho9LD6hpu7V3La2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.