Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp676201rdb; Sat, 6 Jan 2024 04:48:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/ot4hSp8hBGo3BpEvZERKUw6nJ52d409IusWkzP/Jjvxg1/HIDWewJJwEBxkgPJkcmDr3 X-Received: by 2002:a05:6808:318a:b0:3ba:8e3:f4f4 with SMTP id cd10-20020a056808318a00b003ba08e3f4f4mr1479688oib.107.1704545338634; Sat, 06 Jan 2024 04:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704545338; cv=none; d=google.com; s=arc-20160816; b=TaB5WMxEH0syXYEUtWtFxObAt3612bHzgBdnrj4S9NWNsjs7dh8YokYv85DnsYVglm VSmIrfgf5O2UW+DtDyHC/pTN12gjZRF/+wejf5JunvvoKnoS8CwHRAnDDNh1PDjpS0Yo TzBzulD25AgGmMZ/lByIZKismhlxakGEeyDzpecQWRHxf9tz2hirxxTIhxlMDe+rJ2Rv TQX430hUTOFmu5YKZhvFGgzJjfWBeQ2wr52L7kI9iTJwuXigy/zAdKhwKnb69hUQ1yLu ZYot8lo1OoE67HkqAMnehr6uUsIGK4qQFm55JRqEcuaozUGDxdN8xY6D/akNMN9uQ420 +I1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=wMo3OL1UV9ggs46JbwA/uXhDsmPRILP1vW1vh9k8l3Y=; fh=gJUGQVAr7WkVTxEgyG1cF6DvBPfetwfoQYFQJEZbiYE=; b=fgovAW0B+U34XntmQhsuEEPckiha4givhH/Mu/XmWDcurleAwTralPTx2I5/N7BP8g ew7B1YdECBX9uH5vvVFYq+7vIp6m+paNQ/KOWZL2r2tMhxg2DPMyt+HR++HwwwbTU9Xj OOuAYAt/z1nRpmaWCv4vwqQ0LdG8Ofj6AgPzQxF9lTRen5vCo9nEmcjxyCILC4IE0wVy oR4msJcmHkKjcXcDinsWQYOdE/De3iyvmEtrxBvvQnO0stLa54V2vtlNqyvZrE5SRm9M 8oLVZhhI4ut4ccmAA0+UvbCHV25qed8JDvEZHQjep+nzyophAUqRDgePvC8Jq9mc0N5q ktjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=FSJLArIM; spf=pass (google.com: domain of linux-kernel+bounces-18575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ck25-20020a056a02091900b005cdff5da4f9si2937984pgb.456.2024.01.06.04.48.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 04:48:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=FSJLArIM; spf=pass (google.com: domain of linux-kernel+bounces-18575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 99288B22B68 for ; Sat, 6 Jan 2024 12:48:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C45FA748F; Sat, 6 Jan 2024 12:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="FSJLArIM" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.smtpout.orange.fr (smtp-19.smtpout.orange.fr [80.12.242.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5775A6FC8 for ; Sat, 6 Jan 2024 12:48:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id M66OrfxTUx8edM66OrYd6Z; Sat, 06 Jan 2024 13:48:37 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1704545317; bh=wMo3OL1UV9ggs46JbwA/uXhDsmPRILP1vW1vh9k8l3Y=; h=From:To:Cc:Subject:Date; b=FSJLArIMjWvmTKEo9wcC5fNVOSpcPdnq6T4CdnN/LQpV9xQ6rGRHCLfSWyob0lRTP uLwyVHoVsJlm0T8zPZTFwWjrUYh0pbIJrelo1xD7fnY92y5oI3PcPKYmOGYOeTtUxS j3NFrZchazAoZIjrXYpf3TdILkwJU/pDtFwKnqLGO9utncm1TRm8Zfp2gMuHDrFoIH 7nFyM1GSkhRGxZU9FG4XV9veJ8FfXE+AukCtEZXS9gw2HoiVY5UzLDIqGBVSnZGD+z Fy5VbmQm9pZGaIhr8bQ1v7j/e6a00Aw2Aa33TC5Y+nnGK7t/KAQcMbuu6KSMBEG8dj bp6GCUlGN2xbg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 06 Jan 2024 13:48:37 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: Ard Biesheuvel , Andi Shyti , Andy Shevchenko , Wolfram Sang Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-i2c@vger.kernel.org Subject: [PATCH 1/2] i2c: synquacer: Fix an error handling path in synquacer_i2c_probe() Date: Sat, 6 Jan 2024 13:48:24 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit If an error occurs after the clk_prepare_enable() call, it should be undone by a corresponding clk_disable_unprepare() call, as already done in the remove() function. As devm_clk_get() is used, we can switch to devm_clk_get_enabled() to handle it automatically and fix the probe. Update the remove() function accordingly and remove the now useless clk_disable_unprepare() call. Fixes: 0d676a6c4390 ("i2c: add support for Socionext SynQuacer I2C controller") Signed-off-by: Christophe JAILLET --- drivers/i2c/busses/i2c-synquacer.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c index bbea521b05dd..a73f5bb9a164 100644 --- a/drivers/i2c/busses/i2c-synquacer.c +++ b/drivers/i2c/busses/i2c-synquacer.c @@ -550,17 +550,13 @@ static int synquacer_i2c_probe(struct platform_device *pdev) device_property_read_u32(&pdev->dev, "socionext,pclk-rate", &i2c->pclkrate); - i2c->pclk = devm_clk_get(&pdev->dev, "pclk"); - if (PTR_ERR(i2c->pclk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - if (!IS_ERR_OR_NULL(i2c->pclk)) { - dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk); - - ret = clk_prepare_enable(i2c->pclk); - if (ret) - return dev_err_probe(&pdev->dev, ret, "failed to enable clock\n"); - i2c->pclkrate = clk_get_rate(i2c->pclk); - } + i2c->pclk = devm_clk_get_enabled(&pdev->dev, "pclk"); + if (IS_ERR(i2c->pclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(i2c->pclk), + "failed to get and enable clock\n"); + + dev_dbg(&pdev->dev, "clock source %p\n", i2c->pclk); + i2c->pclkrate = clk_get_rate(i2c->pclk); if (i2c->pclkrate < SYNQUACER_I2C_MIN_CLK_RATE || i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE) @@ -615,8 +611,6 @@ static void synquacer_i2c_remove(struct platform_device *pdev) struct synquacer_i2c *i2c = platform_get_drvdata(pdev); i2c_del_adapter(&i2c->adapter); - if (!IS_ERR(i2c->pclk)) - clk_disable_unprepare(i2c->pclk); }; static const struct of_device_id synquacer_i2c_dt_ids[] __maybe_unused = { -- 2.34.1