From: Ian Abbott <abbotti@mev.co.uk>
To: Hartley Sweeten <HartleyS@visionengravers.com>,
Rostislav Lisovy <lisovy@gmail.com>,
Ian Abbott <ian.abbott@mev.co.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>
Cc: "pisa@cmp.felk.cvut.cz" <pisa@cmp.felk.cvut.cz>
Subject: Re: [PATCH] comedi: Humusoft MF634 and MF624 DAQ cards driver
Date: Mon, 6 Jan 2014 12:37:32 +0000 [thread overview]
Message-ID: <52CAA38C.9050307@mev.co.uk> (raw)
In-Reply-To: <DC148C5AA1CEBA4E87973D432B1C2D8817E5C72E@P3PWEX4MB008.ex4.secureserver.net>
On 2014-01-02 18:38, Hartley Sweeten wrote:
> On Monday, December 30, 2013 6:37 PM, Rostislav Lisovy wrote:
[snip]
>> +static int mf6x4_dio_insn_bits(struct comedi_device *dev,
>> + struct comedi_subdevice *s,
>> + struct comedi_insn *insn, unsigned int *data)
>> +{
>> + struct mf6x4_private *devpriv = dev->private;
>> +
>> + switch (s->type) {
>> + case COMEDI_SUBD_DI: /* DIN */
>> + data[1] = ioread16(devpriv->bar1_mem + MF6X4_DIN_reg) & MF6X4_DIN_mask;
>> + break;
>> +
>> + case COMEDI_SUBD_DO: /* DOUT */
>> + /* data[0] -- mask
>> + data[1] -- actual value */
>> + if (data[0]) {
>> + s->state &= ~data[0];
>> + s->state |= (data[0] & data[1]);
>
> Please use comedi_dio_update_state() to handle this boilerplate code.
>
>> +
>> + iowrite16(s->state & MF6X4_DOUT_mask,
>> + devpriv->bar1_mem + MF6X4_DOUT_reg);
>> +
>> + data[1] = s->state;
>> + }
>> + break;
>> + }
>> +
>> + return insn->n;
>> +}
>
> Please split this function into a mf6x4_di_insn_bits() and mf6x4_do_insn_bits().
> That will remove an indent level and make the usage a bit clearer.
I'll also add that the `data[1] = s->state;` should be done even if
data[0] is zero, i.e. it should be moved after the end of the `if`
statement.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
next prev parent reply other threads:[~2014-01-06 12:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-31 1:36 [PATCH] comedi: Humusoft MF634 and MF624 DAQ cards driver Rostislav Lisovy
2013-12-31 1:36 ` Rostislav Lisovy
2013-12-31 2:31 ` Dan Carpenter
2014-01-02 18:38 ` Hartley Sweeten
2014-01-05 15:04 ` Rostislav Lisovy
2014-01-05 18:18 ` Dan Carpenter
2014-01-06 12:37 ` Ian Abbott [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-01-07 22:24 [PATCH v2] " Rostislav Lisovy
2014-01-07 22:24 ` [PATCH] " Rostislav Lisovy
2014-01-08 7:47 ` Dan Carpenter
2014-01-08 8:35 ` Rostislav Lisovy
2014-01-08 10:42 ` Ian Abbott
2014-01-09 22:55 ` Rostislav Lisovy
2014-01-09 22:46 [PATCH v3] " Rostislav Lisovy
2014-01-09 22:46 ` [PATCH] " Rostislav Lisovy
2014-01-10 10:29 ` Ian Abbott
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=52CAA38C.9050307@mev.co.uk \
--to=abbotti@mev.co.uk \
--cc=HartleyS@visionengravers.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=ian.abbott@mev.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=lisovy@gmail.com \
--cc=pisa@cmp.felk.cvut.cz \
/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