Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp247676pxb; Fri, 16 Apr 2021 04:50:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFWprvmHNwdLh/x7fGi9NNklNDTdZ+2pi+4cIY7mKI8dPw/4TGXgpoRFd+2+dJpogF3GWJ X-Received: by 2002:a62:1615:0:b029:243:fec5:6618 with SMTP id 21-20020a6216150000b0290243fec56618mr7542835pfw.35.1618573820467; Fri, 16 Apr 2021 04:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618573820; cv=none; d=google.com; s=arc-20160816; b=PPiXJUkRsU5tLM3zLLE3GHU01zDfsmZIUjNiIIk6qcYgrDsMdpNf2WzCI0ICVBEtAb awRi9emGNuGP7ERMc0AJxBG9wbKDZoRM2aQ5ptiI5MC/C1ft23cuJr0bl5eXPNrCaUCT ubbjubCGi0QRnLF39ZMb6wHEO40FQk+hK21yRFkoD/89sP7gunFSK7GsXAn8PytlvlvN GzVVsZ7vFkO6kt+B0VX2Tslutm0W72H22V6Gn0Cr1V6rrRSBlA4FqRjT6LbHfHCf8Ct+ CkMhLcpe1eeZQ0giuFzagYviScWWk6/yTyVzmR3dRedpPAgWVhKbABkbHJEjxFTTgOZo NbKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xWTr4qHeviZFMb/wEtFKQQRLgF2/dLjHlxCN00SpzuA=; b=w+H7eO3JWQlV43TYNvXvaIz0R9S0+yPpNlRE0eRG+0vt/zk+qvZ211/eSFGSDlk+1B 1YhhllfYRJjUx9A3iyBcwhhhNHYUvEhGJQmDaoxjGrmdJe+ogMX2kHy23CL8Uv0KWVI+ XBhmij1czG8apc0HoH/FHjpRewv7WHi8fFTC5YLZBVXHRX8RJNLvQ/HT+JXUYl0L9xvK YBaKY7sKzwlozD/OpehWC6zuTi6wNy/v5nNfG+e4bACtrPXzOuNahCzBRnWW9NwZQnSl wYCe09PPYxmSM1ouBQhcQQKJjc3Sd102Ni0QlT5WU9X8qgRii6UYnUT94t43RZMWq5MJ /iJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=POyag6gR; 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 u133si6095513pgc.332.2021.04.16.04.50.08; Fri, 16 Apr 2021 04:50:20 -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; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=POyag6gR; 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 S240913AbhDPLuC (ORCPT + 99 others); Fri, 16 Apr 2021 07:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238743AbhDPLuB (ORCPT ); Fri, 16 Apr 2021 07:50:01 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E20EC061574; Fri, 16 Apr 2021 04:49:36 -0700 (PDT) Received: from mwalle01.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:fa59:71ff:fe9b:b851]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 4B79322253; Fri, 16 Apr 2021 13:49:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1618573774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xWTr4qHeviZFMb/wEtFKQQRLgF2/dLjHlxCN00SpzuA=; b=POyag6gRhleSn0C/8EJeoXUrAgRXCWBa+dMa1SyRTRnObQ2YOCvSk5XopKhfKqzWYZFUAY IdlZTqAQYTbz0dc5FWGZ3TewTo+k8V1JL4WKfYEBxLWW74vYuP6r6OFIW5/CkQsaGac5gg 3LZBF6n5RpPUg/9zleH+F54OIRLStSo= From: Michael Walle To: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Srinivas Kandagatla , Michael Walle Subject: [PATCH 1/5] nvmem: core: allow specifying of_node Date: Fri, 16 Apr 2021 13:49:24 +0200 Message-Id: <20210416114928.27758-2-michael@walle.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210416114928.27758-1-michael@walle.cc> References: <20210416114928.27758-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Until now, the of_node of the parent device is used. Some devices provide more than just the nvmem provider. To avoid name space clashes, add a way to allow specifying the nvmem cells in subnodes. Consider the following example: flash@0 { compatible = "jedec,spi-nor"; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; partition@0 { reg = <0x000000 0x010000>; }; }; otp { compatible = "mtd-user-otp"; #address-cells = <1>; #size-cells = <1>; serial-number@0 { reg = <0x0 0x8>; }; }; }; There the nvmem provider might be the MTD partition or the OTP region of the flash. Add a new config->of_node parameter, which if set, will be used instead of the parent's of_node. Signed-off-by: Michael Walle Acked-by: Srinivas Kandagatla --- Changes since RFC: - none drivers/nvmem/core.c | 4 +++- include/linux/nvmem-provider.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index bca671ff4e54..62d363a399d3 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -789,7 +789,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->reg_write = config->reg_write; nvmem->keepout = config->keepout; nvmem->nkeepout = config->nkeepout; - if (!config->no_of_node) + if (config->of_node) + nvmem->dev.of_node = config->of_node; + else if (!config->no_of_node) nvmem->dev.of_node = config->dev->of_node; switch (config->id) { diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index e162b757b6d5..471cb7b9e896 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -57,6 +57,7 @@ struct nvmem_keepout { * @type: Type of the nvmem storage * @read_only: Device is read-only. * @root_only: Device is accessibly to root only. + * @of_node: If given, this will be used instead of the parent's of_node. * @no_of_node: Device should not use the parent's of_node even if it's !NULL. * @reg_read: Callback to read data. * @reg_write: Callback to write data. @@ -86,6 +87,7 @@ struct nvmem_config { enum nvmem_type type; bool read_only; bool root_only; + struct device_node *of_node; bool no_of_node; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; -- 2.20.1