f_uac2: why do you save two u8 in one u16?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



looking at f_uac2.c I found this interresting piece of code:

|struct audio_dev {
|         /* Currently active {Interface[15:8] | AltSettings[7:0]} */
|         __u16 ac_alt, as_out_alt, as_in_alt;
|â?Š
|};
|
|â?Š
|#define ALT_SET(x, a)   do {(x) &= ~0xff; (x) |= (a); } while (0)
|#define ALT_GET(x)      ((x) & 0xff)
|#define INTF_SET(x, i)  do {(x) &= 0xff; (x) |= ((i) << 8); } while (0)
|#define INTF_GET(x)     ((x >> 8) & 0xff)
|â?Š
|    ALT_SET(agdev->as_out_alt, 0);
|    INTF_SET(agdev->as_out_alt, ret);
|â?Š

Could one of you two explain to me why smashing two different things (an
interface number and an alternative setting number) into one variable
and using a Macro to seperate them again was a good idea?

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux