Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1873728pxb; Wed, 10 Feb 2021 20:44:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxv1l5/iojFJ8PCmdjO0XSYiju5X0KhTn6lyLLwaGAiD7JhOXWXQHMYG3vA0QrTLwVv5pSm X-Received: by 2002:a05:6402:2683:: with SMTP id w3mr6360926edd.378.1613018655481; Wed, 10 Feb 2021 20:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613018655; cv=none; d=google.com; s=arc-20160816; b=wb9bYxJYL1Bj+fQLfzgxk6J/uEque4HQgj3a+vFuj/8YlYCfOkFwvMl6IZ6zlvJbLI 3S9vHTuqtMc2IKXs5X8JL9DDcgAovTABBQqTVgrz2tjKVV2axPRa9L875wlmt2kEWDvw KxjVjmL1tw+Wv5JPthkmoSPzKf1ipqEiRE7+TTLL+xB/gIS+QN51QrbZcuauwJuh1z8n 9q5/aQB0MRZ43nh89w6/H+icJUOgG10Isw4h0zSPBoGXkLFXkuQcKMP/6A8kfElaIjtv +oI5uWQIvcdBPG0KFliRZajQiOfg4l0dsvv9dhhmQFIie1fE/YpmfKa2dPUgvFTFOQLm NUmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sl6/My6OzOs0T7wZB4oePD5pENhmSvczhT0K8Arc7LI=; b=VFW1WgtqLEhk72nGyzsiwQRd61CXBGgxXVyRQWDZKHFqr7gj2Hfr1qaLjvbfI976ug uu+MUHUlgFVc92K/j07E5HAhI7fnY3x4FiGwH0V/7gDvAO53M+qxKKi2cGMzi3s6GtoX lrsc/AXzQWKTp8mD5ZUayQqFWBeP5Hm3cjCqr0c0ciSN/aX+j48bM/eCMjZr8GSrZMBt G7ywX+ctM2/6ctKhJjPYM2bEbeuhQ83r+LKaIBH/rYZ9uNQZGMgQzo1BkOA/Jdl06zSl AW0WGeb6fK3xli1sxydsHr5+KTpHezeQXme+W4JQ1TqJ7zloOwmgBhCqq2yisaC9eyiO S9Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="WkyTT/tl"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i3si2666840ejj.583.2021.02.10.20.43.51; Wed, 10 Feb 2021 20:44:15 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="WkyTT/tl"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbhBKElr (ORCPT + 99 others); Wed, 10 Feb 2021 23:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbhBKElo (ORCPT ); Wed, 10 Feb 2021 23:41:44 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E1CC06174A for ; Wed, 10 Feb 2021 20:41:04 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id jj19so8015006ejc.4 for ; Wed, 10 Feb 2021 20:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sl6/My6OzOs0T7wZB4oePD5pENhmSvczhT0K8Arc7LI=; b=WkyTT/tlVuOu/QtJMR4TMPtKI3ZroEdf6vo0pV6EA6pmvld9AUZh5AcBIdoQsmyy5W ujhDIglIq4no4S4FnPjAJEON+41CXF/kZhVZc/Of6nBcJmH2ckxq7jFNww9nR/DwT+h/ 8UqUiI1xPm3fisBJZevopAV8RlTeHFLm996qBPYad35tPwuvIkQ2wNljHBO7QuzsU8pl m6UjMx88Bp2ax8h59hFBDU+mEcT6OxV4L26reH2yIq5jyt3ZKaGUX00yc6uufxWXKc/K 6TpW44YRo7+SiphYrSoLs6Eu0cjTNKyi8E8jF9IRE0pU/01y+thIBuSGcpnf168C/Bou mgcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sl6/My6OzOs0T7wZB4oePD5pENhmSvczhT0K8Arc7LI=; b=psi93shDhnwbKhb5nIm9ixDEYMEfXPFG28JovmIZ/xDZQ8gPgZFa7o0eeg1MjVTxoh QvARzascb8w3hNreJKO9USNaOFsDzXj8RjJeUR7ZNLx9AfO/O6A9p9R87v7MPEqM6msT EI8ZrVvUbqLoRmvsuVXfbab++zklYEcGXR1iYrc2YEWqTsxjM6iPERjj+W4hR3P4CZYd T9wnbxjGDd8zOrmXgzNpkiA01W07Fu1Rt7fAPlqvfOqm/plJ2sXib0cq9gDxd5o9H6cZ 44D6gUX+YnBCR5/oLvF+XjAOuN9v+7b/7+4LKRIQLuqWPjXG6fD+8hfN/oveSLe3vTNT BllQ== X-Gm-Message-State: AOAM531FA3GoBMLexG9IWHvPwUZ6mcgLen/j5mKMHbnCnc06cb0SZZId /FdjR+UDNXmEk3YXFGQZDSKmjCyNNByG9RRk0FOq1Q== X-Received: by 2002:a17:906:78a:: with SMTP id l10mr6139548ejc.264.1613018462922; Wed, 10 Feb 2021 20:41:02 -0800 (PST) MIME-Version: 1.0 References: <20210210000259.635748-1-ben.widawsky@intel.com> <20210210000259.635748-5-ben.widawsky@intel.com> <20210210184540.00007536@Huawei.com> In-Reply-To: <20210210184540.00007536@Huawei.com> From: Dan Williams Date: Wed, 10 Feb 2021 20:40:52 -0800 Message-ID: Subject: Re: [PATCH v2 4/8] cxl/mem: Add basic IOCTL interface To: Jonathan Cameron Cc: Ben Widawsky , linux-cxl@vger.kernel.org, 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/ > > 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.