Re: [PATCH 3/5] IB/core: Convert management helpers to core capability bits

Jason Gunthorpe
2015-05-12T19:25:17Z

On Mon, May 11, 2015 at 09:46:56PM -0400, ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
> From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> Remove query_protocol callback
>
> Use the new Core Capability bits for:

Looks broadly reasonable to me, I see why you'd want to keep the
driver functions added in the last patch, so disregard my comment on
null..

> static inline bool rdma_protocol_ib(struct ib_device *device, u8 port_num)
> {
> - return device->query_protocol(device, port_num) == RDMA_PROTOCOL_IB;
> + return (device->port_immutable[port_num].core_cap_flags & RDMA_CORE_CAP_PROT_IB)
> + == RDMA_CORE_CAP_PROT_IB;
> }

This pattern can just be

return device->port_immutable[port_num].core_cap_flags &
RDMA_CORE_CAP_PROT_IB;

Cast to bool will cannonize it automatically

> - return (pt == RDMA_PROTOCOL_IB || pt == RDMA_PROTOCOL_IBOE);
> + return ((flags & RDMA_CORE_CAP_PROT_IB) == RDMA_CORE_CAP_PROT_IB ||
> + (flags & RDMA_CORE_CAP_PROT_IBOE) ==
> RDMA_CORE_CAP_PROT_IBOE);

return device->port_immutable[port_num].core_cap_flags & (RDMA_CORE_CAP_PROT_IB | RDMA_CORE_CAP_PROT_IBOE);

etc.