From patchwork Mon Oct 30 20:41:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lijun.Pan@dell.com X-Patchwork-Id: 10033123 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 8A6F260291 for ; Mon, 30 Oct 2017 20:41:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7059928967 for ; Mon, 30 Oct 2017 20:41:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61C372896B; Mon, 30 Oct 2017 20:41:35 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D8AA728967 for ; Mon, 30 Oct 2017 20:41:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8DCD221CEB12D; Mon, 30 Oct 2017 13:37:42 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=68.232.149.214; helo=esa4.dell-outbound.iphmx.com; envelope-from=lijun.pan@dell.com; receiver=linux-nvdimm@lists.01.org Received: from esa4.dell-outbound.iphmx.com (esa4.dell-outbound.iphmx.com [68.232.149.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 998FD2034CF96 for ; Mon, 30 Oct 2017 13:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1509396092; x=1540932092; h=from:to:cc:subject:date:message-id; bh=MgJbGYS+JFpyE0/yJX0bve3SHhX2INxWP4zIBIBFr/U=; b=lt+mY0ZznBVEm8Of3gBLZce0j/BVvKq+/Riuk9AVrBC0xFyxg6fg7IH3 uYYntPYf6MFeAnrd9bz71ffDllKBuN2+EjhIGO8u2/KzWTobfHxPaeSVO mejrayz5jUZzjDVlO23eNaCVgEMCQjvkAqRJeY/HHG3ZNftxX2aqTXMG4 E=; Received: from esa4.dell-outbound2.iphmx.com ([68.232.154.98]) by esa4.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2017 15:41:31 -0500 Received: from ausc60pc101.us.dell.com ([143.166.85.206]) by esa4.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Oct 2017 02:41:31 +0600 X-LoopCount0: from 10.210.138.183 X-IronPort-AV: E=Sophos; i="5.44,321,1505797200"; d="scan'208"; a="1171990045" X-DLP: DLP_GlobalPCIDSS From: Lijun Pan To: linux-nvdimm@lists.01.org Subject: [PATCH] acpi/nfit: export read_only attribute of dimms Date: Mon, 30 Oct 2017 15:41:27 -0500 Message-Id: <20171030204127.4779-1-Lijun.Pan@dell.com> X-Mailer: git-send-email 2.13.6 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lijun Pan MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Though flags attribute provides enough information about the dimm, it is nice to export the read_only attribute if bit3 of NVDIMM state flag is set. If error is injected by BIOS, bit3 and bit1 are both set. If DIMM is set to read-only by BIOS, bit3 is set. Hence bit3 is good enough to tell whether the dimm is in read-only mode or not. Signed-off-by: Lijun Pan --- drivers/acpi/nfit/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index ebe0857ac346..f96e65aa29dd 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1480,6 +1480,16 @@ static ssize_t flags_show(struct device *dev, } static DEVICE_ATTR_RO(flags); +static ssize_t read_only_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + u16 flags = to_nfit_memdev(dev)->flags; + + return sprintf(buf, "%d\n", + flags & ACPI_NFIT_MEM_NOT_ARMED ? 1 : 0); +} +static DEVICE_ATTR_RO(read_only); + static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1512,6 +1522,7 @@ static struct attribute *acpi_nfit_dimm_attributes[] = { &dev_attr_format1.attr, &dev_attr_serial.attr, &dev_attr_flags.attr, + &dev_attr_read_only.attr, &dev_attr_id.attr, &dev_attr_family.attr, &dev_attr_dsm_mask.attr,