On Sat, Feb 02, 2008 at 12:49:38AM +0100, Michael Biebl wrote: > That's not quite correct. Upstream is also broken, as pm-is-supported > doesn't recognize pmu support.
In the interests of getting this fixed, I dug into pm-pmu.c and added the ability to query the PMU to detect if suspending is supported. I've tested it by manually building pm-pmu and checking the suspend and can-suspend functions: > if sudo ./pm-pmu --can-suspend; then sudo ./pm-pmu --suspend; fi This successfully suspends my Powerbook G4. I've tested it against linux-image-2.6.22-3-powerpc, and against linux-image-2.6.24-1-powerpc. Hopefully we can integrate this into pm-utils, and get this bug resolved. My debian-fu isn't developed enough to understand how to dig into this package fix the rest of it, but I am interested in doing the work. I'll have to go read up on the debian packaging utilities before I continue. In the mean time, if somebody else can use my patch to zap this bug, please do. Cheers, Matthew
diff -ur pm-utils-0.99.2-orig/src/pm-pmu.c pm-utils-0.99.2/src/pm-pmu.c
--- pm-utils-0.99.2-orig/src/pm-pmu.c 2006-08-08 11:17:28.000000000 -0400
+++ pm-utils-0.99.2/src/pm-pmu.c 2008-02-01 21:12:07.000000000 -0500
@@ -53,10 +53,20 @@
return 0;
}
+static int
+pmu_can_sleep(const int fd)
+{
+ unsigned long cap = 0;
+ if (ioctl(fd, PMU_IOC_CAN_SLEEP, &cap) < 0 || cap != 1)
+ return 1;
+
+ return 0;
+}
+
static inline int
print_usage(FILE *output, int retval)
{
- fprintf(output, "usage: pm-pmu --suspend\n");
+ fprintf(output, "usage: pm-pmu [--suspend | --can-suspend]\n");
return retval;
}
@@ -80,6 +90,17 @@
ret = pmu_sleep(fd);
close(fd);
return ret;
+ } else if (!strcmp(argv[1], "--can-suspend")) {
+ int fd, ret;
+ /* Need RDRW perm on pmu to issue PMU_IOC_CAN_SLEEP */
+ if ((fd = open ("/dev/pmu", O_RDWR)) < 0) {
+ perror("open");
+ return 1;
+ }
+
+ ret = pmu_can_sleep(fd);
+ close(fd);
+ return ret;
}
return print_usage(stderr, 1);
signature.asc
Description: Digital signature

