From: Andreas Mohr <andi@lisas.de>
To: Ondrej Zary <linux@rainbow-software.org>
Cc: Andreas Mohr <andi@lisas.de>,
alsa-devel@alsa-project.org, krzysztof.h1@wp.pl,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH] ES938 support for ES18xx driver
Date: Thu, 19 Sep 2013 19:36:49 +0200 [thread overview]
Message-ID: <20130919173649.GA18537@rhlx01.hs-esslingen.de> (raw)
In-Reply-To: <201309162220.55221.linux@rainbow-software.org>
Hi,
On Mon, Sep 16, 2013 at 10:20:54PM +0200, Ondrej Zary wrote:
> +static int snd_es938_read_reg(struct snd_es938 *chip, u8 reg, u8 *out)
> +{
> + u8 buf[8];
> + int i = 0, res;
> + u8 sysex[] = { MIDI_CMD_COMMON_SYSEX, 0x00, 0x00, ES938_ID,
> + ES938_CMD_REG_R, reg, MIDI_CMD_COMMON_SYSEX_END };
> + unsigned long end_time;
> +
> + snd_rawmidi_kernel_write(chip->rfile.output, sysex, sizeof(sysex));
> +
> + memset(buf, 0, sizeof(buf));
> + end_time = jiffies + msecs_to_jiffies(100);
> + while (i < sizeof(buf)) {
> + res = snd_rawmidi_kernel_read(chip->rfile.input, buf + i,
> + sizeof(buf) - i);
> + if (res > 0)
> + i += res;
> + if (time_after(jiffies, end_time))
> + return -1;
> + }
Forgive me, but I seem to faintly remember that it's preferred for
user code to tend towards non-jiffies-based timing (IIRC due to
NOHZ efforts etc.).
So if that actually is the case, then one might want to change it to
less jiffies-dependent handling (use non-jiffies helpers), but then how?
> +static void snd_es938_write_reg(struct snd_es938 *chip, u8 reg, u8 val)
> +{
> + u8 sysex[] = { MIDI_CMD_COMMON_SYSEX, 0x00, 0x00, ES938_ID,
> + ES938_CMD_REG_W, reg, val, MIDI_CMD_COMMON_SYSEX_END };
> +
> + snd_rawmidi_kernel_write(chip->rfile.output, sysex, sizeof(sysex));
snd_rawmidi_kernel_write() is prototyped as const unsigned char *buf,
so perhaps...
const unsigned char buf[] = ...;?
(static const probably not so useful
e.g. since static const may be rather prone to cache misses)
Though personally I do favour u8, since "char" seems so unsuitably stringy -
but the prototype currently doesn't offer it typed that way...
(Almost-)Reviewed-By: Andreas Mohr <andim2@users.sf.net>
Andreas Mohr
prev parent reply other threads:[~2013-09-19 17:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-14 20:40 Ondrej Zary
2013-09-15 18:49 ` Andreas Mohr
2013-09-15 20:25 ` Ondrej Zary
2013-09-15 20:35 ` Andreas Mohr
2013-09-15 21:04 ` Ondrej Zary
2013-09-15 21:23 ` Andreas Mohr
2013-09-16 16:14 ` Ondrej Zary
2013-09-16 20:20 ` Ondrej Zary
2013-09-19 17:36 ` Andreas Mohr [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=20130919173649.GA18537@rhlx01.hs-esslingen.de \
--to=andi@lisas.de \
--cc=alsa-devel@alsa-project.org \
--cc=krzysztof.h1@wp.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rainbow-software.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®