From: Muli Ben-Yehuda <mulix@mulix.org>

Reindent the trident OSS sound driver



 sound/oss/trident.c | 2209 +++++++++++++++++++++++++++-------------------------
 1 files changed, 1172 insertions(+), 1037 deletions(-)

diff -puN sound/oss/trident.c~trident-cleanup-indentation-D1-2.6.0 sound/oss/trident.c
--- 25/sound/oss/trident.c~trident-cleanup-indentation-D1-2.6.0	2004-01-01 16:02:12.000000000 -0800
+++ 25-akpm/sound/oss/trident.c	2004-01-01 16:03:03.000000000 -0800
@@ -206,7 +206,7 @@
 #include <linux/interrupt.h>
 #include <linux/pm.h>
 #include <linux/gameport.h>
-#include <linux/kernel.h> 
+#include <linux/kernel.h>
 #include <asm/uaccess.h>
 #include <asm/hardirq.h>
 #include <asm/io.h>
@@ -221,26 +221,26 @@
 #define DRIVER_VERSION "0.14.10h-2.5"
 
 /* magic numbers to protect our data structures */
-#define TRIDENT_CARD_MAGIC	0x5072696E /* "Prin" */
-#define TRIDENT_STATE_MAGIC	0x63657373 /* "cess" */
+#define TRIDENT_CARD_MAGIC	0x5072696E	/* "Prin" */
+#define TRIDENT_STATE_MAGIC	0x63657373	/* "cess" */
 
-#define TRIDENT_DMA_MASK	0x3fffffff /* DMA buffer mask for pci_alloc_consist */
-#define ALI_DMA_MASK		0x7fffffff /* ALI Tridents have 31-bit DMA. Wow. */
+#define TRIDENT_DMA_MASK	0x3fffffff	/* DMA buffer mask for pci_alloc_consist */
+#define ALI_DMA_MASK		0x7fffffff	/* ALI Tridents have 31-bit DMA. Wow. */
 
 #define NR_HW_CH		32
 
 /* maximum number of AC97 codecs connected, AC97 2.0 defined 4, but 7018 and 4D-NX only
    have 2 SDATA_IN lines (currently) */
-#define NR_AC97		2	
+#define NR_AC97		2
 
 /* minor number of /dev/swmodem (temporary, experimental) */
 #define SND_DEV_SWMODEM	7
 
-static const unsigned ali_multi_channels_5_1[] = { 
-	/*ALI_SURR_LEFT_CHANNEL, ALI_SURR_RIGHT_CHANNEL,*/
-	ALI_CENTER_CHANNEL, 
-	ALI_LEF_CHANNEL, 
-	ALI_SURR_LEFT_CHANNEL, 
+static const unsigned ali_multi_channels_5_1[] = {
+	/*ALI_SURR_LEFT_CHANNEL, ALI_SURR_RIGHT_CHANNEL, */
+	ALI_CENTER_CHANNEL,
+	ALI_LEF_CHANNEL,
+	ALI_SURR_LEFT_CHANNEL,
 	ALI_SURR_RIGHT_CHANNEL
 };
 
@@ -257,7 +257,7 @@ enum {
 	CYBER5050
 };
 
-static char * card_names[] = {
+static char *card_names[] = {
 	"Trident 4DWave DX",
 	"Trident 4DWave NX",
 	"SiS 7018 PCI Audio",
@@ -265,7 +265,7 @@ static char * card_names[] = {
 	"Tvia/IGST CyberPro 5050"
 };
 
-static struct pci_device_id trident_pci_tbl [] = {
+static struct pci_device_id trident_pci_tbl[] = {
 	{PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_DX,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, TRIDENT_4D_DX},
 	{PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_TRIDENT_4DWAVE_NX,
@@ -274,12 +274,12 @@ static struct pci_device_id trident_pci_
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_7018},
 	{PCI_VENDOR_ID_ALI, PCI_DEVICE_ID_ALI_5451,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, ALI_5451},
-	{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_5050, 
+	{PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_5050,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, CYBER5050},
 	{0,}
 };
 
-MODULE_DEVICE_TABLE (pci, trident_pci_tbl);
+MODULE_DEVICE_TABLE(pci, trident_pci_tbl);
 
 /* "software" or virtual channel, an instance of opened /dev/dsp */
 struct trident_state {
@@ -308,13 +308,14 @@ struct trident_state {
 		unsigned fragshift;
 
 		/* our buffer acts like a circular ring */
-		unsigned hwptr;		/* where dma last started, updated by update_ptr */
-		unsigned swptr;		/* where driver last clear/filled, updated by read/write */
-		int count;		/* bytes to be comsumed or been generated by dma machine */
+		unsigned hwptr;	/* where dma last started, updated by update_ptr */
+		unsigned swptr;	/* where driver last clear/filled, updated by read/write */
+		int count;	/* bytes to be comsumed or been generated by dma machine */
 		unsigned total_bytes;	/* total bytes dmaed by hardware */
 
-		unsigned error;		/* number of over/underruns */
-		wait_queue_head_t wait;	/* put process on wait queue when no more space in buffer */
+		unsigned error;	/* number of over/underruns */
+                /* put process on wait queue when no more space in buffer */
+		wait_queue_head_t wait;	
 
 		/* redundant, but makes calculations easier */
 		unsigned fragsize;
@@ -329,10 +330,10 @@ struct trident_state {
 		unsigned ossfragshift;
 		int ossmaxfrags;
 		unsigned subdivision;
-		
+
 	} dmabuf;
 
-	/* 5.1 channels */	
+	/* 5.1 channels */
 	struct trident_state *other_states[4];
 	int multi_channels_adjust_count;
 	unsigned chans_num;
@@ -344,13 +345,15 @@ struct trident_state {
 
 /* hardware channels */
 struct trident_channel {
-	int  num;	/* channel number */
-	u32 lba;	/* Loop Begine Address, where dma buffer starts */
-	u32 eso;	/* End Sample Offset, wehre dma buffer ends (in the unit of samples) */
-	u32 delta;	/* delta value, sample rate / 48k for playback, 48k/sample rate for recording */
-	u16 attribute;	/* control where PCM data go and come  */
+	int num; /* channel number */
+	u32 lba; /* Loop Begine Address, where dma buffer starts */
+	u32 eso; /* End Sample Offset, wehre dma buffer ends */ 
+	         /* (in the unit of samples) */
+	u32 delta; /* delta value, sample rate / 48k for playback, */
+	           /* 48k/sample rate for recording */
+	u16 attribute; /* control where PCM data go and come  */
 	u16 fm_vol;
-	u32 control;	/* signed/unsigned, 8/16 bits, mono/stereo */
+	u32 control; /* signed/unsigned, 8/16 bits, mono/stereo */
 };
 
 struct trident_pcm_bank_address {
@@ -360,16 +363,14 @@ struct trident_pcm_bank_address {
 	u32 aint_en;
 };
 
-static struct trident_pcm_bank_address bank_a_addrs =
-{
+static struct trident_pcm_bank_address bank_a_addrs = {
 	T4D_START_A,
 	T4D_STOP_A,
 	T4D_AINT_A,
 	T4D_AINTEN_A
 };
 
-static struct trident_pcm_bank_address bank_b_addrs =
-{
+static struct trident_pcm_bank_address bank_b_addrs = {
 	T4D_START_B,
 	T4D_STOP_B,
 	T4D_AINT_B,
@@ -380,7 +381,7 @@ struct trident_pcm_bank {
 	/* register addresses to control bank operations */
 	struct trident_pcm_bank_address *addresses;
 	/* each bank has 32 channels */
-	u32 bitmap; /* channel allocation bitmap */
+	u32 bitmap;		/* channel allocation bitmap */
 	struct trident_channel channels[32];
 };
 
@@ -396,16 +397,17 @@ struct trident_card {
 	/* The trident has a certain amount of cross channel interaction
 	   so we use a single per card lock */
 	spinlock_t lock;
-	
+
 	/* PCI device stuff */
-	struct pci_dev * pci_dev;
+	struct pci_dev *pci_dev;
 	u16 pci_id;
 	u8 revision;
 
 	/* soundcore stuff */
 	int dev_audio;
 
-	/* structures for abstraction of hardware facilities, codecs, banks and channels*/
+	/* structures for abstraction of hardware facilities, codecs, */ 
+	/* banks and channels */
 	struct ac97_codec *ac97_codec[NR_AC97];
 	struct trident_pcm_bank banks[NR_BANKS];
 	struct trident_state *states[NR_HW_CH];
@@ -413,13 +415,13 @@ struct trident_card {
 	/* hardware resources */
 	unsigned long iobase;
 	u32 irq;
-	
+
 	/* Function support */
-	struct trident_channel *(*alloc_pcm_channel)(struct trident_card *);
-	struct trident_channel *(*alloc_rec_pcm_channel)(struct trident_card *);
-	void (*free_pcm_channel)(struct trident_card *, unsigned int chan);
-	void (*address_interrupt)(struct trident_card *);
-	
+	struct trident_channel *(*alloc_pcm_channel) (struct trident_card *);
+	struct trident_channel *(*alloc_rec_pcm_channel) (struct trident_card *);
+	void (*free_pcm_channel) (struct trident_card *, unsigned int chan);
+	void (*address_interrupt) (struct trident_card *);
+
 	/* Added by Matt Wu 01-05-2001 for spdif in */
 	int multi_channel_use_count;
 	int rec_channel_use_count;
@@ -435,15 +437,14 @@ struct trident_card {
 };
 
 /* table to map from CHANNELMASK to channel attribute for SiS 7018 */
-static u16 mask2attr [] =
-{
+static u16 mask2attr[] = {
 	PCM_LR, PCM_LR, SURR_LR, CENTER_LFE,
 	HSET, MIC, MODEM_LINE1, MODEM_LINE2,
 	I2S_LR, SPDIF_LR
 };
 
 /* table to map from channel attribute to CHANNELMASK for SiS 7018 */
-static int attr2mask [] = {
+static int attr2mask[] = {
 	DSP_BIND_MODEM1, DSP_BIND_MODEM2, DSP_BIND_FRONT, DSP_BIND_HANDSET,
 	DSP_BIND_I2S, DSP_BIND_CENTER_LFE, DSP_BIND_SURR, DSP_BIND_SPDIF
 };
@@ -462,8 +463,8 @@ static void trident_ac97_set(struct ac97
 static u16 trident_ac97_get(struct ac97_codec *codec, u8 reg);
 
 static int trident_open_mixdev(struct inode *inode, struct file *file);
-static int trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
-				unsigned long arg);
+static int trident_ioctl_mixdev(struct inode *inode, struct file *file, 
+				unsigned int cmd, unsigned long arg);
 
 static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val);
 static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg);
@@ -482,14 +483,13 @@ static void ali_setup_spdif_in(struct tr
 static void ali_disable_spdif_in(struct trident_card *card);
 static void ali_disable_special_channel(struct trident_card *card, int ch);
 static void ali_setup_spdif_out(struct trident_card *card, int flag);
-static int ali_write_5_1(struct trident_state *state, const char *buffer,
+static int ali_write_5_1(struct trident_state *state, const char *buffer, 
 			 int cnt_for_multi_channel, unsigned int *copy_count, 
 			 unsigned int *state_cnt);
 static int ali_allocate_other_states_resources(struct trident_state *state, 
 					       int chan_nums);
 static void ali_free_other_states_resources(struct trident_state *state);
 
-
 /* save registers for ALi Power Management */
 static struct ali_saved_registers {
 	unsigned long global_regs[ALI_GLOBAL_REGS];
@@ -503,7 +503,6 @@ static struct ali_saved_registers {
         (cnt) -= (offset);	  \
 	(copy_count) += (offset); \
 } while (0)
-	  
 
 #define lock_set_fmt(state) do { \
         spin_lock_irqsave(&state->card->lock, flags);			\
@@ -514,23 +513,23 @@ static struct ali_saved_registers {
 	state->fmt_flag = 1;						\
 	spin_unlock_irqrestore(&state->card->lock, flags);              \
 } while (0)
-				
+
 #define unlock_set_fmt(state)  do {                             \
         spin_lock_irqsave(&state->card->lock, flags);		\
 	state->fmt_flag = 0;					\
 	spin_unlock_irqrestore(&state->card->lock, flags);      \
 } while (0)
 
-static int trident_enable_loop_interrupts(struct trident_card * card)
+static int
+trident_enable_loop_interrupts(struct trident_card *card)
 {
 	u32 global_control;
 
 	global_control = inl(TRID_REG(card, T4D_LFO_GC_CIR));
 
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	case PCI_DEVICE_ID_SI_7018:
-		global_control |= (ENDLP_IE | MIDLP_IE| BANK_B_EN);
+		global_control |= (ENDLP_IE | MIDLP_IE | BANK_B_EN);
 		break;
 	case PCI_DEVICE_ID_ALI_5451:
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_DX:
@@ -544,13 +543,14 @@ static int trident_enable_loop_interrupt
 
 	outl(global_control, TRID_REG(card, T4D_LFO_GC_CIR));
 
-	TRDBG("trident: Enable Loop Interrupts, globctl = 0x%08X\n",
+	TRDBG("trident: Enable Loop Interrupts, globctl = 0x%08X\n", 
 	      inl(TRID_REG(card, T4D_LFO_GC_CIR)));
 
 	return (TRUE);
 }
 
-static int trident_disable_loop_interrupts(struct trident_card * card)
+static int
+trident_disable_loop_interrupts(struct trident_card *card)
 {
 	u32 global_control;
 
@@ -558,13 +558,14 @@ static int trident_disable_loop_interrup
 	global_control &= ~(ENDLP_IE | MIDLP_IE);
 	outl(global_control, TRID_REG(card, T4D_LFO_GC_CIR));
 
-	TRDBG("trident: Disabled Loop Interrupts, globctl = 0x%08X\n",
+	TRDBG("trident: Disabled Loop Interrupts, globctl = 0x%08X\n", 
 	      global_control);
 
 	return (TRUE);
 }
 
-static void trident_enable_voice_irq(struct trident_card * card, unsigned int channel)
+static void
+trident_enable_voice_irq(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -576,32 +577,36 @@ static void trident_enable_voice_irq(str
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: enabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_AINTEN_B? "AINTEN_B":"AINTEN_A",reg,addr);
-#endif /* DEBUG */ 
+	TRDBG("trident: enabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n", 
+	      channel, addr == T4D_AINTEN_B ? "AINTEN_B" : "AINTEN_A", 
+	      reg, addr);
+#endif /* DEBUG */
 }
 
-static void trident_disable_voice_irq(struct trident_card * card, unsigned int channel)
+static void
+trident_disable_voice_irq(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
 	u32 reg, addr = bank->addresses->aint_en;
-	
+
 	reg = inl(TRID_REG(card, addr));
 	reg &= ~mask;
 	outl(reg, TRID_REG(card, addr));
-	
+
 	/* Ack the channel in case the interrupt was set before we disable it. */
 	outl(mask, TRID_REG(card, bank->addresses->aint));
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: disabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_AINTEN_B? "AINTEN_B":"AINTEN_A",reg,addr);
-#endif /* DEBUG */ 
+	TRDBG("trident: disabled IRQ on channel %d, %s = 0x%08x(addr:%X)\n", 
+	      channel, addr == T4D_AINTEN_B ? "AINTEN_B" : "AINTEN_A", 
+	      reg, addr);
+#endif /* DEBUG */
 }
 
-static void trident_start_voice(struct trident_card * card, unsigned int channel)
+static void
+trident_start_voice(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -609,18 +614,20 @@ static void trident_start_voice(struct t
 
 #ifdef DEBUG
 	u32 reg;
-#endif /* DEBUG */ 
+#endif /* DEBUG */
 
 	outl(mask, TRID_REG(card, addr));
 
-#ifdef DEBUG 
+#ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: start voice on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_START_B? "START_B":"START_A",reg,addr);
-#endif /* DEBUG */ 
+	TRDBG("trident: start voice on channel %d, %s = 0x%08x(addr:%X)\n", 
+	      channel, addr == T4D_START_B ? "START_B" : "START_A", 
+	      reg, addr);
+#endif /* DEBUG */
 }
 
-static void trident_stop_voice(struct trident_card * card, unsigned int channel)
+static void
+trident_stop_voice(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -628,38 +635,43 @@ static void trident_stop_voice(struct tr
 
 #ifdef DEBUG
 	u32 reg;
-#endif /* DEBUG */ 
+#endif /* DEBUG */
 
 	outl(mask, TRID_REG(card, addr));
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, addr));
-	TRDBG("trident: stop voice on channel %d, %s = 0x%08x(addr:%X)\n",
-	      channel, addr==T4D_STOP_B? "STOP_B":"STOP_A",reg,addr);
-#endif /* DEBUG */ 
+	TRDBG("trident: stop voice on channel %d, %s = 0x%08x(addr:%X)\n", 
+	      channel, addr == T4D_STOP_B ? "STOP_B" : "STOP_A", 
+	      reg, addr);
+#endif /* DEBUG */
 }
 
-static u32 trident_get_interrupt_mask (struct trident_card * card, unsigned int channel)
+static u32
+trident_get_interrupt_mask(struct trident_card *card, unsigned int channel)
 {
 	struct trident_pcm_bank *bank = &card->banks[channel];
 	u32 addr = bank->addresses->aint;
 	return inl(TRID_REG(card, addr));
 }
 
-static int trident_check_channel_interrupt(struct trident_card * card, unsigned int channel)
+static int
+trident_check_channel_interrupt(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
-	u32 reg = trident_get_interrupt_mask (card, channel >> 5);
+	u32 reg = trident_get_interrupt_mask(card, channel >> 5);
 
 #ifdef DEBUG
 	if (reg & mask)
-		TRDBG("trident: channel %d has interrupt, %s = 0x%08x\n",
-		      channel,reg==T4D_AINT_B? "AINT_B":"AINT_A", reg);
-#endif /* DEBUG */ 
+		TRDBG("trident: channel %d has interrupt, %s = 0x%08x\n", 
+		      channel, reg == T4D_AINT_B ? "AINT_B" : "AINT_A", 
+		      reg);
+#endif /* DEBUG */
 	return (reg & mask) ? TRUE : FALSE;
 }
 
-static void trident_ack_channel_interrupt(struct trident_card * card, unsigned int channel)
+static void
+trident_ack_channel_interrupt(struct trident_card *card, unsigned int channel)
 {
 	unsigned int mask = 1 << (channel & 0x1f);
 	struct trident_pcm_bank *bank = &card->banks[channel >> 5];
@@ -671,12 +683,13 @@ static void trident_ack_channel_interrup
 
 #ifdef DEBUG
 	reg = inl(TRID_REG(card, T4D_AINT_B));
-	TRDBG("trident: Ack channel %d interrupt, AINT_B = 0x%08x\n",
+	TRDBG("trident: Ack channel %d interrupt, AINT_B = 0x%08x\n", 
 	      channel, reg);
-#endif /* DEBUG */ 
+#endif /* DEBUG */
 }
 
-static struct trident_channel * trident_alloc_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+trident_alloc_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
@@ -697,28 +710,30 @@ static struct trident_channel * trident_
 	return NULL;
 }
 
-static void trident_free_pcm_channel(struct trident_card *card, unsigned int channel)
+static void
+trident_free_pcm_channel(struct trident_card *card, unsigned int channel)
 {
 	int bank;
-        unsigned char b;
+	unsigned char b;
 
 	if (channel < 31 || channel > 63)
 		return;
 
-	if (card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_DX ||
-            card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) {
-          b = inb (TRID_REG(card, T4D_REC_CH));
-          if ((b & ~0x80) == channel)
-            outb(0x0, TRID_REG(card, T4D_REC_CH));
-        }
-            
+	if (card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_DX || 
+	    card->pci_id == PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) {
+		b = inb(TRID_REG(card, T4D_REC_CH));
+		if ((b & ~0x80) == channel)
+			outb(0x0, TRID_REG(card, T4D_REC_CH));
+	}
+
 	bank = channel >> 5;
 	channel = channel & 0x1f;
-        
+
 	card->banks[bank].bitmap &= ~(1 << (channel));
 }
 
-static struct trident_channel * cyber_alloc_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+cyber_alloc_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
@@ -743,26 +758,30 @@ static struct trident_channel * cyber_al
 	return NULL;
 }
 
-static void cyber_free_pcm_channel(struct trident_card *card, unsigned int channel)
+static void
+cyber_free_pcm_channel(struct trident_card *card, unsigned int channel)
 {
 	if (channel > 31)
 		return;
 	card->banks[BANK_A].bitmap &= ~(1 << (channel));
 }
 
-static inline void cyber_outidx(int port,int idx,int data)
+static inline void
+cyber_outidx(int port, int idx, int data)
 {
-	outb(idx,port);
-	outb(data,port+1);
+	outb(idx, port);
+	outb(data, port + 1);
 }
 
-static inline int cyber_inidx(int port,int idx)
+static inline int
+cyber_inidx(int port, int idx)
 {
-	outb(idx,port);
-	return inb(port+1);
+	outb(idx, port);
+	return inb(port + 1);
 }
 
-static int cyber_init_ritual(struct trident_card *card)
+static int
+cyber_init_ritual(struct trident_card *card)
 {
 	/* some black magic, taken from SDK samples */
 	/* remove this and nothing will work */
@@ -771,42 +790,42 @@ static int cyber_init_ritual(struct trid
 	unsigned long flags;
 
 	/*
- 	 *	Keep interrupts off for the configure - we don't want to
- 	 *	clash with another cyberpro config event
- 	 */
- 	
-	spin_lock_irqsave(&card->lock, flags); 
+	 *      Keep interrupts off for the configure - we don't want to
+	 *      clash with another cyberpro config event
+	 */
+
+	spin_lock_irqsave(&card->lock, flags);
 	portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
 	/* enable, if it was disabled */
-	if( (portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE ) {
-		printk(KERN_INFO "cyberpro5050: enabling audio controller\n" );
-		cyber_outidx( CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE,
-			portDat | CYBER_BMSK_AUENZ_ENABLE );
+	if ((portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE) {
+		printk(KERN_INFO "cyberpro5050: enabling audio controller\n");
+		cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE, 
+			     portDat | CYBER_BMSK_AUENZ_ENABLE);
 		/* check again if hardware is enabled now */
 		portDat = cyber_inidx(CYBER_PORT_AUDIO, CYBER_IDX_AUDIO_ENABLE);
 	}
-	if( (portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE )
-	{
-		printk(KERN_ERR "cyberpro5050: initAudioAccess: no success\n" );
+	if ((portDat & CYBER_BMSK_AUENZ) != CYBER_BMSK_AUENZ_ENABLE) {
+		printk(KERN_ERR "cyberpro5050: initAudioAccess: no success\n");
 		ret = -1;
+	} else {
+		cyber_outidx(CYBER_PORT_AUDIO, CYBER_IDX_IRQ_ENABLE, 
+			     CYBER_BMSK_AUDIO_INT_ENABLE);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x01);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xba, 0x20);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbb, 0x08);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x02);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xb3, 0x06);
+		cyber_outidx(CYBER_PORT_AUDIO, 0xbf, 0x00);
 	}
-	else
-	{
-		cyber_outidx( CYBER_PORT_AUDIO, CYBER_IDX_IRQ_ENABLE, CYBER_BMSK_AUDIO_INT_ENABLE );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x01 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xba, 0x20 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbb, 0x08 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x02 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xb3, 0x06 );
-		cyber_outidx( CYBER_PORT_AUDIO, 0xbf, 0x00 );
-	}
-	spin_unlock_irqrestore(&card->lock, flags); 
+	spin_unlock_irqrestore(&card->lock, flags);
 	return ret;
 }
 
 /*  called with spin lock held */
 
-static int trident_load_channel_registers(struct trident_card *card, u32 *data, unsigned int channel)
+static int
+trident_load_channel_registers(struct trident_card *card, u32 * data, 
+			       unsigned int channel)
 {
 	int i;
 
@@ -821,10 +840,10 @@ static int trident_load_channel_register
 	for (i = 0; i < CHANNEL_REGS; i++) {
 		if (i == 3 && card->pci_id == PCI_DEVICE_ID_ALI_5451)
 			continue;
-		outl(data[i], TRID_REG(card, CHANNEL_START + 4*i));
+		outl(data[i], TRID_REG(card, CHANNEL_START + 4 * i));
 	}
-	if (card->pci_id == PCI_DEVICE_ID_ALI_5451 ||
-		card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451 || 
+	    card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
 		outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF1));
 		outl(ALI_EMOD_Still, TRID_REG(card, ALI_EBUF2));
 	}
@@ -832,7 +851,8 @@ static int trident_load_channel_register
 }
 
 /* called with spin lock held */
-static int trident_write_voice_regs(struct trident_state *state)
+static int
+trident_write_voice_regs(struct trident_state *state)
 {
 	unsigned int data[CHANNEL_REGS + 1];
 	struct trident_channel *channel;
@@ -842,27 +862,27 @@ static int trident_write_voice_regs(stru
 	data[1] = channel->lba;
 	data[4] = channel->control;
 
-	switch (state->card->pci_id)
-	{
+	switch (state->card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
-		data[0] = 0; /* Current Sample Offset */
+		data[0] = 0;	/* Current Sample Offset */
 		data[2] = (channel->eso << 16) | (channel->delta & 0xffff);
 		data[3] = 0;
-		break;	
+		break;
 	case PCI_DEVICE_ID_SI_7018:
 	case PCI_DEVICE_ID_INTERG_5050:
-		data[0] = 0; /* Current Sample Offset */
+		data[0] = 0;	/* Current Sample Offset */
 		data[2] = (channel->eso << 16) | (channel->delta & 0xffff);
 		data[3] = (channel->attribute << 16) | (channel->fm_vol & 0xffff);
 		break;
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_DX:
-		data[0] = 0; /* Current Sample Offset */
+		data[0] = 0;	/* Current Sample Offset */
 		data[2] = (channel->eso << 16) | (channel->delta & 0xffff);
 		data[3] = channel->fm_vol & 0xffff;
 		break;
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_NX:
 		data[0] = (channel->delta << 24);
-		data[2] = ((channel->delta << 16) & 0xff000000) | (channel->eso & 0x00ffffff);
+		data[2] = ((channel->delta << 16) & 0xff000000) | 
+			(channel->eso & 0x00ffffff);
 		data[3] = channel->fm_vol & 0xffff;
 		break;
 	default:
@@ -872,7 +892,8 @@ static int trident_write_voice_regs(stru
 	return trident_load_channel_registers(state->card, data, channel->num);
 }
 
-static int compute_rate_play(u32 rate)
+static int
+compute_rate_play(u32 rate)
 {
 	int delta;
 	/* We special case 44100 and 8000 since rounding with the equation
@@ -890,7 +911,8 @@ static int compute_rate_play(u32 rate)
 	return delta;
 }
 
-static int compute_rate_rec(u32 rate)
+static int
+compute_rate_rec(u32 rate)
 {
 	int delta;
 
@@ -905,9 +927,11 @@ static int compute_rate_rec(u32 rate)
 
 	return delta;
 }
+
 /* set playback sample rate */
-static unsigned int trident_set_dac_rate(struct trident_state * state, unsigned int rate)
-{	
+static unsigned int
+trident_set_dac_rate(struct trident_state *state, unsigned int rate)
+{
 	struct dmabuf *dmabuf = &state->dmabuf;
 
 	if (rate > 48000)
@@ -926,7 +950,8 @@ static unsigned int trident_set_dac_rate
 }
 
 /* set recording sample rate */
-static unsigned int trident_set_adc_rate(struct trident_state * state, unsigned int rate)
+static unsigned int
+trident_set_adc_rate(struct trident_state *state, unsigned int rate)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 
@@ -945,8 +970,9 @@ static unsigned int trident_set_adc_rate
 	return rate;
 }
 
-/* prepare channel attributes for playback */ 
-static void trident_play_setup(struct trident_state *state)
+/* prepare channel attributes for playback */
+static void
+trident_play_setup(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	struct trident_channel *channel = dmabuf->channel;
@@ -960,19 +986,21 @@ static void trident_play_setup(struct tr
 	if (state->card->pci_id != PCI_DEVICE_ID_SI_7018) {
 		channel->attribute = 0;
 		if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-			if ((channel->num == ALI_SPDIF_IN_CHANNEL) || (channel->num == ALI_PCM_IN_CHANNEL))
+			if ((channel->num == ALI_SPDIF_IN_CHANNEL) || 
+			    (channel->num == ALI_PCM_IN_CHANNEL))
 				ali_disable_special_channel(state->card, channel->num);
-			else if ((inl(TRID_REG(state->card, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_OUT_CH_ENABLE) 
-								&& (channel->num == ALI_SPDIF_OUT_CHANNEL))
-			{
-				ali_set_spdif_out_rate(state->card, state->dmabuf.rate);
+			else if ((inl(TRID_REG(state->card, ALI_GLOBAL_CONTROL)) 
+				  & ALI_SPDIF_OUT_CH_ENABLE)
+				 && (channel->num == ALI_SPDIF_OUT_CHANNEL)) {
+				ali_set_spdif_out_rate(state->card, 
+						       state->dmabuf.rate);
 				state->dmabuf.channel->delta = 0x1000;
 			}
 		}
 	}
 
 	channel->fm_vol = 0x0;
-	
+
 	channel->control = CHANNEL_LOOP;
 	if (dmabuf->fmt & TRIDENT_FMT_16BIT) {
 		/* 16-bits */
@@ -984,18 +1012,19 @@ static void trident_play_setup(struct tr
 		/* stereo */
 		channel->control |= CHANNEL_STEREO;
 
-	TRDBG("trident: trident_play_setup, LBA = 0x%08x, "
-	      "Delta = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
-	      channel->lba, channel->delta, channel->eso, channel->control);
+	TRDBG("trident: trident_play_setup, LBA = 0x%08x, Delta = 0x%08x, "
+	      "ESO = 0x%08x, Control = 0x%08x\n", channel->lba, 
+	      channel->delta, channel->eso, channel->control);
 
 	trident_write_voice_regs(state);
 }
 
 /* prepare channel attributes for recording */
-static void trident_rec_setup(struct trident_state *state)
+static void
+trident_rec_setup(struct trident_state *state)
 {
 	u16 w;
-	u8  bval;
+	u8 bval;
 
 	struct trident_card *card = state->card;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1003,8 +1032,7 @@ static void trident_rec_setup(struct tri
 	unsigned int rate;
 
 	/* Enable AC-97 ADC (capture) */
-	switch (card->pci_id) 
-	{
+	switch (card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
 		ali_enable_special_channel(state);
 		break;
@@ -1032,24 +1060,25 @@ static void trident_rec_setup(struct tri
 
 	channel->lba = dmabuf->dma_handle;
 	channel->delta = compute_rate_rec(dmabuf->rate);
-	if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) && (channel->num == ALI_SPDIF_IN_CHANNEL)) {
+	if ((card->pci_id == PCI_DEVICE_ID_ALI_5451) && 
+	    (channel->num == ALI_SPDIF_IN_CHANNEL)) {
 		rate = ali_get_spdif_in_rate(card);
-		if (rate == 0)
-		{
-			printk(KERN_WARNING "trident: ALi 5451 S/PDIF input setup error!\n");
+		if (rate == 0) {
+			printk(KERN_WARNING "trident: ALi 5451 "
+			       "S/PDIF input setup error!\n");
 			rate = 48000;
 		}
-		bval = inb(TRID_REG(card,ALI_SPDIF_CTRL));
-		if (bval & 0x10)
-		{
-			outb(bval,TRID_REG(card,ALI_SPDIF_CTRL));
-			printk(KERN_WARNING "trident: cleared ALi 5451 S/PDIF parity error flag.\n");
+		bval = inb(TRID_REG(card, ALI_SPDIF_CTRL));
+		if (bval & 0x10) {
+			outb(bval, TRID_REG(card, ALI_SPDIF_CTRL));
+			printk(KERN_WARNING "trident: cleared ALi "
+			       "5451 S/PDIF parity error flag.\n");
 		}
 
 		if (rate != 48000)
 			channel->delta = ((rate << 12) / dmabuf->rate) & 0x0000ffff;
 	}
-	
+
 	channel->eso = dmabuf->dmasize >> sample_shift[dmabuf->fmt];
 	channel->eso -= 1;
 
@@ -1058,7 +1087,7 @@ static void trident_rec_setup(struct tri
 	}
 
 	channel->fm_vol = 0x0;
-	
+
 	channel->control = CHANNEL_LOOP;
 	if (dmabuf->fmt & TRIDENT_FMT_16BIT) {
 		/* 16-bits */
@@ -1069,17 +1098,18 @@ static void trident_rec_setup(struct tri
 	if (dmabuf->fmt & TRIDENT_FMT_STEREO)
 		/* stereo */
 		channel->control |= CHANNEL_STEREO;
-	
-	TRDBG("trident: trident_rec_setup, LBA = 0x%08x, "
-	      "Delat = 0x%08x, ESO = 0x%08x, Control = 0x%08x\n",
-	      channel->lba, channel->delta, channel->eso, channel->control);
+
+	TRDBG("trident: trident_rec_setup, LBA = 0x%08x, Delat = 0x%08x, "
+	      "ESO = 0x%08x, Control = 0x%08x\n", channel->lba, 
+	      channel->delta, channel->eso, channel->control);
 
 	trident_write_voice_regs(state);
 }
 
 /* get current playback/recording dma buffer pointer (byte offset from LBA),
    called with spinlock held! */
-static inline unsigned trident_get_dma_addr(struct trident_state *state)
+static inline unsigned
+trident_get_dma_addr(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	u32 cso;
@@ -1089,8 +1119,7 @@ static inline unsigned trident_get_dma_a
 
 	outb(dmabuf->channel->num, TRID_REG(state->card, T4D_LFO_GC_CIR));
 
-	switch (state->card->pci_id) 
-	{
+	switch (state->card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
 	case PCI_DEVICE_ID_SI_7018:
 	case PCI_DEVICE_ID_TRIDENT_4DWAVE_DX:
@@ -1106,8 +1135,7 @@ static inline unsigned trident_get_dma_a
 		return 0;
 	}
 
-	
-	TRDBG("trident: trident_get_dma_addr: chip reported channel: %d, "
+	TRDBG("trident: trident_get_dma_addr: chip reported channel: %d, " 
 	      "cso = 0x%04x\n", dmabuf->channel->num, cso);
 
 	/* ESO and CSO are in units of Samples, convert to byte offset */
@@ -1117,7 +1145,8 @@ static inline unsigned trident_get_dma_a
 }
 
 /* Stop recording (lock held) */
-static inline void __stop_adc(struct trident_state *state)
+static inline void
+__stop_adc(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1128,7 +1157,8 @@ static inline void __stop_adc(struct tri
 	trident_disable_voice_irq(card, chan_num);
 }
 
-static void stop_adc(struct trident_state *state)
+static void
+stop_adc(struct trident_state *state)
 {
 	struct trident_card *card = state->card;
 	unsigned long flags;
@@ -1138,7 +1168,8 @@ static void stop_adc(struct trident_stat
 	spin_unlock_irqrestore(&card->lock, flags);
 }
 
-static void start_adc(struct trident_state *state)
+static void
+start_adc(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1146,7 +1177,9 @@ static void start_adc(struct trident_sta
 	unsigned long flags;
 
 	spin_lock_irqsave(&card->lock, flags);
-	if ((dmabuf->mapped || dmabuf->count < (signed)dmabuf->dmasize) && dmabuf->ready) {
+	if ((dmabuf->mapped || 
+	     dmabuf->count < (signed) dmabuf->dmasize) && 
+	    dmabuf->ready) {
 		dmabuf->enable |= ADC_RUNNING;
 		trident_enable_voice_irq(card, chan_num);
 		trident_start_voice(card, chan_num);
@@ -1155,7 +1188,8 @@ static void start_adc(struct trident_sta
 }
 
 /* stop playback (lock held) */
-static inline void __stop_dac(struct trident_state *state)
+static inline void
+__stop_dac(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1164,15 +1198,20 @@ static inline void __stop_dac(struct tri
 	dmabuf->enable &= ~DAC_RUNNING;
 	trident_stop_voice(card, chan_num);
 	if (state->chans_num == 6) {
-		trident_stop_voice(card, state->other_states[0]->dmabuf.channel->num);
-		trident_stop_voice(card, state->other_states[1]->dmabuf.channel->num);
-		trident_stop_voice(card, state->other_states[2]->dmabuf.channel->num);
-		trident_stop_voice(card, state->other_states[3]->dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[0]->
+				   dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[1]->
+				   dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[2]->
+				   dmabuf.channel->num);
+		trident_stop_voice(card, state->other_states[3]->
+				   dmabuf.channel->num);
 	}
 	trident_disable_voice_irq(card, chan_num);
 }
 
-static void stop_dac(struct trident_state *state)
+static void
+stop_dac(struct trident_state *state)
 {
 	struct trident_card *card = state->card;
 	unsigned long flags;
@@ -1180,9 +1219,10 @@ static void stop_dac(struct trident_stat
 	spin_lock_irqsave(&card->lock, flags);
 	__stop_dac(state);
 	spin_unlock_irqrestore(&card->lock, flags);
-}	
+}
 
-static void start_dac(struct trident_state *state)
+static void
+start_dac(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned int chan_num = dmabuf->channel->num;
@@ -1195,10 +1235,14 @@ static void start_dac(struct trident_sta
 		trident_enable_voice_irq(card, chan_num);
 		trident_start_voice(card, chan_num);
 		if (state->chans_num == 6) {
-			trident_start_voice(card, state->other_states[0]->dmabuf.channel->num);
-			trident_start_voice(card, state->other_states[1]->dmabuf.channel->num);
-			trident_start_voice(card, state->other_states[2]->dmabuf.channel->num);
-			trident_start_voice(card, state->other_states[3]->dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[0]->
+					    dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[1]->
+					    dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[2]->
+					    dmabuf.channel->num);
+			trident_start_voice(card, state->other_states[3]->
+					    dmabuf.channel->num);
 		}
 	}
 	spin_unlock_irqrestore(&card->lock, flags);
@@ -1207,24 +1251,26 @@ static void start_dac(struct trident_sta
 #define DMABUF_DEFAULTORDER (15-PAGE_SHIFT)
 #define DMABUF_MINORDER 1
 
-/* alloc a DMA buffer of with a buffer of this order */ 
-static int alloc_dmabuf(struct dmabuf* dmabuf, struct pci_dev* pci_dev, int order)
+/* alloc a DMA buffer of with a buffer of this order */
+static int
+alloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev, int order)
 {
 	void *rawbuf = NULL;
 	struct page *page, *pend;
 
-	if (!(rawbuf = pci_alloc_consistent(pci_dev, PAGE_SIZE << order,
+	if (!(rawbuf = pci_alloc_consistent(pci_dev, PAGE_SIZE << order, 
 					    &dmabuf->dma_handle)))
 		return -ENOMEM;
 
 	TRDBG("trident: allocated %ld (order = %d) bytes at %p\n",
 	      PAGE_SIZE << order, order, rawbuf);
 
-	dmabuf->ready  = dmabuf->mapped = 0;
+	dmabuf->ready = dmabuf->mapped = 0;
 	dmabuf->rawbuf = rawbuf;
 	dmabuf->buforder = order;
-	
-	/* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+
+	/* now mark the pages as reserved; otherwise */ 
+	/* remap_page_range doesn't do what we want */
 	pend = virt_to_page(rawbuf + (PAGE_SIZE << order) - 1);
 	for (page = virt_to_page(rawbuf); page <= pend; page++)
 		SetPageReserved(page);
@@ -1232,41 +1278,44 @@ static int alloc_dmabuf(struct dmabuf* d
 	return 0;
 }
 
-/* allocate the main DMA buffer, playback and recording buffer should be */ 
+/* allocate the main DMA buffer, playback and recording buffer should be */
 /* allocated separately */
-static int alloc_main_dmabuf(struct trident_state *state)
+static int
+alloc_main_dmabuf(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	int order;
-	int ret = -ENOMEM; 
+	int ret = -ENOMEM;
 
 	/* alloc as big a chunk as we can, FIXME: is this necessary ?? */
 	for (order = DMABUF_DEFAULTORDER; order >= DMABUF_MINORDER; order--) {
 		if (!(ret = alloc_dmabuf(dmabuf, state->card->pci_dev, order)))
-			return 0; 
-		/* else try again */ 
+			return 0;
+		/* else try again */
 	}
-	return ret; 
+	return ret;
 }
 
-/* deallocate a DMA buffer */ 
-static void dealloc_dmabuf(struct dmabuf* dmabuf, struct pci_dev* pci_dev)
+/* deallocate a DMA buffer */
+static void
+dealloc_dmabuf(struct dmabuf *dmabuf, struct pci_dev *pci_dev)
 {
 	struct page *page, *pend;
-	
+
 	if (dmabuf->rawbuf) {
 		/* undo marking the pages as reserved */
 		pend = virt_to_page(dmabuf->rawbuf + (PAGE_SIZE << dmabuf->buforder) - 1);
 		for (page = virt_to_page(dmabuf->rawbuf); page <= pend; page++)
 			ClearPageReserved(page);
-		pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder,
+		pci_free_consistent(pci_dev, PAGE_SIZE << dmabuf->buforder, 
 				    dmabuf->rawbuf, dmabuf->dma_handle);
 		dmabuf->rawbuf = NULL;
 	}
 	dmabuf->mapped = dmabuf->ready = 0;
 }
 
-static int prog_dmabuf(struct trident_state *state, unsigned rec)
+static int
+prog_dmabuf(struct trident_state *state, unsigned rec)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned bytepersec;
@@ -1274,13 +1323,13 @@ static int prog_dmabuf(struct trident_st
 	unsigned bufsize, dma_nums;
 	unsigned long flags;
 	int ret, i, order;
-	
+
 	lock_set_fmt(state);
 	if (state->chans_num == 6)
 		dma_nums = 5;
-	else 	
+	else
 		dma_nums = 1;
-	
+
 	for (i = 0; i < dma_nums; i++) {
 		if (i > 0) {
 			s = state->other_states[i - 1];
@@ -1302,19 +1351,19 @@ static int prog_dmabuf(struct trident_st
 					return ret;
 				}
 			} else {
-				ret = -ENOMEM; 
+				ret = -ENOMEM;
 				if ((order = state->dmabuf.buforder - 1) >= DMABUF_MINORDER) {
-					ret = alloc_dmabuf(dmabuf, state->card->pci_dev, order); 
+					ret = alloc_dmabuf(dmabuf, state->card->pci_dev, order);
 				}
 				if (ret) {
-					/* release the main DMA buffer */ 
-					dealloc_dmabuf(&state->dmabuf, state->card->pci_dev); 
-					/* release the auxiliary DMA buffers */ 
-					for (i-=2; i >= 0; i--)
+					/* release the main DMA buffer */
+					dealloc_dmabuf(&state->dmabuf, state->card->pci_dev);
+					/* release the auxiliary DMA buffers */
+					for (i -= 2; i >= 0; i--)
 						dealloc_dmabuf(&state->other_states[i]->dmabuf, 
-							       state->card->pci_dev); 
+							       state->card->pci_dev);
 					unlock_set_fmt(state);
-					return ret; 
+					return ret;
 				}
 			}
 		}
@@ -1323,12 +1372,12 @@ static int prog_dmabuf(struct trident_st
 		bufsize = PAGE_SIZE << dmabuf->buforder;
 		if (dmabuf->ossfragshift) {
 			if ((1000 << dmabuf->ossfragshift) < bytepersec)
-				dmabuf->fragshift = ld2(bytepersec/1000);
+				dmabuf->fragshift = ld2(bytepersec / 1000);
 			else
 				dmabuf->fragshift = dmabuf->ossfragshift;
 		} else {
 			/* lets hand out reasonable big ass buffers by default */
-			dmabuf->fragshift = (dmabuf->buforder + PAGE_SHIFT -2);
+			dmabuf->fragshift = (dmabuf->buforder + PAGE_SHIFT - 2);
 		}
 		dmabuf->numfrag = bufsize >> dmabuf->fragshift;
 		while (dmabuf->numfrag < 4 && dmabuf->fragshift > 3) {
@@ -1341,23 +1390,24 @@ static int prog_dmabuf(struct trident_st
 		dmabuf->fragsamples = dmabuf->fragsize >> sample_shift[dmabuf->fmt];
 		dmabuf->dmasize = dmabuf->numfrag << dmabuf->fragshift;
 
-		memset(dmabuf->rawbuf, (dmabuf->fmt & TRIDENT_FMT_16BIT) ? 0 : 0x80,
+		memset(dmabuf->rawbuf, (dmabuf->fmt & TRIDENT_FMT_16BIT) ? 0 : 0x80, 
 		       dmabuf->dmasize);
 
 		spin_lock_irqsave(&s->card->lock, flags);
-		if (rec) 
+		if (rec)
 			trident_rec_setup(s);
-		else 
+		else
 			trident_play_setup(s);
-		
+
 		spin_unlock_irqrestore(&s->card->lock, flags);
 
 		/* set the ready flag for the dma buffer */
 		dmabuf->ready = 1;
 
-		TRDBG("trident: prog_dmabuf(%d), sample rate = %d, format = %d, numfrag = %d, "
-		      "fragsize = %d dmasize = %d\n",
-		      dmabuf->channel->num, dmabuf->rate, dmabuf->fmt, dmabuf->numfrag,
+		TRDBG("trident: prog_dmabuf(%d), sample rate = %d, "
+		      "format = %d, numfrag = %d, fragsize = %d "
+		      "dmasize = %d\n", dmabuf->channel->num, 
+		      dmabuf->rate, dmabuf->fmt, dmabuf->numfrag, 
 		      dmabuf->fragsize, dmabuf->dmasize);
 	}
 	unlock_set_fmt(state);
@@ -1371,7 +1421,8 @@ static int prog_dmabuf(struct trident_st
    so we have to clear the tail space to "silence"
    |xxxxxx000000|------------|   or   |xxxxxxxxxxxx|xxxxxx000000|
 */
-static void trident_clear_tail(struct trident_state *state)
+static void
+trident_clear_tail(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned swptr;
@@ -1383,17 +1434,17 @@ static void trident_clear_tail(struct tr
 	swptr = dmabuf->swptr;
 	spin_unlock_irqrestore(&state->card->lock, flags);
 
-	if (swptr == 0 || swptr == dmabuf->dmasize / 2 || swptr == dmabuf->dmasize)
+	if (swptr == 0 || swptr == dmabuf->dmasize / 2 || 
+	    swptr == dmabuf->dmasize)
 		return;
 
-	if (swptr < dmabuf->dmasize/2)
-		len = dmabuf->dmasize/2 - swptr;
+	if (swptr < dmabuf->dmasize / 2)
+		len = dmabuf->dmasize / 2 - swptr;
 	else
 		len = dmabuf->dmasize - swptr;
 
 	memset(dmabuf->rawbuf + swptr, silence, len);
-	if(state->card->pci_id != PCI_DEVICE_ID_ALI_5451)
-	{
+	if (state->card->pci_id != PCI_DEVICE_ID_ALI_5451) {
 		spin_lock_irqsave(&state->card->lock, flags);
 		dmabuf->swptr += len;
 		dmabuf->count += len;
@@ -1404,7 +1455,8 @@ static void trident_clear_tail(struct tr
 	start_dac(state);
 }
 
-static int drain_dac(struct trident_state *state, int nonblock)
+static int
+drain_dac(struct trident_state *state, int nonblock)
 {
 	DECLARE_WAITQUEUE(wait, current);
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1440,19 +1492,16 @@ static int drain_dac(struct trident_stat
 
 		/* No matter how much data is left in the buffer, we have to wait until
 		   CSO == ESO/2 or CSO == ESO when address engine interrupts */
-	 	if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451 ||
-		    state->card->pci_id == PCI_DEVICE_ID_INTERG_5050)
-		{	
-			diff = dmabuf->swptr - trident_get_dma_addr(state) + dmabuf->dmasize ;
+		if (state->card->pci_id == PCI_DEVICE_ID_ALI_5451 || 
+		    state->card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
+			diff = dmabuf->swptr - trident_get_dma_addr(state) + dmabuf->dmasize;
 			diff = diff % (dmabuf->dmasize);
-			tmo  = (diff * HZ) / dmabuf->rate;
-		}
-		else
-		{
+			tmo = (diff * HZ) / dmabuf->rate;
+		} else {
 			tmo = (dmabuf->dmasize * HZ) / dmabuf->rate;
 		}
 		tmo >>= sample_shift[dmabuf->fmt];
-		if (!schedule_timeout(tmo ? tmo : 1) && tmo){
+		if (!schedule_timeout(tmo ? tmo : 1) && tmo) {
 			break;
 		}
 	}
@@ -1464,8 +1513,10 @@ static int drain_dac(struct trident_stat
 	return 0;
 }
 
-/* update buffer manangement pointers, especially, dmabuf->count and dmabuf->hwptr */
-static void trident_update_ptr(struct trident_state *state)
+/* update buffer manangement pointers, especially, */ 
+/* dmabuf->count and dmabuf->hwptr */
+static void
+trident_update_ptr(struct trident_state *state)
 {
 	struct dmabuf *dmabuf = &state->dmabuf;
 	unsigned hwptr, swptr;
@@ -1484,19 +1535,21 @@ static void trident_update_ptr(struct tr
 	if (dmabuf->enable == ADC_RUNNING) {
 		if (dmabuf->mapped) {
 			dmabuf->count -= diff;
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
+			if (dmabuf->count >= (signed) dmabuf->fragsize)
 				wake_up(&dmabuf->wait);
 		} else {
 			dmabuf->count += diff;
 
-			if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
-				/* buffer underrun or buffer overrun, we have no way to recover
-				   it here, just stop the machine and let the process force hwptr
-				   and swptr to sync */
+			if (dmabuf->count < 0 || 
+			    dmabuf->count > dmabuf->dmasize) {
+				/* buffer underrun or buffer overrun, */ 
+				/* we have no way to recover it here, just */ 
+				/* stop the machine and let the process */ 
+				/* force hwptr and swptr to sync */
 				__stop_adc(state);
 				dmabuf->error++;
 			}
-			if (dmabuf->count < (signed)dmabuf->dmasize/2)
+			if (dmabuf->count < (signed) dmabuf->dmasize / 2)
 				wake_up(&dmabuf->wait);
 		}
 	}
@@ -1505,19 +1558,19 @@ static void trident_update_ptr(struct tr
 	if (dmabuf->enable == DAC_RUNNING) {
 		if (dmabuf->mapped) {
 			dmabuf->count += diff;
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
+			if (dmabuf->count >= (signed) dmabuf->fragsize)
 				wake_up(&dmabuf->wait);
 		} else {
 			dmabuf->count -= diff;
 
-			if (dmabuf->count < 0 || dmabuf->count > dmabuf->dmasize) {
+			if (dmabuf->count < 0 || 
+			    dmabuf->count > dmabuf->dmasize) {
 				/* buffer underrun or buffer overrun, we have no way to recover
 				   it here, just stop the machine and let the process force hwptr
 				   and swptr to sync */
 				__stop_dac(state);
 				dmabuf->error++;
-			}
-			else if (!dmabuf->endcleared) {
+			} else if (!dmabuf->endcleared) {
 				swptr = dmabuf->swptr;
 				silence = (dmabuf->fmt & TRIDENT_FMT_16BIT ? 0 : 0x80);
 				if (dmabuf->update_flag & ALI_ADDRESS_INT_UPDATE) {
@@ -1525,26 +1578,25 @@ static void trident_update_ptr(struct tr
 					   According to 1/2 algorithm of Address Engine Interrupt,
 					   check the validation of the data of half dmasize. */
 					half_dmasize = dmabuf->dmasize / 2;
-					if ((diff = hwptr - half_dmasize) < 0 )
+					if ((diff = hwptr - half_dmasize) < 0)
 						diff = hwptr;
 					if ((dmabuf->count + diff) < half_dmasize) {
 						//there is invalid data in the end of half buffer
 						if ((clear_cnt = half_dmasize - swptr) < 0)
 							clear_cnt += half_dmasize;
 						//clear the invalid data
-						memset (dmabuf->rawbuf + swptr,
-							silence, clear_cnt);
+						memset(dmabuf->rawbuf + swptr, silence, clear_cnt);
 						if (state->chans_num == 6) {
-						clear_cnt = clear_cnt / 2;
-						swptr = swptr / 2;
-							memset (state->other_states[0]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
-							memset (state->other_states[1]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
-							memset (state->other_states[2]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
-							memset (state->other_states[3]->dmabuf.rawbuf + swptr,
-								silence, clear_cnt);
+							clear_cnt = clear_cnt / 2;
+							swptr = swptr / 2;
+							memset(state->other_states[0]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
+							memset(state->other_states[1]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
+							memset(state->other_states[2]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
+							memset(state->other_states[3]->dmabuf.rawbuf + swptr, 
+							       silence, clear_cnt);
 						}
 						dmabuf->endcleared = 1;
 					}
@@ -1552,18 +1604,18 @@ static void trident_update_ptr(struct tr
 					clear_cnt = dmabuf->fragsize;
 					if ((swptr + clear_cnt) > dmabuf->dmasize)
 						clear_cnt = dmabuf->dmasize - swptr;
-					memset (dmabuf->rawbuf + swptr, silence, clear_cnt);
+					memset(dmabuf->rawbuf + swptr, silence, clear_cnt);
 					if (state->chans_num == 6) {
 						clear_cnt = clear_cnt / 2;
 						swptr = swptr / 2;
-						memset (state->other_states[0]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
-						memset (state->other_states[1]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
-						memset (state->other_states[2]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
-						memset (state->other_states[3]->dmabuf.rawbuf + swptr,
-							silence, clear_cnt);
+						memset(state->other_states[0]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
+						memset(state->other_states[1]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
+						memset(state->other_states[2]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
+						memset(state->other_states[3]->dmabuf.rawbuf + swptr, 
+						       silence, clear_cnt);
 					}
 					dmabuf->endcleared = 1;
 				}
@@ -1571,29 +1623,30 @@ static void trident_update_ptr(struct tr
 			/* trident_update_ptr is called by interrupt handler or by process via
 			   ioctl/poll, we only wake up the waiting process when we have more
 			   than 1/2 buffer free (always true for interrupt handler) */
-			if (dmabuf->count < (signed)dmabuf->dmasize/2)
+			if (dmabuf->count < (signed) dmabuf->dmasize / 2)
 				wake_up(&dmabuf->wait);
 		}
 	}
 	dmabuf->update_flag &= ~ALI_ADDRESS_INT_UPDATE;
 }
 
-static void trident_address_interrupt(struct trident_card *card)
+static void
+trident_address_interrupt(struct trident_card *card)
 {
 	int i;
 	struct trident_state *state;
-	unsigned int channel; 
-	
+	unsigned int channel;
+
 	/* Update the pointers for all channels we are running. */
 	/* FIXME: should read interrupt status only once */
 	for (i = 0; i < NR_HW_CH; i++) {
-		channel = 63 - i; 
+		channel = 63 - i;
 		if (trident_check_channel_interrupt(card, channel)) {
 			trident_ack_channel_interrupt(card, channel);
 			if ((state = card->states[i]) != NULL) {
 				trident_update_ptr(state);
 			} else {
-				printk(KERN_WARNING "trident: spurious channel "
+				printk(KERN_WARNING "trident: spurious channel " 
 				       "irq %d.\n", channel);
 				trident_stop_voice(card, channel);
 				trident_disable_voice_irq(card, channel);
@@ -1602,7 +1655,8 @@ static void trident_address_interrupt(st
 	}
 }
 
-static void ali_hwvol_control(struct trident_card *card, int opt)
+static void
+ali_hwvol_control(struct trident_card *card, int opt)
 {
 	u16 dwTemp, volume[2], mute, diff, *pVol[2];
 
@@ -1610,7 +1664,7 @@ static void ali_hwvol_control(struct tri
 	mute = dwTemp & 0x8000;
 	volume[0] = dwTemp & 0x001f;
 	volume[1] = (dwTemp & 0x1f00) >> 8;
-	if (volume[0] < volume [1]) {
+	if (volume[0] < volume[1]) {
 		pVol[0] = &volume[0];
 		pVol[1] = &volume[1];
 	} else {
@@ -1619,10 +1673,11 @@ static void ali_hwvol_control(struct tri
 	}
 	diff = *(pVol[1]) - *(pVol[0]);
 
-	if (opt == 1) {                     // MUTE
+	if (opt == 1) {		// MUTE
 		dwTemp ^= 0x8000;
-		ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
-	} else if (opt == 2) {   // Down
+		ali_ac97_write(card->ac97_codec[0], 
+			       0x02, dwTemp);
+	} else if (opt == 2) {	// Down
 		if (mute)
 			return;
 		if (*(pVol[1]) < 0x001f) {
@@ -1632,21 +1687,21 @@ static void ali_hwvol_control(struct tri
 		dwTemp &= 0xe0e0;
 		dwTemp |= (volume[0]) | (volume[1] << 8);
 		ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
-		card->ac97_codec[0]->mixer_state[0] = ((32-volume[0])*25/8) | (((32-volume[1])*25/8) << 8);
-	} else if (opt == 4) {   // Up
+		card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) | 
+			(((32 - volume[1]) * 25 / 8) << 8);
+	} else if (opt == 4) {	// Up
 		if (mute)
 			return;
-		if (*(pVol[0]) >0) {
+		if (*(pVol[0]) > 0) {
 			(*pVol[0])--;
 			*(pVol[1]) = *(pVol[0]) + diff;
 		}
 		dwTemp &= 0xe0e0;
 		dwTemp |= (volume[0]) | (volume[1] << 8);
 		ali_ac97_write(card->ac97_codec[0], 0x02, dwTemp);
-		card->ac97_codec[0]->mixer_state[0] = ((32-volume[0])*25/8) | (((32-volume[1])*25/8) << 8);
-	} 
-	else 
-	{
+		card->ac97_codec[0]->mixer_state[0] = ((32 - volume[0]) * 25 / 8) | 
+			(((32 - volume[1]) * 25 / 8) << 8);
+	} else {
 		/* Nothing needs doing */
 	}
 }
@@ -1655,12 +1710,13 @@ static void ali_hwvol_control(struct tri
  *	Re-enable reporting of vol change after 0.1 seconds
  */
 
-static void ali_timeout(unsigned long ptr)
+static void
+ali_timeout(unsigned long ptr)
 {
-	struct trident_card *card = (struct trident_card *)ptr;
+	struct trident_card *card = (struct trident_card *) ptr;
 	u16 temp = 0;
 
-	/* Enable GPIO IRQ (MISCINT bit 18h)*/
+	/* Enable GPIO IRQ (MISCINT bit 18h) */
 	temp = inw(TRID_REG(card, T4D_MISCINT + 2));
 	temp |= 0x0004;
 	outw(temp, TRID_REG(card, T4D_MISCINT + 2));
@@ -1669,62 +1725,65 @@ static void ali_timeout(unsigned long pt
 /*
  *	Set up the timer to clear the vol change notification
  */
- 
-static void ali_set_timer(struct trident_card *card)
+
+static void
+ali_set_timer(struct trident_card *card)
 {
 	/* Add Timer Routine to Enable GPIO IRQ */
 	del_timer(&card->timer);	/* Never queue twice */
 	card->timer.function = ali_timeout;
 	card->timer.data = (unsigned long) card;
-	card->timer.expires = jiffies + HZ/10;
+	card->timer.expires = jiffies + HZ / 10;
 	add_timer(&card->timer);
 }
 
 /*
  *	Process a GPIO event
  */
- 
-static void ali_queue_task(struct trident_card *card, int opt)
+
+static void
+ali_queue_task(struct trident_card *card, int opt)
 {
 	u16 temp;
 
-	/* Disable GPIO IRQ (MISCINT bit 18h)*/
+	/* Disable GPIO IRQ (MISCINT bit 18h) */
 	temp = inw(TRID_REG(card, T4D_MISCINT + 2));
-	temp &= (u16)(~0x0004);
+	temp &= (u16) (~0x0004);
 	outw(temp, TRID_REG(card, T4D_MISCINT + 2));
 
 	/* Adjust the volume */
 	ali_hwvol_control(card, opt);
-	
+
 	/* Set the timer for 1/10th sec */
 	ali_set_timer(card);
 }
 
-static void cyber_address_interrupt(struct trident_card *card)
+static void
+cyber_address_interrupt(struct trident_card *card)
 {
-	int i,irq_status;
+	int i, irq_status;
 	struct trident_state *state;
-	unsigned int channel; 
+	unsigned int channel;
 
 	/* Update the pointers for all channels we are running. */
 	/* FIXED: read interrupt status only once */
-	irq_status=inl(TRID_REG(card, T4D_AINT_A) );
+	irq_status = inl(TRID_REG(card, T4D_AINT_A));
 
-	TRDBG("cyber_address_interrupt: irq_status 0x%X\n",irq_status);
+	TRDBG("cyber_address_interrupt: irq_status 0x%X\n", irq_status);
 
 	for (i = 0; i < NR_HW_CH; i++) {
-		channel = 31 - i; 
-		if (irq_status & ( 1 << channel) ) {
-			/* clear bit by writing a 1, zeroes are ignored */ 		
-			outl( (1 << channel), TRID_REG(card, T4D_AINT_A));
-		
+		channel = 31 - i;
+		if (irq_status & (1 << channel)) {
+			/* clear bit by writing a 1, zeroes are ignored */
+			outl((1 << channel), TRID_REG(card, T4D_AINT_A));
+
 			TRDBG("cyber_interrupt: channel %d\n", channel);
 
 			if ((state = card->states[i]) != NULL) {
 				trident_update_ptr(state);
 			} else {
-				printk(KERN_WARNING "cyber5050: spurious "
-				       "channel irq %d.\n", channel); 
+				printk(KERN_WARNING "cyber5050: spurious " 
+				       "channel irq %d.\n", channel);
 				trident_stop_voice(card, channel);
 				trident_disable_voice_irq(card, channel);
 			}
@@ -1732,9 +1791,10 @@ static void cyber_address_interrupt(stru
 	}
 }
 
-static irqreturn_t trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t
+trident_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
-	struct trident_card *card = (struct trident_card *)dev_id;
+	struct trident_card *card = (struct trident_card *) dev_id;
 	u32 event;
 	u32 gpio;
 
@@ -1747,31 +1807,33 @@ static irqreturn_t trident_interrupt(int
 		card->address_interrupt(card);
 	}
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451)
-	{
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		/* GPIO IRQ (H/W Volume Control) */
 		event = inl(TRID_REG(card, T4D_MISCINT));
-		if (event & (1<<25)) {
+		if (event & (1 << 25)) {
 			gpio = inl(TRID_REG(card, ALI_GPIO));
-			if (!timer_pending(&card->timer)) 
-				ali_queue_task(card, gpio&0x07);
+			if (!timer_pending(&card->timer))
+				ali_queue_task(card, gpio & 0x07);
 		}
 		event = inl(TRID_REG(card, T4D_MISCINT));
-		outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), TRID_REG(card, T4D_MISCINT));
+		outl(event | (ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 
+		     TRID_REG(card, T4D_MISCINT));
 		spin_unlock(&card->lock);
 		return IRQ_HANDLED;
 	}
 
 	/* manually clear interrupt status, bad hardware design, blame T^2 */
-	outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW),
+	outl((ST_TARGET_REACHED | MIXER_OVERFLOW | MIXER_UNDERFLOW), 
 	     TRID_REG(card, T4D_MISCINT));
 	spin_unlock(&card->lock);
 	return IRQ_HANDLED;
 }
 
-/* in this loop, dmabuf.count signifies the amount of data that is waiting to be copied to
-   the user's buffer.  it is filled by the dma machine and drained by this loop. */
-static ssize_t trident_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
+/* in this loop, dmabuf.count signifies the amount of data that is waiting */ 
+/* to be copied to the user's buffer.  it is filled by the dma machine and */ 
+/* drained by this loop. */
+static ssize_t
+trident_read(struct file *file, char *buffer, size_t count, loff_t * ppos)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1785,12 +1847,12 @@ static ssize_t trident_read(struct file 
 	VALIDATE_STATE(state);
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-		
+
 	if (dmabuf->mapped)
 		return -ENXIO;
 	if (!access_ok(VERIFY_WRITE, buffer, count))
 		return -EFAULT;
-		
+
 	down(&state->sem);
 	if (!dmabuf->ready && (ret = prog_dmabuf(state, 1)))
 		goto out;
@@ -1798,8 +1860,9 @@ static ssize_t trident_read(struct file 
 	while (count > 0) {
 		spin_lock_irqsave(&state->card->lock, flags);
 		if (dmabuf->count > (signed) dmabuf->dmasize) {
-			/* buffer overrun, we are recovering from sleep_on_timeout,
-			   resync hwptr and swptr, make process flush the buffer */
+			/* buffer overrun, we are recovering from */ 
+			/* sleep_on_timeout, resync hwptr and swptr, */ 
+			/* make process flush the buffer */
 			dmabuf->count = dmabuf->dmasize;
 			dmabuf->swptr = dmabuf->hwptr;
 		}
@@ -1813,17 +1876,19 @@ static ssize_t trident_read(struct file 
 			cnt = count;
 		if (cnt <= 0) {
 			unsigned long tmo;
-			/* buffer is empty, start the dma machine and wait for data to be
-			   recorded */
+			/* buffer is empty, start the dma machine and */ 
+			/* wait for data to be recorded */
 			start_adc(state);
 			if (file->f_flags & O_NONBLOCK) {
-				if (!ret) ret = -EAGAIN;
+				if (!ret)
+					ret = -EAGAIN;
 				goto out;
 			}
-			
+
 			up(&state->sem);
-			/* No matter how much space left in the buffer, we have to wait until
-			   CSO == ESO/2 or CSO == ESO when address engine interrupts */
+			/* No matter how much space left in the buffer, */ 
+			/* we have to wait until CSO == ESO/2 or CSO == ESO */ 
+			/* when address engine interrupts */
 			tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
 			tmo >>= sample_shift[dmabuf->fmt];
 			/* There are two situations when sleep_on_timeout returns, one is when
@@ -1835,21 +1900,21 @@ static ssize_t trident_read(struct file 
 			   NOTHING we can do to prevent it. */
 			if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
 				TRDBG(KERN_ERR "trident: recording schedule timeout, "
-				      "dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
-				      dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
+				      "dmasz %u fragsz %u count %i hwptr %u swptr %u\n", 
+				      dmabuf->dmasize, dmabuf->fragsize, dmabuf->count, 
 				      dmabuf->hwptr, dmabuf->swptr);
 
 				/* a buffer overrun, we delay the recovery until next time the
 				   while loop begin and we REALLY have space to record */
 			}
 			if (signal_pending(current)) {
-				if(!ret) ret = -ERESTARTSYS;
+				if (!ret)
+					ret = -ERESTARTSYS;
 				goto out;
 			}
 			down(&state->sem);
-			if(dmabuf->mapped)
-			{
-				if(!ret)
+			if (dmabuf->mapped) {
+				if (!ret)
 					ret = -ENXIO;
 				goto out;
 			}
@@ -1857,7 +1922,8 @@ static ssize_t trident_read(struct file 
 		}
 
 		if (copy_to_user(buffer, dmabuf->rawbuf + swptr, cnt)) {
-			if (!ret) ret = -EFAULT;
+			if (!ret)
+				ret = -EFAULT;
 			goto out;
 		}
 
@@ -1881,7 +1947,8 @@ out:
 /* in this loop, dmabuf.count signifies the amount of data that is waiting to be dma to
    the soundcard.  it is drained by the dma machine and filled by this loop. */
 
-static ssize_t trident_write(struct file *file, const char *buffer, size_t count, loff_t *ppos)
+static ssize_t
+trident_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -1897,34 +1964,32 @@ static ssize_t trident_write(struct file
 	VALIDATE_STATE(state);
 	if (ppos != &file->f_pos)
 		return -ESPIPE;
-	
+
 	/*
-	 *	Guard against an mmap or ioctl while writing
-	 */	
-	 
+	 *      Guard against an mmap or ioctl while writing
+	 */
+
 	down(&state->sem);
-	
-	if (dmabuf->mapped)
-	{
+
+	if (dmabuf->mapped) {
 		ret = -ENXIO;
 		goto out;
 	}
 	if (!dmabuf->ready && (ret = prog_dmabuf(state, 0)))
 		goto out;
 
-	if (!access_ok(VERIFY_READ, buffer, count))
-	{
-		ret= -EFAULT;
+	if (!access_ok(VERIFY_READ, buffer, count)) {
+		ret = -EFAULT;
 		goto out;
 	}
-	
+
 	ret = 0;
 
 	while (count > 0) {
 		spin_lock_irqsave(&state->card->lock, flags);
 		if (dmabuf->count < 0) {
-			/* buffer underrun, we are recovering from sleep_on_timeout,
-			   resync hwptr and swptr */
+			/* buffer underrun, we are recovering from */ 
+			/* sleep_on_timeout, resync hwptr and swptr */
 			dmabuf->count = 0;
 			dmabuf->swptr = dmabuf->hwptr;
 		}
@@ -1938,45 +2003,52 @@ static ssize_t trident_write(struct file
 			cnt = count;
 		if (cnt <= 0) {
 			unsigned long tmo;
-			/* buffer is full, start the dma machine and wait for data to be
-			   played */
+			/* buffer is full, start the dma machine and */ 
+			/* wait for data to be played */
 			start_dac(state);
 			if (file->f_flags & O_NONBLOCK) {
-				if (!ret) ret = -EAGAIN;
+				if (!ret)
+					ret = -EAGAIN;
 				goto out;
 			}
-			/* No matter how much data left in the buffer, we have to wait until
-			   CSO == ESO/2 or CSO == ESO when address engine interrupts */
+			/* No matter how much data left in the buffer, */ 
+			/* we have to wait until CSO == ESO/2 or CSO == ESO */ 
+			/* when address engine interrupts */
 			lock_set_fmt(state);
 			tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
 			tmo >>= sample_shift[dmabuf->fmt];
 			unlock_set_fmt(state);
 			up(&state->sem);
-			
-			/* There are two situations when sleep_on_timeout returns, one is when
-			   the interrupt is serviced correctly and the process is waked up by
-			   ISR ON TIME. Another is when timeout is expired, which means that
-			   either interrupt is NOT serviced correctly (pending interrupt) or it
-			   is TOO LATE for the process to be scheduled to run (scheduler latency)
-			   which results in a (potential) buffer underrun. And worse, there is
-			   NOTHING we can do to prevent it. */
+
+			/* There are two situations when sleep_on_timeout */ 
+			/* returns, one is when the interrupt is serviced */ 
+			/* correctly and the process is waked up by ISR */ 
+			/* ON TIME. Another is when timeout is expired, which */ 
+			/* means that either interrupt is NOT serviced */ 
+			/* correctly (pending interrupt) or it is TOO LATE */ 
+			/* for the process to be scheduled to run */ 
+			/* (scheduler latency) which results in a (potential) */ 
+			/* buffer underrun. And worse, there is NOTHING we */ 
+			/* can do to prevent it. */
 			if (!interruptible_sleep_on_timeout(&dmabuf->wait, tmo)) {
-				TRDBG(KERN_ERR "trident: playback schedule timeout, "
-				      "dmasz %u fragsz %u count %i hwptr %u swptr %u\n",
-				      dmabuf->dmasize, dmabuf->fragsize, dmabuf->count,
+				TRDBG(KERN_ERR "trident: playback schedule "
+				      "timeout, dmasz %u fragsz %u count %i "
+				      "hwptr %u swptr %u\n", dmabuf->dmasize, 
+				      dmabuf->fragsize, dmabuf->count, 
 				      dmabuf->hwptr, dmabuf->swptr);
 
-				/* a buffer underrun, we delay the recovery until next time the
-				   while loop begin and we REALLY have data to play */
+				/* a buffer underrun, we delay the recovery */ 
+				/* until next time the while loop begin and */ 
+				/* we REALLY have data to play */
 			}
 			if (signal_pending(current)) {
-				if (!ret) ret = -ERESTARTSYS;
+				if (!ret)
+					ret = -ERESTARTSYS;
 				goto out;
 			}
 			down(&state->sem);
-			if(dmabuf->mapped)
-			{
-				if(!ret)
+			if (dmabuf->mapped) {
+				if (!ret)
 					ret = -ENXIO;
 				goto out;
 			}
@@ -1986,8 +2058,9 @@ static ssize_t trident_write(struct file
 		if (state->chans_num == 6) {
 			copy_count = 0;
 			state_cnt = 0;
-			if (ali_write_5_1(state, buffer, cnt, &copy_count, &state_cnt) == -EFAULT) {
-				if (state_cnt){
+			if (ali_write_5_1(state, buffer, cnt, &copy_count, 
+					  &state_cnt) == -EFAULT) {
+				if (state_cnt) {
 					swptr = (swptr + state_cnt) % dmabuf->dmasize;
 					spin_lock_irqsave(&state->card->lock, flags);
 					dmabuf->swptr = swptr;
@@ -1996,23 +2069,25 @@ static ssize_t trident_write(struct file
 					spin_unlock_irqrestore(&state->card->lock, flags);
 				}
 				ret += copy_count;
-				if (!ret) ret = -EFAULT;
+				if (!ret)
+					ret = -EFAULT;
 				unlock_set_fmt(state);
 				goto out;
 			}
-		}
-		else {
-			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, cnt)) {
-				if (!ret) ret = -EFAULT;
+		} else {
+			if (copy_from_user(dmabuf->rawbuf + swptr, 
+					   buffer, cnt)) {
+				if (!ret)
+					ret = -EFAULT;
 				unlock_set_fmt(state);
 				goto out;
 			}
 			state_cnt = cnt;
 		}
 		unlock_set_fmt(state);
-		
-		swptr = (swptr + state_cnt) % dmabuf->dmasize;		
-		
+
+		swptr = (swptr + state_cnt) % dmabuf->dmasize;
+
 		spin_lock_irqsave(&state->card->lock, flags);
 		dmabuf->swptr = swptr;
 		dmabuf->count += state_cnt;
@@ -2020,7 +2095,7 @@ static ssize_t trident_write(struct file
 		spin_unlock_irqrestore(&state->card->lock, flags);
 
 		count -= cnt;
-		buffer += cnt;	
+		buffer += cnt;
 		ret += cnt;
 		start_dac(state);
 	}
@@ -2029,9 +2104,9 @@ out:
 	return ret;
 }
 
-
 /* No kernel lock - we have our own spinlock */
-static unsigned int trident_poll(struct file *file, struct poll_table_struct *wait)
+static unsigned int
+trident_poll(struct file *file, struct poll_table_struct *wait)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -2041,23 +2116,21 @@ static unsigned int trident_poll(struct 
 	VALIDATE_STATE(state);
 
 	/*
-	 *	Guard against a parallel poll and write causing multiple
-	 *	prog_dmabuf events
+	 *      Guard against a parallel poll and write causing multiple
+	 *      prog_dmabuf events
 	 */
-	 
+
 	down(&state->sem);
 
 	if (file->f_mode & FMODE_WRITE) {
-		if (!dmabuf->ready && prog_dmabuf(state, 0))
-		{
+		if (!dmabuf->ready && prog_dmabuf(state, 0)) {
 			up(&state->sem);
 			return 0;
 		}
 		poll_wait(file, &dmabuf->wait, wait);
 	}
 	if (file->f_mode & FMODE_READ) {
-		if (!dmabuf->ready && prog_dmabuf(state, 1))
-		{
+		if (!dmabuf->ready && prog_dmabuf(state, 1)) {
 			up(&state->sem);
 			return 0;
 		}
@@ -2065,19 +2138,20 @@ static unsigned int trident_poll(struct 
 	}
 
 	up(&state->sem);
-	
+
 	spin_lock_irqsave(&state->card->lock, flags);
 	trident_update_ptr(state);
 	if (file->f_mode & FMODE_READ) {
-		if (dmabuf->count >= (signed)dmabuf->fragsize)
+		if (dmabuf->count >= (signed) dmabuf->fragsize)
 			mask |= POLLIN | POLLRDNORM;
 	}
 	if (file->f_mode & FMODE_WRITE) {
 		if (dmabuf->mapped) {
-			if (dmabuf->count >= (signed)dmabuf->fragsize)
+			if (dmabuf->count >= (signed) dmabuf->fragsize)
 				mask |= POLLOUT | POLLWRNORM;
 		} else {
-			if ((signed)dmabuf->dmasize >= dmabuf->count + (signed)dmabuf->fragsize)
+			if ((signed) dmabuf->dmasize >= dmabuf->count + 
+			    (signed) dmabuf->fragsize)
 				mask |= POLLOUT | POLLWRNORM;
 		}
 	}
@@ -2086,7 +2160,8 @@ static unsigned int trident_poll(struct 
 	return mask;
 }
 
-static int trident_mmap(struct file *file, struct vm_area_struct *vma)
+static int
+trident_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -2095,14 +2170,14 @@ static int trident_mmap(struct file *fil
 
 	VALIDATE_STATE(state);
 	lock_kernel();
-	
+
 	/*
-	 *	Lock against poll read write or mmap creating buffers. Also lock
-	 *	a read or write against an mmap.
+	 *      Lock against poll read write or mmap creating buffers. Also lock
+	 *      a read or write against an mmap.
 	 */
-	 
+
 	down(&state->sem);
-	
+
 	if (vma->vm_flags & VM_WRITE) {
 		if ((ret = prog_dmabuf(state, 0)) != 0)
 			goto out;
@@ -2119,7 +2194,7 @@ static int trident_mmap(struct file *fil
 	if (size > (PAGE_SIZE << dmabuf->buforder))
 		goto out;
 	ret = -EAGAIN;
-	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf),
+	if (remap_page_range(vma, vma->vm_start, virt_to_phys(dmabuf->rawbuf), 
 			     size, vma->vm_page_prot))
 		goto out;
 	dmabuf->mapped = 1;
@@ -2130,7 +2205,9 @@ out:
 	return ret;
 }
 
-static int trident_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+static int
+trident_ioctl(struct inode *inode, struct file *file, 
+	      unsigned int cmd, unsigned long arg)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct dmabuf *dmabuf = &state->dmabuf;
@@ -2142,17 +2219,16 @@ static int trident_ioctl(struct inode *i
 	struct trident_card *card = state->card;
 
 	VALIDATE_STATE(state);
-	mapped = ((file->f_mode & FMODE_WRITE) && dmabuf->mapped) ||
+	mapped = ((file->f_mode & FMODE_WRITE) && dmabuf->mapped) || 
 		((file->f_mode & FMODE_READ) && dmabuf->mapped);
-	TRDBG("trident: trident_ioctl, command = %2d, arg = 0x%08x\n",
-	      _IOC_NR(cmd), arg ? *(int *)arg : 0);
+	TRDBG("trident: trident_ioctl, command = %2d, arg = 0x%08x\n", 
+	      _IOC_NR(cmd), arg ? *(int *) arg : 0);
 
-	switch (cmd) 
-	{
+	switch (cmd) {
 	case OSS_GETVERSION:
-		ret = put_user(SOUND_VERSION, (int *)arg);
+		ret = put_user(SOUND_VERSION, (int *) arg);
 		break;
-		
+
 	case SNDCTL_DSP_RESET:
 		/* FIXME: spin_lock ? */
 		if (file->f_mode & FMODE_WRITE) {
@@ -2176,9 +2252,8 @@ static int trident_ioctl(struct inode *i
 			ret = drain_dac(state, file->f_flags & O_NONBLOCK);
 		break;
 
-	case SNDCTL_DSP_SPEED: /* set smaple rate */
-		if (get_user(val, (int *)arg))
-		{
+	case SNDCTL_DSP_SPEED:	/* set smaple rate */
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2198,12 +2273,11 @@ static int trident_ioctl(struct inode *i
 				spin_unlock_irqrestore(&state->card->lock, flags);
 			}
 		}
-		ret = put_user(dmabuf->rate, (int *)arg);
+		ret = put_user(dmabuf->rate, (int *) arg);
 		break;
 
-	case SNDCTL_DSP_STEREO: /* set stereo or mono channel */
-		if (get_user(val, (int *)arg))
-		{
+	case SNDCTL_DSP_STEREO:	/* set stereo or mono channel */
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2232,24 +2306,24 @@ static int trident_ioctl(struct inode *i
 			if ((val = prog_dmabuf(state, 0)))
 				ret = val;
 			else
-				ret = put_user(dmabuf->fragsize, (int *)arg);
+				ret = put_user(dmabuf->fragsize, (int *) arg);
 			break;
 		}
 		if (file->f_mode & FMODE_READ) {
 			if ((val = prog_dmabuf(state, 1)))
 				ret = val;
 			else
-				ret = put_user(dmabuf->fragsize, (int *)arg);
+				ret = put_user(dmabuf->fragsize, (int *) arg);
 			break;
 		}
 
-	case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format*/
-		ret = put_user(AFMT_S16_LE|AFMT_U16_LE|AFMT_S8|AFMT_U8, (int *)arg);
+	case SNDCTL_DSP_GETFMTS: /* Returns a mask of supported sample format */
+		ret = put_user(AFMT_S16_LE | AFMT_U16_LE | AFMT_S8 | 
+			       AFMT_U8, (int *) arg);
 		break;
 
-	case SNDCTL_DSP_SETFMT: /* Select sample format */
-		if (get_user(val, (int *)arg))
-		{
+	case SNDCTL_DSP_SETFMT:	/* Select sample format */
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2273,13 +2347,12 @@ static int trident_ioctl(struct inode *i
 			}
 		}
 		unlock_set_fmt(state);
-		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ?
-				AFMT_S16_LE : AFMT_U8, (int *)arg);
+		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE : 
+			       AFMT_U8, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_CHANNELS:
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2288,24 +2361,22 @@ static int trident_ioctl(struct inode *i
 			if (file->f_mode & FMODE_WRITE) {
 				stop_dac(state);
 				dmabuf->ready = 0;
-								
+
 				//prevent from memory leak
 				if ((state->chans_num > 2) && (state->chans_num != val)) {
 					ali_free_other_states_resources(state);
 					state->chans_num = 1;
 				}
-				
-				if (val >= 2)
-				{
+
+				if (val >= 2) {
 
 					dmabuf->fmt |= TRIDENT_FMT_STEREO;
 					if ((val == 6) && (state->card->pci_id == PCI_DEVICE_ID_ALI_5451)) {
-
-						if( card->rec_channel_use_count > 0 )
-						{
-							printk(KERN_ERR "trident: Record is working on the card!\n");
+						if (card->rec_channel_use_count > 0) {
+							printk(KERN_ERR "trident: Record is "
+							       "working on the card!\n");
 							ret = -EBUSY;
-							unlock_set_fmt(state); 
+							unlock_set_fmt(state);
 							break;
 						}
 
@@ -2321,12 +2392,11 @@ static int trident_ioctl(struct inode *i
 							unlock_set_fmt(state);
 							break;
 						}
-						state->card->multi_channel_use_count ++;
+						state->card->multi_channel_use_count++;
 						up(&state->card->open_sem);
-					}
-					else val = 2;	/*yield to 2-channels*/
-				}
-				else
+					} else
+						val = 2;	/*yield to 2-channels */
+				} else
 					dmabuf->fmt &= ~TRIDENT_FMT_STEREO;
 				state->chans_num = val;
 			}
@@ -2334,17 +2404,17 @@ static int trident_ioctl(struct inode *i
 				stop_adc(state);
 				dmabuf->ready = 0;
 				if (val >= 2) {
-					if (!((file->f_mode & FMODE_WRITE) && (val == 6)))
+					if (!((file->f_mode & FMODE_WRITE) && 
+					      (val == 6)))
 						val = 2;
 					dmabuf->fmt |= TRIDENT_FMT_STEREO;
-				}
-				else
+				} else
 					dmabuf->fmt &= ~TRIDENT_FMT_STEREO;
 				state->chans_num = val;
 			}
 			unlock_set_fmt(state);
 		}
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_POST:
@@ -2352,18 +2422,15 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_SUBDIVIDE:
-		if (dmabuf->subdivision)
-		{
+		if (dmabuf->subdivision) {
 			ret = -EINVAL;
 			break;
 		}
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
-		if (val != 1 && val != 2 && val != 4)
-		{
+		if (val != 1 && val != 2 && val != 4) {
 			ret = -EINVAL;
 			break;
 		}
@@ -2371,8 +2438,7 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_SETFRAGMENT:
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2389,13 +2455,11 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETOSPACE:
-		if (!(file->f_mode & FMODE_WRITE))
-		{
+		if (!(file->f_mode & FMODE_WRITE)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0)
-		{ 
+		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0) {
 			ret = val;
 			break;
 		}
@@ -2406,17 +2470,16 @@ static int trident_ioctl(struct inode *i
 		abinfo.fragstotal = dmabuf->numfrag;
 		abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
+		ret = copy_to_user((void *) arg, &abinfo, sizeof (abinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_GETISPACE:
-		if (!(file->f_mode & FMODE_READ))
-		{
+		if (!(file->f_mode & FMODE_READ)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 1)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf(state, 1)) != 0) {
 			ret = val;
 			break;
 		}
@@ -2427,7 +2490,8 @@ static int trident_ioctl(struct inode *i
 		abinfo.fragstotal = dmabuf->numfrag;
 		abinfo.fragments = abinfo.bytes >> dmabuf->fragshift;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
+		ret = copy_to_user((void *) arg, &abinfo, sizeof (abinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_NONBLOCK:
@@ -2435,8 +2499,8 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETCAPS:
-		ret = put_user(DSP_CAP_REALTIME|DSP_CAP_TRIGGER|DSP_CAP_MMAP|DSP_CAP_BIND,
-			    (int *)arg);
+		ret = put_user(DSP_CAP_REALTIME | DSP_CAP_TRIGGER | 
+			       DSP_CAP_MMAP | DSP_CAP_BIND, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_GETTRIGGER:
@@ -2445,18 +2509,18 @@ static int trident_ioctl(struct inode *i
 			val |= PCM_ENABLE_INPUT;
 		if ((file->f_mode & FMODE_WRITE) && dmabuf->enable)
 			val |= PCM_ENABLE_OUTPUT;
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_SETTRIGGER:
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
 		if (file->f_mode & FMODE_READ) {
 			if (val & PCM_ENABLE_INPUT) {
-				if (!dmabuf->ready && (ret = prog_dmabuf(state, 1)))
+				if (!dmabuf->ready && 
+				    (ret = prog_dmabuf(state, 1)))
 					break;
 				start_adc(state);
 			} else
@@ -2464,7 +2528,8 @@ static int trident_ioctl(struct inode *i
 		}
 		if (file->f_mode & FMODE_WRITE) {
 			if (val & PCM_ENABLE_OUTPUT) {
-				if (!dmabuf->ready && (ret = prog_dmabuf(state, 0)))
+				if (!dmabuf->ready && 
+				    (ret = prog_dmabuf(state, 0)))
 					break;
 				start_dac(state);
 			} else
@@ -2473,13 +2538,12 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETIPTR:
-		if (!(file->f_mode & FMODE_READ))
-		{
+		if (!(file->f_mode & FMODE_READ)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 1)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf(state, 1)) 
+		    != 0) {
 			ret = val;
 			break;
 		}
@@ -2489,32 +2553,33 @@ static int trident_ioctl(struct inode *i
 		cinfo.blocks = dmabuf->count >> dmabuf->fragshift;
 		cinfo.ptr = dmabuf->hwptr;
 		if (dmabuf->mapped)
-			dmabuf->count &= dmabuf->fragsize-1;
+			dmabuf->count &= dmabuf->fragsize - 1;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &cinfo, sizeof(cinfo))?-EFAULT:0;
+		ret = copy_to_user((void *) arg, &cinfo, sizeof (cinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_GETOPTR:
-		if (!(file->f_mode & FMODE_WRITE))
-		{
+		if (!(file->f_mode & FMODE_WRITE)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) 
+		    != 0) {
 			ret = val;
 			break;
 		}
-		
+
 		spin_lock_irqsave(&state->card->lock, flags);
 		trident_update_ptr(state);
 		cinfo.bytes = dmabuf->total_bytes;
 		cinfo.blocks = dmabuf->count >> dmabuf->fragshift;
 		cinfo.ptr = dmabuf->hwptr;
 		if (dmabuf->mapped)
-			dmabuf->count &= dmabuf->fragsize-1;
+			dmabuf->count &= dmabuf->fragsize - 1;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = copy_to_user((void *)arg, &cinfo, sizeof(cinfo))?-EFAULT:0;
+		ret = copy_to_user((void *) arg, &cinfo, sizeof (cinfo)) ? 
+			-EFAULT : 0;
 		break;
 
 	case SNDCTL_DSP_SETDUPLEX:
@@ -2522,13 +2587,11 @@ static int trident_ioctl(struct inode *i
 		break;
 
 	case SNDCTL_DSP_GETODELAY:
-		if (!(file->f_mode & FMODE_WRITE))
-		{
+		if (!(file->f_mode & FMODE_WRITE)) {
 			ret = -EINVAL;
 			break;
 		}
-		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0)
-		{
+		if (!dmabuf->ready && (val = prog_dmabuf(state, 0)) != 0) {
 			ret = val;
 			break;
 		}
@@ -2536,37 +2599,35 @@ static int trident_ioctl(struct inode *i
 		trident_update_ptr(state);
 		val = dmabuf->count;
 		spin_unlock_irqrestore(&state->card->lock, flags);
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SOUND_PCM_READ_RATE:
-		ret = put_user(dmabuf->rate, (int *)arg);
+		ret = put_user(dmabuf->rate, (int *) arg);
 		break;
 
 	case SOUND_PCM_READ_CHANNELS:
-		ret = put_user((dmabuf->fmt & TRIDENT_FMT_STEREO) ? 2 : 1,
-				(int *)arg);
+		ret = put_user((dmabuf->fmt & TRIDENT_FMT_STEREO) ? 2 : 1, 
+			       (int *) arg);
 		break;
 
 	case SOUND_PCM_READ_BITS:
-		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ?
-				AFMT_S16_LE : AFMT_U8, (int *)arg);
+		ret = put_user((dmabuf->fmt & TRIDENT_FMT_16BIT) ? AFMT_S16_LE : 
+			       AFMT_U8, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_GETCHANNELMASK:
-		ret = put_user(DSP_BIND_FRONT|DSP_BIND_SURR|DSP_BIND_CENTER_LFE,
-				(int *)arg);
+		ret = put_user(DSP_BIND_FRONT | DSP_BIND_SURR | 
+			       DSP_BIND_CENTER_LFE,  (int *) arg);
 		break;
 
 	case SNDCTL_DSP_BIND_CHANNEL:
-		if (state->card->pci_id != PCI_DEVICE_ID_SI_7018)
-		{
+		if (state->card->pci_id != PCI_DEVICE_ID_SI_7018) {
 			ret = -EINVAL;
 			break;
 		}
 
-		if (get_user(val, (int *)arg))
-		{
+		if (get_user(val, (int *) arg)) {
 			ret = -EFAULT;
 			break;
 		}
@@ -2576,12 +2637,14 @@ static int trident_ioctl(struct inode *i
 		} else {
 			dmabuf->ready = 0;
 			if (file->f_mode & FMODE_READ)
-				dmabuf->channel->attribute = (CHANNEL_REC|SRC_ENABLE);
+				dmabuf->channel->attribute = (CHANNEL_REC | 
+							      SRC_ENABLE);
 			if (file->f_mode & FMODE_WRITE)
-				dmabuf->channel->attribute = (CHANNEL_SPC_PB|SRC_ENABLE);
+				dmabuf->channel->attribute = (CHANNEL_SPC_PB | 
+							      SRC_ENABLE);
 			dmabuf->channel->attribute |= mask2attr[ffs(val)];
 		}
-		ret = put_user(val, (int *)arg);
+		ret = put_user(val, (int *) arg);
 		break;
 
 	case SNDCTL_DSP_MAPINBUF:
@@ -2592,23 +2655,23 @@ static int trident_ioctl(struct inode *i
 	default:
 		ret = -EINVAL;
 		break;
-		
+
 	}
 	return ret;
 }
 
-static int trident_open(struct inode *inode, struct file *file)
+static int
+trident_open(struct inode *inode, struct file *file)
 {
 	int i = 0;
 	int minor = iminor(inode);
 	struct trident_card *card = devs;
 	struct trident_state *state = NULL;
 	struct dmabuf *dmabuf = NULL;
-	
+
 	/* Added by Matt Wu 01-05-2001 */
-	if(file->f_mode & FMODE_READ)
-	{
-		if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (file->f_mode & FMODE_READ) {
+		if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 			if (card->multi_channel_use_count > 0)
 				return -EBUSY;
 		}
@@ -2617,11 +2680,9 @@ static int trident_open(struct inode *in
 	/* find an available virtual channel (instance of /dev/dsp) */
 	while (card != NULL) {
 		down(&card->open_sem);
-		if(file->f_mode & FMODE_READ)
-		{
+		if (file->f_mode & FMODE_READ) {
 			/* Skip opens on cards that are in 6 channel mode */
-			if (card->multi_channel_use_count > 0)
-			{
+			if (card->multi_channel_use_count > 0) {
 				up(&card->open_sem);
 				card = card->next;
 				continue;
@@ -2630,11 +2691,11 @@ static int trident_open(struct inode *in
 		for (i = 0; i < NR_HW_CH; i++) {
 			if (card->states[i] == NULL) {
 				state = card->states[i] = (struct trident_state *)
-					kmalloc(sizeof(struct trident_state), GFP_KERNEL);
+				    kmalloc(sizeof (struct trident_state), GFP_KERNEL);
 				if (state == NULL) {
 					return -ENOMEM;
 				}
-				memset(state, 0, sizeof(struct trident_state));
+				memset(state, 0, sizeof (struct trident_state));
 				init_MUTEX(&state->sem);
 				dmabuf = &state->dmabuf;
 				goto found_virt;
@@ -2647,15 +2708,15 @@ static int trident_open(struct inode *in
 	if (!state) {
 		return -ENODEV;
 	}
- found_virt:
+      found_virt:
 	/* found a free virtual channel, allocate hardware channels */
-	if(file->f_mode & FMODE_READ)
+	if (file->f_mode & FMODE_READ)
 		dmabuf->channel = card->alloc_rec_pcm_channel(card);
 	else
 		dmabuf->channel = card->alloc_pcm_channel(card);
-		
+
 	if (dmabuf->channel == NULL) {
-		kfree (card->states[i]);
+		kfree(card->states[i]);
 		card->states[i] = NULL;
 		return -ENODEV;
 	}
@@ -2667,16 +2728,16 @@ static int trident_open(struct inode *in
 	init_waitqueue_head(&dmabuf->wait);
 	file->private_data = state;
 
-	/* set default sample format. According to OSS Programmer's Guide  /dev/dsp
-	   should be default to unsigned 8-bits, mono, with sample rate 8kHz and
-	   /dev/dspW will accept 16-bits sample */
+	/* set default sample format. According to OSS Programmer's */ 
+	/* Guide  /dev/dsp should be default to unsigned 8-bits, mono, */ 
+	/* with sample rate 8kHz and /dev/dspW will accept 16-bits sample */
 	if (file->f_mode & FMODE_WRITE) {
 		dmabuf->fmt &= ~TRIDENT_FMT_MASK;
 		if ((minor & 0x0f) == SND_DEV_DSP16)
 			dmabuf->fmt |= TRIDENT_FMT_16BIT;
 		dmabuf->ossfragshift = 0;
-		dmabuf->ossmaxfrags  = 0;
-		dmabuf->subdivision  = 0;
+		dmabuf->ossmaxfrags = 0;
+		dmabuf->subdivision = 0;
 		if (card->pci_id == PCI_DEVICE_ID_SI_7018) {
 			/* set default channel attribute to normal playback */
 			dmabuf->channel->attribute = CHANNEL_PB;
@@ -2685,37 +2746,38 @@ static int trident_open(struct inode *in
 	}
 
 	if (file->f_mode & FMODE_READ) {
-		/* FIXME: Trident 4d can only record in signed 16-bits stereo, 48kHz sample,
-		   to be dealed with in trident_set_adc_rate() ?? */
+		/* FIXME: Trident 4d can only record in signed 16-bits stereo, */ 
+		/* 48kHz sample, to be dealed with in trident_set_adc_rate() ?? */
 		dmabuf->fmt &= ~TRIDENT_FMT_MASK;
 		if ((minor & 0x0f) == SND_DEV_DSP16)
 			dmabuf->fmt |= TRIDENT_FMT_16BIT;
 		dmabuf->ossfragshift = 0;
-		dmabuf->ossmaxfrags  = 0;
-		dmabuf->subdivision  = 0;
+		dmabuf->ossmaxfrags = 0;
+		dmabuf->subdivision = 0;
 		if (card->pci_id == PCI_DEVICE_ID_SI_7018) {
 			/* set default channel attribute to 0x8a80, record from
-			   PCM L/R FIFO and mono = (left + right + 1)/2*/
-			dmabuf->channel->attribute =
-				(CHANNEL_REC|PCM_LR|MONO_MIX);
+			   PCM L/R FIFO and mono = (left + right + 1)/2 */
+			dmabuf->channel->attribute = (CHANNEL_REC | PCM_LR | 
+						      MONO_MIX);
 		}
 		trident_set_adc_rate(state, 8000);
-	
+
 		/* Added by Matt Wu 01-05-2001 */
-		if(card->pci_id == PCI_DEVICE_ID_ALI_5451)
-			card->rec_channel_use_count ++;
+		if (card->pci_id == PCI_DEVICE_ID_ALI_5451)
+			card->rec_channel_use_count++;
 	}
 
 	state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
 	up(&card->open_sem);
 
 	TRDBG("trident: open virtual channel %d, hard channel %d\n", 
-              state->virt, dmabuf->channel->num);
+	      state->virt, dmabuf->channel->num);
 
 	return 0;
 }
 
-static int trident_release(struct inode *inode, struct file *file)
+static int
+trident_release(struct inode *inode, struct file *file)
 {
 	struct trident_state *state = (struct trident_state *)file->private_data;
 	struct trident_card *card;
@@ -2760,7 +2822,7 @@ static int trident_release(struct inode 
 
 		/* Added by Matt Wu */
 		if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-			if( card->rec_channel_use_count-- < 0 )
+			if (card->rec_channel_use_count-- < 0)
 				card->rec_channel_use_count = 0;
 		}
 	}
@@ -2775,32 +2837,32 @@ static int trident_release(struct inode 
 	return 0;
 }
 
-static /*const*/ struct file_operations trident_audio_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.read		= trident_read,
-	.write		= trident_write,
-	.poll		= trident_poll,
-	.ioctl		= trident_ioctl,
-	.mmap		= trident_mmap,
-	.open		= trident_open,
-	.release	= trident_release,
+static /*const */ struct file_operations trident_audio_fops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.read = trident_read,
+	.write = trident_write,
+	.poll = trident_poll,
+	.ioctl = trident_ioctl,
+	.mmap = trident_mmap,
+	.open = trident_open,
+	.release = trident_release,
 };
 
 /* trident specific AC97 functions */
 /* Write AC97 codec registers */
-static void trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val)
+static void
+trident_ac97_set(struct ac97_codec *codec, u8 reg, u16 val)
 {
 	struct trident_card *card = (struct trident_card *)codec->private_data;
 	unsigned int address, mask, busy;
-	unsigned short count  = 0xffff;
+	unsigned short count = 0xffff;
 	unsigned long flags;
 	u32 data;
 
 	data = ((u32) val) << 16;
 
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	default:
 	case PCI_DEVICE_ID_SI_7018:
 		address = SI_AC97_WRITE;
@@ -2834,7 +2896,6 @@ static void trident_ac97_set(struct ac97
 			break;
 	} while (count--);
 
-
 	data |= (mask | (reg & AC97_REG_ADDR));
 
 	if (count == 0) {
@@ -2848,7 +2909,8 @@ static void trident_ac97_set(struct ac97
 }
 
 /* Read AC97 codec registers */
-static u16 trident_ac97_get(struct ac97_codec *codec, u8 reg)
+static u16
+trident_ac97_get(struct ac97_codec *codec, u8 reg)
 {
 	struct trident_card *card = (struct trident_card *)codec->private_data;
 	unsigned int address, mask, busy;
@@ -2856,8 +2918,7 @@ static u16 trident_ac97_get(struct ac97_
 	unsigned long flags;
 	u32 data;
 
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	default:
 	case PCI_DEVICE_ID_SI_7018:
 		address = SI_AC97_READ;
@@ -2905,31 +2966,31 @@ static u16 trident_ac97_get(struct ac97_
 }
 
 /* rewrite ac97 read and write mixer register by hulei for ALI*/
-static int acquirecodecaccess(struct trident_card *card)
+static int
+acquirecodecaccess(struct trident_card *card)
 {
-	u16 wsemamask=0x6000; /* bit 14..13 */
+	u16 wsemamask = 0x6000;	/* bit 14..13 */
 	u16 wsemabits;
-        u16 wcontrol ;
+	u16 wcontrol;
 	int block = 0;
 	int ncount = 25;
 	while (1) {
-		wcontrol = inw(TRID_REG(card,  ALI_AC97_WRITE));
+		wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
 		wsemabits = wcontrol & wsemamask;
-		
-		if (wsemabits==0x4000)
-			return 1; /* 0x4000 is audio ,then success */
+
+		if (wsemabits == 0x4000)
+			return 1;	/* 0x4000 is audio ,then success */
 		if (ncount-- < 0)
 			break;
-		if (wsemabits == 0)
-		{
-		unlock:
-			outl(((u32)(wcontrol & 0x1eff)|0x00004000), TRID_REG(card, ALI_AC97_WRITE));
+		if (wsemabits == 0) {
+		      unlock:
+			outl(((u32) (wcontrol & 0x1eff) | 0x00004000), 
+			     TRID_REG(card, ALI_AC97_WRITE));
 			continue;
 		}
 		udelay(20);
 	}
-	if(!block)
-	{
+	if (!block) {
 		TRDBG("accesscodecsemaphore: try unlock\n");
 		block = 1;
 		goto unlock;
@@ -2937,24 +2998,26 @@ static int acquirecodecaccess(struct tri
 	return 0;
 }
 
-static void releasecodecaccess(struct trident_card *card)
-{ 
+static void
+releasecodecaccess(struct trident_card *card)
+{
 	unsigned long wcontrol;
-	wcontrol = inl(TRID_REG(card,  ALI_AC97_WRITE));
+	wcontrol = inl(TRID_REG(card, ALI_AC97_WRITE));
 	outl((wcontrol & 0xffff1eff), TRID_REG(card, ALI_AC97_WRITE));
 }
 
-static int waitforstimertick(struct trident_card *card)
+static int
+waitforstimertick(struct trident_card *card)
 {
 	unsigned long chk1, chk2;
 	unsigned int wcount = 0xffff;
-	chk1 = inl(TRID_REG(card,  ALI_STIMER));
-	
-	while(1) {
-		chk2 = inl(TRID_REG(card,  ALI_STIMER));
-		if( (wcount > 0) && chk1 != chk2)
+	chk1 = inl(TRID_REG(card, ALI_STIMER));
+
+	while (1) {
+		chk2 = inl(TRID_REG(card, ALI_STIMER));
+		if ((wcount > 0) && chk1 != chk2)
 			return 1;
-		if(wcount <= 0)
+		if (wcount <= 0)
 			break;
 		udelay(50);
 	}
@@ -2962,16 +3025,17 @@ static int waitforstimertick(struct trid
 }
 
 /* Read AC97 codec registers for ALi*/
-static u16 ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
+static u16
+ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
 {
 	unsigned int address, mask;
 	unsigned int ncount;
-        unsigned long aud_reg;
+	unsigned long aud_reg;
 	u32 data;
-        u16 wcontrol;
-        unsigned long flags;
+	u16 wcontrol;
+	unsigned long flags;
 
-	if(!card)
+	if (!card)
 		BUG();
 
 	address = ALI_AC97_READ;
@@ -2981,121 +3045,127 @@ static u16 ali_ac97_get(struct trident_c
 	mask = ALI_AC97_READ_ACTION | ALI_AC97_AUDIO_BUSY;
 	if (secondary)
 		mask |= ALI_AC97_SECONDARY;
-    
-    	spin_lock_irqsave(&card->lock, flags);
-    	
+
+	spin_lock_irqsave(&card->lock, flags);
+
 	if (!acquirecodecaccess(card))
 		printk(KERN_ERR "access codec fail\n");
-	
+
 	wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
 	wcontrol &= 0xfe00;
-	wcontrol |= (0x8000|reg);
-	outw(wcontrol,TRID_REG(card,  ALI_AC97_WRITE));
+	wcontrol |= (0x8000 | reg);
+	outw(wcontrol, TRID_REG(card, ALI_AC97_WRITE));
 
 	data = (mask | (reg & AC97_REG_ADDR));
-	
-	if(!waitforstimertick(card)) {
+
+	if (!waitforstimertick(card)) {
 		printk(KERN_ERR "ali_ac97_read: BIT_CLOCK is dead\n");
 		goto releasecodec;
 	}
-	
-	udelay(20);		
-	
-	ncount=10;
-	
-	while(1) {
-		if ((inw(TRID_REG(card,ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) != 0)
+
+	udelay(20);
+
+	ncount = 10;
+
+	while (1) {
+		if ((inw(TRID_REG(card, ALI_AC97_WRITE)) & ALI_AC97_BUSY_READ) 
+		    != 0)
 			break;
-		if(ncount <=0)
+		if (ncount <= 0)
 			break;
-		if(ncount--==1) {
+		if (ncount-- == 1) {
 			TRDBG("ali_ac97_read :try clear busy flag\n");
-			aud_reg = inl(TRID_REG(card,  ALI_AC97_WRITE));
-			outl((aud_reg & 0xffff7fff), TRID_REG(card, ALI_AC97_WRITE));
+			aud_reg = inl(TRID_REG(card, ALI_AC97_WRITE));
+			outl((aud_reg & 0xffff7fff), 
+			     TRID_REG(card, ALI_AC97_WRITE));
 		}
 		udelay(10);
 	}
-	
+
 	data = inl(TRID_REG(card, address));
 
 	spin_unlock_irqrestore(&card->lock, flags);
-	
+
 	return ((u16) (data >> 16));
 
- releasecodec: 
+      releasecodec:
 	releasecodecaccess(card);
 	spin_unlock_irqrestore(&card->lock, flags);
 	printk(KERN_ERR "ali_ac97_read: AC97 CODEC read timed out.\n");
 	return 0;
 }
 
-
 /* Write AC97 codec registers for hulei*/
-static void ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
+static void
+ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)
 {
 	unsigned int address, mask;
 	unsigned int ncount;
 	u32 data;
-        u16 wcontrol;
-        unsigned long flags;
-	
+	u16 wcontrol;
+	unsigned long flags;
+
 	data = ((u32) val) << 16;
-	
-	if(!card)
+
+	if (!card)
 		BUG();
-	
+
 	address = ALI_AC97_WRITE;
 	mask = ALI_AC97_WRITE_ACTION | ALI_AC97_AUDIO_BUSY;
 	if (secondary)
 		mask |= ALI_AC97_SECONDARY;
 	if (card->revision == ALI_5451_V02)
 		mask |= ALI_AC97_WRITE_MIXER_REGISTER;
-		
+
 	spin_lock_irqsave(&card->lock, flags);
-        if (!acquirecodecaccess(card))      
+	if (!acquirecodecaccess(card))
 		printk(KERN_ERR "ali_ac97_write: access codec fail\n");
-			
+
 	wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
 	wcontrol &= 0xff00;
-	wcontrol |= (0x8100|reg);/* bit 8=1: (ali1535 )reserved /ali1535+ write */
-	outl(( data |wcontrol), TRID_REG(card,ALI_AC97_WRITE ));
+	wcontrol |= (0x8100 | reg); /* bit 8=1: (ali1535 )reserved/ */ 
+	                            /* ali1535+ write */
+	outl((data | wcontrol), TRID_REG(card, ALI_AC97_WRITE));
 
-        if(!waitforstimertick(card)) {
+	if (!waitforstimertick(card)) {
 		printk(KERN_ERR "BIT_CLOCK is dead\n");
 		goto releasecodec;
 	}
-	
-        ncount = 10;
-	while(1) {
+
+	ncount = 10;
+	while (1) {
 		wcontrol = inw(TRID_REG(card, ALI_AC97_WRITE));
-		if(!(wcontrol & 0x8000))
+		if (!(wcontrol & 0x8000))
 			break;
-		if(ncount <= 0)
+		if (ncount <= 0)
 			break;
-		if(ncount-- == 1) {
+		if (ncount-- == 1) {
 			TRDBG("ali_ac97_set :try clear busy flag!!\n");
-			outw(wcontrol & 0x7fff, TRID_REG(card, ALI_AC97_WRITE));
+			outw(wcontrol & 0x7fff, 
+			     TRID_REG(card, ALI_AC97_WRITE));
 		}
 		udelay(10);
 	}
-	
- releasecodec:
+
+      releasecodec:
 	releasecodecaccess(card);
 	spin_unlock_irqrestore(&card->lock, flags);
 	return;
 }
 
-static void ali_enable_special_channel(struct trident_state *stat)
+static void
+ali_enable_special_channel(struct trident_state *stat)
 {
 	struct trident_card *card = stat->card;
 	unsigned long s_channels;
-	
+
 	s_channels = inl(TRID_REG(card, ALI_GLOBAL_CONTROL));
-	s_channels |= (1<<stat->dmabuf.channel->num);
+	s_channels |= (1 << stat->dmabuf.channel->num);
 	outl(s_channels, TRID_REG(card, ALI_GLOBAL_CONTROL));
 }
 
-static u16 ali_ac97_read(struct ac97_codec *codec, u8 reg)
+static u16
+ali_ac97_read(struct ac97_codec *codec, u8 reg)
 {
 	int id;
 	u16 data;
@@ -3104,25 +3174,26 @@ static u16 ali_ac97_read(struct ac97_cod
 	/* Added by Matt Wu */
 	if (!codec)
 		BUG();
-		
-	card = (struct trident_card *)codec->private_data;
 
-	if(!card->mixer_regs_ready)
+	card = (struct trident_card *) codec->private_data;
+
+	if (!card->mixer_regs_ready)
 		return ali_ac97_get(card, codec->id, reg);
 
 	/*
-	 *	FIXME: need to stop this caching some registers
+	 *      FIXME: need to stop this caching some registers
 	 */
-	if(codec->id)
+	if (codec->id)
 		id = 1;
 	else
 		id = 0;
 
-	data = card->mixer_regs[reg/2][id];
+	data = card->mixer_regs[reg / 2][id];
 	return data;
 }
 
-static void ali_ac97_write(struct ac97_codec *codec, u8 reg, u16 val)
+static void
+ali_ac97_write(struct ac97_codec *codec, u8 reg, u16 val)
 {
 	int id;
 	struct trident_card *card;
@@ -3130,21 +3201,20 @@ static void ali_ac97_write(struct ac97_c
 	/*  Added by Matt Wu */
 	if (!codec)
 		BUG();
-		
-	card = (struct trident_card *)codec->private_data;
 
-	if (!card->mixer_regs_ready)
-	{
+	card = (struct trident_card *) codec->private_data;
+
+	if (!card->mixer_regs_ready) {
 		ali_ac97_set(card, codec->id, reg, val);
 		return;
 	}
 
-	if(codec->id)
+	if (codec->id)
 		id = 1;
 	else
 		id = 0;
 
-	card->mixer_regs[reg/2][id] = val;
+	card->mixer_regs[reg / 2][id] = val;
 	ali_ac97_set(card, codec->id, reg, val);
 }
 
@@ -3153,73 +3223,78 @@ flag:	ALI_SPDIF_OUT_TO_SPDIF_OUT
 	ALI_PCM_TO_SPDIF_OUT
 */
 
-static void ali_setup_spdif_out(struct trident_card *card, int flag)
+static void
+ali_setup_spdif_out(struct trident_card *card, int flag)
 {
 	unsigned long spdif;
 	unsigned char ch;
 
-        char temp;
-        struct pci_dev *pci_dev = NULL;
+	char temp;
+	struct pci_dev *pci_dev = NULL;
 
-        pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
-        if (pci_dev == NULL)
-                return;
-        pci_read_config_byte(pci_dev, 0x61, &temp);
-        temp |= 0x40;
-        pci_write_config_byte(pci_dev, 0x61, temp);
-        pci_read_config_byte(pci_dev, 0x7d, &temp);
-        temp |= 0x01;
-        pci_write_config_byte(pci_dev, 0x7d, temp);
-        pci_read_config_byte(pci_dev, 0x7e, &temp);
-        temp &= (~0x20);
-        temp |= 0x10;
-        pci_write_config_byte(pci_dev, 0x7e, temp);
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
+	if (pci_dev == NULL)
+		return;
+	pci_read_config_byte(pci_dev, 0x61, &temp);
+	temp |= 0x40;
+	pci_write_config_byte(pci_dev, 0x61, temp);
+	pci_read_config_byte(pci_dev, 0x7d, &temp);
+	temp |= 0x01;
+	pci_write_config_byte(pci_dev, 0x7d, temp);
+	pci_read_config_byte(pci_dev, 0x7e, &temp);
+	temp &= (~0x20);
+	temp |= 0x10;
+	pci_write_config_byte(pci_dev, 0x7e, temp);
 
 	ch = inb(TRID_REG(card, ALI_SCTRL));
 	outb(ch | ALI_SPDIF_OUT_ENABLE, TRID_REG(card, ALI_SCTRL));
 	ch = inb(TRID_REG(card, ALI_SPDIF_CTRL));
 	outb(ch & ALI_SPDIF_OUT_CH_STATUS, TRID_REG(card, ALI_SPDIF_CTRL));
-   
+
 	if (flag & ALI_SPDIF_OUT_TO_SPDIF_OUT) {
-  		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
-   		spdif |= ALI_SPDIF_OUT_CH_ENABLE;
-   		spdif &= ALI_SPDIF_OUT_SEL_SPDIF;
-   		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
+		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
+		spdif |= ALI_SPDIF_OUT_CH_ENABLE;
+		spdif &= ALI_SPDIF_OUT_SEL_SPDIF;
+		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
 		spdif = inw(TRID_REG(card, ALI_SPDIF_CS));
 		if (flag & ALI_SPDIF_OUT_NON_PCM)
-   			spdif |= 0x0002;
-		else	spdif &= (~0x0002);
-   		outw(spdif, TRID_REG(card, ALI_SPDIF_CS));
-   	}
-   	else {
-   		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
-   		spdif |= ALI_SPDIF_OUT_SEL_PCM;
-   		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
-   	}
+			spdif |= 0x0002;
+		else
+			spdif &= (~0x0002);
+		outw(spdif, TRID_REG(card, ALI_SPDIF_CS));
+	} else {
+		spdif = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
+		spdif |= ALI_SPDIF_OUT_SEL_PCM;
+		outw(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
+	}
 }
 
-static void ali_disable_special_channel(struct trident_card *card, int ch)
+static void
+ali_disable_special_channel(struct trident_card *card, int ch)
 {
 	unsigned long sc;
-	
+
 	sc = inl(TRID_REG(card, ALI_GLOBAL_CONTROL));
 	sc &= ~(1 << ch);
 	outl(sc, TRID_REG(card, ALI_GLOBAL_CONTROL));
 }
 
-static void ali_disable_spdif_in(struct trident_card *card)
+static void
+ali_disable_spdif_in(struct trident_card *card)
 {
 	unsigned long spdif;
-	
+
 	spdif = inl(TRID_REG(card, ALI_GLOBAL_CONTROL));
 	spdif &= (~ALI_SPDIF_IN_SUPPORT);
 	outl(spdif, TRID_REG(card, ALI_GLOBAL_CONTROL));
-	
-	ali_disable_special_channel(card, ALI_SPDIF_IN_CHANNEL);	
+
+	ali_disable_special_channel(card, ALI_SPDIF_IN_CHANNEL);
 }
 
-static void ali_setup_spdif_in(struct trident_card *card)
-{	
+static void
+ali_setup_spdif_in(struct trident_card *card)
+{
 	unsigned long spdif;
 
 	//Set SPDIF IN Supported
@@ -3242,93 +3317,93 @@ static void ali_setup_spdif_in(struct tr
 */
 }
 
-static void ali_delay(struct trident_card *card,int interval)
+static void
+ali_delay(struct trident_card *card, int interval)
 {
-	unsigned long  begintimer,currenttimer;
+	unsigned long begintimer, currenttimer;
 
-	begintimer   = inl(TRID_REG(card,  ALI_STIMER));
-	currenttimer = inl(TRID_REG(card,  ALI_STIMER));
+	begintimer = inl(TRID_REG(card, ALI_STIMER));
+	currenttimer = inl(TRID_REG(card, ALI_STIMER));
 
 	while (currenttimer < begintimer + interval)
-		currenttimer = inl(TRID_REG(card,  ALI_STIMER));
+		currenttimer = inl(TRID_REG(card, ALI_STIMER));
 }
 
-static void ali_detect_spdif_rate(struct trident_card *card)
+static void
+ali_detect_spdif_rate(struct trident_card *card)
 {
-	u16 wval  = 0;
+	u16 wval = 0;
 	u16 count = 0;
-	u8  bval = 0, R1 = 0, R2 = 0;
+	u8 bval = 0, R1 = 0, R2 = 0;
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CTRL));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CTRL));
 	bval |= 0x02;
-	outb(bval,TRID_REG(card,ALI_SPDIF_CTRL));
+	outb(bval, TRID_REG(card, ALI_SPDIF_CTRL));
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CTRL + 1));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CTRL + 1));
 	bval |= 0x1F;
-	outb(bval,TRID_REG(card,ALI_SPDIF_CTRL + 1));
+	outb(bval, TRID_REG(card, ALI_SPDIF_CTRL + 1));
 
-	while (((R1 < 0x0B )||(R1 > 0x0E)) && (R1 != 0x12) && count <= 50000)
-	{
-		count ++;
+	while (((R1 < 0x0B) || (R1 > 0x0E)) && (R1 != 0x12) && 
+	       count <= 50000) {
+		count++;
 
 		ali_delay(card, 6);
 
-		bval = inb(TRID_REG(card,ALI_SPDIF_CTRL + 1));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CTRL + 1));
 		R1 = bval & 0x1F;
 	}
 
-	if (count > 50000)
-	{
-		printk(KERN_WARNING "trident: Error in ali_detect_spdif_rate!\n");
+	if (count > 50000) {
+		printk(KERN_WARNING "trident: Error in "
+		       "ali_detect_spdif_rate!\n");
 		return;
 	}
 
 	count = 0;
 
-	while (count <= 50000)
-	{
-		count ++;
+	while (count <= 50000) {
+		count++;
 
 		ali_delay(card, 6);
 
-		bval = inb(TRID_REG(card,ALI_SPDIF_CTRL + 1));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CTRL + 1));
 		R2 = bval & 0x1F;
 
-		if(R2 != R1)
+		if (R2 != R1)
 			R1 = R2;
 		else
 			break;
 	}
 
-	if (count > 50000)
-	{
-		printk(KERN_WARNING "trident: Error in ali_detect_spdif_rate!\n");
+	if (count > 50000) {
+		printk(KERN_WARNING "trident: Error in "
+		       "ali_detect_spdif_rate!\n");
 		return;
 	}
 
-	switch (R2)
-	{
+	switch (R2) {
 	case 0x0b:
 	case 0x0c:
 	case 0x0d:
 	case 0x0e:
-		wval  = inw(TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval = inw(TRID_REG(card, ALI_SPDIF_CTRL + 2));
 		wval &= 0xE0F0;
-		wval |= (u16)0x09 << 8 | (u16)0x05;
-		outw(wval,TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval |= (u16) 0x09 << 8 | (u16) 0x05;
+		outw(wval, TRID_REG(card, ALI_SPDIF_CTRL + 2));
 
-		bval  = inb(TRID_REG(card,ALI_SPDIF_CS +3)) & 0xF0;
-		outb(bval|0x02,TRID_REG(card,ALI_SPDIF_CS + 3));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CS + 3)) & 0xF0;
+		outb(bval | 0x02, TRID_REG(card, ALI_SPDIF_CS + 3));
 		break;
 
 	case 0x12:
-		wval  = inw(TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval = inw(TRID_REG(card, ALI_SPDIF_CTRL + 2));
 		wval &= 0xE0F0;
-		wval |= (u16)0x0E << 8 | (u16)0x08;
-		outw(wval,TRID_REG(card,ALI_SPDIF_CTRL + 2));
+		wval |= (u16) 0x0E << 8 | (u16) 0x08;
+		outw(wval, TRID_REG(card, ALI_SPDIF_CTRL + 2));
 
-		bval  = inb(TRID_REG(card,ALI_SPDIF_CS +3)) & 0xF0;
-		outb(bval|0x03,TRID_REG(card,ALI_SPDIF_CS + 3));
+		bval = inb(TRID_REG(card, ALI_SPDIF_CS + 3)) & 0xF0;
+		outb(bval | 0x03, TRID_REG(card, ALI_SPDIF_CS + 3));
 		break;
 
 	default:
@@ -3337,23 +3412,23 @@ static void ali_detect_spdif_rate(struct
 
 }
 
-static unsigned int ali_get_spdif_in_rate(struct trident_card *card)
+static unsigned int
+ali_get_spdif_in_rate(struct trident_card *card)
 {
-	u32	dwRate = 0;
-	u8	bval = 0;
+	u32 dwRate = 0;
+	u8 bval = 0;
 
 	ali_detect_spdif_rate(card);
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CTRL));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CTRL));
 	bval &= 0x7F;
 	bval |= 0x40;
-	outb(bval,TRID_REG(card,ALI_SPDIF_CTRL));
+	outb(bval, TRID_REG(card, ALI_SPDIF_CTRL));
 
-	bval  = inb(TRID_REG(card,ALI_SPDIF_CS + 3));
+	bval = inb(TRID_REG(card, ALI_SPDIF_CS + 3));
 	bval &= 0x0F;
 
-	switch (bval)
-	{
+	switch (bval) {
 	case 0:
 		dwRate = 44100;
 		break;
@@ -3369,24 +3444,27 @@ static unsigned int ali_get_spdif_in_rat
 	}
 
 	return dwRate;
-	
+
 }
 
-static int ali_close_multi_channels(void)
+static int
+ali_close_multi_channels(void)
 {
 	char temp = 0;
 	struct pci_dev *pci_dev = NULL;
 
-        pci_dev = pci_find_device(PCI_VENDOR_ID_AL,PCI_DEVICE_ID_AL_M1533, pci_dev);
-        if (pci_dev == NULL)
-                return -1;
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
+	if (pci_dev == NULL)
+		return -1;
 	pci_read_config_byte(pci_dev, 0x59, &temp);
 	temp &= ~0x80;
 	pci_write_config_byte(pci_dev, 0x59, temp);
-	
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev);
+
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 
+				  pci_dev);
 	if (pci_dev == NULL)
-                return -1;
+		return -1;
 
 	pci_read_config_byte(pci_dev, 0xB8, &temp);
 	temp &= ~0x20;
@@ -3395,25 +3473,28 @@ static int ali_close_multi_channels(void
 	return 0;
 }
 
-static int ali_setup_multi_channels(struct trident_card *card, int chan_nums)
+static int
+ali_setup_multi_channels(struct trident_card *card, int chan_nums)
 {
 	unsigned long dwValue;
 	char temp = 0;
 	struct pci_dev *pci_dev = NULL;
 
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
 	if (pci_dev == NULL)
-                return -1;
+		return -1;
 	pci_read_config_byte(pci_dev, 0x59, &temp);
 	temp |= 0x80;
 	pci_write_config_byte(pci_dev, 0x59, temp);
-	
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev);
- 	if (pci_dev == NULL)
-                return -1;
-	pci_read_config_byte(pci_dev, (int)0xB8, &temp);
+
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, 
+				  pci_dev);
+	if (pci_dev == NULL)
+		return -1;
+	pci_read_config_byte(pci_dev, (int) 0xB8, &temp);
 	temp |= 0x20;
-	pci_write_config_byte(pci_dev, (int)0xB8,(u8) temp);
+	pci_write_config_byte(pci_dev, (int) 0xB8, (u8) temp);
 	if (chan_nums == 6) {
 		dwValue = inl(TRID_REG(card, ALI_SCTRL)) | 0x000f0000;
 		outl(dwValue, TRID_REG(card, ALI_SCTRL));
@@ -3424,11 +3505,10 @@ static int ali_setup_multi_channels(stru
 			ali_ac97_write(card->ac97_codec[0], 0x36, 0);
 			ali_ac97_write(card->ac97_codec[0], 0x38, 0);
 			/*
-			 *	On a board with a single codec you won't get the
-			 *	surround. On other boards configure it.
+			 *      On a board with a single codec you won't get the
+			 *      surround. On other boards configure it.
 			 */
-			if(card->ac97_codec[1]!=NULL)
-			{
+			if (card->ac97_codec[1] != NULL) {
 				ali_ac97_write(card->ac97_codec[1], 0x36, 0);
 				ali_ac97_write(card->ac97_codec[1], 0x38, 0);
 				ali_ac97_write(card->ac97_codec[1], 0x02, 0x0606);
@@ -3441,7 +3521,8 @@ static int ali_setup_multi_channels(stru
 	return -EINVAL;
 }
 
-static void ali_free_pcm_channel(struct trident_card *card, unsigned int channel)
+static void
+ali_free_pcm_channel(struct trident_card *card, unsigned int channel)
 {
 	int bank;
 
@@ -3454,25 +3535,25 @@ static void ali_free_pcm_channel(struct 
 	card->banks[bank].bitmap &= ~(1 << (channel));
 }
 
-static int ali_allocate_other_states_resources(struct trident_state *state, int chan_nums)
+static int
+ali_allocate_other_states_resources(struct trident_state *state, int chan_nums)
 {
 	struct trident_card *card = state->card;
 	struct trident_state *s;
 	int i, state_count = 0;
 	struct trident_pcm_bank *bank;
 	struct trident_channel *channel;
-	
+
 	bank = &card->banks[BANK_A];
-	
+
 	if (chan_nums == 6) {
-		for(i = 0;(i < ALI_CHANNELS) && (state_count != 4); i++) {
+		for (i = 0; (i < ALI_CHANNELS) && (state_count != 4); i++) {
 			if (!card->states[i]) {
 				if (!(bank->bitmap & (1 << ali_multi_channels_5_1[state_count]))) {
 					bank->bitmap |= (1 << ali_multi_channels_5_1[state_count]);
 					channel = &bank->channels[ali_multi_channels_5_1[state_count]];
 					channel->num = ali_multi_channels_5_1[state_count];
-				}
-				else {
+				} else {
 					state_count--;
 					for (; state_count >= 0; state_count--) {
 						kfree(state->other_states[state_count]);
@@ -3481,18 +3562,18 @@ static int ali_allocate_other_states_res
 					return -EBUSY;
 				}
 				s = card->states[i] = (struct trident_state *)
-						kmalloc(sizeof(struct trident_state), GFP_KERNEL);
+				    kmalloc(sizeof (struct trident_state), GFP_KERNEL);
 				if (!s) {
 					ali_free_pcm_channel(card, ali_multi_channels_5_1[state_count]);
 					state_count--;
-					for (; state_count >= 0; state_count--) {						
+					for (; state_count >= 0; state_count--) {
 						ali_free_pcm_channel(card, ali_multi_channels_5_1[state_count]);
 						kfree(state->other_states[state_count]);
 					}
 					return -ENOMEM;
 				}
-				memset(s, 0, sizeof(struct trident_state));
-				
+				memset(s, 0, sizeof (struct trident_state));
+
 				s->dmabuf.channel = channel;
 				s->dmabuf.ossfragshift = s->dmabuf.ossmaxfrags = s->dmabuf.subdivision = 0;
 				init_waitqueue_head(&s->dmabuf.wait);
@@ -3503,7 +3584,7 @@ static int ali_allocate_other_states_res
 				state->other_states[state_count++] = s;
 			}
 		}
-		
+
 		if (state_count != 4) {
 			state_count--;
 			for (; state_count >= 0; state_count--) {
@@ -3516,103 +3597,110 @@ static int ali_allocate_other_states_res
 	return 0;
 }
 
-static void ali_save_regs(struct trident_card *card)
+static void
+ali_save_regs(struct trident_card *card)
 {
 	unsigned long flags;
 	int i, j;
 
-	spin_lock_irqsave(&card->lock, flags); 
+	spin_lock_irqsave(&card->lock, flags);
+
+	ali_registers.global_regs[0x2c] = inl(TRID_REG(card, T4D_MISCINT));
+	//ali_registers.global_regs[0x20] = inl(TRID_REG(card,T4D_START_A));    
+	ali_registers.global_regs[0x21] = inl(TRID_REG(card, T4D_STOP_A));
 
-	ali_registers.global_regs[0x2c] = inl(TRID_REG(card,T4D_MISCINT));
-	//ali_registers.global_regs[0x20] = inl(TRID_REG(card,T4D_START_A));	
-	ali_registers.global_regs[0x21] = inl(TRID_REG(card,T4D_STOP_A));
-	
 	//disable all IRQ bits
 	outl(ALI_DISABLE_ALL_IRQ, TRID_REG(card, T4D_MISCINT));
-	
+
 	for (i = 1; i < ALI_MIXER_REGS; i++)
-		ali_registers.mixer_regs[i] = ali_ac97_read (card->ac97_codec[0], i*2);
-	
-	for (i = 0; i < ALI_GLOBAL_REGS; i++)
-	{	
-		if ((i*4 == T4D_MISCINT) || (i*4 == T4D_STOP_A))
+		ali_registers.mixer_regs[i] = ali_ac97_read(card->ac97_codec[0], 
+							    i * 2);
+
+	for (i = 0; i < ALI_GLOBAL_REGS; i++) {
+		if ((i * 4 == T4D_MISCINT) || (i * 4 == T4D_STOP_A))
 			continue;
-		ali_registers.global_regs[i] = inl(TRID_REG(card, i*4));
+		ali_registers.global_regs[i] = inl(TRID_REG(card, i * 4));
 	}
-	
-	for (i = 0; i < ALI_CHANNELS; i++) 
-	{
-		outb(i,TRID_REG(card, T4D_LFO_GC_CIR));
-		for (j = 0; j < ALI_CHANNEL_REGS; j++) 
-			ali_registers.channel_regs[i][j] = inl(TRID_REG(card, j*4 + 0xe0));
+
+	for (i = 0; i < ALI_CHANNELS; i++) {
+		outb(i, TRID_REG(card, T4D_LFO_GC_CIR));
+		for (j = 0; j < ALI_CHANNEL_REGS; j++)
+			ali_registers.channel_regs[i][j] = inl(TRID_REG(card, 
+									j * 4 + 0xe0));
 	}
 
 	//Stop all HW channel
 	outl(ALI_STOP_ALL_CHANNELS, TRID_REG(card, T4D_STOP_A));
 
-	spin_unlock_irqrestore(&card->lock, flags); 
+	spin_unlock_irqrestore(&card->lock, flags);
 }
 
-static void ali_restore_regs(struct trident_card *card)
+static void
+ali_restore_regs(struct trident_card *card)
 {
 	unsigned long flags;
 	int i, j;
 
-	spin_lock_irqsave(&card->lock, flags); 
-	
+	spin_lock_irqsave(&card->lock, flags);
+
 	for (i = 1; i < ALI_MIXER_REGS; i++)
-		ali_ac97_write(card->ac97_codec[0], i*2, ali_registers.mixer_regs[i]);
-	
-	for (i = 0; i < ALI_CHANNELS; i++) 
-	{
-		outb(i,TRID_REG(card, T4D_LFO_GC_CIR));
-		for (j = 0; j < ALI_CHANNEL_REGS; j++) 
-			outl(ali_registers.channel_regs[i][j], TRID_REG(card, j*4 + 0xe0));
-	}
-	
-	for (i = 0; i < ALI_GLOBAL_REGS; i++)
-	{	
-		if ((i*4 == T4D_MISCINT) || (i*4 == T4D_STOP_A) || (i*4 == T4D_START_A))
+		ali_ac97_write(card->ac97_codec[0], i * 2, 
+			       ali_registers.mixer_regs[i]);
+
+	for (i = 0; i < ALI_CHANNELS; i++) {
+		outb(i, TRID_REG(card, T4D_LFO_GC_CIR));
+		for (j = 0; j < ALI_CHANNEL_REGS; j++)
+			outl(ali_registers.channel_regs[i][j], 
+			     TRID_REG(card, j * 4 + 0xe0));
+	}
+
+	for (i = 0; i < ALI_GLOBAL_REGS; i++) {
+		if ((i * 4 == T4D_MISCINT) || (i * 4 == T4D_STOP_A) || 
+		    (i * 4 == T4D_START_A))
 			continue;
-		outl(ali_registers.global_regs[i], TRID_REG(card, i*4));
+		outl(ali_registers.global_regs[i], TRID_REG(card, i * 4));
 	}
-	
+
 	//start HW channel
-	outl(ali_registers.global_regs[0x20], TRID_REG(card,T4D_START_A));
+	outl(ali_registers.global_regs[0x20], TRID_REG(card, T4D_START_A));
 	//restore IRQ enable bits
-	outl(ali_registers.global_regs[0x2c], TRID_REG(card,T4D_MISCINT));
+	outl(ali_registers.global_regs[0x2c], TRID_REG(card, T4D_MISCINT));
 
-	spin_unlock_irqrestore(&card->lock, flags); 
+	spin_unlock_irqrestore(&card->lock, flags);
 }
 
-static int trident_suspend(struct pci_dev *dev, u32 unused)
+static int
+trident_suspend(struct pci_dev *dev, u32 unused)
 {
-	struct trident_card *card = pci_get_drvdata(dev); 
+	struct trident_card *card = pci_get_drvdata(dev);
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		ali_save_regs(card);
 	}
 	return 0;
 }
 
-static int trident_resume(struct pci_dev *dev)
+static int
+trident_resume(struct pci_dev *dev)
 {
-	struct trident_card *card = pci_get_drvdata(dev); 
+	struct trident_card *card = pci_get_drvdata(dev);
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		ali_restore_regs(card);
 	}
 	return 0;
 }
 
-static struct trident_channel *ali_alloc_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+ali_alloc_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
 
 	bank = &card->banks[BANK_A];
-	
-	if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & (ALI_SPDIF_OUT_CH_ENABLE)) {
+
+	if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & 
+	    (ALI_SPDIF_OUT_CH_ENABLE)) {
 		idx = ALI_SPDIF_OUT_CHANNEL;
 		if (!(bank->bitmap & (1 << idx))) {
 			struct trident_channel *channel = &bank->channels[idx];
@@ -3621,8 +3709,9 @@ static struct trident_channel *ali_alloc
 			return channel;
 		}
 	}
-	
-	for (idx = ALI_PCM_OUT_CHANNEL_FIRST; idx <= ALI_PCM_OUT_CHANNEL_LAST ; idx++) {
+
+	for (idx = ALI_PCM_OUT_CHANNEL_FIRST; idx <= ALI_PCM_OUT_CHANNEL_LAST; 
+	     idx++) {
 		if (!(bank->bitmap & (1 << idx))) {
 			struct trident_channel *channel = &bank->channels[idx];
 			bank->bitmap |= 1 << idx;
@@ -3632,39 +3721,46 @@ static struct trident_channel *ali_alloc
 	}
 
 	/* no more free channels avaliable */
-//	printk(KERN_ERR "ali: no more channels available on Bank A.\n");
+#if 0 
+	printk(KERN_ERR "ali: no more channels available on Bank A.\n");
+#endif /* 0 */ 
 	return NULL;
 }
 
-static struct trident_channel *ali_alloc_rec_pcm_channel(struct trident_card *card)
+static struct trident_channel *
+ali_alloc_rec_pcm_channel(struct trident_card *card)
 {
 	struct trident_pcm_bank *bank;
 	int idx;
-	
+
 	if (inl(TRID_REG(card, ALI_GLOBAL_CONTROL)) & ALI_SPDIF_IN_SUPPORT)
 		idx = ALI_SPDIF_IN_CHANNEL;
-	else	idx = ALI_PCM_IN_CHANNEL;
+	else
+		idx = ALI_PCM_IN_CHANNEL;
 
 	bank = &card->banks[BANK_A];
-	
+
 	if (!(bank->bitmap & (1 << idx))) {
 		struct trident_channel *channel = &bank->channels[idx];
 		bank->bitmap |= 1 << idx;
 		channel->num = idx;
 		return channel;
 	}
-	
+
 	/* no free recordable channels avaliable */
-//	printk(KERN_ERR "ali: no recordable channels available on Bank A.\n");
+#if 0 
+	printk(KERN_ERR "ali: no recordable channels available on Bank A.\n");
+#endif /* 0 */ 
 	return NULL;
 }
 
-static void ali_set_spdif_out_rate(struct trident_card *card, unsigned int rate)
+static void
+ali_set_spdif_out_rate(struct trident_card *card, unsigned int rate)
 {
 	unsigned char ch_st_sel;
 	unsigned short status_rate;
-	
-	switch(rate) {
+
+	switch (rate) {
 	case 44100:
 		status_rate = 0;
 		break;
@@ -3676,28 +3772,30 @@ static void ali_set_spdif_out_rate(struc
 		status_rate = 0x200;
 		break;
 	}
-	
-	ch_st_sel = inb(TRID_REG(card, ALI_SPDIF_CTRL)) & ALI_SPDIF_OUT_CH_STATUS;	//select spdif_out
-	
-	ch_st_sel |= 0x80;	//select right
+
+	/* select spdif_out */ 
+	ch_st_sel = inb(TRID_REG(card, ALI_SPDIF_CTRL)) & ALI_SPDIF_OUT_CH_STATUS;
+
+	ch_st_sel |= 0x80;	/* select right */ 
 	outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL));
 	outb(status_rate | 0x20, TRID_REG(card, ALI_SPDIF_CS + 2));
-	
-	ch_st_sel &= (~0x80);	//select left
+
+	ch_st_sel &= (~0x80);	/* select left */ 
 	outb(ch_st_sel, TRID_REG(card, ALI_SPDIF_CTRL));
 	outw(status_rate | 0x10, TRID_REG(card, ALI_SPDIF_CS + 2));
 }
 
-static void ali_address_interrupt(struct trident_card *card)
+static void
+ali_address_interrupt(struct trident_card *card)
 {
 	int i, channel;
 	struct trident_state *state;
 	u32 mask, channel_mask;
-	
-	mask = trident_get_interrupt_mask (card, 0);
+
+	mask = trident_get_interrupt_mask(card, 0);
 	for (i = 0; i < NR_HW_CH; i++) {
 		if ((state = card->states[i]) == NULL)
-			continue;		
+			continue;
 		channel = state->dmabuf.channel->num;
 		if ((channel_mask = 1 << channel) & mask) {
 			mask &= ~channel_mask;
@@ -3724,37 +3822,41 @@ protection is no harm because all DMAs o
 depend on a master state's DMA, and changing the counters of the master
 state DMA is protected by a spinlock.
 */
-static int ali_write_5_1(struct trident_state *state,  
-			 const char *buf, int cnt_for_multi_channel, 
-			 unsigned int *copy_count, 
-			 unsigned int *state_cnt)
+static int
+ali_write_5_1(struct trident_state *state, const char *buf, 
+	      int cnt_for_multi_channel, unsigned int *copy_count, 
+	      unsigned int *state_cnt)
 {
-	
+
 	struct dmabuf *dmabuf = &state->dmabuf;
 	struct dmabuf *dmabuf_temp;
 	const char *buffer = buf;
 	unsigned swptr, other_dma_nums, sample_s;
 	unsigned int i, loop;
-	
+
 	other_dma_nums = 4;
 	sample_s = sample_size[dmabuf->fmt] >> 1;
 	swptr = dmabuf->swptr;
 
 	if ((i = state->multi_channels_adjust_count) > 0) {
 		if (i == 1) {
-			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf->rawbuf + swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+			seek_offset(swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 			i--;
 			(*state_cnt) += sample_s;
 			state->multi_channels_adjust_count++;
-		}
-		else	i = i - (state->chans_num - other_dma_nums);
+		} else
+			i = i - (state->chans_num - other_dma_nums);
 		for (; (i < other_dma_nums) && (cnt_for_multi_channel > 0); i++) {
 			dmabuf_temp = &state->other_states[i]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 		}
 		if (cnt_for_multi_channel == 0)
 			state->multi_channels_adjust_count += i;
@@ -3762,58 +3864,75 @@ static int ali_write_5_1(struct trident_
 	if (cnt_for_multi_channel > 0) {
 		loop = cnt_for_multi_channel / (state->chans_num * sample_s);
 		for (i = 0; i < loop; i++) {
-			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s * 2))
+			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, 
+					   sample_s * 2))
 				return -EFAULT;
-			seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s * 2, *copy_count);
+			seek_offset(swptr, buffer, cnt_for_multi_channel, 
+				    sample_s * 2, *copy_count);
 			(*state_cnt) += (sample_s * 2);
-		
+
 			dmabuf_temp = &state->other_states[0]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
-		
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
+
 			dmabuf_temp = &state->other_states[1]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
-		
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
+
 			dmabuf_temp = &state->other_states[2]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
-				
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
+
 			dmabuf_temp = &state->other_states[3]->dmabuf;
-			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+			if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, 
+					   buffer, sample_s))
 				return -EFAULT;
-			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+			seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 		}
-		
+
 		if (cnt_for_multi_channel > 0) {
 			state->multi_channels_adjust_count = cnt_for_multi_channel / sample_s;
-			
+
 			if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
 				return -EFAULT;
-			seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);			
+			seek_offset(swptr, buffer, cnt_for_multi_channel, 
+				    sample_s, *copy_count);
 			(*state_cnt) += sample_s;
-			
+
 			if (cnt_for_multi_channel > 0) {
-				if (copy_from_user(dmabuf->rawbuf + swptr, buffer, sample_s))
+				if (copy_from_user(dmabuf->rawbuf + swptr, 
+						   buffer, sample_s))
 					return -EFAULT;
-				seek_offset(swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+				seek_offset(swptr, buffer, cnt_for_multi_channel, 
+					    sample_s, *copy_count);
 				(*state_cnt) += sample_s;
-			
+
 				if (cnt_for_multi_channel > 0) {
-					loop = state->multi_channels_adjust_count - (state->chans_num - other_dma_nums);
+					loop = state->multi_channels_adjust_count - 
+						(state->chans_num - other_dma_nums);
 					for (i = 0; i < loop; i++) {
 						dmabuf_temp = &state->other_states[i]->dmabuf;
-						if (copy_from_user(dmabuf_temp->rawbuf + dmabuf_temp->swptr, buffer, sample_s))
+						if (copy_from_user(dmabuf_temp->rawbuf + 
+								   dmabuf_temp->swptr, 
+								   buffer, sample_s))
 							return -EFAULT;
-						seek_offset(dmabuf_temp->swptr, buffer, cnt_for_multi_channel, sample_s, *copy_count);
+						seek_offset(dmabuf_temp->swptr, buffer, 
+							    cnt_for_multi_channel, 
+							    sample_s, *copy_count);
 					}
 				}
 			}
-		}
-		else
+		} else
 			state->multi_channels_adjust_count = 0;
 	}
 	for (i = 0; i < other_dma_nums; i++) {
@@ -3823,15 +3942,16 @@ static int ali_write_5_1(struct trident_
 	return *state_cnt;
 }
 
-static void ali_free_other_states_resources(struct trident_state *state)
+static void
+ali_free_other_states_resources(struct trident_state *state)
 {
 	int i;
 	struct trident_card *card = state->card;
 	struct trident_state *s;
 	unsigned other_states_count;
-	
-	other_states_count = state->chans_num - 2;	/* except PCM L/R channels*/
-	for ( i = 0; i < other_states_count; i++) {
+
+	other_states_count = state->chans_num - 2; /* except PCM L/R channels */
+	for (i = 0; i < other_states_count; i++) {
 		s = state->other_states[i];
 		dealloc_dmabuf(&s->dmabuf, card->pci_dev);
 		ali_disable_special_channel(s->card, s->dmabuf.channel->num);
@@ -3842,35 +3962,38 @@ static void ali_free_other_states_resour
 }
 
 struct proc_dir_entry *res;
-static int ali_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
+static int
+ali_write_proc(struct file *file, const char *buffer, unsigned long count, void *data)
 {
-	struct trident_card *card = (struct trident_card *)data;
+	struct trident_card *card = (struct trident_card *) data;
 	unsigned long flags;
 	char c;
 
-	if (count<0)
+	if (count < 0)
 		return -EINVAL;
 	if (count == 0)
 		return 0;
 	if (get_user(c, buffer))
 		return -EFAULT;
-	
+
 	spin_lock_irqsave(&card->lock, flags);
 	switch (c) {
-	    case '0':
+	case '0':
 		ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
 		ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
 		break;
-	    case '1':
-		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT|ALI_SPDIF_OUT_PCM);
-		break;
-	    case '2':
-		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT|ALI_SPDIF_OUT_NON_PCM);
+	case '1':
+		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT | 
+				    ALI_SPDIF_OUT_PCM);
+		break;
+	case '2':
+		ali_setup_spdif_out(card, ALI_SPDIF_OUT_TO_SPDIF_OUT | 
+				    ALI_SPDIF_OUT_NON_PCM);
 		break;
-	    case '3':
+	case '3':
 		ali_disable_spdif_in(card);	//default
 		break;
-	    case '4':
+	case '4':
 		ali_setup_spdif_in(card);
 		break;
 	}
@@ -3880,7 +4003,8 @@ static int ali_write_proc(struct file *f
 }
 
 /* OSS /dev/mixer file operation methods */
-static int trident_open_mixdev(struct inode *inode, struct file *file)
+static int
+trident_open_mixdev(struct inode *inode, struct file *file)
 {
 	int i = 0;
 	int minor = iminor(inode);
@@ -3888,45 +4012,47 @@ static int trident_open_mixdev(struct in
 
 	for (card = devs; card != NULL; card = card->next)
 		for (i = 0; i < NR_AC97; i++)
-			if (card->ac97_codec[i] != NULL &&
+			if (card->ac97_codec[i] != NULL && 
 			    card->ac97_codec[i]->dev_mixer == minor)
 				goto match;
 
 	if (!card) {
 		return -ENODEV;
 	}
- match:
+      match:
 	file->private_data = card->ac97_codec[i];
 
-
 	return 0;
 }
 
-static int trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd,
-				unsigned long arg)
+static int
+trident_ioctl_mixdev(struct inode *inode, struct file *file, unsigned int cmd, 
+		     unsigned long arg)
 {
-	struct ac97_codec *codec = (struct ac97_codec *)file->private_data;
+	struct ac97_codec *codec = (struct ac97_codec *) file->private_data;
 
 	return codec->mixer_ioctl(codec, cmd, arg);
 }
 
-static /*const*/ struct file_operations trident_mixer_fops = {
-	.owner		= THIS_MODULE,
-	.llseek		= no_llseek,
-	.ioctl		= trident_ioctl_mixdev,
-	.open		= trident_open_mixdev,
+static /*const */ struct file_operations trident_mixer_fops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.ioctl = trident_ioctl_mixdev,
+	.open = trident_open_mixdev,
 };
 
-static int ali_reset_5451(struct trident_card *card)
+static int
+ali_reset_5451(struct trident_card *card)
 {
 	struct pci_dev *pci_dev = NULL;
-	unsigned int   dwVal;
+	unsigned int dwVal;
 	unsigned short wCount, wReg;
 
-	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, pci_dev);
+	pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, 
+				  pci_dev);
 	if (pci_dev == NULL)
 		return -1;
-	
+
 	pci_read_config_dword(pci_dev, 0x7c, &dwVal);
 	pci_write_config_dword(pci_dev, 0x7c, dwVal | 0x08000000);
 	udelay(5000);
@@ -3946,9 +4072,9 @@ static int ali_reset_5451(struct trident
 	udelay(5000);
 
 	wCount = 2000;
-	while(wCount--) {
+	while (wCount--) {
 		wReg = ali_ac97_get(card, 0, AC97_POWER_CONTROL);
-		if((wReg & 0x000f) == 0x000f)
+		if ((wReg & 0x000f) == 0x000f)
 			return 0;
 		udelay(5000);
 	}
@@ -3957,33 +4083,32 @@ static int ali_reset_5451(struct trident
 }
 
 /* AC97 codec initialisation. */
-static int __devinit trident_ac97_init(struct trident_card *card)
+static int __devinit
+trident_ac97_init(struct trident_card *card)
 {
 	int num_ac97 = 0;
 	unsigned long ready_2nd = 0;
 	struct ac97_codec *codec;
 	int i = 0;
-	
 
 	/* initialize controller side of AC link, and find out if secondary codes
 	   really exist */
-	switch (card->pci_id)
-	{
+	switch (card->pci_id) {
 	case PCI_DEVICE_ID_ALI_5451:
-		if (ali_reset_5451(card)) 
-		{
-			printk(KERN_ERR "trident_ac97_init: error resetting 5451.\n");
+		if (ali_reset_5451(card)) {
+			printk(KERN_ERR "trident_ac97_init: error "
+			       "resetting 5451.\n");
 			return -1;
 		}
-		outl(0x80000001,TRID_REG(card, ALI_GLOBAL_CONTROL));
-		outl(0x00000000,TRID_REG(card, T4D_AINTEN_A));
-		outl(0xffffffff,TRID_REG(card, T4D_AINT_A));
-		outl(0x00000000,TRID_REG(card, T4D_MUSICVOL_WAVEVOL));
-		outb(0x10,	TRID_REG(card, ALI_MPUR2));
+		outl(0x80000001, TRID_REG(card, ALI_GLOBAL_CONTROL));
+		outl(0x00000000, TRID_REG(card, T4D_AINTEN_A));
+		outl(0xffffffff, TRID_REG(card, T4D_AINT_A));
+		outl(0x00000000, TRID_REG(card, T4D_MUSICVOL_WAVEVOL));
+		outb(0x10, TRID_REG(card, ALI_MPUR2));
 		ready_2nd = inl(TRID_REG(card, ALI_SCTRL));
 		ready_2nd &= 0x3fff;
 		outl(ready_2nd | PCMOUT | 0x8000, TRID_REG(card, ALI_SCTRL));
-		ready_2nd = inl(TRID_REG(card, ALI_SCTRL)); 
+		ready_2nd = inl(TRID_REG(card, ALI_SCTRL));
 		ready_2nd &= SI_AC97_SECONDARY_READY;
 		if (card->revision < ALI_5451_V02)
 			ready_2nd = 0;
@@ -3992,10 +4117,10 @@ static int __devinit trident_ac97_init(s
 		/* disable AC97 GPIO interrupt */
 		outl(0x00, TRID_REG(card, SI_AC97_GPIO));
 		/* when power up the AC link is in cold reset mode so stop it */
-		outl(PCMOUT|SURROUT|CENTEROUT|LFEOUT|SECONDARY_ID,
+		outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT | SECONDARY_ID, 
 		     TRID_REG(card, SI_SERIAL_INTF_CTRL));
-		/* it take a long time to recover from a cold reset (especially when you have
-		   more than one codec) */
+		/* it take a long time to recover from a cold reset */ 
+		/* (especially when you have more than one codec) */
 		udelay(2000);
 		ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL));
 		ready_2nd &= SI_AC97_SECONDARY_READY;
@@ -4014,10 +4139,10 @@ static int __devinit trident_ac97_init(s
 		/* disable AC97 GPIO interrupt */
 		outl(0x00, TRID_REG(card, SI_AC97_GPIO));
 		/* when power up, the AC link is in cold reset mode, so stop it */
-		outl(PCMOUT|SURROUT|CENTEROUT|LFEOUT,
+		outl(PCMOUT | SURROUT | CENTEROUT | LFEOUT, 
 		     TRID_REG(card, SI_SERIAL_INTF_CTRL));
-		/* it take a long time to recover from a cold reset (especially when you have
-		   more than one codec) */
+		/* it take a long time to recover from a cold reset (especially */ 
+		/* when you have more than one codec) */
 		udelay(2000);
 		ready_2nd = inl(TRID_REG(card, SI_SERIAL_INTF_CTRL));
 		ready_2nd &= SI_AC97_SECONDARY_READY;
@@ -4028,20 +4153,19 @@ static int __devinit trident_ac97_init(s
 		if ((codec = ac97_alloc_codec()) == NULL)
 			return -ENOMEM;
 
-		/* initialize some basic codec information, other fields will be filled
-		   in ac97_probe_codec */
+		/* initialize some basic codec information, other fields */ 
+		/* will be filled in ac97_probe_codec */
 		codec->private_data = card;
 		codec->id = num_ac97;
 
 		if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 			codec->codec_read = ali_ac97_read;
 			codec->codec_write = ali_ac97_write;
-		}
-		else {
+		} else {
 			codec->codec_read = trident_ac97_get;
 			codec->codec_write = trident_ac97_set;
 		}
-	
+
 		if (ac97_probe_codec(codec) == 0)
 			break;
 
@@ -4062,65 +4186,72 @@ static int __devinit trident_ac97_init(s
 		for (num_ac97 = 0; num_ac97 < NR_AC97; num_ac97++) {
 			if (card->ac97_codec[num_ac97] == NULL)
 				break;
-			for (i=0; i<64;i++)
-				card->mixer_regs[i][num_ac97] = ali_ac97_get(card, num_ac97,i*2);
+			for (i = 0; i < 64; i++)
+				card->mixer_regs[i][num_ac97] = ali_ac97_get(card, num_ac97, 
+									     i * 2);
 		}
 	}
-	return num_ac97+1;
+	return num_ac97 + 1;
 }
 
 /* Gameport functions for the cards ADC gameport */
 
-static unsigned char trident_game_read(struct gameport *gameport)
+static unsigned char
+trident_game_read(struct gameport *gameport)
 {
 	struct trident_card *card = gameport->driver;
 	return inb(TRID_REG(card, T4D_GAME_LEG));
 }
 
-static void trident_game_trigger(struct gameport *gameport)
+static void
+trident_game_trigger(struct gameport *gameport)
 {
 	struct trident_card *card = gameport->driver;
 	outb(0xff, TRID_REG(card, T4D_GAME_LEG));
 }
 
-static int trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
+static int
+trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
 {
-        struct trident_card *card = gameport->driver;
+	struct trident_card *card = gameport->driver;
 	int i;
 
 	*buttons = (~inb(TRID_REG(card, T4D_GAME_LEG)) >> 4) & 0xf;
 
 	for (i = 0; i < 4; i++) {
-		axes[i] = inw(TRID_REG(card, T4D_GAME_AXD) + i * sizeof(u16));
-		if (axes[i] == 0xffff) axes[i] = -1;
+		axes[i] = inw(TRID_REG(card, T4D_GAME_AXD) + i * sizeof (u16));
+		if (axes[i] == 0xffff)
+			axes[i] = -1;
 	}
-        
-        return 0;
+
+	return 0;
 }
 
-static int trident_game_open(struct gameport *gameport, int mode)
+static int
+trident_game_open(struct gameport *gameport, int mode)
 {
 	struct trident_card *card = gameport->driver;
 
 	switch (mode) {
-		case GAMEPORT_MODE_COOKED:
-			outb(0x80, TRID_REG(card, T4D_GAME_CR));
-			wait_ms(20);
-			return 0;
-		case GAMEPORT_MODE_RAW:
-			outb(0x00, TRID_REG(card, T4D_GAME_CR));
-			return 0;
-		default:
-			return -1;
+	case GAMEPORT_MODE_COOKED:
+		outb(0x80, TRID_REG(card, T4D_GAME_CR));
+		wait_ms(20);
+		return 0;
+	case GAMEPORT_MODE_RAW:
+		outb(0x00, TRID_REG(card, T4D_GAME_CR));
+		return 0;
+	default:
+		return -1;
 	}
 
 	return 0;
 }
 
-
-/* install the driver, we do not allocate hardware channel nor DMA buffer now, they are defered 
-   until "ACCESS" time (in prog_dmabuf called by open/read/write/ioctl/mmap) */
-static int __devinit trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
+/* install the driver, we do not allocate hardware channel nor DMA buffer */ 
+/* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ 
+/* open/read/write/ioctl/mmap) */
+static int __devinit
+trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
 {
 	unsigned long iobase;
 	struct trident_card *card;
@@ -4140,9 +4271,9 @@ static int __devinit trident_probe(struc
 	else
 		dma_mask = TRIDENT_DMA_MASK;
 	if (pci_set_dma_mask(pci_dev, dma_mask)) {
-		printk(KERN_ERR "trident: architecture does not support"
-		       " %s PCI busmaster DMA\n",
-		       pci_dev->device == PCI_DEVICE_ID_ALI_5451 ?
+		printk(KERN_ERR "trident: architecture does not support" 
+		       " %s PCI busmaster DMA\n", 
+		       pci_dev->device == PCI_DEVICE_ID_ALI_5451 ? 
 		       "32-bit" : "30-bit");
 		goto out;
 	}
@@ -4154,17 +4285,17 @@ static int __devinit trident_probe(struc
 		iobase = pci_resource_start(pci_dev, 0);
 
 	if (!request_region(iobase, 256, card_names[pci_id->driver_data])) {
-		printk(KERN_ERR "trident: can't allocate I/O space at 0x%4.4lx\n",
-		       iobase);
+		printk(KERN_ERR "trident: can't allocate I/O space at "
+		       "0x%4.4lx\n", iobase);
 		goto out;
 	}
 
 	rc = -ENOMEM;
-	if ((card = kmalloc(sizeof(struct trident_card), GFP_KERNEL)) == NULL) {
+	if ((card = kmalloc(sizeof (struct trident_card), GFP_KERNEL)) == NULL) {
 		printk(KERN_ERR "trident: out of memory\n");
 		goto out_release_region;
 	}
-	memset(card, 0, sizeof(*card));
+	memset(card, 0, sizeof (*card));
 
 	init_timer(&card->timer);
 	card->iobase = iobase;
@@ -4194,15 +4325,15 @@ static int __devinit trident_probe(struc
 
 	pci_set_master(pci_dev);
 
-	printk(KERN_INFO "trident: %s found at IO 0x%04lx, IRQ %d\n",
+	printk(KERN_INFO "trident: %s found at IO 0x%04lx, IRQ %d\n", 
 	       card_names[pci_id->driver_data], card->iobase, card->irq);
 
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
-		/* ALi channel Management */	
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+		/* ALi channel Management */
 		card->alloc_pcm_channel = ali_alloc_pcm_channel;
 		card->alloc_rec_pcm_channel = ali_alloc_rec_pcm_channel;
 		card->free_pcm_channel = ali_free_pcm_channel;
-		
+
 		card->address_interrupt = ali_address_interrupt;
 
 		/* Added by Matt Wu 01-05-2001 for spdif in */
@@ -4210,8 +4341,8 @@ static int __devinit trident_probe(struc
 		card->rec_channel_use_count = 0;
 
 		/* ALi SPDIF OUT function */
-		if(card->revision == ALI_5451_V02) {
-			ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);		
+		if (card->revision == ALI_5451_V02) {
+			ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
 			res = create_proc_entry("ALi5451", 0, NULL);
 			if (res) {
 				res->write_proc = ali_write_proc;
@@ -4221,32 +4352,29 @@ static int __devinit trident_probe(struc
 
 		/* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */
 		card->hwvolctl = 0;
-		pci_dev_m1533 = pci_find_device(PCI_VENDOR_ID_AL,PCI_DEVICE_ID_AL_M1533, pci_dev_m1533);
+		pci_dev_m1533 = pci_find_device(PCI_VENDOR_ID_AL, 
+						PCI_DEVICE_ID_AL_M1533, 
+						pci_dev_m1533);
 		rc = -ENODEV;
 		if (pci_dev_m1533 == NULL)
 			goto out_proc_fs;
 		pci_read_config_byte(pci_dev_m1533, 0x63, &bits);
-		if (bits & (1<<5))
+		if (bits & (1 << 5))
 			card->hwvolctl = 1;
-		if (card->hwvolctl) 
-		{
+		if (card->hwvolctl) {
 			/* Clear m1533 pci cfg 78h bit 30 to zero, which makes
 			   GPIO11/12/13 work as ACGP_UP/DOWN/MUTE. */
 			pci_read_config_byte(pci_dev_m1533, 0x7b, &bits);
-			bits &= 0xbf; /*clear bit 6 */
+			bits &= 0xbf;	/*clear bit 6 */
 			pci_write_config_byte(pci_dev_m1533, 0x7b, bits);
 		}
-	}
-	else if(card->pci_id == PCI_DEVICE_ID_INTERG_5050)
-	{
+	} else if (card->pci_id == PCI_DEVICE_ID_INTERG_5050) {
 		card->alloc_pcm_channel = cyber_alloc_pcm_channel;
 		card->alloc_rec_pcm_channel = cyber_alloc_pcm_channel;
 		card->free_pcm_channel = cyber_free_pcm_channel;
 		card->address_interrupt = cyber_address_interrupt;
 		cyber_init_ritual(card);
-	}
-	else
-	{
+	} else {
 		card->alloc_pcm_channel = trident_alloc_pcm_channel;
 		card->alloc_rec_pcm_channel = trident_alloc_pcm_channel;
 		card->free_pcm_channel = trident_free_pcm_channel;
@@ -4255,9 +4383,10 @@ static int __devinit trident_probe(struc
 
 	/* claim our irq */
 	rc = -ENODEV;
-	if (request_irq(card->irq, &trident_interrupt, SA_SHIRQ,
+	if (request_irq(card->irq, &trident_interrupt, SA_SHIRQ, 
 			card_names[pci_id->driver_data], card)) {
-		printk(KERN_ERR "trident: unable to allocate irq %d\n", card->irq);
+		printk(KERN_ERR "trident: unable to allocate irq %d\n", 
+		       card->irq);
 		goto out_proc_fs;
 	}
 	/* register /dev/dsp */
@@ -4282,35 +4411,36 @@ static int __devinit trident_probe(struc
 
 	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		/* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */
-		if(card->hwvolctl) 
-		{
-			/* Enable GPIO IRQ (MISCINT bit 18h)*/
+		if (card->hwvolctl) {
+			/* Enable GPIO IRQ (MISCINT bit 18h) */
 			temp = inw(TRID_REG(card, T4D_MISCINT + 2));
 			temp |= 0x0004;
 			outw(temp, TRID_REG(card, T4D_MISCINT + 2));
 
-			/* Enable H/W Volume Control GLOVAL CONTROL bit 0*/
+			/* Enable H/W Volume Control GLOVAL CONTROL bit 0 */
 			temp = inw(TRID_REG(card, ALI_GLOBAL_CONTROL));
 			temp |= 0x0001;
 			outw(temp, TRID_REG(card, ALI_GLOBAL_CONTROL));
 
 		}
-		if(card->revision == ALI_5451_V02)
+		if (card->revision == ALI_5451_V02)
 			ali_close_multi_channels();
 		/* edited by HMSEO for GT sound */
 #if defined(CONFIG_ALPHA_NAUTILUS) || defined(CONFIG_ALPHA_GENERIC)
 		{
 			u16 ac97_data;
 			extern struct hwrpb_struct *hwrpb;
-		
+
 			if ((hwrpb->sys_type) == 201) {
-				printk(KERN_INFO "trident: Running on Alpha system type Nautilus\n");
+				printk(KERN_INFO "trident: Running on Alpha system "
+				       "type Nautilus\n");
 				ac97_data = ali_ac97_get(card, 0, AC97_POWER_CONTROL);
-				ali_ac97_set(card, 0, AC97_POWER_CONTROL, ac97_data | ALI_EAPD_POWER_DOWN);
+				ali_ac97_set(card, 0, AC97_POWER_CONTROL, 
+					     ac97_data | ALI_EAPD_POWER_DOWN);
 			}
 		}
-#endif /* CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC */ 
-		/* edited by HMSEO for GT sound*/
+#endif				/* CONFIG_ALPHA_NAUTILUS || CONFIG_ALPHA_GENERIC */
+		/* edited by HMSEO for GT sound */
 	}
 	rc = 0;
 	pci_set_drvdata(pci_dev, card);
@@ -4321,7 +4451,9 @@ static int __devinit trident_probe(struc
 	/* Register gameport */
 	gameport_register_port(&card->gameport);
 
-out:	return rc;
+out:
+	return rc;
+
 out_unregister_sound_dsp:
 	unregister_sound_dsp(card->dev_audio);
 out_free_irq:
@@ -4335,26 +4467,27 @@ out_proc_fs:
 	devs = NULL;
 out_release_region:
 	release_region(iobase, 256);
-	goto out;
+	return rc; 
 }
 
-static void __devexit trident_remove(struct pci_dev *pci_dev)
+static void __devexit
+trident_remove(struct pci_dev *pci_dev)
 {
 	int i;
 	struct trident_card *card = pci_get_drvdata(pci_dev);
 
 	/*
- 	 *	Kill running timers before unload. We can't have them
- 	 *	going off after rmmod!
- 	 */
-	if(card->hwvolctl)
+	 *      Kill running timers before unload. We can't have them
+	 *      going off after rmmod!
+	 */
+	if (card->hwvolctl)
 		del_timer_sync(&card->timer);
-		
+
 	/* ALi S/PDIF and Power Management */
-	if(card->pci_id == PCI_DEVICE_ID_ALI_5451) {
+	if (card->pci_id == PCI_DEVICE_ID_ALI_5451) {
 		ali_setup_spdif_out(card, ALI_PCM_TO_SPDIF_OUT);
-                ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
-                ali_disable_spdif_in(card);
+		ali_disable_special_channel(card, ALI_SPDIF_OUT_CHANNEL);
+		ali_disable_spdif_in(card);
 		remove_proc_entry("ALi5451", NULL);
 	}
 
@@ -4382,35 +4515,37 @@ static void __devexit trident_remove(str
 }
 
 MODULE_AUTHOR("Alan Cox, Aaron Holtzman, Ollie Lho, Ching Ling Lee");
-MODULE_DESCRIPTION("Trident 4DWave/SiS 7018/ALi 5451 and Tvia/IGST CyberPro5050 PCI Audio Driver");
+MODULE_DESCRIPTION("Trident 4DWave/SiS 7018/ALi 5451 and Tvia/IGST "
+		   "CyberPro5050 PCI Audio Driver");
 MODULE_LICENSE("GPL");
 
-
 #define TRIDENT_MODULE_NAME "trident"
 
 static struct pci_driver trident_pci_driver = {
-	.name		= TRIDENT_MODULE_NAME,
-	.id_table	= trident_pci_tbl,
-	.probe		= trident_probe,
-	.remove		= __devexit_p(trident_remove),
-	.suspend	= trident_suspend,
-	.resume		= trident_resume
+	.name = TRIDENT_MODULE_NAME,
+	.id_table = trident_pci_tbl,
+	.probe = trident_probe,
+	.remove = __devexit_p(trident_remove),
+	.suspend = trident_suspend,
+	.resume = trident_resume
 };
 
-static int __init trident_init_module (void)
+static int __init
+trident_init_module(void)
 {
-	printk(KERN_INFO "Trident 4DWave/SiS 7018/ALi 5451,Tvia CyberPro "
-	       "5050 PCI Audio, version " DRIVER_VERSION ", " 
-	       __TIME__ " " __DATE__ "\n");
+	printk(KERN_INFO "Trident 4DWave/SiS 7018/ALi 5451,Tvia CyberPro " 
+	       "5050 PCI Audio, version " DRIVER_VERSION ", " __TIME__ " " 
+	       __DATE__ "\n");
 
 	if (!pci_register_driver(&trident_pci_driver)) {
 		pci_unregister_driver(&trident_pci_driver);
-                return -ENODEV;
+		return -ENODEV;
 	}
 	return 0;
 }
 
-static void __exit trident_cleanup_module (void)
+static void __exit
+trident_cleanup_module(void)
 {
 	pci_unregister_driver(&trident_pci_driver);
 }

_