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: 25121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942478wrr; Wed, 23 Nov 2022 10:05:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf51N4XF68rn3jeDMbhjmOhgw+URmLAV8z9C1R8OqIUOyWYUnwVS5yxpCXheEfx9vI5XKS4c X-Received: by 2002:aa7:c6da:0:b0:469:172:1f38 with SMTP id b26-20020aa7c6da000000b0046901721f38mr24319314eds.195.1669226752677; Wed, 23 Nov 2022 10:05:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226752; cv=none; d=google.com; s=arc-20160816; b=jXqnA8IxiIe+bj9L391sMRRaeXnuXNocOm1sHO0PbYaU2zYLiiRIvztDA9X8E4Q96f gUps+DpMXImvQiEEpCW2domQv77B32O8IKPUvgdgSoSUPhscRdB85AqDJ+NUGlNwfuYi ptOpzIslItaTehljlnpnuHDlx3zAEtgETkLvSteExXz1SY2beodtOnbiyZJGGZiBYlk/ WsvyGXNUosRNGgiWe3FQ3T0UH+4lQcIXE5Y8bzM9HCLEZLNKti+YqOlK/IbBFmAjoizQ vyj6g0tMVZC7nwO0ivZPiocbaY0RZ+RiUsQjuxctlA8vanPmMTBSSydbDxPtXkMHXIog awhw== 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=FGdZLi8Kaekagprvtmjt1fkHx30M/b/xsvMTa000JA0=; b=E6b8+HQ6oacR4TRgM8uCJW60ChLtkOS/EZ4eYYS+SOijITAKXwyxw+Kq2NvtLnJWE5 QMvnOrtdx+OzmGEgY+wrkXW5jsm9cXLNmFYbmdjYT4a73g4pBGmRnYDtqPxi82Yx26H6 43Pxyamw8mWGOyvzmcECzNmltpexuU9rKcLDsBhdI8nEGKyVVsQF1qrdJCnEavxSIymp JrIkZnZvHnN2j7EpJHiHprYyoeKZ1H4ybuelYCrJamH6uxJmiLfoZdSSN9yIwj31LeoK N9mX1PkMvhcNh5NfJrA7D+bEGLswABPwLE4eq1+SUt9d2Dnf9MH31Z9WbmhY1j77ePqQ sMUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=to6F88I7; 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 sg42-20020a170907a42a00b007ade82b9e73si243529ejc.757.2022.11.23.10.05.17; Wed, 23 Nov 2022 10:05:52 -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=to6F88I7; 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 S239485AbiKWSE1 (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239418AbiKWSCa (ORCPT ); Wed, 23 Nov 2022 13:02:30 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14810B9C; Wed, 23 Nov 2022 10:02:26 -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 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-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?1750311111246857799?= X-GMAIL-MSGID: =?utf-8?q?1750311111246857799?= 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;