Re: newbus questions

From: Bruce Evans <bde_at_zeta.org.au>
Date: Tue, 15 Jul 2003 13:54:14 +1000 (EST)
On Mon, 14 Jul 2003, Nate Lawson wrote:

> 3. It appears bus_alloc_resource() takes a range of values.  If I know the
> exact value to use, I request it via "value, value" instead of "0, ~0".
> Is this correct?

It's correct if you really know the values, unlike "0, ~0".  The maximum
value for a resource is ULONG_MAX.  This is also a magic value in
conjunction with a value of 0 for the start of a resource and a value
of 1 for the count (see the man page).  ULONG_MAX can be spelled ~0ul
to abbreviate and obfuscate the code a little.  ULONG_MAX can't be
spelled ~0, but this is what the man page description says to use for
the magic value.  ~0 is -1 on 2's complement machines and -0 on 1's
complement machines.  It just happens to become ULONG_MAX on some
machines including 2's complement ones after bogus type conversions
when it is passed to bus_alloc_resource.  Most drivers use the bogus
version of course.  The examples in the man page are correct although
the description isn't.

Bruce
Received on Mon Jul 14 2003 - 18:54:26 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:15 UTC