Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2024484pxb; Thu, 11 Feb 2021 02:13:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1RWEbIlmPzyo5Xlq6w3GwY1E/kSeRoMTxVR3p9n4PFr7XFcLr73iSldcCDG2Qmn/LlmYj X-Received: by 2002:a17:907:20d6:: with SMTP id qq22mr7788989ejb.517.1613038415633; Thu, 11 Feb 2021 02:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613038415; cv=none; d=google.com; s=arc-20160816; b=gU7Q1UaUoWDkUCjSgoEAbwaWYOpXMJ4eshBhE9PuCJz5KZ2JMhyoLFRnsvjLQfKsOt F2RrXv+ee8fy8FuzgIKYkpJ0QWkfVgHP1ZD4/S2igtP0uisH8LlLgitJMCRasDnGtph6 pdTGKutPia/BlszhuSwEzDyVYZLiS5KX5F3a/cUBm8E6F36R6744ud34eQQohJmw8K8c ZI0kXZ2hfeDP8wpskqXwV6mtwJWW4cIsuqNBRKKRsGmwvEDdS9FxHdO/CrJvW00DEUQl LYRzQLFhe4/syDY1aSj1IV/xh3o66J0DZN9rr5swTnEJ99rlUNS1S73T+C8bga3xliry qpVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=tv+DCV2RvAUbbEKaCratEPt+njDPfeFGdqc7pr3jkkc=; b=TuZR8bzgcBfrAgNPV4511vS0Yv4UkJnu2NgFRLxLK0tjIx7tcc/zw5OxhsZ2SctjQh 4uSm7byTWdT55W1O8furz5sKfRoyra5Ipt//W/QHiaUgDVc1uxhfNAV0DDsyecUVRsL6 bM+SphwjOlYEi2MdvyQrhIYboFd3mekjssgqqXuasdqlnlCUTRFAMTQoEDM1AD/ZqxJ4 JAVIAalLJQ2VWweDCEDbmNHZSONne7mzIiaMk1+pR1SPWb+sTjuVrCTLglF07zTYQ06X SPKNz5AWEnda8CIYAQ6ylsT/X2+fZMDglaxVLiYKaz0Ay716ZmLOO6j8DoLhZKwYivOO /g+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si3406622edy.471.2021.02.11.02.13.10; Thu, 11 Feb 2021 02:13:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230198AbhBKKKf (ORCPT + 99 others); Thu, 11 Feb 2021 05:10:35 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2544 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230030AbhBKKIb (ORCPT ); Thu, 11 Feb 2021 05:08:31 -0500 Received: from fraeml715-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Dbsd6739dz67mrk; Thu, 11 Feb 2021 18:02:50 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml715-chm.china.huawei.com (10.206.15.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 11 Feb 2021 11:07:48 +0100 Received: from localhost (10.47.31.44) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2106.2; Thu, 11 Feb 2021 10:07:47 +0000 Date: Thu, 11 Feb 2021 10:06:46 +0000 From: Jonathan Cameron To: Dan Williams CC: Ben Widawsky , , "Linux ACPI" , Linux Kernel Mailing List , linux-nvdimm , Linux PCI , Bjorn Helgaas , "Chris Browy , Christoph Hellwig , Dan Williams , David Hildenbrand , David Rientjes" , "Jon Masters , Rafael Wysocki , Randy Dunlap" , "John Groves (jgroves)" , "Kelley, Sean V" , "kernel test robot" , Dan Williams Subject: Re: [PATCH v2 4/8] cxl/mem: Add basic IOCTL interface Message-ID: <20210211100646.00007dcc@Huawei.com> In-Reply-To: References: <20210210000259.635748-1-ben.widawsky@intel.com> <20210210000259.635748-5-ben.widawsky@intel.com> <20210210184540.00007536@Huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.31.44] X-ClientProxiedBy: lhreml709-chm.china.huawei.com (10.201.108.58) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 10 Feb 2021 20:40:52 -0800 Dan Williams wrote: > On Wed, Feb 10, 2021 at 10:47 AM Jonathan Cameron > wrote: > [..] > > > +#define CXL_CMDS \ > > > + ___C(INVALID, "Invalid Command"), \ > > > + ___C(IDENTIFY, "Identify Command"), \ > > > + ___C(MAX, "Last command") > > > + > > > +#define ___C(a, b) CXL_MEM_COMMAND_ID_##a > > > +enum { CXL_CMDS }; > > > + > > > +#undef ___C > > > +#define ___C(a, b) { b } > > > +static const struct { > > > + const char *name; > > > +} cxl_command_names[] = { CXL_CMDS }; > > > +#undef ___C > > > > Unless there are going to be a lot of these, I'd just write them out long hand > > as much more readable than the macro magic. > > This macro magic isn't new to Linux it was introduced with ftrace: > > See "cpp tricks and treats": https://lwn.net/Articles/383362/ Yeah. I've dealt with that one a few times. It's very cleaver and compact but a PITA to debug build errors related to it. > > > > > enum { > > CXL_MEM_COMMAND_ID_INVALID, > > CXL_MEM_COMMAND_ID_IDENTIFY, > > CXL_MEM_COMMAND_ID_MAX > > }; > > > > static const struct { > > const char *name; > > } cxl_command_names[] = { > > [CXL_MEM_COMMAND_ID_INVALID] = { "Invalid Command" }, > > [CXL_MEM_COMMAND_ID_IDENTIFY] = { "Identify Comamnd" }, > > /* I hope you never need the Last command to exist in here as that sounds like a bug */ > > }; > > > > That's assuming I actually figured the macro fun out correctly. > > To my mind it's worth doing this stuff for 'lots' no so much for 3. > > The list will continue to expand, and it eliminates the "did you > remember to update cxl_command_names" review burden permanently. How about a compromise. Add a comment giving how the first entry expands to avoid people (me at least :) having to think their way through it every time? Jonathan