From patchwork Tue Aug 4 14:14:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaurav Kohli X-Patchwork-Id: 247430 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp397313ilo; Tue, 4 Aug 2020 07:15:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYrqq+96vDhW/sV75I3pzRY0/XjVUuxEF/unY5bu/uGbVKtrIYzqZpGkrXwhRQTEQNgg/I X-Received: by 2002:a05:6402:899:: with SMTP id e25mr20352788edy.311.1596550515142; Tue, 04 Aug 2020 07:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596550515; cv=none; d=google.com; s=arc-20160816; b=Fa/Bm7O9D/+NrmtbNEYPhY3uf8mBGc5mjJjc+fHE0OxzDtoCKd/NAIgelnQ7yDF2PW 8b85kuZ1Svh02gj4ZxXYsvxbv6pDlNMfSqUdPkIzBFukRfdihS2R3AJMHY4DfdEnpU5V jwuaUTyPuWP7CrXYa0bKjw26m8zD7iLNkmmzXes6EzrCL1QKBmTnO5VcNBIlfJxtpCpU P81qEB2OT7obR3UHAMM1vgNEMTzVw29/c6amqiV77KJIHqrlaCbYGaza1IxFm3wbJtRq qr0EM32AT0wNrJrREP7PlEd7Ldd4hue34rqqCph6vDZEfjZMC3ppWJr3vtXvvqLXDa3I BhEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+/wDKM8e+UTlr9vo9Yot5xUHaBCdgwMhr9KnyKUdbY4=; b=jeb35mayeJjXmAAlhFibllRDYJFcP6q+yXVPTbnN9zuCdZi9HjF4alZ3xb+YnHCXfA B/FPXSCnt4rnZ5wOj9FfKOPRT+FRsxKJWeTFlBkP1tb9h7KiulWsq4veRNI//HM+PB8F Zm7OE03XZjhuAyPaY6u6jg90Ua/ncWSrqaurKZBHuc8RJeW063SEq+ywYHU65DVLc+26 gknU9C+IOclb2Ej4gF/hX5zYhEdwuGTLvcz1+66GB3H6pzaFLxsyXr/5ewEVYqxAF4UB gp+VstMO7JsWVZWRZYMs+fUsT5uEhVWMqAF4vMWfW+yxfLIOkfUSNRoka5gMoa3VhWFt iYsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si9587585edn.405.2020.08.04.07.15.14; Tue, 04 Aug 2020 07:15:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728724AbgHDOPL (ORCPT + 15 others); Tue, 4 Aug 2020 10:15:11 -0400 Received: from alexa-out.qualcomm.com ([129.46.98.28]:9467 "EHLO alexa-out.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbgHDOPG (ORCPT ); Tue, 4 Aug 2020 10:15:06 -0400 Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 04 Aug 2020 07:15:04 -0700 Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 04 Aug 2020 07:15:03 -0700 Received: from gkohli-linux.qualcomm.com ([10.204.78.26]) by ironmsg01-blr.qualcomm.com with ESMTP; 04 Aug 2020 19:44:50 +0530 Received: by gkohli-linux.qualcomm.com (Postfix, from userid 427023) id 73D3B486B; Tue, 4 Aug 2020 19:44:49 +0530 (IST) From: Gaurav Kohli To: will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, neeraju@codeaurora.org, Srinivas Kandagatla Subject: [PATCH] nvmem: core: add support to NVMEM_NO_SYSFS_ENTRY Date: Tue, 4 Aug 2020 19:44:43 +0530 Message-Id: <1596550484-11029-2-git-send-email-gkohli@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1596550484-11029-1-git-send-email-gkohli@codeaurora.org> References: <1596550484-11029-1-git-send-email-gkohli@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Srinivas Kandagatla Some users might not want to expose nvmem entry to sysfs and only intend to use kernel interface so add such provision. Signed-off-by: Srinivas Kandagatla --- Documentation/ABI/stable/sysfs-bus-nvmem | 2 ++ drivers/nvmem/Kconfig | 5 +++++ drivers/nvmem/core.c | 11 ++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) NULL, }; @@ -240,7 +240,7 @@ static const struct attribute_group nvmem_bin_ro_group = { .attrs = nvmem_attrs, }; -static const struct attribute_group *nvmem_ro_dev_groups[] = { +static const __maybe_unused struct attribute_group *nvmem_ro_dev_groups[] = { &nvmem_bin_ro_group, NULL, }; @@ -265,7 +265,7 @@ static const struct attribute_group nvmem_bin_rw_root_group = { .attrs = nvmem_attrs, }; -static const struct attribute_group *nvmem_rw_root_dev_groups[] = { +static const __maybe_unused struct attribute_group *nvmem_rw_root_dev_groups[] = { &nvmem_bin_rw_root_group, NULL, }; @@ -289,7 +289,7 @@ static const struct attribute_group nvmem_bin_ro_root_group = { .attrs = nvmem_attrs, }; -static const struct attribute_group *nvmem_ro_root_dev_groups[] = { +static const __maybe_unused struct attribute_group *nvmem_ro_root_dev_groups[] = { &nvmem_bin_ro_root_group, NULL, }; @@ -688,6 +688,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->read_only = device_property_present(config->dev, "read-only") | config->read_only; +#if !defined(CONFIG_NVMEM_NO_SYSFS_ENTRY) if (config->root_only) nvmem->dev.groups = nvmem->read_only ? nvmem_ro_root_dev_groups : @@ -696,7 +697,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->dev.groups = nvmem->read_only ? nvmem_ro_dev_groups : nvmem_rw_dev_groups; - +#endif device_initialize(&nvmem->dev); dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name); -- 2.21.0 diff --git a/Documentation/ABI/stable/sysfs-bus-nvmem b/Documentation/ABI/stable/sysfs-bus-nvmem index 5923ab4620c5..12aab0a85fea 100644 --- a/Documentation/ABI/stable/sysfs-bus-nvmem +++ b/Documentation/ABI/stable/sysfs-bus-nvmem @@ -6,6 +6,8 @@ Description: This file allows user to read/write the raw NVMEM contents. Permissions for write to this file depends on the nvmem provider configuration. + Note: This file is not present if CONFIG_NVMEM_NO_SYSFS_ENTRY + is enabled ex: hexdump /sys/bus/nvmem/devices/qfprom0/nvmem diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 0a7a470ee859..6ab3276d287c 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -192,4 +192,9 @@ config SC27XX_EFUSE This driver can also be built as a module. If so, the module will be called nvmem-sc27xx-efuse. +config NVMEM_NO_SYSFS_ENTRY + bool "No nvmem sysfs entry" + + help + Say Yes if you do not want to add nvmem entry to sysfs. endif diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index b9a0270883a0..c70f183fe379 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -216,7 +216,7 @@ static const struct attribute_group nvmem_bin_rw_group = { .attrs = nvmem_attrs, }; -static const struct attribute_group *nvmem_rw_dev_groups[] = { +static const __maybe_unused struct attribute_group *nvmem_rw_dev_groups[] = { &nvmem_bin_rw_group,