Re: [Alsa-devel] [PATCH] alsa: correct nonsensical sysfs device symlinks

Takashi Iwai
2007-01-26T18:25:43Z

At Fri, 26 Jan 2007 10:04:57 -0800,
Greg KH wrote:
>
> On Fri, Jan 26, 2007 at 12:40:31PM +0100, Takashi Iwai wrote:
> > 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>
>
> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
>
> Thanks for working on tracking this down, sorry I forgot all about this
> when doing this original conversion.

Greg, feel free to pick it up to your tree for pushing. Since this
patch conflicts with the development tree of ALSA mm branch, it'd be
even harder to push from ALSA tree, unfortuantely...

Of course, it'd be safer after confirming that the patch works indeed.
(My brief tests show good results, though.)

thanks,

Takashi