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

ALSA: sscape: Use standard print API

Use the standard print API with dev_*() instead of the old house-baked
one. It gives better information and allows dynamically control of
debug prints.

The device pointer is stored in struct soundscape for calling
dev_*().

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20240807133452.9424-35-tiwai@suse.de

+48 -48
+48 -48
sound/isa/sscape.c
··· 138 138 struct snd_wss *chip; 139 139 140 140 unsigned char midi_vol; 141 + struct device *dev; 141 142 }; 142 143 143 144 #define INVALID_IRQ ((unsigned)-1) ··· 162 161 if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, 163 162 s->chip->card->dev, 164 163 size, buf) < 0) { 165 - snd_printk(KERN_ERR "sscape: Failed to allocate " 166 - "%lu bytes for DMA\n", 167 - size); 164 + dev_err(s->dev, 165 + "sscape: Failed to allocate %lu bytes for DMA\n", 166 + size); 168 167 return NULL; 169 168 } 170 169 } ··· 464 463 */ 465 464 spin_unlock_irqrestore(&s->lock, flags); 466 465 467 - snd_printk(KERN_ERR 468 - "sscape: DMA upload has timed out\n"); 466 + dev_err(s->dev, "sscape: DMA upload has timed out\n"); 469 467 ret = -EAGAIN; 470 468 goto _release_dma; 471 469 } ··· 487 487 */ 488 488 ret = 0; 489 489 if (!obp_startup_ack(s, 5000)) { 490 - snd_printk(KERN_ERR "sscape: No response " 491 - "from on-board processor after upload\n"); 490 + dev_err(s->dev, 491 + "sscape: No response from on-board processor after upload\n"); 492 492 ret = -EAGAIN; 493 493 } else if (!host_startup_ack(s, 5000)) { 494 - snd_printk(KERN_ERR 495 - "sscape: SoundScape failed to initialise\n"); 494 + dev_err(s->dev, "sscape: SoundScape failed to initialise\n"); 496 495 ret = -EAGAIN; 497 496 } 498 497 ··· 520 521 521 522 ret = request_firmware(&init_fw, "scope.cod", card->dev); 522 523 if (ret < 0) { 523 - snd_printk(KERN_ERR "sscape: Error loading scope.cod"); 524 + dev_err(card->dev, "sscape: Error loading scope.cod"); 524 525 return ret; 525 526 } 526 527 ret = upload_dma_data(sscape, init_fw->data, init_fw->size); ··· 538 539 539 540 data &= 0xf; 540 541 if (ret == 0 && data > 7) { 541 - snd_printk(KERN_ERR 542 - "sscape: timeout reading firmware version\n"); 542 + dev_err(card->dev, 543 + "sscape: timeout reading firmware version\n"); 543 544 ret = -EAGAIN; 544 545 } 545 546 ··· 560 561 561 562 err = request_firmware(&init_fw, name, card->dev); 562 563 if (err < 0) { 563 - snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d", 564 - version); 564 + dev_err(card->dev, "sscape: Error loading sndscape.co%d", 565 + version); 565 566 return err; 566 567 } 567 568 err = upload_dma_data(sscape, init_fw->data, init_fw->size); 568 569 if (err == 0) 569 - snd_printk(KERN_INFO "sscape: MIDI firmware loaded %zu KBs\n", 570 - init_fw->size >> 10); 570 + dev_info(card->dev, "sscape: MIDI firmware loaded %zu KBs\n", 571 + init_fw->size >> 10); 571 572 572 573 release_firmware(init_fw); 573 574 ··· 782 783 static int mpu401_open(struct snd_mpu401 *mpu) 783 784 { 784 785 if (!verify_mpu401(mpu)) { 785 - snd_printk(KERN_ERR "sscape: MIDI disabled, " 786 - "please load firmware\n"); 786 + dev_err(mpu->rmidi->card->dev, 787 + "sscape: MIDI disabled, please load firmware\n"); 787 788 return -ENODEV; 788 789 } 789 790 ··· 870 871 871 872 err = snd_wss_pcm(chip, 0); 872 873 if (err < 0) { 873 - snd_printk(KERN_ERR "sscape: No PCM device " 874 - "for AD1845 chip\n"); 874 + dev_err(card->dev, 875 + "sscape: No PCM device for AD1845 chip\n"); 875 876 goto _error; 876 877 } 877 878 878 879 err = snd_wss_mixer(chip); 879 880 if (err < 0) { 880 - snd_printk(KERN_ERR "sscape: No mixer device " 881 - "for AD1845 chip\n"); 881 + dev_err(card->dev, 882 + "sscape: No mixer device for AD1845 chip\n"); 882 883 goto _error; 883 884 } 884 885 if (chip->hardware != WSS_HW_AD1848) { 885 886 err = snd_wss_timer(chip, 0); 886 887 if (err < 0) { 887 - snd_printk(KERN_ERR "sscape: No timer device " 888 - "for AD1845 chip\n"); 888 + dev_err(card->dev, 889 + "sscape: No timer device for AD1845 chip\n"); 889 890 goto _error; 890 891 } 891 892 } ··· 894 895 err = snd_ctl_add(card, 895 896 snd_ctl_new1(&midi_mixer_ctl, chip)); 896 897 if (err < 0) { 897 - snd_printk(KERN_ERR "sscape: Could not create " 898 - "MIDI mixer control\n"); 898 + dev_err(card->dev, 899 + "sscape: Could not create MIDI mixer control\n"); 899 900 goto _error; 900 901 } 901 902 } ··· 931 932 */ 932 933 io_res = devm_request_region(card->dev, port[dev], 8, "SoundScape"); 933 934 if (!io_res) { 934 - snd_printk(KERN_ERR 935 - "sscape: can't grab port 0x%lx\n", port[dev]); 935 + dev_err(card->dev, 936 + "sscape: can't grab port 0x%lx\n", port[dev]); 936 937 return -EBUSY; 937 938 } 938 939 wss_res = NULL; ··· 940 941 wss_res = devm_request_region(card->dev, wss_port[dev], 4, 941 942 "SoundScape"); 942 943 if (!wss_res) { 943 - snd_printk(KERN_ERR "sscape: can't grab port 0x%lx\n", 944 - wss_port[dev]); 944 + dev_err(card->dev, "sscape: can't grab port 0x%lx\n", 945 + wss_port[dev]); 945 946 return -EBUSY; 946 947 } 947 948 } ··· 951 952 */ 952 953 err = snd_devm_request_dma(card->dev, dma[dev], "SoundScape"); 953 954 if (err < 0) { 954 - snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", dma[dev]); 955 + dev_err(card->dev, "sscape: can't grab DMA %d\n", dma[dev]); 955 956 return err; 956 957 } 957 958 ··· 961 962 sscape->io_base = port[dev]; 962 963 963 964 if (!detect_sscape(sscape, wss_port[dev])) { 964 - printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", 965 + dev_err(card->dev, "sscape: hardware not detected at 0x%x\n", 965 966 sscape->io_base); 966 967 return -ENODEV; 967 968 } ··· 984 985 break; 985 986 } 986 987 987 - printk(KERN_INFO "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n", 988 - name, sscape->io_base, irq[dev], dma[dev]); 988 + dev_info(card->dev, "sscape: %s card detected at 0x%x, using IRQ %d, DMA %d\n", 989 + name, sscape->io_base, irq[dev], dma[dev]); 989 990 990 991 /* 991 992 * Check that the user didn't pass us garbage data ... 992 993 */ 993 994 irq_cfg = get_irq_config(sscape->type, irq[dev]); 994 995 if (irq_cfg == INVALID_IRQ) { 995 - snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); 996 + dev_err(card->dev, "sscape: Invalid IRQ %d\n", irq[dev]); 996 997 return -ENXIO; 997 998 } 998 999 999 1000 mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); 1000 1001 if (mpu_irq_cfg == INVALID_IRQ) { 1001 - snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); 1002 + dev_err(card->dev, "sscape: Invalid IRQ %d\n", mpu_irq[dev]); 1002 1003 return -ENXIO; 1003 1004 } 1004 1005 ··· 1042 1043 err = create_ad1845(card, wss_port[dev], irq[dev], 1043 1044 dma[dev], dma2[dev]); 1044 1045 if (err < 0) { 1045 - snd_printk(KERN_ERR 1046 - "sscape: No AD1845 device at 0x%lx, IRQ %d\n", 1047 - wss_port[dev], irq[dev]); 1046 + dev_err(card->dev, 1047 + "sscape: No AD1845 device at 0x%lx, IRQ %d\n", 1048 + wss_port[dev], irq[dev]); 1048 1049 return err; 1049 1050 } 1050 1051 strcpy(card->driver, "SoundScape"); ··· 1064 1065 err = create_mpu401(card, MIDI_DEVNUM, port[dev], 1065 1066 mpu_irq[dev]); 1066 1067 if (err < 0) { 1067 - snd_printk(KERN_ERR "sscape: Failed to create " 1068 - "MPU-401 device at 0x%lx\n", 1069 - port[dev]); 1068 + dev_err(card->dev, 1069 + "sscape: Failed to create MPU-401 device at 0x%lx\n", 1070 + port[dev]); 1070 1071 return err; 1071 1072 } 1072 1073 ··· 1109 1110 if (irq[i] == SNDRV_AUTO_IRQ || 1110 1111 mpu_irq[i] == SNDRV_AUTO_IRQ || 1111 1112 dma[i] == SNDRV_AUTO_DMA) { 1112 - printk(KERN_INFO 1113 - "sscape: insufficient parameters, " 1114 - "need IO, IRQ, MPU-IRQ and DMA\n"); 1113 + dev_info(pdev, 1114 + "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); 1115 1115 return 0; 1116 1116 } 1117 1117 ··· 1129 1131 return ret; 1130 1132 1131 1133 sscape = get_card_soundscape(card); 1134 + sscape->dev = pdev; 1132 1135 sscape->type = SSCAPE; 1133 1136 1134 1137 dma[dev] &= 0x03; ··· 1140 1141 1141 1142 ret = snd_card_register(card); 1142 1143 if (ret < 0) { 1143 - snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); 1144 + dev_err(pdev, "sscape: Failed to register sound card\n"); 1144 1145 return ret; 1145 1146 } 1146 1147 dev_set_drvdata(pdev, card); ··· 1193 1194 1194 1195 if (!pnp_is_active(dev)) { 1195 1196 if (pnp_activate_dev(dev) < 0) { 1196 - snd_printk(KERN_INFO "sscape: device is inactive\n"); 1197 + dev_info(&dev->dev, "sscape: device is inactive\n"); 1197 1198 return -EBUSY; 1198 1199 } 1199 1200 } ··· 1209 1210 return ret; 1210 1211 1211 1212 sscape = get_card_soundscape(card); 1213 + sscape->dev = card->dev; 1212 1214 1213 1215 /* 1214 1216 * Identify card model ... ··· 1240 1240 1241 1241 ret = snd_card_register(card); 1242 1242 if (ret < 0) { 1243 - snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); 1243 + dev_err(card->dev, "sscape: Failed to register sound card\n"); 1244 1244 return ret; 1245 1245 } 1246 1246