Re: pm_message_t becoming struct

Pavel Machek
2005-03-25T15:23:32Z

[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]

Hi!

> > static int foo_suspend(struct pci_dev *pdev, u32 state)
> >
> > . that's wrong. Now we have
> >
> > static int foo_suspend(struct pci_dev *pdev, pm_message_t state)
> >
> > , which is slightly better, but people still get it wrong, because
> > pm_message_t is compatible with u32. Oops. Obvious solution is to make
> > pm_message_t typedefed into struct, so people can't do the typing
> > wrong. This is kernel 101.
> >
> > What you would like to have is
> >
> > static int foo_suspend(struct pci_dev *pdev, struct pm_message *state)
> >
> > which I agree is marginally nicer to look at, but still does not
> > provide enough typechecking and [more importantly] there's no way in
> > hell we are doing second search and replace over all the drivers.
>
> Are you willing to go halfway? If we do something more like this:
>
> typedef struct {
> struct pm_message *m;
> } pm_message_t;
>
> then the code can pass pm_message_t's around with full type-checking and
> still retain the benefit of sending a pointer rather than a structure.
>
> Yes, it looks stupid. But it's a reasonable compromise that won't

I'm afraid it really looks stupid. [It actually has benefit that we
_could_ go over tree in future and change pm_message_t into struct
pm_message *.]

OTOH we would probably be stuck with this stupid-looking-thing
forever, and I'd really prefer to avoid that.