From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] PATCH: hwmon-fscher-support-fscpos.patch
Date: Sat, 21 Jul 2007 20:48:33 +0000 [thread overview]
Message-ID: <20070721224833.52f6fc61@hyperion.delvare> (raw)
In-Reply-To: <46922D2E.60400@hhs.nl>
Hi Hans,
On Sun, 15 Jul 2007 11:40:34 +0200, Hans de Goede wrote:
> Despite you saying that the individual alarms patch should be split up I
> actually tried to make as little changes as possible. I'm not sure now if that
> is the best plan, these 2 drivers really need a cleanup, they also need dyn
> sysfs attr + handlers for example, but I wanted to safe that for later to keep
> the patches small / manageable.
And I thank you for that. Note that it's always easier to merge two
(incremental) patches afterwards than to split one patch afterwards ;)
> >> @@ -709,8 +756,14 @@ static ssize_t set_watchdog_control(stru
> >>
> >> static ssize_t show_watchdog_control(struct fscher_data *data, char *buf, int nr)
> >> {
> >> - /* bits 0..3 reserved, bit 5 write only => mask with 0xd0 */
> >> - return sprintf(buf, "%u\n", data->watchdog[2] & 0xd0);
> >> + u8 mask;
> >> +
> >> + if (data->kind = fscher)
> >> + mask = 0xd0; /* bits 0..3 reserved, 5 write only */
> >> + else
> >> + mask = 0x90; /* bits 0..3 & 6 reserved, 5 write only */
> >
> > ... and 0xb0 here. Any reason why you use different values? If you
> > think the fscpos driver uses the wrong masks, please send a patch to
> > fix them.
> >
>
> Bit 5 is write only, so we have no idea what it will return when read, so yes I
> believe the fscpos driver is using the wrong masks.
It's write-only, but it has a default value of 0... which suggests that
reading from this register will always return 0 for bit 5. Not to say
that masking it out isn't a good idea, but the code we have in fscpos
probably works fine in practice.
> Alternatively to fixing
> this we could concider ripping out the watchdog support completely, I would
> actually prefer that, because as said its nothing more then a couple of raw
> registers exports. If peope want to get to the raw registers they can use i2c-dev.
It's not that simple, because the fscpos (or fscher) driver requests
the I2C address, so i2c-dev won't be able to use it... unless
I2C_SLAVE_FORCE is used, or direct I2C messaging is used, but we don't
want to encourage either practice. In fact I would like i2c-dev to be
less permissive in the future, I wanted to work on it but as usual it
got preempted by higher-priority tasks.
> >> @@ -720,7 +773,7 @@ static ssize_t set_watchdog_status(struc
> >> unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
> >>
> >> mutex_lock(&data->update_lock);
> >> - data->watchdog[1] &= ~v;
> >> + data->watchdog[1] &= ~v; /* write 1 to clear */
> >
> > This comment is confusing. You say "write 1 to clear" while the code
> > sets the bit in question to 0, not 1. Please clarify.
> >
> >> fscher_write_value(client, reg, v);
> >> mutex_unlock(&data->update_lock);
> >> return count;
>
> The code in question confused me, hence I added the comment to try and clarify
> it. Notice how v gets masked with 0x02, and thus can only be 0 or 0x02, if its
> zero, the this line: "data->watchdog[1] &= ~v" does nothing, if its 0x02, then
> bit 1 of our copy of the watchdog register gets cleared. IOW if the user writes
> 1 to bit 1 its gets cleared. We update our local copy of the register to
> reflect this, clearing the bit if a one is written, notice that v is used later
> to write to the chip, not our copy of the register, so a 1 gets written,
> clearing the bit and the statement I added the comment to updates our in memory
> copy to reflect the change caused by this write.
>
> Suggestions for a clearer comment, while not using as much text as I just did,
> are welcome.
Thanks for the clarification. I'm fine with the comment now, but I
think it should be moved one line down, next to the
fscher_write_value(). If you also want a comment on the first line,
that could be /* update our copy */ (it would probably be more logical
the other way around, BTW.)
> Alternatively, we could just leave it as is, without any comment
> at all. Or even better just kill off the pseudo watchdog support entirely.
I admit that this watchdog implementation is less than optimal, and I
would be happy to get rid of it. But now that it has been there for a
while, you can't just kill it. You need to either offer a replacement,
or deprecate it and only plan it for a removal in a (relatively) far
future.
The Linux kernel does have a standard interface for watchdogs, so the
clean solution would be to replace this non-standard interface with the
standard one. I don't know how hard it would be, but I guess probably
not too difficult, especially as you have a chip for testing.
If you really don't have the time to do this, then you will have to
make it clearly visible (Kconfig, documentation, log message) that the
old watchdog interface is deprecated and will be removed, so that
users have a chance to volunteer for the conversion if they care. You
can make it a config option if you want.
Hope that helps,
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
prev parent reply other threads:[~2007-07-21 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-09 12:42 [lm-sensors] PATCH: hwmon-fscher-support-fscpos.patch Hans de Goede
2007-07-09 12:42 ` Hans de Goede
2007-07-15 9:07 ` Jean Delvare
2007-07-15 9:40 ` Hans de Goede
2007-07-16 16:39 ` Stefan Ott
2007-07-21 20:48 ` Jean Delvare [this message]
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=20070721224833.52f6fc61@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.