On Tue, 11 May 2021 17:38:04 +0200 David Hildenbrand <david@xxxxxxxxxx> wrote: > On 11.05.21 16:41, Claudio Imbrenda wrote: > > On Tue, 11 May 2021 13:43:36 +0200 > > David Hildenbrand <david@xxxxxxxxxx> wrote: > > > >> On 10.05.21 17:00, Janosch Frank wrote: > >>> Lets grab more of the feature bits from SCLP read info so we can > >>> use them in the cpumodel tests. > >>> > >>> Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx> > >>> Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx> > >>> --- > >>> lib/s390x/sclp.c | 20 ++++++++++++++++++++ > >>> lib/s390x/sclp.h | 38 +++++++++++++++++++++++++++++++++++--- > >>> 2 files changed, 55 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c > >>> index f11c2035..f25cfdb2 100644 > >>> --- a/lib/s390x/sclp.c > >>> +++ b/lib/s390x/sclp.c > >>> @@ -129,6 +129,13 @@ CPUEntry *sclp_get_cpu_entries(void) > >>> return (CPUEntry *)(_read_info + > >>> read_info->offset_cpu); } > >>> > >>> +static bool sclp_feat_check(int byte, int mask) > >>> +{ > >>> + uint8_t *rib = (uint8_t *)read_info; > >>> + > >>> + return !!(rib[byte] & mask); > >>> +} > >> > >> Instead of a mask, I'd just check for bit (offset) numbers within > >> the byte. > >> > >> static bool sclp_feat_check(int byte, int bit) > >> { > >> uint8_t *rib = (uint8_t *)read_info; > >> > >> return !!(rib[byte] & (0x80 >> bit)); > >> } > > > > using a mask might be useful to check multiple facilities at the > > same time, but in that case the check should be > > IMHO checking with a mask here multiple facilities will be very error > prone either way ... and we only have a single byte to check for. as I said, I do not have a strong opinion either way :)