From patchwork Mon Dec 28 21:02:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Dalessandro X-Patchwork-Id: 7927101 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7673A9F387 for ; Mon, 28 Dec 2015 21:02:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CAB4201EC for ; Mon, 28 Dec 2015 21:02:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A91DD201E4 for ; Mon, 28 Dec 2015 21:02:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752726AbbL1VCs (ORCPT ); Mon, 28 Dec 2015 16:02:48 -0500 Received: from mga09.intel.com ([134.134.136.24]:35602 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752708AbbL1VCr (ORCPT ); Mon, 28 Dec 2015 16:02:47 -0500 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 28 Dec 2015 13:02:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,492,1444719600"; d="scan'208";a="624911802" Received: from scymds01.sc.intel.com ([10.82.194.37]) by FMSMGA003.fm.intel.com with ESMTP; 28 Dec 2015 13:02:47 -0800 Received: from scvm10.sc.intel.com (scvm10.sc.intel.com [10.82.195.27]) by scymds01.sc.intel.com with ESMTP id tBSL2kpL015643; Mon, 28 Dec 2015 13:02:46 -0800 Received: from scvm10.sc.intel.com (localhost [127.0.0.1]) by scvm10.sc.intel.com with ESMTP id tBSL2kkq032740; Mon, 28 Dec 2015 13:02:46 -0800 Subject: [PATCH v2 05/36] IB/rdmavt: Macroize override checks during driver registration To: dledford@redhat.com From: Dennis Dalessandro Cc: linux-rdma@vger.kernel.org, Mike Marciniszyn , Ira Weiny Date: Mon, 28 Dec 2015 13:02:46 -0800 Message-ID: <20151228210205.29850.3900.stgit@scvm10.sc.intel.com> In-Reply-To: <20151228205612.29850.7328.stgit@scvm10.sc.intel.com> References: <20151228205612.29850.7328.stgit@scvm10.sc.intel.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a macro to cut down on writing the same lines over and over again for what will be a large number of functions that will be supported. Reviewed-by: Mike Marciniszyn Reviewed-by: Ira Weiny Signed-off-by: Dennis Dalessandro --- Changes since v1: Change CDR macro to CHECK_DRIVER_OVERRIDE to be more clear drivers/infiniband/sw/rdmavt/vt.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c index b65cde4..8bd25c3 100644 --- a/drivers/infiniband/sw/rdmavt/vt.c +++ b/drivers/infiniband/sw/rdmavt/vt.c @@ -64,29 +64,25 @@ static void rvt_cleanup(void) } module_exit(rvt_cleanup); +/* + * Check driver override. If driver passes a value use it, otherwise we use our + * own value. + */ +#define CHECK_DRIVER_OVERRIDE(rdi, x) \ + rdi->ibdev.x = rdi->ibdev.x ? : rvt_ ##x + int rvt_register_device(struct rvt_dev_info *rdi) { if (!rdi) return -EINVAL; - /* - * Drivers have the option to override anything in the ibdev that they - * want to specifically handle. VT needs to check for things it supports - * and if the driver wants to handle that functionality let it. We may - * come up with a better mechanism that simplifies the code at some - * point. - */ - /* DMA Operations */ rdi->ibdev.dma_ops = rdi->ibdev.dma_ops ? : &rvt_default_dma_mapping_ops; /* Protection Domain */ - rdi->ibdev.alloc_pd = - rdi->ibdev.alloc_pd ? : rvt_alloc_pd; - rdi->ibdev.dealloc_pd = - rdi->ibdev.dealloc_pd ? : rvt_dealloc_pd; - + CHECK_DRIVER_OVERRIDE(rdi, alloc_pd); + CHECK_DRIVER_OVERRIDE(rdi, dealloc_pd); spin_lock_init(&rdi->n_pds_lock); rdi->n_pds_allocated = 0;