2005-01-04 12:50:08

by Pavel Machek

[permalink] [raw]
Subject: mark older power managment as deprecated

Hi!

What about this patch? It marks old power managemnt as obsolete (and
also adds some sparse-style type checking; typedefs were already there
so why not use them?). I think it should go in, so that we can get a
rid of old power managment infrastructure post-2.6.11.

Pavel

--- clean-mm/include/linux/pm.h 2005-01-03 17:15:43.000000000 +0100
+++ linux-mm/include/linux/pm.h 2005-01-04 13:11:18.000000000 +0100
@@ -28,44 +28,28 @@
#include <asm/atomic.h>

/*
- * Power management requests
+ * Power management requests... these are passed to pm_send_all() and friends.
+ *
+ * these functions are old and deprecated, see below.
*/
-enum
-{
- PM_SUSPEND, /* enter D1-D3 */
- PM_RESUME, /* enter D0 */
-
- PM_SAVE_STATE, /* save device's state */
+typedef int __bitwise pm_request_t;

- /* enable wake-on */
- PM_SET_WAKEUP,
+#define PM_SUSPEND ((__force pm_request_t) 1) /* enter D1-D3 */
+#define PM_RESUME ((__force pm_request_t) 2) /* enter D0 */

- /* bus resource management */
- PM_GET_RESOURCES,
- PM_SET_RESOURCES,
-
- /* base station management */
- PM_EJECT,
- PM_LOCK,
-};
-
-typedef int pm_request_t;

/*
- * Device types
+ * Device types... these are passed to pm_register
*/
-enum
-{
- PM_UNKNOWN_DEV = 0, /* generic */
- PM_SYS_DEV, /* system device (fan, KB controller, ...) */
- PM_PCI_DEV, /* PCI device */
- PM_USB_DEV, /* USB device */
- PM_SCSI_DEV, /* SCSI device */
- PM_ISA_DEV, /* ISA device */
- PM_MTD_DEV, /* Memory Technology Device */
-};
+typedef int __bitwise pm_dev_t;

-typedef int pm_dev_t;
+#define PM_UNKNOWN_DEV ((__force pm_request_t) 0) /* generic */
+#define PM_SYS_DEV ((__force pm_request_t) 1) /* system device (fan, KB controller, ...) */
+#define PM_PCI_DEV ((__force pm_request_t) 2) /* PCI device */
+#define PM_USB_DEV ((__force pm_request_t) 3) /* USB device */
+#define PM_SCSI_DEV ((__force pm_request_t) 4) /* SCSI device */
+#define PM_ISA_DEV ((__force pm_request_t) 5) /* ISA device */
+#define PM_MTD_DEV ((__force pm_request_t) 6) /* Memory Technology Device */

/*
* System device hardware ID (PnP) values
@@ -119,32 +103,27 @@
/*
* Register a device with power management
*/
-struct pm_dev *pm_register(pm_dev_t type,
- unsigned long id,
- pm_callback callback);
+struct pm_dev __deprecated *pm_register(pm_dev_t type, unsigned long id, pm_callback callback);

/*
* Unregister a device with power management
*/
-void pm_unregister(struct pm_dev *dev);
+void __deprecated pm_unregister(struct pm_dev *dev);

/*
* Unregister all devices with matching callback
*/
-void pm_unregister_all(pm_callback callback);
+void __deprecated pm_unregister_all(pm_callback callback);

/*
* Send a request to a single device
*/
-int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
+int __deprecated pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);

/*
* Send a request to all devices
*/
-int pm_send_all(pm_request_t rqst, void *data);
-
-static inline void pm_access(struct pm_dev *dev) {}
-static inline void pm_dev_idle(struct pm_dev *dev) {}
+int __deprecated pm_send_all(pm_request_t rqst, void *data);

#else /* CONFIG_PM */

@@ -171,16 +150,10 @@
return 0;
}

-static inline struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
-{
- return 0;
-}
-
-static inline void pm_access(struct pm_dev *dev) {}
-static inline void pm_dev_idle(struct pm_dev *dev) {}
-
#endif /* CONFIG_PM */

+/* Functions above this comment are list-based old-style power
+ * managment. Please avoid using them. */

/*
* Callbacks for platform drivers to implement.

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


2005-01-04 13:04:51

by Russell King

[permalink] [raw]
Subject: Re: mark older power managment as deprecated

On Tue, Jan 04, 2005 at 01:46:59PM +0100, Pavel Machek wrote:
> +typedef int __bitwise pm_dev_t;
>
> -typedef int pm_dev_t;
> +#define PM_UNKNOWN_DEV ((__force pm_request_t) 0) /* generic */
> +#define PM_SYS_DEV ((__force pm_request_t) 1) /* system device (fan, KB controller, ...) */
> +#define PM_PCI_DEV ((__force pm_request_t) 2) /* PCI device */
> +#define PM_USB_DEV ((__force pm_request_t) 3) /* USB device */
> +#define PM_SCSI_DEV ((__force pm_request_t) 4) /* SCSI device */
> +#define PM_ISA_DEV ((__force pm_request_t) 5) /* ISA device */
> +#define PM_MTD_DEV ((__force pm_request_t) 6) /* Memory Technology Device */

Shouldn't these beeeeeeeeeeeeeeeeeeeeeeee pm_dev_t?

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial core

2005-01-04 13:13:31

by Pavel Machek

[permalink] [raw]
Subject: Re: mark older power managment as deprecated

Hi!

> > +typedef int __bitwise pm_dev_t;
> >
> > -typedef int pm_dev_t;
> > +#define PM_UNKNOWN_DEV ((__force pm_request_t) 0) /* generic */
> > +#define PM_SYS_DEV ((__force pm_request_t) 1) /* system device (fan, KB controller, ...) */
> > +#define PM_PCI_DEV ((__force pm_request_t) 2) /* PCI device */
> > +#define PM_USB_DEV ((__force pm_request_t) 3) /* USB device */
> > +#define PM_SCSI_DEV ((__force pm_request_t) 4) /* SCSI device */
> > +#define PM_ISA_DEV ((__force pm_request_t) 5) /* ISA device */
> > +#define PM_MTD_DEV ((__force pm_request_t) 6) /* Memory Technology Device */
>
> Shouldn't these beeeeeeeeeeeeeeeeeeeeeeee pm_dev_t?

Oops, right. Here's updated diff.
Pavel

--- clean-mm/include/linux/pm.h 2005-01-03 17:15:43.000000000 +0100
+++ linux-mm/include/linux/pm.h 2005-01-04 13:11:18.000000000 +0100
@@ -28,44 +28,28 @@
#include <asm/atomic.h>

/*
- * Power management requests
+ * Power management requests... these are passed to pm_send_all() and friends.
+ *
+ * these functions are old and deprecated, see below.
*/
-enum
-{
- PM_SUSPEND, /* enter D1-D3 */
- PM_RESUME, /* enter D0 */
-
- PM_SAVE_STATE, /* save device's state */
+typedef int __bitwise pm_request_t;

- /* enable wake-on */
- PM_SET_WAKEUP,
+#define PM_SUSPEND ((__force pm_request_t) 1) /* enter D1-D3 */
+#define PM_RESUME ((__force pm_request_t) 2) /* enter D0 */

- /* bus resource management */
- PM_GET_RESOURCES,
- PM_SET_RESOURCES,
-
- /* base station management */
- PM_EJECT,
- PM_LOCK,
-};
-
-typedef int pm_request_t;

/*
- * Device types
+ * Device types... these are passed to pm_register
*/
-enum
-{
- PM_UNKNOWN_DEV = 0, /* generic */
- PM_SYS_DEV, /* system device (fan, KB controller, ...) */
- PM_PCI_DEV, /* PCI device */
- PM_USB_DEV, /* USB device */
- PM_SCSI_DEV, /* SCSI device */
- PM_ISA_DEV, /* ISA device */
- PM_MTD_DEV, /* Memory Technology Device */
-};
+typedef int __bitwise pm_dev_t;

-typedef int pm_dev_t;
+#define PM_UNKNOWN_DEV ((__force pm_dev_t) 0) /* generic */
+#define PM_SYS_DEV ((__force pm_dev_t) 1) /* system device (fan, KB controller, ...) */
+#define PM_PCI_DEV ((__force pm_dev_t) 2) /* PCI device */
+#define PM_USB_DEV ((__force pm_dev_t) 3) /* USB device */
+#define PM_SCSI_DEV ((__force pm_dev_t) 4) /* SCSI device */
+#define PM_ISA_DEV ((__force pm_dev_t) 5) /* ISA device */
+#define PM_MTD_DEV ((__force pm_dev_t) 6) /* Memory Technology Device */

/*
* System device hardware ID (PnP) values
@@ -119,32 +103,27 @@
/*
* Register a device with power management
*/
-struct pm_dev *pm_register(pm_dev_t type,
- unsigned long id,
- pm_callback callback);
+struct pm_dev __deprecated *pm_register(pm_dev_t type, unsigned long id, pm_callback callback);

/*
* Unregister a device with power management
*/
-void pm_unregister(struct pm_dev *dev);
+void __deprecated pm_unregister(struct pm_dev *dev);

/*
* Unregister all devices with matching callback
*/
-void pm_unregister_all(pm_callback callback);
+void __deprecated pm_unregister_all(pm_callback callback);

/*
* Send a request to a single device
*/
-int pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);
+int __deprecated pm_send(struct pm_dev *dev, pm_request_t rqst, void *data);

/*
* Send a request to all devices
*/
-int pm_send_all(pm_request_t rqst, void *data);
-
-static inline void pm_access(struct pm_dev *dev) {}
-static inline void pm_dev_idle(struct pm_dev *dev) {}
+int __deprecated pm_send_all(pm_request_t rqst, void *data);

#else /* CONFIG_PM */

@@ -171,16 +150,10 @@
return 0;
}

-static inline struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from)
-{
- return 0;
-}
-
-static inline void pm_access(struct pm_dev *dev) {}
-static inline void pm_dev_idle(struct pm_dev *dev) {}
-
#endif /* CONFIG_PM */

+/* Functions above this comment are list-based old-style power
+ * managment. Please avoid using them. */

/*
* Callbacks for platform drivers to implement.


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

2005-01-04 16:41:26

by Takashi Iwai

[permalink] [raw]
Subject: Power management of old ISA devices (Re: mark older power managment as deprecated)

At Tue, 4 Jan 2005 13:46:59 +0100,
Pavel Machek wrote:
>
> What about this patch? It marks old power managemnt as obsolete (and
> also adds some sparse-style type checking; typedefs were already there
> so why not use them?). I think it should go in, so that we can get a
> rid of old power managment infrastructure post-2.6.11.

ALSA core part still includes pm_register/unregister() for old
(non-PnP) ISA devices.

What is the proper way to register/unregister PM hooks for such
devices?


thanks,

Takashi

2005-01-04 20:31:12

by Pavel Machek

[permalink] [raw]
Subject: Re: Power management of old ISA devices (Re: mark older power managment as deprecated)

Hi!

> > What about this patch? It marks old power managemnt as obsolete (and
> > also adds some sparse-style type checking; typedefs were already there
> > so why not use them?). I think it should go in, so that we can get a
> > rid of old power managment infrastructure post-2.6.11.
>
> ALSA core part still includes pm_register/unregister() for old
> (non-PnP) ISA devices.
>
> What is the proper way to register/unregister PM hooks for such
> devices?

How are PnP ISA devices handled?

Right solution for ISA devices is probably to create an ISA bus in
driver model, and hook such devices there....

Alternatively, you might just hang them onto platform bus, in similar
way i8042 uses...

Imagine this configuration:

cpu -- PCI #1 -- PCI to PCI bridge -- PCI #2 -- PCI to ISA bridge -- sound card #1 on 0x100
\- PCI to PCI bridge -- PCI #3 -- PCI to ISA bridge -- sound card #2 on 0x100

...would you say that's supported? If yes you'd need to create ISA
buses and do it properly, otherwise hooking to platform bus is
probably acceptable.


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

2005-01-05 18:12:38

by Takashi Iwai

[permalink] [raw]
Subject: Re: Power management of old ISA devices (Re: mark older power managment as deprecated)

At Tue, 4 Jan 2005 21:22:45 +0100,
Pavel Machek wrote:
>
> Hi!
>
> > > What about this patch? It marks old power managemnt as obsolete (and
> > > also adds some sparse-style type checking; typedefs were already there
> > > so why not use them?). I think it should go in, so that we can get a
> > > rid of old power managment infrastructure post-2.6.11.
> >
> > ALSA core part still includes pm_register/unregister() for old
> > (non-PnP) ISA devices.
> >
> > What is the proper way to register/unregister PM hooks for such
> > devices?
>
> How are PnP ISA devices handled?

Sorry, correction: pm_register() is used for both ISA PnP and non-PnP
devices.

> Right solution for ISA devices is probably to create an ISA bus in
> driver model, and hook such devices there....

Yep.

> Alternatively, you might just hang them onto platform bus, in similar
> way i8042 uses...

This looks easier to implement as a temporary solution until ISA bus
is implemented. We know how many instances are to be initiailized in
advance, so each driver object can have a unique name.

> Imagine this configuration:
>
> cpu -- PCI #1 -- PCI to PCI bridge -- PCI #2 -- PCI to ISA bridge -- sound card #1 on 0x100
> \- PCI to PCI bridge -- PCI #3 -- PCI to ISA bridge -- sound card #2 on 0x100
>
> ...would you say that's supported? If yes you'd need to create ISA
> buses and do it properly, otherwise hooking to platform bus is
> probably acceptable.

Well, I don't think this can be problematic on ISA soundcards with
platform_device. Anyway, I'll try to implement platform_device at
first as a test...


Thanks!

Takashi