On 2021/4/2 20:17, chenglang wrote: >> diff --git a/drivers/infiniband/hw/hns/hns_roce_common.h b/drivers/infiniband/hw/hns/hns_roce_common.h >> index 23c438c..5b5fedf 100644 >> --- a/drivers/infiniband/hw/hns/hns_roce_common.h >> +++ b/drivers/infiniband/hw/hns/hns_roce_common.h >> @@ -87,6 +87,17 @@ >> >> #define hr_reg_write(ptr, field, val) _hr_reg_write(ptr, field, val) >> >> +#define _hr_reg_read(ptr, field_type, field_h, field_l) \ >> + ({ \ >> + const field_type *_ptr = ptr; \ >> + BUILD_BUG_ON(((field_h) / 32) != ((field_l) / 32)); \ >> + ((le32_to_cpu(*((__le32 *)_ptr + (field_h) / 32)) & \ >> + GENMASK((field_h) % 32, (field_l) % 32)) >> \ >> + ((field_l) % 32)); \ >> + }) > I will try this: > > #define _hr_reg_read(ptr, field_type, field_h, field_l) > > ({ > const field_type *_ptr = ptr; > FIELD_GET(GENMASK((field_h) % 32, (field_l) % 32), > le32_to_cpu(*((__le32 *)_ptr +(field_h)/32))) > + BUILD_BUG_ON_ZERO(((field_h) / 32) != ((field_l) / 32)); > }) > > > Thanks. > OK, I will send v2 instead. Thanks Weihang