From patchwork Tue Dec 6 20:07:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 30498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3027304wrr; Tue, 6 Dec 2022 12:10:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4aKmCqBwt+HW4KefIpXN7Nidx5C9hZqPdOFqOjCyIYz27rYtS+KPHyvRRYT5iYROyEnw/V X-Received: by 2002:a63:5511:0:b0:477:ce06:6c94 with SMTP id j17-20020a635511000000b00477ce066c94mr53957145pgb.138.1670357404886; Tue, 06 Dec 2022 12:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670357404; cv=none; d=google.com; s=arc-20160816; b=vhGFWDuO5aX/T29Iy63Gh1pQGgxE8niK1YK6XWCL97Rnjberv9iss7gv5xH6nW2hPq T8gBH6n4iDgiEtDhAeixCw6ot+WKmPfjB+sO9wMx9xv8tlIeSyrfXre+9JgDjGD8ezfU Afc4ww441+PQF1XH1t98UzeW0Tq5BtTFcoYu8wVLyAR6X1/o+cuCKzlfTC49exyMc/xO +zrMQoBQdG0EpHgLTe9vaWPidi5hQpWCLUYhozJesYfMDxuA2ouIU15rt98g6q56eqiW mwj4gGgn0tAfkyY0Nze+wONdHgeZxbgT4VyTvLtkGufIiJOzrp4iaPrVFrzbGBM2haeE hblQ== 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=FIvGlxXDqA7PdqR3w+bWH+qxGv8mVWV/x4LMDhqSiY0=; b=c0gB5exttl5dcAL14M6QEo+kCOVc+7ksAQaWqKqBJKUwkTnvjo9OiITQRnQ87srcpd 21uDFriJMsiJ142gZYlX+DlriL9A8A4ufAygGaPluW93bCH7UAtU2vhef1UP67pHr88V YLLGGBWdUDiQjX++12N27G4jNHOvgQZ7CLzjM9FBvZJEPDSQBlGArmTj54X90b0HnYny MF+OzqGztj7k+mH0KhsT9HYM/vcg00SsUGTV/Igr4w2T8REVdfcifIdi7HJmjOCuVKZY xjGSoud9AdXMj8i8C3OUybwUBg5YAjm6vMzQKuFtQqaZAWEqGOIglSbAfY/tpn6I+JFQ k2qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=rBi9EfJa; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a056a00170d00b0056bb0103ea4si19393604pfc.246.2022.12.06.12.09.52; Tue, 06 Dec 2022 12:10:04 -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=@walle.cc header.s=mail2022082101 header.b=rBi9EfJa; 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 S229702AbiLFUIq (ORCPT + 99 others); Tue, 6 Dec 2022 15:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbiLFUHz (ORCPT ); Tue, 6 Dec 2022 15:07:55 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A632ED49; Tue, 6 Dec 2022 12:07:54 -0800 (PST) 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 845943BA3; Tue, 6 Dec 2022 21:07:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1670357272; 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=FIvGlxXDqA7PdqR3w+bWH+qxGv8mVWV/x4LMDhqSiY0=; b=rBi9EfJaMdyOqQUMqPOWwci7D4uff7jojS2lmOnAJkn8bevd5D7mCEtthb9PQuqY3ddgRl wkjzEVI507MuSILbV/+SuzFupdSPRIjSbxOMCyAt2QVGdFquzhhv/X5KnCUhsCKfZmPU+v e6JJ8+UijsfJqi9c4sLkp3qaHFrl3SQ6qhIXDK7UCtLyU8TlLMS8pOmS80vQolkxuNxbUb l7DqCbQgZZCnyOIXolqqhlROkzgQAEJeZcqLDIwMgtzH/QPMZfdrPpREXoPuy3+34y3dEW fUO7WTPA5yOAdzb+5/y6jmvim3lQc6wzOmqONK/TNjLlj3mT3cEzan1/Op6mpQ== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle , Dan Carpenter Subject: [PATCH v5 14/21] nvmem: core: allow to modify a cell before adding it Date: Tue, 6 Dec 2022 21:07:33 +0100 Message-Id: <20221206200740.3567551-15-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221206200740.3567551-1-michael@walle.cc> References: <20221206200740.3567551-1-michael@walle.cc> MIME-Version: 1.0 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 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?1751496686109482729?= X-GMAIL-MSGID: =?utf-8?q?1751496686109482729?= 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 v4: - none changes since v3: - none changes since v2: - none 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 5afd4818cb34..2706fc5ed494 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -694,6 +694,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; @@ -723,6 +724,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 1930496d8854..bfaba5227ac9 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;