Re: [git pull] x86 fixes

From: Ingo Molnar
Date: Mon Jan 12 2009 - 16:13:00 EST



* Harvey Harrison <harvey.harrison@xxxxxxxxx> wrote:

> On Mon, 2009-01-12 at 21:52 +0100, Ingo Molnar wrote:
> > * Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> > +static inline int is_new_memtype_allowed(unsigned long flags,
> > + unsigned long new_flags)
> > +{
> > + /*
> > + * Certain new memtypes are not allowed with certain
> > + * requested memtype:
> > + * - request is uncached, return cannot be write-back
> > + * - request is write-combine, return cannot be write-back
> > + */
> > + if ((flags == _PAGE_CACHE_UC_MINUS &&
> > + new_flags == _PAGE_CACHE_WB) ||
> > + (flags == _PAGE_CACHE_WC &&
> > + new_flags == _PAGE_CACHE_WB)) {
> > + return 0;
> > + }
>
> if ((flags == _PAGE_CACHE_UC_MINUS || flags == _PAGE_CACHE_WC) &&
> (new_flags == _PAGE_CACHE_WB))
>
> might be a bit neater perhaps.

indeed. The most readable one is probably:

static inline int
is_new_memtype_allowed(unsigned long flags, unsigned long new_flags)
{
/*
* Certain new memtypes are not allowed with certain
* requested memtype:
* - request is uncached, return cannot be write-back
* - request is write-combine, return cannot be write-back
*/

if (new_flags != _PAGE_CACHE_WB)
return 1;

if (flags == _PAGE_CACHE_UC_MINUS)
return 0;
if (flags == _PAGE_CACHE_WC)
return 0;

return 1;
}

Ingo
--
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/