HomeFreeBSD

sound: Simplify locking during device creation

Description

sound: Simplify locking during device creation

The mechanism of acquiring SD_F_BUSY in pcm_init() and releasing it in
pcm_register() is a leftover from the previous device creation scheme,
where pcm_init() (previously pcm_register()) would create the sysctl
nodes, as well as the device node. In this scenario, acquiring SD_F_BUSY
was necessary, in order to avoid races in case the device was accessed
before it was ready for use. Commit 66f3eb14e955 ("sound: Move sysctl
and /dev/dspX creation to pcm_setstatus()") fixed this issue, so we can
simplify things now. Only acquire SD_F_BUSY in pcm_addchan(), because
chn_init() expects to be called with SD_F_BUSY acquired.

While here, move the sndstat_register() call further down to be more
robust.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D48482

(cherry picked from commit fd906e47b18f53b09524647bf8431dc6170b8dfd)

Details

Provenance
christosAuthored on Tue, Feb 25, 11:44 AM
Reviewer
markj
Differential Revision
D48482: sound: Simplify locking during device creation
Parents
rGbd9a9c001951: snd_uaudio: Remove undefined functions
Branches
Unknown
Tags
Unknown