From patchwork Wed Mar 8 15:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 66298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp403999wrd; Wed, 8 Mar 2023 07:35:31 -0800 (PST) X-Google-Smtp-Source: AK7set9jdj6bax+mVAOviGWhw0K3FlA1mcUbgGtVDghmkgMcm8SVK/RKetiPqexI1h9sE8y8q7YK X-Received: by 2002:a05:6a20:c126:b0:cd:74aa:df55 with SMTP id bh38-20020a056a20c12600b000cd74aadf55mr15112603pzb.25.1678289730898; Wed, 08 Mar 2023 07:35:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678289730; cv=none; d=google.com; s=arc-20160816; b=0en/4IItW0BGIMCwIUXDnHtPg8ploDRqPpktKQpsvbDbUdELSCvmN1PfMjX2654khn WIQGh5h8lFR4/mCbot9KR+h383peUl7/7wrqZL2+LgOy8f6oWBalAD3aJJE1HmommvvM /WzJcuYpPD3E6Wk5aUcgZFGTcvsoqXLB0jHfd5gN//HryZWLGittUqwU1W6XtKUlCNH5 /sHR7SY47Ayl+nFsVFEWphra6DoJCeryI3bXKUGeBwmH4uYRJPQtpXKnAPBkILZgRvQF Cp2+3dE8nanJ8mJunWzkNxmLd9x1rlornma0rU4CUnv2sy+R6a0Sd2tasDi6nh+0iPM3 qZrA== 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=EhEP0p7cTgU2NYHkJBTt1zaHHLH70q1d3GVrDXZ/qrs=; b=jTBwaA6i67YAvs3+ReTvvR4ysDCq8ytWkZ+cGJ2m7H19PbLDeGzHI5HCqnEgtkgfqK C27cnzv7ndO2h338rvzX4BnI7/ewRjfB/P/kzBNOpS2tffzdLTgsrMxWrmqhvAh+1Yz3 06xIuZ0wgLm877Dr2hCp9Tm37rH/XjejNAqpB9ooP0dcdLJMZZ0rt8Xm7wLat6m9Yt0w MtVPfxfJYBowErRtP3kefdQHenIS4f7kHL+KE2/v376ZpaK1v3JH9FA5tBTfuWCoakwR vij0xYn071U5syojt6Yf5vQO88q77P6jQ6cxp3Osk8m5iZR4Sb06DVnfxGD23GqvwzpW AMpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=X6gOZgA+; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a656452000000b005023dfa3c69si5639810pgv.405.2023.03.08.07.35.15; Wed, 08 Mar 2023 07:35:30 -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=@bootlin.com header.s=gm1 header.b=X6gOZgA+; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbjCHPd7 (ORCPT + 99 others); Wed, 8 Mar 2023 10:33:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232235AbjCHPdG (ORCPT ); Wed, 8 Mar 2023 10:33:06 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D93D5D253; Wed, 8 Mar 2023 07:32:32 -0800 (PST) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CB060FF807; Wed, 8 Mar 2023 15:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1678289551; 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=EhEP0p7cTgU2NYHkJBTt1zaHHLH70q1d3GVrDXZ/qrs=; b=X6gOZgA+OwTX9CO3gJJjRDk3sGu9vCOMiuNbeDIwq+JnxYcAt+lBDTU2PuJS8/p82NMspL 9fdLtlz4m+6EUFEiQUYDEDlq/3M1uVmmfPS218moRA7TL5gMHWl77IWrYp9dh9lQY4ey/4 2+bIFRMHaa0sisfiDEUmxepkvil2WxXVghn1LsSXf3SXyC4WSR4RMppXYlUtq4ZtXkFF/5 lUoDWncTLyZIw2SfTicQKYt6oDsKxXGSpvb3eS9d2U+de7pE5bcBD10moP5PIv9O4TzlmL 9m2i4uo7YEHw+NoWzMJAiDPnUilYAwU3e5gb2wNL9JvMvW9l/bAB+fVtJDlZ0w== From: Miquel Raynal To: Srinivas Kandagatla , Cc: Greg Kroah-Hartman , Michael Walle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Robert Marko , Luka Perkov , Thomas Petazzoni , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, Miquel Raynal Subject: [PATCH v3 16/20] nvmem: core: provide own priv pointer in post process callback Date: Wed, 8 Mar 2023 16:31:56 +0100 Message-Id: <20230308153200.682248-17-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230308153200.682248-1-miquel.raynal@bootlin.com> References: <20230308153200.682248-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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?1759814332535256145?= X-GMAIL-MSGID: =?utf-8?q?1759814332535256145?= From: Michael Walle 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 Signed-off-by: Miquel Raynal --- 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 fccb2728193a..212c5ba5789f 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -54,6 +54,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; @@ -471,6 +472,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; @@ -1568,7 +1570,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 d3d7af86a283..0cf9f9490514 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; }; /**