From patchwork Wed Jul 12 12:08:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13310266 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 B6F76EB64D9 for ; Wed, 12 Jul 2023 12:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbjGLMIv (ORCPT ); Wed, 12 Jul 2023 08:08:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbjGLMIt (ORCPT ); Wed, 12 Jul 2023 08:08:49 -0400 Received: from imap4.hz.codethink.co.uk (imap4.hz.codethink.co.uk [188.40.203.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C01E4F for ; Wed, 12 Jul 2023 05:08:44 -0700 (PDT) Received: from [134.238.52.102] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1qJYdj-00CX6F-BR; Wed, 12 Jul 2023 13:08:16 +0100 Received: from ben by rainbowdash with local (Exim 4.96) (envelope-from ) id 1qJYdg-0005XT-2O; Wed, 12 Jul 2023 13:08:12 +0100 From: Ben Dooks To: nvdimm@lists.linux.dev Cc: linux-acpi@vger.kernel.org, Ben Dooks Subject: [PATCH v2] ACPI: NFIT: add helper to_nfit_mem() to take device to nfit_mem Date: Wed, 12 Jul 2023 13:08:10 +0100 Message-Id: <20230712120810.21282-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add a quick helper to just do struct device to the struct nfit_mem field it should be referencing. This reduces the number of code lines in some of the following code as it removes the intermediate struct nvdimm. Signed-off-by: Ben Dooks Reviewed-by: Alison Schofield --- v2: - fix typo of follwoing - add blank line in to_nfit_mem() --- drivers/acpi/nfit/core.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 0fcc247fdfac..b04c8a41380a 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1361,18 +1361,23 @@ static const struct attribute_group *acpi_nfit_attribute_groups[] = { NULL, }; -static struct acpi_nfit_memory_map *to_nfit_memdev(struct device *dev) +static struct nfit_mem *to_nfit_mem(struct device *dev) { struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + + return nvdimm_provider_data(nvdimm); +} + +static struct acpi_nfit_memory_map *to_nfit_memdev(struct device *dev) +{ + struct nfit_mem *nfit_mem = to_nfit_mem(dev); return __to_nfit_memdev(nfit_mem); } static struct acpi_nfit_control_region *to_nfit_dcr(struct device *dev) { - struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + struct nfit_mem *nfit_mem = to_nfit_mem(dev); return nfit_mem->dcr; } @@ -1531,8 +1536,7 @@ static DEVICE_ATTR_RO(serial); static ssize_t family_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + struct nfit_mem *nfit_mem = to_nfit_mem(dev); if (nfit_mem->family < 0) return -ENXIO; @@ -1543,8 +1547,7 @@ static DEVICE_ATTR_RO(family); static ssize_t dsm_mask_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + struct nfit_mem *nfit_mem = to_nfit_mem(dev); if (nfit_mem->family < 0) return -ENXIO; @@ -1555,8 +1558,7 @@ static DEVICE_ATTR_RO(dsm_mask); static ssize_t flags_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + struct nfit_mem *nfit_mem = to_nfit_mem(dev); u16 flags = __to_nfit_memdev(nfit_mem)->flags; if (test_bit(NFIT_MEM_DIRTY, &nfit_mem->flags)) @@ -1576,8 +1578,7 @@ static DEVICE_ATTR_RO(flags); static ssize_t id_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + struct nfit_mem *nfit_mem = to_nfit_mem(dev); return sprintf(buf, "%s\n", nfit_mem->id); } @@ -1586,8 +1587,7 @@ static DEVICE_ATTR_RO(id); static ssize_t dirty_shutdown_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct nvdimm *nvdimm = to_nvdimm(dev); - struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); + struct nfit_mem *nfit_mem = to_nfit_mem(dev); return sprintf(buf, "%d\n", nfit_mem->dirty_shutdown); }