From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C44E6C71153 for ; Tue, 29 Aug 2023 13:34:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236438AbjH2Nej (ORCPT ); Tue, 29 Aug 2023 09:34:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236208AbjH2Ndc (ORCPT ); Tue, 29 Aug 2023 09:33:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D5D2CCE; Tue, 29 Aug 2023 06:33:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E027C6574D; Tue, 29 Aug 2023 13:32:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21693C433CD; Tue, 29 Aug 2023 13:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693315956; bh=8BJat/PnflBGy2w/90xhTxQ3qWxwanl2fKWzgHIxuY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=htrP20m58TDxn/rMgMu01M+GIejvxVRGkXR/OlwBXw5WYsRptnoUMlSQGRulTAHJE MW7Y2cmddHebn2ExafjIsh//HZ4400+/gOpXJdmv6TLQ2XLYasqYCrlCCjRUGxJesm MD+O6Y1jBfI3jvdZnsclCpNt7w9IPQpmfROar3Qs1/UIXiK7nNVNfRzpTRWBkzH/o7 wed5StNis6mSsNDaPX/7p0A2aRj/J68neKHqSdpenrSTKupRtrQb5bnAh1xq+YMWkP 1BYCsQKKnbBWrIgc0Mctk5dON5v6+qx+g/eJRBeSyDoIPYMRjuHVHv2vnrLi5FD48s 0BgnuE5uv+ONg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Carlos Song , Dong Aisheng , Andi Shyti , Wolfram Sang , Sasha Levin , aisheng.dong@nxp.com, shawnguo@kernel.org, linux-i2c@vger.kernel.org, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 6.4 13/17] i2c: imx-lpi2c: return -EINVAL when i2c peripheral clk doesn't work Date: Tue, 29 Aug 2023 09:32:00 -0400 Message-Id: <20230829133211.519957-13-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230829133211.519957-1-sashal@kernel.org> References: <20230829133211.519957-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.4.12 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Carlos Song [ Upstream commit b610c4bbd153c2cde548db48559e170905d7c369 ] On MX8X platforms, the default clock rate is 0 if without explicit clock setting in dts nodes. I2c can't work when i2c peripheral clk rate is 0. Add a i2c peripheral clk rate check before configuring the clock register. When i2c peripheral clk rate is 0 and directly return -EINVAL. Signed-off-by: Carlos Song Acked-by: Dong Aisheng Reviewed-by: Andi Shyti Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-imx-lpi2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c index 4d24ceb57ee74..338171f76daf7 100644 --- a/drivers/i2c/busses/i2c-imx-lpi2c.c +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c @@ -209,6 +209,9 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx) lpi2c_imx_set_mode(lpi2c_imx); clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk); + if (!clk_rate) + return -EINVAL; + if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST) filt = 0; else -- 2.40.1