Skip to contentSkip to conversation

Type-checking for pci layer

PATCH Pavel Machek 3 participants 6 messages Nov 3, 2004 PCI

lore
Share & tools
lore
#0 lore raw

Hi!

This adds type-checking to PCI layer. u32 has been replaced with defines, so it is no longer easy to confuse it with system suspend level. Patrick included it in his power tree, but I guess direct merging to you (Andrew) is faster/easier way to go? Please apply,

Pavel

Acked-by Patrick Mochel
include/linux/pci.h +12 -4
@@ -480,6 +480,14 @@
 #define DEVICE_COUNT_COMPATIBLE	4
 #define DEVICE_COUNT_RESOURCE	12
 
+typedef int __bitwise pci_power_t;
+
+#define PCI_D0	((pci_power_t __force) 0)
+#define PCI_D1	((pci_power_t __force) 1)
+#define PCI_D2	((pci_power_t __force) 2)
+#define PCI_D3hot	((pci_power_t __force) 3)
+#define PCI_D3cold	((pci_power_t __force) 4)
+
 /*
  * The pci_dev structure is used to describe PCI devices.
  */
@@ -508,7 +526,7 @@
 					   this if your device has broken DMA
 					   or supports 64-bit transfers.  */
 
-	u32             current_state;  /* Current operating state. In ACPI-speak,
+	pci_power_t     current_state;  /* Current operating state. In ACPI-speak,
 					   this is D0-D3, D0 being fully functional,
 					   and D3 being off. */
 
@@ -645,7 +663,7 @@
 	struct pci_dynids dynids;
 };
 
-#define	to_pci_driver(drv) container_of(drv,struct pci_driver, driver)
+#define	to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
 
 /**
  * PCI_DEVICE - macro used to describe a specific pci device
@@ -781,8 +799,8 @@
 /* Power management related routines */
 int pci_save_state(struct pci_dev *dev, u32 *buffer);
 int pci_restore_state(struct pci_dev *dev, u32 *buffer);
-int pci_set_power_state(struct pci_dev *dev, int state);
-int pci_enable_wake(struct pci_dev *dev, u32 state, int enable);
+int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
+int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
 
 /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
 void pci_bus_assign_resources(struct pci_bus *bus);
drivers/pci/pci.c +2 -2
@@ -242,7 +242,7 @@
  */
 
 int
-pci_set_power_state(struct pci_dev *dev, int state)
+pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 {
 	int pm;
 	u16 pmcsr;
@@ -422,7 +422,7 @@
  * 0 if operation is successful.
  * 
  */
-int pci_enable_wake(struct pci_dev *dev, u32 state, int enable)
+int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
 {
 	int pm;
 	u16 value;
Signature · 2 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
#1 lore raw
Quoted 10 lines · Pavel Machek

Hi!

This adds type-checking to PCI layer. u32 has been replaced with defines, so it is no longer easy to confuse it with system suspend level. Patrick included it in his power tree, but I guess direct merging to you (Andrew) is faster/easier way to go? Please apply,

Pavel

Woah, I've never acked this patch. Let me push it through my pci trees, or if Pat's already taken it, I'll get it from him through that path.

thanks,

greg k-h

#2 lore raw

Hi!

Quoted 11 lines
Quoted 8 lines

This adds type-checking to PCI layer. u32 has been replaced with defines, so it is no longer easy to confuse it with system suspend level. Patrick included it in his power tree, but I guess direct merging to you (Andrew) is faster/easier way to go? Please apply,

Pavel

Woah, I've never acked this patch. Let me push it through my pci trees, or if Pat's already taken it, I'll get it from him through that path.

Did I misunderstandd email exchange? [I have full version with all headers, too...]. [I hope I sent same patch as last time... Hmm, only files were transposed]

Or did you just say that you agree with Patrick, nothing about original patch?

From: Pavel Machek <[email protected]>
To: Greg KH <[email protected]>,
Linux-pm mailing list <[email protected]>
Subject: [linux-pm] Typechecking for pci layer

--===============94806148714041028==
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi!

Does this look like a way to go? I created special type for pci power state, because otherwise it is too tempting to pass system power level (or something completely unrelated :) to pci_ functions.

I'm not sure if PCI_D3cold should be included like this. pci_enable_wake at least ignores it...

Pavel

drivers/pci/pci.c +2 -2
@@ -242,7 +242,7 @@
  */
 
 int
-pci_set_power_state(struct pci_dev *dev, int state)
+pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 {
 	int pm;
 	u16 pmcsr;
@@ -422,7 +422,7 @@
  * 0 if operation is successful.
  * 
  */
-int pci_enable_wake(struct pci_dev *dev, u32 state, int enable)
+int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
 {
 	int pm;
 	u16 value;
include/linux/pci.h +12 -4
@@ -480,6 +480,14 @@
 #define DEVICE_COUNT_COMPATIBLE	4
 #define DEVICE_COUNT_RESOURCE	12
 
+typedef int __bitwise pci_power_t;
+
+#define PCI_D0	((pci_power_t __force) 0)
+#define PCI_D1	((pci_power_t __force) 1)
+#define PCI_D2	((pci_power_t __force) 2)
+#define PCI_D3hot	((pci_power_t __force) 3)
+#define PCI_D3cold	((pci_power_t __force) 4)
+
 /*
  * The pci_dev structure is used to describe PCI devices.
  */
@@ -508,7 +516,7 @@
 					   this if your device has broken DMA
 					   or supports 64-bit transfers.  */
 
-	u32             current_state;  /* Current operating state. In ACPI-speak,
+	pci_power_t     current_state;  /* Current operating state. In ACPI-speak,
 					   this is D0-D3, D0 being fully functional,
 					   and D3 being off. */
 
@@ -645,7 +653,7 @@
 	struct pci_dynids dynids;
 };
 
-#define	to_pci_driver(drv) container_of(drv,struct pci_driver, driver)
+#define	to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
 
 /**
  * PCI_DEVICE - macro used to describe a specific pci device
@@ -781,8 +789,8 @@
 /* Power management related routines */
 int pci_save_state(struct pci_dev *dev, u32 *buffer);
 int pci_restore_state(struct pci_dev *dev, u32 *buffer);
-int pci_set_power_state(struct pci_dev *dev, int state);
-int pci_enable_wake(struct pci_dev *dev, u32 state, int enable);
+int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
+int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
 
 /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
 void pci_bus_assign_resources(struct pci_bus *bus);
Signature · 8 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

From: Patrick Mochel <[email protected]>
To: Pavel Machek <[email protected]>
Cc: Greg KH <[email protected]>,
	Linux-pm mailing list <[email protected]>
Subject: Re: [linux-pm] Typechecking for pci layer
Quoted 8 lines · Pavel Machek

Hi!

Does this look like a way to go? I created special type for pci power state, because otherwise it is too tempting to pass system power level (or something completely unrelated :) to pci_ functions.

I'm not sure if PCI_D3cold should be included like this. pci_enable_wake at least ignores it...

It's not a real state that devices can enter; IIRC it just describes the state devices are in when the system is initially turned on. I don't know why some drivers use it, but it doesn't seem right. (It's been a while since I read the spec, though, so I could be wrong.)

If Greg ACKs it, I'll add it to my tree and push it upwards.

Pat

From: Greg KH <[email protected]>
To: Patrick Mochel <[email protected]>
Cc: Pavel Machek <[email protected]>,
Linux-pm mailing list <[email protected]>
Subject: Re: [linux-pm] Typechecking for pci layer

Quoted 12 lines · Patrick Mochel
Quoted 8 lines · Pavel Machek

Hi!

Does this look like a way to go? I created special type for pci power state, because otherwise it is too tempting to pass system power level (or something completely unrelated :) to pci_ functions.

I'm not sure if PCI_D3cold should be included like this. pci_enable_wake at least ignores it...

Quoted 6 lines

It's not a real state that devices can enter; IIRC it just describes the state devices are in when the system is initially turned on. I don't know why some drivers use it, but it doesn't seem right. (It's been a while since I read the spec, though, so I could be wrong.)

If Greg ACKs it, I'll add it to my tree and push it upwards.

ACK.

heh, reminds me of bill the cat...

greg k-h

Signature · 2 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
#3 lore raw
Quoted 14 lines · Pavel Machek

Hi!

Quoted 11 lines
Quoted 8 lines

This adds type-checking to PCI layer. u32 has been replaced with defines, so it is no longer easy to confuse it with system suspend level. Patrick included it in his power tree, but I guess direct merging to you (Andrew) is faster/easier way to go? Please apply,

Pavel

Woah, I've never acked this patch. Let me push it through my pci trees, or if Pat's already taken it, I'll get it from him through that path.

Quoted 6 lines

Did I misunderstandd email exchange? [I have full version with all headers, too...]. [I hope I sent same patch as last time... Hmm, only files were transposed]

Or did you just say that you agree with Patrick, nothing about original patch?

Ugh, there are just too many pm patches flying around. Sorry, but yes, I did ack this patch, but I did so to let Pat take it. He's the one collecting all of these changes.

Also, due to the fact that we are all still discussing (well, I'm listening at least) how this is all going to work on the linux-pm mailing list, I think it's quite early to be getting patches like these into the tree right now.

So, in short, Andrew, don't apply it. Let Pat collect them, and then I'll channel them in through the proper paths.

thanks,

greg k-h

#4 lore raw

Hi!

Quoted 23 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines

This adds type-checking to PCI layer. u32 has been replaced with defines, so it is no longer easy to confuse it with system suspend level. Patrick included it in his power tree, but I guess direct merging to you (Andrew) is faster/easier way to go? Please apply,

Pavel

Woah, I've never acked this patch. Let me push it through my pci trees, or if Pat's already taken it, I'll get it from him through that path.

Quoted 6 lines

Did I misunderstandd email exchange? [I have full version with all headers, too...]. [I hope I sent same patch as last time... Hmm, only files were transposed]

Or did you just say that you agree with Patrick, nothing about original patch?

Ugh, there are just too many pm patches flying around. Sorry, but yes, I did ack this patch, but I did so to let Pat take it. He's the one collecting all of these changes.

Quoted 7 lines

Also, due to the fact that we are all still discussing (well, I'm listening at least) how this is all going to work on the linux-pm mailing list, I think it's quite early to be getting patches like these into the tree right now.

So, in short, Andrew, don't apply it. Let Pat collect them, and then I'll channel them in through the proper paths.

Ok, I was hoping this change could go in because it does not change any code and David was already posting changes that should better be done relative to this one.

[Problem with Pat's tree is that I'm unable to access it :-(].
Pavel

Signature · 2 lines
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
#5 lore raw
Quoted 2 lines · Pavel Machek

[Problem with Pat's tree is that I'm unable to access it :-(].

bk://kernel.bkbits.net//home/mochel/linux-2.6-power is part of -mm, but appears to have been empty for some time.