From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 15 Apr 2024 09:22:22 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rwGfW-001f6h-2K for lore@lore.pengutronix.de; Mon, 15 Apr 2024 09:22:22 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rwGfV-00073Z-It for lore@pengutronix.de; Mon, 15 Apr 2024 09:22:22 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=Ql/fBvp5SLPqpsBO6FbAmqMGyazo25/XnsYncYMND5A=; b=PKWFYmseOfLI5PX5XUfP6QCtxi mODGfebVB9HAmi7XnwimcT1K+Ugd3JfzFrjPmSMLUoY7vebYZ8ivCZnbYmB3LbtImVGQrMYVe5sh7 7KVgWjBf/qVuUiAqhDaS4jEA56VwZbVQyBgwl5NzVuO6Agd/eiugYL8doiAiIqqwnwAVvKaAWeFqG bPzuTTZ+/IjCvLAEKe5z/zzVcYyNqyILjOUWO61Y7NHx7LsuxBaDf/znWWfSuBU71YvDfC3z6tBxe 1hcKGoe7PQMO4HU8wx4Qf1OGhzhUMruk+X7fptmI2DseqFxrvyWL1MD9JJszqBHatIKFuFgP8YE5T jtktYzDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwGet-00000007JkT-1sNc; Mon, 15 Apr 2024 07:21:43 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwGeq-00000007Jk1-062L for barebox@lists.infradead.org; Mon, 15 Apr 2024 07:21:41 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rwGeo-0006Ed-3M; Mon, 15 Apr 2024 09:21:38 +0200 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rwGen-00CNfp-My; Mon, 15 Apr 2024 09:21:37 +0200 Received: from localhost ([::1] helo=dude05.red.stw.pengutronix.de) by dude05.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1rwGen-004W4J-20; Mon, 15 Apr 2024 09:21:37 +0200 From: Ahmad Fatoum To: barebox@lists.infradead.org Cc: Ahmad Fatoum Date: Mon, 15 Apr 2024 09:21:35 +0200 Message-Id: <20240415072135.1076571-1-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_002140_180913_D3CED017 X-CRM114-Status: GOOD ( 11.55 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-6.2 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH] pinctrl: rockchip: check for invalid pull settings X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) Commit e877582e9875 ("pinctrl: rockchip: fix bias settings") reinstated the translation done to pull settings via the bank->pull_type array, like the original Linux driver does. What it didn't do is actually check that the translation succeeded. Add this check to make sure we don't somehow end up packing a negative value into the bitset we write into the hardware. Signed-off-by: Ahmad Fatoum --- drivers/pinctrl/pinctrl-rockchip.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index c1e937ea2cb1..ca9939c9e91d 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2172,8 +2172,13 @@ static int rockchip_set_pull(struct rockchip_pin_bank *bank, if (ret == RK_BIAS_PULL_UP) ret = 3; } + if (ret < 0) { + dev_err(dev, "unsupported pull setting %d\n", pull); + return ret; + } + /* enable the write to the equivalent lower bits */ data = ((1 << RK3188_PULL_BITS_PER_PIN) - 1) << (bit + 16); rmask = data | (data >> 16); data |= (ret << bit); -- 2.39.2