[PATCH] alsa: correct nonsensical sysfs device symlinks

From: Christopher \"Monty\" Montgomery
Date: Wed Jan 24 2007 - 20:50:40 EST


This patch was generated against 2.6.20-rc5; it fixes a bug that
cropped up in a late 2.6.19-mm kernel.

When ALSA's sysfs device creation was converted from using
class_device_create() to device_create(), the fourth param from
class_device_create() [dev] was simply plugged into arg 2 of
device_create(). This causes the device symlinks under all the
class/sound/[node] to point to nonsensical places. Among other
problems, this breaks HAL and all audio software that depends on HAL.

The nature of this bug is not simply a need to update HAL;
class/[node]/device symlinks are required to point to a device entry
in /sys/devices; the bug causes them to point to other places within
/sys/class. This patch is [hopefully] a trivial change to restore the
desired behavior.

Signed-off-by: Monty Montgomery <xiphmont@xxxxxxxxx>
---

Apologies for sending patch as text/plain attachment; we've
established in the past that Gmail will not leave unformatted text
email unmunged.
diff -uprN -X linux-2.6.20-rc5/Documentation/dontdiff linux-2.6.20-rc5/sound/core/sound.c linux-2.6.20-rc5-monty/sound/core/sound.c
--- linux-2.6.20-rc5/sound/core/sound.c 2007-01-12 13:54:26.000000000 -0500
+++ linux-2.6.20-rc5-monty/sound/core/sound.c 2007-01-24 20:30:07.000000000 -0500
@@ -265,7 +265,9 @@ int snd_register_device(int type, struct
snd_minors[minor] = preg;
if (card)
device = card->dev;
- preg->dev = device_create(sound_class, device, MKDEV(major, minor),
+ preg->dev = device_create(sound_class,
+ (device?device->parent:NULL),
+ MKDEV(major, minor),
"%s", name);
if (preg->dev)
dev_set_drvdata(preg->dev, private_data);