From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] Myson MTP008 driver ported to 2.6 kernel
Date: Wed, 05 Oct 2005 21:46:45 +0000 [thread overview]
Message-ID: <20051005214556.3b50a1ea.khali@linux-fr.org> (raw)
In-Reply-To: <20051004125511.GI7154@kira.glasswings.com.au>
Hi Andrew,
> On Wed, Oct 05, 2005 at 05:12:12PM +0200, Jean Delvare wrote:
> > > #define SENS_FROM_REG(val) ((val) = 0 ? 0 : ((val) ^ 0x03))
> > > #define SENS_TO_REG(val) SENS_FROM_REG(val)
> >
> > This looks like a trick. Don't use tricks. You're really not saving
> > anything, but are increasing the chances that a bug sneaks in.
>
> OK, these are two alternatives:
>
> #define SENS_FROM_REG(val) ((val) = 0 ? 0 : (1 - (val - 1)) + 1)
>
> #define SENS_FROM_REG(val) ((val) = 0 ? 0 : (val) = 1 ? 2 : 1)
>
> Do you really find either of these more readable? I don't.
I tend to prefer the second one, a matter of personnal taste I presume.
But actually, it would probably be much better to simply not use macros
for these conversions. This would certainly result in more readable and
more efficient code.
> This code is also clearly commented:
>
> /* sysfs temperature sensor types mtp008 sensor types
> * 0: Not defined 0: Analog input (voltage)
> * 1: PII/Celeron Diode 2: PII Diode
> * 2: 3904 transistor 1: Thermistor
Thanks for documenting it, this is helpful. Now that I pay more
attention to this though, it doesn't look correct to me. In the
standard sysfs convention, thermisor is 3, not 2. So you should convert
MTP008's type 1 to 3, not 2. Additionally, note that using type 0 for
analog input is not totally conform to the sysfs standard. Type 0 means
that the temperature input it disabled and unused, *not* that it is
used for something different. This is the reason why I would prefer
that we trust the BIOS settings and don't allow pin function change at
runtime at all.
Anyway, this is just a suggestion, I leave the final decision to Helge
or anyone actually working on the code. As long as the code is correct,
fine with me.
Thanks,
--
Jean Delvare
next prev parent reply other threads:[~2005-10-05 21:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-04 14:56 [lm-sensors] Myson MTP008 driver ported to 2.6 kernel Andrew Pam
2005-10-04 21:37 ` Jean Delvare
2005-10-05 12:04 ` Andrew Pam
2005-10-05 13:32 ` Helge Bahmann
2005-10-05 15:25 ` Andrew Pam
2005-10-05 17:22 ` Jean Delvare
2005-10-05 18:41 ` Andrew Pam
2005-10-05 18:48 ` Andrew Pam
2005-10-05 18:51 ` Andrew Pam
2005-10-05 19:25 ` Tonu Samuel
2005-10-05 20:46 ` Jean Delvare
2005-10-05 21:46 ` Jean Delvare [this message]
2005-10-06 11:09 ` Andrew Pam
2005-10-06 11:13 ` Andrew Pam
2005-10-06 11:57 ` Jean Delvare
2005-10-06 12:20 ` Jean Delvare
2005-10-06 16:02 ` Andrew Pam
2005-10-09 20:03 ` Andrew Pam
2006-05-24 7:20 ` Andrew Pam
2006-05-24 8:39 ` Helge Bahmann
2006-05-24 12:57 ` Andrew Pam
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=20051005214556.3b50a1ea.khali@linux-fr.org \
--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.