From: Shiraz Hashim <shiraz.hashim@st.com>
To: viresh kumar <viresh.kumar@linaro.org>
Cc: <thierry.reding@avionic-design.de>,
<spear--sw-devel@lists.codex.cro.st.com>,
<linux-kernel@vger.kernel.org>, <spear-devel@list.st.com>
Subject: Re: [PATCH] pwm: add spear pwm driver support
Date: Fri, 19 Oct 2012 15:13:09 +0530 [thread overview]
Message-ID: <20121019094308.GC4185@localhost.localdomain> (raw)
In-Reply-To: <CAOh2x=kXu2EG4GFaW8HpSi=VFLvGEMEyeN_3L74wU2sfe1Z=uQ@mail.gmail.com>
Hi Viresh,
On Fri, Oct 19, 2012 at 12:23:08PM +0530, viresh kumar wrote:
> On Fri, Oct 19, 2012 at 11:29 AM, Shiraz Hashim <shiraz.hashim@st.com> 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 <shiraz.hashim@st.com> 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?
>
You are right. The code is un-necessarily disabling all pwms while trying to
enable the clock for those which are not enabled also.
> >> > + 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);
> ...
> }
It may not be required as pwms which are not enabled do not have
their clocks enabled. Hence, perhaps we can do following,
8<---------------------------
static int 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 *pwm = &pc->chip.pwms[i];
if (test_bit(PWMF_ENABLED, &pwm->flags)) {
spear_pwm_writel(pc, i, PWMCR, 0);
clk_disable(pc->clk);
}
}
/* clk was prepared in probe, hence unprepare it here */
clk_unprepare(pc->clk);
return pwmchip_remove(&pc->chip);
}
---------------------------->8
--
regards
Shiraz
next prev parent reply other threads:[~2012-10-19 9:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 11:28 Shiraz Hashim
2012-10-18 12:08 ` Thierry Reding
2012-10-18 13:29 ` Shiraz Hashim
2012-10-18 13:42 ` Thierry Reding
2012-10-18 18:05 ` viresh kumar
2012-10-18 17:41 ` viresh kumar
2012-10-19 5:59 ` Shiraz Hashim
2012-10-19 6:02 ` Viresh Kumar
2012-10-19 6:53 ` viresh kumar
2012-10-19 9:43 ` Shiraz Hashim [this message]
2012-10-19 9:45 ` Viresh Kumar
2012-10-19 10:01 ` Shiraz Hashim
2012-10-19 10:08 ` Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121019094308.GC4185@localhost.localdomain \
--to=shiraz.hashim@st.com \
--cc=linux-kernel@vger.kernel.org \
--cc=spear--sw-devel@lists.codex.cro.st.com \
--cc=spear-devel@list.st.com \
--cc=thierry.reding@avionic-design.de \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®