From patchwork Wed Mar 8 15:31:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 66308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp406026wrd; Wed, 8 Mar 2023 07:39:34 -0800 (PST) X-Google-Smtp-Source: AK7set+LxxAR6Qnfu4VroodaE8r49zH/Haxjq7H2VUu6garjiK5dKV57bMRM5X20zyWWJRkNrjT6 X-Received: by 2002:a05:6a20:7aa7:b0:c7:6232:c6e2 with SMTP id u39-20020a056a207aa700b000c76232c6e2mr14777444pzh.48.1678289973748; Wed, 08 Mar 2023 07:39:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678289973; cv=none; d=google.com; s=arc-20160816; b=VDqEcAdufKKfIIyWRgDloh0j42NlNSG6z/9i9UZGVatRf4dIne8xPAoSY97tTIxXF5 DrA9sW61zeOP8MPKDQR94pzMnh78A+gA40X8Ob01UnjQQS/ke0fvxdIboN6lVtt4ha0B 0Hrn/L5RGbrdKE4O5gcSp6saw3A/mJXLha7HeI1nkqk4YL2LT0RUHUFj+XTWm7D5dA4A asMXtac3nApMZ8GS1mcsg79AJB66eLm1SNmRdP8lvsX60wPORwiDc6J8s63uzITCnLiF V6+wMPTgleOQer5db4K0EB2dyFTtG2ztjf6C7J7Q+3lXA2d0K3m4cg83DVgPihhgfv7T 3wNA== 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=uNiNDyX4GaTfMI2x7EDRmsWPXsDEC+d6+Vzjx+rSfbg=; b=CLvmZqAUEhGamHCGUs7r89101rFwOa0objNDTN/iuFWbKG34NK+s36W0U6wvxm0PyH Df+eZsMP0ROQehFODQMVmxn67UB0m4l3RmkJ+i/lnYnqPH0DnhnfEAxzwFilqfUg9jnp HIpkLXgtJHgS9f8t96bN3pr2G4lQhaIyxSsmaI/BFUdDJRH3DwDAvJnLFU4BQhJBsKCg F8FkSAdHjL+f1OvJG2ohdMkbMO5XJURMCNLRLXKtSa3jTwAm11AIfuwTEUyeB4rooMEZ nSkb2TWV8IprEjlkGC5K6AwINOLydPMKMXxWKUbqqHAK45gbnIrGdTOzGiidBGQh8GM2 C+CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fiU+R4qS; 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 3-20020a631143000000b004fbcff506c5si13892911pgr.346.2023.03.08.07.39.20; Wed, 08 Mar 2023 07:39:33 -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=fiU+R4qS; 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 S232280AbjCHPdg (ORCPT + 99 others); Wed, 8 Mar 2023 10:33:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232212AbjCHPcz (ORCPT ); Wed, 8 Mar 2023 10:32:55 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 778565D244; Wed, 8 Mar 2023 07:32:28 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id C6BC8FF803; Wed, 8 Mar 2023 15:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678289546; 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=uNiNDyX4GaTfMI2x7EDRmsWPXsDEC+d6+Vzjx+rSfbg=; b=fiU+R4qSe+SYgKPHztNLUiJNcwUUQ5sdflk1BjJ7XPE29xJaYqT1YMFMFE2cw1z6rItJb1 GY1vdXQFqunKASh5EUWj65djg7+XT4YOTkmaIEwWGuyhG55j7wmkRT3C+tHvR2domAOWxj rlCe27eemstW4iQclClYvJ0EfhDItfo3Q04vOZU38SkEN1TcUB5d/tsC7HSGC/NOu+ufwi /bQL3niecPNsgKbJBBX2XssKgWi951Vo5a+uf3XnnBtfck222Gk8W6NQY5ZBJxpQ8KNq4C XApxhwtgk6RDwgjbautO2ckDlowPP5Ap9o6vLDadxVbNNNrKy9DCpxcvzBvh2w== 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 v3 13/20] nvmem: core: allow to modify a cell before adding it Date: Wed, 8 Mar 2023 16:31:53 +0100 Message-Id: <20230308153200.682248-14-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308153200.682248-1-miquel.raynal@bootlin.com> References: <20230308153200.682248-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, RCVD_IN_MSPIKE_H2,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?1759814587290200882?= X-GMAIL-MSGID: =?utf-8?q?1759814587290200882?= 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 0708f9f27898..f43025ad315b 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;