From patchwork Wed Jan 11 07:30:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 41785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3180610wrt; Tue, 10 Jan 2023 23:42:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXv/x4iEtDlFliMJTYrC2e+8eK55ruEw8kOQ+IeAQ8ySH0iUZihcflcdQIcWrLHmUScQ4W1e X-Received: by 2002:a05:6a20:94c3:b0:ad:dcdf:aaad with SMTP id ht3-20020a056a2094c300b000addcdfaaadmr90843066pzb.19.1673422928401; Tue, 10 Jan 2023 23:42:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673422928; cv=none; d=google.com; s=arc-20160816; b=PIA6qaALpgcRrO8A5Y/xF/9UmBeMb4yWLek0Iwz39TaKhyooHTMfwLvxj19UcDC5qy 4q7KO5/FwRjUCdlCiE5HwuRPQO1YGvE3IlwzdXH8zIKu7Vl4NvAJrKF1NR9v5pULBLen qEYpIbTUU0oo6fYCI3pkR/qAczB4duQ/4tToFmWHObSSjK+62kSLqmXcUsUpCr0uYfTF HvZgE6bzvrNjbIcV5gR/DUzeYwsppGMsrxVJRoM6sD9rTedViMSdjnBjLgmuC/yQP8j3 MauPy70ev6ykwl8FwjtNbJqDWj2UYZvvTJOxa2TFGgMffHZw6J+Cewlb1YbDzabvnD4k gEvg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8DBHbw8SRKxIaaEznlgvFtV6o4AQh3C5twMwXmVKndw=; b=CW2WCTjPvcd/y8eAUilf/+dSNwqfUKyMC4sdU1LDfBatz64/9zgwDhZ+sB+PHewy0p LoFUnfcNaYvoTXi3TcNv+5O8I5FZPfGoJhn2w3WEqN1xwZRZVHxbvk/1V9/nCU0qEuQJ biSigMzKXhB71p9/exWcKL36UMXPiq6dNuLtWiwh/KOw18mVFEqH+802nkdwaVFVYDw5 DuuzGv3JbNyvQ6OV+rKFAcLgL/CBwokOA0mFhYwGLi6myCC694vjwkBzrNlGgrLuXMTN LJBSH+upCaobE/jqjOHh01jY1dn+Kl4loFJWfrIUB2BiA07mkOcMRz8VsNrGOj1Ck0mM 7dZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LKZl3Yl1; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h29-20020a63385d000000b0047005e8d874si5373239pgn.9.2023.01.10.23.41.55; Tue, 10 Jan 2023 23:42:08 -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=@gmail.com header.s=20210112 header.b=LKZl3Yl1; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231927AbjAKHbS (ORCPT + 99 others); Wed, 11 Jan 2023 02:31:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235641AbjAKHbP (ORCPT ); Wed, 11 Jan 2023 02:31:15 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EF78E9; Tue, 10 Jan 2023 23:31:13 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id v30so21067456edb.9; Tue, 10 Jan 2023 23:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8DBHbw8SRKxIaaEznlgvFtV6o4AQh3C5twMwXmVKndw=; b=LKZl3Yl1yaH9pHPcrGazQYIO/+lPuf0TVx5YL6feozCkqA0Y3rsXDrPv7+ShBohCGE mav3xeeCzvYfgs7cVqj2k8cDb4fur4tYELCuJfHlTGMbAFF0LCN14a9bLzyiMCsef1WH wl7/sxpMWWGKhzMEV2FjqMmAMatKIqDjV8E0Vu9Mx6XHPOglF4ZP83Jt828aQfXaGeDe 5742PSda/syaQ0PJFDoHuNopxeADoOKLpitq3OAuD84Q8VnMeVrVYn5mUaJsQi0r8vH3 VNnsVGX3qIbYEuYlTKe3T3xALuE8WUuSFOe6BbP58ExuaMQAAxTpzLNJ+gQwRZLu7qMT UQPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8DBHbw8SRKxIaaEznlgvFtV6o4AQh3C5twMwXmVKndw=; b=JlcBM0AdvVelZFbC2n8sXB3zk4FSzh/JYZaA70zdn8NYJshW91r9qaFvnOofyeg7bD KcIjt78k2mPxzYHHz+7Gt5czetlH06LEOweqe3KeqpeHyGFvQU+e2HynbKCgUjuvGYZV 0plWidupNXE6t2O0DMp1LH/p9uZGuoL1osO4XmV8T/Z5RwwvqWeW8gJ6Y6ZjFm7IKXla YaLSA2Kk0s/ylFFlbxflVOxUFX2UC+0mPjghGzk8iQxOoUSs+/nuqtmi0geNEKrI9/lJ Vrb4sWb6miu4RxLnbT9sXsvXqvSXKQcSb0T0+G4YRywx2nUF0plbUpDssoLdwa996cut XlKA== X-Gm-Message-State: AFqh2kojWUl+vGKjGRCDb/8zwac3uoFmCrMT47Co0dCwwykFm2DOkMYl aeZldikn5N5VlOoz1iHYYhrzIE95QvI= X-Received: by 2002:a05:6402:456:b0:484:8b49:e117 with SMTP id p22-20020a056402045600b004848b49e117mr50242343edw.3.1673422271823; Tue, 10 Jan 2023 23:31:11 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id ed6-20020a056402294600b00499e5659988sm593193edb.68.2023.01.10.23.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 23:31:11 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, u-boot@lists.denx.de, =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= Subject: [PATCH V2 1/6] nvmem: core: add nvmem_dev_size() helper Date: Wed, 11 Jan 2023 08:30:57 +0100 Message-Id: <20230111073102.8147-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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?1754711120495096858?= X-GMAIL-MSGID: =?utf-8?q?1754711120495096858?= From: Rafał Miłecki This is required by layouts that need to read whole NVMEM space. It applies to NVMEM devices without hardcoded layout (like U-Boot environment data block). Signed-off-by: Rafał Miłecki --- V2: Drop "const" from "const size_t" --- drivers/nvmem/core.c | 13 +++++++++++++ include/linux/nvmem-consumer.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index d3be50ed2d0b..32f7fb81375a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -2062,6 +2062,19 @@ void nvmem_del_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries) } EXPORT_SYMBOL_GPL(nvmem_del_cell_lookups); +/** + * nvmem_dev_size() - Get the size of a given nvmem device. + * + * @nvmem: nvmem device. + * + * Return: size of the nvmem device. + */ +size_t nvmem_dev_size(struct nvmem_device *nvmem) +{ + return nvmem->size; +} +EXPORT_SYMBOL_GPL(nvmem_dev_size); + /** * nvmem_dev_name() - Get the name of a given nvmem device. * diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index fa030d93b768..c3005ab6cc4f 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -78,6 +78,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); +size_t nvmem_dev_size(struct nvmem_device *nvmem); const char *nvmem_dev_name(struct nvmem_device *nvmem); void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries,