From patchwork Thu Aug 2 20:17:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 1268081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 593F7DF223 for ; Thu, 2 Aug 2012 20:21:12 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sx1qP-00049R-Tj; Thu, 02 Aug 2012 20:18:05 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sx1qM-00049D-RW for linux-arm-kernel@lists.infradead.org; Thu, 02 Aug 2012 20:18:03 +0000 Received: by bkcji2 with SMTP id ji2so4662684bkc.36 for ; Thu, 02 Aug 2012 13:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type; bh=4MqBbgqQRYEX95mwDdvOkTsPe6XyxgO9TF6VlvGBTBE=; b=agrcLEJXaHCdn2E5kOmCqnjzUKyZFDYV9rPM/g/5wNwzeGpkemx2s2JO/gm59tdNyP G7GjOOv/DjEnK07kP2Nw+bMSAx01RGhEiXPSAuKTLEEMC06W3MOk3LhV6+kePE2OpRwY gQOBQUhGf+lQkNcLVsHp0JwpBWH0I96Wy+HtWOip+IhnaT+RMygnv/00hj8mljdGufEk Kkx7MM/GnPRrLfcy4ZOsYt8QIQ1OwdBIyOe5Soh/TNZGXp1rC8htwkFlx9RAZNjj5kwQ dDCpNrGD+iewplmsUzHeGHRhukPn3m2w560WjBtAkgHSbgvrZFW5RG5/3H+UR/YWzL76 H4jw== Received: by 10.204.152.207 with SMTP id h15mr8852315bkw.5.1343938681020; Thu, 02 Aug 2012 13:18:01 -0700 (PDT) Received: from [10.0.1.6] (i59F72AC4.versanet.de. [89.247.42.196]) by mx.google.com with ESMTPS id t23sm4004927bks.4.2012.08.02.13.17.58 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Aug 2012 13:17:59 -0700 (PDT) Message-ID: <501AE074.8090906@gmail.com> Date: Thu, 02 Aug 2012 22:17:56 +0200 From: Daniel Mack User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Russell King - ARM Linux Subject: Re: [PATCH 1/2] net: davinci_mdio: enable and disable clock References: <1343936616-29318-1-git-send-email-zonque@gmail.com> <20120802195308.GZ6802@n2100.arm.linux.org.uk> In-Reply-To: <20120802195308.GZ6802@n2100.arm.linux.org.uk> X-Enigmail-Version: 1.4.3 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zonque[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: mugunthanvnm@ti.com, paul@pwsan.com, netdev@vger.kernel.org, koen@dominion.thruhere.net, devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On 02.08.2012 21:53, Russell King - ARM Linux wrote: > On Thu, Aug 02, 2012 at 09:43:35PM +0200, Daniel Mack wrote: >> Make the driver control the device clocks. Appearantly, the Davinci >> platform probes this driver with the clock all powered up, but on OMAP, >> this isn't the case. > > Hmm, this looks like it could do with improvement, especially as we're > moving everything over to a common clk API. > > 1. This driver could do with clk_prepare()/clk_unprepare() calls. Ok, done. > 2. This driver should not be making the assumption that NULL means > it can avoid clk_* calls. It should instead be using > if (!IS_ERR(clk)) Well spotted. Amended patch below. Thanks, Daniel From 57670e52d19218f897d835d25223bf4b4932252f Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Thu, 2 Aug 2012 21:24:36 +0200 Subject: [PATCH] net: davinci_mdio: prepare and unprepare clocks Make the driver control the device clocks. Appearantly, the Davinci platform probes this driver with the clock all powered up, but on OMAP, this isn't the case. While at it, also check for IS_ERR(data->clk) in the bail_out: label of .probe(). Signed-off-by: Daniel Mack --- drivers/net/ethernet/ti/davinci_mdio.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index cd7ee20..462f81d 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -332,6 +332,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev) goto bail_out; } + clk_prepare(data->clk); + dev_set_drvdata(dev, data); data->dev = dev; spin_lock_init(&data->lock); @@ -379,8 +381,11 @@ bail_out: if (data->bus) mdiobus_free(data->bus); - if (data->clk) + if (data->clk && !IS_ERR(data->clk)) { + clk_unprepare(data->clk); clk_put(data->clk); + } + pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -397,8 +402,11 @@ static int __devexit davinci_mdio_remove(struct platform_device *pdev) if (data->bus) mdiobus_free(data->bus); - if (data->clk) + if (data->clk) { + clk_unprepare(data->clk); clk_put(data->clk); + } + pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); @@ -427,6 +435,8 @@ static int davinci_mdio_suspend(struct device *dev) data->suspended = true; spin_unlock(&data->lock); + clk_unprepare(data->clk); + return 0; } @@ -435,6 +445,8 @@ static int davinci_mdio_resume(struct device *dev) struct davinci_mdio_data *data = dev_get_drvdata(dev); u32 ctrl; + clk_prepare(data->clk); + spin_lock(&data->lock); pm_runtime_put_sync(data->dev); -- 1.7.11.2