Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2454372rdd; Fri, 12 Jan 2024 09:50:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IECG3ZDj2ubJTZcDrTLA9wdYh3lxTu9av2mVkxxk7zMwR2rTfXTNJF7blUO7Rd7K4pp5OGF X-Received: by 2002:a17:90a:488c:b0:28b:fb65:5385 with SMTP id b12-20020a17090a488c00b0028bfb655385mr1719913pjh.92.1705081841138; Fri, 12 Jan 2024 09:50:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705081841; cv=none; d=google.com; s=arc-20160816; b=BAZnZTbazjKY2ghIyAQXKf+P3T/F2HNZwyPsO1hXN+IqqwdM94xYFyB7cVP1U0xctI P6j2A/RGiwAcT9iRDsYuiNTMjsm+Pd8yHA9H3FH/7q9G1/p2ID9vOtxoeKRKFsZU8c33 LMYlWQgVPO9+NvawWHGpy8vPTuZviwpDSVc86ZoTb7Bsq5jwzlSWSk9awDSBn1CpV0+e pMimPyuo0xPk4IL1Vcq+MXwFLuzGYdPHUsqWe3/sT6LjDsUjMNpLDKC8LR2C+cqhRjur m+P+14veHj5CYc9kqr3BTboaYp8dgKgqksB1kwBi/lcZduNbPKYvK9lGBob0aenLnkja epyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=5QhDsspvIVowjj4/iLU2IUW5XFmjRiKkFU3WSnBz5NE=; fh=988SbUHXVhHAlL1PeA7LL9F+AE+WOKGni4BFZo0KgvU=; b=0GY0KJvcfFN6z8Q5pEE3PODBYdcjXsVTJ/LK7LhFQ93GNgZuLYiWnj9gzaD87mKuB3 feLjOJQVIkUukrtkqNB3xg8gh60YP7zfyo8KO/Y010wCZc4ac+2FQP0j4M2MMjpOxkuQ /CijYpZOVdTy9bshtun9nI573QsZ+b2HgjRyM5MmnDWrrHdRmqnZWu6DA8+iXdlFa6Vo FZ0Ncsa8jS1PIpGwLqS8chp0TdobTFwzopsbjcu2aEIvlzgIOJ1aB9BnK6VhAnS3qZYC AlMaGSTOBPLWkqqp6iCoZ9GyRv9CbI7SK7vsUtbQQoQefjwQnJRi+4VVrWRhWdx0dKCI Fcmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cG9A6iap; spf=pass (google.com: domain of linux-kernel+bounces-24939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h17-20020a17090ac39100b0028cad5040acsi6032152pjt.95.2024.01.12.09.50.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 09:50:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cG9A6iap; spf=pass (google.com: domain of linux-kernel+bounces-24939-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24939-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2021B28584E for ; Fri, 12 Jan 2024 17:50:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A24FD17C95; Fri, 12 Jan 2024 17:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cG9A6iap" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C697B2263D; Fri, 12 Jan 2024 17:50:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51F5FC433F1; Fri, 12 Jan 2024 17:50:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705081827; bh=GZ6Ouo8eQK4R+P9Tx4PS6afuH0vvh/IfABUDSekGxEc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cG9A6iaprfYQmCFxymyAp1BHAYy5u6lXTSHuuhHje9BJ7EzkKXOZjNGH38ptV2JCs IZKNF4mc/wZ6ydpJs4SfgNxoFbm4WPyiw0lN99FBG4D7j0shHoq7WitGNx3GfJ0Dm7 RcKOzr9zRvU+ldZUCjmSMsjaSqk4NnsKQeP1F2YszU0k93mB657HpKUqgxkkEGSkBD 8HGIUn3DJlktzGwYJQ+r8jAGayfH9glqjFUPlTqTjasTb7iQDgM0kC/zI4uuwKmdmb fl/nMZLa6zeJTqiEuaYNRr/ae22okqTfkD0VT/LT52+ymFoG8gNzpolvJlhNz1YUEp tehOsR3K/jhLA== Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-50e7ddd999bso7484252e87.1; Fri, 12 Jan 2024 09:50:26 -0800 (PST) X-Gm-Message-State: AOJu0YyjIshXF6pceUlYpruSe4JI9Gd6zHBW7r/EShXr+T1bBBIt4ndU zqIrBF2xSZNf48GN47dTK8Frh8lWWZgd4P0/hX4= X-Received: by 2002:a05:6512:39ca:b0:50e:a9c0:70ad with SMTP id k10-20020a05651239ca00b0050ea9c070admr1167312lfu.32.1705081824525; Fri, 12 Jan 2024 09:50:24 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Fri, 12 Jan 2024 18:50:13 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] i2c: synquacer: Fix an error handling path in synquacer_i2c_probe() To: Christophe JAILLET Cc: Andi Shyti , Andy Shevchenko , Wolfram Sang , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-i2c@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Sat, 6 Jan 2024 at 13:48, Christophe JAILLET wrote: > > 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 Acked-by: Ard Biesheuvel > --- > 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 >