Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751383AbdHVFX2 (ORCPT ); Tue, 22 Aug 2017 01:23:28 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:58403 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751087AbdHVFX0 (ORCPT ); Tue, 22 Aug 2017 01:23:26 -0400 Subject: Re: [PATCH v2 2/3] i2c: davinci: Add PM Runtime Support To: Franklin S Cooper Jr , , , , , , , , , References: <20170816221715.15027-1-fcooper@ti.com> <20170816221715.15027-3-fcooper@ti.com> <8207a684-f010-ca82-baae-db06665f098e@ti.com> From: Sekhar Nori Message-ID: Date: Tue, 22 Aug 2017 10:52:39 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1975 Lines: 65 On Tuesday 22 August 2017 06:47 AM, Franklin S Cooper Jr wrote: > > > On 08/21/2017 04:05 AM, Sekhar Nori wrote: >> On Thursday 17 August 2017 03:47 AM, Franklin S Cooper Jr wrote: >> >>> @@ -802,7 +821,6 @@ static int davinci_i2c_probe(struct platform_device *pdev) >>> dev->clk = devm_clk_get(&pdev->dev, NULL); >>> if (IS_ERR(dev->clk)) >>> return PTR_ERR(dev->clk); >>> - clk_prepare_enable(dev->clk); >>> >>> mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); >>> dev->base = devm_ioremap_resource(&pdev->dev, mem); >>> @@ -811,6 +829,18 @@ static int davinci_i2c_probe(struct platform_device *pdev) >>> goto err_unuse_clocks; >> >> This goto is wrong now. There is no need to unwind the pm_runtime setup >> on a devm_ioremap_resource() failure. You can just return error here. > > Ok >> >>> } >>> >>> + pm_runtime_set_autosuspend_delay(dev->dev, >>> + DAVINCI_I2C_PM_TIMEOUT); >>> + pm_runtime_use_autosuspend(dev->dev); >>> + >>> + pm_runtime_enable(dev->dev); >>> + >>> + r = pm_runtime_get_sync(dev->dev); >>> + if (r < 0) { >>> + dev_err(dev->dev, "failed to runtime_get device: %d\n", r); >>> + goto err_unuse_clocks; >>> + } >>> + >>> i2c_davinci_init(dev); >>> >>> r = devm_request_irq(&pdev->dev, dev->irq, i2c_davinci_isr, 0, >>> @@ -849,10 +879,16 @@ static int davinci_i2c_probe(struct platform_device *pdev) >>> if (r) >>> goto err_unuse_clocks; >>> >>> + pm_runtime_mark_last_busy(dev->dev); >>> + pm_runtime_put_autosuspend(dev->dev); >>> + >>> return 0; >>> >>> err_unuse_clocks: >>> - clk_disable_unprepare(dev->clk); >>> + pm_runtime_dont_use_autosuspend(dev->dev); >>> + pm_runtime_put_sync(dev->dev); >>> + pm_runtime_disable(dev->dev); >>> + >>> dev->clk = NULL; >> >> This null setting of clk seems quite bogus and can be cleaned-up. > > Do you mean that I should just remove this line? Yes, and I noticed a similar line in at least one more place that can be removed as well. Thanks, Sekhar