All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] PWMconfig problem with Asus P5B Deluxe / Winbond
Date: Sun, 18 Nov 2007 15:14:46 +0000	[thread overview]
Message-ID: <20071118161446.61ab72c6@hyperion.delvare> (raw)
In-Reply-To: <4dfa50520711142226r2e6d1c3fy229e05d4ca43d032@mail.gmail.com>

Hi Alexander, David,

On Fri, 16 Nov 2007 00:15:21 +0100, Alexander Kiel wrote:
> Hi David,
> 
> > I understand the problem now. In the w83627ehf driver, there is this code:
> > static ssize_t
> > store_pwm_enable(struct device *dev, struct device_attribute *attr,
> >                         const char *buf, size_t count)
> > 
> > ...
> > 
> >         if (!val || (val > 2))  /* only modes 1 and 2 are supported */
> >                 return -EINVAL;
> > 
> > That is the "write error: invalid argument" error. The reason this
> > code rejects a write of 0 to pwm_enable is because the w83627ehf does
> > not have a true "disable" mode. Some other chips will set the pwm
> > output to 100% when they are disabled. The w83627ehf doesn't have a
> > disable mode. Of course, setting it to manual and storing 255 in the
> > pwm would do the same thing.
> > 
> > That's what pwmconfig (lm_sensors version 2.10.4) does:
> >                 # Try pwmN_enable=0
> >                 echo 0 > $ENABLE 2> /dev/null
> >                 if [ "`cat $ENABLE`" -eq 0 ]
> >                 then
> >                         # Success
> >                         return 0
> >                 fi
> > 
> >                 # It didn't work, try pwmN_enable=1 pwmN%5
> >                 echo 1 > $ENABLE 2> /dev/null
> >                 echo $MAX > $1
> >                 if [ "`cat $ENABLE`" -eq 1 -a "`cat $1`" -ge 190 ]
> >                 then
> >                         # Success
> >                         return 0
> >                 fi

Note that the failure can be triggered by two conditions: pwmN_enable
not set to 1, or pwmN less than 190. In Alexander's case, pwmN_enable
has the expected value:

> hwmon0/device/pwm1_enable stuck to 1

Which means that the problem is that writing 255 to pwm1 did not work.
No idea why... I agree that the error message could be made clearer,
I'll improve it now.

> > 
> > So I *think* the problem is in pwmconfig. But yes, manually writing 0
> > to pwm_enable will give you an -EINVAL.
> > 
> > To be completely honest, I haven't run pwmconfig in a while. I know it
> > generally works, but someone should probably post a patch to get it to
> > work smoothly with w83627ehf and w83627dhg chips. (I could do that...
> > given lots of time :-)

It already works just fine for me. I am unable to reproduce Alexander's
problem.

> 
> Ok the problem with pwmconfig is the following:
> 
> echo 0 > $ENABLE 2> /dev/null outputs actually 0. This is the 0 from the
> echo. echo 3 > $ENABLE 2> /dev/null would output 3. I have no clue why
> this is the case.

How did you try that, on the command line? $ENABLE is a variable in the
pwmconfig script, on the command line it's undefined, so that can't
work. Your original report doesn't show any "0" printed on the screen.

> 
> This 0 causes the line echo $MAX > $1 to set pwm1 to 0 instead of 255.

I very much doubt it. Both statements are separate, I fail to see how
whatever the first one does could have any influence on the second.

> If I add a > /dev/null to the line echo 0 > $ENABLE 2> /dev/null it
> works as it should.
> 
> So the diff is:
> ----------------------------------------------------------------------
> 127c127
> <               echo 0 > $ENABLE > /dev/null 2> /dev/null
> ---
> >               echo 0 > $ENABLE 2> /dev/null
> ----------------------------------------------------------------------
> 
> Can you submit this patch? I don't have a reasonable access to the
> lm-sensors community.

This patch is not correct, it breaks pwmconfig more than it fixes it.

As explained above, the problem you have is not with setting
pwm1_enable to 1 (that works) but presumably with setting pwm1 to 255.
So you're trying to fix the wrong line of the script.

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2007-11-18 15:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-15  6:26 [lm-sensors] PWMconfig problem with Asus P5B Deluxe / Winbond David Hubbard
2007-11-15 11:08 ` Alexander Kiel
2007-11-15 19:41 ` David Hubbard
2007-11-15 23:15 ` Alexander Kiel
2007-11-16  0:24 ` David Hubbard
2007-11-16  0:41 ` Alexander Kiel
2007-11-16  0:59 ` David Hubbard
2007-11-18 15:14 ` Jean Delvare [this message]
2007-11-18 15:57 ` Alexander Kiel
2007-11-18 16:34 ` Jean Delvare
2007-11-18 17:10 ` Alexander Kiel
2007-11-18 20:09 ` Jean Delvare
2007-11-19  6:32 ` David Hubbard
2007-11-21 22:16 ` Jean Delvare

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=20071118161446.61ab72c6@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.