From patchwork Tue Mar 7 16:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 65732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2543424wrd; Tue, 7 Mar 2023 09:03:02 -0800 (PST) X-Google-Smtp-Source: AK7set+SxxsGw/4NDHfOduZ97EsHoOm+AfnI3pHx5XsftOI+f/X7635sMBQ6Dh8WDU5dQFrdxYZF X-Received: by 2002:a17:906:730d:b0:8b1:3193:4874 with SMTP id di13-20020a170906730d00b008b131934874mr19206087ejc.46.1678208582688; Tue, 07 Mar 2023 09:03:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678208582; cv=none; d=google.com; s=arc-20160816; b=qnT/XBQGcTqdkU0j6fnWApGL8RFNBqUoADPxVi6qHCyoX3nyJIB8FRQR4fltD/ty8E f7hpgIwZLXHccqwsPUksYHsVRAsWyhFwudgYslUYvCnCqzX0VqMflgw4TwwxAV6lRPIT iXs/ppGSb10212YW1twFHr8yAodyWDV2ArX14KQRbC66HPvcfLBu48qRIndUTpKuCcQj v2JtHnN7uluakpoR5ZLDdvlH9UP7Hx1aeIcA1kIu0cQoXmhxPQ811UtQIosfxfrtZGHq Ela3zgkqMsH6relhavQwd9Ds/7wubv3O+5oAtdcsFQ7rb2vp6WvKYTsV04aRT6iCzVyi WrGg== 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=6hNxCYBR5yzRDGBSbfvJ7idoAKl7NjU5wAcCzaXPD2w=; b=L4U5beK9iA6TopXbw5Cr1KFm7B9TOvLPjubUrQA7nzDHc4x1ImTiLOKE24C3/lPRYW KakZUzXY5s4WojuiGdJ4vXectsmKHjecvyq/z5oD7JTdZZvt78Xz1cScVHwMI2Ki/QLE bC/FVpaq9fqUDQmYBLmY63qCKhNyCxpGrH4RDfkZBkehn1+9VPAVszFXexJiNUNmm/9n Tvw0qxoUoKNJVBbAN1FIpBJkE768xMGoCnV8VouW5Z4bFPNZx6YzS+AHUeIyxHHev1bd ZpWSHwdqM/ySbBVVqi+qxnSBrnIHAf4M/5G5w3X4RpgrXpbFulS1Jc5ifnUy5gku0v/F 7njA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SXd0K+s7; 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 e18-20020a170906c01200b008d4ddc88221si4304861ejz.510.2023.03.07.09.02.38; Tue, 07 Mar 2023 09:03:02 -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=SXd0K+s7; 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 S231434AbjCGRAC (ORCPT + 99 others); Tue, 7 Mar 2023 12:00:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbjCGQ6M (ORCPT ); Tue, 7 Mar 2023 11:58:12 -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 AE6C959E0; Tue, 7 Mar 2023 08:54:54 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 49391C0007; Tue, 7 Mar 2023 16:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678208093; 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=6hNxCYBR5yzRDGBSbfvJ7idoAKl7NjU5wAcCzaXPD2w=; b=SXd0K+s7oI2QByaA7bb9vJpRXYpl2uydhFjRxV+TmG/Ic38saSyLyA/G8YCRyzs8L8Scek NjRlMTPTf/IeLkL8n6psTRSeR3QNrdWCNXb+pnZZCwY2p2+Yg5BwXvp2Qgpd/l8vD/9sLi 0w/QBkDSAcR6oXrTrdNiIiCpifkfphn8Slu9GCN02HvqIdRIQuT3YGMadwJ+yUvbZAs33I HCdP9bsnuXnxkhcx+N4RaT3Qna0xFb+aa1mckogyeUpMK7XLILmTfkj49OHELeXQP3BbqW /u99Ugi5LgvVeXLtI/l0il/lGuBeYuJ3Wr7bSoBTKQkr2uz76FIqTf0WBLtMvA== From: Miquel Raynal To: Srinivas Kandagatla , Cc: Greg Kroah-Hartman , Michael Walle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Robert Marko , Luka Perkov , Thomas Petazzoni , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Miquel Raynal Subject: [PATCH v2 14/21] nvmem: core: allow to modify a cell before adding it Date: Tue, 7 Mar 2023 17:53:52 +0100 Message-Id: <20230307165359.225361-15-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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759729243235672754?= X-GMAIL-MSGID: =?utf-8?q?1759729243235672754?= From: Michael Walle 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 Signed-off-by: Miquel Raynal --- 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 664d48f0dfa7..82e11b9576ad 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -695,6 +695,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 device_node *child; const __be32 *addr; @@ -724,6 +725,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 3bfc23553a9e..be81cc88eabc 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -155,6 +155,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. * @@ -168,6 +170,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;