From patchwork Mon Nov 4 21:43:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 13862133 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5B5FD111B8 for ; Mon, 4 Nov 2024 21:46:21 +0000 (UTC) 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=/4tmB1crXrQeW2xb2p4HQOS59dYvDstelXee2aLIlks=; b=UsU0vQpCKR9kV9+F53yl5F6fWX Thk53fQD9novxkg0wVlJnPKLiY67fmSSxrpfP5zhBbTZMBRU67T3VasDtI5H92Ku3BJ5ywQFkmCOC f7g74bz/PcDuvTV9Wk49GjPFnXiwIoldrmFxhmRNKOtIjolsA9vgPp7YECIJM8kzadtUowivGwP8T AZrbYXw/lj9tshq91gnqH9GFWdF/GAoQbHn+X+HhfgOqfqh188iPLDbao7SgLnDBfqNynnBS+DN+C uGv1+trGIPw3L+B0EClemcmO4vgo4LwQDKL5fPqKZCATPtSbsoLZl6ClsHqfsN6KYSDIlA3nJmvzi JUEIIUCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t84tm-0000000FDKS-2JKV; Mon, 04 Nov 2024 21:46:10 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t84r3-0000000FCtA-3FJS; Mon, 04 Nov 2024 21:43:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=/4tmB1crXrQeW2xb2p4HQOS59dYvDstelXee2aLIlks=; b=NcVkjO+XlpVfFsHODDo1D0stFq CxKDkYvnX/YwTeDRHzXFD1w9nRNVRlo8KjrhckKYhlLx/JsIkGhJEK2Rk1WXmG2WIL/ugTBd7H1nj 8MhZVV5sRYuClMut4U3ui0Ge+3YL1lcU6XbQaUlx6bQf/Hm70SPret0lLoyHqtWhbBrlMsOStAyMq QKI95bRjotpZ5dFplLfG+eXN41K03G7bLgKj6JEzKf8Kwarb2Vj/WbT7OeJdPRDK7H9A5F8TqKdJ2 LXQmF5dBGYUbGrndlqXOiGgSdgB4YreXDi3+4slRmYIxnVl1x76h7yMnc0qtgHjtduSObTzMt09VL HMnrczVg==; Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t84r0-0000000BaJh-2E4f; Mon, 04 Nov 2024 21:43:20 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-6cbe9914487so33311236d6.1; Mon, 04 Nov 2024 13:43:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730756594; x=1731361394; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/4tmB1crXrQeW2xb2p4HQOS59dYvDstelXee2aLIlks=; b=RQYD7tJ1+VCrbQhuHxETdHT11bEXswcWrfkodlCufWg2sh3feebEamtKiABCVLmbFP reUTbr4bvMWgEXNrwnQ8Pqtj7lwIwQhsYlCQW8QVis2gq/4NNhWQ7HRVTov+gjRremlL N6qmPpY5U1LN7D5DcUG+K/fyylGBovZsRJiXQsTroM0SH3/YaswwutH9woydbT6Uce0m QrSdQ8sS0ie7Xi49qtN0pISG2ka/2Kn/LVv5xUl0kUnA/cW/Cwhtzd8/omEU2Ne2LM+W gfzUZ1sI3+241lW1EMyQ7S0yTox1+O22DmwWogmjJFtGOZVAjk95OeHZRgBqJkgzpRlP gbLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730756594; x=1731361394; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/4tmB1crXrQeW2xb2p4HQOS59dYvDstelXee2aLIlks=; b=Zd0bQYEZTq2NmRoQDYtHmWLF+/3BFRE9YuBSgEuauoC3Z86CwXrgj0JwlG+cx+OUpE q6dIP8mmvGLuCUJGE5d+VSydUpJ1bcO+fPZIMHjzbGZ195m2b82KyhpwipSFIyOeXqM/ b1QmbhObtGKXnDhfBtDy1uwfU0QJo6yJRXPxtbmRLlB2ZPjEdjoC2LlaLiipx+SNwnvg 8Y+BOcn5Jm5FbsxMYhKXR4guq5qfDxxRQmna9nIQ5225XNagSvQS1YdgGldNpGlwhJJ4 sjwaclXIHQdBEl+Q2pRH3QVqAzdy6FBODHGhABKn5f1bwlEF39DcB2JizLoHRnxV1LP+ +zUw== X-Forwarded-Encrypted: i=1; AJvYcCWIBG4youB9vZAA22Edmbu4dQNa8DoCJlm8fVCPq/kdnem8ud9tVnSxyHkOcww1tbAhl1ggwOc/ULVextD6Hg==@lists.infradead.org X-Gm-Message-State: AOJu0YxoFw5/hGlb73rvB4ppD7XB6cSdtSmU7I/DwfVGLWv81PajdQR/ JTpplYBKp7YuhzHJL77Mf2/zjXM3jf43p+l6FW2+6tp8+2YUdYDx X-Google-Smtp-Source: AGHT+IHiD08rBdxTtb8aWm9tjEu6W9aqyM2twM5OiMs1ouAVCkDkPquU7pdY0W4uFRX0AKoynB85Ww== X-Received: by 2002:a05:6214:3386:b0:6cb:fa1c:87da with SMTP id 6a1803df08f44-6d351b2083emr248567506d6.38.1730756593883; Mon, 04 Nov 2024 13:43:13 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d35415b1edsm52553916d6.75.2024.11.04.13.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:43:13 -0800 (PST) From: Jiasheng Jiang To: rmk@dyn-67.arm.linux.org.uk, max.schwarz@online.de, dianders@chromium.org, david.wu@rock-chips.com, heiko@sntech.de, vz@mleia.com, andi.shyti@kernel.org, wsa@kernel.org, manabian@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH 1/3] i2c: lpc2k: Add check for clk_enable() Date: Mon, 4 Nov 2024 21:43:08 +0000 Message-Id: <20241104214310.6048-1-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_214318_867948_4BCCB23D X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add check for the return value of clk_enable() in order to catch the potential exception. Fixes: 3f9c37a0c9a5 ("i2c: lpc2k: add driver") Signed-off-by: Jiasheng Jiang --- drivers/i2c/busses/i2c-lpc2k.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-lpc2k.c b/drivers/i2c/busses/i2c-lpc2k.c index 9fb33cbf7419..ea9831f34cd6 100644 --- a/drivers/i2c/busses/i2c-lpc2k.c +++ b/drivers/i2c/busses/i2c-lpc2k.c @@ -442,8 +442,14 @@ static int i2c_lpc2k_suspend(struct device *dev) static int i2c_lpc2k_resume(struct device *dev) { struct lpc2k_i2c *i2c = dev_get_drvdata(dev); + int ret; + + ret = clk_enable(i2c->clk); + if (ret) { + dev_err(dev, "failed to enable clock: %d\n", ret); + return ret; + } - clk_enable(i2c->clk); i2c_lpc2k_reset(i2c); return 0; From patchwork Mon Nov 4 21:43:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 13862134 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0068D111B8 for ; Mon, 4 Nov 2024 21:48:03 +0000 (UTC) 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:References:In-Reply-To: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:List-Owner; bh=qOLycEB3fTB76jveJ6Ec3et2DfKHvs/Gj7ofAidlU2U=; b=eydTYvHNXkxo99MQ0nLeQ/8h6r CDh+XOy2JZ4ywF68ATfYCAZ23wddu+oHIMSYqDaolbXMY2v3aL/i5aPC8g24i6fWdiAGIY02xdZrx FszyQ3DdgxM1Hgxj3jYPtNPEowFpiFeiYpufeLF+ylT2VXgZ8TL+aMbU78h9x3T5zxmopjMRe8DyO 0Ap7O19ytIb9pZrQFQPJ9IrLv1uBefI92B5xEXqP2VCHr8ZZONhiElmQAfzl+wWtTcHEwUvyF0j+U RxsGNrmcSysTwftIPka1iXHhiUceVU0sooruBnpKUCnMKa3dTPxaNH/m2DxazfK/DaLtmgPaA1dZu kgtEBCvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t84vS-0000000FDVn-14hF; Mon, 04 Nov 2024 21:47:54 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t84r5-0000000FCtw-1bUd; Mon, 04 Nov 2024 21:43:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=qOLycEB3fTB76jveJ6Ec3et2DfKHvs/Gj7ofAidlU2U=; b=lr6txmaPVkCwe/RG63e7dqiS0C GGCWod32Bjy87DL1/SrSEghXmwvjQd1qP/LO122O97hS6sH4my2fOVt6xFy7hZ31SN7sRnkBYepJM txbfVBwbe7Utj7xFNphFsRUjSQgNTg53RCm2+yBeLP7sfjsxY8IenEXvMaHsm/xd2MbhcSPRhSrgp cIeOqB+p+u5qN2zJX65HO3A+BX2ii81AEKPw0r0mc/VF/IG4W0Jr6wqYmyFcC5ToBfbALnAVTFDGZ f3RJMPd4XG7/Mcq9XVKWZIDr3dc+/k2eyEBn4II8uJae83hUF605Et0ci+D+4Bqc3vUwtecgjFLIU +3lJwmTw==; Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by casper.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t84r1-00000001bX9-0bcd; Mon, 04 Nov 2024 21:43:22 +0000 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-5ebc1af8e91so2210015eaf.1; Mon, 04 Nov 2024 13:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730756595; x=1731361395; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qOLycEB3fTB76jveJ6Ec3et2DfKHvs/Gj7ofAidlU2U=; b=ge9MHd0pdCrMvl2pTD+g6UgPH4VQUoiesBBmIJfAiMXM4y82FCY6isj2sXODptLU8b PZcMddwDVoftH8X89L/ArYqFg+jJXYpxGZNYszlw07qtpfcSVcrF8+Jq/1qQPyn3iSg+ PSOEGL5QR+ARTMBMXoVIuUrEnBm1qEhp6gwwKVHrDYJ+bGtFdjt8Ta73CgIK6BZE3XoZ J/p+cmYAA0NogJ9OCMPs/l1vhBCFxNVRoi5w5ycV7rF9iwI0Jlaedjhc9ujaIlOL4gbF VrHhl/T4166JsIIhpB5uZm9peklZlpjb1qFUQlH2axKth8ZFUP+7rcB61HFDFCche6bg 8GWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730756595; x=1731361395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qOLycEB3fTB76jveJ6Ec3et2DfKHvs/Gj7ofAidlU2U=; b=f9kj6VeN5EkQuj0WqmQb+/Fr1urzHf1ooKGO/odpPzxXaC0Bsc76xLs51oyD1rXJea VdjOjRY8mgdIf7jVUMxw4ogu90c65K6QiEVgBNVlsMddLPOhJEu/aeRBShZDOt8nSkqb 2vL6v+AYSbe6DHWrP3fr2xZsZ4CGqDr4HXZVpPRSzZSRGuho81ympYe9D8ZTi0PRNIvT jUrkRdUG6ynUo44s9h1fpR9CltpcNmqWIt2xM9b6MrankkcGi5/GshuCDomJGfJalD29 sAMtyg3yGUg1KY8s97Yk7uEDvFw5nolFuubJ1YGWSh82aR7kI+sSFD8YZ7tIn6VTwuxt Tkeg== X-Forwarded-Encrypted: i=1; AJvYcCU2Jl1UY5ewgeIb+Qh7Gyleuf1yPmmc5YNud7NIt5mzdsAjJJxT9A/k4QagJBCB2QEzl5FO1xqGScern/jikA==@lists.infradead.org X-Gm-Message-State: AOJu0YzUHazvJy1i8afjLu7Nw1UZ8wnzrDSoSV5IM5o6kkAzigBA+09x LYsDcriWBj0p+qnMmSBBArIuBgxg8PToGaMrvWByBrf7Nx3bzElA X-Google-Smtp-Source: AGHT+IGnt1DbQccv8yv6iE45XBrqGyCFkNPY8U/R7NDQnyLk4H54QS9Fm7w3bkWhRyMLeNLeyX0P/A== X-Received: by 2002:a05:6358:7254:b0:1ad:10eb:cd39 with SMTP id e5c5f4694b2df-1c3f9f7979amr1635893255d.26.1730756595525; Mon, 04 Nov 2024 13:43:15 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d35415b1edsm52553916d6.75.2024.11.04.13.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:43:15 -0800 (PST) From: Jiasheng Jiang To: rmk@dyn-67.arm.linux.org.uk, max.schwarz@online.de, dianders@chromium.org, david.wu@rock-chips.com, heiko@sntech.de, vz@mleia.com, andi.shyti@kernel.org, wsa@kernel.org, manabian@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH 2/3] i2c: pxa: Add check for clk_enable() and clk_prepare_enable() Date: Mon, 4 Nov 2024 21:43:09 +0000 Message-Id: <20241104214310.6048-2-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104214310.6048-1-jiashengjiangcool@gmail.com> References: <20241104214310.6048-1-jiashengjiangcool@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_214319_866928_2E6B0C56 X-CRM114-Status: GOOD ( 12.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add check for the return values of clk_enable() and clk_prepare_enable() in order to catch the potential exceptions. Fixes: e7d48fa2b5fb ("[I2C] pxa: provide late suspend and early resume hooks") Fixes: c3cef3f3c07b ("[ARM] pxa: update pxa i2c driver to use clk support") Signed-off-by: Jiasheng Jiang --- drivers/i2c/busses/i2c-pxa.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 4d76e71cdd4b..1118a7f5c6bf 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -1503,7 +1503,11 @@ static int i2c_pxa_probe(struct platform_device *dev) i2c->adap.name); } - clk_prepare_enable(i2c->clk); + ret = clk_prepare_enable(i2c->clk); + if (ret) { + dev_err(&dev->dev, "failed to enable clock: %d\n", ret); + return ret; + } if (i2c->use_pio) { i2c->adap.algo = &i2c_pxa_pio_algorithm; @@ -1560,8 +1564,14 @@ static int i2c_pxa_suspend_noirq(struct device *dev) static int i2c_pxa_resume_noirq(struct device *dev) { struct pxa_i2c *i2c = dev_get_drvdata(dev); + int ret; + + ret = clk_enable(i2c->clk); + if (ret) { + dev_err(dev, "failed to enable clock: %d\n", ret); + return ret; + } - clk_enable(i2c->clk); i2c_pxa_reset(i2c); return 0; From patchwork Mon Nov 4 21:43:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 13862202 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DF4ED1CA09 for ; Mon, 4 Nov 2024 23:01:25 +0000 (UTC) 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:References:In-Reply-To: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:List-Owner; bh=gpEshnq6i6G+Np3ZVcF5ef21yjGyMRFFgjDXZD1qG8A=; b=323HkbW3+Mj/4wxzw2Dg69UfcO +QViX0DevPRa/VFytWFfR8odn+CB1wrpQQQIPDLdB1F4DNuQ0n6jV9WM1Bfu4vcanJbJwUEu+oYF9 dmoG+H5sXOfQ4SrfzyPXsr6He4E4xzrwMvNtUpggmGMskhg6EYfS1CkoU8tNLunMzEX4ZvTLOCQbj sCxMOO4a5qxYZ+nHwoFoMMI7qqXp7suxRVrZzobZm8TQo7s+sxO9uDxUDg46cWTh8ChGB16ON7Om3 xmCSwVNf9gjLeOhb6Khm43DWAhTK+HO99qu2RzYXJO/22jMhQVscLg50CMsL1vKcfNExf6ZsBS+bx EIEAPIWg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t864P-0000000FLTz-3fvy; Mon, 04 Nov 2024 23:01:13 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t84r5-0000000FCuB-2W53; Mon, 04 Nov 2024 21:43:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=gpEshnq6i6G+Np3ZVcF5ef21yjGyMRFFgjDXZD1qG8A=; b=QE2mZAIep+zRaWFM3y3Js8Gtnb pbTbxBiMzErkM7tQOFY1wSnnhlm1EsywqEO5CWocZsjX9MGfIbwiqexLwasaOGYO88Zbd5SYNAwst VJ7X17cQR/Ne8X/zS1AYO9yK66/2QJfjkmXXfS4sXOrgdIocEmUFpOWtZIL3aSpdZ+AxTQS4dIpt8 fLtjt1IGf5+SlELSbzLC8BJxOpKFfYjp1V5bhoMb8y4rnSX0zCe381fUV51cOidUy3XfJivmpSikN VYkh0gTwZQBz65NlZVFQ1/3Z31j3LQ7PG03KAelKTkY2rgF3ku+HMGLoTx+Hf414fF19wgNx7g2jN SIe9gLDA==; Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t84r2-0000000BaKF-1Dtm; Mon, 04 Nov 2024 21:43:22 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7b13fe8f4d0so333383385a.0; Mon, 04 Nov 2024 13:43:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730756597; x=1731361397; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gpEshnq6i6G+Np3ZVcF5ef21yjGyMRFFgjDXZD1qG8A=; b=YEg18+Lb+4OsheWy+xmuf6BU2jKlZa/t7Ww9AQq9R79a7Ax1FRpt7feZChZUuRNEEm OZMb9DmBkt99ezbJyKKO3T9D29U83xOvaGVQd+vnGNxN/y8kez0HjhMjhDHSlkOdH4zw sLKxG9QmcOeuBd3yZ/iT6jfMAqE5PjhjCU698PJiIXAUOeeKL1U0Z95Jb6MKXQEImbzT ktWPaPBG89bpJHnVdZ14ROWMlb3JDlE8Uq+9vrn6bS344SqqI1nhSb9GhJqJ10bFEkSG ODVRWfIzchsYJmfbt+UwrQREjpwNTmF3HfQOZiqawBDM12HA52PGCC8UYzBnUbapSaTb fWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730756597; x=1731361397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gpEshnq6i6G+Np3ZVcF5ef21yjGyMRFFgjDXZD1qG8A=; b=ThqaYRn3dyQNirOF3UvQmKuAt63d0e21j4t1H2Z1F9OytOGuhwL2Bt0lDn01mxb/FR NXtpUcmjKltcqwZh+c7MkTWGmu8AOFB2HyYKJmrOEHPw0n3UxfODX1yYS268L+h51WJS GjznMOOhN0JJc/aUguf5+Jks8u0rue8dP4UpAccbyW9b526QVOGT+Ujjfq76qqehOgqP Hg7w01CokBv1Mx9EZtiljsVtMnfzRiai9F8ZGJM5x0K8sX4RkjxLrD/jfxHZrHrfHsco JKeDqIlKf58QzWyZ9doB/DKQggflGsu7deFazORRrG3ANmn9fZbCLeoioACiMrXHzrA0 J7OA== X-Forwarded-Encrypted: i=1; AJvYcCWIwp0ztJYOfQtLmmsCj2P9MJ4VLB+SjyzRXnLCOhViLRxlqrs2W/3/CMyXFXwcXsugBLHUKI6NjS47KK/Dwg==@lists.infradead.org X-Gm-Message-State: AOJu0YzDozeLnHKgVT//CdfuTiDwEdASrolGA2rQbyUGat0A/fwdIslZ ZUcz9IgEAMRauLwLuX7icizphgz2EQaw9PPElr36TfD/Q4YKJu68 X-Google-Smtp-Source: AGHT+IES5Vzl7DJKtNHPJ7UmtrOwkZwfCRkFo15pFheXgrIEAUHkNDpzR2YA54jau7pQhc5lYfGEsQ== X-Received: by 2002:a05:6214:5f01:b0:6d1:7854:ab49 with SMTP id 6a1803df08f44-6d351a8f23bmr277872066d6.11.1730756597159; Mon, 04 Nov 2024 13:43:17 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d35415b1edsm52553916d6.75.2024.11.04.13.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:43:16 -0800 (PST) From: Jiasheng Jiang To: rmk@dyn-67.arm.linux.org.uk, max.schwarz@online.de, dianders@chromium.org, david.wu@rock-chips.com, heiko@sntech.de, vz@mleia.com, andi.shyti@kernel.org, wsa@kernel.org, manabian@gmail.com Cc: linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH 3/3] i2c: rk3x: Add check for clk_enable() Date: Mon, 4 Nov 2024 21:43:10 +0000 Message-Id: <20241104214310.6048-3-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104214310.6048-1-jiashengjiangcool@gmail.com> References: <20241104214310.6048-1-jiashengjiangcool@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_214320_416962_9920DEF1 X-CRM114-Status: GOOD ( 16.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add check for the return value of clk_enable() in order to catch the potential exception. Moreover, convert the return type of rk3x_i2c_adapt_div() into int and add the check. Fixes: 7e086c3fc2df ("i2c: rk3x: add i2c support for rk3399 soc") Fixes: 249051f49907 ("i2c: rk3x: handle dynamic clock rate changes correctly") Fixes: c41aa3ce938b ("i2c: rk3x: add driver for Rockchip RK3xxx SoC I2C adapter") Signed-off-by: Jiasheng Jiang --- drivers/i2c/busses/i2c-rk3x.c | 55 ++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 4ef9bad77b85..a4662b0dbd8c 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -871,7 +871,7 @@ static int rk3x_i2c_v1_calc_timings(unsigned long clk_rate, return ret; } -static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) +static int rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) { struct i2c_timings *t = &i2c->t; struct rk3x_i2c_calced_timings calc; @@ -883,7 +883,11 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) ret = i2c->soc_data->calc_timings(clk_rate, t, &calc); WARN_ONCE(ret != 0, "Could not reach SCL freq %u", t->bus_freq_hz); - clk_enable(i2c->pclk); + ret = clk_enable(i2c->pclk); + if (ret) { + dev_err(i2c->dev, "Can't enable bus clk for rk3399: %d\n", ret); + return ret; + } spin_lock_irqsave(&i2c->lock, flags); val = i2c_readl(i2c, REG_CON); @@ -904,6 +908,8 @@ static void rk3x_i2c_adapt_div(struct rk3x_i2c *i2c, unsigned long clk_rate) clk_rate / 1000, 1000000000 / t->bus_freq_hz, t_low_ns, t_high_ns); + + return 0; } /** @@ -942,19 +948,27 @@ static int rk3x_i2c_clk_notifier_cb(struct notifier_block *nb, unsigned long return NOTIFY_STOP; /* scale up */ - if (ndata->new_rate > ndata->old_rate) - rk3x_i2c_adapt_div(i2c, ndata->new_rate); + if (ndata->new_rate > ndata->old_rate) { + if (rk3x_i2c_adapt_div(i2c, ndata->new_rate)) + return NOTIFY_STOP; + } return NOTIFY_OK; case POST_RATE_CHANGE: /* scale down */ - if (ndata->new_rate < ndata->old_rate) - rk3x_i2c_adapt_div(i2c, ndata->new_rate); + if (ndata->new_rate < ndata->old_rate) { + if (rk3x_i2c_adapt_div(i2c, ndata->new_rate)) + return NOTIFY_STOP; + } + return NOTIFY_OK; case ABORT_RATE_CHANGE: /* scale up */ - if (ndata->new_rate > ndata->old_rate) - rk3x_i2c_adapt_div(i2c, ndata->old_rate); + if (ndata->new_rate > ndata->old_rate) { + if (rk3x_i2c_adapt_div(i2c, ndata->old_rate)) + return NOTIFY_STOP; + } + return NOTIFY_OK; default: return NOTIFY_DONE; @@ -1068,8 +1082,20 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, spin_lock_irqsave(&i2c->lock, flags); - clk_enable(i2c->clk); - clk_enable(i2c->pclk); + ret = clk_enable(i2c->clk); + if (ret) { + dev_err(i2c->dev, "Can't enable bus clk: %d\n", ret); + spin_unlock_irqrestore(&i2c->lock, flags); + return ret; + } + + ret = clk_enable(i2c->pclk); + if (ret) { + dev_err(i2c->dev, "Can't enable bus clk for rk3399: %d\n", ret); + clk_disable(i2c->clk); + spin_unlock_irqrestore(&i2c->lock, flags); + return ret; + } i2c->is_last_msg = false; @@ -1149,9 +1175,7 @@ static __maybe_unused int rk3x_i2c_resume(struct device *dev) { struct rk3x_i2c *i2c = dev_get_drvdata(dev); - rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk)); - - return 0; + return rk3x_i2c_adapt_div(i2c, clk_get_rate(i2c->clk)); } static u32 rk3x_i2c_func(struct i2c_adapter *adap) @@ -1365,9 +1389,12 @@ static int rk3x_i2c_probe(struct platform_device *pdev) } clk_rate = clk_get_rate(i2c->clk); - rk3x_i2c_adapt_div(i2c, clk_rate); + ret = rk3x_i2c_adapt_div(i2c, clk_rate); clk_disable(i2c->clk); + if (ret) + goto err_clk_notifier; + ret = i2c_add_adapter(&i2c->adap); if (ret < 0) goto err_clk_notifier;