Skip to contentSkip to conversation

scsi/pm8001: use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM)

PATCH Applied Yijing Wang 3 participants 5 messages Jun 18, 2013 – Jun 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 8/9 scsi/pm8001: use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM)

Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code.

---
 drivers/scsi/pm8001/pm8001_init.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +3 -4
index e4b9bc7..3861aa1 100644
@@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sas_ha_struct *sha = pci_get_drvdata(pdev);
 	struct pm8001_hba_info *pm8001_ha;
-	int i , pos;
+	int i;
 	u32 device_state;
 	pm8001_ha = sha->lldd_ha;
 	flush_workqueue(pm8001_wq);
 	scsi_block_requests(pm8001_ha->shost);
-	pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
-	if (pos == 0) {
-		printk(KERN_ERR " PCI PM not supported\n");
+	if (!pdev->pm_cap) {
+		dev_err(&pdev->dev, " PCI PM not supported\n");
 		return -ENODEV;
 	}
 	PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
Signature · 1 line
1.7.1
#1 lore raw

It works, thanks.

Lindar.

-----Original Message-----
From: Yijing Wang [mailto:[email protected]]
Sent: Tuesday, June 18, 2013 4:24 PM
To: James E.J. Bottomley
Cc: [email protected]; Hanjun Guo; [email protected]; Yijing Wang; [email protected]; [email protected]; [email protected]
Subject: [PATCH 8/9] scsi/pm8001: use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM)

Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code.

---
 drivers/scsi/pm8001/pm8001_init.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/scsi/pm8001/pm8001_init.c
index e4b9bc7..3861aa1 100644

drivers/scsi/pm8001/pm8001_init.c +0 -0
@@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev,

pm_message_t state) {
struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct pm8001_hba_info *pm8001_ha;
- int i , pos;
+ int i;
u32 device_state;
pm8001_ha = sha->lldd_ha; flush_workqueue(pm8001_wq); scsi_block_requests(pm8001_ha->shost);
- pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
- if (pos == 0) {
- printk(KERN_ERR " PCI PM not supported\n");
+ if (!pdev->pm_cap) {
+ dev_err(&pdev->dev, " PCI PM not supported\n");
return -ENODEV;
} PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
--
1.7.1

#2 lore raw
In reply to Yijing Wang

Hi,
Any comments?

Quoted 37 lines · Yijing Wang

Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code.

---
 drivers/scsi/pm8001/pm8001_init.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +3 -4
index e4b9bc7..3861aa1 100644
@@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sas_ha_struct *sha = pci_get_drvdata(pdev);
 	struct pm8001_hba_info *pm8001_ha;
-	int i , pos;
+	int i;
 	u32 device_state;
 	pm8001_ha = sha->lldd_ha;
 	flush_workqueue(pm8001_wq);
 	scsi_block_requests(pm8001_ha->shost);
-	pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
-	if (pos == 0) {
-		printk(KERN_ERR " PCI PM not supported\n");
+	if (!pdev->pm_cap) {
+		dev_err(&pdev->dev, " PCI PM not supported\n");
 		return -ENODEV;
 	}
 	PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
Signature · 2 lines
Thanks!
Yijing
#3 lore raw
In reply to Yijing Wang
Quoted 4 lines · Yijing Wang

Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code.

I think Lindar already replied to you, and tested it on hardware.

So you can add her:
Acked-by or Tested-by

Regards,
Jack

Quoted 33 lines
---
 drivers/scsi/pm8001/pm8001_init.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +3 -4
index e4b9bc7..3861aa1 100644
@@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sas_ha_struct *sha = pci_get_drvdata(pdev);
 	struct pm8001_hba_info *pm8001_ha;
-	int i , pos;
+	int i;
 	u32 device_state;
 	pm8001_ha = sha->lldd_ha;
 	flush_workqueue(pm8001_wq);
 	scsi_block_requests(pm8001_ha->shost);
-	pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
-	if (pos == 0) {
-		printk(KERN_ERR " PCI PM not supported\n");
+	if (!pdev->pm_cap) {
+		dev_err(&pdev->dev, " PCI PM not supported\n");
 		return -ENODEV;
 	}
 	PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);
#4 lore raw
Quoted 6 lines · Jack Wang
Quoted 4 lines · Yijing Wang

Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code.

I think Lindar already replied to you, and tested it on hardware.

I didn't receive the reply, I will check my email client, maybe I lose some emails. Jack, Lindar thank you very much.

Quoted 3 lines

So you can add her:
Acked-by or Tested-by

ok, I will add them.

Quoted 41 lines

Regards,
Jack

Quoted 23 lines
---
 drivers/scsi/pm8001/pm8001_init.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/scsi/pm8001/pm8001_init.c +1 -1
index e4b9bc7..3861aa1 100644
@@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 {
 	struct sas_ha_struct *sha = pci_get_drvdata(pdev);
 	struct pm8001_hba_info *pm8001_ha;
-	int i , pos;
+	int i;
 	u32 device_state;
 	pm8001_ha = sha->lldd_ha;

drivers/scsi/pm8001/pm8001_init.c static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) · line 924

Quoted 10 lines
drivers/scsi/pm8001/pm8001_init.c +2 -3
 	flush_workqueue(pm8001_wq);
 	scsi_block_requests(pm8001_ha->shost);
-	pos = pci_find_capability(pdev, PCI_CAP_ID_PM);
-	if (pos == 0) {
-		printk(KERN_ERR " PCI PM not supported\n");
+	if (!pdev->pm_cap) {
+		dev_err(&pdev->dev, " PCI PM not supported\n");
 		return -ENODEV;
 	}
 	PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF);

.

Signature · 2 lines
Thanks!
Yijing