diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-01-30 13:30:10 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 13:30:10 +0100 |
commit | a4ec1effce83796209a0258602b0cf50026d86f2 (patch) | |
tree | 557df52f7a541b7b3e9762b3ad379bf98349bfb8 /arch/x86/mach-voyager | |
parent | 31183ba8fd05b6ddc67ab4d726167cbc52e1b346 (diff) |
x86: mach-voyager, lindent
lindent the mach-voyager files to get rid of more than 300 style errors:
errors lines of code errors/KLOC
arch/x86/mach-voyager/ [old] 409 3729 109.6
arch/x86/mach-voyager/ [new] 71 3678 19.3
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/mach-voyager')
-rw-r--r-- | arch/x86/mach-voyager/setup.c | 32 | ||||
-rw-r--r-- | arch/x86/mach-voyager/voyager_basic.c | 132 | ||||
-rw-r--r-- | arch/x86/mach-voyager/voyager_cat.c | 601 | ||||
-rw-r--r-- | arch/x86/mach-voyager/voyager_smp.c | 672 | ||||
-rw-r--r-- | arch/x86/mach-voyager/voyager_thread.c | 52 |
5 files changed, 718 insertions, 771 deletions
diff --git a/arch/x86/mach-voyager/setup.c b/arch/x86/mach-voyager/setup.c index 3bef977cb29..81257a86198 100644 --- a/arch/x86/mach-voyager/setup.c +++ b/arch/x86/mach-voyager/setup.c @@ -44,7 +44,7 @@ void __init trap_init_hook(void) { } -static struct irqaction irq0 = { +static struct irqaction irq0 = { .handler = timer_interrupt, .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL, .mask = CPU_MASK_NONE, @@ -59,44 +59,47 @@ void __init time_init_hook(void) /* Hook for machine specific memory setup. */ -char * __init machine_specific_memory_setup(void) +char *__init machine_specific_memory_setup(void) { char *who; who = "NOT VOYAGER"; - if(voyager_level == 5) { + if (voyager_level == 5) { __u32 addr, length; int i; who = "Voyager-SUS"; e820.nr_map = 0; - for(i=0; voyager_memory_detect(i, &addr, &length); i++) { + for (i = 0; voyager_memory_detect(i, &addr, &length); i++) { add_memory_region(addr, length, E820_RAM); } return who; - } else if(voyager_level == 4) { + } else if (voyager_level == 4) { __u32 tom; - __u16 catbase = inb(VOYAGER_SSPB_RELOCATION_PORT)<<8; + __u16 catbase = inb(VOYAGER_SSPB_RELOCATION_PORT) << 8; /* select the DINO config space */ outb(VOYAGER_DINO, VOYAGER_CAT_CONFIG_PORT); /* Read DINO top of memory register */ tom = ((inb(catbase + 0x4) & 0xf0) << 16) - + ((inb(catbase + 0x5) & 0x7f) << 24); + + ((inb(catbase + 0x5) & 0x7f) << 24); - if(inb(catbase) != VOYAGER_DINO) { - printk(KERN_ERR "Voyager: Failed to get DINO for L4, setting tom to EXT_MEM_K\n"); - tom = (boot_params.screen_info.ext_mem_k)<<10; + if (inb(catbase) != VOYAGER_DINO) { + printk(KERN_ERR + "Voyager: Failed to get DINO for L4, setting tom to EXT_MEM_K\n"); + tom = (boot_params.screen_info.ext_mem_k) << 10; } who = "Voyager-TOM"; add_memory_region(0, 0x9f000, E820_RAM); /* map from 1M to top of memory */ - add_memory_region(1*1024*1024, tom - 1*1024*1024, E820_RAM); + add_memory_region(1 * 1024 * 1024, tom - 1 * 1024 * 1024, + E820_RAM); /* FIXME: Should check the ASICs to see if I need to * take out the 8M window. Just do it at the moment * */ - add_memory_region(8*1024*1024, 8*1024*1024, E820_RESERVED); + add_memory_region(8 * 1024 * 1024, 8 * 1024 * 1024, + E820_RESERVED); return who; } @@ -114,8 +117,7 @@ char * __init machine_specific_memory_setup(void) unsigned long mem_size; /* compare results from other methods and take the greater */ - if (boot_params.alt_mem_k - < boot_params.screen_info.ext_mem_k) { + if (boot_params.alt_mem_k < boot_params.screen_info.ext_mem_k) { mem_size = boot_params.screen_info.ext_mem_k; who = "BIOS-88"; } else { @@ -126,6 +128,6 @@ char * __init machine_specific_memory_setup(void) e820.nr_map = 0; add_memory_region(0, LOWMEMSIZE(), E820_RAM); add_memory_region(HIGH_MEMORY, mem_size << 10, E820_RAM); - } + } return who; } diff --git a/arch/x86/mach-voyager/voyager_basic.c b/arch/x86/mach-voyager/voyager_basic.c index 9b77b39b71a..6a949e4edde 100644 --- a/arch/x86/mach-voyager/voyager_basic.c +++ b/arch/x86/mach-voyager/voyager_basic.c @@ -35,7 +35,7 @@ /* * Power off function, if any */ -void (*pm_power_off)(void); +void (*pm_power_off) (void); EXPORT_SYMBOL(pm_power_off); int voyager_level = 0; @@ -43,39 +43,38 @@ int voyager_level = 0; struct voyager_SUS *voyager_SUS = NULL; #ifdef CONFIG_SMP -static void -voyager_dump(int dummy1, struct tty_struct *dummy3) +static void voyager_dump(int dummy1, struct tty_struct *dummy3) { /* get here via a sysrq */ voyager_smp_dump(); } static struct sysrq_key_op sysrq_voyager_dump_op = { - .handler = voyager_dump, - .help_msg = "Voyager", - .action_msg = "Dump Voyager Status", + .handler = voyager_dump, + .help_msg = "Voyager", + .action_msg = "Dump Voyager Status", }; #endif -void -voyager_detect(struct voyager_bios_info *bios) +void voyager_detect(struct voyager_bios_info *bios) { - if(bios->len != 0xff) { - int class = (bios->class_1 << 8) - | (bios->class_2 & 0xff); + if (bios->len != 0xff) { + int class = (bios->class_1 << 8) + | (bios->class_2 & 0xff); printk("Voyager System detected.\n" " Class %x, Revision %d.%d\n", class, bios->major, bios->minor); - if(class == VOYAGER_LEVEL4) + if (class == VOYAGER_LEVEL4) voyager_level = 4; - else if(class < VOYAGER_LEVEL5_AND_ABOVE) + else if (class < VOYAGER_LEVEL5_AND_ABOVE) voyager_level = 3; else voyager_level = 5; printk(" Architecture Level %d\n", voyager_level); - if(voyager_level < 4) - printk("\n**WARNING**: Voyager HAL only supports Levels 4 and 5 Architectures at the moment\n\n"); + if (voyager_level < 4) + printk + ("\n**WARNING**: Voyager HAL only supports Levels 4 and 5 Architectures at the moment\n\n"); /* install the power off handler */ pm_power_off = voyager_power_off; #ifdef CONFIG_SMP @@ -86,15 +85,13 @@ voyager_detect(struct voyager_bios_info *bios) } } -void -voyager_system_interrupt(int cpl, void *dev_id) +void voyager_system_interrupt(int cpl, void *dev_id) { printk("Voyager: detected system interrupt\n"); } /* Routine to read information from the extended CMOS area */ -__u8 -voyager_extended_cmos_read(__u16 addr) +__u8 voyager_extended_cmos_read(__u16 addr) { outb(addr & 0xff, 0x74); outb((addr >> 8) & 0xff, 0x75); @@ -108,12 +105,11 @@ voyager_extended_cmos_read(__u16 addr) typedef struct ClickMap { struct Entry { - __u32 Address; - __u32 Length; + __u32 Address; + __u32 Length; } Entry[CLICK_ENTRIES]; } ClickMap_t; - /* This routine is pretty much an awful hack to read the bios clickmap by * mapping it into page 0. There are usually three regions in the map: * Base Memory @@ -122,8 +118,7 @@ typedef struct ClickMap { * * Returns are 0 for failure and 1 for success on extracting region. */ -int __init -voyager_memory_detect(int region, __u32 *start, __u32 *length) +int __init voyager_memory_detect(int region, __u32 * start, __u32 * length) { int i; int retval = 0; @@ -132,13 +127,14 @@ voyager_memory_detect(int region, __u32 *start, __u32 *length) unsigned long map_addr; unsigned long old; - if(region >= CLICK_ENTRIES) { + if (region >= CLICK_ENTRIES) { printk("Voyager: Illegal ClickMap region %d\n", region); return 0; } - for(i = 0; i < sizeof(cmos); i++) - cmos[i] = voyager_extended_cmos_read(VOYAGER_MEMORY_CLICKMAP + i); + for (i = 0; i < sizeof(cmos); i++) + cmos[i] = + voyager_extended_cmos_read(VOYAGER_MEMORY_CLICKMAP + i); map_addr = *(unsigned long *)cmos; @@ -147,10 +143,10 @@ voyager_memory_detect(int region, __u32 *start, __u32 *length) pg0[0] = ((map_addr & PAGE_MASK) | _PAGE_RW | _PAGE_PRESENT); local_flush_tlb(); /* now clear everything out but page 0 */ - map = (ClickMap_t *)(map_addr & (~PAGE_MASK)); + map = (ClickMap_t *) (map_addr & (~PAGE_MASK)); /* zero length is the end of the clickmap */ - if(map->Entry[region].Length != 0) { + if (map->Entry[region].Length != 0) { *length = map->Entry[region].Length * CLICK_SIZE; *start = map->Entry[region].Address; retval = 1; @@ -165,10 +161,9 @@ voyager_memory_detect(int region, __u32 *start, __u32 *length) /* voyager specific handling code for timer interrupts. Used to hand * off the timer tick to the SMP code, since the VIC doesn't have an * internal timer (The QIC does, but that's another story). */ -void -voyager_timer_interrupt(void) +void voyager_timer_interrupt(void) { - if((jiffies & 0x3ff) == 0) { + if ((jiffies & 0x3ff) == 0) { /* There seems to be something flaky in either * hardware or software that is resetting the timer 0 @@ -186,18 +181,20 @@ voyager_timer_interrupt(void) __u16 val; spin_lock(&i8253_lock); - + outb_p(0x00, 0x43); val = inb_p(0x40); val |= inb(0x40) << 8; spin_unlock(&i8253_lock); - if(val > LATCH) { - printk("\nVOYAGER: countdown timer value too high (%d), resetting\n\n", val); + if (val > LATCH) { + printk + ("\nVOYAGER: countdown timer value too high (%d), resetting\n\n", + val); spin_lock(&i8253_lock); - outb(0x34,0x43); - outb_p(LATCH & 0xff , 0x40); /* LSB */ - outb(LATCH >> 8 , 0x40); /* MSB */ + outb(0x34, 0x43); + outb_p(LATCH & 0xff, 0x40); /* LSB */ + outb(LATCH >> 8, 0x40); /* MSB */ spin_unlock(&i8253_lock); } } @@ -206,14 +203,13 @@ voyager_timer_interrupt(void) #endif } -void -voyager_power_off(void) +void voyager_power_off(void) { printk("VOYAGER Power Off\n"); - if(voyager_level == 5) { + if (voyager_level == 5) { voyager_cat_power_off(); - } else if(voyager_level == 4) { + } else if (voyager_level == 4) { /* This doesn't apparently work on most L4 machines, * but the specs say to do this to get automatic power * off. Unfortunately, if it doesn't power off the @@ -222,10 +218,8 @@ voyager_power_off(void) #if 0 int port; - /* enable the voyager Configuration Space */ - outb((inb(VOYAGER_MC_SETUP) & 0xf0) | 0x8, - VOYAGER_MC_SETUP); + outb((inb(VOYAGER_MC_SETUP) & 0xf0) | 0x8, VOYAGER_MC_SETUP); /* the port for the power off flag is an offset from the floating base */ port = (inb(VOYAGER_SSPB_RELOCATION_PORT) << 8) + 0x21; @@ -235,62 +229,57 @@ voyager_power_off(void) } /* and wait for it to happen */ local_irq_disable(); - for(;;) + for (;;) halt(); } /* copied from process.c */ -static inline void -kb_wait(void) +static inline void kb_wait(void) { int i; - for (i=0; i<0x10000; i++) + for (i = 0; i < 0x10000; i++) if ((inb_p(0x64) & 0x02) == 0) break; } -void -machine_shutdown(void) +void machine_shutdown(void) { /* Architecture specific shutdown needed before a kexec */ } -void -machine_restart(char *cmd) +void machine_restart(char *cmd) { printk("Voyager Warm Restart\n"); kb_wait(); - if(voyager_level == 5) { + if (voyager_level == 5) { /* write magic values to the RTC to inform system that * shutdown is beginning */ outb(0x8f, 0x70); - outb(0x5 , 0x71); - + outb(0x5, 0x71); + udelay(50); - outb(0xfe,0x64); /* pull reset low */ - } else if(voyager_level == 4) { - __u16 catbase = inb(VOYAGER_SSPB_RELOCATION_PORT)<<8; + outb(0xfe, 0x64); /* pull reset low */ + } else if (voyager_level == 4) { + __u16 catbase = inb(VOYAGER_SSPB_RELOCATION_PORT) << 8; __u8 basebd = inb(VOYAGER_MC_SETUP); - + outb(basebd | 0x08, VOYAGER_MC_SETUP); outb(0x02, catbase + 0x21); } local_irq_disable(); - for(;;) + for (;;) halt(); } -void -machine_emergency_restart(void) +void machine_emergency_restart(void) { /*for now, just hook this to a warm restart */ machine_restart(NULL); } -void -mca_nmi_hook(void) +void mca_nmi_hook(void) { __u8 dumpval __maybe_unused = inb(0xf823); __u8 swnmi __maybe_unused = inb(0xf813); @@ -301,8 +290,8 @@ mca_nmi_hook(void) /* clear swnmi */ outb(0xff, 0xf813); /* tell SUS to ignore dump */ - if(voyager_level == 5 && voyager_SUS != NULL) { - if(voyager_SUS->SUS_mbox == VOYAGER_DUMP_BUTTON_NMI) { + if (voyager_level == 5 && voyager_SUS != NULL) { + if (voyager_SUS->SUS_mbox == VOYAGER_DUMP_BUTTON_NMI) { voyager_SUS->kernel_mbox = VOYAGER_NO_COMMAND; voyager_SUS->kernel_flags |= VOYAGER_OS_IN_PROGRESS; udelay(1000); @@ -310,15 +299,14 @@ mca_nmi_hook(void) voyager_SUS->kernel_flags &= ~VOYAGER_OS_IN_PROGRESS; } } - printk(KERN_ERR "VOYAGER: Dump switch pressed, printing CPU%d tracebacks\n", smp_processor_id()); + printk(KERN_ERR + "VOYAGER: Dump switch pressed, printing CPU%d tracebacks\n", + smp_processor_id()); show_stack(NULL, NULL); show_state(); } - - -void -machine_halt(void) +void machine_halt(void) { /* treat a halt like a power off */ machine_power_off(); diff --git a/arch/x86/mach-voyager/voyager_cat.c b/arch/x86/mach-voyager/voyager_cat.c index 2132ca652df..17a7904f75b 100644 --- a/arch/x86/mach-voyager/voyager_cat.c +++ b/arch/x86/mach-voyager/voyager_cat.c @@ -39,34 +39,32 @@ #define CAT_DATA (sspb + 0xd) /* the internal cat functions */ -static void cat_pack(__u8 *msg, __u16 start_bit, __u8 *data, - __u16 num_bits); -static void cat_unpack(__u8 *msg, __u16 start_bit, __u8 *data, +static void cat_pack(__u8 * msg, __u16 start_bit, __u8 * data, __u16 num_bits); +static void cat_unpack(__u8 * msg, __u16 start_bit, __u8 * data, __u16 num_bits); -static void cat_build_header(__u8 *header, const __u16 len, +static void cat_build_header(__u8 * header, const __u16 len, const __u16 smallest_reg_bits, const __u16 longest_reg_bits); -static int cat_sendinst(voyager_module_t *modp, voyager_asic_t *asicp, +static int cat_sendinst(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, __u8 op); -static int cat_getdata(voyager_module_t *modp, voyager_asic_t *asicp, - __u8 reg, __u8 *value); -static int cat_shiftout(__u8 *data, __u16 data_bytes, __u16 header_bytes, +static int cat_getdata(voyager_module_t * modp, voyager_asic_t * asicp, + __u8 reg, __u8 * value); +static int cat_shiftout(__u8 * data, __u16 data_bytes, __u16 header_bytes, __u8 pad_bits); -static int cat_write(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, +static int cat_write(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, __u8 value); -static int cat_read(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, - __u8 *value); -static int cat_subread(voyager_module_t *modp, voyager_asic_t *asicp, +static int cat_read(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, + __u8 * value); +static int cat_subread(voyager_module_t * modp, voyager_asic_t * asicp, __u16 offset, __u16 len, void *buf); -static int cat_senddata(voyager_module_t *modp, voyager_asic_t *asicp, +static int cat_senddata(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, __u8 value); -static int cat_disconnect(voyager_module_t *modp, voyager_asic_t *asicp); -static int cat_connect(voyager_module_t *modp, voyager_asic_t *asicp); +static int cat_disconnect(voyager_module_t * modp, voyager_asic_t * asicp); +static int cat_connect(voyager_module_t * modp, voyager_asic_t * asicp); -static inline const char * -cat_module_name(int module_id) +static inline const char *cat_module_name(int module_id) { - switch(module_id) { + switch (module_id) { case 0x10: return "Processor Slot 0"; case 0x11: @@ -105,14 +103,14 @@ voyager_module_t *voyager_cat_list; /* the I/O port assignments for the VIC and QIC */ static struct resource vic_res = { - .name = "Voyager Interrupt Controller", - .start = 0xFC00, - .end = 0xFC6F + .name = "Voyager Interrupt Controller", + .start = 0xFC00, + .end = 0xFC6F }; static struct resource qic_res = { - .name = "Quad Interrupt Controller", - .start = 0xFC70, - .end = 0xFCFF + .name = "Quad Interrupt Controller", + .start = 0xFC70, + .end = 0xFCFF }; /* This function is used to pack a data bit stream inside a message. @@ -120,7 +118,7 @@ static struct resource qic_res = { * Note: This function assumes that any unused bit in the data stream * is set to zero so that the ors will work correctly */ static void -cat_pack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits) +cat_pack(__u8 * msg, const __u16 start_bit, __u8 * data, const __u16 num_bits) { /* compute initial shift needed */ const __u16 offset = start_bit % BITS_PER_BYTE; @@ -130,7 +128,7 @@ cat_pack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits) int i; /* adjust if we have more than a byte of residue */ - if(residue >= BITS_PER_BYTE) { + if (residue >= BITS_PER_BYTE) { residue -= BITS_PER_BYTE; len++; } @@ -138,24 +136,25 @@ cat_pack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits) /* clear out the bits. We assume here that if len==0 then * residue >= offset. This is always true for the catbus * operations */ - msg[byte] &= 0xff << (BITS_PER_BYTE - offset); + msg[byte] &= 0xff << (BITS_PER_BYTE - offset); msg[byte++] |= data[0] >> offset; - if(len == 0) + if (len == 0) return; - for(i = 1; i < len; i++) - msg[byte++] = (data[i-1] << (BITS_PER_BYTE - offset)) - | (data[i] >> offset); - if(residue != 0) { + for (i = 1; i < len; i++) + msg[byte++] = (data[i - 1] << (BITS_PER_BYTE - offset)) + | (data[i] >> offset); + if (residue != 0) { __u8 mask = 0xff >> residue; - __u8 last_byte = data[i-1] << (BITS_PER_BYTE - offset) - | (data[i] >> offset); - + __u8 last_byte = data[i - 1] << (BITS_PER_BYTE - offset) + | (data[i] >> offset); + last_byte &= ~mask; msg[byte] &= mask; msg[byte] |= last_byte; } return; } + /* unpack the data again (same arguments as cat_pack()). data buffer * must be zero populated. * @@ -163,7 +162,7 @@ cat_pack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits) * data (starting at bit 0 in data). */ static void -cat_unpack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits) +cat_unpack(__u8 * msg, const __u16 start_bit, __u8 * data, const __u16 num_bits) { /* compute initial shift needed */ const __u16 offset = start_bit % BITS_PER_BYTE; @@ -172,97 +171,97 @@ cat_unpack(__u8 *msg, const __u16 start_bit, __u8 *data, const __u16 num_bits) __u16 byte = start_bit / BITS_PER_BYTE; int i; - if(last_bits != 0) + if (last_bits != 0) len++; /* special case: want < 8 bits from msg and we can get it from * a single byte of the msg */ - if(len == 0 && BITS_PER_BYTE - offset >= num_bits) { + if (len == 0 && BITS_PER_BYTE - offset >= num_bits) { data[0] = msg[byte] << offset; data[0] &= 0xff >> (BITS_PER_BYTE - num_bits); return; } - for(i = 0; i < len; i++) { + for (i = 0; i < len; i++) { /* this annoying if has to be done just in case a read of * msg one beyond the array causes a panic */ - if(offset != 0) { + if (offset != 0) { data[i] = msg[byte++] << offset; data[i] |= msg[byte] >> (BITS_PER_BYTE - offset); - } - else { + } else { data[i] = msg[byte++]; } } /* do we need to truncate the final byte */ - if(last_bits != 0) { - data[i-1] &= 0xff << (BITS_PER_BYTE - last_bits); + if (last_bits != 0) { + data[i - 1] &= 0xff << (BITS_PER_BYTE - last_bits); } return; } static void -cat_build_header(__u8 *header, const __u16 len, const __u16 smallest_reg_bits, +cat_build_header(__u8 * header, const __u16 len, const __u16 smallest_reg_bits, const __u16 longest_reg_bits) { int i; __u16 start_bit = (smallest_reg_bits - 1) % BITS_PER_BYTE; __u8 *last_byte = &header[len - 1]; - if(start_bit == 0) + if (start_bit == 0) start_bit = 1; /* must have at least one bit in the hdr */ - - for(i=0; i < len; i++) + + for (i = 0; i < len; i++) header[i] = 0; - for(i = start_bit; i > 0; i--) + for (i = start_bit; i > 0; i--) *last_byte = ((*last_byte) << 1) + 1; } static int -cat_sendinst(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, __u8 op) +cat_sendinst(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, __u8 op) { __u8 parity, inst, inst_buf[4] = { 0 }; __u8 iseq[VOYAGER_MAX_SCAN_PATH], hseq[VOYAGER_MAX_REG_SIZE]; __u16 ibytes, hbytes, padbits; int i; - + /* * Parity is the parity of the register number + 1 (READ_REGISTER * and WRITE_REGISTER always add '1' to the number of bits == 1) */ - parity = (__u8)(1 + (reg & 0x01) + - ((__u8)(reg & 0x02) >> 1) + - ((__u8)(reg & 0x04) >> 2) + - ((__u8)(reg & 0x08) >> 3)) % 2; + parity = (__u8) (1 + (reg & 0x01) + + ((__u8) (reg & 0x02) >> 1) + + ((__u8) (reg & 0x04) >> 2) + + ((__u8) (reg & 0x08) >> 3)) % 2; inst = ((parity << 7) | (reg << 2) | op); outb(VOYAGER_CAT_IRCYC, CAT_CMD); - if(!modp->scan_path_connected) { - if(asicp->asic_id != VOYAGER_CAT_ID) { - printk("**WARNING***: cat_sendinst has disconnected scan path not to CAT asic\n"); + if (!modp->scan_path_connected) { + if (asicp->asic_id != VOYAGER_CAT_ID) { + printk + ("**WARNING***: cat_sendinst has disconnected scan path not to CAT asic\n"); return 1; } outb(VOYAGER_CAT_HEADER, CAT_DATA); outb(inst, CAT_DATA); - if(inb(CAT_DATA) != VOYAGER_CAT_HEADER) { + if (inb(CAT_DATA) != VOYAGER_CAT_HEADER) { CDEBUG(("VOYAGER CAT: cat_sendinst failed to get CAT_HEADER\n")); return 1; } return 0; } ibytes = modp->inst_bits / BITS_PER_BYTE; - if((padbits = modp->inst_bits % BITS_PER_BYTE) != 0) { + if ((padbits = modp->inst_bits % BITS_PER_BYTE) != 0) { padbits = BITS_PER_BYTE - padbits; ibytes++; } hbytes = modp->largest_reg / BITS_PER_BYTE; - if(modp->largest_reg % BITS_PER_BYTE) + if (modp->largest_reg % BITS_PER_BYTE) hbytes++; CDEBUG(("cat_sendinst: ibytes=%d, hbytes=%d\n", ibytes, hbytes)); /* initialise the instruction sequence to 0xff */ - for(i=0; i < ibytes + hbytes; i++) + for (i = 0; i < ibytes + hbytes; i++) iseq[i] = 0xff; cat_build_header(hseq, hbytes, modp->smallest_reg, modp->largest_reg); cat_pack(iseq, modp->inst_bits, hseq, hbytes * BITS_PER_BYTE); @@ -271,11 +270,11 @@ cat_sendinst(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, __u8 op) cat_pack(iseq, asicp->bit_location, inst_buf, asicp->ireg_length); #ifdef VOYAGER_CAT_DEBUG printk("ins = 0x%x, iseq: ", inst); - for(i=0; i< ibytes + hbytes; i++) + for (i = 0; i < ibytes + hbytes; i++) printk("0x%x ", iseq[i]); printk("\n"); #endif - if(cat_shiftout(iseq, ibytes, hbytes, padbits)) { + if (cat_shiftout(iseq, ibytes, hbytes, padbits)) { CDEBUG(("VOYAGER CAT: cat_sendinst: cat_shiftout failed\n")); return 1; } @@ -284,72 +283,74 @@ cat_sendinst(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, __u8 op) } static int -cat_getdata(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, - __u8 *value) +cat_getdata(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, + __u8 * value) { - if(!modp->scan_path_connected) { - if(asicp->asic_id != VOYAGER_CAT_ID) { + if (!modp->scan_path_connected) { + if (asicp->asic_id != VOYAGER_CAT_ID) { CDEBUG(("VOYAGER CAT: ERROR: cat_getdata to CAT asic with scan path connected\n")); return 1; } - if(reg > VOYAGER_SUBADDRHI) + if (reg > VOYAGER_SUBADDRHI) outb(VOYAGER_CAT_RUN, CAT_CMD); outb(VOYAGER_CAT_DRCYC, CAT_CMD); outb(VOYAGER_CAT_HEADER, CAT_DATA); *value = inb(CAT_DATA); outb(0xAA, CAT_DATA); - if(inb(CAT_DATA) != VOYAGER_CAT_HEADER) { + if (inb(CAT_DATA) != VOYAGER_CAT_HEADER) { CDEBUG(("cat_getdata: failed to get VOYAGER_CAT_HEADER\n")); return 1; } return 0; - } - else { - __u16 sbits = modp->num_asics -1 + asicp->ireg_length; + } else { + __u16 sbits = modp->num_asics - 1 + asicp->ireg_length; __u16 sbytes = sbits / BITS_PER_BYTE; __u16 tbytes; - __u8 string[VOYAGER_MAX_SCAN_PATH], trailer[VOYAGER_MAX_REG_SIZE]; + __u8 string[VOYAGER_MAX_SCAN_PATH], + trailer[VOYAGER_MAX_REG_SIZE]; __u8 padbits; int i; - + outb(VOYAGER_CAT_DRCYC, CAT_CMD); - if((padbits = sbits % BITS_PER_BYTE) != 0) { + if ((padbits = sbits % BITS_PER_BYTE) != 0) { padbits = BITS_PER_BYTE - padbits; sbytes++; } tbytes = asicp->ireg_length / BITS_PER_BYTE; - if(asicp->ireg_length % BITS_PER_BYTE) + if (asicp->ireg_length % BITS_PER_BYTE) tbytes++; CDEBUG(("cat_getdata: tbytes = %d, sbytes = %d, padbits = %d\n", - tbytes, sbytes, padbits)); + tbytes, sbytes, padbits)); cat_build_header(trailer, tbytes, 1, asicp->ireg_length); - - for(i = tbytes - 1; i >= 0; i--) { + for (i = tbytes - 1; i >= 0; i--) { outb(trailer[i], CAT_DATA); string[sbytes + i] = inb(CAT_DATA); } - for(i = sbytes - 1; i >= 0; i--) { + for (i = sbytes - 1; i >= 0; i--) { outb(0xaa, CAT_DATA); string[i] = inb(CAT_DATA); } *value = 0; - cat_unpack(string, padbits + (tbytes * BITS_PER_BYTE) + asicp->asic_location, value, asicp->ireg_length); + cat_unpack(string, + padbits + (tbytes * BITS_PER_BYTE) + + asicp->asic_location, value, asicp->ireg_length); #ifdef VOYAGER_CAT_DEBUG printk("value=0x%x, string: ", *value); - for(i=0; i< tbytes+sbytes; i++) + for (i = 0; i < tbytes + sbytes; i++) printk("0x%x ", string[i]); printk("\n"); #endif - + /* sanity check the rest of the return */ - for(i=0; i < tbytes; i++) { + for (i = 0; i < tbytes; i++) { __u8 input = 0; - cat_unpack(string, padbits + (i * BITS_PER_BYTE), &input, BITS_PER_BYTE); - if(trailer[i] != input) { + cat_unpack(string, padbits + (i * BITS_PER_BYTE), + &input, BITS_PER_BYTE); + if (trailer[i] != input) { CDEBUG(("cat_getdata: failed to sanity check rest of ret(%d) 0x%x != 0x%x\n", i, input, trailer[i])); return 1; } @@ -360,14 +361,14 @@ cat_getdata(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, } static int -cat_shiftout(__u8 *data, __u16 data_bytes, __u16 header_bytes, __u8 pad_bits) +cat_shiftout(__u8 * data, __u16 data_bytes, __u16 header_bytes, __u8 pad_bits) { int i; - - for(i = data_bytes + header_bytes - 1; i >= header_bytes; i--) + + for (i = data_bytes + header_bytes - 1; i >= header_bytes; i--) outb(data[i], CAT_DATA); - for(i = header_bytes - 1; i >= 0; i--) { + for (i = header_bytes - 1; i >= 0; i--) { __u8 header = 0; __u8 input; @@ -376,7 +377,7 @@ cat_shiftout(__u8 *data, __u16 data_bytes, __u16 header_bytes, __u8 pad_bits) CDEBUG(("cat_shiftout: returned 0x%x\n", input)); cat_unpack(data, ((data_bytes + i) * BITS_PER_BYTE) - pad_bits, &header, BITS_PER_BYTE); - if(input != header) { + if (input != header) { CDEBUG(("VOYAGER CAT: cat_shiftout failed to return header 0x%x != 0x%x\n", input, header)); return 1; } @@ -385,57 +386,57 @@ cat_shiftout(__u8 *data, __u16 data_bytes, __u16 header_bytes, __u8 pad_bits) } static int -cat_senddata(voyager_module_t *modp, voyager_asic_t *asicp, +cat_senddata(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, __u8 value) { outb(VOYAGER_CAT_DRCYC, CAT_CMD); - if(!modp->scan_path_connected) { - if(asicp->asic_id != VOYAGER_CAT_ID) { + if (!modp->scan_path_connected) { + if (asicp->asic_id != VOYAGER_CAT_ID) { CDEBUG(("VOYAGER CAT: ERROR: scan path disconnected when asic != CAT\n")); return 1; } outb(VOYAGER_CAT_HEADER, CAT_DATA); outb(value, CAT_DATA); - if(inb(CAT_DATA) != VOYAGER_CAT_HEADER) { + if (inb(CAT_DATA) != VOYAGER_CAT_HEADER) { CDEBUG(("cat_senddata: failed to get correct header response to sent data\n")); return 1; } - if(reg > VOYAGER_SUBADDRHI) { + if (reg > VOYAGER_SUBADDRHI) { outb(VOYAGER_CAT_RUN, CAT_CMD); outb(VOYAGER_CAT_END, CAT_CMD); outb(VOYAGER_CAT_RUN, CAT_CMD); } - + return 0; - } - else { + } else { __u16 hbytes = asicp->ireg_length / BITS_PER_BYTE; - __u16 dbytes = (modp->num_asics - 1 + asicp->ireg_length)/BITS_PER_BYTE; - __u8 padbits, dseq[VOYAGER_MAX_SCAN_PATH], - hseq[VOYAGER_MAX_REG_SIZE]; + __u16 dbytes = + (modp->num_asics - 1 + asicp->ireg_length) / BITS_PER_BYTE; + __u8 padbits, dseq[VOYAGER_MAX_SCAN_PATH], + hseq[VOYAGER_MAX_REG_SIZE]; int i; - if((padbits = (modp->num_asics - 1 - + asicp->ireg_length) % BITS_PER_BYTE) != 0) { + if ((padbits = (modp->num_asics - 1 + + asicp->ireg_length) % BITS_PER_BYTE) != 0) { padbits = BITS_PER_BYTE - padbits; dbytes++; } - if(asicp->ireg_length % BITS_PER_BYTE) + if (asicp->ireg_length % BITS_PER_BYTE) hbytes++; - + cat_build_header(hseq, hbytes, 1, asicp->ireg_length); - - for(i = 0; i < dbytes + hbytes; i++) + + for (i = 0; i < dbytes + hbytes; i++) dseq[i] = 0xff; CDEBUG(("cat_senddata: dbytes=%d, hbytes=%d, padbits=%d\n", dbytes, hbytes, padbits)); cat_pack(dseq, modp->num_asics - 1 + asicp->ireg_length, hseq, hbytes * BITS_PER_BYTE); - cat_pack(dseq, asicp->asic_location, &value, + cat_pack(dseq, asicp->asic_location, &value, asicp->ireg_length); #ifdef VOYAGER_CAT_DEBUG printk("dseq "); - for(i=0; i<hbytes+dbytes; i++) { + for (i = 0; i < hbytes + dbytes; i++) { printk("0x%x ", dseq[i]); } printk("\n"); @@ -445,121 +446,125 @@ cat_senddata(voyager_module_t *modp, voyager_asic_t *asicp, } static int -cat_write(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, - __u8 value) +cat_write(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, __u8 value) { - if(cat_sendinst(modp, asicp, reg, VOYAGER_WRITE_CONFIG)) + if (cat_sendinst(modp, asicp, reg, VOYAGER_WRITE_CONFIG)) return 1; return cat_senddata(modp, asicp, reg, value); } static int -cat_read(voyager_module_t *modp, voyager_asic_t *asicp, __u8 reg, - __u8 *value) +cat_read(voyager_module_t * modp, voyager_asic_t * asicp, __u8 reg, + __u8 * value) { - if(cat_sendinst(modp, asicp, reg, VOYAGER_READ_CONFIG)) + if (cat_sendinst(modp, asicp, reg, VOYAGER_READ_CONFIG)) return 1; return cat_getdata(modp, asicp, reg, value); } static int -cat_subaddrsetup(voyager_module_t *modp, voyager_asic_t *asicp, __u16 offset, +cat_subaddrsetup(voyager_module_t * modp, voyager_asic_t * asicp, __u16 offset, __u16 len) { __u8 val; - if(len > 1) { + if (len > 1) { /* set auto increment */ __u8 newval; - - if(cat_read(modp, asicp, VOYAGER_AUTO_INC_REG, &val)) { + + if (cat_read(modp, asicp, VOYAGER_AUTO_INC_REG, &val)) { CDEBUG(("cat_subaddrsetup: read of VOYAGER_AUTO_INC_REG failed\n")); return 1; } - CDEBUG(("cat_subaddrsetup: VOYAGER_AUTO_INC_REG = 0x%x\n", val)); + CDEBUG(("cat_subaddrsetup: VOYAGER_AUTO_INC_REG = 0x%x\n", + val)); newval = val | VOYAGER_AUTO_INC; - if(newval != val) { - if(cat_write(modp, asicp, VOYAGER_AUTO_INC_REG, val)) { + if (newval != val) { + if (cat_write(modp, asicp, VOYAGER_AUTO_INC_REG, val)) { CDEBUG(("cat_subaddrsetup: write to VOYAGER_AUTO_INC_REG failed\n")); return 1; } } } - if(cat_write(modp, asicp, VOYAGER_SUBADDRLO, (__u8)(offset &0xff))) { + if (cat_write(modp, asicp, VOYAGER_SUBADDRLO, (__u8) (offset & 0xff))) { CDEBUG(("cat_subaddrsetup: write to SUBADDRLO failed\n")); return 1; } - if(asicp->subaddr > VOYAGER_SUBADDR_LO) { - if(cat_write(modp, asicp, VOYAGER_SUBADDRHI, (__u8)(offset >> 8))) { + if (asicp->subaddr > VOYAGER_SUBADDR_LO) { + if (cat_write + (modp, asicp, VOYAGER_SUBADDRHI, (__u8) (offset >> 8))) { CDEBUG(("cat_subaddrsetup: write to SUBADDRHI failed\n")); return 1; } cat_read(modp, asicp, VOYAGER_SUBADDRHI, &val); - CDEBUG(("cat_subaddrsetup: offset = %d, hi = %d\n", offset, val)); + CDEBUG(("cat_subaddrsetup: offset = %d, hi = %d\n", offset, + val)); } cat_read(modp, asicp, VOYAGER_SUBADDRLO, &val); CDEBUG(("cat_subaddrsetup: offset = %d, lo = %d\n", offset, val)); return 0; } - + static int -cat_subwrite(voyager_module_t *modp, voyager_asic_t *asicp, __u16 offset, - __u16 len, void *buf) +cat_subwrite(voyager_module_t * modp, voyager_asic_t * asicp, __u16 offset, + __u16 len, void *buf) { int i, retval; /* FIXME: need special actions for VOYAGER_CAT_ID here */ - if(asicp->asic_id == VOYAGER_CAT_ID) { + if (asicp->asic_id == VOYAGER_CAT_ID) { CDEBUG(("cat_subwrite: ATTEMPT TO WRITE TO CAT ASIC\n")); /* FIXME -- This is supposed to be handled better * There is a problem writing to the cat asic in the * PSI. The 30us delay seems to work, though */ udelay(30); } - - if((retval = cat_subaddrsetup(modp, asicp, offset, len)) != 0) { + + if ((retval = cat_subaddrsetup(modp, asicp, offset, len)) != 0) { printk("cat_subwrite: cat_subaddrsetup FAILED\n"); return retval; } - - if(cat_sendinst(modp, asicp, VOYAGER_SUBADDRDATA, VOYAGER_WRITE_CONFIG)) { + + if (cat_sendinst + (modp, asicp, VOYAGER_SUBADDRDATA, VOYAGER_WRITE_CONFIG)) { printk("cat_subwrite: cat_sendinst FAILED\n"); return 1; } - for(i = 0; i < len; i++) { - if(cat_senddata(modp, asicp, 0xFF, ((__u8 *)buf)[i])) { - printk("cat_subwrite: cat_sendata element at %d FAILED\n", i); + for (i = 0; i < len; i++) { + if (cat_senddata(modp, asicp, 0xFF, ((__u8 *) buf)[i])) { + printk + ("cat_subwrite: cat_sendata element at %d FAILED\n", + i); return 1; } } return 0; } static int -cat_subread(voyager_module_t *modp, voyager_asic_t *asicp, __u16 offset, +cat_subread(voyager_module_t * modp, voyager_asic_t * asicp, __u16 offset, __u16 len, void *buf) { int i, retval; - if((retval = cat_subaddrsetup(modp, asicp, offset, len)) != |