Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp985497rwb; Fri, 18 Nov 2022 10:55:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5AArexx5n6nK2d+IaymG1EARgHgotogO/O/8cT6VGqAKUPg0BJ5fN6z4BxensAaHBSDl1x X-Received: by 2002:a17:906:ca18:b0:781:c97c:84d1 with SMTP id jt24-20020a170906ca1800b00781c97c84d1mr6977449ejb.147.1668797757978; Fri, 18 Nov 2022 10:55:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668797757; cv=none; d=google.com; s=arc-20160816; b=nWVxPNxNDYCZ7uKdQRdfJFBCbga4O+NfzqDYVbigGgXk/7lNzsHZBBtIRl+JnL865E sgNFzEJw28S4dpPHo6ZU+AKRVHNuOW6Yht3cIOtlVtV6MNmC4Bo8aATRBhR+f6jbLA50 Mvs9HTebzTkix1ARdwhA5FgczKUjCjwex9+CUB0TmjqQwnD7tRtQkSoeN5ec/+9c42rb pet/0xkJM9E7SzkDo58Kq1BeM82Huq5kcPcSUenB+kOQ74CmMPglcbi1fSIwCAb0473M Au8DN/0XMIH+K2KegxzRZzK+M1B3s1SbCQ/XIQh9A8cKh1yeklRlEItOIcX7R7CwUgNt Ae/Q== 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=OG+BVTzaBMIaLV8CZzAesSGp8DMidyfnS2AwgUumpzc=; b=D6QpmkqM5Efcz+ULxDGsFIdK7V8cf5JYmbE615kovjE+HpGnRf0bQv6y1eW0W+GNV3 TLrZ0YlhEzSqm2LN3kWkU9AkkyQoXsgbHYy4sifCXzCsdAZXBwIW6st3zo8bXmXXyTtb uj1Qh9sjxDSc0PPT88J+C+W5VvYz+WtimBdxVGMed1LUqKtmHY4feSgs/2O+IealUMi+ GMweyoNlCEprJWABMBJLiBSRSP2oSeOI5HR5cg04FvtBpv7H2P/v8AqEdUpkfAIlhF7F u+og4lvtnZZj2zlIh5TZN1uogPvXdpYYZ2hGEPmYNHdd8A0BtRRaw/tWw4jiTLUfKnX4 I/JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=wLLRoBWV; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc30-20020a1709078a1e00b0078dffe01cbesi3475897ejc.4.2022.11.18.10.55.35; Fri, 18 Nov 2022 10:55:57 -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=wLLRoBWV; 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 S242922AbiKRSw7 (ORCPT + 90 others); Fri, 18 Nov 2022 13:52:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242881AbiKRSv5 (ORCPT ); Fri, 18 Nov 2022 13:51:57 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C0518FF9E; Fri, 18 Nov 2022 10:51:56 -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 8B219276A; Fri, 18 Nov 2022 19:51:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1668797491; 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=OG+BVTzaBMIaLV8CZzAesSGp8DMidyfnS2AwgUumpzc=; b=wLLRoBWV22ibu36eSl8Pmzp0vTUmUSidcSKUeTZrmB1jxB1CoLZi3tlc9uFHZTneaAKeg+ jbIpOoOa3jNxmRHwpqxAdNWTeZXfkXfS4USCkumVgjf/fpLlPeeSEytuEPG0aRDViJh/Hr 9uTw3RSyPxh16PoR57nFP5sD/xzohfQoRsQ1AqnWIrFwDZmsxUVTNUDPxH8aW+nbPoHuNf ZpSv+AGhp5F6M8V8IMfCDH3A0gnen7ajIgt0T1ivfC7NellWHFH3GZZLPo92MvWDC/qoPI COKZ5+QpkK8ZOXzfS2Z8Mr0iNLcBiok2mkhnl3pBTN1UgYhlgySC66QCKZvhIg== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand 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 v3 14/18] nvmem: core: provide own priv pointer in post process callback Date: Fri, 18 Nov 2022 19:51:14 +0100 Message-Id: <20221118185118.1190044-15-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221118185118.1190044-1-michael@walle.cc> References: <20221118185118.1190044-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 It doesn't make any more sense to have a opaque pointer set up by the nvmem device. Usually, the layout isn't associated with a particular nvmem device. Instead, let the caller who set the post process callback provide the priv pointer. Signed-off-by: Michael Walle --- changes since v2: - don't drop the pointer but let the user specify an opaque pointer changes since v1: - new patch drivers/nvmem/core.c | 4 +++- include/linux/nvmem-provider.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 9234c7d87a69..e03976f6ad1c 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -53,6 +53,7 @@ struct nvmem_cell_entry { int bit_offset; int nbits; nvmem_cell_post_process_t read_post_process; + void *priv; struct device_node *np; struct nvmem_device *nvmem; struct list_head node; @@ -470,6 +471,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem, cell->bytes = info->bytes; cell->name = info->name; cell->read_post_process = info->read_post_process; + cell->priv = info->priv; cell->bit_offset = info->bit_offset; cell->nbits = info->nbits; @@ -1558,7 +1560,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem, nvmem_shift_read_buffer_in_place(cell, buf); if (cell->read_post_process) { - rc = cell->read_post_process(nvmem->priv, id, index, + rc = cell->read_post_process(cell->priv, id, index, cell->offset, buf, cell->bytes); if (rc) return rc; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 12833fe4eb4d..cb0814f2ddae 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -20,7 +20,8 @@ typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset, void *val, size_t bytes); /* used for vendor specific post processing of cell data */ typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int index, - unsigned int offset, void *buf, size_t bytes); + unsigned int offset, void *buf, + size_t bytes); enum nvmem_type { NVMEM_TYPE_UNKNOWN = 0, @@ -56,6 +57,7 @@ struct nvmem_keepout { * @np: Optional device_node pointer. * @read_post_process: Callback for optional post processing of cell data * on reads. + * @priv: Opaque data passed to the read_post_process hook. */ struct nvmem_cell_info { const char *name; @@ -65,6 +67,7 @@ struct nvmem_cell_info { unsigned int nbits; struct device_node *np; nvmem_cell_post_process_t read_post_process; + void *priv; }; /** -- 2.30.2