From patchwork Tue Nov 28 16:30:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 747827 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp3934591wru; Tue, 28 Nov 2023 08:31:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUaJR4E8yGrrG+qWeWw8j151C5Wo538FhSSWFiXmusdKcwlQCgvsxDpfEVp4KCeNX+Sdbw X-Received: by 2002:a17:90a:1944:b0:27d:c95:b0ad with SMTP id 4-20020a17090a194400b0027d0c95b0admr14806613pjh.21.1701189072914; Tue, 28 Nov 2023 08:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701189072; cv=none; d=google.com; s=arc-20160816; b=jrX46/AHTFEGq/NJIk0OxSZJ8mipSi6WKwpFKdNhzwq83La/0TLwsxo9EP2OE2xmha w9aXfugOR1mP/FVfKYLba8VB7lkqst25UR1unly6B/3M9ls7LxcAcgBvBodfOXWerJEk 63qHQdTVBVy3IZAW3Cc46rfBh2HY1YwYRkgOBI5bSoSaXHwhh8AiLJcZx13FwLi6hHGX ER+JEYgxvs78aRyDVRbRuC0cV3bIVpkQH1zGUjtW7XzyqItOo0W4OTQR7fSlm0r9Ghqw xRvA9GTJBivXszmpQ9RxI4sntgv/T/ttBecQkmSjadvZ2Q/h+sRhl4yzGnmyz+M95TCK 8Kfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ZD3xWJFTddk3OTmdBUhNqHlWq/BUIyH8Xi/jMrAbFW8=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=z/JtRaLdItjTBKT7KA+kkVyWnReMKOG8BrZfcBjZgYSUxVwXoLvtvsUvhNytrD42xH xB7zELDN0EzbJhBj85U/fgcgysqEzG7qvX3LsmZETXnlHyXEF8OXyoRYRyV7XPj6DZCb C7HT7enI65mgjrpmcQL02WdTIQc2jI3CmDV2lrWdoUgccoHqeEKDa57sexARheyW4eX2 egiC4EYwiE19sMfRFyiyHs4aPrKcykiWM9uU8Us1bKqJlnfOB1k1uP2LQRKq8t8hXYSG GHF19KNKBMV62ej55RR0HysG7tUNp2wewnUlzHb6SYPmuvXl0CdaaUSrKhc2UzL62pQF H1dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yRQZ1AMM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id k2-20020a170902ce0200b001bdc10170casi13140354plg.36.2023.11.28.08.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:31:12 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yRQZ1AMM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 449A387759; Tue, 28 Nov 2023 17:30:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="yRQZ1AMM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B42B8776E; Tue, 28 Nov 2023 17:30:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9504D87741 for ; Tue, 28 Nov 2023 17:30:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40b27b498c3so45367695e9.0 for ; Tue, 28 Nov 2023 08:30:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701189051; x=1701793851; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZD3xWJFTddk3OTmdBUhNqHlWq/BUIyH8Xi/jMrAbFW8=; b=yRQZ1AMM7I/Z/dVIMxE7IF4yi28FuyJhSSu0nWjfd2wFu6S/5a5BlnfXQAXf6m7tK8 n9Mm3eQC5LB0+PFm6boL/McHf0QV3gqQGdoYKVmwT3t5jwgfa9sAOYARTU3DWQNOEPw6 xRp1Kprqkun5yFukC8+PG9JxKzY+LndKZfN9+nK4MbLi6Eo9wKnxQE2BEtw4H3W5O20N wF7CAKbNLifHbmoZxUjtXy+pyxWLku9m/ZGUFxYc8cALVy4eC/M12Crse+gQxdykh4L/ ndkrLHuFn+GT3Yi79T/2jdFseYE+jLLcrNm0M/BzUOaLwClztN1/iIyU4ke/mX6pLD56 qfpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701189051; x=1701793851; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZD3xWJFTddk3OTmdBUhNqHlWq/BUIyH8Xi/jMrAbFW8=; b=j6+9JW/AZ5J+TsXE8YT5w7tc6QPCaDfOV5W6oKya7buHtsDTOZmYlma8co2zi2ZQQA PY2lBFRgRl+8qC0GP6jt4eQsWilWd+Kug6xkLLzJ/PoKLKwp5z0Gb2h3hHJ5AivEq81u PUCHdZUMSFfdJAD9raIMpi+VL0oAhE+ESEfwIn5eJBLi+583tFZZMqntLZN3AUqBeFAl yeTP7Z6GCHEQSh65SY143DF762bsXK/srPhzy1izMbU88nlcZxHnB26Qo7WXnBUR1vfA J2H73ixnp821pgOXUCp66pujniT4lxgaEkAuBkMWqhB0eQ/Ku8zi7AO9+/OPyImPz3BI j2CA== X-Gm-Message-State: AOJu0YzXG+t8Pm/08Y8I4JGc+DEsE6Ec72+oB7UNa2yEoHH4iRQejyNJ xT0D1hb7NYfBP9494qmDKmcwKNWx/zjWhx5X/XLJww== X-Received: by 2002:a05:600c:1c11:b0:405:3dbc:8823 with SMTP id j17-20020a05600c1c1100b004053dbc8823mr13277768wms.12.1701189050693; Tue, 28 Nov 2023 08:30:50 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id d21-20020adf9b95000000b003316debbde4sm15530041wrc.48.2023.11.28.08.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:30:50 -0800 (PST) From: Caleb Connolly Date: Tue, 28 Nov 2023 16:30:25 +0000 Subject: [PATCH v4 1/5] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231128-b4-qcom-dt-compat-v4-1-949d0982d1de@linaro.org> References: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> In-Reply-To: <20231128-b4-qcom-dt-compat-v4-0-949d0982d1de@linaro.org> To: Ramon Fried , Jorge Ramirez-Ortiz , Neil Armstrong , Sumit Garg , Mateusz Kulikowski , Jaehoon Chung , Dzmitry Sankouski , Stephan Gerhold , Caleb Connolly Cc: u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=1576; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=Ow6e+BYI9LfPmrbAV1SHSrFbCMy8//JMJxsRN55OU2Q=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ00e3Gp84Y+ddkG9n5r14XdlcxY3LGbFYpp5TGfZ9uT xNgyDbtKGVhEORgkBVTZBE/scyyae1le43tCy7AzGFlAhnCwMUpABOZM4XhN+sC0ec278qjONWy FHx+/RBY8+qyHOM65pc707dfZ1+q+5iRYWuC3twz+85GRgs0akltCI/g/7bZ6YuM97ItuYylF9l 4AwE= X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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 priv->pid is uint32_t, but dev_read_addr() returns a uint64_t on arm64, with the upper bits being used for error codes. Do error checking before downcasting to u32 to prevent errors being silently ignored. Reviewed-by: Sumit Garg Signed-off-by: Caleb Connolly --- drivers/gpio/qcom_pmic_gpio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 65feb453ebc3..e5841f502953 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -221,11 +221,14 @@ static int qcom_gpio_probe(struct udevice *dev) { struct qcom_gpio_bank *priv = dev_get_priv(dev); int reg; + u64 pid; - priv->pid = dev_read_addr(dev); - if (priv->pid == FDT_ADDR_T_NONE) + pid = dev_read_addr(dev); + if (pid == FDT_ADDR_T_NONE) return log_msg_ret("bad address", -EINVAL); + priv->pid = pid; + /* Do a sanity check */ reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE); if (reg != REG_TYPE_VAL) @@ -328,11 +331,14 @@ static int qcom_pwrkey_probe(struct udevice *dev) { struct qcom_gpio_bank *priv = dev_get_priv(dev); int reg; + u64 pid; - priv->pid = dev_read_addr(dev); - if (priv->pid == FDT_ADDR_T_NONE) + pid = dev_read_addr(dev); + if (pid == FDT_ADDR_T_NONE) return log_msg_ret("bad address", -EINVAL); + priv->pid = pid; + /* Do a sanity check */ reg = pmic_reg_read(dev->parent, priv->pid + REG_TYPE); if (reg != 0x1)