Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753226Ab2JSGxK (ORCPT ); Fri, 19 Oct 2012 02:53:10 -0400 Received: from mail-vc0-f174.google.com ([209.85.220.174]:33092 "EHLO mail-vc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750976Ab2JSGxJ (ORCPT ); Fri, 19 Oct 2012 02:53:09 -0400 MIME-Version: 1.0 In-Reply-To: <20121019055943.GA4185@localhost.localdomain> References: <1350559712-8514-1-git-send-email-shiraz.hashim@st.com> <20121019055943.GA4185@localhost.localdomain> Date: Fri, 19 Oct 2012 12:23:08 +0530 X-Google-Sender-Auth: L0HTjR0qbputBtkHP-9b8avNvEo Message-ID: Subject: Re: [PATCH] pwm: add spear pwm driver support From: viresh kumar To: Shiraz Hashim Cc: thierry.reding@avionic-design.de, spear--sw-devel@lists.codex.cro.st.com, linux-kernel@vger.kernel.org, spear-devel@list.st.com Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2254 Lines: 66 On Fri, Oct 19, 2012 at 11:29 AM, Shiraz Hashim wrote: > On Thu, Oct 18, 2012 at 11:11:06PM +0530, viresh kumar wrote: >> On Thu, Oct 18, 2012 at 4:58 PM, Shiraz Hashim wrote: >> > +static int __devexit spear_pwm_remove(struct platform_device *pdev) >> > +{ >> > + struct spear_pwm_chip *pc = platform_get_drvdata(pdev); >> > + int i; >> > + >> > + if (WARN_ON(!pc)) >> > + return -ENODEV; >> > + >> > + for (i = 0; i < NUM_PWM; i++) { >> > + struct pwm_device *pwmd = &pc->chip.pwms[i]; >> > + >> > + if (!test_bit(PWMF_ENABLED, &pwmd->flags)) One point here: If i am not wrong you want to disable pwmd if it is enabled. Shouldn't you check for if (test_bit(PWMF_ENABLED, &pwmd->flags)) instead? >> > + if (clk_prepare_enable(pc->clk) < 0) >> > + continue; >> > + >> > + spear_pwm_writel(pc, i, PWMCR, 0); >> > + clk_disable_unprepare(pc->clk); >> > + } >> >> You are enabling/disabling clock N times here and each of these will >> write to an register. Do something better. >> > > I need to shut down all active pwms, how else would you suggest that ? Sorry, i misread the code on the second go :( I am proposing something like: static int __devexit spear_pwm_remove(struct platform_device *pdev) { struct spear_pwm_chip *pc = platform_get_drvdata(pdev); int i, clk_enabled = 0; if (WARN_ON(!pc)) return -ENODEV; for (i = 0; i < NUM_PWM; i++) { struct pwm_device *pwmd = &pc->chip.pwms[i]; if (!test_bit(PWMF_ENABLED, &pwmd->flags) && !clk_enabled) if (clk_prepare_enable(pc->clk) < 0) continue; else clk_enabled++; spear_pwm_writel(pc, i, PWMCR, 0); } if (clk_enabled) clk_disable_unprepare(pc->clk); ... } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/