Message ID | 20230307165359.225361-13-miquel.raynal@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2543188wrd; Tue, 7 Mar 2023 09:02:43 -0800 (PST) X-Google-Smtp-Source: AK7set/dPrs/9VLnP5yD9gN3/SeSfFmV4sUCdq4bBwFC1gVpCSyu5kAHmp4VzmxReI3UOLIPc8QU X-Received: by 2002:a05:6402:1512:b0:4c2:6b68:c126 with SMTP id f18-20020a056402151200b004c26b68c126mr3673617edw.8.1678208563833; Tue, 07 Mar 2023 09:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678208563; cv=none; d=google.com; s=arc-20160816; b=tsJQzhTxhUDUJ1D6pmvY1jEtX3PFxl+Mzc4MXGCTY8Mnx0vuSsVPoy0PHR9X0gvckt c1M4sCHnegaaFDkeE/+E4rS2hH8u7olxngPVdgQE93B8glkHc8vkbeEhS4AyDUfBHMfH YJuR35tXw5XMimLO+vCq3YooCNySRgN2yv5EIckqIw0slr3u6TH7Crn3xbksEDdTgyev oK46uxOpMp2Fh6B+jcFYd0flzd1LpRiCyKYCkSRFihlAq26LXXNt7XJJrIARiTKxGo42 v1zkpF8Zv41Fivy5qGFW6OreBx+o4PqgI/6X4flzHeVAytQbnxgpDrbBJoC0NfFFaD0+ oCVQ== 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=kOBXXD4vbju2aL5V1RwDCtfqYKoZS1/2BAnTjzjhigg=; b=zWpDzyCc19lZaExCY4GSthWaQTv6lPLVs1XMkrsEsaLE+JfDdRgGkx0A9F5O51ASQg /DDw2XgvAl2tBsrHMnuKpUVWxs+vtrCH2M5Usqq5RUti7Cx4R1VXDznEqzzkx876epDx CJcV65xE2CBdSg4SfbiOQQ/OYVWbaLs6zmNEP8Oc0jy8Cy/Ydh3hlpkRcoCCDuMQEoA0 u5IPRpAUXejBjLQ7eoCClnbj7XolmZHN4Xi36VgTy6eNEuY6CZChZBk9Kh9iB59Yw1me NJU7MmOO0TtsMtzZ7+8SgYUEG3Gc32bidlbw1912Xt8KxckE8DIu22J5hk/OC9traHDb fP9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XmvOkhJe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e1-20020a50fb81000000b004af6a815065si1833556edq.592.2023.03.07.09.02.17; Tue, 07 Mar 2023 09:02:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=XmvOkhJe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbjCGQ7o (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 7 Mar 2023 11:59:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjCGQ6K (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Mar 2023 11:58:10 -0500 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5426B90099; Tue, 7 Mar 2023 08:54:46 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 2D87BC000D; Tue, 7 Mar 2023 16:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678208085; 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=kOBXXD4vbju2aL5V1RwDCtfqYKoZS1/2BAnTjzjhigg=; b=XmvOkhJe/csozAO8RiC8briNTgzHaFAAeLwzDqCK5gHSaayiyxCSAkjAukIRH1k59bhq/K +S0T3pupqkvWW+nNIBG51gEyZ1XnlGdxOq2oW4sGPQJbn3Sl48GvY7jtAsEBDe27jebiQ4 Ia3We7tWbjefJ4ukYMM7B7+tZGgv6mYd9apYvPCLOyKeBqxCByy3Be5QlXHNucg15MMX0s Anh4WXFdYr4ue087X/eRxrHSHtg7EiLe3loDg9kRjG1ryd3ff4xqkCkKNDgojG5Go4WGhM wa8FHizTxjoWOmLsYgTHU3X3To44xP+GI8cPPPvRZn5a7NbOHm6IkskEUU4sew== From: Miquel Raynal <miquel.raynal@bootlin.com> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, <linux-kernel@vger.kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Michael Walle <michael@walle.cc>, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= <rafal@milecki.pl>, Robert Marko <robert.marko@sartura.hr>, Luka Perkov <luka.perkov@sartura.hr>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Rob Herring <robh+dt@kernel.org>, Frank Rowand <frowand.list@gmail.com>, devicetree@vger.kernel.org, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH v2 12/21] nvmem: core: request layout modules loading Date: Tue, 7 Mar 2023 17:53:50 +0100 Message-Id: <20230307165359.225361-13-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230307165359.225361-1-miquel.raynal@bootlin.com> References: <20230307165359.225361-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759729223262225741?= X-GMAIL-MSGID: =?utf-8?q?1759729223262225741?= |
Series |
nvmem: Layouts support
|
|
Commit Message
Miquel Raynal
March 7, 2023, 4:53 p.m. UTC
When a storage device like an eeprom or an mtd device probes, it registers an nvmem device if the nvmem subsystem has been enabled (bool symbol). During nvmem registration, if the device is using layouts to expose dynamic nvmem cells, the core will first try to get a reference over the layout driver callbacks. In practice there is not relationship that can be described between the storage driver and the nvmem layout. So there is no way we can enforce both drivers will be built-in or both will be modules. If the storage device driver is built-in but the layout is built as a module, instead of badly failing with an endless probe deferral loop, lets just make a modprobe call in case the driver was made available in an initramfs with of_device_node_request_module(), and offer a fully functional system to the user. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Michael Walle <michael@walle.cc> --- drivers/nvmem/core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 51fd792b8d70..9ef7617e2718 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -17,6 +17,7 @@ #include <linux/nvmem-provider.h> #include <linux/gpio/consumer.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/slab.h> struct nvmem_device { @@ -761,6 +762,13 @@ static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) if (!layout_np) return NULL; + /* + * In case the nvmem device was built-in while the layout was built as a + * module, we shall manually request the layout driver loading otherwise + * we'll never have any match. + */ + of_device_node_request_module(layout_np); + spin_lock(&nvmem_layout_lock); list_for_each_entry(l, &nvmem_layouts, node) {