Commit b89b889a authored by Takashi Iwai's avatar Takashi Iwai

Merge branch 'topic/hda-refresh-cleanup' into for-next

Merge a cleanup for HD-audio widget refresh code
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parents d4bd3053 774a075a
...@@ -120,7 +120,7 @@ void snd_hdac_device_unregister(struct hdac_device *codec); ...@@ -120,7 +120,7 @@ void snd_hdac_device_unregister(struct hdac_device *codec);
int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name); int snd_hdac_device_set_chip_name(struct hdac_device *codec, const char *name);
int snd_hdac_codec_modalias(struct hdac_device *hdac, char *buf, size_t size); int snd_hdac_codec_modalias(struct hdac_device *hdac, char *buf, size_t size);
int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs); int snd_hdac_refresh_widgets(struct hdac_device *codec);
unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid, unsigned int snd_hdac_make_cmd(struct hdac_device *codec, hda_nid_t nid,
unsigned int verb, unsigned int parm); unsigned int verb, unsigned int parm);
......
...@@ -89,7 +89,7 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, ...@@ -89,7 +89,7 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus,
fg = codec->afg ? codec->afg : codec->mfg; fg = codec->afg ? codec->afg : codec->mfg;
err = snd_hdac_refresh_widgets(codec, false); err = snd_hdac_refresh_widgets(codec);
if (err < 0) if (err < 0)
goto error; goto error;
...@@ -394,32 +394,35 @@ static void setup_fg_nodes(struct hdac_device *codec) ...@@ -394,32 +394,35 @@ static void setup_fg_nodes(struct hdac_device *codec)
/** /**
* snd_hdac_refresh_widgets - Reset the widget start/end nodes * snd_hdac_refresh_widgets - Reset the widget start/end nodes
* @codec: the codec object * @codec: the codec object
* @sysfs: re-initialize sysfs tree, too
*/ */
int snd_hdac_refresh_widgets(struct hdac_device *codec, bool sysfs) int snd_hdac_refresh_widgets(struct hdac_device *codec)
{ {
hda_nid_t start_nid; hda_nid_t start_nid;
int nums, err; int nums, err = 0;
/*
* Serialize against multiple threads trying to update the sysfs
* widgets array.
*/
mutex_lock(&codec->widget_lock);
nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid); nums = snd_hdac_get_sub_nodes(codec, codec->afg, &start_nid);
if (!start_nid || nums <= 0 || nums >= 0xff) { if (!start_nid || nums <= 0 || nums >= 0xff) {
dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n", dev_err(&codec->dev, "cannot read sub nodes for FG 0x%02x\n",
codec->afg); codec->afg);
return -EINVAL; err = -EINVAL;
goto unlock;
} }
if (sysfs) { err = hda_widget_sysfs_reinit(codec, start_nid, nums);
mutex_lock(&codec->widget_lock); if (err < 0)
err = hda_widget_sysfs_reinit(codec, start_nid, nums); goto unlock;
mutex_unlock(&codec->widget_lock);
if (err < 0)
return err;
}
codec->num_nodes = nums; codec->num_nodes = nums;
codec->start_nid = start_nid; codec->start_nid = start_nid;
codec->end_nid = start_nid + nums; codec->end_nid = start_nid + nums;
return 0; unlock:
mutex_unlock(&codec->widget_lock);
return err;
} }
EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets); EXPORT_SYMBOL_GPL(snd_hdac_refresh_widgets);
......
...@@ -428,7 +428,7 @@ int hda_widget_sysfs_reinit(struct hdac_device *codec, ...@@ -428,7 +428,7 @@ int hda_widget_sysfs_reinit(struct hdac_device *codec,
int i; int i;
if (!codec->widgets) if (!codec->widgets)
return hda_widget_sysfs_init(codec); return 0;
tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL); tree = kmemdup(codec->widgets, sizeof(*tree), GFP_KERNEL);
if (!tree) if (!tree)
......
...@@ -1016,7 +1016,7 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec) ...@@ -1016,7 +1016,7 @@ int snd_hda_codec_update_widgets(struct hda_codec *codec)
hda_nid_t fg; hda_nid_t fg;
int err; int err;
err = snd_hdac_refresh_widgets(&codec->core, true); err = snd_hdac_refresh_widgets(&codec->core);
if (err < 0) if (err < 0)
return err; return err;
......
...@@ -2043,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_device *hdev) ...@@ -2043,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_device *hdev)
"Failed in parse and map nid with err: %d\n", ret); "Failed in parse and map nid with err: %d\n", ret);
return ret; return ret;
} }
snd_hdac_refresh_widgets(hdev, true); snd_hdac_refresh_widgets(hdev);
/* ASoC specific initialization */ /* ASoC specific initialization */
ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec,
......
...@@ -560,6 +560,11 @@ int line6_init_pcm(struct usb_line6 *line6, ...@@ -560,6 +560,11 @@ int line6_init_pcm(struct usb_line6 *line6,
line6pcm->max_packet_size_out = line6pcm->max_packet_size_out =
usb_maxpacket(line6->usbdev, usb_maxpacket(line6->usbdev,
usb_sndisocpipe(line6->usbdev, ep_write), 1); usb_sndisocpipe(line6->usbdev, ep_write), 1);
if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) {
dev_err(line6pcm->line6->ifcdev,
"cannot get proper max packet size\n");
return -EINVAL;
}
spin_lock_init(&line6pcm->out.lock); spin_lock_init(&line6pcm->out.lock);
spin_lock_init(&line6pcm->in.lock); spin_lock_init(&line6pcm->in.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment