... > >> - if (!csum_trailer->valid) { > >> + if (!u8_get_bits(csum_trailer->flags, MAP_CSUM_DL_VALID_FMASK)) { > > > > Is that just an overcomplicated way of saying: > > if (!(csum_trailer->flags & MAP_CSUM_DL_VALID_FMASK)) { > > Yes it is. I defined and used all the field masks in a > consistent way, but I do think it will read better the > way you suggest. Bjorn also asked me privately whether > GENMASK(15, 15) was just the same as BIT(15) (it is). > > I will post version 3 of the series, identifying which > fields are single bit/Boolean. For those I will define > the value using BIT() and will set/extract using simple > AND/OR operators. I won't use the _FMASK suffix on such > fields.
Even for the checksum offset a simple 'offset << CONSTANT' is enough. If it is the bottom bits then even that isn't really needed. You might want to mask off high bits - but that is an error path that needs to have been checked earlier. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)