--- zzzz-none-000/linux-3.10.107/sound/usb/clock.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/usb/clock.c 2021-02-04 17:41:59.000000000 +0000 @@ -115,9 +115,9 @@ return ret; if (ret != sizeof(pin)) { - snd_printk(KERN_ERR - "usb-audio:%d: setting selector (id %d) unexpected length %d\n", - chip->dev->devnum, selector_id, ret); + usb_audio_err(chip, + "setting selector (id %d) unexpected length %d\n", + selector_id, ret); return -EINVAL; } @@ -126,9 +126,9 @@ return ret; if (ret != pin) { - snd_printk(KERN_ERR - "usb-audio:%d: setting selector (id %d) to %x failed (current: %d)\n", - chip->dev->devnum, selector_id, pin, ret); + usb_audio_err(chip, + "setting selector (id %d) to %x failed (current: %d)\n", + selector_id, pin, ret); return -EINVAL; } @@ -158,7 +158,8 @@ &data, sizeof(data)); if (err < 0) { - snd_printk(KERN_WARNING "%s(): cannot get clock validity for id %d\n", + dev_warn(&dev->dev, + "%s(): cannot get clock validity for id %d\n", __func__, source_id); return 0; } @@ -177,9 +178,9 @@ entity_id &= 0xff; if (test_and_set_bit(entity_id, visited)) { - snd_printk(KERN_WARNING - "%s(): recursive clock topology detected, id %d.\n", - __func__, entity_id); + usb_audio_warn(chip, + "%s(): recursive clock topology detected, id %d.\n", + __func__, entity_id); return -EINVAL; } @@ -188,8 +189,9 @@ if (source) { entity_id = source->bClockID; if (validate && !uac_clock_source_is_valid(chip, entity_id)) { - snd_printk(KERN_ERR "usb-audio:%d: clock source %d is not valid, cannot use\n", - chip->dev->devnum, entity_id); + usb_audio_err(chip, + "clock source %d is not valid, cannot use\n", + entity_id); return -ENXIO; } return entity_id; @@ -208,7 +210,7 @@ /* Selector values are one-based */ if (ret > selector->bNrInPins || ret < 1) { - snd_printk(KERN_ERR + usb_audio_err(chip, "%s(): selector reported illegal value, id %d, ret %d\n", __func__, selector->bClockID, ret); @@ -237,9 +239,9 @@ if (err < 0) continue; - snd_printk(KERN_INFO - "usb-audio:%d: found and selected valid clock source %d\n", - chip->dev->devnum, ret); + usb_audio_info(chip, + "found and selected valid clock source %d\n", + ret); return ret; } @@ -283,6 +285,8 @@ unsigned char data[3]; int err, crate; + if (get_iface_desc(alts)->bNumEndpoints < 1) + return -EINVAL; ep = get_endpoint(alts, 0)->bEndpointAddress; /* if endpoint doesn't have sampling rate control, bail out */ @@ -296,23 +300,28 @@ USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_OUT, UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, sizeof(data))) < 0) { - snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep %#x\n", - dev->devnum, iface, fmt->altsetting, rate, ep); + dev_err(&dev->dev, "%d:%d: cannot set freq %d to ep %#x\n", + iface, fmt->altsetting, rate, ep); return err; } + /* Don't check the sample rate for devices which we know don't + * support reading */ + if (snd_usb_get_sample_rate_quirk(chip)) + return 0; + if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), UAC_GET_CUR, USB_TYPE_CLASS | USB_RECIP_ENDPOINT | USB_DIR_IN, UAC_EP_CS_ATTR_SAMPLE_RATE << 8, ep, data, sizeof(data))) < 0) { - snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep %#x\n", - dev->devnum, iface, fmt->altsetting, ep); + dev_err(&dev->dev, "%d:%d: cannot get freq at ep %#x\n", + iface, fmt->altsetting, ep); return 0; /* some devices don't support reading */ } crate = data[0] | (data[1] << 8) | (data[2] << 16); if (crate != rate) { - snd_printd(KERN_WARNING "current rate %d is different from the runtime rate %d\n", crate, rate); + dev_warn(&dev->dev, "current rate %d is different from the runtime rate %d\n", crate, rate); // runtime->rate = crate; } @@ -332,8 +341,8 @@ snd_usb_ctrl_intf(chip) | (clock << 8), &data, sizeof(data)); if (err < 0) { - snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq (v2): err %d\n", - dev->devnum, iface, altsetting, err); + dev_warn(&dev->dev, "%d:%d: cannot get freq (v2): err %d\n", + iface, altsetting, err); return 0; } @@ -369,8 +378,9 @@ snd_usb_ctrl_intf(chip) | (clock << 8), &data, sizeof(data)); if (err < 0) { - snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d (v2): err %d\n", - dev->devnum, iface, fmt->altsetting, rate, err); + usb_audio_err(chip, + "%d:%d: cannot set freq %d (v2): err %d\n", + iface, fmt->altsetting, rate, err); return err; } @@ -381,14 +391,14 @@ if (cur_rate != rate) { if (!writeable) { - snd_printk(KERN_WARNING - "%d:%d:%d: freq mismatch (RO clock): req %d, clock runs @%d\n", - dev->devnum, iface, fmt->altsetting, rate, cur_rate); + usb_audio_warn(chip, + "%d:%d: freq mismatch (RO clock): req %d, clock runs @%d\n", + iface, fmt->altsetting, rate, cur_rate); return -ENXIO; } - snd_printd(KERN_WARNING - "current rate %d is different from the runtime rate %d\n", - cur_rate, rate); + usb_audio_dbg(chip, + "current rate %d is different from the runtime rate %d\n", + cur_rate, rate); } /* Some devices doesn't respond to sample rate changes while the @@ -407,9 +417,7 @@ struct usb_host_interface *alts, struct audioformat *fmt, int rate) { - struct usb_interface_descriptor *altsd = get_iface_desc(alts); - - switch (altsd->bInterfaceProtocol) { + switch (fmt->protocol) { case UAC_VERSION_1: default: return set_sample_rate_v1(chip, iface, alts, fmt, rate);