Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1296587rwe; Thu, 1 Sep 2022 16:17:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VACipskJCaBk73kzF/dgHnoaAGs2eEwMoGccaPKv7dXrDvKsxI/u6vuXnMU+E1S6CfEQS X-Received: by 2002:a17:906:6a03:b0:730:a20e:cf33 with SMTP id qw3-20020a1709066a0300b00730a20ecf33mr26155601ejc.620.1662074277666; Thu, 01 Sep 2022 16:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662074277; cv=none; d=google.com; s=arc-20160816; b=DlVNY7YrFhA0NIe7JcNRBTYFCcUW4naSjALR4lbRPu2roYdEJiXEv2KVUPwdC7te1L XV5GHnyfV/BQOHh3Q5uEEzAJGgpsVfcZa8k+7Di2HXvx/D55P66wtv9DF1KcikwRERH6 23TAzH+D83ZEQZtYRMegEiHQfKWjh6Wf3QTzsorOsQgwH3r4VBaTnNodpF+YgdNL7iav Y2e2iz51w8j+/rbs2waz/7QRAfdU9EBnH76FFjkkOIROmH+QwzATisKeI1o4TpEPAjn1 s/w7lVXUR7napFwEmRW1iYJ0mfNN3g2Z7MyV83H8bYYEX2Y7HBmuTWfUaJPqcrW7CIKB LyVg== 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=c5Tm5NgUjgsDKZgk1Ba857CClebez+/VRvwjllvM7EA=; b=LvHFUyPhaSCpC09BeSwyr4KP6AQwl6mk6+gMfwYwb52GHUML/ZRxeOohWhNDurNvcp oxQh2AI7BclO3mJbf/p5FUPXDkXk5aKXlJZXl8QaTSMCjlx9Ff6Os34tJcAlroQzCCGY f9P3NZqDECpYJHqtxAxEseK3GV/z5OfDu7mRqNYr7P1VylNMSkSupxOVY9xx9gYQ4FkC Y3gpMLnSa32lXuM46wAol7naiMbFZamF2noVSb3ijcLlFniCIXIMm4Mbda7zdKIyaIDH ZeL8whW7KU96li9k8ZmjiVxz/BHb+GSB0LryFIOHwiPBm5QKk22eyQfP6sLWTBISCuWR dU3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=QNDnFCwP; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht8-20020a170907608800b0072b6290f476si330140ejc.842.2022.09.01.16.17.29; Thu, 01 Sep 2022 16:17:57 -0700 (PDT) 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=@walle.cc header.s=mail2022082101 header.b=QNDnFCwP; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235329AbiIAWWY (ORCPT + 99 others); Thu, 1 Sep 2022 18:22:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235033AbiIAWVL (ORCPT ); Thu, 1 Sep 2022 18:21:11 -0400 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE68DA2600; Thu, 1 Sep 2022 15:19:20 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 866DC21EE; Fri, 2 Sep 2022 00:19:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1662070752; 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=c5Tm5NgUjgsDKZgk1Ba857CClebez+/VRvwjllvM7EA=; b=QNDnFCwPPEMrDdiAIZjnc2qr2trT/+wfriMAeCUHW8mtz+WDlqDTeANWBO5gS1DNDamyve Tp5PzhSInvwBAkzYfDxM5PFGHVSl/bf/5TkQpiy6w2YZsI1qflDNntb8pCRFNw1IE6A8yE sPHs7j77+ii7LMYbjX8bs2sSA/W98qdJ8o2gDqoQlglj2kdIsZnPDYICFeyXo98Yy0zR31 cNGc4SChoh1TGv8urKq891kNEjdcQ4ToUHFXbNkv+4O1vIVPOrSOfj3cE1uPFBO28p+f0f y02dgjpM1Qc74ll54vCguJEHlx0Htq1ryuPWzebjdyjTY1hHwUZEn1bh9Eeuow== From: Michael Walle To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Shawn Guo , Li Yang , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Frank Rowand Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ahmad Fatoum , Philipp Zabel , Michael Walle Subject: [PATCH v2 10/20] nvmem: core: allow to modify a cell before adding it Date: Fri, 2 Sep 2022 00:18:47 +0200 Message-Id: <20220901221857.2600340-11-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220901221857.2600340-1-michael@walle.cc> References: <20220901221857.2600340-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam: Yes X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org Provide a way to modify a cell before it will get added. This is useful to attach a custom post processing hook via a layout. Signed-off-by: Michael Walle --- changes since v1: - new patch drivers/nvmem/core.c | 4 ++++ include/linux/nvmem-provider.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 02d0a7099d9a..3b65512762b9 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -693,6 +693,7 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem) static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) { + struct nvmem_layout *layout = nvmem->layout; struct device *dev = &nvmem->dev; struct nvmem_cell_entry *cell; struct device_node *child; @@ -729,6 +730,9 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) info.np = of_node_get(child); + if (layout && layout->fixup_cell_info) + layout->fixup_cell_info(nvmem, layout, &info); + ret = nvmem_add_one_cell(nvmem, &info); kfree(info.name); if (ret) { diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index cb488b338d6f..9cb340764b89 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -157,6 +157,8 @@ struct nvmem_cell_table { * @add_cells: Will be called if a nvmem device is found which * has this layout. The function will add layout * specific cells with nvmem_add_one_cell(). + * @fixup_cell_info: Will be called before a cell is added. Can be + * used to modify the nvmem_cell_info. * @owner: Pointer to struct module. * @node: List node. * @@ -170,6 +172,9 @@ struct nvmem_layout { const struct of_device_id *of_match_table; int (*add_cells)(struct device *dev, struct nvmem_device *nvmem, struct nvmem_layout *layout); + void (*fixup_cell_info)(struct nvmem_device *nvmem, + struct nvmem_layout *layout, + struct nvmem_cell_info *cell); /* private */ struct module *owner; -- 2.30.2