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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86EA6C7EE2A for ; Thu, 1 Jun 2023 15:04:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 673F58474B; Thu, 1 Jun 2023 17:04:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="yU+7xbo/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9FDD78619E; Thu, 1 Jun 2023 16:11:35 +0200 (CEST) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 662438479B for ; Thu, 1 Jun 2023 16:11:29 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=h5k0HDM9Bnc4NfDFcM+rZfn5IS5H15tOEznT74QN/gw=; b=yU +7xbo/79kDt0sNT906CZQlAopmzeJMZ0fqdCggcHgT0NGodYAg1or+NMyiXEf2S5V3xc06Kx0FxoD IiV6xXQWCQsB76FCX9YJHdU9pTAvjhN4/Ga+RemzyE6tN0/osdREBsi1Rm2ygV2gp5y4o66oOSrok RZTbuGm916xY3JNBJ8SxYuYGmarGPW9TTl+Cv4TqBpijOXxRw8hfJwMQ2cG0QcUkP5EP3DndXtIDI QX2mk0zm3QfKvmCI9ywwu2FHbeMIFHQc9KFV2sslBTPspgVEfOAp202twTSSAyLGJf1tNSGdMwHiU ERiK8iduifjNB1c8giFTYTilzAaVwZ6A==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q4j1R-0002en-An; Thu, 01 Jun 2023 15:11:25 +0100 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , Simon Glass , Philipp Tomsich , Kever Yang , Eugen Hristev Subject: [PATCH] core: read: fix dev_read_addr_size() Date: Thu, 1 Jun 2023 15:11:19 +0100 Message-Id: <20230601141119.1658720-1-john@metanate.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES X-Mailman-Approved-At: Thu, 01 Jun 2023 17:04:04 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The behaviour of dev_read_addr_size() is surprising as it does not handle #address-cells and #size-cells but instead hardcodes the values based on sizeof(fdt_addr_t). This is different from dev_read_addr_size_index() and dev_read_addr_size_name() both of which do read the cell sizes from the device tree. Since dev_read_addr_size() is only used by a single driver and this driver is broken when CONFIG_FDT_64BIT does not match the address size in the device tree, fix the function to behave like all of the other similarly named functions. Drop the property name argument as the only caller passes "reg" and this is the expected property name matching the other similarly named functions. Signed-off-by: John Keeping --- drivers/core/read.c | 5 ++--- drivers/reset/reset-rockchip.c | 2 +- include/dm/read.h | 12 +++--------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/core/read.c b/drivers/core/read.c index 0289a2edb6..5749473a6c 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -211,10 +211,9 @@ void *dev_remap_addr(const struct udevice *dev) return dev_remap_addr_index(dev, 0); } -fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *property, - fdt_size_t *sizep) +fdt_addr_t dev_read_addr_size(const struct udevice *dev, fdt_size_t *sizep) { - return ofnode_get_addr_size(dev_ofnode(dev), property, sizep); + return dev_read_addr_size_index(dev, 0, sizep); } const char *dev_read_name(const struct udevice *dev) diff --git a/drivers/reset/reset-rockchip.c b/drivers/reset/reset-rockchip.c index 2ebe3382f7..6cabaa10a3 100644 --- a/drivers/reset/reset-rockchip.c +++ b/drivers/reset/reset-rockchip.c @@ -97,7 +97,7 @@ static int rockchip_reset_probe(struct udevice *dev) fdt_addr_t addr; fdt_size_t size; - addr = dev_read_addr_size(dev, "reg", &size); + addr = dev_read_addr_size(dev, &size); if (addr == FDT_ADDR_T_NONE) return -EINVAL; diff --git a/include/dm/read.h b/include/dm/read.h index 56ac076c9f..137f2a52a2 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -347,18 +347,13 @@ fdt_addr_t dev_read_addr_pci(const struct udevice *dev); void *dev_remap_addr(const struct udevice *dev); /** - * dev_read_addr_size() - get address and size from a device property - * - * This does no address translation. It simply reads an property that contains - * an address and a size value, one after the other. + * dev_read_addr_size() - Get the reg property of a device * * @dev: Device to read from - * @propname: property to read * @sizep: place to put size value (on success) * Return: address value, or FDT_ADDR_T_NONE on error */ -fdt_addr_t dev_read_addr_size(const struct udevice *dev, const char *propname, - fdt_size_t *sizep); +fdt_addr_t dev_read_addr_size(const struct udevice *dev, fdt_size_t *sizep); /** * dev_read_name() - get the name of a device's node @@ -1002,10 +997,9 @@ static inline void *dev_remap_addr_name(const struct udevice *dev, } static inline fdt_addr_t dev_read_addr_size(const struct udevice *dev, - const char *propname, fdt_size_t *sizep) { - return ofnode_get_addr_size(dev_ofnode(dev), propname, sizep); + return dev_read_addr_size_index(dev, 0, sizep); } static inline const char *dev_read_name(const struct udevice *dev) -- 2.40.1