summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-07-07 05:29:03 -0400
committerTakashi Iwai <tiwai@suse.de>2019-07-07 05:29:30 -0400
commitb89b889a326a7abf1c9ceef7ddbe06dbaf8c2520 (patch)
treed4f6a91d90fee3da58080dbd2c43a469dc5503a4
parentd4bd30532688558a7de70f0c8edd2a7a25c3963f (diff)
parent774a075ab5140bb4504e6026bf327021926c3e65 (diff)
Merge branch 'topic/hda-refresh-cleanup' into for-next
Merge a cleanup for HD-audio widget refresh code Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/hdaudio.h2
-rw-r--r--sound/hda/hdac_device.c29
-rw-r--r--sound/hda/hdac_sysfs.c2
-rw-r--r--sound/pci/hda/hda_codec.c2
-rw-r--r--sound/soc/codecs/hdac_hdmi.c2
-rw-r--r--sound/usb/line6/pcm.c5
6 files changed, 25 insertions, 17 deletions
diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h
index f49af557bdb0..612a17e375d0 100644
--- a/include/sound/hdaudio.h
+++ b/include/sound/hdaudio.h
@@ -120,7 +120,7 @@ void snd_hdac_device_unregister(struct hdac_device *codec);
120int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name); 120int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name);
121int snd_hdac_codec_modalias(struct hdac_device *hdac, char *buf, size_t size); 121int snd_hdac_codec_modalias(struct hdac_device *hdac, char *buf, size_t size);
122 122
123int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs); 123int snd_hdac_refresh_widgets(struct hdac_device *codec);
124 124
125unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid, 125unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid,
126 unsigned int verb, unsigned int parm); 126 unsigned int verb, unsigned int parm);
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 4769f4c03e14..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,32 +394,35 @@ 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 */
399int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs) 398int 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; 401 int nums, err = 0;
403 402
403 /*
404 * Serialize against multiple threads trying to update the sysfs
405 * widgets array.
406 */
407 mutex_lock(&codec->widget_lock);
404 nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); 408 nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid);
405 if (!start_nid || nums <= 0 || nums >= 0xff) { 409 if (!start_nid || nums <= 0 || nums >= 0xff) {
406 dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", 410 dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n",
407 codec->afg); 411 codec->afg);
408 return -EINVAL; 412 err = -EINVAL;
413 goto unlock;
409 } 414 }
410 415
411 if (sysfs) { 416 err = hda_widget_sysfs_reinit(codec, start_nid, nums);
412 mutex_lock(&codec->widget_lock); 417 if (err < 0)
413 err = hda_widget_sysfs_reinit(codec, start_nid, nums); 418 goto unlock;
414 mutex_unlock(&codec->widget_lock);
415 if (err < 0)
416 return err;
417 }
418 419
419 codec->num_nodes = nums; 420 codec->num_nodes = nums;
420 codec->start_nid = start_nid; 421 codec->start_nid = start_nid;
421 codec->end_nid = start_nid + nums; 422 codec->end_nid = start_nid + nums;
422 return 0; 423unlock:
424 mutex_unlock(&codec->widget_lock);
425 return err;
423} 426}
424EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets); 427EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets);
425 428
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)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index ccb53f1c1e1a..7d8834907f1f 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1016,7 +1016,7 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)
1016 hda_nid_t fg; 1016 hda_nid_t fg;
1017 int err; 1017 int err;
1018 1018
1019 err = snd_hdac_refresh_widgets(&codec->core, true); 1019 err = snd_hdac_refresh_widgets(&codec->core);
1020 if (err < 0) 1020 if (err < 0)
1021 return err; 1021 return err;
1022 1022
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 660e0587f399..6302ad5b7128 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -2043,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_device *hdev)
2043 "Failed in parse and map nid with err: %d\n", ret); 2043 "Failed in parse and map nid with err: %d\n", ret);
2044 return ret; 2044 return ret;
2045 } 2045 }
2046 snd_hdac_refresh_widgets(hdev, true); 2046 snd_hdac_refresh_widgets(hdev);
2047 2047
2048 /* ASoC specific initialization */ 2048 /* ASoC specific initialization */
2049 ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, 2049 ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec,
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
index 72c6f8e82a7e..78c2d6cab3b5 100644
--- a/sound/usb/line6/pcm.c
+++ b/sound/usb/line6/pcm.c
@@ -560,6 +560,11 @@ int line6_init_pcm(struct usb_line6 *line6,
560 line6pcm->max_packet_size_out = 560 line6pcm->max_packet_size_out =
561 usb_maxpacket(line6->usbdev, 561 usb_maxpacket(line6->usbdev,
562 usb_sndisocpipe(line6->usbdev, ep_write), 1); 562 usb_sndisocpipe(line6->usbdev, ep_write), 1);
563 if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {
564 dev_err(line6pcm->line6->ifcdev,
565 "cannot get proper max packet size\n");
566 return -EINVAL;
567 }
563 568
564 spin_lock_init(&line6pcm->out.lock); 569 spin_lock_init(&line6pcm->out.lock);
565 spin_lock_init(&line6pcm->in.lock); 570 spin_lock_init(&line6pcm->in.lock);