Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1066942rwe; Thu, 25 Aug 2022 14:55:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR4IlUWJfTvwpuM5l6SUE2TR+KJm5kQd/CH/tiAiCWSc4BjOzY54u26OyYT4UOyKNh0qF2eX X-Received: by 2002:a17:907:6e17:b0:73d:8d0a:f450 with SMTP id sd23-20020a1709076e1700b0073d8d0af450mr3573198ejc.452.1661464535524; Thu, 25 Aug 2022 14:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661464535; cv=none; d=google.com; s=arc-20160816; b=S5CNrTiZK7bW2P0WVVaEGFQVpQU7ObxWIZQ0YGs7IOGEgztgeRK3f3ne+GW2MTWV4a ZmOJfdRhXk5CBObB6+wnGEGhzVLTbqAGzM2MVTgX6hbIcxzXf9yoXKH6uqVDNWPfW+5S PxRjNUdVH/c0zBYJ+Wl1JUFwqDKsnq+s4LgKQAw+BuQB26Zlfw5InUE/9M90lrfDGR9X MvLFpLEHM7oLVioGrelfvZ/+oX1twEgou2XsII68R/InCi57O/Mn7laoKatt/cg8JlAE vP1N83pN9L3pHpinwL+fvsP8+bNNNZ4ldUI/KHVvoDxRcld/IHYnhHb2psmI+3mFFzMf fDYg== 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=bZ0MB2oqU++FCqLOXHr3+VjUWFBZ0liXMlmqroQmEUU=; b=M6V419aFXaG9QrOSJ07/QxeieXPWSnh4SxN3pF0F2LXaJp4X+922qiXULFQc1CnZgw M7SM/wLXphALvglSYchg49QvdLvbJHmFSq89henjNRmBd8b2Rs2mNflP5MD+d8kiTPpH qTOrdbSnQOuGRwSgbHR6mJg0RnPZ6hkqQcwvdTp0UBHVQ4Fzet9erUhr7an17oIKbLMb n3bTKlo7cAwnG3T/gu1t4lpjBENsNnXTsjtbxhuSlk8sX3hXqxieT0Lv+LQShtiSqMFy pp0Hbe2VH733dSspUYUepCEtCrrWwUasmnlbREO1u2BDVrEjHb24lyA8D8gTM5fj5Wtw fdqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=uyKoL9zf; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bu20-20020a170906a15400b00730a1d3bb99si200396ejb.436.2022.08.25.14.55.09; Thu, 25 Aug 2022 14:55:35 -0700 (PDT) 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=uyKoL9zf; 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 S244157AbiHYVqY (ORCPT + 99 others); Thu, 25 Aug 2022 17:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244093AbiHYVpU (ORCPT ); Thu, 25 Aug 2022 17:45:20 -0400 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBBB5AF4A1; Thu, 25 Aug 2022 14:44:57 -0700 (PDT) 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 5AD7398F8; Thu, 25 Aug 2022 23:44:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1661463881; 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=bZ0MB2oqU++FCqLOXHr3+VjUWFBZ0liXMlmqroQmEUU=; b=uyKoL9zfJgM6YR5kpaLWJ9M/6XYY+6B1YfX/EgNk0VuTy1k+ps1CY+IJv5zklWHYhG16nj 47TW5CYs/4ntqSnpePVEKP9A7WGN38riPevWIWzwtLXqS+elvWN6lfQ46GLppOOdHf/GO7 1a18I8IEQmgtXuZ4vFO8uGdIHX8WQ1wE7b2yrBR7a14xv9SoyweOAv0DSjjerLYZCqU4c0 pIjgeb1ZkP6PVQwko6Y80CHBMlXyuz6gNIN3lGFU5DJn9YlnMWN9TFPeFmj4T8R+g7wBvd sLThdknz2cPx4RVc6fYylF/v/Ma2275hx/aCWfaCaxPHM1TYqGdwJRbRiN5vKg== From: Michael Walle To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Shawn Guo , Li Yang , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Frank Rowand Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Ahmad Fatoum , Michael Walle Subject: [PATCH v1 11/14] nvmem: core: export nvmem device size Date: Thu, 25 Aug 2022 23:44:20 +0200 Message-Id: <20220825214423.903672-12-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220825214423.903672-1-michael@walle.cc> References: <20220825214423.903672-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, T_SCC_BODY_TEXT_LINE,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 Export the size of the nvmem device. NVMEM layout drivers might need it and might not have access to the device which is registering the NVMEM device. Signed-off-by: Michael Walle --- drivers/nvmem/core.c | 13 +++++++++++++ include/linux/nvmem-consumer.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index cbfbe6264e6c..f46ae358fe88 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -2031,6 +2031,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvmem) } EXPORT_SYMBOL_GPL(nvmem_dev_name); +/** + * nvmem_device_size() - Get the size of a given nvmem device. + * + * @nvmem: nvmem device. + * + * Return: size of the nvmem device. + */ +size_t nvmem_device_size(struct nvmem_device *nvmem) +{ + return nvmem->size; +} +EXPORT_SYMBOL_GPL(nvmem_device_size); + static int __init nvmem_init(void) { return bus_register(&nvmem_bus_type); diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 761b8ef78adc..6b2a80a5fdd5 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -90,6 +90,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); int nvmem_device_cell_write(struct nvmem_device *nvmem, struct nvmem_cell_info *info, void *buf); +size_t nvmem_device_size(struct nvmem_device *nvmem); const char *nvmem_dev_name(struct nvmem_device *nvmem); @@ -219,6 +220,11 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem, return -EOPNOTSUPP; } +static inline size_t nvmem_device_size(struct nvmem_device *nvmem) +{ + return 0; +} + static inline const char *nvmem_dev_name(struct nvmem_device *nvmem) { return NULL; -- 2.30.2