| changeset 3516: | ffd29b2ba72d |
|---|---|
| parent 3515: | 645a4ae29b20 |
| child 3517: | 98be5a30a219 |
| author: | tiwai |
| date: | Mon Feb 18 11:30:12 2008 +0100 (4 years ago) |
| files: | drivers/pcsp/pcsp.c drivers/pcsp/pcsp.h drivers/pcsp/pcsp_input.c drivers/pcsp/pcsp_lib.c |
| description: | pcsp - Comply to Lindent & checkpatch.pl Signed-off-by: Stas Sergeev <stsp@aknet.ru> |
--- a/drivers/pcsp/pcsp.c Fri Feb 15 17:03:55 2008 +0100 +++ b/drivers/pcsp/pcsp.c Mon Feb 18 11:30:12 2008 +0100 @@ -36,7 +36,6 @@ MODULE_PARM_DESC(enable, "dummy"); struct snd_pcsp pcsp_chip; - static int __init snd_pcsp_create(struct snd_card *card) { static struct snd_device_ops ops = { }; @@ -47,9 +46,9 @@ static int __init snd_pcsp_create(struct hrtimer_get_res(CLOCK_MONOTONIC, &tp); if (tp.tv_sec || tp.tv_nsec > PCSP_MAX_PERIOD_NS) { printk(KERN_ERR "PCSP: Timer resolution is not sufficient " - "(%linS)\n", tp.tv_nsec); + "(%linS)\n", tp.tv_nsec); printk(KERN_ERR "PCSP: Make sure you have HPET and ACPI " - "enabled.\n"); + "enabled.\n"); return -EIO; } @@ -59,7 +58,7 @@ static int __init snd_pcsp_create(struct min_div = MAX_DIV; #if PCSP_DEBUG printk("PCSP: lpj=%li, min_div=%i, res=%li\n", - loops_per_jiffy, min_div, tp.tv_nsec); + loops_per_jiffy, min_div, tp.tv_nsec); #endif div = MAX_DIV / min_div; @@ -69,7 +68,7 @@ static int __init snd_pcsp_create(struct pcsp_chip.treble = min(pcsp_chip.max_treble, PCSP_DEFAULT_TREBLE); pcsp_chip.playback_ptr = 0; pcsp_chip.period_ptr = 0; - pcsp_chip.timer_active = 0; + atomic_set(&pcsp_chip.timer_active, 0); pcsp_chip.enable = 1; pcsp_chip.pcspkr = 1; @@ -144,9 +143,10 @@ static int __init alsa_card_pcsp_init(vo /* Well, CONFIG_DEBUG_PAGEALLOC makes the sound horrible. Lets alert */ printk(KERN_WARNING "PCSP: Warning, CONFIG_DEBUG_PAGEALLOC is enabled!\n" - "You have to disable it if you want to use the PC-Speaker driver.\n" - "Unless it is disabled, enjoy the horrible, distorted and crackling " - "noise.\n"); + "You have to disable it if you want to use the PC-Speaker " + "driver.\n" + "Unless it is disabled, enjoy the horrible, distorted " + "and crackling noise.\n"); #endif if (enable) {
--- a/drivers/pcsp/pcsp.h Fri Feb 15 17:03:55 2008 +0100 +++ b/drivers/pcsp/pcsp.h Mon Feb 18 11:30:12 2008 +0100 @@ -14,16 +14,6 @@ #define PCSP_SOUND_VERSION 0x400 /* read 4.00 */ #define PCSP_DEBUG 0 - -#if PCSP_DEBUG -#define assert(expr) \ - if(!(expr)) { \ - printk( "Assertion failed! %s, %s, %s, line=%d\n", \ - #expr,__FILE__,__FUNCTION__,__LINE__); \ - } -#else -#define assert(expr) -#endif /* default timer freq for PC-Speaker: 18643 Hz */ #define DIV_18KHZ 64 @@ -50,7 +40,8 @@ #define PCSP_PERIOD_NS() (1000000000ULL * PCSP_RATE__1) #else /* and now - without using __udivdi3 :( */ -#define PCSP_PERIOD_NS() (chip->treble ? PCSP_MIN_PERIOD_NS : PCSP_MAX_PERIOD_NS) +#define PCSP_PERIOD_NS() (chip->treble ? PCSP_MIN_PERIOD_NS : \ + PCSP_MAX_PERIOD_NS) #endif #define PCSP_MAX_PERIOD_SIZE (64*1024) @@ -64,14 +55,13 @@ struct snd_pcsp { unsigned short port, irq, dma; spinlock_t substream_lock; struct snd_pcm_substream *playback_substream; - volatile size_t playback_ptr; - volatile size_t period_ptr; - volatile int timer_active; + size_t playback_ptr; + size_t period_ptr; + atomic_t timer_active; unsigned char val61; int enable; int max_treble; int treble; -// int bass; int pcspkr; };
--- a/drivers/pcsp/pcsp_input.c Fri Feb 15 17:03:55 2008 +0100 +++ b/drivers/pcsp/pcsp_input.c Mon Feb 18 11:30:12 2008 +0100 @@ -49,7 +49,7 @@ static int pcspkr_input_event(struct inp { unsigned int count = 0; - if (pcsp_chip.timer_active || !pcsp_chip.pcspkr) + if (atomic_read(&pcsp_chip.timer_active) || !pcsp_chip.pcspkr) return 0; switch (type) { @@ -112,7 +112,7 @@ int __exit pcspkr_input_remove(struct in return 0; /* turn off the speaker */ pcspkr_do_sound(0); - input_unregister_device(dev); // this also does kfree() + input_unregister_device(dev); /* this also does kfree() */ return 0; }
--- a/drivers/pcsp/pcsp_lib.c Fri Feb 15 17:03:55 2008 +0100 +++ b/drivers/pcsp/pcsp_lib.c Mon Feb 18 11:30:12 2008 +0100 @@ -75,7 +75,7 @@ enum hrtimer_restart pcsp_do_timer(struc goto exit_nr_unlock1; substream = chip->playback_substream; snd_pcm_stream_lock(substream); - if (!chip->timer_active) + if (!atomic_read(&chip->timer_active)) goto exit_nr_unlock2; runtime = substream->runtime; @@ -99,7 +99,8 @@ enum hrtimer_restart pcsp_do_timer(struc chip->playback_ptr += PCSP_INDEX_INC() * fmt_size; periods_elapsed = chip->playback_ptr - chip->period_ptr; if (periods_elapsed < 0) { - printk(KERN_WARNING "PCSP: playback_ptr inconsistent (%zi %zi %zi)\n", + printk(KERN_WARNING "PCSP: playback_ptr inconsistent " + "(%zi %zi %zi)\n", chip->playback_ptr, period_bytes, buffer_bytes); periods_elapsed += buffer_bytes; } @@ -118,7 +119,7 @@ enum hrtimer_restart pcsp_do_timer(struc spin_unlock_irqrestore(&chip->substream_lock, flags); - if (!chip->timer_active) + if (!atomic_read(&chip->timer_active)) return HRTIMER_NORESTART; hrtimer_forward(&chip->timer, chip->timer.expires, ktime_set(0, PCSP_PERIOD_NS())); @@ -133,7 +134,7 @@ exit_nr_unlock1: static void pcsp_start_playing(struct snd_pcsp *chip) { - if (chip->timer_active) { + if (atomic_read(&chip->timer_active)) { printk(KERN_ERR "PCSP: Timer already active\n"); return; } @@ -142,17 +143,17 @@ static void pcsp_start_playing(struct sn chip->val61 = inb(0x61) | 0x03; outb_p(0x92, 0x43); /* binary, mode 1, LSB only, ch 2 */ spin_unlock(&i8253_lock); - chip->timer_active = 1; + atomic_set(&chip->timer_active, 1); tasklet_schedule(&pcsp_start_timer_tasklet); } static void pcsp_stop_playing(struct snd_pcsp *chip) { - if (!chip->timer_active) + if (!atomic_read(&chip->timer_active)) return; - chip->timer_active = 0; + atomic_set(&chip->timer_active, 0); spin_lock(&i8253_lock); /* restore the timer */ outb_p(0xb6, 0x43); /* binary, mode 3, LSB/MSB, ch 2 */ @@ -164,9 +165,9 @@ static int snd_pcsp_playback_close(struc { struct snd_pcsp *chip = snd_pcm_substream_chip(substream); #if PCSP_DEBUG - printk("close called\n"); + printk(KERN_INFO "PCSP: close called\n"); #endif - if (chip->timer_active) { + if (atomic_read(&chip->timer_active)) { printk(KERN_ERR "PCSP: timer still active\n"); pcsp_stop_playing(chip); } @@ -190,7 +191,7 @@ static int snd_pcsp_playback_hw_free(str static int snd_pcsp_playback_hw_free(struct snd_pcm_substream *substream) { #if PCSP_DEBUG - printk("hw_free called\n"); + printk(KERN_INFO "PCSP: hw_free called\n"); #endif return snd_pcm_lib_free_pages(substream); } @@ -199,12 +200,13 @@ static int snd_pcsp_playback_prepare(str { struct snd_pcsp *chip = snd_pcm_substream_chip(substream); #if PCSP_DEBUG - printk("prepare called, size=%zi psize=%zi f=%zi f1=%i\n", - snd_pcm_lib_buffer_bytes(substream), - snd_pcm_lib_period_bytes(substream), - snd_pcm_lib_buffer_bytes(substream) / - snd_pcm_lib_period_bytes(substream), - substream->runtime->periods); + printk(KERN_INFO "PCSP: prepare called, " + "size=%zi psize=%zi f=%zi f1=%i\n", + snd_pcm_lib_buffer_bytes(substream), + snd_pcm_lib_period_bytes(substream), + snd_pcm_lib_buffer_bytes(substream) / + snd_pcm_lib_period_bytes(substream), + substream->runtime->periods); #endif chip->playback_ptr = 0; chip->period_ptr = 0; @@ -215,7 +217,7 @@ static int snd_pcsp_trigger(struct snd_p { struct snd_pcsp *chip = snd_pcm_substream_chip(substream); #if PCSP_DEBUG - printk("trigger called\n"); + printk(KERN_INFO "PCSP: trigger called\n"); #endif switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -266,9 +268,9 @@ static int snd_pcsp_playback_open(struct struct snd_pcsp *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; #if PCSP_DEBUG - printk("open called\n"); + printk(KERN_INFO "PCSP: open called\n"); #endif - if (chip->timer_active) { + if (atomic_read(&chip->timer_active)) { printk(KERN_ERR "PCSP: still active!!\n"); return -EBUSY; }