All of lore.kernel.org
 help / color / mirror / Atom feed
* Type-checking for pci layer
@ 2004-11-03 21:47 Pavel Machek
  2004-11-03 21:51 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2004-11-03 21:47 UTC (permalink / raw)
  To: Andrew Morton, kernel list; +Cc: Greg KH

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: Greg KH <greg@kroah.com>
Acked-by: Patrick Mochel

--- clean/include/linux/pci.h	2004-10-01 00:30:30.000000000 +0200
+++ linux/include/linux/pci.h	2004-11-01 21:24:17.000000000 +0100
@@ -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);
--- clean/drivers/pci/pci.c	2004-10-01 00:30:16.000000000 +0200
+++ linux/drivers/pci/pci.c	2004-10-25 23:24:37.000000000 +0200
@@ -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;

-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Type-checking for pci layer
  2004-11-03 21:47 Type-checking for pci layer Pavel Machek
@ 2004-11-03 21:51 ` Greg KH
  2004-11-03 22:14   ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2004-11-03 21:51 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, kernel list

On Wed, Nov 03, 2004 at 10:47:11PM +0100, Pavel Machek wrote:
> 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: Greg KH <greg@kroah.com>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Type-checking for pci layer
  2004-11-03 21:51 ` Greg KH
@ 2004-11-03 22:14   ` Pavel Machek
  2004-11-03 22:21     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2004-11-03 22:14 UTC (permalink / raw)
  To: Greg KH; +Cc: Andrew Morton, kernel list

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: Greg KH <greg@kroah.com>
> 
> 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 <pavel@ucw.cz>
To: Greg KH <greg@kroah.com>,
	Linux-pm mailing list <linux-pm@lists.osdl.org>
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

--- clean/drivers/pci/pci.c	2004-10-01 00:30:16.000000000 +0200
+++ linux/drivers/pci/pci.c	2004-10-25 23:24:37.000000000 +0200
@@ -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;
--- clean/include/linux/pci.h	2004-10-01 00:30:30.000000000 +0200
+++ linux/include/linux/pci.h	2004-10-25 23:25:41.000000000 +0200
@@ -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);

-- 
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 <mochel@digitalimplant.org>
To: Pavel Machek <pavel@ucw.cz>
Cc: Greg KH <greg@kroah.com>,
	Linux-pm mailing list <linux-pm@lists.osdl.org>
Subject: Re: [linux-pm] Typechecking for pci layer

On Tue, 26 Oct 2004, Pavel Machek wrote:

> 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 <greg@kroah.com>
To: Patrick Mochel <mochel@digitalimplant.org>
Cc: Pavel Machek <pavel@ucw.cz>,
	Linux-pm mailing list <linux-pm@lists.osdl.org>
Subject: Re: [linux-pm] Typechecking for pci layer

On Thu, Oct 28, 2004 at 08:43:55AM -0700, Patrick Mochel wrote:
> 
> On Tue, 26 Oct 2004, Pavel Machek wrote:
> 
> > 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.

ACK.

heh, reminds me of bill the cat...

greg k-h


-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Type-checking for pci layer
  2004-11-03 22:14   ` Pavel Machek
@ 2004-11-03 22:21     ` Greg KH
  2004-11-03 22:48       ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2004-11-03 22:21 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andrew Morton, kernel list

On Wed, Nov 03, 2004 at 11:14:40PM +0100, Pavel Machek wrote:
> 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: Greg KH <greg@kroah.com>
> > 
> > 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?

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Type-checking for pci layer
  2004-11-03 22:21     ` Greg KH
@ 2004-11-03 22:48       ` Pavel Machek
  2004-11-03 23:11         ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2004-11-03 22:48 UTC (permalink / raw)
  To: Greg KH; +Cc: Andrew Morton, kernel list

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: Greg KH <greg@kroah.com>
> > > 
> > > 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?
> 
> 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.

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
-- 
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Type-checking for pci layer
  2004-11-03 22:48       ` Pavel Machek
@ 2004-11-03 23:11         ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2004-11-03 23:11 UTC (permalink / raw)
  To: Pavel Machek; +Cc: greg, akpm, linux-kernel

Pavel Machek <pavel@ucw.cz> wrote:
>
> [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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-11-03 23:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03 21:47 Type-checking for pci layer Pavel Machek
2004-11-03 21:51 ` Greg KH
2004-11-03 22:14   ` Pavel Machek
2004-11-03 22:21     ` Greg KH
2004-11-03 22:48       ` Pavel Machek
2004-11-03 23:11         ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.