From patchwork Thu Aug 10 08:23:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jehoon Park X-Patchwork-Id: 13348997 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 5EA56C001DB for ; Thu, 10 Aug 2023 08:21:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231177AbjHJIVP (ORCPT ); Thu, 10 Aug 2023 04:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjHJIVO (ORCPT ); Thu, 10 Aug 2023 04:21:14 -0400 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BADF6DC for ; Thu, 10 Aug 2023 01:21:13 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20230810082110epoutp040f13f303d700263a0a0c7eb5009693c2~5996N7Fc53025830258epoutp04C for ; Thu, 10 Aug 2023 08:21:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20230810082110epoutp040f13f303d700263a0a0c7eb5009693c2~5996N7Fc53025830258epoutp04C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691655670; bh=EKbo0WUTNsLO5aA9YClOBcslLNoazkQ4NnjHSwDdiO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UtAuxXbEWrtY07qYvAyE7zQYR73M3K6iaWwUHk7Q6lOOeLd469nzgNBqnkjDBF84E NWwOR4bQ5MI/mforZd5b4vwfhhOE4n8d/TyTXwKO0y3vJhd3eCSvq1RKkkFwRuLb// 6R+H7s5e8dD2McAi13zKhEM9XJ9G6E0CSjWtBXrI= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230810082109epcas2p151fa13821dd19f5106ea88f1e10b5d53~5995pUQJ_2693426934epcas2p12; Thu, 10 Aug 2023 08:21:09 +0000 (GMT) Received: from epsmgec2p1.samsung.com (unknown [182.195.36.70]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4RM0Hm72x5z4x9QB; Thu, 10 Aug 2023 08:21:08 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmgec2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.DC.49986.4FD94D46; Thu, 10 Aug 2023 17:21:08 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p4.samsung.com (KnoxPortal) with ESMTPA id 20230810082108epcas2p49dce460a55b44ece76c8df4122313514~5994d03CW0623306233epcas2p4t; Thu, 10 Aug 2023 08:21:08 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230810082108epsmtrp162e037a6647407190c3d97c42e96bcce~5994dB7zF3202032020epsmtrp1t; Thu, 10 Aug 2023 08:21:08 +0000 (GMT) X-AuditID: b6c32a43-84dfa7000000c342-c5-64d49df4e554 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id C7.24.64355.4FD94D46; Thu, 10 Aug 2023 17:21:08 +0900 (KST) Received: from jehoon-Precision-7920-Tower.dsn.sec.samsung.com (unknown [10.229.83.133]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230810082108epsmtip15d4a2bac85823c02d93bb298c28f0c82~5994OBMxM1945419454epsmtip1R; Thu, 10 Aug 2023 08:21:08 +0000 (GMT) From: Jehoon Park To: linux-cxl@vger.kernel.org Cc: nvdimm@lists.linux.dev, Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Dave Jiang , Davidlohr Bueso , Jonathan Cameron , Kyungsan Kim , Junhyeok Im , Jehoon Park Subject: [ndctl PATCH v3 1/3] libcxl: Update a outdated value to the latest revision Date: Thu, 10 Aug 2023 17:23:52 +0900 Message-Id: <20230810082354.5992-2-jehoon.park@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230810082354.5992-1-jehoon.park@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmqe6XuVdSDLZtMre4+/gCm8X0qRcY LU7cbGSzWH1zDaPF/qfPWSwOvG5gt1i18BqbxeKjM5gtju7hsDg/6xSLxcoff1gtbk04xuTA 49Fy5C2rx+I9L5k8XmyeyejRt2UVo8fU2fUenzfJBbBFZdtkpCampBYppOYl56dk5qXbKnkH xzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXmAJ2opFCWmFMKFApILC5W0rezKcovLUlVyMgv LrFVSi1IySkwL9ArTswtLs1L18tLLbEyNDAwMgUqTMjO2LbgLHPBfraKLXuOszYwHmLtYuTk kBAwkehuWM7SxcjFISSwg1Fi45Q5rBDOJ0aJ1+unMMI53bP6GGFank69yAyR2MkosfjTeqiW XiaJJSt72ECq2AS0Je5v3wBmiwjISjSve8AEUsQssJlZYtnOc2AJYYEwieOvr4JdwiKgKrFp 6lcwm1fAWuLZxyVQF8pLrN5wgBnE5hSwkfi8dyXYNgmBt+wShzbuhypykTjSNgnqPmGJV8e3 sEPYUhIv+9ug7HyJnydvQdUXSHz68oEFwjaWeHfzOVCcA+g6TYn1u/RBTAkBZYkjt8AqmAX4 JDoO/2WHCPNKdLQJQTSqSnQd/wC1VFri8JWjzBC2h8SGJ0uhIdfPKPFy4V/GCYxysxAWLGBk XMUollpQnJuemmxUYAiPsuT83E2M4DSo5byD8cr8f3qHGJk4GA8xSnAwK4nw2g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 0BQ+jfFg3USD4rn5zVe4anI9tefO8P3zaJqaUL/ZtTXhy8Xa/EUsdbcf/T7BaTmj6INKNgmR nWuaK6csT/LktH5fGjEjd/GUs7rHLPaKzxVXzSjcrHrKaPdJ+wuskRfWiU7vNkzblqDVNmfS e4/Nln+2a8af9jn07u5a0eg30gw1FVMjjl38dHfXYoWTsl+Ms6Y8cd4qkNT0etb7c/KBb3gc P2uelhJPuXxS2mlZMU/LzoqEG3VMV37oN99y9FrpfO7oz4sB/xav15gx++OzuJrUGQf13ovy Z7W9mb39/jOxFfdVlOqVL8298/1AjW3R+Y0vy+fk5Z36tz0pzzRyuhJLcUaioRZzUXEiAJGb ogzDAgAA X-CMS-MailID: 20230810082108epcas2p49dce460a55b44ece76c8df4122313514 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230810082108epcas2p49dce460a55b44ece76c8df4122313514 References: <20230810082354.5992-1-jehoon.park@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Update the predefined value for device temperature field when it is not implemented. (Revised in CXL 2.0 Errata F38) Signed-off-by: Jehoon Park Reviewed-by: Jonathan Cameron --- cxl/lib/private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cxl/lib/private.h b/cxl/lib/private.h index a641727..a692fd5 100644 --- a/cxl/lib/private.h +++ b/cxl/lib/private.h @@ -360,7 +360,7 @@ struct cxl_cmd_set_partition { #define CXL_CMD_HEALTH_INFO_EXT_CORRECTED_PERSISTENT_WARNING (1) #define CXL_CMD_HEALTH_INFO_LIFE_USED_NOT_IMPL 0xff -#define CXL_CMD_HEALTH_INFO_TEMPERATURE_NOT_IMPL 0xffff +#define CXL_CMD_HEALTH_INFO_TEMPERATURE_NOT_IMPL 0x7fff static inline int check_kmod(struct kmod_ctx *kmod_ctx) { From patchwork Thu Aug 10 08:23:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jehoon Park X-Patchwork-Id: 13348998 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 31AEBC001B0 for ; Thu, 10 Aug 2023 08:21:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231994AbjHJIVV (ORCPT ); Thu, 10 Aug 2023 04:21:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjHJIVU (ORCPT ); Thu, 10 Aug 2023 04:21:20 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59B4AC for ; Thu, 10 Aug 2023 01:21:19 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230810082117epoutp038e75aed07f65ae020e25c22762d94c39~59_BJ2vbb2667926679epoutp03L for ; Thu, 10 Aug 2023 08:21:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230810082117epoutp038e75aed07f65ae020e25c22762d94c39~59_BJ2vbb2667926679epoutp03L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691655677; bh=BiuER2At4jDkAcJOxckMGncwwMHXN1DeBeM8JYSfCJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GTa0Sl6pEFFUu7ql2A90nqc83j98f5irfd1MuaHu7xi8ndRxse41JzOZfDii2r9wp +K743jl93OFJfeCyHz+4CQrfx6+uz9wrW+RVnV7EX7AS2+3k63rkAvYl1DoAABj3L+ ojHnWCUMT7brJm9pk/xWcMQQF7Mup0Ilr7sFPsnE= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20230810082116epcas2p2bd8cc5bd8a168db96e4b20e78d1b2ce6~59_AKp_Pb2819828198epcas2p2V; Thu, 10 Aug 2023 08:21:16 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.90]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4RM0Hw13bQz4x9Q3; Thu, 10 Aug 2023 08:21:16 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 89.B7.49913.BFD94D46; Thu, 10 Aug 2023 17:21:16 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230810082115epcas2p31c2f26887e54c9fdeab0215bbde49f0a~599-R-eTB1437714377epcas2p3y; Thu, 10 Aug 2023 08:21:15 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230810082115epsmtrp249288e19407cf84f7b9abaf59abfdb4c~599-QiW3S3060530605epsmtrp2W; Thu, 10 Aug 2023 08:21:15 +0000 (GMT) X-AuditID: b6c32a45-5cfff7000000c2f9-a1-64d49dfbf04c Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id E9.24.64355.BFD94D46; Thu, 10 Aug 2023 17:21:15 +0900 (KST) Received: from jehoon-Precision-7920-Tower.dsn.sec.samsung.com (unknown [10.229.83.133]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230810082115epsmtip1a473fe04e45bbb2279150faee0cdd782~599-FO3TI2164621646epsmtip1J; Thu, 10 Aug 2023 08:21:15 +0000 (GMT) From: Jehoon Park To: linux-cxl@vger.kernel.org Cc: nvdimm@lists.linux.dev, Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Dave Jiang , Davidlohr Bueso , Jonathan Cameron , Kyungsan Kim , Junhyeok Im , Jehoon Park Subject: [ndctl PATCH v3 2/3] libcxl: Fix accessors for temperature field to support negative value Date: Thu, 10 Aug 2023 17:23:53 +0900 Message-Id: <20230810082354.5992-3-jehoon.park@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230810082354.5992-1-jehoon.park@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOKsWRmVeSWpSXmKPExsWy7bCmqe6fuVdSDC58YbK4+/gCm8X0qRcY LU7cbGSzWH1zDaPF/qfPWSwOvG5gt1i18BqbxeKjM5gtju7hsDg/6xSLxcoff1gtbk04xuTA 49Fy5C2rx+I9L5k8XmyeyejRt2UVo8fU2fUenzfJBbBFZdtkpCampBYppOYl56dk5qXbKnkH xzvHm5oZGOoaWlqYKynkJeam2iq5+AToumXmAJ2opFCWmFMKFApILC5W0rezKcovLUlVyMgv LrFVSi1IySkwL9ArTswtLs1L18tLLbEyNDAwMgUqTMjOeP68qmCZdMWkfY1sDYxnxLoYOTkk BEwkfv6dyQJiCwnsYJS4sVa2i5ELyP7EKNF+v5cFznn86RYrTMfkKRcZIRI7GSXuPn3HCuH0 MkncWn6ODaSKTUBb4v72DWC2iICsRPO6B0wgRcwCm5kllu2EKBIWSJX41XiXHcRmEVCVWPDx K1icV8Ba4v/Sz8wQ6+QlVm84AGZzCthIfN67EmybhMBLdonJLfsYIYpcJHZ+m8gCYQtLvDq+ hR3ClpL4/G4vG4SdL/HzJMwPBRKfvnyAqjeWeHfzOVCcA+g6TYn1u/RBTAkBZYkjt8AqmAX4 JDoO/2WHCPNKdLQJQTSqSnQd/wB1gLTE4StHoS72kLi4cQ8TJEz6GSX2zd/GNIFRbhbCggWM jKsYxVILinPTU4uNCgzhEZacn7uJEZwCtVx3ME5++0HvECMTB+MhRgkOZiURXtvgSylCvC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dqCLHek59zk2F60U3NG5aFL8NM93Z2Lr77/uaWbxbGy9bWl04N0PSN/+N5xSR R2e9QnxdjnDNcjAJmSin8vn2ZYsOJXs12VmnFRkm51otfvo+OeFUaECYSldhPh/3+Qi/m9ts l76RZ41PWuhl76mWMatj6SzlyUKV3o/sM66dTn2nG33c+efxd5clZOcsiunUm1DxIGFnSP9m u2ufmgteLf729u1BmZrFR/J+dp1/opNkmDVBm/ug4t3pG7NuGEpNdJlc7HHF+H7fp103eA4X iR3b3RG2cdbppC2Of387H+Nr63X4yZ5ru/5yIt8XTSHfcusvD5VYijMSDbWYi4oTAcdsK6bB AgAA X-CMS-MailID: 20230810082115epcas2p31c2f26887e54c9fdeab0215bbde49f0a X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230810082115epcas2p31c2f26887e54c9fdeab0215bbde49f0a References: <20230810082354.5992-1-jehoon.park@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Add a new macro function to retrieve a signed value such as a temperature. Modify accessors for signed value to return INT_MAX when error occurs and set errno to corresponding errno codes. Fix the error checking value of the temperature accessor in cxl/json.c. Signed-off-by: Jehoon Park --- cxl/json.c | 2 +- cxl/lib/libcxl.c | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cxl/json.c b/cxl/json.c index 7678d02..89e5fd0 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -246,7 +246,7 @@ static struct json_object *util_cxl_memdev_health_to_json( } field = cxl_cmd_health_info_get_temperature(cmd); - if (field != 0xffff) { + if (field != INT_MAX) { jobj = json_object_new_int(field); if (jobj) json_object_object_add(jhealth, "temperature", jobj); diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c index af4ca44..53c9b25 100644 --- a/cxl/lib/libcxl.c +++ b/cxl/lib/libcxl.c @@ -3661,11 +3661,23 @@ cxl_cmd_alert_config_get_life_used_prog_warn_threshold(struct cxl_cmd *cmd) life_used_prog_warn_threshold); } +#define cmd_get_field_s16(cmd, n, N, field) \ +do { \ + struct cxl_cmd_##n *c = \ + (struct cxl_cmd_##n *)cmd->send_cmd->out.payload; \ + int rc = cxl_cmd_validate_status(cmd, CXL_MEM_COMMAND_ID_##N); \ + if (rc) { \ + errno = -rc; \ + return INT_MAX; \ + } \ + return (int16_t)le16_to_cpu(c->field); \ +} while(0) + CXL_EXPORT int cxl_cmd_alert_config_get_dev_over_temperature_crit_alert_threshold( struct cxl_cmd *cmd) { - cmd_get_field_u16(cmd, get_alert_config, GET_ALERT_CONFIG, + cmd_get_field_s16(cmd, get_alert_config, GET_ALERT_CONFIG, dev_over_temperature_crit_alert_threshold); } @@ -3673,7 +3685,7 @@ CXL_EXPORT int cxl_cmd_alert_config_get_dev_under_temperature_crit_alert_threshold( struct cxl_cmd *cmd) { - cmd_get_field_u16(cmd, get_alert_config, GET_ALERT_CONFIG, + cmd_get_field_s16(cmd, get_alert_config, GET_ALERT_CONFIG, dev_under_temperature_crit_alert_threshold); } @@ -3681,7 +3693,7 @@ CXL_EXPORT int cxl_cmd_alert_config_get_dev_over_temperature_prog_warn_threshold( struct cxl_cmd *cmd) { - cmd_get_field_u16(cmd, get_alert_config, GET_ALERT_CONFIG, + cmd_get_field_s16(cmd, get_alert_config, GET_ALERT_CONFIG, dev_over_temperature_prog_warn_threshold); } @@ -3689,7 +3701,7 @@ CXL_EXPORT int cxl_cmd_alert_config_get_dev_under_temperature_prog_warn_threshold( struct cxl_cmd *cmd) { - cmd_get_field_u16(cmd, get_alert_config, GET_ALERT_CONFIG, + cmd_get_field_s16(cmd, get_alert_config, GET_ALERT_CONFIG, dev_under_temperature_prog_warn_threshold); } @@ -3914,7 +3926,7 @@ CXL_EXPORT int cxl_cmd_health_info_get_life_used(struct cxl_cmd *cmd) static int health_info_get_temperature_raw(struct cxl_cmd *cmd) { - cmd_get_field_u16(cmd, get_health_info, GET_HEALTH_INFO, + cmd_get_field_s16(cmd, get_health_info, GET_HEALTH_INFO, temperature); } @@ -3922,10 +3934,10 @@ CXL_EXPORT int cxl_cmd_health_info_get_temperature(struct cxl_cmd *cmd) { int rc = health_info_get_temperature_raw(cmd); - if (rc < 0) - return rc; - if (rc == CXL_CMD_HEALTH_INFO_TEMPERATURE_NOT_IMPL) - return -EOPNOTSUPP; + if (rc == CXL_CMD_HEALTH_INFO_TEMPERATURE_NOT_IMPL) { + errno = EOPNOTSUPP; + return INT_MAX; + } return rc; } From patchwork Thu Aug 10 08:23:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jehoon Park X-Patchwork-Id: 13348999 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 2C135C001B0 for ; Thu, 10 Aug 2023 08:21:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229693AbjHJIV0 (ORCPT ); Thu, 10 Aug 2023 04:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbjHJIVZ (ORCPT ); Thu, 10 Aug 2023 04:21:25 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05BEDAC for ; Thu, 10 Aug 2023 01:21:25 -0700 (PDT) Received: from epcas2p3.samsung.com (unknown [182.195.41.55]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230810082123epoutp0264aac0d1616e4064309db5778a24da30~59_GSxg1c0816808168epoutp02Z for ; Thu, 10 Aug 2023 08:21:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230810082123epoutp0264aac0d1616e4064309db5778a24da30~59_GSxg1c0816808168epoutp02Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1691655683; bh=TV9praheqYMa1Yz2hAnqcTTM6ObCGENXWShMrnyGeO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p2KR69SaZwGnynpTN94SfvOXBHxbQ4Lc1M8KE0LO9M0VpPJ21scipdliY5o0wbyZ6 wfRIGYJytjFv9XD4mx7ZCVWABYbsMYHn9MWMS7ZV88PmTUnzeMKnSOAs0cszqxwMsS RfsuWKi5AlOKzL4NKHFVhmfCC93tnkkBW891Gq8Y= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230810082122epcas2p435c50358082de854b89f74129e1c3e7e~59_FzSk5B2037220372epcas2p4-; Thu, 10 Aug 2023 08:21:22 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.91]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4RM0J20lVNz4x9Q1; Thu, 10 Aug 2023 08:21:22 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 55.E1.40133.10E94D46; Thu, 10 Aug 2023 17:21:21 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230810082121epcas2p3eb7acc9bdf13cafe9ef79a6fdd06b679~59_ENlXZw2608826088epcas2p3I; Thu, 10 Aug 2023 08:21:21 +0000 (GMT) Received: from epsmgmcp1.samsung.com (unknown [182.195.42.82]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230810082121epsmtrp14b948958d0cb16bec4292a75ba5d23eb~59_EM2ivI3202132021epsmtrp1A; Thu, 10 Aug 2023 08:21:21 +0000 (GMT) X-AuditID: b6c32a46-4edb870000009cc5-c1-64d49e01189c Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgmcp1.samsung.com (Symantec Messaging Gateway) with SMTP id 0C.24.64355.00E94D46; Thu, 10 Aug 2023 17:21:20 +0900 (KST) Received: from jehoon-Precision-7920-Tower.dsn.sec.samsung.com (unknown [10.229.83.133]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230810082120epsmtip14a0b07628db31283f3e1f4241692741d~59_D7iKzo1945419454epsmtip1U; Thu, 10 Aug 2023 08:21:20 +0000 (GMT) From: Jehoon Park To: linux-cxl@vger.kernel.org Cc: nvdimm@lists.linux.dev, Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Dave Jiang , Davidlohr Bueso , Jonathan Cameron , Kyungsan Kim , Junhyeok Im , Jehoon Park Subject: [ndctl PATCH v3 3/3] cxl/json.c: Fix the error checking logic when listing device's health info Date: Thu, 10 Aug 2023 17:23:54 +0900 Message-Id: <20230810082354.5992-4-jehoon.park@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230810082354.5992-1-jehoon.park@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmqS7jvCspBncatSzuPr7AZjF96gVG ixM3G9ksVt9cw2ix/+lzFosDrxvYLVYtvMZmsfjoDGaLo3s4LM7POsVisfLHH1aLWxOOMTnw eLQcecvqsXjPSyaPF5tnMnr0bVnF6DF1dr3H501yAWxR2TYZqYkpqUUKqXnJ+SmZeem2St7B 8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5QCcqKZQl5pQChQISi4uV9O1sivJLS1IVMvKL S2yVUgtScgrMC/SKE3OLS/PS9fJSS6wMDQyMTIEKE7Iz/n2YwFhwj6Niwf19TA2Mc9i7GDk5 JARMJCZev8jaxcjFISSwg1Fi8v8NbBDOJ0aJbV1djHDOq+8rmGFaJlxYwA6R2MkoMb9jPwuE 08skse34QRaQKjYBbYn720FmcXKICMhKNK97wAR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RzcQgJbGeUON7fzwiRkJa413wFqkhY4n7LEVaIom4m idYzJ9lAEmwC2hL3t28As0UEZCWa1z1gAiliFtjLLNEx8zwrSEJYIEOitWUzM4jNIqAq8XDf XSYQm1fAWuJF32UWiA3yEqs3HACr4RSwkfi8dyVYrxBQzYyl81gnMPItYGRYxSiaWlCcm56b XGCoV5yYW1yal66XnJ+7iREcqFpBOxiXrf+rd4iRiYPxEKMEB7OSCK9t8KUUId6UxMqq1KL8 +KLSnNTiQ4zSHCxK4rzKOZ0pQgLpiSWp2ampBalFMFkmDk6pBibh1v7Qeo8l3ZarHl85uu7y a6P929foT+e593nqNMYLvOwnbt/XyjirECF5QY1ZZbZE7Nef76Jkqqdd2O7ec3KdjFGrSaj1 jf8vDi7W/XxF8+hqqwWmP2V+vZqtuubzU68XFtvu/Jpsv9278f2RLUvzOwQkbjqrf1Oa8r38 TQZDKc9O+T6v//0fLj4T6RT6E7yTyVNY/4O0r1mRlL2vSVSSKUP8PPVrMpLLV7l/Citm/eiy eNFLi1UPdkl/+spsN2ertsFvYfWlHSFufxLNH/azv6o8P/VAD+/dQxnaHXdcSyTE55prH2tY sfy8B9vvjD2vNn1tWOR1f/eRzeWcU0wzXk6a6dJzUrh6uvy04itdSizFGYmGWsxFxYkA2OEt e8MCAAA= X-CMS-MailID: 20230810082121epcas2p3eb7acc9bdf13cafe9ef79a6fdd06b679 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230810082121epcas2p3eb7acc9bdf13cafe9ef79a6fdd06b679 References: <20230810082354.5992-1-jehoon.park@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Change the variable type for storing result of life used field accessor : u32 to int. Fix the value for checking device's life used field is implemented. Signed-off-by: Jehoon Park --- cxl/json.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cxl/json.c b/cxl/json.c index 89e5fd0..102bfaf 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (C) 2015-2021 Intel Corporation. All rights reserved. +#include #include #include #include @@ -238,9 +239,9 @@ static struct json_object *util_cxl_memdev_health_to_json( json_object_object_add(jhealth, "ext_corrected_persistent", jobj); /* other fields */ - field = cxl_cmd_health_info_get_life_used(cmd); - if (field != 0xff) { - jobj = json_object_new_int(field); + rc = cxl_cmd_health_info_get_life_used(cmd); + if (rc != -EOPNOTSUPP) { + jobj = json_object_new_int(rc); if (jobj) json_object_object_add(jhealth, "life_used_percent", jobj); }