From: Pete Zaitcev <zaitcev@redhat.com>
To: Tsozik <tsozik@yahoo.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
zaitcev@redhat.com
Subject: Re: [PATCH 1/1] mct_u232: added _ioctl and _get_icount functions
Date: Sun, 26 Dec 2010 20:57:56 -0700 [thread overview]
Message-ID: <20101226205756.78f4d21a@lembas.zaitcev.lan> (raw)
In-Reply-To: <342039.62488.qm@web65711.mail.ac4.yahoo.com>
On Sun, 26 Dec 2010 18:58:46 -0800 (PST)
Tsozik <tsozik@yahoo.com> wrote:
> Please let me know if there's anything else I need to correct before
> it can be rolled out,
I am hardly an expert here, but I looked it up as much as I could,
and this looks like a wrong way to do it:
> @@ -386,27 +396,41 @@ static int mct_u232_get_modem_stat(struc
> /* Translate Control Line states */
> + if (msr & MCT_U232_MSR_DSR) {
> *control_state |= TIOCM_DSR;
> + icount->dsr++;
> + } else {
> *control_state &= ~TIOCM_DSR;
> + }
Unfortunately, Kerrisk's manpages do not seem to offer an authoritative
definition, but the expectations across the code seems that the counter
actually counts the changes. I know that some people talked about
counting "interrupts", but the way it's implemented in trustworthy
drivers suggests something like this:
unsigned int old_ctl_state;
old_ctl_state = *control_state;
if (msr & MCT_U232_MSR_DSR)
*control_state |= TIOCM_DSR;
else
*control_state &= ~TIOCM_DSR;
if (old_ctl_state != *control_state)
icount->dsr++;
...... repeat for all bits
E.g. for DSR going down too, although perhaps I'm not suggesting the
best way to do it. Could you re-implement it like the above and
check that your radiation counter works the same with it and
when driven by a built-in serial port?
Another thing, you should take priv->lock around fetching of
mct_u232_port->icount in mct_u232_ioctl. It seems superfluous,
I know, because the API itself is racy, but just to be nice
and doing the expected thing...
-- Pete
next prev parent reply other threads:[~2010-12-27 3:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-27 2:58 [PATCH 1/1] mct_u232: added _ioctl and _get_icount functions Tsozik
2010-12-27 3:57 ` Pete Zaitcev [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-12-27 6:34 Tsozik
2010-12-27 17:08 ` Pete Zaitcev
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=20101226205756.78f4d21a@lembas.zaitcev.lan \
--to=zaitcev@redhat.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=tsozik@yahoo.com \
/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