From patchwork Tue Dec 19 17:40:22 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: 13498669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E888FC46CD7 for ; Tue, 19 Dec 2023 17:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g2UusGQMlzWpXG8Z3kfC/tR+G2AByqvmvrb+NcfYi/M=; b=CpJnox26kQMIj9 CHL7nrgJxkkqZiAcBU2d7BlvRtS3BdfcJVYGjhQ0MnI1g7cI9ywNVjYIGTgufWHybxcQk+PHOCTgQ C+2L/kuIKKEYPgW65ufHGYwAaEwBXRqlvvc8klqam8cCvHg2V2eJbCbGW0C3B/e7QZ4lMHtHafIYD 9CZ1oiaehOc81EQIwpJLmbFVOmoSpVmlO15y8nn+JqxiWBLv4P1W/tE3j+THePUiYFBQEyfqULA6o NcZ9rfKEQ8JNvJw5QiRqm5W/T2VHS3XCmAN1oAH3JJmarj5wdM1vHhUcf/vESktk8dnvqS1bXSw9p HwHBOOWtRH0hElBUMULg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFe5M-00EysO-0n; Tue, 19 Dec 2023 17:40:52 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFe5E-00EynM-0a; Tue, 19 Dec 2023 17:40:45 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-54f4f7e88feso6614442a12.3; Tue, 19 Dec 2023 09:40:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703007640; x=1703612440; darn=lists.infradead.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=KpoIUiZtPgGcupfXqit6R3n8WKSf6bjAH/albF1PKDDj0Yor93zUemQN7oG1ew2p3s S3XGNVl3PATNFgRxQ0rGKznjGChFqq6E6LzY9+Q9icPtVkNmTdTVAkwoPA7Yd7UQMRKk L0qQfKaisI9hX/rgdZ736fmyeIz/6HJdyDopMZeAWtztimt3dnOTUWVcK/mIoFlh/iwk 6bmlr4I5qhuwegmSv3hw+WXPYH37qI6nCmBgdJn7z9iCdLm4kjCRNUQXVwiDNTqX66tY +BqePFJF/86RhBa6A7AiyXpYJ+OzC9s9PfBYUlYEYCy28sWd9xkvsMyY2nPPz6vzJz0e DK/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703007640; x=1703612440; 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=SkZwbmX3sg6jIr/fXKDsovIt7+vrlsLCpizwC8YKXyD0uvFX0HurGt/pQMs+S7QyP1 MzNcLYTiRgssaOzCA83niee7dt+UQXt8jhxMOg+fp37+Nj1llgdPDw3VxskuWro69NNA qM1QMjUvrUw0vaiJZqtFlYNB1MVJOMGkXyF/DEO5iyFj0fDk74Wgna49mQb6arUP4FIA xZ4cchp2sxe9TtHiwkdCBC6LSGPzVJgywIr83KNhKpALKDYW/g1IF/wpgq+rm4VSVoWT OZCGu4PWSJ2cHYdGG48CpSq9RqT7ZVy1hDZRtri/D+5Vjh/wdJQlWoJ6iF/qc3WSfXwM JPog== X-Gm-Message-State: AOJu0Yw4vVyk+xDhNvBL6lHSGSdjg4lfjxfVoljOAOFNlOJkO3l2yRjC LG/L9re5BbkzHudXBXtcuEI= X-Google-Smtp-Source: AGHT+IE4Iweh6+hO7rOhKCZkig6kqe51ihdxK4L/LdTZ6cXOsGys0uUBqLTu6ozGXqXinvBp5StI5w== X-Received: by 2002:a17:906:74d0:b0:a26:8c0f:b0ca with SMTP id z16-20020a17090674d000b00a268c0fb0camr53272ejl.75.1703007640440; Tue, 19 Dec 2023 09:40:40 -0800 (PST) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id tx27-20020a1709078e9b00b00a1c85124b08sm15834840ejc.94.2023.12.19.09.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 09:40:40 -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 V2 2/5] nvmem: core: add nvmem_dev_size() helper Date: Tue, 19 Dec 2023 18:40:22 +0100 Message-Id: <20231219174025.15228-2-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231219174025.15228-1-zajec5@gmail.com> References: <20231219174025.15228-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_094044_238524_6AD7B479 X-CRM114-Status: GOOD ( 11.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);