From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 301D2C433FE for ; Mon, 7 Nov 2022 15:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231851AbiKGPl0 (ORCPT ); Mon, 7 Nov 2022 10:41:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232936AbiKGPlZ (ORCPT ); Mon, 7 Nov 2022 10:41:25 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E851F9ED for ; Mon, 7 Nov 2022 07:41:23 -0800 (PST) Received: from fraeml738-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4N5b4q1h6dz6HJTP; Mon, 7 Nov 2022 23:39:23 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml738-chm.china.huawei.com (10.206.15.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 7 Nov 2022 16:41:21 +0100 Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 7 Nov 2022 15:41:20 +0000 Date: Mon, 7 Nov 2022 15:41:20 +0000 From: Jonathan Cameron To: Dave Jiang CC: , , , , , , , Subject: Re: [PATCH v2 15/19] cxl/pmem: add id attribute to CXL based nvdimm Message-ID: <20221107154120.00002834@Huawei.com> In-Reply-To: <166377437758.430546.16461184844990298793.stgit@djiang5-desk3.ch.intel.com> References: <166377414787.430546.3863229455285366312.stgit@djiang5-desk3.ch.intel.com> <166377437758.430546.16461184844990298793.stgit@djiang5-desk3.ch.intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org On Wed, 21 Sep 2022 08:32:57 -0700 Dave Jiang wrote: > Add an id group attribute for CXL based nvdimm object. The addition allows > ndctl to display the "unique id" for the nvdimm. The serial number for the > CXL memory device will be used for this id. > > [ > { > "dev":"nmem10", > "id":"0x4", > "security":"disabled" > }, > ] > > The id attribute is needed by the ndctl security key management to setup a > keyblob with a unique file name tied to the mem device. > > Signed-off-by: Dave Jiang One comment inline, but feel free to ignore. Reviewed-by: Jonathan Cameron > --- > drivers/cxl/pmem.c | 29 ++++++++++++++++++++++++++++- > 1 file changed, 28 insertions(+), 1 deletion(-) > > diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c > index 24bec4ca3866..9f34f8701b57 100644 > --- a/drivers/cxl/pmem.c > +++ b/drivers/cxl/pmem.c > @@ -48,6 +48,32 @@ static void unregister_nvdimm(void *nvdimm) > cxl_nvd->bridge = NULL; > } > > +static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf) > +{ > + struct nvdimm *nvdimm = to_nvdimm(dev); > + struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(nvdimm); > + struct cxl_memdev *cxlmd = cxl_nvd->cxlmd; > + struct cxl_dev_state *cxlds = cxlmd->cxlds; > + > + return sysfs_emit(buf, "%lld\n", cxlds->serial); Given single uses I'd be tempted to not bother with the local variables except when it gets really olong struct cxl_nvdimm *cxl_nvd = nvdimm_provider_data(to_nvdimm(dev)); struct cxl_dev_state *cxlds = cxl_nvd->cxlmd->cxlds; maybe. Up to you on what style you prefer though. > +}