Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp358078pxa; Tue, 4 Aug 2020 07:20:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9g1cJTKSLsIi/ba6AKEJulU0ksURW65XXdfiFC7tGmeSNy6Tq/1hpBkaxVqYZh9pb/AV3 X-Received: by 2002:a05:6402:c0a:: with SMTP id co10mr21677788edb.342.1596550810143; Tue, 04 Aug 2020 07:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596550810; cv=none; d=google.com; s=arc-20160816; b=B1YzExTuLmi+QBCdjvMIGTJO+kI6JkWWY8+GyxJ2KY7h2h9YxVrIDciRvA+mlqjKM1 UbJgpv58r/dbV1xmYfa/Tkj00hLxsqJBXT5bOx2GWGgZbHDeRo2zx7D0btTC23sc556F QPyzrPT4xvZ4mpbva/UjGF8jxnoYIG/Xf9E3wQbEuTve/i+dRzvH0FJofgBr91P5nT1U IW9oTFYjr3MMThP+Thjkae/WyHnTRHmWrxBf2DHNrt0kmV5tIj15WfEv904saJa/yNpL 2y9mNnFjmc83rQVPIVbn1EZxPn8jaCT5vI5yOydVYOD3HN2sZKIZTDeXP7iueyDVPHul D2iQ== 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=PhMo12e6AnKanhdBop2acTT5c6A0dpv0/OUwVbs5bfF3LrMfxlVSvQRR2wkVcGRGXh ZsUCOIn82HTjx6Z9YNtAB3VThfqRyWvGt670em54U5FzFpZ2c08Og6UEBXN2upEmn77M UTmzE3zGXfBvqPdPE9b81jMRIg/eqowuZ8FKfm+UdR/gXAOMacRsgp/ANWYFC2a39Q37 waV2XDuBVCZ5/HuGiIVYkcrFrpTEI3qJeTm4APk9uKzGUzCR4OyPECJxeiVvzv3vrpRY ayqJC60jQYoo6CHkmhpzbxjUqViBdmXWsX5+I7mcjSl/Kkgu62Hhv8O1cX7Mz42mmHDE qC/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 d7si12928895edp.94.2020.08.04.07.19.35; Tue, 04 Aug 2020 07:20:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbgHDOPQ (ORCPT + 99 others); Tue, 4 Aug 2020 10:15:16 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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, 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