--- zzzz-none-000/linux-3.10.107/drivers/media/usb/cx231xx/cx231xx-audio.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/usb/cx231xx/cx231xx-audio.c 2021-02-04 17:41:59.000000000 +0000 @@ -20,8 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "cx231xx.h" #include -#include #include #include #include @@ -37,25 +37,18 @@ #include #include #include -#include "cx231xx.h" static int debug; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "activates debug info"); -#define dprintk(fmt, arg...) do { \ - if (debug) \ - printk(KERN_INFO "cx231xx-audio %s: " fmt, \ - __func__, ##arg); \ - } while (0) - static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; static int cx231xx_isoc_audio_deinit(struct cx231xx *dev) { int i; - dprintk("Stopping isoc\n"); + dev_dbg(dev->dev, "Stopping isoc\n"); for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { if (dev->adev.urb[i]) { @@ -79,7 +72,7 @@ { int i; - dprintk("Stopping bulk\n"); + dev_dbg(dev->dev, "Stopping bulk\n"); for (i = 0; i < CX231XX_AUDIO_BUFS; i++) { if (dev->adev.urb[i]) { @@ -123,7 +116,8 @@ case -ESHUTDOWN: return; default: /* error */ - dprintk("urb completition error %d.\n", urb->status); + dev_dbg(dev->dev, "urb completition error %d.\n", + urb->status); break; } @@ -182,8 +176,9 @@ status = usb_submit_urb(urb, GFP_ATOMIC); if (status < 0) { - cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", - status); + dev_err(dev->dev, + "resubmit of audio urb failed (error=%i)\n", + status); } return; } @@ -211,7 +206,8 @@ case -ESHUTDOWN: return; default: /* error */ - dprintk("urb completition error %d.\n", urb->status); + dev_dbg(dev->dev, "urb completition error %d.\n", + urb->status); break; } @@ -266,8 +262,9 @@ status = usb_submit_urb(urb, GFP_ATOMIC); if (status < 0) { - cx231xx_errdev("resubmit of audio urb failed (error=%i)\n", - status); + dev_err(dev->dev, + "resubmit of audio urb failed (error=%i)\n", + status); } return; } @@ -277,7 +274,8 @@ int i, errCode; int sb_size; - cx231xx_info("%s: Starting ISO AUDIO transfers\n", __func__); + dev_dbg(dev->dev, + "%s: Starting ISO AUDIO transfers\n", __func__); if (dev->state & DEV_DISCONNECTED) return -ENODEV; @@ -295,7 +293,7 @@ memset(dev->adev.transfer_buffer[i], 0x80, sb_size); urb = usb_alloc_urb(CX231XX_ISO_NUM_AUDIO_PACKETS, GFP_ATOMIC); if (!urb) { - cx231xx_errdev("usb_alloc_urb failed!\n"); + dev_err(dev->dev, "usb_alloc_urb failed!\n"); for (j = 0; j < i; j++) { usb_free_urb(dev->adev.urb[j]); kfree(dev->adev.transfer_buffer[j]); @@ -338,7 +336,8 @@ int i, errCode; int sb_size; - cx231xx_info("%s: Starting BULK AUDIO transfers\n", __func__); + dev_dbg(dev->dev, + "%s: Starting BULK AUDIO transfers\n", __func__); if (dev->state & DEV_DISCONNECTED) return -ENODEV; @@ -356,7 +355,7 @@ memset(dev->adev.transfer_buffer[i], 0x80, sb_size); urb = usb_alloc_urb(CX231XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); if (!urb) { - cx231xx_errdev("usb_alloc_urb failed!\n"); + dev_err(dev->dev, "usb_alloc_urb failed!\n"); for (j = 0; j < i; j++) { usb_free_urb(dev->adev.urb[j]); kfree(dev->adev.transfer_buffer[j]); @@ -392,8 +391,9 @@ size_t size) { struct snd_pcm_runtime *runtime = subs->runtime; + struct cx231xx *dev = snd_pcm_substream_chip(subs); - dprintk("Allocating vbuffer\n"); + dev_dbg(dev->dev, "Allocating vbuffer\n"); if (runtime->dma_area) { if (runtime->dma_bytes > size) return 0; @@ -436,16 +436,12 @@ struct snd_pcm_runtime *runtime = substream->runtime; int ret = 0; - dprintk("opening device and trying to acquire exclusive lock\n"); - - if (!dev) { - cx231xx_errdev("BUG: cx231xx can't find device struct." - " Can't proceed with open\n"); - return -ENODEV; - } + dev_dbg(dev->dev, + "opening device and trying to acquire exclusive lock\n"); if (dev->state & DEV_DISCONNECTED) { - cx231xx_errdev("Can't open. the device was removed.\n"); + dev_err(dev->dev, + "Can't open. the device was removed.\n"); return -ENODEV; } @@ -458,7 +454,8 @@ ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); mutex_unlock(&dev->lock); if (ret < 0) { - cx231xx_errdev("failed to set alternate setting !\n"); + dev_err(dev->dev, + "failed to set alternate setting !\n"); return ret; } @@ -484,7 +481,7 @@ int ret; struct cx231xx *dev = snd_pcm_substream_chip(substream); - dprintk("closing device\n"); + dev_dbg(dev->dev, "closing device\n"); /* inform hardware to stop streaming */ mutex_lock(&dev->lock); @@ -494,7 +491,8 @@ /* 1 - 48000 samples per sec */ ret = cx231xx_set_alt_setting(dev, INDEX_AUDIO, 0); if (ret < 0) { - cx231xx_errdev("failed to set alternate setting !\n"); + dev_err(dev->dev, + "failed to set alternate setting !\n"); mutex_unlock(&dev->lock); return ret; @@ -504,10 +502,10 @@ mutex_unlock(&dev->lock); if (dev->adev.users == 0 && dev->adev.shutdown == 1) { - dprintk("audio users: %d\n", dev->adev.users); - dprintk("disabling audio stream!\n"); + dev_dbg(dev->dev, "audio users: %d\n", dev->adev.users); + dev_dbg(dev->dev, "disabling audio stream!\n"); dev->adev.shutdown = 0; - dprintk("released lock\n"); + dev_dbg(dev->dev, "released lock\n"); if (atomic_read(&dev->stream_started) > 0) { atomic_set(&dev->stream_started, 0); schedule_work(&dev->wq_trigger); @@ -519,9 +517,10 @@ static int snd_cx231xx_hw_capture_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { + struct cx231xx *dev = snd_pcm_substream_chip(substream); int ret; - dprintk("Setting capture parameters\n"); + dev_dbg(dev->dev, "Setting capture parameters\n"); ret = snd_pcm_alloc_vmalloc_buffer(substream, params_buffer_bytes(hw_params)); @@ -543,7 +542,7 @@ { struct cx231xx *dev = snd_pcm_substream_chip(substream); - dprintk("Stop capture, if needed\n"); + dev_dbg(dev->dev, "Stop capture, if needed\n"); if (atomic_read(&dev->stream_started) > 0) { atomic_set(&dev->stream_started, 0); @@ -568,7 +567,7 @@ struct cx231xx *dev = container_of(work, struct cx231xx, wq_trigger); if (atomic_read(&dev->stream_started)) { - dprintk("starting capture"); + dev_dbg(dev->dev, "starting capture"); if (is_fw_load(dev) == 0) cx25840_call(dev, core, load_fw); if (dev->USE_ISO) @@ -576,7 +575,7 @@ else cx231xx_init_audio_bulk(dev); } else { - dprintk("stopping capture"); + dev_dbg(dev->dev, "stopping capture"); cx231xx_isoc_audio_deinit(dev); } } @@ -662,11 +661,11 @@ return 0; } - cx231xx_info("cx231xx-audio.c: probing for cx231xx " - "non standard usbaudio\n"); + dev_dbg(dev->dev, + "probing for cx231xx non standard usbaudio\n"); - err = snd_card_create(index[devnr], "Cx231xx Audio", THIS_MODULE, - 0, &card); + err = snd_card_new(dev->dev, index[devnr], "Cx231xx Audio", + THIS_MODULE, 0, &card); if (err < 0) return err; @@ -682,7 +681,6 @@ pcm->info_flags = 0; pcm->private_data = dev; strcpy(pcm->name, "Conexant cx231xx Capture"); - snd_card_set_dev(card, &dev->udev->dev); strcpy(card->driver, "Cx231xx-Audio"); strcpy(card->shortname, "Cx231xx Audio"); strcpy(card->longname, "Conexant cx231xx Audio"); @@ -708,14 +706,13 @@ bEndpointAddress; adev->num_alt = uif->num_altsetting; - cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", - adev->end_point_addr, adev->num_alt); + dev_info(dev->dev, + "audio EndPoint Addr 0x%x, Alternate settings: %i\n", + adev->end_point_addr, adev->num_alt); adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); - if (adev->alt_max_pkt_size == NULL) { - cx231xx_errdev("out of memory!\n"); + if (adev->alt_max_pkt_size == NULL) return -ENOMEM; - } for (i = 0; i < adev->num_alt; i++) { u16 tmp = @@ -723,8 +720,9 @@ wMaxPacketSize); adev->alt_max_pkt_size[i] = (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); - cx231xx_info("Alternate setting %i, max size= %i\n", i, - adev->alt_max_pkt_size[i]); + dev_dbg(dev->dev, + "audio alternate setting %i, max size= %i\n", i, + adev->alt_max_pkt_size[i]); } return 0;