From patchwork Tue Dec 6 20:07:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 30494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3027177wrr; Tue, 6 Dec 2022 12:09:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf51Ksr2kqkm67Efjv9FLyu1xIA+dOov6Cm6cwVshw2QDPObOPntgoksNYUvRqh6pnHZMgon X-Received: by 2002:aa7:860f:0:b0:574:a8a7:22d with SMTP id p15-20020aa7860f000000b00574a8a7022dmr56904155pfn.78.1670357388501; Tue, 06 Dec 2022 12:09:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670357388; cv=none; d=google.com; s=arc-20160816; b=KhFs74Xlijksfrzotrb27bkZWrvee0dBEcOC2hnk9VnhOCwvqsBoP7yhK59gRQePON EiBgp+dij1i9GnjT1DPfD7aCll7r3gJud3VH0sBRU4yT6FA7LIqgOkrJWwTT4nm+eQRE 8jfLO4RBWId77hdm6PH5cuNycUEmHeAb6FwY6pI1YwvLomC4e06krbyHjX6mBZMKvPiL vpT3Gmc7tJ7b2SGESSdDBsfOjvmoRxzVDJDr8lehbxX7umAsT7qa36o+OUax1XWrD6nf qzuKAqOZIvM2XtCxdMI2B+ABiBihPCMqJbBFpzM8hACMJ6RrhSRj4Yh7S/IgzUsKhGOA feQQ== 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=J7SJGsn5PwH3KKasmpxguMiSfB3p2ys1JrTJjwXri5Y=; b=PB5huaM23UVnAsC7Z6iw7YxQyDcSeZ+LwO7Hjlaj+Yh3B1DPdM8pecsqJYszcU0uNd nqwMfERAOCnFQOl+TSyQ2A7DLUuH5vLvy9x6U+wu95v+IHgyZu1RN0BvUG74mE4Lplj3 0NAQtc4WgyfYjMZSYV6w6L+VTatGjERisx0kPIFdO19l1mvN7R3fZLz8xSJGNFXCGUZ0 7JCZEzSTb5+n7DZ6sj+TE4kfcjtBjlS9oaEbIx0Cuz9+PInmuMNIYAlzVZvmJJaEGpA7 wU0VMr/JwH4R4Y1UfVCVq6S2xg13PaHEq35ChBr8FEldTDMzhxPfTxztrdUU3y8xQVc5 uwRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=iIGAW8B5; 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 e20-20020a63e014000000b0046fd05d55e0si18127666pgh.567.2022.12.06.12.09.34; Tue, 06 Dec 2022 12:09:48 -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=iIGAW8B5; 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 S229822AbiLFUJD (ORCPT + 99 others); Tue, 6 Dec 2022 15:09:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiLFUH6 (ORCPT ); Tue, 6 Dec 2022 15:07:58 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74EF32FC35; Tue, 6 Dec 2022 12:07: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 5AB6A3BC6; Tue, 6 Dec 2022 21:07:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1670357273; 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=J7SJGsn5PwH3KKasmpxguMiSfB3p2ys1JrTJjwXri5Y=; b=iIGAW8B5O8Xb9pGmDJvfgfkva2BrZ6Fp5OymfEALdVxrOaKft7BeV+3lTMHcsIKd3mZ+/S mXqyuCbRrosZLA6DPHunlK0GMh44qzeYTyk/xkZxCSCQTwh7hQj1mHkqxbihfONU1lE86n kk3zrdADUSxLLLESb0ngvS3U4TcANNTxreJbbxw0r2LYZumsK/6uYlOhCZ6nndaGR8Zj0N aTQqhaYG9IdTMUo5VUq7Xr4pOVlpVmxW/Yyy9BOrvzgsjHilceA2EMSeF8+qoTMOV1hc+S /BzweQ9D+CdVkhLTe+wDZY3WDmxAK6gnNbXYC4Bla+p5CenO9AjEcTPBIlTavg== 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 , Dan Carpenter Subject: [PATCH v5 17/21] nvmem: core: provide own priv pointer in post process callback Date: Tue, 6 Dec 2022 21:07:36 +0100 Message-Id: <20221206200740.3567551-18-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221206200740.3567551-1-michael@walle.cc> References: <20221206200740.3567551-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?1751496669270150632?= X-GMAIL-MSGID: =?utf-8?q?1751496669270150632?= 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 v4: - none changes since v3: - none 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 dc329daaa350..2282dc80aa0b 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; @@ -1554,7 +1556,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; }; /**