Re: Totally broken PCI PM calls

From: Pavel Machek
Date: Sun Oct 24 2004 - 16:00:54 EST


Hi!

> > I'm trying to learn how to work with bitwise on obsolete stuff, but
> > checking there is good, too, right?
> >
> > Is this right way to do it?
> >
> > +typedef enum pm_request __bitwise {
> > + __bitwise PM_SUSPEND, /* enter D1-D3 */
> > + __bitwise PM_RESUME, /* enter D0 */
> > +} pm_request_t;
>
> No, "__bitwise" is a type attribute, so you'd have to do it something like
> this:

Ok, after -Wbitwise for sparse, strict typechecking seems to
work. Unfortunately, it produces a *lot* of noise, for code such as

static ssize_t disk_show(struct subsystem * subsys, char * buf)
{
return sprintf(buf, "%s\n", pm_disk_modes[pm_disk_mode]);
}

...where pm_disk_mode is __bitwise. That is not really what we
want. Would it be possible to get something similar to __bitwise where
arithmetic is still okay to do? With __bitwise, I'd need to do:

@@ -292,15 +297,15 @@
int i;
int len;
char *p;
- u32 mode = 0;
+ suspend_disk_method_t mode = 0;

p = memchr(buf, '\n', n);
len = p ? p - buf : n;

down(&pm_sem);
- for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
+ for (i = (int __force) PM_DISK_FIRMWARE; i < (int __force) PM_DISK_MAX; i++) {
if (!strncmp(buf, pm_disk_modes[i], len)) {
- mode = i;
+ mode = (suspend_disk_method_t __force) i;
break;
}
}


...thats ugly.

Pavel
--
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/