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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48A70C61DA4 for ; Mon, 6 Feb 2023 10:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229964AbjBFK3f (ORCPT ); Mon, 6 Feb 2023 05:29:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbjBFK3G (ORCPT ); Mon, 6 Feb 2023 05:29:06 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F7FD1E9DF for ; Mon, 6 Feb 2023 02:28:40 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id f47-20020a05600c492f00b003dc584a7b7eso10380998wmp.3 for ; Mon, 06 Feb 2023 02:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2qJxrwfcLTXBaQBmmE6as0L4veHi/uh8tjNkkwxbsmQ=; b=aR0xlvy16wCdmaX9IDKoHB3K6u8mRttydDPEvNifYdPYbp1aW4vBYC13gz3okywIaJ NlerD07kTv7d5qaBlgfbkK9aNbsZnQ9zv4Pt3Y750V/55olJmDTjJP2OdQ4A2V5P0G3k BH97Gxpf4Wa+QOqOXTFIowhVIS5SagErhljt0LaCSh8/040DnyIRYDuKxBkqx8AbAcit tbN5EDuWNK54OlhTSuez2VKY1tsbr2o+UHMPRNJSxE3lxJ2/9WwvpvMTsCQBMuGBbQpr No65Ff258wWrHMHP7Docix22A5x+g7J6hVndF/rxkzUETITliSyVB7+qf6F1RozD5idV eZQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2qJxrwfcLTXBaQBmmE6as0L4veHi/uh8tjNkkwxbsmQ=; b=YVO9UTdffCb9R9z4n5JtU8t4q+dnH4joDYeafCblakasoCpZ4CCJcqSU6pm58hipqk 48SptRaAOZqeZFM9zuK9lpn3Dk0l8x6GykuqtiBxNCIGOYEaiGRqMJct6JZ67uk9PaiB kLzi3j1wCdth3H5+ZkBKm7ZAy1Mx7vqDaLAacUwuR3NrUbC7Qvozd883jayudesWyCvm 1NWghElAXsNgZ5B+aWIJzHMs5HIpfj08yxwBuidX0x390GB/5vFxIVjGX2FUX34RlxCO 7mQas5eWC+ppRLo2BYnwheORqJpLzE38nlXJ3FCy+mIu5tctxdOqH7Zr/wW8h3ZclpO+ RlLg== X-Gm-Message-State: AO0yUKUYbbjo9YV/JO8E/eUooTgB0y44wwxiN7CsWHqAG0UVtWhiintd wMI904uNpBMf25xmfI+OCtOGd7Q9b3fJIdmH X-Google-Smtp-Source: AK7set+QE6jjpdmllesbr+iJgpJFTFYZzDxuaNILkuZXMzJURk5i0qqYdtYEYDHaK73X0oGG4v8ATg== X-Received: by 2002:a05:600c:3caa:b0:3da:270b:ba6b with SMTP id bg42-20020a05600c3caa00b003da270bba6bmr20018547wmb.41.1675679319038; Mon, 06 Feb 2023 02:28:39 -0800 (PST) Received: from localhost.localdomain ([5.133.47.210]) by smtp.gmail.com with ESMTPSA id g10-20020a05600c310a00b003de77597f16sm11002446wmo.21.2023.02.06.02.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Feb 2023 02:28:38 -0800 (PST) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Michael Walle , Srinivas Kandagatla Subject: [RESEND PATCH 20/37] nvmem: imx-ocotp: replace global post processing with layouts Date: Mon, 6 Feb 2023 10:27:42 +0000 Message-Id: <20230206102759.669838-21-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230206102759.669838-1-srinivas.kandagatla@linaro.org> References: <20230206102759.669838-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Walle 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 Signed-off-by: Srinivas Kandagatla --- 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); -- 2.25.1