Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/netlink: Simplify netlink listener existence check

All users of rdma_nl_chk_listeners() are interested to get boolean answer
if netlink socket has listeners, so update all places to boolean function.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Leon Romanovsky and committed by
Jason Gunthorpe
38716732 d31131bb

+6 -6
+1 -1
drivers/infiniband/core/addr.c
··· 315 315 static int ib_nl_fetch_ha(struct rdma_dev_addr *dev_addr, 316 316 const void *daddr, u32 seq, u16 family) 317 317 { 318 - if (rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) 318 + if (!rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) 319 319 return -EADDRNOTAVAIL; 320 320 321 321 return ib_nl_ip_send_msg(dev_addr, daddr, seq, family);
+2 -2
drivers/infiniband/core/netlink.c
··· 47 47 const struct rdma_nl_cbs *cb_table; 48 48 } rdma_nl_types[RDMA_NL_NUM_CLIENTS]; 49 49 50 - int rdma_nl_chk_listeners(unsigned int group) 50 + bool rdma_nl_chk_listeners(unsigned int group) 51 51 { 52 - return (netlink_has_listeners(nls, group)) ? 0 : -1; 52 + return netlink_has_listeners(nls, group); 53 53 } 54 54 EXPORT_SYMBOL(rdma_nl_chk_listeners); 55 55
+1 -1
drivers/infiniband/core/sa_query.c
··· 1384 1384 1385 1385 if ((query->flags & IB_SA_ENABLE_LOCAL_SERVICE) && 1386 1386 (!(query->flags & IB_SA_QUERY_OPA))) { 1387 - if (!rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) { 1387 + if (rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) { 1388 1388 if (!ib_nl_make_request(query, gfp_mask)) 1389 1389 return id; 1390 1390 }
+2 -2
include/rdma/rdma_netlink.h
··· 96 96 /** 97 97 * Check if there are any listeners to the netlink group 98 98 * @group: the netlink group ID 99 - * Returns 0 on success or a negative for no listeners. 99 + * Returns true on success or false if no listeners. 100 100 */ 101 - int rdma_nl_chk_listeners(unsigned int group); 101 + bool rdma_nl_chk_listeners(unsigned int group); 102 102 #endif /* _RDMA_NETLINK_H */