From patchwork Wed Nov 23 18:01:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 13054098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2EFDC4332F for ; Wed, 23 Nov 2022 18:28:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7w5UV9b+sAq4DHv3QHtumtEGboyE3lqCaBTpvup8PXU=; b=qsbpVV8gHG4xH9 BgBSs2hDhfyN6ZU6BQSiKorlqnuS8e6eY3iZSidSmsnD/3bPOpuTl1e2c1ZbSRtjnkVl+xK7ah169 BaAw0F1fdU9nN7YdCB03AYn6MlgMgGhdXb1eY1InQXVT1YIeY26SyEJyzYNOaR9HsXoKDi7GEMgsW /AAIFoDwvLr2blNbZXjPT5y29KUen1wJnj4FEAUu1Em14tJelx3wOwwcBj39bWp9EWzoCVIswFfP3 XiBgzh0uRRNjWwr8nhUXsMp9Qz0V+N73DIhRue7lsQxNcPqyqCn6NPVQz8SGyGOqx6wMlriIktYl4 E45vo5g5Pbx/veNxWGvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxuSU-001bHh-Fs; Wed, 23 Nov 2022 18:26:54 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxuS6-001b6j-7K for linux-arm-kernel@bombadil.infradead.org; Wed, 23 Nov 2022 18:26:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FGdZLi8Kaekagprvtmjt1fkHx30M/b/xsvMTa000JA0=; b=Z/y0AKVjYNlnnBF0yTyDF7okUq dclZZ62hKADNTvThO4sw9B/DIYgqaW74/YHQq1rnh3+SvlLylgbBxEivivkEq8IgczAt+YCbn2Qz3 nH1kg0N4Jx24IUCiL3beqKsIBlqwcZSPk+2XSGZ5jjFXLiCR4nD4e+BTM7aoJh6IBTN8xMUUI8JXB ef0H9HdzUyDrbWWHF33znT9WPp8zLonKpEcueIcsDauqdYP7LESc50BGqNA1PRpeGq96750pDoM3d UJj37cljhbfkow4luybNMHvOazuScMnkQOnq/g4vppossrOZHu2WSZzMzsK/WInYjx0+aEG2m9q7L jDlj08fA==; Received: from 0001.3ffe.de ([159.69.201.130] helo=mail.3ffe.de) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxu4t-003sQY-Cq for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 18:02:36 +0000 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 39A373B37; Wed, 23 Nov 2022 19:02:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226544; 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=FGdZLi8Kaekagprvtmjt1fkHx30M/b/xsvMTa000JA0=; b=to6F88I7laehj/GAVEm1nFLFl+6bEbL7zo0aV8deuodaX9dYLOe4+ZvrJN2bn3kxaNhxM6 Kl8/R6oZ80LnJ3UXIo+JpLWdgJlNt6Sv/LPbhAT/IyDSi4VOfKvvZebrWg5SI/fD+y3N4b HWIYepJ+tJ8zEdHTyYlu44Xdwukz93ADIj85MHfWDNOKg0GfURP/qAgkgUE2UHv2QPuPDW GZ462oSpw2A95r8dFqzfBrNyla8iY0RsPqf4j07261N1z5hPVM02QhAvVWytZziPpKixQ3 Wd2HyxU5giNltKUbVqeTcxFLCqbJHLvRl4AEcin7Aw48Ytipno0HaEqWFjO7AQ== 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 Subject: [PATCH v4 13/20] nvmem: core: allow to modify a cell before adding it Date: Wed, 23 Nov 2022 19:01:44 +0100 Message-Id: <20221123180151.2160033-14-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 X-Spam: Yes X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_180231_886328_3829BCC9 X-CRM114-Status: GOOD ( 15.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 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 e75642a675ae..ccbde9629f7f 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 nvmem_cell_entry *cell; struct device_node *child; @@ -730,6 +731,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;