From patchwork Thu Dec 21 17:34:17 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: 182365 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp570922dyi; Thu, 21 Dec 2023 09:35:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3NRQHe/FWTytKsN9lmr6WZRBGIFGe9GDTJLqqdA+qPEHcgbmyGQBes4xilS9Jai86jnmE X-Received: by 2002:a50:c18a:0:b0:553:a5e5:78d8 with SMTP id m10-20020a50c18a000000b00553a5e578d8mr2829803edf.26.1703180109977; Thu, 21 Dec 2023 09:35:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703180109; cv=none; d=google.com; s=arc-20160816; b=ci6esMrxCVy37iw02TvwBUs0+ZkqQQgZlEayXVCbxAr1V979Uv12Z2Hp54Oyc9iGmf Lq6PFatUyTcdAUTDVnUlFwAylNs7m1S6TNEtxIEkNnawQgVd05NbU21Vu6nxOdOZZUAD Y2ej7wapeVvxehedo/wp/LhDoxvEnnSLufHM0nQ4jowVtNTFlFGBwr0ilXKhNncg3rTX bb6+Obf8SftvPhmJTK4gVcm6h7DJT5pbCKAKcqaMHb33gX7KbqhEhHLGq72bTx0sjiMt PZwnuCNAyxt7aGuvZFjf6Pyp8zKve8MZ98uuuU/soBWenYgi6uAAex5fB9otmnrnrJNH f32w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HS/utwklj/mQdHgmYltSxcVR9bMR4HdMDBmcgJXrZDU=; fh=dfLNqWOtm0UaHb8GCHMuBSVlbZCi7eV095mQO5nOqs8=; b=IDPO/u7otPMLivN1+7JjzF9l8fMMjisc5K1H1L+oJyDmPUdnr+qXfaasDwPU8MYzAk Dqru1do6BgQ+ZUNA6UpgBFsv/S81IFkkofNJhl9B1HfbT4y/bZqgU+PZmNbGjhdd47Ni nbhRhMVG1Gp+v9CpQefcVjUM5zkFuOZYXEA5eBSgSJg1U7ic5BHCg8bejkDueGvap4dD 1otNAqyfLQQJGAxk207xnsGFaqvQ2a0DEh9bpCHxwp9shLAXKTJavGIH8aEr9apacTfm Hc+ZrgJFMmwrvTEy3hU5a0inrCyvOUaSUcY0fZzNfYzx1g4GwXfUpNFslAp322i16bge q/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Eu0UUoTW; spf=pass (google.com: domain of linux-kernel+bounces-8856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s22-20020a50ab16000000b0055411a2ac45si893375edc.331.2023.12.21.09.35.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:35:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Eu0UUoTW; spf=pass (google.com: domain of linux-kernel+bounces-8856-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8856-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 95F551F25767 for ; Thu, 21 Dec 2023 17:35:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 466C86351C; Thu, 21 Dec 2023 17:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Eu0UUoTW" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CCCD634F0; Thu, 21 Dec 2023 17:34:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a2340c803c6so129382066b.0; Thu, 21 Dec 2023 09:34:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703180074; x=1703784874; darn=vger.kernel.org; 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=HS/utwklj/mQdHgmYltSxcVR9bMR4HdMDBmcgJXrZDU=; b=Eu0UUoTWpKyE3YCGUdSsqVezppxNYEp9/2/S74PEgflbINlV+iD6vnfbrY48bwVRma /VLUT8X2y7aMVwleN4WeUJtYBKSshIxKAe50wyNCuQu774t4ti4obsBuTE7I2yt+EWqQ fhaRHNq7eO9luv6dVpP3u40Oa78fEf0G5hegiF4y+4pY0cXoOVEe19KKewT3NK4Zcd7z jXs5wpVn8m9OXebZ0t9fEfEIpqqCmogv1JQXDmLWo4EYXPozyeX/YVd4wr79mtKSjez2 xGWeRPoAV8D44uTjyBWYhE6hjOrM5OxxN5lREzYSMe6f6U35rt/yfcG89hlKjB3wQnCO ExUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703180074; x=1703784874; 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=HS/utwklj/mQdHgmYltSxcVR9bMR4HdMDBmcgJXrZDU=; b=xQcWSgkKmizNCS6hqM45+6M1W7uqfEqiwt5OizhHsDOwhL+db2usTpIM/SAkGhjQgX pQosyIOE1ChN4Q696cFs3Q+4jJP7TqXTLrNkEcMEnneCz6a2Oo15gPPm13MkHqIdFq7y DeSYiZQWuQKPk85Dj5c2+xRZKFrGSE46dOI61Xsb7HkOdPTG8ljAEDga57V5MpRZmKLy tL24IHZadXN7ZbWYPLdE7cW4wIeVBR5EyVsmtDzpaIfaGHmQJo/jEB0ZDymUvR1hhNIC s9D6bCHBcWNKAT7KHOd/ft7AdPqtTPQzxQ7n3sZmsAMPcjnuwnfe6I8xUxB13gdTfE8S 8D6Q== X-Gm-Message-State: AOJu0YxhLVUKcMDcO1jjtzavhiwacanX+x5Pa22qwZS4pGjcC71E60dg 4EoBMqbF3b2qybn6cmX3vWs= X-Received: by 2002:a17:906:4749:b0:a23:65de:419c with SMTP id j9-20020a170906474900b00a2365de419cmr75233ejs.144.1703180074094; Thu, 21 Dec 2023 09:34:34 -0800 (PST) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id z25-20020a1709060ad900b00a23499f1d7dsm1176118ejf.209.2023.12.21.09.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:34:33 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Greg Kroah-Hartman , Michael Walle , Miquel Raynal , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, u-boot@lists.denx.de, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V3 2/6] nvmem: core: add nvmem_dev_size() helper Date: Thu, 21 Dec 2023 18:34:17 +0100 Message-Id: <20231221173421.13737-2-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231221173421.13737-1-zajec5@gmail.com> References: <20231221173421.13737-1-zajec5@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785913786865813649 X-GMAIL-MSGID: 1785913786865813649 From: Rafał Miłecki This is required by layouts that need to read whole NVMEM content. It's especially useful for NVMEM devices without hardcoded layout (like U-Boot environment data block). Signed-off-by: Rafał Miłecki Reviewed-by: Miquel Raynal --- 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 4ed54076346d..980123fb4dde 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -2163,6 +2163,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvmem) } EXPORT_SYMBOL_GPL(nvmem_dev_name); +/** + * 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); + static int __init nvmem_init(void) { int ret; diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 2d306fa13b1a..34c0e58dfa26 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -81,6 +81,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); const char *nvmem_dev_name(struct nvmem_device *nvmem); +size_t nvmem_dev_size(struct nvmem_device *nvmem); void nvmem_add_cell_lookups(struct nvmem_cell_lookup *entries, size_t nentries);