mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: "Jon Arne Jørgensen" <jonarne@jonarne.no>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	elezegarcia@gmail.com
Subject: Re: [RFC V1 5/8] smi2021: Add smi2021_video.c
Date: Mon, 18 Mar 2013 09:58:32 +0100	[thread overview]
Message-ID: <87620p3wzr.fsf@nemi.mork.no> (raw)
In-Reply-To: <201303180917.03572.hverkuil@xs4all.nl> (Hans Verkuil's message of "Mon, 18 Mar 2013 09:17:03 +0100")

Hans Verkuil <hverkuil@xs4all.nl> writes:

>> +/*
>> + *
>> + * The device delivers data in chunks of 0x400 bytes.
>> + * The four first bytes is a magic header to identify the chunks.
>> + *	0xaa 0xaa 0x00 0x00 = saa7113 Active Video Data
>> + *	0xaa 0xaa 0x00 0x01 = PCM - 24Bit 2 Channel audio data
>> + */
>> +static void process_packet(struct smi2021_dev *dev, u8 *p, int len)
>> +{
>> +	int i;
>> +	u32 *header;
>> +
>> +	if (len % 0x400 != 0) {
>> +		printk_ratelimited(KERN_INFO "smi2021::%s: len: %d\n",
>> +				__func__, len);
>> +		return;
>> +	}
>> +
>> +	for (i = 0; i < len; i += 0x400) {
>> +		header = (u32 *)(p + i);
>> +		switch (__cpu_to_be32(*header)) {
>
> That's not right. You probably mean __be32_to_cpu, that makes more sense.
>
>> +		case 0xaaaa0000: {
>> +			parse_video(dev, p+i+4, 0x400-4);
>> +			break;
>> +		}
>> +		case 0xaaaa0001: {
>> +			smi2021_audio(dev, p+i+4, 0x400-4);
>> +			break;
>> +		}

This could be just me, but I would have done it like this to take
advantage of compile time constant conversions (and also dropping the
noisy extra {}s):

		switch (*header) {
		case cpu_to_be32(0xaaaa0000):
			parse_video(dev, p+i+4, 0x400-4);
			break;
		case cpu_to_be32(0xaaaa0001):
			smi2021_audio(dev, p+i+4, 0x400-4);
			break;
                ..


>From the name of the function I assume the difference may actually be
measurable here if this runs for every processed packet.


Bjørn

  reply	other threads:[~2013-03-18  8:59 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14 14:06 [RFC V1 0/8] Add a driver for somagic smi2021 Jon Arne Jørgensen
2013-03-14 14:06 ` [RFC V1 1/8] smi2021: Add the header file Jon Arne Jørgensen
2013-03-15 12:13   ` Ezequiel Garcia
2013-03-17 20:16     ` Jon Arne Jørgensen
2013-03-14 14:06 ` [RFC V1 2/8] smi2021: Add smi2021_main.c Jon Arne Jørgensen
2013-03-15 12:20   ` Ezequiel Garcia
2013-03-17 20:14     ` Jon Arne Jørgensen
2013-03-18  7:58   ` Hans Verkuil
2013-03-20  9:30     ` Jon Arne Jørgensen
2013-03-18  8:30   ` Hans Verkuil
2013-03-20  9:31     ` Jon Arne Jørgensen
2013-03-14 14:06 ` [RFC V1 3/8] smi2021: Add smi2021_i2c.c Jon Arne Jørgensen
2013-03-15 12:27   ` Ezequiel Garcia
2013-03-17 19:59     ` Jon Arne Jørgensen
2013-03-18  8:04   ` Hans Verkuil
2013-03-20  9:32     ` Jon Arne Jørgensen
2013-03-14 14:07 ` [RFC V1 4/8] smi2021: Add smi2021_v4l2.c Jon Arne Jørgensen
2013-03-15 12:33   ` Ezequiel Garcia
2013-03-17 20:27     ` Jon Arne Jørgensen
2013-03-18  8:12   ` Hans Verkuil
2013-03-20  9:43     ` Jon Arne Jørgensen
2013-03-20 10:07       ` Hans Verkuil
2013-03-18  8:29   ` Hans Verkuil
2013-03-20  9:48     ` Jon Arne Jørgensen
2013-03-20 10:10       ` Hans Verkuil
2013-03-20 10:16         ` Jon Arne Jørgensen
2013-03-20 10:21           ` Hans Verkuil
2013-03-20 11:09             ` Jon Arne Jørgensen
2013-03-14 14:07 ` [RFC V1 5/8] smi2021: Add smi2021_video.c Jon Arne Jørgensen
2013-03-15 12:40   ` Ezequiel Garcia
2013-03-17 20:19     ` Jon Arne Jørgensen
2013-03-18  8:17   ` Hans Verkuil
2013-03-18  8:58     ` Bjørn Mork [this message]
2013-03-20 10:06       ` Jon Arne Jørgensen
2013-03-20 10:09         ` Hans Verkuil
2013-03-14 14:07 ` [RFC V1 6/8] smi2021: Add smi2021_audio.c Jon Arne Jørgensen
2013-03-14 14:07 ` [RFC V1 7/8] smi2021: Add smi2021_bl.c Jon Arne Jørgensen
2013-03-18  9:31   ` Bjørn Mork
2013-03-20  8:59     ` Jon Arne Jørgensen
2013-03-14 14:07 ` [RFC V1 8/8] smi2021: Add Kconfig and Makefiles Jon Arne Jørgensen
2013-03-15 12:08 ` [RFC V1 0/8] Add a driver for somagic smi2021 Ezequiel Garcia
2013-03-17 20:01   ` Jon Arne Jørgensen
2013-03-18  0:05     ` Ezequiel Garcia
2013-03-20 10:11       ` Jon Arne Jørgensen

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=87620p3wzr.fsf@nemi.mork.no \
    --to=bjorn@mork.no \
    --cc=elezegarcia@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jonarne@jonarne.no \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@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 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®