On Thu, 2006-07-06 at 16:51 +0200, Johannes Berg wrote:

> How about making it a void* instead? Like

Actually, make that a u32. Use 0 for the 'mistake' case, anything else
goes. Then we can use it like I suggested, and others can use it as an
index into a table (they subtract 1 before using it as an index if it is
not 0 == error)

> struct firmware_hash_table {
>       u8 signature[16];
>       void* value;
          -u32-
> };

> Then we can use a NULL pointer to indicate end-of-array (for the input)
                  --- 0 --------
> or not-found (for output), and those that know that their values are
> going to fit into a pointer like bcm43xx can encode them in there right
                    - a u32 -
> away:
> 
> #define VERSION_PTR(a,b,c,d) ((void*) (((a)<<24) | ((b)<<16) | ((c)<<8) | (d))
> 
> struct firmware_hash_table bcm43xx_firmware_versions[] = {
> { {0x44, 0xc5, 0xa5, 0x28, 0xcb, 0x3b, 0x43, 0x08, 0x9c, 0x1f, 0x4b, 0x56, 
> 0x2b, 0x66, 0x0d, 0xc7 }, VERSION_PTR(3,130,20,0) },
> ...,
> {} /* terminate array */
> };

johannes

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to