ALSA: hda: Fix driver index handling at re-binding
authorTakashi Iwai <tiwai@suse.de>
Wed, 9 Feb 2022 08:19:12 +0000 (09:19 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 9 Feb 2022 08:20:11 +0000 (09:20 +0100)
commit69458e2c27800da7697c87ed908b65323ef3f3bd
treea9fc6a392c61295d7470abe58d0d894f399c674f
parent8f85b4da579e006547c8cf3660220c54b99451da
ALSA: hda: Fix driver index handling at re-binding

HD-audio driver handles the multiple instances and keeps the static
index that is incremented at each probe.  This becomes a problem when
user tries to re-bind the device via sysfs multiple times; as the
device index isn't cleared unlike rmmod case, it points to the next
element at re-binding, and eventually later you can't probe any more
when it reaches to SNDRV_CARDS_MAX (usually 32).

This patch is an attempt to improve the handling at rebinding.
Instead of a static device index, now we keep a bitmap and assigns to
the first zero bit position.  At the driver remove, in return, the
bitmap slot is cleared again, so that it'll be available for the next
probe.

Reported-by: Alexander Sergeyev <sergeev917@gmail.com>
Link: https://lore.kernel.org/r/20220209081912.20687-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_intel.c