From patchwork Sun Jun 11 01:36:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 691551 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 E8121C77B7A for ; Sun, 11 Jun 2023 01:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbjFKBnE (ORCPT ); Sat, 10 Jun 2023 21:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjFKBnD (ORCPT ); Sat, 10 Jun 2023 21:43:03 -0400 X-Greylist: delayed 348 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 10 Jun 2023 18:43:01 PDT Received: from 9.mo583.mail-out.ovh.net (9.mo583.mail-out.ovh.net [178.32.96.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7AFCF9 for ; Sat, 10 Jun 2023 18:43:01 -0700 (PDT) Received: from director2.ghost.mail-out.ovh.net (unknown [10.108.20.172]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 00B7D250D5 for ; Sun, 11 Jun 2023 01:37:10 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-kbn2q (unknown [10.111.172.215]) by director2.ghost.mail-out.ovh.net (Postfix) with ESMTPS id A44391FD48; Sun, 11 Jun 2023 01:37:09 +0000 (UTC) Received: from etezian.org ([37.59.142.95]) by ghost-submission-6684bf9d7b-kbn2q with ESMTPSA id TTG8JEUlhWSDHQoAzNwXuw (envelope-from ); Sun, 11 Jun 2023 01:37:09 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-95G001b0d3709a-d66c-403f-a71d-a9678c160044, 457C5B0377F35283987BC361B5457E8A7F11D0C4) smtp.auth=andi@etezian.org X-OVh-ClientIp: 93.66.31.89 From: Andi Shyti To: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Andi Shyti Subject: [PATCH 1/3] i2c: busses: i2c-nomadik: Remove unnecessary goto label Date: Sun, 11 Jun 2023 03:36:59 +0200 Message-Id: <20230611013701.1464025-2-andi.shyti@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230611013701.1464025-1-andi.shyti@kernel.org> References: <20230611013701.1464025-1-andi.shyti@kernel.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 2685834230988999239 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgeduuddggeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughiucfuhhihthhiuceorghnughirdhshhihthhisehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvghrnhepgfduveejteegteelhfetueetheegfeehhfektddvleehtefhheevkeduleeuueevnecukfhppeduvdejrddtrddtrddupdelfedrieeirdefuddrkeelpdefjedrheelrddugedvrdelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegrnhguihesvghtvgiiihgrnhdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqihdvtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheekfedpmhhouggvpehsmhhtphhouhht Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The err_no_mem goto label doesn't do anything. Remove it. Signed-off-by: Andi Shyti --- drivers/i2c/busses/i2c-nomadik.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 5004b9dd98563..8b9577318388e 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -971,10 +971,9 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) u32 max_fifo_threshold = (vendor->fifodepth / 2) - 1; dev = devm_kzalloc(&adev->dev, sizeof(*dev), GFP_KERNEL); - if (!dev) { - ret = -ENOMEM; - goto err_no_mem; - } + if (!dev) + return -ENOMEM; + dev->vendor = vendor; dev->adev = adev; nmk_i2c_of_probe(np, dev); @@ -995,30 +994,27 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) dev->virtbase = devm_ioremap(&adev->dev, adev->res.start, resource_size(&adev->res)); - if (!dev->virtbase) { - ret = -ENOMEM; - goto err_no_mem; - } + if (!dev->virtbase) + return -ENOMEM; dev->irq = adev->irq[0]; ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0, DRIVER_NAME, dev); if (ret) { dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq); - goto err_no_mem; + return ret; } dev->clk = devm_clk_get(&adev->dev, NULL); if (IS_ERR(dev->clk)) { dev_err(&adev->dev, "could not get i2c clock\n"); - ret = PTR_ERR(dev->clk); - goto err_no_mem; + return PTR_ERR(dev->clk); } ret = clk_prepare_enable(dev->clk); if (ret) { dev_err(&adev->dev, "can't prepare_enable clock\n"); - goto err_no_mem; + return ret; } init_hw(dev); @@ -1049,7 +1045,6 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) err_no_adap: clk_disable_unprepare(dev->clk); - err_no_mem: return ret; } From patchwork Sun Jun 11 01:37:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 692342 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 D36E5C7EE2F for ; Sun, 11 Jun 2023 01:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbjFKBhS (ORCPT ); Sat, 10 Jun 2023 21:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjFKBhR (ORCPT ); Sat, 10 Jun 2023 21:37:17 -0400 Received: from 10.mo561.mail-out.ovh.net (10.mo561.mail-out.ovh.net [87.98.165.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1A672D41 for ; Sat, 10 Jun 2023 18:37:14 -0700 (PDT) Received: from director6.ghost.mail-out.ovh.net (unknown [10.108.16.177]) by mo561.mail-out.ovh.net (Postfix) with ESMTP id 3DFC622EAC for ; Sun, 11 Jun 2023 01:37:13 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-k74kh (unknown [10.110.208.213]) by director6.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 9B7BB1FDF5; Sun, 11 Jun 2023 01:37:11 +0000 (UTC) Received: from etezian.org ([37.59.142.99]) by ghost-submission-6684bf9d7b-k74kh with ESMTPSA id grODI0clhWT1gwoAM1KJvg (envelope-from ); Sun, 11 Jun 2023 01:37:11 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-99G00307afac82-1ce9-4646-8f23-06c3426a4ec5, 457C5B0377F35283987BC361B5457E8A7F11D0C4) smtp.auth=andi@etezian.org X-OVh-ClientIp: 93.66.31.89 From: Andi Shyti To: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Andi Shyti Subject: [PATCH 2/3] i2c: busses: nomadik: Use devm_clk_get_enabled() Date: Sun, 11 Jun 2023 03:37:00 +0200 Message-Id: <20230611013701.1464025-3-andi.shyti@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230611013701.1464025-1-andi.shyti@kernel.org> References: <20230611013701.1464025-1-andi.shyti@kernel.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 2686678655319935559 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgeduuddggeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughiucfuhhihthhiuceorghnughirdhshhihthhisehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvghrnhepgfduveejteegteelhfetueetheegfeehhfektddvleehtefhheevkeduleeuueevnecukfhppeduvdejrddtrddtrddupdelfedrieeirdefuddrkeelpdefjedrheelrddugedvrdelleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoegrnhguihesvghtvgiiihgrnhdrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqihdvtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheeiuddpmhhouggvpehsmhhtphhouhht Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Replace the pair of functions, devm_clk_get() and clk_prepare_enable(), with a single function devm_clk_get_enabled(). Signed-off-by: Andi Shyti --- drivers/i2c/busses/i2c-nomadik.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 8b9577318388e..2141ba05dfece 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -1005,18 +1005,12 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) return ret; } - dev->clk = devm_clk_get(&adev->dev, NULL); + dev->clk = devm_clk_get_enabled(&adev->dev, NULL); if (IS_ERR(dev->clk)) { - dev_err(&adev->dev, "could not get i2c clock\n"); + dev_err(&adev->dev, "could enable i2c clock\n"); return PTR_ERR(dev->clk); } - ret = clk_prepare_enable(dev->clk); - if (ret) { - dev_err(&adev->dev, "can't prepare_enable clock\n"); - return ret; - } - init_hw(dev); adap = &dev->adap; @@ -1037,16 +1031,11 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) ret = i2c_add_adapter(adap); if (ret) - goto err_no_adap; + return ret; pm_runtime_put(&adev->dev); return 0; - - err_no_adap: - clk_disable_unprepare(dev->clk); - - return ret; } static void nmk_i2c_remove(struct amba_device *adev) @@ -1060,7 +1049,6 @@ static void nmk_i2c_remove(struct amba_device *adev) clear_all_interrupts(dev); /* disable the controller */ i2c_clr_bit(dev->virtbase + I2C_CR, I2C_CR_PE); - clk_disable_unprepare(dev->clk); release_mem_region(res->start, resource_size(res)); } From patchwork Sun Jun 11 01:37:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 691552 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 41939C7EE29 for ; Sun, 11 Jun 2023 01:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbjFKBhS (ORCPT ); Sat, 10 Jun 2023 21:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjFKBhR (ORCPT ); Sat, 10 Jun 2023 21:37:17 -0400 Received: from 10.mo561.mail-out.ovh.net (10.mo561.mail-out.ovh.net [87.98.165.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A95DC2D44 for ; Sat, 10 Jun 2023 18:37:15 -0700 (PDT) Received: from director6.ghost.mail-out.ovh.net (unknown [10.109.146.166]) by mo561.mail-out.ovh.net (Postfix) with ESMTP id 39AEC23384 for ; Sun, 11 Jun 2023 01:37:14 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-mx8lq (unknown [10.111.172.114]) by director6.ghost.mail-out.ovh.net (Postfix) with ESMTPS id DF9631FDF5; Sun, 11 Jun 2023 01:37:13 +0000 (UTC) Received: from etezian.org ([37.59.142.109]) by ghost-submission-6684bf9d7b-mx8lq with ESMTPSA id FlwkNUklhWSwAgAA59J6Zg (envelope-from ); Sun, 11 Jun 2023 01:37:13 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-109S003fc1a52dc-a023-4c56-b5f9-7471cd84b6a3, 457C5B0377F35283987BC361B5457E8A7F11D0C4) smtp.auth=andi@etezian.org X-OVh-ClientIp: 93.66.31.89 From: Andi Shyti To: Linus Walleij Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, Andi Shyti Subject: [PATCH 3/3] i2c: busses: nomadik: Use dev_err_probe() whenever possible Date: Sun, 11 Jun 2023 03:37:01 +0200 Message-Id: <20230611013701.1464025-4-andi.shyti@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230611013701.1464025-1-andi.shyti@kernel.org> References: <20230611013701.1464025-1-andi.shyti@kernel.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 2686960131119516231 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrgeduuddggeehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptehnughiucfuhhihthhiuceorghnughirdhshhihthhisehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvghrnhepgfduveejteegteelhfetueetheegfeehhfektddvleehtefhheevkeduleeuueevnecukfhppeduvdejrddtrddtrddupdelfedrieeirdefuddrkeelpdefjedrheelrddugedvrddutdelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeorghnughisegvthgviihirghnrdhorhhgqedpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhivdgtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehiedupdhmohguvgepshhmthhpohhuth Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Make use of dev_err_probe() in order to simplify the code and avoid printing when returning EPROBE_DEFER. Signed-off-by: Andi Shyti --- drivers/i2c/busses/i2c-nomadik.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 2141ba05dfece..1e5fd23ef45c3 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -1000,16 +1000,14 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) dev->irq = adev->irq[0]; ret = devm_request_irq(&adev->dev, dev->irq, i2c_irq_handler, 0, DRIVER_NAME, dev); - if (ret) { - dev_err(&adev->dev, "cannot claim the irq %d\n", dev->irq); - return ret; - } + if (ret) + return dev_err_probe(&adev->dev, ret, + "cannot claim the irq %d\n", dev->irq); dev->clk = devm_clk_get_enabled(&adev->dev, NULL); - if (IS_ERR(dev->clk)) { - dev_err(&adev->dev, "could enable i2c clock\n"); - return PTR_ERR(dev->clk); - } + if (IS_ERR(dev->clk)) + return dev_err_probe(&adev->dev, PTR_ERR(dev->clk), + "could enable i2c clock\n"); init_hw(dev);