From: Takashi Iwai <tiwai@suse.de>
To: xiphmont@xiph.org
Cc: "Greg KH" <greg@kroah.com>, "Pierre Ossman" <drzeus@drzeus.cx>,
fedora-desktop-list@redhat.com, alsa-devel@alsa-project.org,
jrb@redhat.com, linux-kernel@vger.kernel.org, mclasen@redhat.com,
"Lennart Poettering" <lennart@poettering.net>,
perex@suse.cz
Subject: Re: [Alsa-devel] [PATCH] alsa: correct nonsensical sysfs device symlinks
Date: Fri, 26 Jan 2007 12:40:31 +0100 [thread overview]
Message-ID: <s5hejpivwwg.wl%tiwai@suse.de> (raw)
In-Reply-To: <806dafc20701260253r145fee43kc6db1ca6de1ab3e6@mail.gmail.com>
At Fri, 26 Jan 2007 05:53:36 -0500,
xiphmont@xiph.org wrote:
>
> On 1/25/07, Greg KH <greg@kroah.com> wrote:
>
> > Is there anything else left to fix?
>
> Once that testing is done, no. But don't trust the two patches I sent
> yet, I'll resumbit the patch resulting from more thorough testing in a
> few hours (much thanks to Takashi for giving me the parent device
> feedback I was trolling for).
After rechecking the current code regarding this sysfs change at last
night, I found out that it's more broken for some devices like
sound/arm/*. They refer to card->dev to obtain the device for memory
allocation, etc, and passing card* object will screw them up.
The below is my current fix. Hoepfully all evils got away now... and
thanks for Monty for heading up this issue!
Takashi
====
[PATCH] ALSA: Fix sysfs breakage
The recent change for a new sysfs tree with card* object breaks the
/sys/class/sound tree if CONFIG_SYSFS_DEPRECATED is enabled.
The device in each entry doesn't point the correct device object:
/sys/class/sound
...
|-- pcmC0D0c
| |-- dev
| |-- device -> ../../../class/sound/card0
| |-- pcm_class
| |-- power
| | `-- wakeup
| |-- subsystem -> ../../../class/sound
| `-- uevent
Also, this change breaks some drivers (like sound/arm/*) referring
card->dev directly to obtain the device object for memory handling.
This patch reverts the semantics of card->dev to the former version,
which points to a real device object. The card* object is stored in a
new card->card_dev field, instead. The device parent is chosen either
card->dev or card->card_dev according to CONFIG_SYSFS_DEPRECATED to
keep the tree compatibility.
Also, card* isn't created if CONFIG_SYSFS_DEPRECATED is enabled. The
reason of card* object is a root of all beloing devices, and it makes
little sense if each sound device points to the real device object
directly.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
include/sound/core.h | 18 +++++++++++++++---
sound/core/init.c | 18 +++++++++++-------
sound/core/sound.c | 4 +---
sound/core/sound_oss.c | 4 +---
4 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/include/sound/core.h b/include/sound/core.h
index a994bea..521f036 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -132,8 +132,10 @@ struct snd_card {
int shutdown; /* this card is going down */
int free_on_last_close; /* free in context of file_release */
wait_queue_head_t shutdown_sleep;
- struct device *parent;
- struct device *dev;
+ struct device *dev; /* device assigned to this card */
+#ifndef CONFIG_SYSFS_DEPRECATED
+ struct device *card_dev; /* cardX object for sysfs */
+#endif
#ifdef CONFIG_PM
unsigned int power_state; /* power state */
@@ -191,6 +193,16 @@ struct snd_minor {
struct device *dev; /* device for sysfs */
};
+/* return a device pointer linked to each sound device as a parent */
+static inline struct device *snd_card_get_device_link(struct snd_card *card)
+{
+#ifdef CONFIG_SYSFS_DEPRECATED
+ return card ? card->dev : NULL;
+#else
+ return card ? card->card_dev : NULL;
+#endif
+}
+
/* sound.c */
extern int snd_major;
@@ -257,7 +269,7 @@ int snd_card_file_add(struct snd_card *c
int snd_card_file_remove(struct snd_card *card, struct file *file);
#ifndef snd_card_set_dev
-#define snd_card_set_dev(card,devptr) ((card)->parent = (devptr))
+#define snd_card_set_dev(card,devptr) ((card)->dev = (devptr))
#endif
/* device.c */
diff --git a/sound/core/init.c b/sound/core/init.c
index 6152a75..a4cc6b1 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -361,8 +361,10 @@ static int snd_card_do_free(struct snd_c
snd_printk(KERN_WARNING "unable to free card info\n");
/* Not fatal error */
}
- if (card->dev)
- device_unregister(card->dev);
+#ifndef CONFIG_SYSFS_DEPRECATED
+ if (card->card_dev)
+ device_unregister(card->card_dev);
+#endif
kfree(card);
return 0;
}
@@ -497,12 +499,14 @@ int snd_card_register(struct snd_card *c
int err;
snd_assert(card != NULL, return -EINVAL);
- if (!card->dev) {
- card->dev = device_create(sound_class, card->parent, 0,
- "card%i", card->number);
- if (IS_ERR(card->dev))
- card->dev = NULL;
+#ifndef CONFIG_SYSFS_DEPRECATED
+ if (!card->card_dev) {
+ card->card_dev = device_create(sound_class, card->dev, 0,
+ "card%i", card->number);
+ if (IS_ERR(card->card_dev))
+ card->card_dev = NULL;
}
+#endif
if ((err = snd_device_register_all(card)) < 0)
return err;
mutex_lock(&snd_card_mutex);
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 2827420..82a61c6 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -238,7 +238,7 @@ int snd_register_device(int type, struct
{
int minor;
struct snd_minor *preg;
- struct device *device = NULL;
+ struct device *device = snd_card_get_device_link(card);
snd_assert(name, return -EINVAL);
preg = kmalloc(sizeof *preg, GFP_KERNEL);
@@ -263,8 +263,6 @@ int snd_register_device(int type, struct
return minor;
}
snd_minors[minor] = preg;
- if (card)
- device = card->dev;
preg->dev = device_create(sound_class, device, MKDEV(major, minor),
"%s", name);
if (preg->dev)
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index b2fc40a..4566df4 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -106,7 +106,7 @@ int snd_register_oss_device(int type, st
int cidx = SNDRV_MINOR_OSS_CARD(minor);
int track2 = -1;
int register1 = -1, register2 = -1;
- struct device *carddev = NULL;
+ struct device *carddev = snd_card_get_device_link(card);
if (card && card->number >= 8)
return 0; /* ignore silently */
@@ -134,8 +134,6 @@ int snd_register_oss_device(int type, st
track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1);
break;
}
- if (card)
- carddev = card->dev;
register1 = register_sound_special_device(f_ops, minor, carddev);
if (register1 != minor)
goto __end;
next prev parent reply other threads:[~2007-01-26 11:40 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-25 1:50 Christopher "Monty" Montgomery
2007-01-25 4:26 ` Greg KH
2007-01-25 14:11 ` Christopher "Monty" Montgomery
2007-01-25 15:15 ` Pierre Ossman
2007-01-25 15:36 ` Christopher "Monty" Montgomery
2007-01-25 15:40 ` Pierre Ossman
2007-01-25 15:57 ` Christopher "Monty" Montgomery
2007-01-25 16:54 ` [Alsa-devel] " Takashi Iwai
2007-01-25 17:03 ` Christopher "Monty" Montgomery
2007-01-25 17:30 ` xiphmont
2007-01-25 17:47 ` Takashi Iwai
2007-01-25 18:07 ` xiphmont
2007-01-25 18:23 ` Takashi Iwai
2007-01-25 18:34 ` xiphmont
2007-01-25 18:38 ` Takashi Iwai
2007-01-25 18:51 ` xiphmont
2007-01-25 19:49 ` Greg KH
2007-01-25 20:40 ` xiphmont
2007-01-25 21:59 ` Greg KH
2007-01-26 10:53 ` xiphmont
2007-01-26 11:40 ` Takashi Iwai [this message]
2007-01-26 18:04 ` Greg KH
2007-01-26 18:25 ` Takashi Iwai
2007-01-26 18:31 ` xiphmont
2007-01-26 19:06 ` Greg KH
2007-01-26 21:58 ` xiphmont
2007-01-26 18:03 ` xiphmont
2007-01-26 18:42 ` Greg KH
2007-01-25 17:48 ` Christopher "Monty" Montgomery
2007-01-25 11:27 ` Pierre Ossman
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=s5hejpivwwg.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=drzeus@drzeus.cx \
--cc=fedora-desktop-list@redhat.com \
--cc=greg@kroah.com \
--cc=jrb@redhat.com \
--cc=lennart@poettering.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mclasen@redhat.com \
--cc=perex@suse.cz \
--cc=xiphmont@xiph.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®