On Tuesday 17 August 2004 11:55 pm, Benjamin Herrenschmidt wrote: > > > Yes, that's exactly what I did... Unfortunately typedef means ugly > > code. So I'll just switch it back to enum system_state, and lets care > > about device power managment when it hits us, okay? > > I don't agree... with this approach, we'll have to change all drivers > _twice_ when we move to something more descriptive than a scalar The advantage of switching _now_ to enums is that it can be done without actually changing drivers ... however, there are actually two different suspend-state confusions. That patch just affects the first of them, whereas it's the second which actively breaks things today: - Confusion #1 ... "generic" PM framework uses a u32, and the meaning of that u32 has never been formally defined. In practice, most kernel code (except swsusp) passes an enum there already ... PM_SUSPEND_* values, which are unfortunately in an anonymous enum so there's no way even a smartened "sparse" could report errors. - Confusion #2 ... PCI suspend calls use a u32, which has since at least 2.4 meant a PCI power state. Those values are not the same as PM_SUSPEND_* values. PCI drivers that use that u32 are currently getting burnt by the way PM_SUSPEND_* values get passed in when the drivers expect a PCI power state. Example, passing PM_SUSPEND_MEM when the intention is PCI_D3hot (2 rather than 3). I happen to think the _right_ fix involves switching from a scalar to something that recognizes {bus,device,driver}-specific PM states. Such a switch would be extremely disruptive; it'd mean changing every driver. So it's something I'd not rush into ... it'd be worth doing as part of fixing multiple holes in the PM framework. Which leaves me thinking that the desirable near-term fix involves cleanup for #1, and minor sleight-of-hand to fix #2. Something like the attached patch (untested) ... which would let us answer Andrew's "why?" question by pointing to some bugtraq IDs. - Dave