Skip to contentSkip to conversation

use named constants for pci_power_t values

PATCH Applied Julia Lawall 4 participants 9 messages Jan 2, 2014 – Jan 6, 2014

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

cover use named constants for pci_power_t values

Replace numbers by named constants. The complete semantic patch used is as follows (http://coccinelle.lip6.fr/):

// <smpl>
@@
expression pdev;
@@

pci_set_power_state(pdev,
(
- 0
+ PCI_D0
|
- 1
+ PCI_D1
|
- 2
+ PCI_D2
|
- 3
+ PCI_D3hot
|
- 4
+ PCI_D3cold
|
- 5
+ PCI_UNKNOWN
|
- -1
+ PCI_POWER_ERROR
)
)

@@
expression e1,e2;
@@

pci_enable_wake(e1,
(
- 0
+ PCI_D0
|
- 1
+ PCI_D1
|
- 2
+ PCI_D2
|
- 3
+ PCI_D3hot
|
- 4
+ PCI_D3cold
|
- 5
+ PCI_UNKNOWN
|
- -1
+ PCI_POWER_ERROR
)
,e2)
// </smpl>

#1 lore raw

PATCH 1/3 mfd: sta2x11-mfd: use named constants for pci_power_t values

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev;
@@

pci_set_power_state(pdev,
- 0
+ PCI_D0
)
// </smpl>

---
 drivers/mfd/sta2x11-mfd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/sta2x11-mfd.c +1 -1
index 0d42e40..5b72db0 100644
@@ -529,7 +529,7 @@ static int sta2x11_mfd_resume(struct pci_dev *pdev)
 {
 	int err;
 
-	pci_set_power_state(pdev, 0);
+	pci_set_power_state(pdev, PCI_D0);
 	err = pci_enable_device(pdev);
 	if (err)
 		return err;
#2 lore raw

Re: [PATCH 1/3] mfd: sta2x11-mfd: use named constants for pci_power_t values

Quoted 10 lines · Julia Lawall

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev;
@@

Quoted 5 lines

pci_set_power_state(pdev,
- 0
+ PCI_D0
)
// </smpl>

I'm happy with the code and that you used Coccinelle to discover the issue, but I feel a little more explanation would be helpful to readers.

Why is (pci_power_t __force) 0 better than 0?

Quoted 20 lines
---
 drivers/mfd/sta2x11-mfd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/sta2x11-mfd.c +1 -1
index 0d42e40..5b72db0 100644
@@ -529,7 +529,7 @@ static int sta2x11_mfd_resume(struct pci_dev *pdev)
 {
 	int err;
 
-	pci_set_power_state(pdev, 0);
+	pci_set_power_state(pdev, PCI_D0);
 	err = pci_enable_device(pdev);
 	if (err)
 		return err;
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Re: [PATCH 1/3] mfd: sta2x11-mfd: use named constants for pci_power_t values

Quoted 18 lines · Lee Jones
Quoted 10 lines · Julia Lawall

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev;
@@

Quoted 5 lines

pci_set_power_state(pdev,
- 0
+ PCI_D0
)
// </smpl>

Quoted 5 lines

I'm happy with the code and that you used Coccinelle to discover the issue, but I feel a little more explanation would be helpful to readers.

Why is (pci_power_t __force) 0 better than 0?

I wasn't particularly attached to the cast, and I don't know if it is an issue. But in trying to understand the code, I found PCI_D0 more understandable than 0.

julia

Quoted 31 lines
Quoted 12 lines
---
 drivers/mfd/sta2x11-mfd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/sta2x11-mfd.c +0 -0
index 0d42e40..5b72db0 100644

drivers/mfd/sta2x11-mfd.c static int sta2x11_mfd_resume(struct pci_dev *pdev) · line 535

Quoted 8 lines
drivers/mfd/sta2x11-mfd.c +1 -1
@@ -529,7 +529,7 @@ static int sta2x11_mfd_resume(struct pci_dev *pdev)
 {
 	int err;
 
-	pci_set_power_state(pdev, 0);
+	pci_set_power_state(pdev, PCI_D0);
 	err = pci_enable_device(pdev);
 	if (err)
 		return err;

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead

Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH 1/3] mfd: sta2x11-mfd: use named constants for pci_power_t values

Quoted 20 lines
Quoted 20 lines
Quoted 10 lines

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev;
@@

Quoted 5 lines

pci_set_power_state(pdev,
- 0
+ PCI_D0
)
// </smpl>

I'm happy with the code and that you used Coccinelle to discover the issue, but I feel a little more explanation would be helpful to readers.

Quoted 5 lines
Quoted 1 line

Why is (pci_power_t __force) 0 better than 0?

I wasn't particularly attached to the cast, and I don't know if it is an issue. But in trying to understand the code, I found PCI_D0 more understandable than 0.

Well I don't want to waste any of your or my time, so I'll apply the patch and add something along those lines to the commit message.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 2/3 ALSA: cs5535audio: use named constants for pci_power_t values

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev;
@@

pci_set_power_state(pdev,
- 3
+ PCI_D3hot
)
// </smpl>

---
 sound/pci/cs5535audio/cs5535audio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/cs5535audio/cs5535audio.c +1 -1
index 902bebd..c0d2835 100644
@@ -253,7 +253,7 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)
 static int snd_cs5535audio_free(struct cs5535audio *cs5535au)
 {
 	synchronize_irq(cs5535au->irq);
-	pci_set_power_state(cs5535au->pci, 3);
+	pci_set_power_state(cs5535au->pci, PCI_D3hot);
 
 	if (cs5535au->irq >= 0)
 		free_irq(cs5535au->irq, cs5535au);
Applied
#6 lore raw

Re: [PATCH 2/3] ALSA: cs5535audio: use named constants for pci_power_t values

At Fri, 3 Jan 2014 00:40:30 +0100,

Quoted 11 lines · Julia Lawall

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev;
@@

Quoted 7 lines

pci_set_power_state(pdev,
- 3
+ PCI_D3hot
)
// </smpl>

Thanks, applied.

Takashi

Quoted 19 lines
---
 sound/pci/cs5535audio/cs5535audio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/cs5535audio/cs5535audio.c +1 -1
index 902bebd..c0d2835 100644
@@ -253,7 +253,7 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id)
 static int snd_cs5535audio_free(struct cs5535audio *cs5535au)
 {
 	synchronize_irq(cs5535au->irq);
-	pci_set_power_state(cs5535au->pci, 3);
+	pci_set_power_state(cs5535au->pci, PCI_D3hot);
 
 	if (cs5535au->irq >= 0)
 		free_irq(cs5535au->irq, cs5535au);
#7 lore raw

PATCH 3/3 smsc9420: use named constants for pci_power_t values

In reply to Julia Lawall

From: Julia Lawall <[email protected]>

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e1,e2;
@@

pci_enable_wake(e1,
- 0
+ PCI_D0
,e2)
// </smpl>

---
 drivers/net/ethernet/smsc/smsc9420.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/smsc/smsc9420.c +1 -1
index 9d6effe..d3b967a 100644
@@ -1540,7 +1540,7 @@ static int smsc9420_resume(struct pci_dev *pdev)
 
 	pci_set_master(pdev);
 
-	err = pci_enable_wake(pdev, 0, 0);
+	err = pci_enable_wake(pdev, PCI_D0, 0);
 	if (err)
 		netif_warn(pd, ifup, pd->dev, "pci_enable_wake failed: %d\n",
 			   err);