diff options
| -rw-r--r-- | sound/hda/hdac_device.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 4769f4c03e14..11050bfd8068 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c | |||
| @@ -399,27 +399,33 @@ static void setup_fg_nodes(struct hdac_device *codec) | |||
| 399 | int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs) | 399 | int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs) |
| 400 | { | 400 | { |
| 401 | hda_nid_t start_nid; | 401 | hda_nid_t start_nid; |
| 402 | int nums, err; | 402 | int nums, err = 0; |
| 403 | 403 | ||
| 404 | /* | ||
| 405 | * Serialize against multiple threads trying to update the sysfs | ||
| 406 | * widgets array. | ||
| 407 | */ | ||
| 408 | mutex_lock(&codec->widget_lock); | ||
| 404 | nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); | 409 | nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); |
| 405 | if (!start_nid || nums <= 0 || nums >= 0xff) { | 410 | if (!start_nid || nums <= 0 || nums >= 0xff) { |
| 406 | dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", | 411 | dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", |
| 407 | codec->afg); | 412 | codec->afg); |
| 408 | return -EINVAL; | 413 | err = -EINVAL; |
| 414 | goto unlock; | ||
| 409 | } | 415 | } |
| 410 | 416 | ||
| 411 | if (sysfs) { | 417 | if (sysfs) { |
| 412 | mutex_lock(&codec->widget_lock); | ||
| 413 | err = hda_widget_sysfs_reinit(codec, start_nid, nums); | 418 | err = hda_widget_sysfs_reinit(codec, start_nid, nums); |
| 414 | mutex_unlock(&codec->widget_lock); | ||
| 415 | if (err < 0) | 419 | if (err < 0) |
| 416 | return err; | 420 | goto unlock; |
| 417 | } | 421 | } |
| 418 | 422 | ||
| 419 | codec->num_nodes = nums; | 423 | codec->num_nodes = nums; |
| 420 | codec->start_nid = start_nid; | 424 | codec->start_nid = start_nid; |
| 421 | codec->end_nid = start_nid + nums; | 425 | codec->end_nid = start_nid + nums; |
| 422 | return 0; | 426 | unlock: |
| 427 | mutex_unlock(&codec->widget_lock); | ||
| 428 | return err; | ||
| 423 | } | 429 | } |
| 424 | EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets); | 430 | EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets); |
| 425 | 431 | ||
