On Thu, Dec 08, 2016 at 11:26:32AM +0200, Or Gerlitz wrote: > /* insert a value to a struct */ > #define MLX5_SET(typ, p, fld, v) do { \ > + typeof( v ) _v = v; \ > BUILD_BUG_ON(__mlx5_st_sz_bits(typ) % 32); \ > *((__be32 *)(p) + __mlx5_dw_off(typ, fld)) = \ > cpu_to_be32((be32_to_cpu(*((__be32 *)(p) + __mlx5_dw_off(typ, fld))) & \ > - (~__mlx5_dw_mask(typ, fld))) | (((v) & > __mlx5_mask(typ, fld)) \ > + (~__mlx5_dw_mask(typ, fld))) | (((_v) & > __mlx5_mask(typ, fld)) \ > << __mlx5_dw_bit_off(typ, fld))); \ > } while (0) Ugh, that is ugly. This is better, it has proper type safety :| static inline _mlx5_set(__be32 *p, u32 dw_mask, u32 mask, u32 dw_off, unsigned int bit_off, u32 val) { *(p + dw_off) = cpu_to_b32((be32_to_cpu_p(p + dw_off) & ~dw_mask) | ((val & mask) << bit_off)); } #define MLX5_SET(typ, p, fld, v) \ _mlx5_set(p, __mlx5_dw_mask(typ, fld), __mlx5_mask(typ, fld), __mlx5_dw_off(typ, fld), __mlx5_dw_bit_off(typ, fld), v) Jason -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html