From patchwork Wed Nov 23 18:01:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 25119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942380wrr; Wed, 23 Nov 2022 10:05:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6sKYCGHmYF0B/Zx0hLCGuG+1/HEzr49M3UGNxy1dtjzb3aY5x8yXiw4LzN4EI4bosFFTer X-Received: by 2002:a17:906:480b:b0:78d:9f25:6103 with SMTP id w11-20020a170906480b00b0078d9f256103mr24920414ejq.168.1669226742996; Wed, 23 Nov 2022 10:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226742; cv=none; d=google.com; s=arc-20160816; b=l+EmbiWm+JEoI8/TzlBcnx2hLHoI+bk5wdU2cpnRLwI5f850hZd5cGZcc4tVigvI2Z 5vS6w5r/p+wegqKGfy8lLDIwuhdwvFyjJTXkyzW2Eud8lcDZ74JnWLrsmoQaSlfHGrYN pbnUjiAJ111nLjC+EfD1eqNGAwsxYsX75bxOVn8o7GntEUVbZG7E24te/95UP1obF8St k1VW+alxIe8+GwaJDwp4kvmTLEFAXq7azXaX2Yw4d8aXjqy9x4jqZqxfrZp2FtDFr4xs wH9ju+ya2M7SriBD8GYnlZxzqibtk/K6mLARnVWc8QZn7K0JUKu8uBSm3Du5t60Tp8Zl W2aw== 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=BPNHYJ7cdASLHAEjEX3cpHT6PEI/wCz5wvyevFbTiJM=; b=uq6TIuwwYasVa5XR4hM9QsJaW022W4rfFFabnzPsRpFWwyJNMNFaJByoLJUy6aQc45 6CEY8P9fSS0OFfQzvAFsYQGJU1RMFVf10yO6ABFH5el6etSs6sZz3pnGNTLadI9RaID5 OXCPdcMQQK170R5bAlizhLEtyDeDibYiC8hECOKaEuzTXYMn0oSH2/teVziwzOWBp5ch rnTA7i4hvjtTT3Ln4/vR5FICtqgNatEjpy1xRiUqO3KbrxyuzU4ZcTOHFcHXtCWwqRJ3 0FXc2yeDnSJvPnwiENoZXmwmdKJLKQoJokFbFU0nU/Q9mNSyIBSswbIz1LcSuixcswTi YPsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=w86O7N3O; 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 o20-20020a50fd94000000b0046a2b7d1d1esi453553edt.286.2022.11.23.10.05.12; Wed, 23 Nov 2022 10:05:42 -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=w86O7N3O; 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 S239525AbiKWSEY (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239416AbiKWSCa (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 146D5B85; 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 AE81A27BF; 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=BPNHYJ7cdASLHAEjEX3cpHT6PEI/wCz5wvyevFbTiJM=; b=w86O7N3OKtp8gWhowSQtXL8imOvtNFWH65d7LXHQkMQA8N+Lio0/i8k3YGeixS0gr59oUU tXX17iGKPUfrspytGuLqtk6KK4MWzq5iSjkL07jzHSHE0kSZmJg2xJCOe5rMZjjW1xY8Ds jdpSwNbRk+bSdioshV2RHL26JgkettVKKEQkTjBXCm6o/uoDuUWUc0S8ptQNArh/n4LvBr NtMaJOT2AuRQtQ2XSot9eaSIidHffSTlWSxWmnc+iRTEl3aSceRoUQZgUNO7CKoos7fzUX VaAfCK+yaSa0XxcxiQkm6wXimeKKUGGRtyZBzeJiXyVqlHMO5aAFWY8aaTMo5Q== 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 14/20] nvmem: imx-ocotp: replace global post processing with layouts Date: Wed, 23 Nov 2022 19:01:45 +0100 Message-Id: <20221123180151.2160033-15-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?1750311101079829157?= X-GMAIL-MSGID: =?utf-8?q?1750311101079829157?= In preparation of retiring the global post processing hook change this driver to use layouts. The layout will be supplied during registration and will be used to add the post processing hook to all added cells. Signed-off-by: Michael Walle Tested-by: Michael Walle # on kontron-pitx-imx8m --- changes since v3: - none changes since v2: - none changes since v1: - new patch drivers/nvmem/imx-ocotp.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index e9b52ecb3f72..ac0edb6398f1 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -225,18 +225,13 @@ static int imx_ocotp_read(void *context, unsigned int offset, static int imx_ocotp_cell_pp(void *context, const char *id, int index, unsigned int offset, void *data, size_t bytes) { - struct ocotp_priv *priv = context; + u8 *buf = data; + int i; /* Deal with some post processing of nvmem cell data */ - if (id && !strcmp(id, "mac-address")) { - if (priv->params->reverse_mac_address) { - u8 *buf = data; - int i; - - for (i = 0; i < bytes/2; i++) - swap(buf[i], buf[bytes - i - 1]); - } - } + if (id && !strcmp(id, "mac-address")) + for (i = 0; i < bytes / 2; i++) + swap(buf[i], buf[bytes - i - 1]); return 0; } @@ -488,7 +483,6 @@ static struct nvmem_config imx_ocotp_nvmem_config = { .stride = 1, .reg_read = imx_ocotp_read, .reg_write = imx_ocotp_write, - .cell_post_process = imx_ocotp_cell_pp, }; static const struct ocotp_params imx6q_params = { @@ -595,6 +589,17 @@ static const struct of_device_id imx_ocotp_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); +static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem, + struct nvmem_layout *layout, + struct nvmem_cell_info *cell) +{ + cell->read_post_process = imx_ocotp_cell_pp; +} + +struct nvmem_layout imx_ocotp_layout = { + .fixup_cell_info = imx_ocotp_fixup_cell_info, +}; + static int imx_ocotp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -619,6 +624,9 @@ static int imx_ocotp_probe(struct platform_device *pdev) imx_ocotp_nvmem_config.size = 4 * priv->params->nregs; imx_ocotp_nvmem_config.dev = dev; imx_ocotp_nvmem_config.priv = priv; + if (priv->params->reverse_mac_address) + imx_ocotp_nvmem_config.layout = &imx_ocotp_layout; + priv->config = &imx_ocotp_nvmem_config; clk_prepare_enable(priv->clk);