diff options
author | Takashi Iwai <tiwai@suse.de> | 2019-07-03 08:35:12 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-07-05 06:01:06 -0400 |
commit | 774a075ab5140bb4504e6026bf327021926c3e65 (patch) | |
tree | f1d8252e2adc8f0f6ca3bb142f5b612699f8cc7e /sound/hda | |
parent | 3450121997ce872eb7f1248417225827ea249710 (diff) |
ALSA: hda: Simplify snd_hdac_refresh_widgets()
Along with the recent fix for the races of snd_hdac_refresh_widgets()
it turned out that the instantiation of widgets sysfs at
snd_hdac_sysfs_reinit() could cause a race. The race itself was
already covered later by extending the mutex protection range, the
commit 98482377dc72 ("ALSA: hda: Fix widget_mutex incomplete
protection"), but this also indicated that the call of *_reinit() is
basically superfluous, as the widgets shall be created sooner or later
from snd_hdac_device_register().
This patch removes the redundant call of snd_hdac_sysfs_reinit() at
first. By this removal, the sysfs argument itself in
snd_hdac_refresh_widgets() becomes superfluous, too, because the only
case sysfs=false is always with codec->widgets=NULL. So, we drop this
redundant argument as well.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r-- | sound/hda/hdac_device.c | 13 | ||||
-rw-r--r-- | sound/hda/hdac_sysfs.c | 2 |
2 files changed, 6 insertions, 9 deletions
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 11050bfd8068..a265c1d68876 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c | |||
@@ -89,7 +89,7 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, | |||
89 | 89 | ||
90 | fg = codec->afg ? codec->afg : codec->mfg; | 90 | fg = codec->afg ? codec->afg : codec->mfg; |
91 | 91 | ||
92 | err = snd_hdac_refresh_widgets(codec, false); | 92 | err = snd_hdac_refresh_widgets(codec); |
93 | if (err < 0) | 93 | if (err < 0) |
94 | goto error; | 94 | goto error; |
95 | 95 | ||
@@ -394,9 +394,8 @@ static void setup_fg_nodes(struct hdac_device *codec) | |||
394 | /** | 394 | /** |
395 | * snd_hdac_refresh_widgets - Reset the widget start/end nodes | 395 | * snd_hdac_refresh_widgets - Reset the widget start/end nodes |
396 | * @codec: the codec object | 396 | * @codec: the codec object |
397 | * @sysfs: re-initialize sysfs tree, too | ||
398 | */ | 397 | */ |
399 | int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs) | 398 | int snd_hdac_refresh_widgets(struct hdac_device *codec) |
400 | { | 399 | { |
401 | hda_nid_t start_nid; | 400 | hda_nid_t start_nid; |
402 | int nums, err = 0; | 401 | int nums, err = 0; |
@@ -414,11 +413,9 @@ int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs) | |||
414 | goto unlock; | 413 | goto unlock; |
415 | } | 414 | } |
416 | 415 | ||
417 | if (sysfs) { | 416 | err = hda_widget_sysfs_reinit(codec, start_nid, nums); |
418 | err = hda_widget_sysfs_reinit(codec, start_nid, nums); | 417 | if (err < 0) |
419 | if (err < 0) | 418 | goto unlock; |
420 | goto unlock; | ||
421 | } | ||
422 | 419 | ||
423 | codec->num_nodes = nums; | 420 | codec->num_nodes = nums; |
424 | codec->start_nid = start_nid; | 421 | codec->start_nid = start_nid; |
diff --git a/sound/hda/hdac_sysfs.c b/sound/hda/hdac_sysfs.c index 909d5ef1179c..e56e83325903 100644 --- a/sound/hda/hdac_sysfs.c +++ b/sound/hda/hdac_sysfs.c | |||
@@ -428,7 +428,7 @@ int hda_widget_sysfs_reinit(struct hdac_device *codec, | |||
428 | int i; | 428 | int i; |
429 | 429 | ||
430 | if (!codec->widgets) | 430 | if (!codec->widgets) |
431 | return hda_widget_sysfs_init(codec); | 431 | return 0; |
432 | 432 | ||
433 | tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL); | 433 | tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL); |
434 | if (!tree) | 434 | if (!tree) |