Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: oss: Use standard printk helpers

Use dev_err() & co as much as possible. If not available (no device
assigned at the calling point), use pr_xxx() helpers instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

+55 -56
+7 -5
sound/core/oss/mixer_oss.c
··· 1187 1187 if (oss_mixer_names[ch] && strcmp(oss_mixer_names[ch], str) == 0) 1188 1188 break; 1189 1189 if (ch >= SNDRV_OSS_MAX_MIXERS) { 1190 - snd_printk(KERN_ERR "mixer_oss: invalid OSS volume '%s'\n", str); 1190 + pr_err("ALSA: mixer_oss: invalid OSS volume '%s'\n", 1191 + str); 1191 1192 continue; 1192 1193 } 1193 1194 cptr = snd_info_get_str(str, cptr, sizeof(str)); ··· 1202 1201 snd_info_get_str(idxstr, cptr, sizeof(idxstr)); 1203 1202 idx = simple_strtoul(idxstr, NULL, 10); 1204 1203 if (idx >= 0x4000) { /* too big */ 1205 - snd_printk(KERN_ERR "mixer_oss: invalid index %d\n", idx); 1204 + pr_err("ALSA: mixer_oss: invalid index %d\n", idx); 1206 1205 continue; 1207 1206 } 1208 1207 mutex_lock(&mixer->reg_mutex); ··· 1213 1212 goto __unlock; 1214 1213 tbl = kmalloc(sizeof(*tbl), GFP_KERNEL); 1215 1214 if (! tbl) { 1216 - snd_printk(KERN_ERR "mixer_oss: no memory\n"); 1215 + pr_err("ALSA: mixer_oss: no memory\n"); 1217 1216 goto __unlock; 1218 1217 } 1219 1218 tbl->oss_id = ch; ··· 1353 1352 if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, 1354 1353 card, 0, 1355 1354 &snd_mixer_oss_f_ops, card)) < 0) { 1356 - snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", 1357 - card->number, 0); 1355 + dev_err(card->dev, 1356 + "unable to register OSS mixer device %i:%i\n", 1357 + card->number, 0); 1358 1358 kfree(mixer); 1359 1359 return err; 1360 1360 }
+48 -51
sound/core/oss/pcm_oss.c
··· 854 854 params = kmalloc(sizeof(*params), GFP_KERNEL); 855 855 sparams = kmalloc(sizeof(*sparams), GFP_KERNEL); 856 856 if (!sw_params || !params || !sparams) { 857 - snd_printd("No memory\n"); 857 + pcm_dbg(substream->pcm, "No memory\n"); 858 858 err = -ENOMEM; 859 859 goto failure; 860 860 } ··· 877 877 } 878 878 err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask); 879 879 if (err < 0) { 880 - snd_printd("No usable accesses\n"); 880 + pcm_dbg(substream->pcm, "No usable accesses\n"); 881 881 err = -EINVAL; 882 882 goto failure; 883 883 } ··· 902 902 break; 903 903 } 904 904 if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) { 905 - snd_printd("Cannot find a format!!!\n"); 905 + pcm_dbg(substream->pcm, "Cannot find a format!!!\n"); 906 906 err = -EINVAL; 907 907 goto failure; 908 908 } ··· 942 942 if ((err = snd_pcm_plug_format_plugins(substream, 943 943 params, 944 944 sparams)) < 0) { 945 - snd_printd("snd_pcm_plug_format_plugins failed: %i\n", err); 945 + pcm_dbg(substream->pcm, 946 + "snd_pcm_plug_format_plugins failed: %i\n", err); 946 947 snd_pcm_oss_plugin_clear(substream); 947 948 goto failure; 948 949 } 949 950 if (runtime->oss.plugin_first) { 950 951 struct snd_pcm_plugin *plugin; 951 952 if ((err = snd_pcm_plugin_build_io(substream, sparams, &plugin)) < 0) { 952 - snd_printd("snd_pcm_plugin_build_io failed: %i\n", err); 953 + pcm_dbg(substream->pcm, 954 + "snd_pcm_plugin_build_io failed: %i\n", err); 953 955 snd_pcm_oss_plugin_clear(substream); 954 956 goto failure; 955 957 } ··· 985 983 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 986 984 987 985 if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams)) < 0) { 988 - snd_printd("HW_PARAMS failed: %i\n", err); 986 + pcm_dbg(substream->pcm, "HW_PARAMS failed: %i\n", err); 989 987 goto failure; 990 988 } 991 989 ··· 1018 1016 } 1019 1017 1020 1018 if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_SW_PARAMS, sw_params)) < 0) { 1021 - snd_printd("SW_PARAMS failed: %i\n", err); 1019 + pcm_dbg(substream->pcm, "SW_PARAMS failed: %i\n", err); 1022 1020 goto failure; 1023 1021 } 1024 1022 ··· 1112 1110 1113 1111 err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL); 1114 1112 if (err < 0) { 1115 - snd_printd("snd_pcm_oss_prepare: SNDRV_PCM_IOCTL_PREPARE failed\n"); 1113 + pcm_dbg(substream->pcm, 1114 + "snd_pcm_oss_prepare: SNDRV_PCM_IOCTL_PREPARE failed\n"); 1116 1115 return err; 1117 1116 } 1118 1117 runtime->oss.prepare = 0; ··· 1178 1175 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || 1179 1176 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1180 1177 #ifdef OSS_DEBUG 1181 - if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1182 - printk(KERN_DEBUG "pcm_oss: write: " 1183 - "recovering from XRUN\n"); 1184 - else 1185 - printk(KERN_DEBUG "pcm_oss: write: " 1186 - "recovering from SUSPEND\n"); 1178 + pcm_dbg(substream->pcm, 1179 + "pcm_oss: write: recovering from %s\n", 1180 + runtime->status->state == SNDRV_PCM_STATE_XRUN ? 1181 + "XRUN" : "SUSPEND"); 1187 1182 #endif 1188 1183 ret = snd_pcm_oss_prepare(substream); 1189 1184 if (ret < 0) ··· 1214 1213 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || 1215 1214 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1216 1215 #ifdef OSS_DEBUG 1217 - if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1218 - printk(KERN_DEBUG "pcm_oss: read: " 1219 - "recovering from XRUN\n"); 1220 - else 1221 - printk(KERN_DEBUG "pcm_oss: read: " 1222 - "recovering from SUSPEND\n"); 1216 + pcm_dbg(substream->pcm, 1217 + "pcm_oss: read: recovering from %s\n", 1218 + runtime->status->state == SNDRV_PCM_STATE_XRUN ? 1219 + "XRUN" : "SUSPEND"); 1223 1220 #endif 1224 1221 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); 1225 1222 if (ret < 0) ··· 1260 1261 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || 1261 1262 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1262 1263 #ifdef OSS_DEBUG 1263 - if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1264 - printk(KERN_DEBUG "pcm_oss: writev: " 1265 - "recovering from XRUN\n"); 1266 - else 1267 - printk(KERN_DEBUG "pcm_oss: writev: " 1268 - "recovering from SUSPEND\n"); 1264 + pcm_dbg(substream->pcm, 1265 + "pcm_oss: writev: recovering from %s\n", 1266 + runtime->status->state == SNDRV_PCM_STATE_XRUN ? 1267 + "XRUN" : "SUSPEND"); 1269 1268 #endif 1270 1269 ret = snd_pcm_oss_prepare(substream); 1271 1270 if (ret < 0) ··· 1296 1299 if (runtime->status->state == SNDRV_PCM_STATE_XRUN || 1297 1300 runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { 1298 1301 #ifdef OSS_DEBUG 1299 - if (runtime->status->state == SNDRV_PCM_STATE_XRUN) 1300 - printk(KERN_DEBUG "pcm_oss: readv: " 1301 - "recovering from XRUN\n"); 1302 - else 1303 - printk(KERN_DEBUG "pcm_oss: readv: " 1304 - "recovering from SUSPEND\n"); 1302 + pcm_dbg(substream->pcm, 1303 + "pcm_oss: readv: recovering from %s\n", 1304 + runtime->status->state == SNDRV_PCM_STATE_XRUN ? 1305 + "XRUN" : "SUSPEND"); 1305 1306 #endif 1306 1307 ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); 1307 1308 if (ret < 0) ··· 1556 1561 init_waitqueue_entry(&wait, current); 1557 1562 add_wait_queue(&runtime->sleep, &wait); 1558 1563 #ifdef OSS_DEBUG 1559 - printk(KERN_DEBUG "sync1: size = %li\n", size); 1564 + pcm_dbg(substream->pcm, "sync1: size = %li\n", size); 1560 1565 #endif 1561 1566 while (1) { 1562 1567 result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1); ··· 1582 1587 break; 1583 1588 } 1584 1589 if (res == 0) { 1585 - snd_printk(KERN_ERR "OSS sync error - DMA timeout\n"); 1590 + pcm_err(substream->pcm, 1591 + "OSS sync error - DMA timeout\n"); 1586 1592 result = -EIO; 1587 1593 break; 1588 1594 } ··· 1614 1618 mutex_lock(&runtime->oss.params_lock); 1615 1619 if (runtime->oss.buffer_used > 0) { 1616 1620 #ifdef OSS_DEBUG 1617 - printk(KERN_DEBUG "sync: buffer_used\n"); 1621 + pcm_dbg(substream->pcm, "sync: buffer_used\n"); 1618 1622 #endif 1619 1623 size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width; 1620 1624 snd_pcm_format_set_silence(format, ··· 1627 1631 } 1628 1632 } else if (runtime->oss.period_ptr > 0) { 1629 1633 #ifdef OSS_DEBUG 1630 - printk(KERN_DEBUG "sync: period_ptr\n"); 1634 + pcm_dbg(substream->pcm, "sync: period_ptr\n"); 1631 1635 #endif 1632 1636 size = runtime->oss.period_bytes - runtime->oss.period_ptr; 1633 1637 snd_pcm_format_set_silence(format, ··· 1979 1983 int err, cmd; 1980 1984 1981 1985 #ifdef OSS_DEBUG 1982 - printk(KERN_DEBUG "pcm_oss: trigger = 0x%x\n", trigger); 1986 + pcm_dbg(substream->pcm, "pcm_oss: trigger = 0x%x\n", trigger); 1983 1987 #endif 1984 1988 1985 1989 psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; ··· 2199 2203 } 2200 2204 2201 2205 #ifdef OSS_DEBUG 2202 - printk(KERN_DEBUG "pcm_oss: space: bytes = %i, fragments = %i, " 2203 - "fragstotal = %i, fragsize = %i\n", 2204 - info.bytes, info.fragments, info.fragstotal, info.fragsize); 2206 + pcm_dbg(substream->pcm, 2207 + "pcm_oss: space: bytes = %i, fragments = %i, fragstotal = %i, fragsize = %i\n", 2208 + info.bytes, info.fragments, info.fragstotal, info.fragsize); 2205 2209 #endif 2206 2210 if (copy_to_user(_info, &info, sizeof(info))) 2207 2211 return -EFAULT; ··· 2211 2215 static int snd_pcm_oss_get_mapbuf(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct buffmem_desc __user * _info) 2212 2216 { 2213 2217 // it won't be probably implemented 2214 - // snd_printd("TODO: snd_pcm_oss_get_mapbuf\n"); 2218 + // pr_debug("TODO: snd_pcm_oss_get_mapbuf\n"); 2215 2219 return -EINVAL; 2216 2220 } 2217 2221 ··· 2515 2519 if (((cmd >> 8) & 0xff) != 'P') 2516 2520 return -EINVAL; 2517 2521 #ifdef OSS_DEBUG 2518 - printk(KERN_DEBUG "pcm_oss: ioctl = 0x%x\n", cmd); 2522 + pr_debug("pcm_oss: ioctl = 0x%x\n", cmd); 2519 2523 #endif 2520 2524 switch (cmd) { 2521 2525 case SNDCTL_DSP_RESET: ··· 2642 2646 case SNDCTL_DSP_PROFILE: 2643 2647 return 0; /* silently ignore */ 2644 2648 default: 2645 - snd_printd("pcm_oss: unknown command = 0x%x\n", cmd); 2649 + pr_debug("pcm_oss: unknown command = 0x%x\n", cmd); 2646 2650 } 2647 2651 return -EINVAL; 2648 2652 } ··· 2669 2673 #else 2670 2674 { 2671 2675 ssize_t res = snd_pcm_oss_read1(substream, buf, count); 2672 - printk(KERN_DEBUG "pcm_oss: read %li bytes " 2673 - "(returned %li bytes)\n", (long)count, (long)res); 2676 + pcm_dbg(substream->pcm, 2677 + "pcm_oss: read %li bytes (returned %li bytes)\n", 2678 + (long)count, (long)res); 2674 2679 return res; 2675 2680 } 2676 2681 #endif ··· 2690 2693 substream->f_flags = file->f_flags & O_NONBLOCK; 2691 2694 result = snd_pcm_oss_write1(substream, buf, count); 2692 2695 #ifdef OSS_DEBUG 2693 - printk(KERN_DEBUG "pcm_oss: write %li bytes (wrote %li bytes)\n", 2696 + pcm_dbg(substream->pcm, "pcm_oss: write %li bytes (wrote %li bytes)\n", 2694 2697 (long)count, (long)result); 2695 2698 #endif 2696 2699 return result; ··· 2769 2772 int err; 2770 2773 2771 2774 #ifdef OSS_DEBUG 2772 - printk(KERN_DEBUG "pcm_oss: mmap begin\n"); 2775 + pr_debug("pcm_oss: mmap begin\n"); 2773 2776 #endif 2774 2777 pcm_oss_file = file->private_data; 2775 2778 switch ((area->vm_flags & (VM_READ | VM_WRITE))) { ··· 2819 2822 runtime->silence_threshold = 0; 2820 2823 runtime->silence_size = 0; 2821 2824 #ifdef OSS_DEBUG 2822 - printk(KERN_DEBUG "pcm_oss: mmap ok, bytes = 0x%x\n", 2825 + pr_debug("pcm_oss: mmap ok, bytes = 0x%x\n", 2823 2826 runtime->oss.mmap_bytes); 2824 2827 #endif 2825 2828 /* In mmap mode we never stop */ ··· 3007 3010 if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, 3008 3011 pcm->card, index, &snd_pcm_oss_f_reg, 3009 3012 pcm) < 0) { 3010 - snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", 3013 + pcm_err(pcm, "unable to register OSS PCM device %i:%i\n", 3011 3014 pcm->card->number, pcm->device); 3012 3015 } 3013 3016 } ··· 3088 3091 /* check device map table */ 3089 3092 for (i = 0; i < SNDRV_CARDS; i++) { 3090 3093 if (dsp_map[i] < 0 || dsp_map[i] >= SNDRV_PCM_DEVICES) { 3091 - snd_printk(KERN_ERR "invalid dsp_map[%d] = %d\n", 3094 + pr_err("ALSA: pcm_oss: invalid dsp_map[%d] = %d\n", 3092 3095 i, dsp_map[i]); 3093 3096 dsp_map[i] = 0; 3094 3097 } 3095 3098 if (adsp_map[i] < 0 || adsp_map[i] >= SNDRV_PCM_DEVICES) { 3096 - snd_printk(KERN_ERR "invalid adsp_map[%d] = %d\n", 3099 + pr_err("ALSA: pcm_oss: invalid adsp_map[%d] = %d\n", 3097 3100 i, adsp_map[i]); 3098 3101 adsp_map[i] = 1; 3099 3102 }