From patchwork Thu Nov 30 20:22: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: 748511 Delivered-To: patch@linaro.org Received: by 2002:adf:e9c2:0:b0:32d:baff:b0ca with SMTP id l2csp1103297wrn; Thu, 30 Nov 2023 12:22:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEiydxgR/5tBFG5ADbRlGUYPGHxWExUrDthjISCD5n5JfdW8+n+EMax5MxhSPTVldW68xd X-Received: by 2002:a05:6a20:548e:b0:18c:8d0f:a794 with SMTP id i14-20020a056a20548e00b0018c8d0fa794mr16801036pzk.19.1701375776680; Thu, 30 Nov 2023 12:22:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701375776; cv=none; d=google.com; s=arc-20160816; b=I/jVWCk8Sh85j18qDqbyFzJ5YDWvosShfR5J8lxMnCp7hoDp4cFAXva2kk+Lo2lVLf yfE/TSchoCaafyoLnOVAinNhpYPLGFftai8x1YMdT/747W5KVlfvYOG8wLUoi/ElVMbr w1pYML2Vu6K1R8hCrN5WeOk5Hnn3HIWTmYFKSyKu5/51kG+iXxDZq4V9q9MqOIMcvBA1 2wDirvaIJcPCo/ED2LCuV5EdkHAo89tpOZpiM0WHavkdBCKbLW28WsZz7Mpawvi4ADIC 16FFeC+SsJXENP08uuzyZLo7Ff2FcI1t5Utk8T6hONPcrWJaoUhyT7/TrG/9aqjW6wQA 2GcQ== 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=h5xrnR+voR0lzTU912ok/GgXW3KeYZlPIjqgluxKI2NhHT6Bs66KZSHZhGhfF3kuN4 YxiHgKphxF2aEPGWrOG4IFykyKBKopy8azyy4UpMDWEG8re2cLR2YyC0khBhOn1UzTFT ReKosSYkDAvy5qzshN644rv4qG+XGOvLQSMHhPIw5o+hYSr+f5Q5IsT1KByHAka24E/N l17YM9nra6N/Stavsjgm6ytElUsukxqDGlK/5Cxx1FYQ52VOhzM9cirhW5ydjDyRBA/O v0r2QKwZGmre9VIUdZW/qGw7qrW6TVXpef3LK4XKvGE8tTuy8AB6nfXzPUyo+jjIT6Cz TzYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AWicY+bQ; 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 fi5-20020a056a00398500b006cddefd2031si1976208pfb.37.2023.11.30.12.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:56 -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=AWicY+bQ; 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 4E4F4876F1; Thu, 30 Nov 2023 21:22:52 +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="AWicY+bQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AF4E6876F1; Thu, 30 Nov 2023 21:22:50 +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-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) (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 C6C2A876B0 for ; Thu, 30 Nov 2023 21:22:48 +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-x32a.google.com with SMTP id 5b1f17b1804b1-40838915cecso13046095e9.2 for ; Thu, 30 Nov 2023 12:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701375768; x=1701980568; 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=AWicY+bQHNxxzWPUF8jZ8gALpupdVkUYIsWz82zEbuj0ZFEjY9W+APvhc/X+6E6tY2 oI+BO+cE/J66DJoofUaDOZZze739uoE7KN79rZ99NNR2KptYBxX/5jvZOan25WDg0rya amSl9mUrOd1dRhRB1O/ITVrDEm9HkPEQBbKSSt6pzheMGipgnJySMi2d1CZ7JrC3lt3F JbeKPqHDOb2xQujEPtzAaokk3a/ZUzuwrrUbJsQRWMZpFKNJBTldubVrLt51OU3HYRrd cVz0NUz//LZ+i+pcVEJaWbXoE0+7zwBOU5yQLARX6+ftySPWO98wZzWUCLObZHOtQK58 zPjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701375768; x=1701980568; 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=pnkRs6LLI6j90G+bgRSti1X0cykhXnapOxH/ocPRRQa97Nf9CzLjSVvw0RRZPof/x1 d6IUkFf0VWrG1PyKtwJW+2YCq8ByW/+PbsKMpNWXOablWGBVEBBE0+p/6ek25qjiGbO2 Kj7rtXH6ENetra77bGpYxAZhUT3ztVu4tXxhFZ+z0ezJpoiiluzUFJvwfQnBmfjUSQ/g 9itAOzaSsnL2h34qFqhsB1wEwVuIfyEXbUpuqg57e+cTzKZqLaaepTKiKc9XPSU4Eldl NCeds4um7PGutxO7EXClUn5XZmYM6aAWNlujDNDFeN1R6EzTXJl6z+6Cr5X2teyRB/e0 gBZw== X-Gm-Message-State: AOJu0YzrKngqZgTEmtT4on6RSIlHQAY0gHOM930VoPjLtmgjs8HAHWSZ eEHz3EpIJXJAIITEvWA2UdiduQ== X-Received: by 2002:a7b:ce90:0:b0:40b:5e59:da7e with SMTP id q16-20020a7bce90000000b0040b5e59da7emr32233wmj.145.1701375768312; Thu, 30 Nov 2023 12:22:48 -0800 (PST) Received: from lion.localdomain ([79.79.179.141]) by smtp.gmail.com with ESMTPSA id fa23-20020a05600c519700b003fee6e170f9sm3028900wmb.45.2023.11.30.12.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:22:47 -0800 (PST) From: Caleb Connolly Date: Thu, 30 Nov 2023 20:22:25 +0000 Subject: [PATCH v5 1/9] gpio: qcom_pmic: fix silent dev_read_addr downcast MIME-Version: 1.0 Message-Id: <20231130-b4-qcom-dt-compat-v5-1-41500e237ad0@linaro.org> References: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@linaro.org> In-Reply-To: <20231130-b4-qcom-dt-compat-v5-0-41500e237ad0@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=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSM96I7Il6oJIRYW8yyjbxm571qqdiKlym9+V/33T2tH zDJcKl7RykLgyAHg6yYIov4iWWWTWsv22tsX3ABZg4rE8gQBi5OAZhIWjIjw9Rf688+miActOxT 7tejDUejriw/PnGb8NntCTzlmiZVX2Yx/K+9c79zrsdpuVmKLE4bQ0LlHhbFy35/+16Mf+OLnMQ SjSAA 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 Reviewed-by: Neil Armstrong --- 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)