From patchwork Mon Jul 2 11:34:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10501173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCDF66035E for ; Mon, 2 Jul 2018 11:34:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA7A9284B9 for ; Mon, 2 Jul 2018 11:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBAA0285DB; Mon, 2 Jul 2018 11:34:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45454284B9 for ; Mon, 2 Jul 2018 11:34:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753555AbeGBLef (ORCPT ); Mon, 2 Jul 2018 07:34:35 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33961 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753282AbeGBLee (ORCPT ); Mon, 2 Jul 2018 07:34:34 -0400 Received: by mail-wr0-f194.google.com with SMTP id a12-v6so15198567wro.1 for ; Mon, 02 Jul 2018 04:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=R931EmOnK0+WO+AxzzM5AI4roVJ7gvtAKbhX4lFyxMs=; b=JQ3k0K3nr/zjrTGZ3C1LNMKSPDdby6kfKTXUNKFeEvobe9020AXQaWiaKMGgni/9h5 LHLgkt4Q4XYrLjGBCuSD5pTuAmNhg0Hbk12EWidnPV9oWzBpW9arHCxA0kTp3z3w1DTl N3McqEZ6ZqplWVFHPyKR1HgDeeXTlIdbnl2M/XzSs0Cjueb57fenjJy47VNsw95hTR1i 2oUyT55oFI/DAeWM6pGDsHLq3L841fuNYudn74po5JrjrMcltzWVy+TrsWZYdd0T4P4X DwqBVpu8zYykXDFdq/rJNf8uWRKqZu4fmABtPepGYJwnP60TuPf7hO0/eBhShnVUcRWo sjtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=R931EmOnK0+WO+AxzzM5AI4roVJ7gvtAKbhX4lFyxMs=; b=hwc7sILqkCNIF79vGGSJB14DRzD1d9CtIuTpgzQ5T8XKDRUqKQeNWnl0igS0lud1yz 95yWyvX9Uxb5IV0QXKFGbAzKtNVi5ycw03W49IbzItZVWgyaAmbXTzenRvN5BqMC80c5 90mWQvVZu+NNwkKpgztyYM46y+dhi2q7/eR7W00yn3qUajLHwBM+IS8+799v+qwLq2gB 5v9ntDp0MHoQooz2zRH7cLIHogB+tYMKAgc1RQ4gXWaNTe43AT9ovWFzj/mRftWSkCz4 QjK+dM5gN6leivkOrDYS5QDmawU78QnTKJ5qu/7lVES+P6NtfWGNa+mXCJxZp18ciuDi 8lQA== X-Gm-Message-State: APt69E0/bX2n46rJr36fqDNRGT7X64npkyaZHKUwwuZTE03RujYhHdtH m/vWM3cSEfUBgRgdp+fnxJ5PEw== X-Google-Smtp-Source: AAOMgpeVvtgfDlI5kv8toIlzEuv0LtQOwQ23X4u0wfEKpEX/FCtNikk0M/7L2HoYx6Y+v7d16GWosQ== X-Received: by 2002:a5d:4902:: with SMTP id x2-v6mr19255082wrq.66.1530531273224; Mon, 02 Jul 2018 04:34:33 -0700 (PDT) Received: from [10.8.1.82] ([193.47.165.251]) by smtp.googlemail.com with ESMTPSA id u13-v6sm7609178wri.72.2018.07.02.04.34.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 04:34:32 -0700 (PDT) Subject: Re: [PATCH 4/9] RDMA/uverbs: Simplify method definition macros To: Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, "Michael J. Ruhl" , Leon Romanovsky , Guy Levi , Jason Gunthorpe , Yishai Hadas , Majd Dibbiny , artemyko@mellanox.com References: <20180625221249.30730-1-jgg@ziepe.ca> <20180625221249.30730-5-jgg@ziepe.ca> From: Yishai Hadas Message-ID: Date: Mon, 2 Jul 2018 14:34:30 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180625221249.30730-5-jgg@ziepe.ca> Content-Language: en-US Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 6/26/2018 1:12 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > Instead of the large set of indirecting macros, define the few needed > macros to directly instantiate the struct uverbs_method_def and associated > attributes list. > > This is small amount of code duplication but the readability is far > better. > > Signed-off-by: Jason Gunthorpe > --- > -#define DECLARE_UVERBS_NAMED_METHOD_NO_OVERRIDE(id, handler, ...) \ > - DECLARE_UVERBS_METHOD(UVERBS_METHOD(id), id, NULL, ##__VA_ARGS__) > +/* Create a standard destroy method using the default handler. The handle_attr > + * argument must be the attribute specifying the handle to destroy, the > + * default handler does not support any other attributes. > + */ > +#define DECLARE_UVERBS_NAMED_METHOD_DESTROY(_method_id, _handle_attr) \ > + static const struct uverbs_attr_def *const UVERBS_METHOD_ATTRS( \ > + _method_id)[] = { _handle_attr }; \ > + static const struct uverbs_method_def UVERBS_METHOD(_method_id) = { \ > + .id = _method_id, \ > + .handler = uverbs_destroy_def_handler, \ > + .num_attrs = ARRAY_SIZE(UVERBS_METHOD_ATTRS(_method_id)), \ > + .attrs = &UVERBS_METHOD_ATTRS(_method_id), \ > + } To enable drivers using this new standard macro, I would add the below code to this patch. index cbb727f..1d06e6b 100644 the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -247,9 +247,6 @@ void ib_uverbs_detach_umcast(struct ib_qp *qp, void create_udata(struct uverbs_attr_bundle *ctx, struct ib_udata *udata); long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); -int uverbs_destroy_def_handler(struct ib_device *ib_dev, - struct ib_uverbs_file *file, - struct uverbs_attr_bundle *attrs); struct ib_uverbs_flow_spec { union { diff --git a/drivers/infiniband/core/uverbs_std_types.c b/drivers/infiniband/core/uverbs_std_types.c index 912519f..58f2197 100644 --- a/drivers/infiniband/core/uverbs_std_types.c +++ b/drivers/infiniband/core/uverbs_std_types.c @@ -215,6 +215,7 @@ int uverbs_destroy_def_handler(struct ib_device *ib_dev, { return 0; } +EXPORT_SYMBOL_GPL(uverbs_destroy_def_handler); void create_udata(struct uverbs_attr_bundle *ctx, struct ib_udata *udata) { diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 031d121..01b9d5a 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -4160,4 +4160,7 @@ static inline __be16 ib_lid_be16(u32 lid) struct ib_ucontext *ib_uverbs_get_ucontext(struct ib_uverbs_file *ufile); +int uverbs_destroy_def_handler(struct ib_device *ib_dev, + struct ib_uverbs_file *file, + struct uverbs_attr_bundle *attrs); -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in