public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: David Weinehall <tao@acc.umu.se>
Cc: Tachino Nobuhiro <tachino@open.nm.fujitsu.co.jp>,
	"Michael F. Robbins" <compumike@compumike.com>,
	linux-kernel@vger.kernel.org
Subject: Re: SiS/Trident 4DWave sound driver oops
Date: 25 Oct 2001 23:28:02 -0400	[thread overview]
Message-ID: <1004066884.29627.22.camel@phantasy> (raw)
In-Reply-To: <20011026051346.J25701@khan.acc.umu.se>
In-Reply-To: <1004016263.1384.15.camel@tbird.robbins> <7ktjw58u.wl@nisaaru.dvs.cs.fujitsu.co.jp> <1004060759.11258.12.camel@phantasy> <6693w4ds.wl@nisaaru.dvs.cs.fujitsu.co.jp> <1004061741.11366.32.camel@phantasy> <g087jff1.wl@nisaaru.dvs.cs.fujitsu.co.jp> <1004064125.19937.5.camel@phantasy>  <20011026051346.J25701@khan.acc.umu.se>

On Thu, 2001-10-25 at 23:13, David Weinehall wrote:
> I think the way this is coded stinks anyway. the {0,} should be used
> as a loop-terminator, not ARRAY_SIZE(blaha) - 1. Yes, using 0-termination
> wastes space. But it's cleaner and in line with what most other code
> does.

Agreed.  Also, I didn't check if other ac97 code uses the {0,} as a
terminator.  Removing it may break that.

The patch below accomplishes this.

However, now that I am actually looking at the code <g>, I don't see why
this would be a problem either way.  Even though the loop reads the 
"terminal" entry, it just checks whether it equals the specified id.  It
is equal to 0 so I assume it never will...we aren't dereferencing it or
anything.

diff -u linux-2.4.12-ac6/drivers/sound/ac97_codec.c linux/drivers/sound/ac97_codec.c
--- linux-2.4.12-ac6/drivers/sound/ac97_codec.c	Tue Oct 23 17:16:20 2001
+++ linux/drivers/sound/ac97_codec.c	Thu Oct 25 23:21:02 2001
@@ -669,7 +669,7 @@
 {
 	u16 id1, id2;
 	u16 audio, modem;
-	int i;
+	int i = 0;
 
 	/* probing AC97 codec, AC97 2.0 says that bit 15 of register 0x00 (reset) should 
 	 * be read zero.
@@ -700,13 +700,14 @@
 
 	id1 = codec->codec_read(codec, AC97_VENDOR_ID1);
 	id2 = codec->codec_read(codec, AC97_VENDOR_ID2);
-	for (i = 0; i < ARRAY_SIZE(ac97_codec_ids); i++) {
+	while(a97_codec_ids[i].id != 0) {
 		if (ac97_codec_ids[i].id == ((id1 << 16) | id2)) {
 			codec->type = ac97_codec_ids[i].id;
 			codec->name = ac97_codec_ids[i].name;
 			codec->codec_ops = ac97_codec_ids[i].ops;
 			break;
 		}
+		i++;
 	}
 	if (codec->name == NULL)
 		codec->name = "Unknown";


	Robert Love


  reply	other threads:[~2001-10-26  3:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-25 13:24 SiS/Trident 4DWave sound driver oops Michael F. Robbins
2001-10-26  1:37 ` Tachino Nobuhiro
2001-10-26  1:45   ` Robert Love
2001-10-26  1:56     ` Tachino Nobuhiro
2001-10-26  2:02       ` Robert Love
2001-10-26  2:36         ` Tachino Nobuhiro
2001-10-26  2:42           ` Robert Love
2001-10-26  3:13             ` David Weinehall
2001-10-26  3:28               ` Robert Love [this message]
2001-10-26  3:24           ` Stuart Young
2001-10-26 14:36             ` Alan Cox
2001-10-26 14:47               ` Trever L. Adams
2001-10-28 23:06             ` SiS/Trident 4DWave sound driver Stuart Young
2001-10-29  1:19             ` SiS/Trident 4DWave sound driver (Update) Stuart Young
2001-10-29  4:04             ` SiS drivers (more) Stuart Young
2001-10-26 23:43   ` SiS/Trident 4DWave sound driver oops Michael F. Robbins
  -- strict thread matches above, loose matches on Subject: below --
2001-10-25  1:07 Michael F. Robbins
2001-10-25  5:55 ` Stuart Young
2001-10-25  7:02 ` Stuart Young
2001-10-23  6:15 Stuart Young
2001-10-23 16:19 ` Alan Cox
2001-10-24 23:55 ` Stuart Young

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=1004066884.29627.22.camel@phantasy \
    --to=rml@tech9.net \
    --cc=compumike@compumike.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tachino@open.nm.fujitsu.co.jp \
    --cc=tao@acc.umu.se \
    /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