diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2009-10-02 12:41:29 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-10-04 04:22:51 -0400 |
commit | bcde1f8a80d1bdfd43fb498996dfa89666fd7fe3 (patch) | |
tree | ad71932236e08af4b98bb1add256522706578823 | |
parent | 7c824f4b69316df55fe243c5a6c7dba2b62285c1 (diff) |
ALSA: sscape: remove MIDI instances counting with limit ULONG_MAX
There is no sense to limit open MIDI connections with limit
as high as ULONG_MAX.
Also, convert more messages to use the snd_printk.
Correct few old and misleading comments as well.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/isa/sscape.c | 101 |
1 files changed, 29 insertions, 72 deletions
diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 1ce465cc66a8..c739374af20e 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c | |||
@@ -147,12 +147,6 @@ struct soundscape { | |||
147 | struct snd_wss *chip; | 147 | struct snd_wss *chip; |
148 | struct snd_mpu401 *mpu; | 148 | struct snd_mpu401 *mpu; |
149 | 149 | ||
150 | /* | ||
151 | * The MIDI device won't work until we've loaded | ||
152 | * its firmware via a hardware-dependent device IOCTL | ||
153 | */ | ||
154 | spinlock_t fwlock; | ||
155 | unsigned long midi_usage; | ||
156 | unsigned char midi_vol; | 150 | unsigned char midi_vol; |
157 | }; | 151 | }; |
158 | 152 | ||
@@ -164,11 +158,6 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c) | |||
164 | return (struct soundscape *) (c->private_data); | 158 | return (struct soundscape *) (c->private_data); |
165 | } | 159 | } |
166 | 160 | ||
167 | static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu) | ||
168 | { | ||
169 | return (struct soundscape *) (mpu->private_data); | ||
170 | } | ||
171 | |||
172 | /* | 161 | /* |
173 | * Allocates some kernel memory that we can use for DMA. | 162 | * Allocates some kernel memory that we can use for DMA. |
174 | * I think this means that the memory has to map to | 163 | * I think this means that the memory has to map to |
@@ -179,7 +168,9 @@ static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned lo | |||
179 | if (buf) { | 168 | if (buf) { |
180 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), | 169 | if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), |
181 | size, buf) < 0) { | 170 | size, buf) < 0) { |
182 | snd_printk(KERN_ERR "sscape: Failed to allocate %lu bytes for DMA\n", size); | 171 | snd_printk(KERN_ERR "sscape: Failed to allocate " |
172 | "%lu bytes for DMA\n", | ||
173 | size); | ||
183 | return NULL; | 174 | return NULL; |
184 | } | 175 | } |
185 | } | 176 | } |
@@ -482,7 +473,8 @@ static int upload_dma_data(struct soundscape *s, | |||
482 | */ | 473 | */ |
483 | spin_unlock_irqrestore(&s->lock, flags); | 474 | spin_unlock_irqrestore(&s->lock, flags); |
484 | 475 | ||
485 | snd_printk(KERN_ERR "sscape: DMA upload has timed out\n"); | 476 | snd_printk(KERN_ERR |
477 | "sscape: DMA upload has timed out\n"); | ||
486 | ret = -EAGAIN; | 478 | ret = -EAGAIN; |
487 | goto _release_dma; | 479 | goto _release_dma; |
488 | } | 480 | } |
@@ -504,10 +496,12 @@ static int upload_dma_data(struct soundscape *s, | |||
504 | */ | 496 | */ |
505 | ret = 0; | 497 | ret = 0; |
506 | if (!obp_startup_ack(s, 5000)) { | 498 | if (!obp_startup_ack(s, 5000)) { |
507 | snd_printk(KERN_ERR "sscape: No response from on-board processor after upload\n"); | 499 | snd_printk(KERN_ERR "sscape: No response " |
500 | "from on-board processor after upload\n"); | ||
508 | ret = -EAGAIN; | 501 | ret = -EAGAIN; |
509 | } else if (!host_startup_ack(s, 5000)) { | 502 | } else if (!host_startup_ack(s, 5000)) { |
510 | snd_printk(KERN_ERR "sscape: SoundScape failed to initialise\n"); | 503 | snd_printk(KERN_ERR |
504 | "sscape: SoundScape failed to initialise\n"); | ||
511 | ret = -EAGAIN; | 505 | ret = -EAGAIN; |
512 | } | 506 | } |
513 | 507 | ||
@@ -536,7 +530,7 @@ static int sscape_upload_bootblock(struct snd_card *card) | |||
536 | 530 | ||
537 | ret = request_firmware(&init_fw, "scope.cod", card->dev); | 531 | ret = request_firmware(&init_fw, "scope.cod", card->dev); |
538 | if (ret < 0) { | 532 | if (ret < 0) { |
539 | snd_printk(KERN_ERR "Error loading scope.cod"); | 533 | snd_printk(KERN_ERR "sscape: Error loading scope.cod"); |
540 | return ret; | 534 | return ret; |
541 | } | 535 | } |
542 | ret = upload_dma_data(sscape, init_fw->data, init_fw->size); | 536 | ret = upload_dma_data(sscape, init_fw->data, init_fw->size); |
@@ -554,7 +548,8 @@ static int sscape_upload_bootblock(struct snd_card *card) | |||
554 | 548 | ||
555 | data &= 0xf; | 549 | data &= 0xf; |
556 | if (ret == 0 && data > 7) { | 550 | if (ret == 0 && data > 7) { |
557 | snd_printk(KERN_ERR "timeout reading firmware version\n"); | 551 | snd_printk(KERN_ERR |
552 | "sscape: timeout reading firmware version\n"); | ||
558 | ret = -EAGAIN; | 553 | ret = -EAGAIN; |
559 | } | 554 | } |
560 | 555 | ||
@@ -575,12 +570,13 @@ static int sscape_upload_microcode(struct snd_card *card, int version) | |||
575 | 570 | ||
576 | err = request_firmware(&init_fw, name, card->dev); | 571 | err = request_firmware(&init_fw, name, card->dev); |
577 | if (err < 0) { | 572 | if (err < 0) { |
578 | snd_printk(KERN_ERR "Error loading sndscape.co%d", version); | 573 | snd_printk(KERN_ERR "sscape: Error loading sndscape.co%d", |
574 | version); | ||
579 | return err; | 575 | return err; |
580 | } | 576 | } |
581 | err = upload_dma_data(sscape, init_fw->data, init_fw->size); | 577 | err = upload_dma_data(sscape, init_fw->data, init_fw->size); |
582 | if (err == 0) | 578 | if (err == 0) |
583 | snd_printk(KERN_INFO "MIDI firmware loaded %d KBs\n", | 579 | snd_printk(KERN_INFO "sscape: MIDI firmware loaded %d KBs\n", |
584 | init_fw->size >> 10); | 580 | init_fw->size >> 10); |
585 | 581 | ||
586 | release_firmware(init_fw); | 582 | release_firmware(init_fw); |
@@ -750,7 +746,6 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
750 | msleep(1); | 746 | msleep(1); |
751 | spin_lock_irqsave(&s->lock, flags); | 747 | spin_lock_irqsave(&s->lock, flags); |
752 | } | 748 | } |
753 | snd_printd(KERN_INFO "init delay = %d ms\n", d); | ||
754 | 749 | ||
755 | if ((inb(wss_io) & 0x80) != 0) | 750 | if ((inb(wss_io) & 0x80) != 0) |
756 | goto _done; | 751 | goto _done; |
@@ -774,7 +769,6 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
774 | msleep(1); | 769 | msleep(1); |
775 | spin_lock_irqsave(&s->lock, flags); | 770 | spin_lock_irqsave(&s->lock, flags); |
776 | } | 771 | } |
777 | snd_printd(KERN_INFO "init delay = %d ms\n", d); | ||
778 | 772 | ||
779 | /* | 773 | /* |
780 | * SoundScape successfully detected! | 774 | * SoundScape successfully detected! |
@@ -794,38 +788,13 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io) | |||
794 | */ | 788 | */ |
795 | static int mpu401_open(struct snd_mpu401 * mpu) | 789 | static int mpu401_open(struct snd_mpu401 * mpu) |
796 | { | 790 | { |
797 | int err; | ||
798 | |||
799 | if (!verify_mpu401(mpu)) { | 791 | if (!verify_mpu401(mpu)) { |
800 | snd_printk(KERN_ERR "sscape: MIDI disabled, please load firmware\n"); | 792 | snd_printk(KERN_ERR "sscape: MIDI disabled, " |
801 | err = -ENODEV; | 793 | "please load firmware\n"); |
802 | } else { | 794 | return -ENODEV; |
803 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
804 | unsigned long flags; | ||
805 | |||
806 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
807 | |||
808 | if (sscape->midi_usage == ULONG_MAX) { | ||
809 | err = -EBUSY; | ||
810 | } else { | ||
811 | ++(sscape->midi_usage); | ||
812 | err = 0; | ||
813 | } | ||
814 | |||
815 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
816 | } | 795 | } |
817 | 796 | ||
818 | return err; | 797 | return 0; |
819 | } | ||
820 | |||
821 | static void mpu401_close(struct snd_mpu401 * mpu) | ||
822 | { | ||
823 | register struct soundscape *sscape = get_mpu401_soundscape(mpu); | ||
824 | unsigned long flags; | ||
825 | |||
826 | spin_lock_irqsave(&sscape->fwlock, flags); | ||
827 | --(sscape->midi_usage); | ||
828 | spin_unlock_irqrestore(&sscape->fwlock, flags); | ||
829 | } | 798 | } |
830 | 799 | ||
831 | /* | 800 | /* |
@@ -845,8 +814,6 @@ static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned l | |||
845 | struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; | 814 | struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; |
846 | mpu->open_input = mpu401_open; | 815 | mpu->open_input = mpu401_open; |
847 | mpu->open_output = mpu401_open; | 816 | mpu->open_output = mpu401_open; |
848 | mpu->close_input = mpu401_close; | ||
849 | mpu->close_output = mpu401_close; | ||
850 | mpu->private_data = sscape; | 817 | mpu->private_data = sscape; |
851 | sscape->mpu = mpu; | 818 | sscape->mpu = mpu; |
852 | 819 | ||
@@ -993,13 +960,13 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
993 | } | 960 | } |
994 | 961 | ||
995 | spin_lock_init(&sscape->lock); | 962 | spin_lock_init(&sscape->lock); |
996 | spin_lock_init(&sscape->fwlock); | ||
997 | sscape->io_res = io_res; | 963 | sscape->io_res = io_res; |
998 | sscape->wss_res = wss_res; | 964 | sscape->wss_res = wss_res; |
999 | sscape->io_base = port[dev]; | 965 | sscape->io_base = port[dev]; |
1000 | 966 | ||
1001 | if (!detect_sscape(sscape, wss_port[dev])) { | 967 | if (!detect_sscape(sscape, wss_port[dev])) { |
1002 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); | 968 | printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", |
969 | sscape->io_base); | ||
1003 | err = -ENODEV; | 970 | err = -ENODEV; |
1004 | goto _release_dma; | 971 | goto _release_dma; |
1005 | } | 972 | } |
@@ -1036,7 +1003,7 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1036 | 1003 | ||
1037 | mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); | 1004 | mpu_irq_cfg = get_irq_config(sscape->type, mpu_irq[dev]); |
1038 | if (mpu_irq_cfg == INVALID_IRQ) { | 1005 | if (mpu_irq_cfg == INVALID_IRQ) { |
1039 | printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); | 1006 | snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); |
1040 | return -ENXIO; | 1007 | return -ENXIO; |
1041 | } | 1008 | } |
1042 | 1009 | ||
@@ -1073,8 +1040,9 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1073 | err = create_ad1845(card, wss_port[dev], irq[dev], | 1040 | err = create_ad1845(card, wss_port[dev], irq[dev], |
1074 | dma[dev], dma2[dev]); | 1041 | dma[dev], dma2[dev]); |
1075 | if (err < 0) { | 1042 | if (err < 0) { |
1076 | printk(KERN_ERR "sscape: No AD1845 device at 0x%lx, IRQ %d\n", | 1043 | snd_printk(KERN_ERR |
1077 | wss_port[dev], irq[dev]); | 1044 | "sscape: No AD1845 device at 0x%lx, IRQ %d\n", |
1045 | wss_port[dev], irq[dev]); | ||
1078 | goto _release_dma; | 1046 | goto _release_dma; |
1079 | } | 1047 | } |
1080 | strcpy(card->driver, "SoundScape"); | 1048 | strcpy(card->driver, "SoundScape"); |
@@ -1094,7 +1062,7 @@ static int __devinit create_sscape(int dev, struct snd_card *card) | |||
1094 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], | 1062 | err = create_mpu401(card, MIDI_DEVNUM, port[dev], |
1095 | mpu_irq[dev]); | 1063 | mpu_irq[dev]); |
1096 | if (err < 0) { | 1064 | if (err < 0) { |
1097 | printk(KERN_ERR "sscape: Failed to create " | 1065 | snd_printk(KERN_ERR "sscape: Failed to create " |
1098 | "MPU-401 device at 0x%lx\n", | 1066 | "MPU-401 device at 0x%lx\n", |
1099 | port[dev]); | 1067 | port[dev]); |
1100 | goto _release_dma; | 1068 | goto _release_dma; |
@@ -1191,7 +1159,7 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev) | |||
1191 | goto _release_card; | 1159 | goto _release_card; |
1192 | 1160 | ||
1193 | if ((ret = snd_card_register(card)) < 0) { | 1161 | if ((ret = snd_card_register(card)) < 0) { |
1194 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1162 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1195 | goto _release_card; | 1163 | goto _release_card; |
1196 | } | 1164 | } |
1197 | dev_set_drvdata(pdev, card); | 1165 | dev_set_drvdata(pdev, card); |
@@ -1250,18 +1218,7 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1250 | * We have found a candidate ISA PnP card. Now we | 1218 | * We have found a candidate ISA PnP card. Now we |
1251 | * have to check that it has the devices that we | 1219 | * have to check that it has the devices that we |
1252 | * expect it to have. | 1220 | * expect it to have. |
1253 | * | ||
1254 | * We will NOT try and autoconfigure all of the resources | ||
1255 | * needed and then activate the card as we are assuming that | ||
1256 | * has already been done at boot-time using /proc/isapnp. | ||
1257 | * We shall simply try to give each active card the resources | ||
1258 | * that it wants. This is a sensible strategy for a modular | ||
1259 | * system where unused modules are unloaded regularly. | ||
1260 | * | ||
1261 | * This strategy is utterly useless if we compile the driver | ||
1262 | * into the kernel, of course. | ||
1263 | */ | 1221 | */ |
1264 | // printk(KERN_INFO "sscape: %s\n", card->name); | ||
1265 | 1222 | ||
1266 | /* | 1223 | /* |
1267 | * Check that we still have room for another sound card ... | 1224 | * Check that we still have room for another sound card ... |
@@ -1272,7 +1229,7 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1272 | 1229 | ||
1273 | if (!pnp_is_active(dev)) { | 1230 | if (!pnp_is_active(dev)) { |
1274 | if (pnp_activate_dev(dev) < 0) { | 1231 | if (pnp_activate_dev(dev) < 0) { |
1275 | printk(KERN_INFO "sscape: device is inactive\n"); | 1232 | snd_printk(KERN_INFO "sscape: device is inactive\n"); |
1276 | return -EBUSY; | 1233 | return -EBUSY; |
1277 | } | 1234 | } |
1278 | } | 1235 | } |
@@ -1317,7 +1274,7 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, | |||
1317 | goto _release_card; | 1274 | goto _release_card; |
1318 | 1275 | ||
1319 | if ((ret = snd_card_register(card)) < 0) { | 1276 | if ((ret = snd_card_register(card)) < 0) { |
1320 | printk(KERN_ERR "sscape: Failed to register sound card\n"); | 1277 | snd_printk(KERN_ERR "sscape: Failed to register sound card\n"); |
1321 | goto _release_card; | 1278 | goto _release_card; |
1322 | } | 1279 | } |
1323 | 1280 | ||