From patchwork Tue Nov 14 13:48:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 743774 Delivered-To: patch@linaro.org Received: by 2002:a5d:67cf:0:b0:32d:baff:b0ca with SMTP id n15csp2176768wrw; Tue, 14 Nov 2023 05:49:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGelqw99Rh4VdMYFoXFeQ5y5Gc6tzCGPevFsFmny2T3aC1KBuYEddxbAlpe2rLvp/H837MA X-Received: by 2002:a17:906:c0d6:b0:9c7:fd91:4309 with SMTP id bn22-20020a170906c0d600b009c7fd914309mr7746638ejb.0.1699969743705; Tue, 14 Nov 2023 05:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699969743; cv=none; d=google.com; s=arc-20160816; b=YYdrV/Sm8PkeAeVLqioUtrehoXObWCJL89kD9A/yLjnH6uAS5l49jKx/sX0l2ZVqIt H9TJ490TmpyYCvQB/POBO8maOyJaC+8aY7x+bVBiH9/vQW+9OvHa2oMIOULqx4N0hiw6 roiT132Wk/91jq0RSYBE8kZ2KGq8tC7sc0er04YIuOU+/kCCVarMcN3BzxM53MXSX2Qt 1oygFj6Qw0wrmU1+aep3lZBFS6aSPU36rert4TpWtUEnTw4RvbIZN+t9nogBKS0rOVw1 TdXTc/J3O+cby0wUjc9JNSEJI+eUgaCsP0LO59/yrXWYRvDTYQSSDhijJt4xT1dqkQqs Z57g== 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=pcPpqjCyVm/6ofdhTTiOBgtbsnh3mMlC3FejEkmFNLk=; fh=57wjcTC2B872pbvvKlxFgwzI1s9QKuSBoEg/SeZNaxI=; b=lqT+pAY6hO9A/Z8tlb9RpRnb4t5zWSU+VBSVi6C/fHKiRIzm9CKF1JE/jGhpzhj0Rm OUtfMhEemBuYa0zE3jg49haciG9vJ1qF0zNwmn5ckGiyIQzlNVWIVb8YlN29pIumzIIs y4dtTOj4TX1/ti16U8kN1Dp7wD1dEcJKfPqoq3K61IMosawdtX2IerNTCuiGvln2i4U7 RQYWthsqWRGy1XObgE7f8YTT5oSxy8LR+7vfkDdGqLb694MsAXIEWrtSl3BI1UE+1pGP 0u0qvOOMJSySNFCMQCPLCSPkqOg3YvC3ebNXQeNachlxmg60SdkdZMXWwQ5Ujz+4rS2m aaQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dn1Wl1zm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id hs39-20020a1709073ea700b009e5e6f03ebcsi4204936ejc.659.2023.11.14.05.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:49:03 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dn1Wl1zm; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 394FC8747E; Tue, 14 Nov 2023 14:48:54 +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="dn1Wl1zm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E89B3871E4; Tue, 14 Nov 2023 14:48:52 +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-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 1F29387215 for ; Tue, 14 Nov 2023 14:48: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-x335.google.com with SMTP id 5b1f17b1804b1-4083f61322fso44006395e9.1 for ; Tue, 14 Nov 2023 05:48:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699969730; x=1700574530; 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=pcPpqjCyVm/6ofdhTTiOBgtbsnh3mMlC3FejEkmFNLk=; b=dn1Wl1zmoxuaDSRN4Hd3tiEJ/bEltJlEzIiMJ3/0ZQEEj6TaKSbGEugr0h7EXe6fCe TSfiF5NrqNOLzwgbltKKA3jHE9XurXBncMY+gPwKpvPOwqE8rAfnflfykqyK38uthrKX McvVW9FZQpFRKNccF388jIE2E8AkcTc6PQJEe4icODOygm6Uw6pOBeYSrOBrLi+hYHS0 iDrx8z8hICm5X2rwy1Oo55eLXuE1tX/Ir+E9utitTxBJQz2boFi+FjUrelcA52pMJSME gfAxTphowq3++fz7QrFjrVgGdhUmSPEQhATHAPeeRSsuoy9xi3KD660p8TRgZLZAhhgB Kbyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699969730; x=1700574530; 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=pcPpqjCyVm/6ofdhTTiOBgtbsnh3mMlC3FejEkmFNLk=; b=ZwmjKcgIGi9Imk+qMv+aFSF9N6XLmTDSNV5byllSQlOG5k9yEO+9LlxMVxG46TjwN+ UzcupxGUwsqJMDvpAYyCiIFEerp92z6UlPXISKoPeEU2O1jUAzTZ/Ek5lWiycN3dvaTL XpKND+s78Nb8Dk5hmgboXDIGjYy6IxAZM5wcPIx7o4NnLqpW4iQDu014Z5+DTYIQ2Ls1 AEM7odHcNrynP7xKRQ0iwhOMNCLG7kYxYI2UnKgxWUdqvl3rfsfAMlj600JUdyRvUCVK bNxQGt7Tgq9fkgKe34X9xW0a8y6QZz1dVR7JKSc/OADQ3oA+BzbFvL0AWd+8TTHrMJln NT0w== X-Gm-Message-State: AOJu0YwyPE8y/yEPLQeZCjGCkrgQuWyvXOAy0td+FQjmcCV1bY858Il3 6BytuZWCCAqbZ37WfXeUixxwjg== X-Received: by 2002:a05:600c:5247:b0:405:39c1:a98b with SMTP id fc7-20020a05600c524700b0040539c1a98bmr7567467wmb.20.1699969730577; Tue, 14 Nov 2023 05:48:50 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id w10-20020a5d4b4a000000b003313426f136sm7804220wrs.39.2023.11.14.05.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Nov 2023 05:48:50 -0800 (PST) From: Caleb Connolly Date: Tue, 14 Nov 2023 13:48:47 +0000 Subject: [PATCH v3 1/5] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231114-b4-qcom-dt-compat-v3-1-88a92f8f00ba@linaro.org> References: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@linaro.org> In-Reply-To: <20231114-b4-qcom-dt-compat-v3-0-88a92f8f00ba@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=1527; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=L/Hg6krN7n0rquWuC6IguNE2GC8qLGvDuF5QKrLiC1o=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtTgqgNytb5LBf4ePLMrTHFBiNz8r1aXS+ujxXXucGvPU OoM3tLaUcrCIMjBICumyCJ+Ypll09rL9hrbF1yAmcPKBDKEgYtTACYSHc7IsKClzsyzOCdUuboj UfFeRN+R9x/efMue4VTpznX9ItOuAIZ/9s/f8i7e9zLW1kTi/Stj1q9nFvlacRzZ0HExckXytMJ oRQA= 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. Signed-off-by: Caleb Connolly Reviewed-by: Sumit Garg --- 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)