diff options
| author | David S. Miller <davem@kernel.bkbits.net> | 2004-07-01 07:12:53 -0700 |
|---|---|---|
| committer | David S. Miller <davem@kernel.bkbits.net> | 2004-07-01 07:12:53 -0700 |
| commit | bf5c4064091ffbdc2a958f7c3cbff0b400382e63 (patch) | |
| tree | d68f8042e426154b21db76be09fa98938cf39149 | |
| parent | 90d90ae3132f22bf526745d913c41448250165e3 (diff) | |
| parent | fbd7fa39d68c3828f324e556e3f61e462282021c (diff) | |
Merge davem@nuts.davemloft.net:/disk1/BK/net-2.6
into kernel.bkbits.net:/home/davem/net-2.6
174 files changed, 3009 insertions, 739 deletions
diff --git a/arch/arm/mach-pxa/generic.h b/arch/arm/mach-pxa/generic.h index 0534d175617a..f542ef4e7e38 100644 --- a/arch/arm/mach-pxa/generic.h +++ b/arch/arm/mach-pxa/generic.h @@ -13,6 +13,8 @@ extern void __init pxa_map_io(void); extern void __init pxa_init_irq(void); extern void __init pxa_init_time(void); +extern unsigned int get_clk_frequency_khz(int info); + #define SET_BANK(__nr,__start,__size) \ mi->bank[__nr].start = (__start), \ mi->bank[__nr].size = (__size), \ diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index 5b1c89ea512c..155b5950e8b7 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c @@ -171,9 +171,10 @@ static struct pxafb_mach_info toshiba_ltm035a776c __initdata = { static void __init mainstone_init(void) { - platform_add_device(&smc91x_device); + platform_device_register(&smc91x_device); - /* reading the BSR might be handy to select LCD type here */ + /* reading Mainstone's "Virtual Configuration Register" + might be handy to select LCD type here */ if (0) set_pxa_fb_info(&toshiba_ltm04c380k); else diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index f5edc775fe6a..e54aefaa8e0d 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -141,7 +141,7 @@ char *__acpi_map_table(unsigned long phys, unsigned long size) idx = FIX_ACPI_END; while (mapped_size < size) { if (--idx < FIX_ACPI_BEGIN) - return 0; /* cannot handle this */ + return NULL; /* cannot handle this */ phys += PAGE_SIZE; set_fixmap(idx, phys); mapped_size += PAGE_SIZE; @@ -560,7 +560,7 @@ extern u32 pmtmr_ioport; static int __init acpi_parse_fadt(unsigned long phys, unsigned long size) { - struct fadt_descriptor_rev2 *fadt =0; + struct fadt_descriptor_rev2 *fadt = NULL; fadt = (struct fadt_descriptor_rev2*) __acpi_map_table(phys,size); if(!fadt) { diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c index fc991989284b..efd5dc817128 100644 --- a/arch/i386/kernel/i8259.c +++ b/arch/i386/kernel/i8259.c @@ -345,7 +345,7 @@ void __init init_ISA_irqs (void) for (i = 0; i < NR_IRQS; i++) { irq_desc[i].status = IRQ_DISABLED; - irq_desc[i].action = 0; + irq_desc[i].action = NULL; irq_desc[i].depth = 1; if (i < 16) { diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c index ba2055a3959b..7f52bc0d079f 100644 --- a/arch/i386/kernel/irq.c +++ b/arch/i386/kernel/irq.c @@ -1094,7 +1094,7 @@ void init_irq_proc (void) int i; /* create /proc/irq */ - root_irq_dir = proc_mkdir("irq", 0); + root_irq_dir = proc_mkdir("irq", NULL); /* create /proc/irq/prof_cpu_mask */ entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir); diff --git a/arch/i386/kernel/ldt.c b/arch/i386/kernel/ldt.c index c07c21df769d..038d30034a80 100644 --- a/arch/i386/kernel/ldt.c +++ b/arch/i386/kernel/ldt.c @@ -61,7 +61,7 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload) load_LDT(pc); mask = cpumask_of_cpu(smp_processor_id()); if (!cpus_equal(current->mm->cpu_vm_mask, mask)) - smp_call_function(flush_ldt, 0, 1, 1); + smp_call_function(flush_ldt, NULL, 1, 1); preempt_enable(); #else load_LDT(pc); diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c index c8936c4e5de7..87b966248ac4 100644 --- a/arch/i386/kernel/reboot.c +++ b/arch/i386/kernel/reboot.c @@ -88,8 +88,8 @@ static struct unsigned long long * base __attribute__ ((packed)); } real_mode_gdt = { sizeof (real_mode_gdt_entries) - 1, real_mode_gdt_entries }, -real_mode_idt = { 0x3ff, 0 }, -no_idt = { 0, 0 }; +real_mode_idt = { 0x3ff, NULL }, +no_idt = { 0, NULL }; /* This is 16-bit protected mode code to disable paging and the cache, @@ -266,7 +266,7 @@ void machine_restart(char * __unused) if (!reboot_thru_bios) { if (efi_enabled) { - efi.reset_system(EFI_RESET_COLD, EFI_SUCCESS, 0, 0); + efi.reset_system(EFI_RESET_COLD, EFI_SUCCESS, 0, NULL); __asm__ __volatile__("lidt %0": :"m" (no_idt)); __asm__ __volatile__("int3"); } @@ -280,7 +280,7 @@ void machine_restart(char * __unused) } } if (efi_enabled) - efi.reset_system(EFI_RESET_WARM, EFI_SUCCESS, 0, 0); + efi.reset_system(EFI_RESET_WARM, EFI_SUCCESS, 0, NULL); machine_real_restart(jump_to_bios, sizeof(jump_to_bios)); } @@ -296,7 +296,7 @@ EXPORT_SYMBOL(machine_halt); void machine_power_off(void) { if (efi_enabled) - efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, 0); + efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); if (pm_power_off) pm_power_off(); } diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index 00d812090938..375fd076159d 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c @@ -1204,7 +1204,7 @@ static struct nop { } noptypes[] = { { X86_FEATURE_K8, k8_nops }, { X86_FEATURE_K7, k7_nops }, - { -1, 0 } + { -1, NULL } }; /* Replace instructions with better alternatives for this CPU type. diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c index 5e3ac93253d2..bb5960134f67 100644 --- a/arch/i386/kernel/smp.c +++ b/arch/i386/kernel/smp.c @@ -463,7 +463,7 @@ static void do_flush_tlb_all(void* info) void flush_tlb_all(void) { - on_each_cpu(do_flush_tlb_all, 0, 1, 1); + on_each_cpu(do_flush_tlb_all, NULL, 1, 1); } /* diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 27bda2a137d5..1a9b08190492 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c @@ -82,6 +82,7 @@ int smp_threads_ready; extern unsigned char trampoline_data []; extern unsigned char trampoline_end []; static unsigned char *trampoline_base; +static int trampoline_exec; /* * Currently trivial. Write the real->protected mode @@ -108,6 +109,10 @@ void __init smp_alloc_memory(void) */ if (__pa(trampoline_base) >= 0x9F000) BUG(); + /* + * Make the SMP trampoline executable: + */ + trampoline_exec = set_kernel_exec((unsigned long)trampoline_base, 1); } /* @@ -1375,6 +1380,10 @@ void __init smp_cpus_done(unsigned int max_cpus) setup_ioapic_dest(); #endif zap_low_mappings(); + /* + * Disable executability of the SMP trampoline: + */ + set_kernel_exec((unsigned long)trampoline_base, trampoline_exec); } void __init smp_intr_init(void) diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c index 1dcef3d47641..a4f5a20a263f 100644 --- a/arch/i386/kernel/vm86.c +++ b/arch/i386/kernel/vm86.c @@ -732,8 +732,8 @@ static inline void free_vm86_irq(int irqnumber) { unsigned long flags; - free_irq(irqnumber,0); - vm86_irqs[irqnumber].tsk = 0; + free_irq(irqnumber, NULL); + vm86_irqs[irqnumber].tsk = NULL; spin_lock_irqsave(&irqbits_lock, flags); irqbits &= ~(1 << irqnumber); @@ -783,7 +783,7 @@ static int do_vm86_irq_handling(int subfunction, int irqnumber) if (!((1 << sig) & ALLOWED_SIGS)) return -EPERM; if (invalid_vm86_irq(irq)) return -EPERM; if (vm86_irqs[irq].tsk) return -EPERM; - ret = request_irq(irq, &irq_handler, 0, VM86_IRQNAME, 0); + ret = request_irq(irq, &irq_handler, 0, VM86_IRQNAME, NULL); if (ret) return ret; vm86_irqs[irq].sig = sig; vm86_irqs[irq].tsk = current; diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c index f8661fd97303..d492599dac6a 100644 --- a/arch/i386/mm/init.c +++ b/arch/i386/mm/init.c @@ -455,6 +455,33 @@ static void __init set_nx(void) } } +/* + * Enables/disables executability of a given kernel page and + * returns the previous setting. + */ +int __init set_kernel_exec(unsigned long vaddr, int enable) +{ + pte_t *pte; + int ret = 1; + + if (!nx_enabled) + goto out; + + pte = lookup_address(vaddr); + BUG_ON(!pte); + + if (pte_val(*pte) & _PAGE_NX) + ret = 0; + + if (enable) + pte->pte_high &= ~(1 << (_PAGE_BIT_NX - 32)); + else + pte->pte_high |= 1 << (_PAGE_BIT_NX - 32); + __flush_tlb_all(); +out: + return ret; +} + #endif /* diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c index af7c60285237..8eb95be7d771 100644 --- a/arch/i386/mm/pageattr.c +++ b/arch/i386/mm/pageattr.c @@ -17,7 +17,7 @@ static spinlock_t cpa_lock = SPIN_LOCK_UNLOCKED; static struct list_head df_list = LIST_HEAD_INIT(df_list); -static inline pte_t *lookup_address(unsigned long address) +pte_t *lookup_address(unsigned long address) { pgd_t *pgd = pgd_offset_k(address); pmd_t *pmd; diff --git a/arch/i386/oprofile/op_model_p4.c b/arch/i386/oprofile/op_model_p4.c index 8b932b1b3f14..e92eaed25f1b 100644 --- a/arch/i386/oprofile/op_model_p4.c +++ b/arch/i386/oprofile/op_model_p4.c @@ -464,7 +464,7 @@ static void pmc_setup_one_p4_counter(unsigned int ctr) unsigned int escr = 0; unsigned int high = 0; unsigned int counter_bit; - struct p4_event_binding * ev = 0; + struct p4_event_binding *ev = NULL; unsigned int stag; stag = get_stagger(); diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/namespace/nsalloc.c index f7a216c2f6d5..c9dd49ff74bc 100644 --- a/drivers/acpi/namespace/nsalloc.c +++ b/drivers/acpi/namespace/nsalloc.c @@ -496,14 +496,14 @@ acpi_ns_delete_namespace_subtree ( /* Check if this node has any children */ - if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, 0)) { + if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { /* * There is at least one child of this node, * visit the node */ level++; parent_node = child_node; - child_node = 0; + child_node = NULL; } } else { diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/namespace/nsload.c index 07754849692b..314ec6659a72 100644 --- a/drivers/acpi/namespace/nsload.c +++ b/drivers/acpi/namespace/nsload.c @@ -352,7 +352,7 @@ acpi_ns_delete_subtree ( parent_handle = start_handle; - child_handle = 0; + child_handle = NULL; level = 1; /* @@ -373,14 +373,14 @@ acpi_ns_delete_subtree ( /* Check if this object has any children */ if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle, - 0, &dummy))) { + NULL, &dummy))) { /* * There is at least one child of this object, * visit the object */ level++; parent_handle = child_handle; - child_handle = 0; + child_handle = NULL; } } else { diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/namespace/nswalk.c index 130d0c0061a9..5482e74de036 100644 --- a/drivers/acpi/namespace/nswalk.c +++ b/drivers/acpi/namespace/nswalk.c @@ -183,7 +183,7 @@ acpi_ns_walk_namespace ( /* Null child means "get first node" */ parent_node = start_node; - child_node = 0; + child_node = NULL; child_type = ACPI_TYPE_ANY; level = 1; @@ -258,14 +258,14 @@ acpi_ns_walk_namespace ( * maximum depth has been reached. */ if ((level < max_depth) && (status != AE_CTRL_DEPTH)) { - if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, 0)) { + if (acpi_ns_get_next_node (ACPI_TYPE_ANY, child_node, NULL)) { /* * There is at least one child of this * node, visit the onde */ level++; parent_node = child_node; - child_node = 0; + child_node = NULL; } } } diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 8f3557bd124d..be148f4898cd 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -101,7 +101,7 @@ acpi_bus_get_power_flags ( struct acpi_device *device) { acpi_status status = 0; - acpi_handle handle = 0; + acpi_handle handle = NULL; u32 i = 0; ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags"); @@ -799,8 +799,8 @@ static int acpi_bus_scan (struct acpi_device *start) acpi_status status = AE_OK; struct acpi_device *parent = NULL; struct acpi_device *child = NULL; - acpi_handle phandle = 0; - acpi_handle chandle = 0; + acpi_handle phandle = NULL; + acpi_handle chandle = NULL; acpi_object_type type = 0; u32 level = 1; @@ -843,7 +843,7 @@ static int acpi_bus_scan (struct acpi_device *start) if (type == ACPI_TYPE_LOCAL_SCOPE) { level++; phandle = chandle; - chandle = 0; + chandle = NULL; continue; } @@ -883,11 +883,11 @@ static int acpi_bus_scan (struct acpi_device *start) */ if (child->status.present) { status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, - 0, NULL); + NULL, NULL); if (ACPI_SUCCESS(status)) { level++; phandle = chandle; - chandle = 0; + chandle = NULL; parent = child; } } diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 892184a9e25d..f686992ebcec 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -92,7 +92,7 @@ acpi_system_read_dsdt ( { acpi_status status = AE_OK; struct acpi_buffer dsdt = {ACPI_ALLOCATE_BUFFER, NULL}; - void *data = 0; + void *data = NULL; size_t size = 0; ACPI_FUNCTION_TRACE("acpi_system_read_dsdt"); @@ -135,7 +135,7 @@ acpi_system_read_fadt ( { acpi_status status = AE_OK; struct acpi_buffer fadt = {ACPI_ALLOCATE_BUFFER, NULL}; - void *data = 0; + void *data = NULL; size_t size = 0; ACPI_FUNCTION_TRACE("acpi_system_read_fadt"); diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index a1844bc88311..e7480822b0f7 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c @@ -286,7 +286,7 @@ acpi_get_table_header_early ( *header = (void *) __acpi_map_table(fadt->V1_dsdt, sizeof(struct acpi_table_header)); } else - *header = 0; + *header = NULL; if (!*header) { printk(KERN_WARNING PREFIX "Unable to map DSDT\n"); diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c index bbbf06643be8..55cdd46f5e50 100644 --- a/drivers/base/dmapool.c +++ b/drivers/base/dmapool.c @@ -110,7 +110,7 @@ dma_pool_create (const char *name, struct device *dev, if (align == 0) align = 1; if (size == 0) - return 0; + return NULL; else if (size < align) size = align; else if ((size % align) != 0) { @@ -125,7 +125,7 @@ dma_pool_create (const char *name, struct device *dev, allocation = PAGE_SIZE; // FIXME: round up for less fragmentation } else if (allocation < size) - return 0; + return NULL; if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL))) return retval; @@ -167,7 +167,7 @@ pool_alloc_page (struct dma_pool *pool, int mem_flags) page = (struct dma_page *) kmalloc (mapsize + sizeof *page, mem_flags); if (!page) - return 0; + return NULL; page->vaddr = dma_alloc_coherent (pool->dev, pool->allocation, &page->dma, @@ -181,7 +181,7 @@ pool_alloc_page (struct dma_pool *pool, int mem_flags) page->in_use = 0; } else { kfree (page); - page = 0; + page = NULL; } return page; } @@ -302,7 +302,7 @@ restart: remove_wait_queue (&pool->waitq, &wait); goto restart; } - retval = 0; + retval = NULL; goto done; } @@ -334,7 +334,7 @@ pool_find_page (struct dma_pool *pool, dma_addr_t dma) if (dma < (page->dma + pool->allocation)) goto done; } - page = 0; + page = NULL; done: spin_unlock_irqrestore (&pool->lock, flags); return page; diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c index 3b8059af629b..c32652db8593 100644 --- a/drivers/block/cfq-iosched.c +++ b/drivers/block/cfq-iosched.c @@ -196,7 +196,7 @@ __cfq_add_crq_rb(struct cfq_queue *cfqq, struct cfq_rq *crq) } rb_link_node(&crq->rb_node, parent, p); - return 0; + return NULL; } static void diff --git a/drivers/block/deadline-iosched.c b/drivers/block/deadline-iosched.c index 317e7db70489..fb7ab733c709 100644 --- a/drivers/block/deadline-iosched.c +++ b/drivers/block/deadline-iosched.c @@ -205,7 +205,7 @@ __deadline_add_drq_rb(struct deadline_data *dd, struct deadline_rq *drq) } rb_link_node(&drq->rb_node, parent, p); - return 0; + return NULL; } static void diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 70375a056fa1..b55c97d60d46 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -922,7 +922,7 @@ static inline void unlock_fdc(void) { unsigned long flags; - raw_cmd = 0; + raw_cmd = NULL; if (!test_bit(0, &fdc_busy)) DPRINT("FDC access conflict!\n"); @@ -2021,7 +2021,7 @@ static void floppy_start(void) static void do_wakeup(void) { reschedule_timeout(MAXTIMEOUT, "do wakeup", 0); - cont = 0; + cont = NULL; command_status += 2; wake_up(&command_done); } @@ -3191,7 +3191,7 @@ static void raw_cmd_free(struct floppy_raw_cmd **ptr) struct floppy_raw_cmd *next, *this; this = *ptr; - *ptr = 0; + *ptr = NULL; while (this) { if (this->buffer_length) { fd_dma_mem_free((unsigned long)this->kernel_data, @@ -3211,7 +3211,7 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, int ret; int i; - *rcmd = 0; + *rcmd = NULL; while (1) { ptr = (struct floppy_raw_cmd *) kmalloc(sizeof(struct floppy_raw_cmd), GFP_USER); @@ -3219,7 +3219,7 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, return -ENOMEM; *rcmd = ptr; COPYIN(*ptr); - ptr->next = 0; + ptr->next = NULL; ptr->buffer_length = 0; param += sizeof(struct floppy_raw_cmd); if (ptr->cmd_count > 33) @@ -3236,7 +3236,7 @@ static inline int raw_cmd_copyin(int cmd, char __user *param, for (i = 0; i < 16; i++) ptr->reply[i] = 0; ptr->resultcode = 0; - ptr->kernel_data = 0; + ptr->kernel_data = NULL; if (ptr->flags & (FD_RAW_READ | FD_RAW_WRITE)) { if (ptr->length <= 0) @@ -4125,32 +4125,32 @@ static struct param_table { int def_param; int param2; } config_params[] = { - {"allowed_drive_mask", 0, &allowed_drive_mask, 0xff, 0}, /* obsolete */ - {"all_drives", 0, &allowed_drive_mask, 0xff, 0}, /* obsolete */ - {"asus_pci", 0, &allowed_drive_mask, 0x33, 0}, - {"irq", 0, &FLOPPY_IRQ, 6, 0}, - {"dma", 0, &FLOPPY_DMA, 2, 0}, - {"daring", daring, 0, 1, 0}, + {"allowed_drive_mask", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */ + {"all_drives", NULL, &allowed_drive_mask, 0xff, 0}, /* obsolete */ + {"asus_pci", NULL, &allowed_drive_mask, 0x33, 0}, + {"irq", NULL, &FLOPPY_IRQ, 6, 0}, + {"dma", NULL, &FLOPPY_DMA, 2, 0}, + {"daring", daring, NULL, 1, 0}, #if N_FDC > 1 - {"two_fdc", 0, &FDC2, 0x370, 0}, - {"one_fdc", 0, &FDC2, 0, 0}, + {"two_fdc", NULL, &FDC2, 0x370, 0}, + {"one_fdc", NULL, &FDC2, 0, 0}, #endif - {"thinkpad", floppy_set_flags, 0, 1, FD_INVERTED_DCL}, - {"broken_dcl", floppy_set_flags, 0, 1, FD_BROKEN_DCL}, - {"messages", floppy_set_flags, 0, 1, FTD_MSG}, - {"silent_dcl_clear", floppy_set_flags, 0, 1, FD_SILENT_DCL_CLEAR}, - {"debug", floppy_set_flags, 0, 1, FD_DEBUG}, - {"nodma", 0, &can_use_virtual_dma, 1, 0}, - {"omnibook", 0, &can_use_virtual_dma, 1, 0}, - {"yesdma", 0, &can_use_virtual_dma, 0, 0}, - {"fifo_depth", 0, &fifo_depth, 0xa, 0}, - {"nofifo", 0, &no_fifo, 0x20, 0}, - {"usefifo", 0, &no_fifo, 0, 0}, - {"cmos", set_cmos, 0, 0, 0}, - {"slow", 0, &slow_floppy, 1, 0}, - {"unexpected_interrupts", 0, &print_unex, 1, 0}, - {"no_unexpected_interrupts", 0, &print_unex, 0, 0}, - {"L40SX", 0, &print_unex, 0, 0} + {"thinkpad", floppy_set_flags, NULL, 1, FD_INVERTED_DCL}, + {"broken_dcl", floppy_set_flags, NULL, 1, FD_BROKEN_DCL}, + {"messages", floppy_set_flags, NULL, 1, FTD_MSG}, + {"silent_dcl_clear", floppy_set_flags, NULL, 1, FD_SILENT_DCL_CLEAR}, + {"debug", floppy_set_flags, NULL, 1, FD_DEBUG}, + {"nodma", NULL, &can_use_virtual_dma, 1, 0}, + {"omnibook", NULL, &can_use_virtual_dma, 1, 0}, + {"yesdma", NULL, &can_use_virtual_dma, 0, 0}, + {"fifo_depth", NULL, &fifo_depth, 0xa, 0}, + {"nofifo", NULL, &no_fifo, 0x20, 0}, + {"usefifo", NULL, &no_fifo, 0, 0}, + {"cmos", set_cmos, NULL, 0, 0}, + {"slow", NULL, &slow_floppy, 1, 0}, + {"unexpected_interrupts", NULL, &print_unex, 1, 0}, + {"no_unexpected_interrupts", NULL, &print_unex, 0, 0}, + {"L40SX", NULL, &print_unex, 0, 0} EXTRA_FLOPPY_PARAMS }; diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c index 2c849532fb63..00a5bfa133b2 100644 --- a/drivers/block/genhd.c +++ b/drivers/block/genhd.c @@ -90,7 +90,7 @@ int register_blkdev(unsigned int major, const char *name) p->major = major; strlcpy(p->name, name, sizeof(p->name)); - p->next = 0; + p->next = NULL; index = major_to_index(major); spin_lock_irqsave(&major_names_lock, flags); diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index eb0f062c3ce2..cd67fcddf394 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c @@ -901,6 +901,7 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) goto err; if (cdrom_open_write(cdi)) goto err; + ret = 0; } } diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig index f438b076261f..58b117bdaa95 100644 --- a/drivers/char/agp/Kconfig +++ b/drivers/char/agp/Kconfig @@ -165,7 +165,7 @@ config AGP_EFFICEON tristate "Transmeta Efficeon support" depends on AGP && X86 && !X86_64 help - This option fives you AGP support for the Transmeta Efficeon + This option gives you AGP support for the Transmeta Efficeon series processors with integrated northbridges. You should say Y here if you use XFree86 3.3.6 or 4.x and want to diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 06a7ef269ef1..18c38420fad1 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c @@ -536,6 +536,15 @@ static struct pci_device_id agp_amd64_pci_table[] = { .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, }, + /* VIA K8T800Pro */ + { + .class = (PCI_CLASS_BRIDGE_HOST << 8), + .class_mask = ~0, + .vendor = PCI_VENDOR_ID_VIA, + .device = PCI_DEVICE_ID_VIA_K8T800PRO_0, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + }, /* VIA K8T800 */ { .class = (PCI_CLASS_BRIDGE_HOST << 8), diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index ba6c102d26ac..f65662437461 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c @@ -1,6 +1,6 @@ /* * AGPGART driver. - * Copyright (C) 2002-2003 Dave Jones. + * Copyright (C) 2002-2004 Dave Jones. * Copyright (C) 1999 Jeff Hartmann. * Copyright (C) 1999 Precision Insight, Inc. * Copyright (C) 1999 Xi Graphics, Inc. @@ -18,12 +18,12 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE + * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * TODO: + * TODO: * - Allocate more than order 0 pages to avoid too much linear map splitting. */ #include <linux/config.h> @@ -37,7 +37,7 @@ #include <linux/vmalloc.h> #include "agp.h" -__u32 *agp_gatt_table; +__u32 *agp_gatt_table; int agp_memory_reserved; /* @@ -46,7 +46,7 @@ int agp_memory_reserved; */ EXPORT_SYMBOL_GPL(agp_memory_reserved); -/* +/* * Generic routines for handling agp_memory structures - * They use the basic page allocation routines to do the brunt of the work. */ @@ -142,12 +142,12 @@ EXPORT_SYMBOL(agp_free_memory); * agp_allocate_memory - allocate a group of pages of a certain type. * * @page_count: size_t argument of the number of pages - * @type: u32 argument of the type of memory to be allocated. + * @type: u32 argument of the type of memory to be allocated. * * Every agp bridge device will allow you to allocate AGP_NORMAL_MEMORY which * maps to physical ram. Any other type is device dependent. * - * It returns NULL whenever memory is unavailable. + * It returns NULL whenever memory is unavailable. */ struct agp_memory *agp_allocate_memory(size_t page_count, u32 type) { @@ -311,7 +311,7 @@ EXPORT_SYMBOL(agp_copy_info); /** * agp_bind_memory - Bind an agp_memory structure into the GATT. - * + * * @curr: agp_memory pointer * @pg_start: an offset into the graphics aperture translation table * @@ -347,9 +347,9 @@ EXPORT_SYMBOL(agp_bind_memory); /** * agp_unbind_memory - Removes an agp_memory structure from the GATT - * + * * @curr: agp_memory pointer to be removed from the GATT. - * + * * It returns -EINVAL if this piece of agp_memory is not currently bound to * the graphics aperture translation table or if the agp_memory pointer == NULL */ @@ -404,12 +404,18 @@ static void agp_v2_parse_one(u32 *mode, u32 *cmd, u32 *tmp) *cmd &= ~(AGPSTAT2_1X | AGPSTAT2_4X); /* 2X */ if (*cmd & AGPSTAT2_1X) - *cmd &= ~(AGPSTAT2_2X | AGPSTAT2_4X); /* 1Xf */ + *cmd &= ~(AGPSTAT2_2X | AGPSTAT2_4X); /* 1X */ } - +/* + * mode = requested mode. + * cmd = PCI_AGP_STATUS from agp bridge. + * tmp = PCI_AGP_STATUS from graphic card. + */ static void agp_v3_parse_one(u32 *mode, u32 *cmd, u32 *tmp) { + u32 origcmd=*cmd, origtmp=*tmp; + /* ARQSZ - Set the value to the maximum one. * Don't allow the mode register to override values. */ *cmd = ((*cmd & ~AGPSTAT_ARQSZ) | @@ -452,17 +458,43 @@ static void agp_v3_parse_one(u32 *mode, u32 *cmd, u32 *tmp) *mode |= AGPSTAT3_4X; } - if (!((*cmd & AGPSTAT3_8X) && (*tmp & AGPSTAT3_8X) && (*mode & AGPSTAT3_8X))) - *cmd &= ~AGPSTAT3_8X; + if (*mode & AGPSTAT3_8X) { + if (!(*cmd & AGPSTAT3_8X)) { + *cmd &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); + *cmd |= AGPSTAT3_4X; + printk ("%s requested AGPx8 but bridge not capable.\n", current->comm); + return; + } + if (!(*tmp & AGPSTAT3_8X)) { + *cmd &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); + *cmd |= AGPSTAT3_4X; + printk ("%s requested AGPx8 but graphic card not capable.\n", current->comm); + return; + } + /* All set, bridge & device can do AGP x8*/ + *cmd &= ~(AGPSTAT3_4X | AGPSTAT3_RSVD); + return; - if (!((*cmd & AGPSTAT3_4X) && (*tmp & AGPSTAT3_4X) && (*mode & AGPSTAT3_4X))) - *cmd &= ~AGPSTAT3_4X; + } else { - /* Clear out unwanted bits. */ - if (*cmd & AGPSTAT3_8X) - *cmd &= ~(AGPSTAT3_4X | AGPSTAT3_RSVD); - if (*cmd & AGPSTAT3_4X) + /* + * If we didn't specify AGPx8, we can only do x4. + * If the hardware can't do x4, we're up shit creek, and never + * should have got this far. + */ *cmd &= ~(AGPSTAT3_8X | AGPSTAT3_RSVD); + if ((*cmd & AGPSTAT3_4X) && (*tmp & AGPSTAT3_4X)) + *cmd |= AGPSTAT3_4X; + else { + printk (KERN_INFO PFX "Badness. Don't know which AGP mode to set. " + "[cmd:%x tmp:%x fell back to:- cmd:%x tmp:%x]\n", + origcmd, origtmp, *cmd, *tmp); + if (!(*cmd & AGPSTAT3_4X)) + printk (KERN_INFO PFX "Bridge couldn't do AGP x4.\n"); + if (!(*tmp & AGPSTAT3_4X)) + printk (KERN_INFO PFX "Graphic card couldn't do AGP x4.\n"); + } + } } //FIXME: This doesn't smell right. @@ -479,8 +511,10 @@ u32 agp_collect_device_status(u32 mode, u32 cmd) if (!cap_ptr) continue; + //FIXME: We should probably skip anything here that + // isn't an AGP graphic card. /* - * Ok, here we have a AGP device. Disable impossible + * Ok, here we have a AGP device. Disable impossible * settings, and adjust the readqueue to the minimum. */ pci_read_config_dword(device, cap_ptr+PCI_AGP_STATUS, &tmp); @@ -489,7 +523,7 @@ u32 agp_collect_device_status(u32 mode, u32 cmd) cmd = ((cmd & ~AGPSTAT_RQ_DEPTH) | min_t(u32, (mode & AGPSTAT_RQ_DEPTH), min_t(u32, (cmd & AGPSTAT_RQ_DEPTH), (tmp & AGPSTAT_RQ_DEPTH)))); - + /* disable FW if it's not supported */ if (!((cmd & AGPSTAT_FW) && (tmp & AGPSTAT_FW) && (mode & AGPSTAT_FW))) cmd &= ~AGPSTAT_FW; @@ -663,7 +697,7 @@ int agp_generic_create_gatt_table(void) agp_bridge->current_size; break; } - temp = agp_bridge->current_size; + temp = agp_bridge->current_size; } else { agp_bridge->aperture_size_idx = i; } @@ -684,7 +718,7 @@ int agp_generic_create_gatt_table(void) SetPageReserved(page); agp_bridge->gatt_table_real = (u32 *) table; - agp_gatt_table = (void *)table; + agp_gatt_table = (void *)table; agp_bridge->driver->cache_flush(); agp_bridge->gatt_table = ioremap_nocache(virt_to_phys(table), @@ -870,9 +904,9 @@ void agp_generic_free_by_type(struct agp_memory *curr) EXPORT_SYMBOL(agp_generic_free_by_type); -/* +/* * Basic Page Allocation Routines - - * These routines handle page allocation and by default they reserve the allocated + * These routines handle page allocation and by default they reserve the allocated * memory. They also handle incrementing the current_memory_agp value, Which is checked * against a maximum value. */ @@ -883,7 +917,7 @@ void *agp_generic_alloc_page(void) page = alloc_page(GFP_KERNEL); if (page == NULL) - return 0; + return NULL; map_page_into_agp(page); @@ -914,9 +948,9 @@ EXPORT_SYMBOL(agp_generic_destroy_page); /* End Basic Page Allocation Routines */ -/** +/** * agp_enable - initialise the agp point-to-point connection. - * + * * @mode: agp mode register value to configure with. */ void agp_enable(u32 mode) diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index f8b991673465..5aa162a537f2 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c @@ -369,7 +369,7 @@ static int intel_i830_create_gatt_table(void) size = agp_bridge->current_size; page_order = size->page_order; num_entries = size->num_entries; - agp_bridge->gatt_table_real = 0; + agp_bridge->gatt_table_real = NULL; pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp); temp &= 0xfff80000; diff --git a/drivers/char/agp/intel-mch-agp.c b/drivers/char/agp/intel-mch-agp.c index dff4d9933861..c8f230acc5cf 100644 --- a/drivers/char/agp/intel-mch-agp.c +++ b/drivers/char/agp/intel-mch-agp.c @@ -167,7 +167,7 @@ static int intel_i830_create_gatt_table(void) size = agp_bridge->current_size; page_order = size->page_order; num_entries = size->num_entries; - agp_bridge->gatt_table_real = 0; + agp_bridge->gatt_table_real = NULL; pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp); temp &= 0xfff80000; diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index d3f3e80ff317..44e11acbcad7 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c @@ -447,6 +447,7 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, struct agp_bridge_data *bridge; struct pci_dev *bridge_dev; u32 temp, temp2; + u8 cap_ptr = 0; /* Everything is on func 1 here so we are hardcoding function one */ bridge_dev = pci_find_slot((unsigned int)pdev->bus->number, @@ -457,6 +458,8 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, return -ENODEV; } + cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); + switch (pdev->device) { case 0x0006: /* ServerWorks CNB20HE @@ -470,14 +473,15 @@ static int __devinit agp_serverworks_probe(struct pci_dev *pdev, break; default: - printk(KERN_ERR PFX "Unsupported Serverworks chipset " - "(device id: %04x)\n", pdev->device); + if (cap_ptr) + printk(KERN_ERR PFX "Unsupported Serverworks chipset " + "(device id: %04x)\n", pdev->device); return -ENODEV; } serverworks_private.svrwrks_dev = bridge_dev; serverworks_private.gart_addr_ofs = 0x10; - + pci_read_config_dword(pdev, SVWRKS_APSIZE, &temp); if (temp & PCI_BASE_ADDRESS_MEM_TYPE_64) { pci_read_config_dword(pdev, SVWRKS_APSIZE + 4, &temp2); diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c index 2f5c50c29b09..a36c4977700a 100644 --- a/drivers/char/agp/via-agp.c +++ b/drivers/char/agp/via-agp.c @@ -434,6 +434,7 @@ static struct pci_device_id agp_via_pci_table[] = { .subvendor = PCI_ANY_ID, \ .subdevice = PCI_ANY_ID, \ } + ID(PCI_DEVICE_ID_VIA_82C597_0), ID(PCI_DEVICE_ID_VIA_82C598_0), ID(PCI_DEVICE_ID_VIA_8501_0), ID(PCI_DEVICE_ID_VIA_8601_0), diff --git a/drivers/char/defkeymap.c_shipped b/drivers/char/defkeymap.c_shipped index d8ac176c251d..453a2f1ffa15 100644 --- a/drivers/char/defkeymap.c_shipped +++ b/drivers/char/defkeymap.c_shipped @@ -139,10 +139,10 @@ u_short ctrl_alt_map[NR_KEYS] = { }; ushort *key_maps[MAX_NR_KEYMAPS] = { - plain_map, shift_map, altgr_map, 0, - ctrl_map, shift_ctrl_map, 0, 0, - alt_map, 0, 0, 0, - ctrl_alt_map, 0 + plain_map, shift_map, altgr_map, NULL, + ctrl_map, shift_ctrl_map, NULL, NULL, + alt_map, NULL, NULL, NULL, + ctrl_alt_map, NULL }; unsigned int keymap_count = 7; @@ -216,10 +216,10 @@ char *func_table[MAX_NR_FUNC] = { func_buf + 135, func_buf + 140, func_buf + 145, - 0, - 0, + NULL, + NULL, func_buf + 149, - 0, + NULL, }; struct kbdiacr accent_table[MAX_DIACR] = { diff --git a/drivers/char/drm/drm_dma.h b/drivers/char/drm/drm_dma.h index f0230ebeca4c..453da8238d92 100644 --- a/drivers/char/drm/drm_dma.h +++ b/drivers/char/drm/drm_dma.h @@ -152,7 +152,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf) buf->waiting = 0; buf->pending = 0; - buf->filp = 0; + buf->filp = NULL; buf->used = 0; if ( __HAVE_DMA_WAITQUEUE && waitqueue_active(&buf->dma_wait)) { diff --git a/drivers/char/drm/drm_lock.h b/drivers/char/drm/drm_lock.h index 3288996efa30..55fb29f39d3e 100644 --- a/drivers/char/drm/drm_lock.h +++ b/drivers/char/drm/drm_lock.h @@ -95,7 +95,7 @@ int DRM(lock_transfer)(drm_device_t *dev, { unsigned int old, new, prev; - dev->lock.filp = 0; + dev->lock.filp = NULL; do { old = *lock; new = context | _DRM_LOCK_HELD; @@ -120,7 +120,7 @@ int DRM(lock_free)(drm_device_t *dev, { unsigned int old, new, prev; - dev->lock.filp = 0; + dev->lock.filp = NULL; do { old = *lock; new = 0; diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c index 86c4e4204f4c..5beb845a414e 100644 --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c @@ -171,7 +171,7 @@ static int i830_map_buffer(drm_buf_t *buf, struct file *filp) /* Real error */ DRM_ERROR("mmap error\n"); retcode = PTR_ERR(buf_priv->virtual); - buf_priv->virtual = 0; + buf_priv->virtual = NULL; } up_write( ¤t->mm->mmap_sem ); @@ -193,7 +193,7 @@ static int i830_unmap_buffer(drm_buf_t *buf) up_write(¤t->mm->mmap_sem); buf_priv->currently_mapped = I830_BUF_UNMAPPED; - buf_priv->virtual = 0; + buf_priv->virtual = NULL; return retcode; } diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index 9382646e8547..bac378dad6c6 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c @@ -903,7 +903,7 @@ static void n_tty_close(struct tty_struct *tty) n_tty_flush_buffer(tty); if (tty->read_buf) { free_buf(tty->read_buf); - tty->read_buf = 0; + tty->read_buf = NULL; } } @@ -920,7 +920,7 @@ static int n_tty_open(struct tty_struct *tty) memset(tty->read_buf, 0, N_TTY_BUF_SIZE); reset_buffer_flags(tty); tty->column = 0; - n_tty_set_termios(tty, 0); + n_tty_set_termios(tty, NULL); tty->minimum_to_wake = 1; tty->closing = 0; return 0; diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 4cea8c05c81b..fcbb325477e4 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c @@ -144,14 +144,14 @@ static int pty_write(struct tty_struct * tty, int from_user, buf += n; c += n; count -= n; - to->ldisc.receive_buf(to, temp_buffer, 0, n); + to->ldisc.receive_buf(to, temp_buffer, NULL, n); } up(&tty->flip.pty_sem); } else { c = to->ldisc.receive_room(to); if (c > count) c = count; - to->ldisc.receive_buf(to, buf, 0, c); + to->ldisc.receive_buf(to, buf, NULL, c); } return c; diff --git a/drivers/char/selection.c b/drivers/char/selection.c index f08fd792088a..598f6011050d 100644 --- a/drivers/char/selection.c +++ b/drivers/char/selection.c @@ -296,7 +296,7 @@ int paste_selection(struct tty_struct *tty) } count = sel_buffer_lth - pasted; count = MIN(count, tty->ldisc.receive_room(tty)); - tty->ldisc.receive_buf(tty, sel_buffer + pasted, 0, count); + tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count); pasted += count; } remove_wait_queue(&vt->paste_wait, &wait); diff --git a/drivers/char/vt.c b/drivers/char/vt.c index b4f93acec508..de3af3b991b3 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -2498,7 +2498,7 @@ static void con_close(struct tty_struct *tty, struct file *filp) vt = tty->driver_data; if (vt) vc_cons[vt->vc_num].d->vc_tty = NULL; - tty->driver_data = 0; + tty->driver_data = NULL; release_console_sem(); vcs_remove_devfs(tty); up(&tty_sem); diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c index 2cd1770ebc26..bf05ec6c1d3d 100644 --- a/drivers/char/vt_ioctl.c +++ b/drivers/char/vt_ioctl.c @@ -100,7 +100,7 @@ do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm, struct kbd_str /* disallocate map */ key_map = key_maps[s]; if (s && key_map) { - key_maps[s] = 0; + key_maps[s] = NULL; if (key_map[0] == U(K_ALLOCATED)) { kfree(key_map); keymap_count--; diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 19ae46dc0dc1..6ed4de8a58e3 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -100,7 +100,7 @@ static const struct drive_list_entry drive_whitelist [] = { { "CONNER CTMA 4000" , "ALL" }, { "CONNER CTT8000-A" , "ALL" }, { "ST34342A" , "ALL" }, - { 0 , 0 } + { NULL , NULL } }; static const struct drive_list_entry drive_blacklist [] = { @@ -138,7 +138,7 @@ static const struct drive_list_entry drive_blacklist [] = { { "PLEXTOR CD-R PX-W8432T", "ALL" }, { "ATAPI CD-ROM DRIVE 40X MAXIMUM", "ALL" }, { "_NEC DV5800A", "ALL" }, - { 0 , 0 } + { NULL , NULL } }; diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index b7e5cb8166a6..a3ebd9e127e0 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c @@ -790,5 +790,5 @@ void proc_ide_destroy(void) { remove_proc_entry("ide/drivers", proc_ide_root); destroy_proc_ide_interfaces(); - remove_proc_entry("ide", 0); + remove_proc_entry("ide", NULL); } diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 2714aa1a3e4a..2bdb860e03c3 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -2320,7 +2320,7 @@ int __init ide_init (void) init_ide_data(); #ifdef CONFIG_PROC_FS - proc_ide_root = proc_mkdir("ide", 0); + proc_ide_root = proc_mkdir("ide", NULL); #endif #ifdef CONFIG_BLK_DEV_ALI14XX diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index c912be4b2dc4..cc9c999f9a8b 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -1075,7 +1075,7 @@ do { \ #undef PUT_ENVP - envp[i] = 0; + envp[i] = NULL; return 0; } diff --git a/drivers/input/input.c b/drivers/input/input.c index 73b17418a1b9..416084b8065a 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -369,7 +369,7 @@ static void input_call_hotplug(char *verb, struct input_dev *dev) argv[0] = hotplug_path; argv[1] = "input"; - argv[2] = 0; + argv[2] = NULL; envp[i++] = "HOME=/"; envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; @@ -402,7 +402,7 @@ static void input_call_hotplug(char *verb, struct input_dev *dev) SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND); SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF); - envp[i++] = 0; + envp[i++] = NULL; #ifdef INPUT_DEBUG printk(KERN_DEBUG "input.c: calling %s %s [%s %s %s %s %s]\n", diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 843e9b83d6d2..92792bb7d1cb 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -602,7 +602,7 @@ static int recover(struct mirror_set *ms, struct region *reg) { int r; unsigned int i; - struct io_region from, to[ms->nr_mirrors - 1], *dest; + struct io_region from, to[KCOPYD_MAX_REGIONS], *dest; struct mirror *m; unsigned long flags = 0; @@ -757,7 +757,7 @@ static void write_callback(unsigned long error, void *context) static void do_write(struct mirror_set *ms, struct bio *bio) { unsigned int i; - struct io_region io[ms->nr_mirrors]; + struct io_region io[KCOPYD_MAX_REGIONS+1]; struct mirror *m; for (i = 0; i < ms->nr_mirrors; i++) { @@ -1028,7 +1028,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) argc -= args_used; if (!argc || sscanf(argv[0], "%u", &nr_mirrors) != 1 || - nr_mirrors < 2) { + nr_mirrors < 2 || nr_mirrors > KCOPYD_MAX_REGIONS + 1) { ti->error = "dm-mirror: Invalid number of mirrors"; dm_destroy_dirty_log(dl); return -EINVAL; diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 80a1901c4e31..01794ed391a2 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -17,11 +17,13 @@ #include <linux/slab.h> static const char *_name = DM_NAME; -#define MAX_DEVICES 1024 static unsigned int major = 0; static unsigned int _major = 0; +static int realloc_minor_bits(unsigned long requested_minor); +static void free_minor_bits(void); + /* * One of these is allocated per bio. */ @@ -111,11 +113,19 @@ static int __init local_init(void) return -ENOMEM; } + r = realloc_minor_bits(1024); + if (r < 0) { + kmem_cache_destroy(_tio_cache); + kmem_cache_destroy(_io_cache); + return r; + } + _major = major; r = register_blkdev(_major, _name); if (r < 0) { kmem_cache_destroy(_tio_cache); kmem_cache_destroy(_io_cache); + free_minor_bits(); return r; } @@ -129,6 +139,7 @@ static void local_exit(void) { kmem_cache_destroy(_tio_cache); kmem_cache_destroy(_io_cache); + free_minor_bits(); if (unregister_blkdev(_major, _name) < 0) DMERR("devfs_unregister_blkdev failed"); @@ -615,14 +626,58 @@ static int dm_any_congested(void *congested_data, int bdi_bits) /*----------------------------------------------------------------- * A bitset is used to keep track of allocated minor numbers. *---------------------------------------------------------------*/ -static spinlock_t _minor_lock = SPIN_LOCK_UNLOCKED; -static unsigned long _minor_bits[MAX_DEVICES / BITS_PER_LONG]; +static DECLARE_MUTEX(_minor_lock); +static unsigned long *_minor_bits = NULL; +static unsigned long _max_minors = 0; + +#define MINORS_SIZE(minors) ((minors / BITS_PER_LONG) * sizeof(unsigned long)) + +static int realloc_minor_bits(unsigned long requested_minor) +{ + unsigned long max_minors; + unsigned long *minor_bits, *tmp; + + if (requested_minor < _max_minors) + return -EINVAL; + + /* Round up the requested minor to the next power-of-2. */ + max_minors = 1 << fls(requested_minor - 1); + if (max_minors > (1 << MINORBITS)) + return -EINVAL; + + minor_bits = kmalloc(MINORS_SIZE(max_minors), GFP_KERNEL); + if (!minor_bits) + return -ENOMEM; + memset(minor_bits, 0, MINORS_SIZE(max_minors)); + + /* Copy the existing bit-set to the new one. */ + if (_minor_bits) + memcpy(minor_bits, _minor_bits, MINORS_SIZE(_max_minors)); + + tmp = _minor_bits; + _minor_bits = minor_bits; + _max_minors = max_minors; + if (tmp) + kfree(tmp); + + return 0; +} + +static void free_minor_bits(void) +{ + down(&_minor_lock); + kfree(_minor_bits); + _minor_bits = NULL; + _max_minors = 0; + up(&_minor_lock); +} static void free_minor(unsigned int minor) { - spin_lock(&_minor_lock); - clear_bit(minor, _minor_bits); - spin_unlock(&_minor_lock); + down(&_minor_lock); + if (minor < _max_minors) + clear_bit(minor, _minor_bits); + up(&_minor_lock); } /* @@ -630,37 +685,48 @@ static void free_minor(unsigned int minor) */ static int specific_minor(unsigned int minor) { - int r = -EBUSY; + int r = 0; - if (minor >= MAX_DEVICES) { - DMWARN("request for a mapped_device beyond MAX_DEVICES (%d)", - MAX_DEVICES); + if (minor > (1 << MINORBITS)) return -EINVAL; + + down(&_minor_lock); + if (minor >= _max_minors) { + r = realloc_minor_bits(minor); + if (r) { + up(&_minor_lock); + return r; + } } - spin_lock(&_minor_lock); - if (!test_and_set_bit(minor, _minor_bits)) - r = 0; - spin_unlock(&_minor_lock); + if (test_and_set_bit(minor, _minor_bits)) + r = -EBUSY; + up(&_minor_lock); return r; } static int next_free_minor(unsigned int *minor) { - int r = -EBUSY; + int r; unsigned int m; - spin_lock(&_minor_lock); - m = find_first_zero_bit(_minor_bits, MAX_DEVICES); - if (m != MAX_DEVICES) { - set_bit(m, _minor_bits); - *minor = m; - r = 0; + down(&_minor_lock); + m = find_first_zero_bit(_minor_bits, _max_minors); + if (m >= _max_minors) { + r = realloc_minor_bits(_max_minors * 2); + if (r) { + up(&_minor_lock); + return r; + } + m = find_first_zero_bit(_minor_bits, _max_minors); } - spin_unlock(&_minor_lock); - return r; + set_bit(m, _minor_bits); + *minor = m; + up(&_minor_lock); + + return 0; } static struct block_device_operations dm_blk_dops; diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c index 40e46944ecb0..8bdf11700ce1 100644 --- a/drivers/md/kcopyd.c +++ b/drivers/md/kcopyd.c @@ -24,9 +24,6 @@ #include "kcopyd.h" -/* FIXME: this is only needed for the DMERR macros */ -#include "dm.h" - static struct workqueue_struct *_kcopyd_wq; static struct work_struct _kcopyd_work; @@ -576,12 +573,11 @@ int kcopyd_cancel(struct kcopyd_job *job, int block) static DECLARE_MUTEX(_client_lock); static LIST_HEAD(_clients); -static int client_add(struct kcopyd_client *kc) +static void client_add(struct kcopyd_client *kc) { down(&_client_lock); list_add(&kc->list, &_clients); up(&_client_lock); - return 0; } static void client_del(struct kcopyd_client *kc) @@ -671,15 +667,7 @@ int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) return r; } - r = client_add(kc); - if (r) { - dm_io_put(nr_pages); - client_free_pages(kc); - kfree(kc); - kcopyd_exit(); - return r; - } - + client_add(kc); *result = kc; return 0; } diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 37ec9ce1c952..6ca911cb9279 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -238,12 +238,6 @@ static int vortex_debug = VORTEX_DEBUG; static int vortex_debug = 1; #endif -#ifndef __OPTIMIZE__ -#error You must compile this file with the correct options! -#error See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 8749b06c6b99..6f53a942039e 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -813,6 +813,24 @@ config ULTRA32 <file:Documentation/networking/net-modules.txt>. The module will be called smc-ultra32. +config SMC91X + tristate "SMC 91C9x/91C1xxx support" + select CRC32 + select MII + depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6) + help + This is a driver for SMC's 91x series of Ethernet chipsets, + including the SMC91C94 and the SMC91C111. Say Y if you want it + compiled into the kernel, and read the file + <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO, + available from <http://www.linuxdoc.org/docs.html#howto>. + + This driver is also available as a module ( = code which can be + inserted in and removed from the running kernel whenever you want). + The module will be called smc91x. If you want to compile it as a + module, say M here and read <file:Documentation/modules.txt> as well + as <file:Documentation/networking/net-modules.txt>. + config SMC9194 tristate "SMC 9194 support" depends on NET_VENDOR_SMC && (ISA || MAC && BROKEN) @@ -883,7 +901,7 @@ source "drivers/net/tulip/Kconfig" config AT1700 tristate "AT1700/1720/RE1000Plus(C-Bus) support (EXPERIMENTAL)" - depends on NET_ETHERNET && (ISA || MCA) && EXPERIMENTAL + depends on NET_ETHERNET && (ISA || MCA_LEGACY) && EXPERIMENTAL select CRC32 ---help--- If you have a network (Ethernet) card of this type, say Y and read @@ -1122,7 +1140,7 @@ config SKMC config NE2_MCA tristate "NE/2 (ne2000 MCA version) support" - depends on NET_ETHERNET && MCA + depends on NET_ETHERNET && MCA_LEGACY select CRC32 help If you have a network (Ethernet) card of this type, say Y and read @@ -1858,6 +1876,8 @@ config NE_H8300 Say Y here if you want to use the NE2000 compatible controller on the Renesas H8/300 processor. +source "drivers/net/fec_8xx/Kconfig" + endmenu # @@ -2577,3 +2597,4 @@ config NETCONSOLE ---help--- If you want to log kernel messages over the network, enable this. See Documentation/networking/netconsole.txt for details. + diff --git a/drivers/net/Makefile b/drivers/net/Makefile index b6ae311ee882..2ae71cf8b4b0 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -175,6 +175,8 @@ obj-$(CONFIG_R8169) += r8169.o obj-$(CONFIG_AMD8111_ETH) += amd8111e.o obj-$(CONFIG_IBMVETH) += ibmveth.o obj-$(CONFIG_S2IO) += s2io.o +obj-$(CONFIG_SMC91X) += smc91x.o +obj-$(CONFIG_FEC_8XX) += fec_8xx/ obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_NET_FC) += fc/ diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c index e17ddb7728b4..b70c2f0ee5f7 100644 --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c @@ -1634,7 +1634,7 @@ static void ace_tasklet(unsigned long dev) cur_size = atomic_read(&ap->cur_rx_bufs); if ((cur_size < RX_LOW_STD_THRES) && !test_and_set_bit(0, &ap->std_refill_busy)) { -#if DEBUG +#ifdef DEBUG printk("refilling buffers (current %i)\n", cur_size); #endif ace_load_std_rx_ring(ap, RX_RING_SIZE - cur_size); @@ -1644,7 +1644,7 @@ static void ace_tasklet(unsigned long dev) cur_size = atomic_read(&ap->cur_mini_bufs); if ((cur_size < RX_LOW_MINI_THRES) && !test_and_set_bit(0, &ap->mini_refill_busy)) { -#if DEBUG +#ifdef DEBUG printk("refilling mini buffers (current %i)\n", cur_size); #endif @@ -1655,7 +1655,7 @@ static void ace_tasklet(unsigned long dev) cur_size = atomic_read(&ap->cur_jumbo_bufs); if (ap->jumbo && (cur_size < RX_LOW_JUMBO_THRES) && !test_and_set_bit(0, &ap->jumbo_refill_busy)) { -#if DEBUG +#ifdef DEBUG printk("refilling jumbo buffers (current %i)\n", cur_size); #endif ace_load_jumbo_rx_ring(ap, RX_JUMBO_SIZE - cur_size); @@ -2255,7 +2255,7 @@ static irqreturn_t ace_interrupt(int irq, void *dev_id, struct pt_regs *ptregs) if (cur_size < RX_LOW_STD_THRES) { if ((cur_size < RX_PANIC_STD_THRES) && !test_and_set_bit(0, &ap->std_refill_busy)) { -#if DEBUG +#ifdef DEBUG printk("low on std buffers %i\n", cur_size); #endif ace_load_std_rx_ring(ap, @@ -2270,7 +2270,7 @@ static irqreturn_t ace_interrupt(int irq, void *dev_id, struct pt_regs *ptregs) if ((cur_size < RX_PANIC_MINI_THRES) && !test_and_set_bit(0, &ap->mini_refill_busy)) { -#if DEBUG +#ifdef DEBUG printk("low on mini buffers %i\n", cur_size); #endif @@ -2286,7 +2286,7 @@ static irqreturn_t ace_interrupt(int irq, void *dev_id, struct pt_regs *ptregs) if ((cur_size < RX_PANIC_JUMBO_THRES) && !test_and_set_bit(0, &ap->jumbo_refill_busy)){ -#if DEBUG +#ifdef DEBUG printk("low on jumbo buffers %i\n", cur_size); #endif diff --git a/drivers/net/arm/Kconfig b/drivers/net/arm/Kconfig index 1ba12ab47284..470364deded0 100644 --- a/drivers/net/arm/Kconfig +++ b/drivers/net/arm/Kconfig @@ -44,21 +44,3 @@ config ARM_ETHER00 will generate a suitable hw address based on the board serial number (MTD support is required for this). Otherwise you will need to set a suitable hw address using ifconfig. - -config SMC91X - tristate "SMC 91C9x/91C1xxx support" - select CRC32 - select MII - depends on ARM - help - This is a driver for SMC's 91x series of Ethernet chipsets, - including the SMC91C94 and the SMC91C111. Say Y if you want it - compiled into the kernel, and read the file - <file:Documentation/networking/smc9.txt> and the Ethernet-HOWTO, - available from <http://www.linuxdoc.org/docs.html#howto>. - - This driver is also available as a module ( = code which can be - inserted in and removed from the running kernel whenever you want). - The module will be called smc91x. If you want to compile it as a - module, say M here and read <file:Documentation/modules.txt> as well - as <file:Documentation/networking/net-modules.txt>. diff --git a/drivers/net/arm/Makefile b/drivers/net/arm/Makefile index d6d87c03ef72..b0d706834d89 100644 --- a/drivers/net/arm/Makefile +++ b/drivers/net/arm/Makefile @@ -8,4 +8,3 @@ obj-$(CONFIG_ARM_ETHER00) += ether00.o obj-$(CONFIG_ARM_ETHERH) += etherh.o obj-$(CONFIG_ARM_ETHER3) += ether3.o obj-$(CONFIG_ARM_ETHER1) += ether1.o -obj-$(CONFIG_SMC91X) += smc91x.o diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c index 56fc87881626..6af982b60397 100644 --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -87,12 +87,6 @@ static int options[] = {-1, -1, -1, -1, -1, -1, -1, -1}; /* Size of an pre-allocated Rx buffer: <Ethernet MTU> + slack.*/ #define PKT_BUF_SZ 1536 -#if !defined(__OPTIMIZE__) || !defined(__KERNEL__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/config.h> #include <linux/version.h> #include <linux/module.h> diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c index e81e0afda6f8..ecf5b8af096b 100644 --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c @@ -116,12 +116,6 @@ static int rx_copybreak; #define TX_FIFO_THRESH 256 #define RX_FIFO_THRESH 1 /* 0-3, 0==32, 64,96, or 3==128 bytes */ -#if !defined(__OPTIMIZE__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/net/fec_8xx/Kconfig b/drivers/net/fec_8xx/Kconfig new file mode 100644 index 000000000000..db36ac3ea453 --- /dev/null +++ b/drivers/net/fec_8xx/Kconfig @@ -0,0 +1,14 @@ +config FEC_8XX + tristate "Motorola 8xx FEC driver" + depends on NET_ETHERNET && 8xx && (NETTA || NETPHONE) + select MII + +config FEC_8XX_GENERIC_PHY + bool "Support any generic PHY" + depends on FEC_8XX + default y + +config FEC_8XX_DM9161_PHY + bool "Support DM9161 PHY" + depends on FEC_8XX + default n diff --git a/drivers/net/fec_8xx/Makefile b/drivers/net/fec_8xx/Makefile new file mode 100644 index 000000000000..70c54f8c48e5 --- /dev/null +++ b/drivers/net/fec_8xx/Makefile @@ -0,0 +1,12 @@ +# +# Makefile for the Motorola 8xx FEC ethernet controller +# + +obj-$(CONFIG_FEC_8XX) += fec_8xx.o + +fec_8xx-objs := fec_main.o fec_mii.o + +# the platform instantatiation objects +ifeq ($(CONFIG_NETTA),y) +fec_8xx-objs += fec_8xx-netta.o +endif diff --git a/drivers/net/fec_8xx/fec_8xx-netta.c b/drivers/net/fec_8xx/fec_8xx-netta.c new file mode 100644 index 000000000000..7d73661aa367 --- /dev/null +++ b/drivers/net/fec_8xx/fec_8xx-netta.c @@ -0,0 +1,153 @@ +/* + * FEC instantatiation file for NETTA + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/string.h> +#include <linux/ptrace.h> +#include <linux/errno.h> +#include <linux/ioport.h> +#include <linux/slab.h> +#include <linux/interrupt.h> +#include <linux/pci.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/skbuff.h> +#include <linux/spinlock.h> +#include <linux/mii.h> +#include <linux/ethtool.h> + +#include <asm/8xx_immap.h> +#include <asm/pgtable.h> +#include <asm/mpc8xx.h> +#include <asm/irq.h> +#include <asm/bitops.h> +#include <asm/uaccess.h> +#include <asm/commproc.h> + +#include "fec_8xx.h" + +/*************************************************/ + +static struct fec_platform_info fec1_info = { + .fec_no = 0, + .use_mdio = 1, + .phy_addr = 8, + .fec_irq = SIU_LEVEL1, + .phy_irq = CPM_IRQ_OFFSET + CPMVEC_PIO_PC6, + .rx_ring = 128, + .tx_ring = 16, + .rx_copybreak = 240, + .use_napi = 1, + .napi_weight = 17, +}; + +static struct fec_platform_info fec2_info = { + .fec_no = 1, + .use_mdio = 1, + .phy_addr = 2, + .fec_irq = SIU_LEVEL3, + .phy_irq = CPM_IRQ_OFFSET + CPMVEC_PIO_PC7, + .rx_ring = 128, + .tx_ring = 16, + .rx_copybreak = 240, + .use_napi = 1, + .napi_weight = 17, +}; + +static struct net_device *fec1_dev; +static struct net_device *fec2_dev; + +/* XXX custom u-boot & Linux startup needed */ +extern const char *__fw_getenv(const char *var); + +/* access ports */ +#define setbits32(_addr, _v) __fec_out32(&(_addr), __fec_in32(&(_addr)) | (_v)) +#define clrbits32(_addr, _v) __fec_out32(&(_addr), __fec_in32(&(_addr)) & ~(_v)) + +#define setbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) | (_v)) +#define clrbits16(_addr, _v) __fec_out16(&(_addr), __fec_in16(&(_addr)) & ~(_v)) + +int fec_8xx_platform_init(void) +{ + immap_t *immap = (immap_t *)IMAP_ADDR; + bd_t *bd = (bd_t *) __res; + const char *s; + char *e; + int i; + + /* use MDC for MII */ + setbits16(immap->im_ioport.iop_pdpar, 0x0080); + clrbits16(immap->im_ioport.iop_pddir, 0x0080); + + /* configure FEC1 pins */ + setbits16(immap->im_ioport.iop_papar, 0xe810); + setbits16(immap->im_ioport.iop_padir, 0x0810); + clrbits16(immap->im_ioport.iop_padir, 0xe000); + + setbits32(immap->im_cpm.cp_pbpar, 0x00000001); + clrbits32(immap->im_cpm.cp_pbdir, 0x00000001); + + setbits32(immap->im_cpm.cp_cptr, 0x00000100); + clrbits32(immap->im_cpm.cp_cptr, 0x00000050); + + clrbits16(immap->im_ioport.iop_pcpar, 0x0200); + clrbits16(immap->im_ioport.iop_pcdir, 0x0200); + clrbits16(immap->im_ioport.iop_pcso, 0x0200); + setbits16(immap->im_ioport.iop_pcint, 0x0200); + + /* configure FEC2 pins */ + setbits32(immap->im_cpm.cp_pepar, 0x00039620); + setbits32(immap->im_cpm.cp_pedir, 0x00039620); + setbits32(immap->im_cpm.cp_peso, 0x00031000); + clrbits32(immap->im_cpm.cp_peso, 0x00008620); + + setbits32(immap->im_cpm.cp_cptr, 0x00000080); + clrbits32(immap->im_cpm.cp_cptr, 0x00000028); + + clrbits16(immap->im_ioport.iop_pcpar, 0x0200); + clrbits16(immap->im_ioport.iop_pcdir, 0x0200); + clrbits16(immap->im_ioport.iop_pcso, 0x0200); + setbits16(immap->im_ioport.iop_pcint, 0x0200); + + /* fill up */ + fec1_info.sys_clk = bd->bi_intfreq; + fec2_info.sys_clk = bd->bi_intfreq; + + s = __fw_getenv("ethaddr"); + if (s != NULL) { + for (i = 0; i < 6; i++) { + fec1_info.macaddr[i] = simple_strtoul(s, &e, 16); + if (*e) + s = e + 1; + } + } + + s = __fw_getenv("eth1addr"); + if (s != NULL) { + for (i = 0; i < 6; i++) { + fec2_info.macaddr[i] = simple_strtoul(s, &e, 16); + if (*e) + s = e + 1; + } + } + + fec_8xx_init_one(&fec1_info, &fec1_dev); + fec_8xx_init_one(&fec2_info, &fec2_dev); + + return fec1_dev != NULL && fec2_dev != NULL ? 0 : -1; +} + +void fec_8xx_platform_cleanup(void) +{ + if (fec2_dev != NULL) + fec_8xx_cleanup_one(fec2_dev); + + if (fec1_dev != NULL) + fec_8xx_cleanup_one(fec1_dev); +} diff --git a/drivers/net/fec_8xx/fec_8xx.h b/drivers/net/fec_8xx/fec_8xx.h new file mode 100644 index 000000000000..5af60b0f9208 --- /dev/null +++ b/drivers/net/fec_8xx/fec_8xx.h @@ -0,0 +1,218 @@ +#ifndef FEC_8XX_H +#define FEC_8XX_H + +#include <linux/mii.h> +#include <linux/netdevice.h> + +#include <linux/types.h> + +/* HW info */ + +/* CRC polynomium used by the FEC for the multicast group filtering */ +#define FEC_CRC_POLY 0x04C11DB7 + +#define MII_ADVERTISE_HALF (ADVERTISE_100HALF | \ + ADVERTISE_10HALF | ADVERTISE_CSMA) +#define MII_ADVERTISE_ALL (ADVERTISE_100FULL | \ + ADVERTISE_10FULL | MII_ADVERTISE_HALF) + +/* Interrupt events/masks. +*/ +#define FEC_ENET_HBERR 0x80000000U /* Heartbeat error */ +#define FEC_ENET_BABR 0x40000000U /* Babbling receiver */ +#define FEC_ENET_BABT 0x20000000U /* Babbling transmitter */ +#define FEC_ENET_GRA 0x10000000U /* Graceful stop complete */ +#define FEC_ENET_TXF 0x08000000U /* Full frame transmitted */ +#define FEC_ENET_TXB 0x04000000U /* A buffer was transmitted */ +#define FEC_ENET_RXF 0x02000000U /* Full frame received */ +#define FEC_ENET_RXB 0x01000000U /* A buffer was received */ +#define FEC_ENET_MII 0x00800000U /* MII interrupt */ +#define FEC_ENET_EBERR 0x00400000U /* SDMA bus error */ + +#define FEC_ECNTRL_PINMUX 0x00000004 +#define FEC_ECNTRL_ETHER_EN 0x00000002 +#define FEC_ECNTRL_RESET 0x00000001 + +#define FEC_RCNTRL_BC_REJ 0x00000010 +#define FEC_RCNTRL_PROM 0x00000008 +#define FEC_RCNTRL_MII_MODE 0x00000004 +#define FEC_RCNTRL_DRT 0x00000002 +#define FEC_RCNTRL_LOOP 0x00000001 + +#define FEC_TCNTRL_FDEN 0x00000004 +#define FEC_TCNTRL_HBC 0x00000002 +#define FEC_TCNTRL_GTS 0x00000001 + +/* values for MII phy_status */ + +#define PHY_CONF_ANE 0x0001 /* 1 auto-negotiation enabled */ +#define PHY_CONF_LOOP 0x0002 /* 1 loopback mode enabled */ +#define PHY_CONF_SPMASK 0x00f0 /* mask for speed */ +#define PHY_CONF_10HDX 0x0010 /* 10 Mbit half duplex supported */ +#define PHY_CONF_10FDX 0x0020 /* 10 Mbit full duplex supported */ +#define PHY_CONF_100HDX 0x0040 /* 100 Mbit half duplex supported */ +#define PHY_CONF_100FDX 0x0080 /* 100 Mbit full duplex supported */ + +#define PHY_STAT_LINK 0x0100 /* 1 up - 0 down */ +#define PHY_STAT_FAULT 0x0200 /* 1 remote fault */ +#define PHY_STAT_ANC 0x0400 /* 1 auto-negotiation complete */ +#define PHY_STAT_SPMASK 0xf000 /* mask for speed */ +#define PHY_STAT_10HDX 0x1000 /* 10 Mbit half duplex selected */ +#define PHY_STAT_10FDX 0x2000 /* 10 Mbit full duplex selected */ +#define PHY_STAT_100HDX 0x4000 /* 100 Mbit half duplex selected */ +#define PHY_STAT_100FDX 0x8000 /* 100 Mbit full duplex selected */ + +typedef struct phy_info { + unsigned int id; + const char *name; + void (*startup) (struct net_device * dev); + void (*shutdown) (struct net_device * dev); + void (*ack_int) (struct net_device * dev); +} phy_info_t; + +/* The FEC stores dest/src/type, data, and checksum for receive packets. + */ +#define MAX_MTU 1508 /* Allow fullsized pppoe packets over VLAN */ +#define MIN_MTU 46 /* this is data size */ +#define CRC_LEN 4 + +#define PKT_MAXBUF_SIZE (MAX_MTU+ETH_HLEN+CRC_LEN) +#define PKT_MINBUF_SIZE (MIN_MTU+ETH_HLEN+CRC_LEN) + +/* Must be a multiple of 4 */ +#define PKT_MAXBLR_SIZE ((PKT_MAXBUF_SIZE+3) & ~3) +/* This is needed so that invalidate_xxx wont invalidate too much */ +#define ENET_RX_FRSIZE L1_CACHE_ALIGN(PKT_MAXBUF_SIZE) + +/* platform interface */ + +struct fec_platform_info { + int fec_no; /* FEC index */ + int use_mdio; /* use external MII */ + int phy_addr; /* the phy address */ + int fec_irq, phy_irq; /* the irq for the controller */ + int rx_ring, tx_ring; /* number of buffers on rx */ + int sys_clk; /* system clock */ + __u8 macaddr[6]; /* mac address */ + int rx_copybreak; /* limit we copy small frames */ + int use_napi; /* use NAPI */ + int napi_weight; /* NAPI weight */ +}; + +/* forward declaration */ +struct fec; + +struct fec_enet_private { + spinlock_t lock; /* during all ops except TX pckt processing */ + spinlock_t tx_lock; /* during fec_start_xmit and fec_tx */ + int fecno; + struct fec *fecp; + const struct fec_platform_info *fpi; + int rx_ring, tx_ring; + dma_addr_t ring_mem_addr; + void *ring_base; + struct sk_buff **rx_skbuff; + struct sk_buff **tx_skbuff; + cbd_t *rx_bd_base; /* Address of Rx and Tx buffers. */ + cbd_t *tx_bd_base; + cbd_t *dirty_tx; /* ring entries to be free()ed. */ + cbd_t *cur_rx; + cbd_t *cur_tx; + int tx_free; + struct net_device_stats stats; + struct timer_list phy_timer_list; + const struct phy_info *phy; + unsigned int fec_phy_speed; + __u32 msg_enable; + struct mii_if_info mii_if; +}; + +/***************************************************************************/ + +void fec_restart(struct net_device *dev, int duplex, int speed); +void fec_stop(struct net_device *dev); + +/***************************************************************************/ + +int fec_mii_read(struct net_device *dev, int phy_id, int location); +void fec_mii_write(struct net_device *dev, int phy_id, int location, int value); + +int fec_mii_phy_id_detect(struct net_device *dev); +void fec_mii_startup(struct net_device *dev); +void fec_mii_shutdown(struct net_device *dev); +void fec_mii_ack_int(struct net_device *dev); + +void fec_mii_link_status_change_check(struct net_device *dev, int init_media); + +/***************************************************************************/ + +#define FEC1_NO 0x00 +#define FEC2_NO 0x01 +#define FEC3_NO 0x02 + +int fec_8xx_init_one(const struct fec_platform_info *fpi, + struct net_device **devp); +int fec_8xx_cleanup_one(struct net_device *dev); + +/***************************************************************************/ + +#define DRV_MODULE_NAME "fec_8xx" +#define PFX DRV_MODULE_NAME ": " +#define DRV_MODULE_VERSION "0.1" +#define DRV_MODULE_RELDATE "May 6, 2004" + +/***************************************************************************/ + +int fec_8xx_platform_init(void); +void fec_8xx_platform_cleanup(void); + +/***************************************************************************/ + +/* FEC access macros */ +#if defined(CONFIG_8xx) +/* for a 8xx __raw_xxx's are sufficient */ +#define __fec_out32(addr, x) __raw_writel(x, addr) +#define __fec_out16(addr, x) __raw_writew(x, addr) +#define __fec_in32(addr) __raw_readl(addr) +#define __fec_in16(addr) __raw_readw(addr) +#else +/* for others play it safe */ +#define __fec_out32(addr, x) out_be32(addr, x) +#define __fec_out16(addr, x) out_be16(addr, x) +#define __fec_in32(addr) in_be32(addr) +#define __fec_in16(addr) in_be16(addr) +#endif + +/* write */ +#define FW(_fecp, _reg, _v) __fec_out32(&(_fecp)->fec_ ## _reg, (_v)) + +/* read */ +#define FR(_fecp, _reg) __fec_in32(&(_fecp)->fec_ ## _reg) + +/* set bits */ +#define FS(_fecp, _reg, _v) FW(_fecp, _reg, FR(_fecp, _reg) | (_v)) + +/* clear bits */ +#define FC(_fecp, _reg, _v) FW(_fecp, _reg, FR(_fecp, _reg) & ~(_v)) + +/* buffer descriptor access macros */ + +/* write */ +#define CBDW_SC(_cbd, _sc) __fec_out16(&(_cbd)->cbd_sc, (_sc)) +#define CBDW_DATLEN(_cbd, _datlen) __fec_out16(&(_cbd)->cbd_datlen, (_datlen)) +#define CBDW_BUFADDR(_cbd, _bufaddr) __fec_out32(&(_cbd)->cbd_bufaddr, (_bufaddr)) + +/* read */ +#define CBDR_SC(_cbd) __fec_in16(&(_cbd)->cbd_sc) +#define CBDR_DATLEN(_cbd) __fec_in16(&(_cbd)->cbd_datlen) +#define CBDR_BUFADDR(_cbd) __fec_in32(&(_cbd)->cbd_bufaddr) + +/* set bits */ +#define CBDS_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) | (_sc)) + +/* clear bits */ +#define CBDC_SC(_cbd, _sc) CBDW_SC(_cbd, CBDR_SC(_cbd) & ~(_sc)) + +/***************************************************************************/ + +#endif diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c new file mode 100644 index 000000000000..1bf15eed626a --- /dev/null +++ b/drivers/net/fec_8xx/fec_main.c @@ -0,0 +1,1275 @@ +/* + * Fast Ethernet Controller (FEC) driver for Motorola MPC8xx. + * + * Copyright (c) 2003 Intracom S.A. + * by Pantelis Antoniou <panto@intracom.gr> + * + * Heavily based on original FEC driver by Dan Malek <dan@embeddededge.com> + * and modifications by Joakim Tjernlund <joakim.tjernlund@lumentis.se> + * + * Released under the GPL + */ + +#include <linux/config.h> +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <linux/sched.h> +#include <linux/string.h> +#include <linux/ptrace.h> +#include <linux/errno.h> +#include <linux/ioport.h> +#include <linux/slab.h> +#include <linux/interrupt.h> +#include <linux/pci.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/skbuff.h> +#include <linux/spinlock.h> +#include <linux/mii.h> +#include <linux/ethtool.h> + +#include <asm/8xx_immap.h> +#include <asm/pgtable.h> +#include <asm/mpc8xx.h> +#include <asm/irq.h> +#include <asm/bitops.h> +#include <asm/uaccess.h> +#include <asm/commproc.h> +#include <asm/dma-mapping.h> + +#include "fec_8xx.h" + +/*************************************************/ + +#define FEC_MAX_MULTICAST_ADDRS 64 + +/*************************************************/ + +static char version[] __devinitdata = + DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")" "\n"; + +MODULE_AUTHOR("Pantelis Antoniou <panto@intracom.gr>"); +MODULE_DESCRIPTION("Motorola 8xx FEC ethernet driver"); +MODULE_LICENSE("GPL"); + +MODULE_PARM(fec_8xx_debug, "i"); +MODULE_PARM_DESC(fec_8xx_debug, + "FEC 8xx bitmapped debugging message enable value"); + +int fec_8xx_debug = -1; /* -1 == use FEC_8XX_DEF_MSG_ENABLE as value */ + +/*************************************************/ + +/* + * Delay to wait for FEC reset command to complete (in us) + */ +#define FEC_RESET_DELAY 50 + +/*****************************************************************************************/ + +static void fec_whack_reset(fec_t * fecp) +{ + int i; + + /* + * Whack a reset. We should wait for this. + */ + FW(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_RESET); + for (i = 0; + (FR(fecp, ecntrl) & FEC_ECNTRL_RESET) != 0 && i < FEC_RESET_DELAY; + i++) + udelay(1); + + if (i == FEC_RESET_DELAY) + printk(KERN_WARNING "FEC Reset timeout!\n"); + +} + +/****************************************************************************/ + +/* + * Transmitter timeout. + */ +#define TX_TIMEOUT (2*HZ) + +/****************************************************************************/ + +/* + * Returns the CRC needed when filling in the hash table for + * multicast group filtering + * pAddr must point to a MAC address (6 bytes) + */ +static __u32 fec_mulicast_calc_crc(char *pAddr) +{ + u8 byte; + int byte_count; + int bit_count; + __u32 crc = 0xffffffff; + u8 msb; + + for (byte_count = 0; byte_count < 6; byte_count++) { + byte = pAddr[byte_count]; + for (bit_count = 0; bit_count < 8; bit_count++) { + msb = crc >> 31; + crc <<= 1; + if (msb ^ (byte & 0x1)) { + crc ^= FEC_CRC_POLY; + } + byte >>= 1; + } + } + return (crc); +} + +/* + * Set or clear the multicast filter for this adaptor. + * Skeleton taken from sunlance driver. + * The CPM Ethernet implementation allows Multicast as well as individual + * MAC address filtering. Some of the drivers check to make sure it is + * a group multicast address, and discard those that are not. I guess I + * will do the same for now, but just remove the test if you want + * individual filtering as well (do the upper net layers want or support + * this kind of feature?). + */ +static void fec_set_multicast_list(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp = fep->fecp; + struct dev_mc_list *pmc; + __u32 crc; + int temp; + __u32 csrVal; + int hash_index; + __u32 hthi, htlo; + unsigned long flags; + + + if ((dev->flags & IFF_PROMISC) != 0) { + + spin_lock_irqsave(&fep->lock, flags); + FS(fecp, r_cntrl, FEC_RCNTRL_PROM); + spin_unlock_irqrestore(&fep->lock, flags); + + /* + * Log any net taps. + */ + printk(KERN_WARNING DRV_MODULE_NAME + ": %s: Promiscuous mode enabled.\n", dev->name); + return; + + } + + if ((dev->flags & IFF_ALLMULTI) != 0 || + dev->mc_count > FEC_MAX_MULTICAST_ADDRS) { + /* + * Catch all multicast addresses, set the filter to all 1's. + */ + hthi = 0xffffffffU; + htlo = 0xffffffffU; + } else { + hthi = 0; + htlo = 0; + + /* + * Now populate the hash table + */ + for (pmc = dev->mc_list; pmc != NULL; pmc = pmc->next) { + crc = fec_mulicast_calc_crc(pmc->dmi_addr); + temp = (crc & 0x3f) >> 1; + hash_index = ((temp & 0x01) << 4) | + ((temp & 0x02) << 2) | + ((temp & 0x04)) | + ((temp & 0x08) >> 2) | + ((temp & 0x10) >> 4); + csrVal = (1 << hash_index); + if (crc & 1) + hthi |= csrVal; + else + htlo |= csrVal; + } + } + + spin_lock_irqsave(&fep->lock, flags); + FC(fecp, r_cntrl, FEC_RCNTRL_PROM); + FW(fecp, hash_table_high, hthi); + FW(fecp, hash_table_low, htlo); + spin_unlock_irqrestore(&fep->lock, flags); +} + +static int fec_set_mac_address(struct net_device *dev, void *addr) +{ + struct sockaddr *mac = addr; + struct fec_enet_private *fep = netdev_priv(dev); + struct fec *fecp = fep->fecp; + int i; + __u32 addrhi, addrlo; + unsigned long flags; + + /* Get pointer to SCC area in parameter RAM. */ + for (i = 0; i < 6; i++) + dev->dev_addr[i] = mac->sa_data[i]; + + /* + * Set station address. + */ + addrhi = ((__u32) dev->dev_addr[0] << 24) | + ((__u32) dev->dev_addr[1] << 16) | + ((__u32) dev->dev_addr[2] << 8) | + (__u32) dev->dev_addr[3]; + addrlo = ((__u32) dev->dev_addr[4] << 24) | + ((__u32) dev->dev_addr[5] << 16); + + spin_lock_irqsave(&fep->lock, flags); + FW(fecp, addr_low, addrhi); + FW(fecp, addr_high, addrlo); + spin_unlock_irqrestore(&fep->lock, flags); + + return 0; +} + +/* + * This function is called to start or restart the FEC during a link + * change. This only happens when switching between half and full + * duplex. + */ +void fec_restart(struct net_device *dev, int duplex, int speed) +{ +#ifdef CONFIG_DUET + immap_t *immap = (immap_t *) IMAP_ADDR; + __u32 cptr; +#endif + struct fec_enet_private *fep = netdev_priv(dev); + struct fec *fecp = fep->fecp; + const struct fec_platform_info *fpi = fep->fpi; + cbd_t *bdp; + struct sk_buff *skb; + int i; + __u32 addrhi, addrlo; + + fec_whack_reset(fep->fecp); + + /* + * Set station address. + */ + addrhi = ((__u32) dev->dev_addr[0] << 24) | + ((__u32) dev->dev_addr[1] << 16) | + ((__u32) dev->dev_addr[2] << 8) | + (__u32) dev->dev_addr[3]; + addrlo = ((__u32) dev->dev_addr[4] << 24) | + ((__u32) dev->dev_addr[5] << 16); + FW(fecp, addr_low, addrhi); + FW(fecp, addr_high, addrlo); + + /* + * Reset all multicast. + */ + FW(fecp, hash_table_high, 0); + FW(fecp, hash_table_low, 0); + + /* + * Set maximum receive buffer size. + */ + FW(fecp, r_buff_size, PKT_MAXBLR_SIZE); + FW(fecp, r_hash, PKT_MAXBUF_SIZE); + + /* + * Set receive and transmit descriptor base. + */ + FW(fecp, r_des_start, iopa((__u32) (fep->rx_bd_base))); + FW(fecp, x_des_start, iopa((__u32) (fep->tx_bd_base))); + + fep->dirty_tx = fep->cur_tx = fep->tx_bd_base; + fep->tx_free = fep->tx_ring; + fep->cur_rx = fep->rx_bd_base; + + /* + * Reset SKB receive buffers + */ + for (i = 0; i < fep->rx_ring; i++) { + if ((skb = fep->rx_skbuff[i]) == NULL) + continue; + fep->rx_skbuff[i] = NULL; + dev_kfree_skb(skb); + } + + /* + * Initialize the receive buffer descriptors. + */ + for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { + skb = dev_alloc_skb(ENET_RX_FRSIZE); + if (skb == NULL) { + printk(KERN_WARNING DRV_MODULE_NAME + ": %s Memory squeeze, unable to allocate skb\n", + dev->name); + fep->stats.rx_dropped++; + break; + } + fep->rx_skbuff[i] = skb; + skb->dev = dev; + CBDW_BUFADDR(bdp, dma_map_single(NULL, skb->data, + L1_CACHE_ALIGN(PKT_MAXBUF_SIZE), + DMA_FROM_DEVICE)); + CBDW_DATLEN(bdp, 0); /* zero */ + CBDW_SC(bdp, BD_ENET_RX_EMPTY | + ((i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP)); + } + /* + * if we failed, fillup remainder + */ + for (; i < fep->rx_ring; i++, bdp++) { + fep->rx_skbuff[i] = NULL; + CBDW_SC(bdp, (i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP); + } + + /* + * Reset SKB transmit buffers. + */ + for (i = 0; i < fep->tx_ring; i++) { + if ((skb = fep->tx_skbuff[i]) == NULL) + continue; + fep->tx_skbuff[i] = NULL; + dev_kfree_skb(skb); + } + + /* + * ...and the same for transmit. + */ + for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) { + fep->tx_skbuff[i] = NULL; + CBDW_BUFADDR(bdp, virt_to_bus(NULL)); + CBDW_DATLEN(bdp, 0); + CBDW_SC(bdp, (i < fep->tx_ring - 1) ? 0 : BD_SC_WRAP); + } + + /* + * Enable big endian and don't care about SDMA FC. + */ + FW(fecp, fun_code, 0x78000000); + + /* + * Set MII speed. + */ + FW(fecp, mii_speed, fep->fec_phy_speed); + + /* + * Clear any outstanding interrupt. + */ + FW(fecp, ievent, 0xffc0); + FW(fecp, ivec, (fpi->fec_irq / 2) << 29); + + /* + * adjust to speed (only for DUET & RMII) + */ +#ifdef CONFIG_DUET + cptr = in_be32(&immap->im_cpm.cp_cptr); + switch (fpi->fec_no) { + case 0: + /* + * check if in RMII mode + */ + if ((cptr & 0x100) == 0) + break; + + if (speed == 10) + cptr |= 0x0000010; + else if (speed == 100) + cptr &= ~0x0000010; + break; + case 1: + /* + * check if in RMII mode + */ + if ((cptr & 0x80) == 0) + break; + + if (speed == 10) + cptr |= 0x0000008; + else if (speed == 100) + cptr &= ~0x0000008; + break; + default: + break; + } + out_be32(&immap->im_cpm.cp_cptr, cptr); +#endif + + FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ + /* + * adjust to duplex mode + */ + if (duplex) { + FC(fecp, r_cntrl, FEC_RCNTRL_DRT); + FS(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD enable */ + } else { + FS(fecp, r_cntrl, FEC_RCNTRL_DRT); + FC(fecp, x_cntrl, FEC_TCNTRL_FDEN); /* FD disable */ + } + + /* + * Enable interrupts we wish to service. + */ + FW(fecp, imask, FEC_ENET_TXF | FEC_ENET_TXB | + FEC_ENET_RXF | FEC_ENET_RXB); + + /* + * And last, enable the transmit and receive processing. + */ + FW(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); + FW(fecp, r_des_active, 0x01000000); +} + +void fec_stop(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp = fep->fecp; + struct sk_buff *skb; + int i; + + if ((FR(fecp, ecntrl) & FEC_ECNTRL_ETHER_EN) == 0) + return; /* already down */ + + FW(fecp, x_cntrl, 0x01); /* Graceful transmit stop */ + for (i = 0; ((FR(fecp, ievent) & 0x10000000) == 0) && + i < FEC_RESET_DELAY; i++) + udelay(1); + + if (i == FEC_RESET_DELAY) + printk(KERN_WARNING DRV_MODULE_NAME + ": %s FEC timeout on graceful transmit stop\n", + dev->name); + /* + * Disable FEC. Let only MII interrupts. + */ + FW(fecp, imask, 0); + FW(fecp, ecntrl, ~FEC_ECNTRL_ETHER_EN); + + /* + * Reset SKB transmit buffers. + */ + for (i = 0; i < fep->tx_ring; i++) { + if ((skb = fep->tx_skbuff[i]) == NULL) + continue; + fep->tx_skbuff[i] = NULL; + dev_kfree_skb(skb); + } + + /* + * Reset SKB receive buffers + */ + for (i = 0; i < fep->rx_ring; i++) { + if ((skb = fep->rx_skbuff[i]) == NULL) + continue; + fep->rx_skbuff[i] = NULL; + dev_kfree_skb(skb); + } +} + +/* common receive function */ +static int fec_enet_rx_common(struct net_device *dev, int *budget) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp = fep->fecp; + const struct fec_platform_info *fpi = fep->fpi; + cbd_t *bdp; + struct sk_buff *skb, *skbn, *skbt; + int received = 0; + __u16 pkt_len, sc; + int curidx; + int rx_work_limit; + + if (fpi->use_napi) { + rx_work_limit = min(dev->quota, *budget); + + if (!netif_running(dev)) + return 0; + } + + /* + * First, grab all of the stats for the incoming packet. + * These get messed up if we get called due to a busy condition. + */ + bdp = fep->cur_rx; + + /* clear RX status bits for napi*/ + if (fpi->use_napi) + FW(fecp, ievent, FEC_ENET_RXF | FEC_ENET_RXB); + + while (((sc = CBDR_SC(bdp)) & BD_ENET_RX_EMPTY) == 0) { + + curidx = bdp - fep->rx_bd_base; + + /* + * Since we have allocated space to hold a complete frame, + * the last indicator should be set. + */ + if ((sc & BD_ENET_RX_LAST) == 0) + printk(KERN_WARNING DRV_MODULE_NAME + ": %s rcv is not +last\n", + dev->name); + + /* + * Check for errors. + */ + if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL | + BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) { + fep->stats.rx_errors++; + /* Frame too long or too short. */ + if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH)) + fep->stats.rx_length_errors++; + /* Frame alignment */ + if (sc & (BD_ENET_RX_NO | BD_ENET_RX_CL)) + fep->stats.rx_frame_errors++; + /* CRC Error */ + if (sc & BD_ENET_RX_CR) + fep->stats.rx_crc_errors++; + /* FIFO overrun */ + if (sc & BD_ENET_RX_OV) + fep->stats.rx_crc_errors++; + + skbn = fep->rx_skbuff[curidx]; + BUG_ON(skbn == NULL); + + } else { + + /* napi, got packet but no quota */ + if (fpi->use_napi && --rx_work_limit < 0) + break; + + skb = fep->rx_skbuff[curidx]; + BUG_ON(skb == NULL); + + /* + * Process the incoming frame. + */ + fep->stats.rx_packets++; + pkt_len = CBDR_DATLEN(bdp) - 4; /* remove CRC */ + fep->stats.rx_bytes += pkt_len + 4; + + if (pkt_len <= fpi->rx_copybreak) { + /* +2 to make IP header L1 cache aligned */ + skbn = dev_alloc_skb(pkt_len + 2); + if (skbn != NULL) { + skb_reserve(skbn, 2); /* align IP header */ + memcpy(skbn->data, skb->data, pkt_len); + /* swap */ + skbt = skb; + skb = skbn; + skbn = skbt; + } + } else + skbn = dev_alloc_skb(ENET_RX_FRSIZE); + + if (skbn != NULL) { + skb->dev = dev; + skb_put(skb, pkt_len); /* Make room */ + skb->protocol = eth_type_trans(skb, dev); + received++; + if (!fpi->use_napi) + netif_rx(skb); + else + netif_receive_skb(skb); + } else { + printk(KERN_WARNING DRV_MODULE_NAME + ": %s Memory squeeze, dropping packet.\n", + dev->name); + fep->stats.rx_dropped++; + skbn = skb; + } + } + + fep->rx_skbuff[curidx] = skbn; + CBDW_BUFADDR(bdp, dma_map_single(NULL, skbn->data, + L1_CACHE_ALIGN(PKT_MAXBUF_SIZE), + DMA_FROM_DEVICE)); + CBDW_DATLEN(bdp, 0); + CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY); + + /* + * Update BD pointer to next entry. + */ + if ((sc & BD_ENET_RX_WRAP) == 0) + bdp++; + else + bdp = fep->rx_bd_base; + + /* + * Doing this here will keep the FEC running while we process + * incoming frames. On a heavily loaded network, we should be + * able to keep up at the expense of system resources. + */ + FW(fecp, r_des_active, 0x01000000); + } + + fep->cur_rx = bdp; + + if (fpi->use_napi) { + dev->quota -= received; + *budget -= received; + + if (rx_work_limit < 0) + return 1; /* not done */ + + /* done */ + netif_rx_complete(dev); + + /* enable RX interrupt bits */ + FS(fecp, imask, FEC_ENET_RXF | FEC_ENET_RXB); + } + + return 0; +} + +static void fec_enet_tx(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + cbd_t *bdp; + struct sk_buff *skb; + int dirtyidx, do_wake; + __u16 sc; + + spin_lock(&fep->lock); + bdp = fep->dirty_tx; + + do_wake = 0; + while (((sc = CBDR_SC(bdp)) & BD_ENET_TX_READY) == 0) { + + dirtyidx = bdp - fep->tx_bd_base; + + if (fep->tx_free == fep->tx_ring) + break; + + skb = fep->tx_skbuff[dirtyidx]; + + /* + * Check for errors. + */ + if (sc & (BD_ENET_TX_HB | BD_ENET_TX_LC | + BD_ENET_TX_RL | BD_ENET_TX_UN | BD_ENET_TX_CSL)) { + fep->stats.tx_errors++; + if (sc & BD_ENET_TX_HB) /* No heartbeat */ + fep->stats.tx_heartbeat_errors++; + if (sc & BD_ENET_TX_LC) /* Late collision */ + fep->stats.tx_window_errors++; + if (sc & BD_ENET_TX_RL) /* Retrans limit */ + fep->stats.tx_aborted_errors++; + if (sc & BD_ENET_TX_UN) /* Underrun */ + fep->stats.tx_fifo_errors++; + if (sc & BD_ENET_TX_CSL) /* Carrier lost */ + fep->stats.tx_carrier_errors++; + } else + fep->stats.tx_packets++; + + if (sc & BD_ENET_TX_READY) + printk(KERN_WARNING DRV_MODULE_NAME + ": %s HEY! Enet xmit interrupt and TX_READY.\n", + dev->name); + + /* + * Deferred means some collisions occurred during transmit, + * but we eventually sent the packet OK. + */ + if (sc & BD_ENET_TX_DEF) + fep->stats.collisions++; + + /* + * Free the sk buffer associated with this last transmit. + */ + dev_kfree_skb_irq(skb); + fep->tx_skbuff[dirtyidx] = NULL; + + /* + * Update pointer to next buffer descriptor to be transmitted. + */ + if ((sc & BD_ENET_TX_WRAP) == 0) + bdp++; + else + bdp = fep->tx_bd_base; + + /* + * Since we have freed up a buffer, the ring is no longer + * full. + */ + if (!fep->tx_free++) + do_wake = 1; + } + + fep->dirty_tx = bdp; + + spin_unlock(&fep->lock); + + if (do_wake && netif_queue_stopped(dev)) + netif_wake_queue(dev); +} + +/* + * The interrupt handler. + * This is called from the MPC core interrupt. + */ +static irqreturn_t +fec_enet_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + struct net_device *dev = dev_id; + struct fec_enet_private *fep; + const struct fec_platform_info *fpi; + fec_t *fecp; + __u32 int_events; + __u32 int_events_napi; + + if (unlikely(dev == NULL)) + return IRQ_NONE; + + fep = netdev_priv(dev); + fecp = fep->fecp; + fpi = fep->fpi; + + /* + * Get the interrupt events that caused us to be here. + */ + while ((int_events = FR(fecp, ievent) & FR(fecp, imask)) != 0) { + + if (!fpi->use_napi) + FW(fecp, ievent, int_events); + else { + int_events_napi = int_events & ~(FEC_ENET_RXF | FEC_ENET_RXB); + FW(fecp, ievent, int_events_napi); + } + + if ((int_events & (FEC_ENET_HBERR | FEC_ENET_BABR | + FEC_ENET_BABT | FEC_ENET_EBERR)) != 0) + printk(KERN_WARNING DRV_MODULE_NAME + ": %s FEC ERROR(s) 0x%x\n", + dev->name, int_events); + + if ((int_events & FEC_ENET_RXF) != 0) { + if (!fpi->use_napi) + fec_enet_rx_common(dev, NULL); + else { + if (netif_rx_schedule_prep(dev)) { + /* disable rx interrupts */ + FC(fecp, imask, FEC_ENET_RXF | FEC_ENET_RXB); + __netif_rx_schedule(dev); + } else { + printk(KERN_ERR DRV_MODULE_NAME + ": %s driver bug! interrupt while in poll!\n", + dev->name); + FC(fecp, imask, FEC_ENET_RXF | FEC_ENET_RXB); + } + } + } + + if ((int_events & FEC_ENET_TXF) != 0) + fec_enet_tx(dev); + } + + return IRQ_HANDLED; +} + +/* This interrupt occurs when the PHY detects a link change. */ +static irqreturn_t +fec_mii_link_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + struct net_device *dev = dev_id; + struct fec_enet_private *fep; + const struct fec_platform_info *fpi; + + if (unlikely(dev == NULL)) + return IRQ_NONE; + + fep = netdev_priv(dev); + fpi = fep->fpi; + + if (!fpi->use_mdio) + return IRQ_NONE; + + /* + * Acknowledge the interrupt if possible. If we have not + * found the PHY yet we can't process or acknowledge the + * interrupt now. Instead we ignore this interrupt for now, + * which we can do since it is edge triggered. It will be + * acknowledged later by fec_enet_open(). + */ + if (!fep->phy) + return IRQ_NONE; + + fec_mii_ack_int(dev); + fec_mii_link_status_change_check(dev, 0); + + return IRQ_HANDLED; +} + + +/**********************************************************************************/ + +static int fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp = fep->fecp; + cbd_t *bdp; + int curidx; + unsigned long flags; + + spin_lock_irqsave(&fep->tx_lock, flags); + + /* + * Fill in a Tx ring entry + */ + bdp = fep->cur_tx; + + if (!fep->tx_free || (CBDR_SC(bdp) & BD_ENET_TX_READY)) { + netif_stop_queue(dev); + spin_unlock_irqrestore(&fep->tx_lock, flags); + + /* + * Ooops. All transmit buffers are full. Bail out. + * This should not happen, since the tx queue should be stopped. + */ + printk(KERN_WARNING DRV_MODULE_NAME + ": %s tx queue full!.\n", dev->name); + return 1; + } + + curidx = bdp - fep->tx_bd_base; + /* + * Clear all of the status flags. + */ + CBDC_SC(bdp, BD_ENET_TX_STATS); + + /* + * Save skb pointer. + */ + fep->tx_skbuff[curidx] = skb; + + fep->stats.tx_bytes += skb->len; + + /* + * Push the data cache so the CPM does not get stale memory data. + */ + CBDW_BUFADDR(bdp, dma_map_single(NULL, skb->data, + skb->len, DMA_TO_DEVICE)); + CBDW_DATLEN(bdp, skb->len); + + dev->trans_start = jiffies; + + /* + * If this was the last BD in the ring, start at the beginning again. + */ + if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0) + fep->cur_tx++; + else + fep->cur_tx = fep->tx_bd_base; + + if (!--fep->tx_free) + netif_stop_queue(dev); + + /* + * Trigger transmission start + */ + CBDS_SC(bdp, BD_ENET_TX_READY | BD_ENET_TX_INTR | + BD_ENET_TX_LAST | BD_ENET_TX_TC); + FW(fecp, x_des_active, 0x01000000); + + spin_unlock_irqrestore(&fep->tx_lock, flags); + + return 0; +} + +static void fec_timeout(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + + fep->stats.tx_errors++; + + if (fep->tx_free) + netif_wake_queue(dev); + + /* check link status again */ + fec_mii_link_status_change_check(dev, 0); +} + +static int fec_enet_open(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + const struct fec_platform_info *fpi = fep->fpi; + unsigned long flags; + + /* Install our interrupt handler. */ + if (request_irq(fpi->fec_irq, fec_enet_interrupt, 0, "fec", dev) != 0) { + printk(KERN_ERR DRV_MODULE_NAME + ": %s Could not allocate FEC IRQ!", dev->name); + return -EINVAL; + } + + /* Install our phy interrupt handler */ + if (fpi->phy_irq != -1 && + request_irq(fpi->phy_irq, fec_mii_link_interrupt, 0, "fec-phy", + dev) != 0) { + printk(KERN_ERR DRV_MODULE_NAME + ": %s Could not allocate PHY IRQ!", dev->name); + free_irq(fpi->fec_irq, dev); + return -EINVAL; + } + + if (fpi->use_mdio) { + fec_mii_startup(dev); + netif_carrier_off(dev); + fec_mii_link_status_change_check(dev, 1); + } else { + spin_lock_irqsave(&fep->lock, flags); + fec_restart(dev, 1, 100); /* XXX this sucks */ + spin_unlock_irqrestore(&fep->lock, flags); + + netif_carrier_on(dev); + netif_start_queue(dev); + } + return 0; +} + +static int fec_enet_close(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + const struct fec_platform_info *fpi = fep->fpi; + unsigned long flags; + + netif_stop_queue(dev); + netif_carrier_off(dev); + + if (fpi->use_mdio) + fec_mii_shutdown(dev); + + spin_lock_irqsave(&fep->lock, flags); + fec_stop(dev); + spin_unlock_irqrestore(&fep->lock, flags); + + /* release any irqs */ + if (fpi->phy_irq != -1) + free_irq(fpi->phy_irq, dev); + free_irq(fpi->fec_irq, dev); + + return 0; +} + +static struct net_device_stats *fec_enet_get_stats(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + return &fep->stats; +} + +static int fec_enet_poll(struct net_device *dev, int *budget) +{ + return fec_enet_rx_common(dev, budget); +} + +/*************************************************************************/ + +static void fec_get_drvinfo(struct net_device *dev, + struct ethtool_drvinfo *info) +{ + strcpy(info->driver, DRV_MODULE_NAME); + strcpy(info->version, DRV_MODULE_VERSION); +} + +static int fec_get_regs_len(struct net_device *dev) +{ + return sizeof(fec_t); +} + +static void fec_get_regs(struct net_device *dev, struct ethtool_regs *regs, + void *p) +{ + struct fec_enet_private *fep = netdev_priv(dev); + unsigned long flags; + + if (regs->len < sizeof(fec_t)) + return; + + regs->version = 0; + spin_lock_irqsave(&fep->lock, flags); + memcpy_fromio(p, fep->fecp, sizeof(fec_t)); + spin_unlock_irqrestore(&fep->lock, flags); +} + +static int fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) +{ + struct fec_enet_private *fep = netdev_priv(dev); + unsigned long flags; + int rc; + + spin_lock_irqsave(&fep->lock, flags); + rc = mii_ethtool_gset(&fep->mii_if, cmd); + spin_unlock_irqrestore(&fep->lock, flags); + + return rc; +} + +static int fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) +{ + struct fec_enet_private *fep = netdev_priv(dev); + unsigned long flags; + int rc; + + spin_lock_irqsave(&fep->lock, flags); + rc = mii_ethtool_sset(&fep->mii_if, cmd); + spin_unlock_irqrestore(&fep->lock, flags); + + return rc; +} + +static int fec_nway_reset(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + return mii_nway_restart(&fep->mii_if); +} + +static __u32 fec_get_msglevel(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + return fep->msg_enable; +} + +static void fec_set_msglevel(struct net_device *dev, __u32 value) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fep->msg_enable = value; +} + +static struct ethtool_ops fec_ethtool_ops = { + .get_drvinfo = fec_get_drvinfo, + .get_regs_len = fec_get_regs_len, + .get_settings = fec_get_settings, + .set_settings = fec_set_settings, + .nway_reset = fec_nway_reset, + .get_link = ethtool_op_get_link, + .get_msglevel = fec_get_msglevel, + .set_msglevel = fec_set_msglevel, + .get_tx_csum = ethtool_op_get_tx_csum, + .set_tx_csum = ethtool_op_set_tx_csum, /* local! */ + .get_sg = ethtool_op_get_sg, + .set_sg = ethtool_op_set_sg, + .get_regs = fec_get_regs, +}; + +static int fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + struct fec_enet_private *fep = netdev_priv(dev); + struct mii_ioctl_data *mii = (struct mii_ioctl_data *)&rq->ifr_data; + unsigned long flags; + int rc; + + if (!netif_running(dev)) + return -EINVAL; + + spin_lock_irqsave(&fep->lock, flags); + rc = generic_mii_ioctl(&fep->mii_if, mii, cmd, NULL); + spin_unlock_irqrestore(&fep->lock, flags); + return rc; +} + +int fec_8xx_init_one(const struct fec_platform_info *fpi, + struct net_device **devp) +{ + immap_t *immap = (immap_t *) IMAP_ADDR; + static int fec_8xx_version_printed = 0; + struct net_device *dev = NULL; + struct fec_enet_private *fep = NULL; + fec_t *fecp = NULL; + int i; + int err = 0; + int registered = 0; + __u32 siel; + + *devp = NULL; + + switch (fpi->fec_no) { + case 0: + fecp = &((immap_t *) IMAP_ADDR)->im_cpm.cp_fec; + break; +#ifdef CONFIG_DUET + case 1: + fecp = &((immap_t *) IMAP_ADDR)->im_cpm.cp_fec2; + break; +#endif + default: + return -EINVAL; + } + + if (fec_8xx_version_printed++ == 0) + printk(KERN_INFO "%s", version); + + i = sizeof(*fep) + (sizeof(struct sk_buff **) * + (fpi->rx_ring + fpi->tx_ring)); + + dev = alloc_etherdev(i); + if (!dev) { + err = -ENOMEM; + goto err; + } + SET_MODULE_OWNER(dev); + + fep = netdev_priv(dev); + + /* partial reset of FEC */ + fec_whack_reset(fecp); + + /* point rx_skbuff, tx_skbuff */ + fep->rx_skbuff = (struct sk_buff **)&fep[1]; + fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring; + + fep->fecp = fecp; + fep->fpi = fpi; + + /* init locks */ + spin_lock_init(&fep->lock); + spin_lock_init(&fep->tx_lock); + + /* + * Set the Ethernet address. + */ + for (i = 0; i < 6; i++) + dev->dev_addr[i] = fpi->macaddr[i]; + + fep->ring_base = dma_alloc_coherent(NULL, + (fpi->tx_ring + fpi->rx_ring) * + sizeof(cbd_t), &fep->ring_mem_addr, + GFP_KERNEL); + if (fep->ring_base == NULL) { + printk(KERN_ERR DRV_MODULE_NAME + ": %s dma alloc failed.\n", dev->name); + err = -ENOMEM; + goto err; + } + + /* + * Set receive and transmit descriptor base. + */ + fep->rx_bd_base = fep->ring_base; + fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring; + + /* initialize ring size variables */ + fep->tx_ring = fpi->tx_ring; + fep->rx_ring = fpi->rx_ring; + + /* SIU interrupt */ + if (fpi->phy_irq != -1 && + (fpi->phy_irq >= SIU_IRQ0 && fpi->phy_irq < SIU_LEVEL7)) { + + siel = in_be32(&immap->im_siu_conf.sc_siel); + if ((fpi->phy_irq & 1) == 0) + siel |= (0x80000000 >> fpi->phy_irq); + else + siel &= ~(0x80000000 >> (fpi->phy_irq & ~1)); + out_be32(&immap->im_siu_conf.sc_siel, siel); + } + + /* + * The FEC Ethernet specific entries in the device structure. + */ + dev->open = fec_enet_open; + dev->hard_start_xmit = fec_enet_start_xmit; + dev->tx_timeout = fec_timeout; + dev->watchdog_timeo = TX_TIMEOUT; + dev->stop = fec_enet_close; + dev->get_stats = fec_enet_get_stats; + dev->set_multicast_list = fec_set_multicast_list; + dev->set_mac_address = fec_set_mac_address; + if (fpi->use_napi) { + dev->poll = fec_enet_poll; + dev->weight = fpi->napi_weight; + } + dev->ethtool_ops = &fec_ethtool_ops; + dev->do_ioctl = fec_ioctl; + + fep->fec_phy_speed = + ((((fpi->sys_clk + 4999999) / 2500000) / 2) & 0x3F) << 1; + + init_timer(&fep->phy_timer_list); + + /* partial reset of FEC so that only MII works */ + FW(fecp, mii_speed, fep->fec_phy_speed); + FW(fecp, ievent, 0xffc0); + FW(fecp, ivec, (fpi->fec_irq / 2) << 29); + FW(fecp, imask, 0); + FW(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ + FW(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); + + netif_carrier_off(dev); + + err = register_netdev(dev); + if (err != 0) + goto err; + registered = 1; + + if (fpi->use_mdio) { + fep->mii_if.dev = dev; + fep->mii_if.mdio_read = fec_mii_read; + fep->mii_if.mdio_write = fec_mii_write; + fep->mii_if.phy_id_mask = 0x1f; + fep->mii_if.reg_num_mask = 0x1f; + fep->mii_if.phy_id = fec_mii_phy_id_detect(dev); + } + + *devp = dev; + + return 0; + + err: + if (dev != NULL) { + if (fecp != NULL) + fec_whack_reset(fecp); + + if (registered) + unregister_netdev(dev); + + if (fep != NULL) { + if (fep->ring_base) + dma_free_coherent(NULL, + (fpi->tx_ring + + fpi->rx_ring) * + sizeof(cbd_t), fep->ring_base, + fep->ring_mem_addr); + } + free_netdev(dev); + } + return err; +} + +int fec_8xx_cleanup_one(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp = fep->fecp; + const struct fec_platform_info *fpi = fep->fpi; + + fec_whack_reset(fecp); + + unregister_netdev(dev); + + dma_free_coherent(NULL, (fpi->tx_ring + fpi->rx_ring) * sizeof(cbd_t), + fep->ring_base, fep->ring_mem_addr); + + free_netdev(dev); + + return 0; +} + +/**************************************************************************************/ +/**************************************************************************************/ +/**************************************************************************************/ + +static int __init fec_8xx_init(void) +{ + return fec_8xx_platform_init(); +} + +static void __exit fec_8xx_cleanup(void) +{ + fec_8xx_platform_cleanup(); +} + +/**************************************************************************************/ +/**************************************************************************************/ +/**************************************************************************************/ + +module_init(fec_8xx_init); +module_exit(fec_8xx_cleanup); diff --git a/drivers/net/fec_8xx/fec_mii.c b/drivers/net/fec_8xx/fec_mii.c new file mode 100644 index 000000000000..700233655e52 --- /dev/null +++ b/drivers/net/fec_8xx/fec_mii.c @@ -0,0 +1,380 @@ +/* + * Fast Ethernet Controller (FEC) driver for Motorola MPC8xx. + * + * Copyright (c) 2003 Intracom S.A. + * by Pantelis Antoniou <panto@intracom.gr> + * + * Heavily based on original FEC driver by Dan Malek <dan@embeddededge.com> + * and modifications by Joakim Tjernlund <joakim.tjernlund@lumentis.se> + * + * Released under the GPL + */ + +#include <linux/config.h> +#include <linux/module.h> +#include <linux/types.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/string.h> +#include <linux/ptrace.h> +#include <linux/errno.h> +#include <linux/ioport.h> +#include <linux/slab.h> +#include <linux/interrupt.h> +#include <linux/pci.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/skbuff.h> +#include <linux/spinlock.h> +#include <linux/mii.h> +#include <linux/ethtool.h> + +#include <asm/8xx_immap.h> +#include <asm/pgtable.h> +#include <asm/mpc8xx.h> +#include <asm/irq.h> +#include <asm/bitops.h> +#include <asm/uaccess.h> +#include <asm/commproc.h> + +/*************************************************/ + +#include "fec_8xx.h" + +/*************************************************/ + +/* Make MII read/write commands for the FEC. +*/ +#define mk_mii_read(REG) (0x60020000 | ((REG & 0x1f) << 18)) +#define mk_mii_write(REG, VAL) (0x50020000 | ((REG & 0x1f) << 18) | (VAL & 0xffff)) +#define mk_mii_end 0 + +/*************************************************/ + +/* XXX both FECs use the MII interface of FEC1 */ +static spinlock_t fec_mii_lock = SPIN_LOCK_UNLOCKED; + +#define FEC_MII_LOOPS 10000 + +int fec_mii_read(struct net_device *dev, int phy_id, int location) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp; + int i, ret = -1; + unsigned long flags; + + /* XXX MII interface is only connected to FEC1 */ + fecp = &((immap_t *) IMAP_ADDR)->im_cpm.cp_fec; + + spin_lock_irqsave(&fec_mii_lock, flags); + + if ((FR(fecp, r_cntrl) & FEC_RCNTRL_MII_MODE) == 0) { + FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ + FS(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); + FW(fecp, ievent, FEC_ENET_MII); + } + + /* Add PHY address to register command. */ + FW(fecp, mii_speed, fep->fec_phy_speed); + FW(fecp, mii_data, (phy_id << 23) | mk_mii_read(location)); + + for (i = 0; i < FEC_MII_LOOPS; i++) + if ((FR(fecp, ievent) & FEC_ENET_MII) != 0) + break; + + if (i < FEC_MII_LOOPS) { + FW(fecp, ievent, FEC_ENET_MII); + ret = FR(fecp, mii_data) & 0xffff; + } + + spin_unlock_irqrestore(&fec_mii_lock, flags); + + return ret; +} + +void fec_mii_write(struct net_device *dev, int phy_id, int location, int value) +{ + struct fec_enet_private *fep = netdev_priv(dev); + fec_t *fecp; + unsigned long flags; + int i; + + /* XXX MII interface is only connected to FEC1 */ + fecp = &((immap_t *) IMAP_ADDR)->im_cpm.cp_fec; + + spin_lock_irqsave(&fec_mii_lock, flags); + + if ((FR(fecp, r_cntrl) & FEC_RCNTRL_MII_MODE) == 0) { + FS(fecp, r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ + FS(fecp, ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); + FW(fecp, ievent, FEC_ENET_MII); + } + + /* Add PHY address to register command. */ + FW(fecp, mii_speed, fep->fec_phy_speed); /* always adapt mii speed */ + FW(fecp, mii_data, (phy_id << 23) | mk_mii_write(location, value)); + + for (i = 0; i < FEC_MII_LOOPS; i++) + if ((FR(fecp, ievent) & FEC_ENET_MII) != 0) + break; + + if (i < FEC_MII_LOOPS) + FW(fecp, ievent, FEC_ENET_MII); + + spin_unlock_irqrestore(&fec_mii_lock, flags); +} + +/*************************************************/ + +#ifdef CONFIG_FEC_8XX_GENERIC_PHY + +/* + * Generic PHY support. + * Should work for all PHYs, but link change is detected by polling + */ + +static void generic_timer_callback(unsigned long data) +{ + struct net_device *dev = (struct net_device *)data; + struct fec_enet_private *fep = netdev_priv(dev); + + fep->phy_timer_list.expires = jiffies + HZ / 2; + + add_timer(&fep->phy_timer_list); + + fec_mii_link_status_change_check(dev, 0); +} + +static void generic_startup(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + + fep->phy_timer_list.expires = jiffies + HZ / 2; /* every 500ms */ + fep->phy_timer_list.data = (unsigned long)dev; + fep->phy_timer_list.function = generic_timer_callback; + add_timer(&fep->phy_timer_list); +} + +static void generic_shutdown(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + + del_timer_sync(&fep->phy_timer_list); +} + +#endif + +#ifdef CONFIG_FEC_8XX_DM9161_PHY + +/* ------------------------------------------------------------------------- */ +/* The Davicom DM9161 is used on the NETTA board */ + +/* register definitions */ + +#define MII_DM9161_ACR 16 /* Aux. Config Register */ +#define MII_DM9161_ACSR 17 /* Aux. Config/Status Register */ +#define MII_DM9161_10TCSR 18 /* 10BaseT Config/Status Reg. */ +#define MII_DM9161_INTR 21 /* Interrupt Register */ +#define MII_DM9161_RECR 22 /* Receive Error Counter Reg. */ +#define MII_DM9161_DISCR 23 /* Disconnect Counter Register */ + +static void dm9161_startup(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + + fec_mii_write(dev, fep->mii_if.phy_id, MII_DM9161_INTR, 0x0000); +} + +static void dm9161_ack_int(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + + fec_mii_read(dev, fep->mii_if.phy_id, MII_DM9161_INTR); +} + +static void dm9161_shutdown(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + + fec_mii_write(dev, fep->mii_if.phy_id, MII_DM9161_INTR, 0x0f00); +} + +#endif + +/**********************************************************************************/ + +static const struct phy_info phy_info[] = { +#ifdef CONFIG_FEC_8XX_DM9161_PHY + { + .id = 0x00181b88, + .name = "DM9161", + .startup = dm9161_startup, + .ack_int = dm9161_ack_int, + .shutdown = dm9161_shutdown, + }, +#endif +#ifdef CONFIG_FEC_8XX_GENERIC_PHY + { + .id = 0, + .name = "GENERIC", + .startup = generic_startup, + .shutdown = generic_shutdown, + }, +#endif +}; + +/**********************************************************************************/ + +int fec_mii_phy_id_detect(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + const struct fec_platform_info *fpi = fep->fpi; + int i, r, start, end, phytype, physubtype; + const struct phy_info *phy; + int phy_hwid, phy_id; + + /* if no MDIO */ + if (fpi->use_mdio == 0) + return -1; + + phy_hwid = -1; + fep->phy = NULL; + + /* auto-detect? */ + if (fpi->phy_addr == -1) { + start = 0; + end = 32; + } else { /* direct */ + start = fpi->phy_addr; + end = start + 1; + } + + for (phy_id = start; phy_id < end; phy_id++) { + r = fec_mii_read(dev, phy_id, MII_PHYSID1); + if (r == -1 || (phytype = (r & 0xffff)) == 0xffff) + continue; + r = fec_mii_read(dev, phy_id, MII_PHYSID2); + if (r == -1 || (physubtype = (r & 0xffff)) == 0xffff) + continue; + phy_hwid = (phytype << 16) | physubtype; + if (phy_hwid != -1) + break; + } + + if (phy_hwid == -1) { + printk(KERN_ERR DRV_MODULE_NAME + ": %s No PHY detected!\n", dev->name); + return -1; + } + + for (i = 0, phy = phy_info; i < sizeof(phy_info) / sizeof(phy_info[0]); + i++, phy++) + if (phy->id == (phy_hwid >> 4) || phy->id == 0) + break; + + if (i >= sizeof(phy_info) / sizeof(phy_info[0])) { + printk(KERN_ERR DRV_MODULE_NAME + ": %s PHY id 0x%08x is not supported!\n", + dev->name, phy_hwid); + return -1; + } + + fep->phy = phy; + + printk(KERN_INFO DRV_MODULE_NAME + ": %s Phy @ 0x%x, type %s (0x%08x)\n", + dev->name, phy_id, fep->phy->name, phy_hwid); + + return phy_id; +} + +void fec_mii_startup(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + const struct fec_platform_info *fpi = fep->fpi; + + if (!fpi->use_mdio || fep->phy == NULL) + return; + + if (fep->phy->startup == NULL) + return; + + (*fep->phy->startup) (dev); +} + +void fec_mii_shutdown(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + const struct fec_platform_info *fpi = fep->fpi; + + if (!fpi->use_mdio || fep->phy == NULL) + return; + + if (fep->phy->shutdown == NULL) + return; + + (*fep->phy->shutdown) (dev); +} + +void fec_mii_ack_int(struct net_device *dev) +{ + struct fec_enet_private *fep = netdev_priv(dev); + const struct fec_platform_info *fpi = fep->fpi; + + if (!fpi->use_mdio || fep->phy == NULL) + return; + + if (fep->phy->ack_int == NULL) + return; + + (*fep->phy->ack_int) (dev); +} + +/* helper function */ +static int mii_negotiated(struct mii_if_info *mii) +{ + int advert, lpa, val; + + if (!mii_link_ok(mii)) + return 0; + + val = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_BMSR); + if ((val & BMSR_ANEGCOMPLETE) == 0) + return 0; + + advert = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_ADVERTISE); + lpa = (*mii->mdio_read) (mii->dev, mii->phy_id, MII_LPA); + + return mii_nway_result(advert & lpa); +} + +void fec_mii_link_status_change_check(struct net_device *dev, int init_media) +{ + struct fec_enet_private *fep = netdev_priv(dev); + unsigned int media; + unsigned long flags; + + if (mii_check_media(&fep->mii_if, netif_msg_link(fep), init_media) == 0) + return; + + media = mii_negotiated(&fep->mii_if); + + if (netif_carrier_ok(dev)) { + spin_lock_irqsave(&fep->lock, flags); + fec_restart(dev, !!(media & ADVERTISE_FULL), + (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)) ? + 100 : 10); + spin_unlock_irqrestore(&fep->lock, flags); + + netif_start_queue(dev); + } else { + netif_stop_queue(dev); + + spin_lock_irqsave(&fep->lock, flags); + fec_stop(dev); + spin_unlock_irqrestore(&fep->lock, flags); + + } +} diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h index d6c008b26a0a..5111c8e6badf 100644 --- a/drivers/net/ixgb/ixgb.h +++ b/drivers/net/ixgb/ixgb.h @@ -77,7 +77,7 @@ struct ixgb_adapter; #include "ixgb_ee.h" #include "ixgb_ids.h" -#if _DEBUG_DRIVER_ +#ifdef _DEBUG_DRIVER_ #define IXGB_DBG(args...) printk(KERN_DEBUG "ixgb: " args) #else #define IXGB_DBG(args...) diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c index e81ac44e7609..9eacbdec573e 100644 --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c @@ -139,12 +139,6 @@ * NAPI */ -#if !defined(__OPTIMIZE__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/config.h> #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 59d80ebbe88c..7c4ed0ddd12a 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -360,7 +360,10 @@ static void tc574_detach(dev_link_t *link) for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; if (*linkp == NULL) - return; + return; + + if (link->dev) + unregister_netdev(dev); if (link->state & DEV_CONFIG) tc574_release(link); @@ -370,8 +373,6 @@ static void tc574_detach(dev_link_t *link) /* Unlink device structure, free bits */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* tc574_detach */ @@ -580,10 +581,8 @@ static int tc574_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - tc574_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index be997bd296e7..2e0135dad547 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -276,6 +276,9 @@ static void tc589_detach(dev_link_t *link) if (*linkp == NULL) return; + if (link->dev) + unregister_netdev(dev); + if (link->state & DEV_CONFIG) tc589_release(link); @@ -284,8 +287,6 @@ static void tc589_detach(dev_link_t *link) /* Unlink device structure, free bits */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* tc589_detach */ @@ -456,10 +457,8 @@ static int tc589_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - tc589_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index ea5a88cf73e6..bf70b18c58b1 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -231,6 +231,9 @@ static void axnet_detach(dev_link_t *link) if (*linkp == NULL) return; + if (link->dev) + unregister_netdev(dev); + if (link->state & DEV_CONFIG) axnet_release(link); @@ -239,8 +242,6 @@ static void axnet_detach(dev_link_t *link) /* Unlink device structure, free bits */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* axnet_detach */ @@ -525,10 +526,8 @@ static int axnet_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - axnet_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 9ce8df6f2bcf..a824548388d8 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -262,6 +262,19 @@ static void com20020_detach(dev_link_t *link) dev = info->dev; + if (link->dev) { + DEBUG(1,"unregister...\n"); + + unregister_netdev(dev); + + /* + * this is necessary because we register our IRQ separately + * from card services. + */ + if (dev->irq) + free_irq(dev->irq, dev); + } + if (link->state & DEV_CONFIG) com20020_release(link); @@ -276,21 +289,6 @@ static void com20020_detach(dev_link_t *link) dev = info->dev; if (dev) { - if (link->dev) - { - DEBUG(1,"unregister...\n"); - - unregister_netdev(dev); - - /* - * this is necessary because we register our IRQ separately - * from card services. - */ - if (dev->irq) - free_irq(dev->irq, dev); - /* ...but I/O ports are done automatically by card services */ - } - DEBUG(1,"kfree...\n"); free_netdev(dev); } @@ -461,10 +459,8 @@ static int com20020_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - link->state |= DEV_RELEASE_PENDING; - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT; diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 580af370930b..9c40e61fa1bc 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -332,6 +332,9 @@ static void fmvj18x_detach(dev_link_t *link) if (*linkp == NULL) return; + if (link->dev) + unregister_netdev(dev); + if (link->state & DEV_CONFIG) fmvj18x_release(link); @@ -341,8 +344,6 @@ static void fmvj18x_detach(dev_link_t *link) /* Unlink device structure, free pieces */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* fmvj18x_detach */ @@ -741,10 +742,8 @@ static int fmvj18x_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - fmvj18x_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index beccf9e9535d..884ee94ea279 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -446,7 +446,6 @@ static int ibmtr_event(event_t event, int priority, struct tok_info *priv = netdev_priv(dev); priv->sram_virt |= 1; netif_device_detach(dev); - ibmtr_release(link); } break; case CS_EVENT_CARD_INSERTION: diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index bcf284bbb453..475d68dffc45 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -551,6 +551,9 @@ static void nmclan_detach(dev_link_t *link) if (*linkp == NULL) return; + if (link->dev) + unregister_netdev(dev); + if (link->state & DEV_CONFIG) nmclan_release(link); @@ -559,8 +562,6 @@ static void nmclan_detach(dev_link_t *link) /* Unlink device structure, free bits */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* nmclan_detach */ @@ -834,10 +835,8 @@ static int nmclan_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - nmclan_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index b53f5fcf5d12..2db4baabe9c9 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -326,6 +326,9 @@ static void pcnet_detach(dev_link_t *link) if (*linkp == NULL) return; + if (link->dev) + unregister_netdev(dev); + if (link->state & DEV_CONFIG) pcnet_release(link); @@ -334,8 +337,6 @@ static void pcnet_detach(dev_link_t *link) /* Unlink device structure, free bits */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* pcnet_detach */ @@ -806,10 +807,8 @@ static int pcnet_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - pcnet_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 7c1bd346e09d..d3d35ef7d31d 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -411,6 +411,9 @@ static void smc91c92_detach(dev_link_t *link) if (*linkp == NULL) return; + if (link->dev) + unregister_netdev(dev); + if (link->state & DEV_CONFIG) smc91c92_release(link); @@ -419,8 +422,6 @@ static void smc91c92_detach(dev_link_t *link) /* Unlink device structure, free bits */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* smc91c92_detach */ @@ -1112,10 +1113,8 @@ static int smc91c92_event(event_t event, int priority, switch (event) { case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - smc91c92_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index d4cc269029df..870a2d25c1d2 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -668,6 +668,9 @@ xirc2ps_detach(dev_link_t * link) return; } + if (link->dev) + unregister_netdev(dev); + /* * If the device is currently configured and active, we won't * actually delete it yet. Instead, it is marked so that when @@ -683,8 +686,6 @@ xirc2ps_detach(dev_link_t * link) /* Unlink device structure, free it */ *linkp = link->next; - if (link->dev) - unregister_netdev(dev); free_netdev(dev); } /* xirc2ps_detach */ @@ -1203,10 +1204,8 @@ xirc2ps_event(event_t event, int priority, break; case CS_EVENT_CARD_REMOVAL: link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { + if (link->state & DEV_CONFIG) netif_device_detach(dev); - xirc2ps_release(link); - } break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index ed687ec42b28..c57cb341f769 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -22,8 +22,8 @@ *************************************************************************/ #define DRV_NAME "pcnet32" -#define DRV_VERSION "1.30f" -#define DRV_RELDATE "06.16.2004" +#define DRV_VERSION "1.30i" +#define DRV_RELDATE "06.28.2004" #define PFX DRV_NAME ": " static const char *version = @@ -46,6 +46,7 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " tsbogend@alpha.franken.de\n"; #include <linux/etherdevice.h> #include <linux/skbuff.h> #include <linux/spinlock.h> +#include <linux/moduleparam.h> #include <asm/bitops.h> #include <asm/dma.h> @@ -137,6 +138,7 @@ static const char pcnet32_gstrings_test[][ETH_GSTRING_LEN] = { #define MAX_UNITS 8 /* More are supported, limit only on options */ static int options[MAX_UNITS]; static int full_duplex[MAX_UNITS]; +static int homepna[MAX_UNITS]; /* * Theory of Operation @@ -250,6 +252,10 @@ static int full_duplex[MAX_UNITS]; * v1.30f 16 Jun 2004 Don Fry cleanup IRQ to allow 0 and 1 for PCI, * expanding on suggestions from Ralf Baechle <ralf@linux-mips.org>, * and Brian Murphy <brian@murphy.dk>. + * v1.30g 22 Jun 2004 Patrick Simmons <psimmons@flash.net> added option + * homepna for selecting HomePNA mode for PCNet/Home 79C978. + * v1.30h 24 Jun 2004 Don Fry correctly select auto, speed, duplex in bcr32. + * v1.30i 28 Jun 2004 Don Fry change to use module_param. */ @@ -1084,15 +1090,17 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev) fdx = 1; /* * This is based on specs published at www.amd.com. This section - * assumes that a card with a 79C978 wants to go into 1Mb HomePNA - * mode. The 79C978 can also go into standard ethernet, and there - * probably should be some sort of module option to select the - * mode by which the card should operate + * assumes that a card with a 79C978 wants to go into standard + * ethernet mode. The 79C978 can also go into 1Mb HomePNA mode, + * and the module option homepna=1 can select this instead. */ - /* switch to home wiring mode */ media = a->read_bcr(ioaddr, 49); + media &= ~3; /* default to 10Mb ethernet */ + if (cards_found < MAX_UNITS && homepna[cards_found]) + media |= 1; /* switch to home wiring mode */ if (pcnet32_debug & NETIF_MSG_PROBE) - printk(KERN_DEBUG PFX "media reset to %#x.\n", media); + printk(KERN_DEBUG PFX "media set to %sMbit mode.\n", + (media & 1) ? "1" : "10"); a->write_bcr(ioaddr, 49, media); break; case 0x2627: @@ -1417,9 +1425,13 @@ pcnet32_open(struct net_device *dev) val |= 0x10; lp->a.write_csr (ioaddr, 124, val); + /* 24 Jun 2004 according AMD, in order to change the PHY, + * DANAS (or DISPM for 79C976) must be set; then select the speed, + * duplex, and/or enable auto negotiation, and clear DANAS */ if (lp->mii && !(lp->options & PCNET32_PORT_ASEL)) { + lp->a.write_bcr(ioaddr, 32, lp->a.read_bcr(ioaddr, 32) | 0x0080); /* disable Auto Negotiation, set 10Mpbs, HD */ - val = lp->a.read_bcr (ioaddr, 32) & ~0x38; + val = lp->a.read_bcr(ioaddr, 32) & ~0xb8; if (lp->options & PCNET32_PORT_FD) val |= 0x10; if (lp->options & PCNET32_PORT_100) @@ -1427,6 +1439,7 @@ pcnet32_open(struct net_device *dev) lp->a.write_bcr (ioaddr, 32, val); } else { if (lp->options & PCNET32_PORT_ASEL) { + lp->a.write_bcr(ioaddr, 32, lp->a.read_bcr(ioaddr, 32) | 0x0080); /* enable auto negotiate, setup, disable fd */ val = lp->a.read_bcr(ioaddr, 32) & ~0x98; val |= 0x20; @@ -1753,7 +1766,7 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs) spin_lock(&lp->lock); rap = lp->a.read_rap(ioaddr); - while ((csr0 = lp->a.read_csr (ioaddr, 0)) & 0x8600 && --boguscnt >= 0) { + while ((csr0 = lp->a.read_csr (ioaddr, 0)) & 0x8f00 && --boguscnt >= 0) { if (csr0 == 0xffff) { break; /* PCMCIA remove happened */ } @@ -2247,20 +2260,29 @@ static struct pci_driver pcnet32_driver = { .id_table = pcnet32_pci_tbl, }; -MODULE_PARM(debug, "i"); +/* An additional parameter that may be passed in... */ +static int debug = -1; +static int tx_start_pt = -1; +static int pcnet32_have_pci; +static int num_params; + +module_param(debug, int, 0); MODULE_PARM_DESC(debug, DRV_NAME " debug level"); -MODULE_PARM(max_interrupt_work, "i"); +module_param(max_interrupt_work, int, 0); MODULE_PARM_DESC(max_interrupt_work, DRV_NAME " maximum events handled per interrupt"); -MODULE_PARM(rx_copybreak, "i"); +module_param(rx_copybreak, int, 0); MODULE_PARM_DESC(rx_copybreak, DRV_NAME " copy breakpoint for copy-only-tiny-frames"); -MODULE_PARM(tx_start_pt, "i"); +module_param(tx_start_pt, int, 0); MODULE_PARM_DESC(tx_start_pt, DRV_NAME " transmit start point (0-3)"); -MODULE_PARM(pcnet32vlb, "i"); +module_param(pcnet32vlb, int, 0); MODULE_PARM_DESC(pcnet32vlb, DRV_NAME " Vesa local bus (VLB) support (0/1)"); -MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i"); +module_param_array(options, int, num_params, 0); MODULE_PARM_DESC(options, DRV_NAME " initial option setting(s) (0-15)"); -MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i"); +module_param_array(full_duplex, int, num_params, 0); MODULE_PARM_DESC(full_duplex, DRV_NAME " full duplex setting(s) (1)"); +/* Module Parameter for HomePNA cards added by Patrick Simmons, 2004 */ +module_param_array(homepna, int, num_params, 0); +MODULE_PARM_DESC(homepna, DRV_NAME " mode for 79C978 cards (1 for HomePNA, 0 for Ethernet, default Ethernet"); MODULE_AUTHOR("Thomas Bogendoerfer"); MODULE_DESCRIPTION("Driver for PCnet32 and PCnetPCI based ethercards"); @@ -2268,11 +2290,6 @@ MODULE_LICENSE("GPL"); #define PCNET32_MSG_DEFAULT (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) -/* An additional parameter that may be passed in... */ -static int debug = -1; -static int tx_start_pt = -1; -static int pcnet32_have_pci; - static int __init pcnet32_init_module(void) { printk(KERN_INFO "%s", version); diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c index 39b09cd6ba13..e0f88fbd33f5 100644 --- a/drivers/net/sb1250-mac.c +++ b/drivers/net/sb1250-mac.c @@ -55,12 +55,6 @@ static int int_timeout = 0; /* Time in jiffies before concluding the transmitter is hung. */ #define TX_TIMEOUT (2*HZ) -#if !defined(__OPTIMIZE__) || !defined(__KERNEL__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> diff --git a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h index 652775ecb3e6..ea76a95f4e9a 100644 --- a/drivers/net/sk98lin/h/skdrv1st.h +++ b/drivers/net/sk98lin/h/skdrv1st.h @@ -58,12 +58,6 @@ typedef struct s_AC SK_AC; #define SK_ADDR_EQUAL(a1,a2) (!memcmp(a1,a2,6)) -#if !defined(__OPTIMIZE__) || !defined(__KERNEL__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/version.h> #include <linux/types.h> #include <linux/kernel.h> diff --git a/drivers/net/skfp/fplustm.c b/drivers/net/skfp/fplustm.c index d2b43139375f..1f3b423f2635 100644 --- a/drivers/net/skfp/fplustm.c +++ b/drivers/net/skfp/fplustm.c @@ -141,16 +141,17 @@ void mac_update_counter(struct s_smc *smc) /* * write long value into buffer memory over memory data register (MDR), */ -void write_mdr(struct s_smc *smc, u_long val) +static void write_mdr(struct s_smc *smc, u_long val) { CHECK_NPP() ; MDRW(val) ; } +#if 0 /* * read long value from buffer memory over memory data register (MDR), */ -u_long read_mdr(struct s_smc *smc, unsigned int addr) +static u_long read_mdr(struct s_smc *smc, unsigned int addr) { long p ; CHECK_NPP() ; @@ -164,6 +165,8 @@ u_long read_mdr(struct s_smc *smc, unsigned int addr) p += (u_long)inpw(FM_A(FM_MDRL)) ; return(p) ; } +#endif + /* * clear buffer memory */ @@ -529,7 +532,7 @@ static void build_claim_beacon(struct s_smc *smc, u_long t_request) outpw(FM_A(FM_RPXSF),0) ; } -void formac_rcv_restart(struct s_smc *smc) +static void formac_rcv_restart(struct s_smc *smc) { /* enable receive function */ SETMASK(FM_A(FM_MDREG1),smc->hw.fp.rx_mode,FM_ADDRX) ; @@ -1018,25 +1021,6 @@ void sm_mac_check_beacon_claim(struct s_smc *smc) /*-------------------------- interface functions ----------------------------*/ /* - * control ODL output - */ -void sm_pm_control(struct s_smc *smc, int mode) -{ - SK_UNUSED(smc) ; - - /* - * if PCM logic has set LS_REQUEST = Transmit QUIET Line State - * /FOTOFF signal turn activ -> ODL disable - */ - switch(mode) { - case PM_TRANSMIT_DISABLE : - break ; - case PM_TRANSMIT_ENABLE : - break ; - } -} - -/* * control MAC layer (called by RMT) */ void sm_ma_control(struct s_smc *smc, int mode) diff --git a/drivers/net/skfp/h/cmtdef.h b/drivers/net/skfp/h/cmtdef.h index 899c8c0413b0..603982debc71 100644 --- a/drivers/net/skfp/h/cmtdef.h +++ b/drivers/net/skfp/h/cmtdef.h @@ -571,10 +571,6 @@ int cfm_get_mac_output(struct s_smc *smc); int port_to_mib(struct s_smc *smc, int p); int cem_build_path(struct s_smc *smc, char *to, int path_index); int sm_mac_get_tx_state(struct s_smc *smc); -int is_individual(struct fddi_addr *addr); -int is_my_addr(struct s_smc *smc, struct fddi_addr *addr); -int is_broadcast(struct fddi_addr *addr); -int is_equal(struct fddi_addr *addr1, struct fddi_addr *addr2); char *get_pcmstate(struct s_smc *smc, int np); int smt_action(struct s_smc *smc, int class, int code, int index); u_short smt_online(struct s_smc *smc, int on); diff --git a/drivers/net/skfp/h/targetos.h b/drivers/net/skfp/h/targetos.h index 94a81eede792..59de39e293fa 100644 --- a/drivers/net/skfp/h/targetos.h +++ b/drivers/net/skfp/h/targetos.h @@ -110,7 +110,7 @@ struct s_skfp_ioctl { unsigned short cmd; /* Command to run */ unsigned short len; /* Length of the data buffer */ - unsigned char *data; /* Pointer to the data buffer */ + unsigned char __user *data; /* Pointer to the data buffer */ }; /* diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c index a5e5d874c1f2..1eee9d37fd9d 100644 --- a/drivers/net/skfp/skfddi.c +++ b/drivers/net/skfp/skfddi.c @@ -909,7 +909,10 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev) dmi = dev->mc_list; for (i = 0; i < dev->mc_count; i++) { - mac_add_multicast(smc, dmi->dmi_addr, 1); + mac_add_multicast(smc, + (struct fddi_addr *)dmi->dmi_addr, + 1); + PRINTK(KERN_INFO "ENABLE MC ADDRESS:"); PRINTK(" %02x %02x %02x ", dmi->dmi_addr[0], diff --git a/drivers/net/skfp/smt.c b/drivers/net/skfp/smt.c index 8301daf21e48..43f78c74c845 100644 --- a/drivers/net/skfp/smt.c +++ b/drivers/net/skfp/smt.c @@ -76,8 +76,8 @@ static int mac_con_resource_index(struct s_smc *smc, int mac); static int phy_con_resource_index(struct s_smc *smc, int phy); static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason, int local); -static void smt_send_nif(struct s_smc *smc, struct fddi_addr *dest, int fc, - u_long tid, int type, int local); +static void smt_send_nif(struct s_smc *smc, const struct fddi_addr *dest, + int fc, u_long tid, int type, int local); static void smt_send_ecf(struct s_smc *smc, struct fddi_addr *dest, int fc, u_long tid, int type, int len); static void smt_echo_test(struct s_smc *smc, int dna); @@ -123,6 +123,45 @@ void hwm_conv_can(struct s_smc *smc, char *data, int len); #define hwm_conv_can(smc,data,len) #endif + +static inline int is_my_addr(const struct s_smc *smc, + const struct fddi_addr *addr) +{ + return(*(short *)(&addr->a[0]) == + *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[0]) + && *(short *)(&addr->a[2]) == + *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[2]) + && *(short *)(&addr->a[4]) == + *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[4])) ; +} + +static inline int is_zero(const struct fddi_addr *addr) +{ + return(*(short *)(&addr->a[0]) == 0 && + *(short *)(&addr->a[2]) == 0 && + *(short *)(&addr->a[4]) == 0 ) ; +} + +static inline int is_broadcast(const struct fddi_addr *addr) +{ + return(*(u_short *)(&addr->a[0]) == 0xffff && + *(u_short *)(&addr->a[2]) == 0xffff && + *(u_short *)(&addr->a[4]) == 0xffff ) ; +} + +static inline int is_individual(const struct fddi_addr *addr) +{ + return(!(addr->a[0] & GROUP_ADDR)) ; +} + +static inline int is_equal(const struct fddi_addr *addr1, + const struct fddi_addr *addr2) +{ + return(*(u_short *)(&addr1->a[0]) == *(u_short *)(&addr2->a[0]) && + *(u_short *)(&addr1->a[2]) == *(u_short *)(&addr2->a[2]) && + *(u_short *)(&addr1->a[4]) == *(u_short *)(&addr2->a[4]) ) ; +} + /* * list of mandatory paras in frames */ @@ -382,7 +421,7 @@ void smt_event(struct s_smc *smc, int event) */ if (!smc->sm.pend[SMT_TID_NIF]) smc->sm.pend[SMT_TID_NIF] = smt_get_tid(smc) ; - smt_send_nif(smc,&fddi_broadcast,FC_SMT_NSA, + smt_send_nif(smc,&fddi_broadcast, FC_SMT_NSA, smc->sm.pend[SMT_TID_NIF], SMT_REQUEST,0) ; smc->sm.smt_last_notify = time ; } @@ -926,8 +965,8 @@ static void smt_send_rdf(struct s_smc *smc, SMbuf *rej, int fc, int reason, /* * generate and send NIF */ -static void smt_send_nif(struct s_smc *smc, struct fddi_addr *dest, int fc, - u_long tid, int type, int local) +static void smt_send_nif(struct s_smc *smc, const struct fddi_addr *dest, + int fc, u_long tid, int type, int local) /* struct fddi_addr *dest; dest address */ /* int fc; frame control */ /* u_long tid; transaction id */ @@ -1688,43 +1727,6 @@ void *sm_to_para(struct s_smc *smc, struct smt_header *sm, int para) return(0) ; } -int is_my_addr(struct s_smc *smc, struct fddi_addr *addr) -{ - return(*(short *)(&addr->a[0]) == - *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[0]) - && *(short *)(&addr->a[2]) == - *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[2]) - && *(short *)(&addr->a[4]) == - *(short *)(&smc->mib.m[MAC0].fddiMACSMTAddress.a[4])) ; -} - -int is_zero(struct fddi_addr *addr) -{ - return(*(short *)(&addr->a[0]) == 0 && - *(short *)(&addr->a[2]) == 0 && - *(short *)(&addr->a[4]) == 0 ) ; -} - -int is_broadcast(struct fddi_addr *addr) -{ - return(*(u_short *)(&addr->a[0]) == 0xffff && - *(u_short *)(&addr->a[2]) == 0xffff && - *(u_short *)(&addr->a[4]) == 0xffff ) ; -} - -int is_individual(struct fddi_addr *addr) -{ - return(!(addr->a[0] & GROUP_ADDR)) ; -} - -int is_equal(struct fddi_addr *addr1, struct fddi_addr *addr2) -{ - return(*(u_short *)(&addr1->a[0]) == *(u_short *)(&addr2->a[0]) && - *(u_short *)(&addr1->a[2]) == *(u_short *)(&addr2->a[2]) && - *(u_short *)(&addr1->a[4]) == *(u_short *)(&addr2->a[4]) ) ; -} - - #if 0 /* * send ANTC data test frame diff --git a/drivers/net/arm/smc91x.c b/drivers/net/smc91x.c index 3968a1cd50d7..0bacd06a3d76 100644 --- a/drivers/net/arm/smc91x.c +++ b/drivers/net/smc91x.c @@ -86,7 +86,9 @@ static const char version[] = #include <linux/skbuff.h> #include <asm/io.h> +#ifdef CONFIG_ARM #include <asm/hardware.h> +#endif #include <asm/irq.h> #include "smc91x.h" diff --git a/drivers/net/arm/smc91x.h b/drivers/net/smc91x.h index 5212e3763bcb..7679022c0729 100644 --- a/drivers/net/arm/smc91x.h +++ b/drivers/net/smc91x.h @@ -59,6 +59,43 @@ #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) +#elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6) + +/* We can only do 16-bit reads and writes in the static memory space. */ +#define SMC_CAN_USE_8BIT 0 +#define SMC_CAN_USE_16BIT 1 +#define SMC_CAN_USE_32BIT 0 +#define SMC_NOWAIT 1 + +#define SMC_IO_SHIFT 0 + +#define SMC_inw(a, r) in_be16((volatile u16 *)((a) + (r))) +#define SMC_outw(v, a, r) out_be16((volatile u16 *)((a) + (r)), v) +#define SMC_insw(a, r, p, l) \ + do { \ + unsigned long __port = (a) + (r); \ + u16 *__p = (u16 *)(p); \ + int __l = (l); \ + insw(__port, __p, __l); \ + while (__l > 0) { \ + *__p = swab16(*__p); \ + __p++; \ + __l--; \ + } \ + } while (0) +#define SMC_outsw(a, r, p, l) \ + do { \ + unsigned long __port = (a) + (r); \ + u16 *__p = (u16 *)(p); \ + int __l = (l); \ + while (__l > 0) { \ + /* Believe it or not, the swab isn't needed. */ \ + outw( /* swab16 */ (*__p++), __port); \ + __l--; \ + } \ + } while (0) +#define set_irq_type(irq, type) + #elif defined(CONFIG_SA1100_ASSABET) #include <asm/arch/neponset.h> diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index e5069fca1792..44c7aa512300 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c @@ -148,15 +148,6 @@ static char *media[MAX_UNITS]; #define TX_TIMEOUT (4*HZ) #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer.*/ -#ifndef __KERNEL__ -#define __KERNEL__ -#endif -#if !defined(__OPTIMIZE__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - /* Include files, designed to support most kernel versions 2.0.0 and later. */ #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c index 6246e443f496..22d57c86a36d 100644 --- a/drivers/net/tulip/winbond-840.c +++ b/drivers/net/tulip/winbond-840.c @@ -111,15 +111,6 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer.*/ -#ifndef __KERNEL__ -#define __KERNEL__ -#endif -#if !defined(__OPTIMIZE__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - /* Include files, designed to support most kernel versions 2.0.0 and later. */ #include <linux/module.h> #include <linux/kernel.h> diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index 45ab1999ded9..142f5f52f31a 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c @@ -90,12 +90,6 @@ static const int multicast_filter_limit = 32; #define PFX DRV_MODULE_NAME ": " #define ERR_PFX KERN_ERR PFX -#if !defined(__OPTIMIZE__) || !defined(__KERNEL__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index 47443254c985..5589393ee682 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c @@ -183,12 +183,6 @@ static const int multicast_filter_limit = 32; #define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer.*/ -#if !defined(__OPTIMIZE__) || !defined(__KERNEL__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> diff --git a/drivers/net/wan/sbni.h b/drivers/net/wan/sbni.h index 8e83e274824d..27715e70f28b 100644 --- a/drivers/net/wan/sbni.h +++ b/drivers/net/wan/sbni.h @@ -6,7 +6,7 @@ #ifndef SBNI_H #define SBNI_H -#if SBNI_DEBUG +#ifdef SBNI_DEBUG #define DP( A ) A #else #define DP( A ) diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index dc84928d946b..7aa05d696da3 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c @@ -577,7 +577,7 @@ prism54_set_scan(struct net_device *dev, struct iw_request_info *info, * the "Aironet driver for 4500 and 4800 series cards" (GPL) */ -inline char * +static char * prism54_translate_bss(struct net_device *ndev, char *current_ev, char *end_buf, struct obj_bss *bss, char noise) { @@ -1502,7 +1502,7 @@ prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info, /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */ -static inline void +static void format_event(islpci_private *priv, char *dest, const char *str, const struct obj_mlme *mlme, u16 *length, int error) { diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c index b980edccf163..62847f475237 100644 --- a/drivers/net/wireless/prism54/islpci_dev.c +++ b/drivers/net/wireless/prism54/islpci_dev.c @@ -41,6 +41,9 @@ #define ISL3877_IMAGE_FILE "isl3877" #define ISL3890_IMAGE_FILE "isl3890" +static int prism54_bring_down(islpci_private *); +static int islpci_alloc_memory(islpci_private *); + /* Temporary dummy MAC address to use until firmware is loaded. * The idea there is that some tools (such as nameif) may query * the MAC address before the netdev is 'open'. By using a valid @@ -390,7 +393,7 @@ islpci_close(struct net_device *ndev) return prism54_bring_down(priv); } -int +static int prism54_bring_down(islpci_private *priv) { void *device_base = priv->device_base; @@ -601,7 +604,7 @@ islpci_statistics(struct net_device *ndev) /****************************************************************************** Network device configuration functions ******************************************************************************/ -int +static int islpci_alloc_memory(islpci_private *priv) { int counter; diff --git a/drivers/net/wireless/prism54/islpci_dev.h b/drivers/net/wireless/prism54/islpci_dev.h index 19fbd6bfdfff..e0ec5de036f5 100644 --- a/drivers/net/wireless/prism54/islpci_dev.h +++ b/drivers/net/wireless/prism54/islpci_dev.h @@ -210,8 +210,6 @@ islpci_trigger(islpci_private *priv) struct net_device_stats *islpci_statistics(struct net_device *); -int prism54_bring_down(islpci_private *); -int islpci_alloc_memory(islpci_private *); int islpci_free_memory(islpci_private *); struct net_device *islpci_setup(struct pci_dev *); #endif /* _ISLPCI_DEV_H */ diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c index 4f82bfa1e6de..9ae71e92b08d 100644 --- a/drivers/net/wireless/prism54/islpci_eth.c +++ b/drivers/net/wireless/prism54/islpci_eth.c @@ -121,7 +121,7 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev) /* Check alignment and WDS frame formatting. The start of the packet should * be aligned on a 4-byte boundary. If WDS is enabled add another 6 bytes * and add WDS address information */ - if (unlikely(((long) skb->data & 0x03) | init_wds)) { + if (likely(((long) skb->data & 0x03) | init_wds)) { /* get the number of bytes to add and re-allign */ offset = (4 - (long) skb->data) & 0x03; offset += init_wds ? 6 : 0; @@ -156,6 +156,12 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev) } else { newskb = dev_alloc_skb(init_wds ? skb->len + 6 : skb->len); + if (unlikely(newskb == NULL)) { + printk(KERN_ERR "%s: Cannot allocate skb\n", + ndev->name); + err = -ENOMEM; + goto drop_free; + } newskb_offset = (4 - (long) newskb->data) & 0x03; /* Check if newskb->data is aligned */ diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c index 3fe59fb8ffa8..35bde675a6a1 100644 --- a/drivers/net/wireless/prism54/islpci_hotplug.c +++ b/drivers/net/wireless/prism54/islpci_hotplug.c @@ -38,81 +38,111 @@ MODULE_LICENSE("GPL"); /* In this order: vendor, device, subvendor, subdevice, class, class_mask, * driver_data - * Note: for driver_data we put the device's name * If you have an update for this please contact prism54-devel@prism54.org * The latest list can be found at http://prism54.org/supported_cards.php */ static const struct pci_device_id prism54_id_tbl[] = { + /* 3COM 3CRWE154G72 Wireless LAN adapter */ { PCIVENDOR_3COM, PCIDEVICE_3COM6001, PCIVENDOR_3COM, PCIDEVICE_3COM6001, - 0, 0, - (unsigned long) "3COM 3CRWE154G72 Wireless LAN adapter"}, + 0, 0, 0 + }, + + /* D-Link Air Plus Xtreme G A1 - DWL-g650 A1 */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_DLINK, 0x3202UL, - 0, 0, - (unsigned long) "D-Link Air Plus Xtreme G A1 - DWL-g650 A1"}, + 0, 0, 0 + }, + + /* I-O Data WN-G54/CB - WN-G54/CB */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_IODATA, 0xd019UL, - 0, 0, - (unsigned long) "I-O Data WN-G54/CB - WN-G54/CB"}, + 0, 0, 0 + }, + + /* Netgear WG511 */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_NETGEAR, 0x4800UL, - 0, 0, - (unsigned long) "Netgear WG511"}, + 0, 0, 0 + }, + + /* Tekram Technology clones, Allnet, Netcomm, Zyxel */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_I4, 0x0020UL, - 0, 0, - (unsigned long) "PLANEX GW-DS54G"}, + PCIVENDOR_TTL, 0x1605UL, + 0, 0, 0 + }, + + /* SMC2802W */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_SMC, 0x2802UL, - 0, 0, - (unsigned long) "EZ Connect g 2.4GHz 54 Mbps Wireless PCI Card - SMC2802W"}, + 0, 0, 0 + }, + + /* SMC2835W */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_SMC, 0x2835UL, - 0, 0, - (unsigned long) "EZ Connect g 2.4GHz 54 Mbps Wireless Cardbus Adapter - SMC2835W"}, + 0, 0, 0 + }, + + /* Corega CG-WLCB54GT */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, - PCIVENDOR_INTERSIL, 0x0000UL, /* This was probably a bogus reading... */ - 0, 0, - (unsigned long) "SparkLAN WL-850F"}, + PCIVENDOR_ATI, 0xc104UL, + 0, 0, 0 + }, + + /* I4 Z-Com XG-600 */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_I4, 0x0014UL, - 0, 0, - (unsigned long) "I4 Z-Com XG-600"}, + 0, 0, 0 + }, + + /* I4 Z-Com XG-900 and clones Macer, Ovislink, Planex, Peabird, */ + /* Sitecom, Xterasys */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_I4, 0x0020UL, - 0, 0, - (unsigned long) "I4 Z-Com XG-900/PLANEX GW-DS54G"}, + 0, 0, 0 + }, + + /* SMC 2802W V2 */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_ACCTON, 0xee03UL, - 0, 0, - (unsigned long) "SMC 2802Wv2"}, + 0, 0, 0 + }, + + /* SMC 2835W V2 */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCIVENDOR_SMC, 0xa835UL, - 0, 0, - (unsigned long) "SMC 2835Wv2"}, + 0, 0, 0 + }, + + /* Intersil PRISM Indigo Wireless LAN adapter */ { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3877, PCI_ANY_ID, PCI_ANY_ID, - 0, 0, - (unsigned long) "Intersil PRISM Indigo Wireless LAN adapter"}, - { /* Default */ + 0, 0, 0 + }, + + /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ + /* Default */ + { PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890, PCI_ANY_ID, PCI_ANY_ID, - 0, 0, - (unsigned long) "Intersil PRISM Duette/Prism GT Wireless LAN adapter"}, - {0,} + 0, 0, 0 + }, + + /* End of list */ + {0,0,0,0,0,0,0} }; /* register the device with the Hotplug facilities of the kernel */ @@ -138,12 +168,16 @@ prism54_get_card_model(struct net_device *ndev) { islpci_private *priv; char *modelp; + int notwork = 0; priv = netdev_priv(ndev); switch (priv->pdev->subsystem_device) { case PCIDEVICE_ISL3877: modelp = "PRISM Indigo"; break; + case PCIDEVICE_ISL3886: + modelp = "PRISM Javelin / Xbow"; + break; case PCIDEVICE_3COM6001: modelp = "3COM 3CRWE154G72"; break; @@ -161,12 +195,20 @@ prism54_get_card_model(struct net_device *ndev) break; case 0xee03UL: modelp = "SMC2802W V2"; + notwork = 1; break; case 0x2835UL: modelp = "SMC2835W"; break; case 0xa835UL: modelp = "SMC2835W V2"; + notwork = 1; + break; + case 0xc104UL: + modelp = "CG-WLCB54GT"; + break; + case 0x1605UL: + modelp = "Tekram Technology clone"; break; /* Let's leave this one out for now since it seems bogus/wrong * Even if the manufacturer did use 0x0000UL it may not be correct @@ -177,10 +219,10 @@ prism54_get_card_model(struct net_device *ndev) /* We have two reported for the one below :( */ case 0x0014UL: - modelp = "XG-600"; + modelp = "I4 Z-Com XG-600 and clones"; break; case 0x0020UL: - modelp = "XG-900/GW-DS54G"; + modelp = "I4 Z-Com XG-900 and clones"; break; /* Default it */ /* @@ -193,6 +235,10 @@ prism54_get_card_model(struct net_device *ndev) } printk(KERN_DEBUG "%s: %s driver detected card model: %s\n", ndev->name, DRV_NAME, modelp); + if ( notwork ) { + printk(KERN_DEBUG "%s: %s Warning - This may not work\n", + ndev->name, DRV_NAME); + } return; } @@ -247,8 +293,13 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id) * Writing zero to both these two registers will disable both timeouts and * *can* solve problems caused by devices that are slow to respond. */ + /* I am taking these out, we should not be poking around in the + * programmable timers - MSW + */ +/* Do not zero the programmable timers pci_write_config_byte(pdev, 0x40, 0); pci_write_config_byte(pdev, 0x41, 0); +*/ /* request the pci device I/O regions */ rvalue = pci_request_regions(pdev, DRV_NAME); @@ -270,6 +321,9 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id) DEBUG(SHOW_TRACING, "%s: pci_set_master(pdev)\n", DRV_NAME); pci_set_master(pdev); + /* enable MWI */ + pci_set_mwi(pdev); + /* setup the network device interface and its structure */ if (!(ndev = islpci_setup(pdev))) { /* error configuring the driver as a network device */ diff --git a/drivers/net/wireless/prism54/islpci_mgt.h b/drivers/net/wireless/prism54/islpci_mgt.h index 72cb87a9616d..2e8f8ea9c7de 100644 --- a/drivers/net/wireless/prism54/islpci_mgt.h +++ b/drivers/net/wireless/prism54/islpci_mgt.h @@ -46,8 +46,11 @@ extern int pc_debug; #define PCIVENDOR_NETGEAR 0x1385UL #define PCIVENDOR_SMC 0x10b8UL #define PCIVENDOR_ACCTON 0x1113UL +#define PCIVENDOR_ATI 0x1259UL +#define PCIVENDOR_TTL 0x16a5UL #define PCIDEVICE_ISL3877 0x3877UL +#define PCIDEVICE_ISL3886 0x3886UL #define PCIDEVICE_ISL3890 0x3890UL #define PCIDEVICE_3COM6001 0x6001UL #define PCIDEVICE_LATENCY_TIMER_MIN 0x40 diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c index 470466d132f3..f4c2d1d4c015 100644 --- a/drivers/net/wireless/prism54/oid_mgt.c +++ b/drivers/net/wireless/prism54/oid_mgt.c @@ -675,7 +675,7 @@ mgt_commit(islpci_private *priv) /* This will tell you if you are allowed to answer a mlme(ex) request .*/ -inline int +int mgt_mlme_answer(islpci_private *priv) { u32 mlmeautolevel; @@ -692,7 +692,7 @@ mgt_mlme_answer(islpci_private *priv) (mlmeautolevel >= DOT11_MLME_INTERMEDIATE)); } -inline enum oid_num_t +enum oid_num_t mgt_oidtonum(u32 oid) { int i; diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c index ef0c797fdf87..eaafb42eddf5 100644 --- a/drivers/net/yellowfin.c +++ b/drivers/net/yellowfin.c @@ -65,7 +65,7 @@ static int mtu; static int bogus_rx; static int dma_ctrl = 0x004A0263; /* Constrained by errata */ static int fifo_cfg = 0x0020; /* Bypass external Tx FIFO. */ -#elif YF_NEW /* A future perfect board :->. */ +#elif defined(YF_NEW) /* A future perfect board :->. */ static int dma_ctrl = 0x00CAC277; /* Override when loading module! */ static int fifo_cfg = 0x0028; #else @@ -108,12 +108,6 @@ static int gx_fix; #define yellowfin_debug debug -#if !defined(__OPTIMIZE__) -#warning You must compile this file with the correct options! -#warning See the last lines of the source file. -#error You must compile this driver with "-O". -#endif - #include <linux/module.h> #include <linux/kernel.h> #include <linux/string.h> diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c index 2dac57b618a3..e5d06ea62b4c 100644 --- a/drivers/oprofile/buffer_sync.c +++ b/drivers/oprofile/buffer_sync.c @@ -35,7 +35,7 @@ #define DEFAULT_EXPIRE (HZ / 4) static void wq_sync_buffers(void *); -static DECLARE_WORK(sync_wq, wq_sync_buffers, 0); +static DECLARE_WORK(sync_wq, wq_sync_buffers, NULL); static struct timer_list sync_timer; static void timer_ping(unsigned long data); @@ -425,7 +425,7 @@ static void increment_tail(struct oprofile_cpu_buffer * b) */ static void sync_buffer(struct oprofile_cpu_buffer * cpu_buf) { - struct mm_struct * mm = 0; + struct mm_struct *mm = NULL; struct task_struct * new; unsigned long cookie = 0; int in_kernel = 1; diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c index 23979d38dde7..7ee6a3d99a8a 100644 --- a/drivers/oprofile/cpu_buffer.c +++ b/drivers/oprofile/cpu_buffer.c @@ -57,7 +57,7 @@ int alloc_cpu_buffers(void) if (!b->buffer) goto fail; - b->last_task = 0; + b->last_task = NULL; b->last_is_kernel = -1; b->buffer_size = buffer_size; b->tail_pos = 0; @@ -176,5 +176,5 @@ void cpu_buffer_reset(struct oprofile_cpu_buffer * cpu_buf) * values to initialize the buffer */ cpu_buf->last_is_kernel = -1; - cpu_buf->last_task = 0; + cpu_buf->last_task = NULL; } diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 4b394ac31435..b80990df0a90 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c @@ -176,11 +176,11 @@ static struct dentry * __oprofilefs_create_file(struct super_block * sb, qname.hash = full_name_hash(qname.name, qname.len); dentry = d_alloc(root, &qname); if (!dentry) - return 0; + return NULL; inode = oprofilefs_get_inode(sb, S_IFREG | perm); if (!inode) { dput(dentry); - return 0; + return NULL; } inode->i_fop = fops; d_add(dentry, inode); @@ -269,11 +269,11 @@ struct dentry * oprofilefs_mkdir(struct super_block * sb, qname.hash = full_name_hash(qname.name, qname.len); dentry = d_alloc(root, &qname); if (!dentry) - return 0; + return NULL; inode = oprofilefs_get_inode(sb, S_IFDIR | 0755); if (!inode) { dput(dentry); - return 0; + return NULL; } inode->i_op = &simple_dir_inode_operations; inode->i_fop = &simple_dir_operations; diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index fe4cc866de08..dfc8a84047c2 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -2147,7 +2147,7 @@ struct parport *parport_pc_probe_port (unsigned long int base, priv->ctr_writable = ~0x10; priv->ecr = 0; priv->fifo_depth = 0; - priv->dma_buf = 0; + priv->dma_buf = NULL; priv->dma_handle = 0; priv->dev = dev; INIT_LIST_HEAD(&priv->list); diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index 213a1a3b499c..42b23049a7fc 100644 --- a/drivers/pci/hotplug.c +++ b/drivers/pci/hotplug.c @@ -59,7 +59,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, if ((buffer_size - length <= 0) || (i >= num_envp)) return -ENOMEM; - envp[i] = 0; + envp[i] = NULL; return 0; } diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 7229b2d10c08..95c17f254948 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -837,7 +837,7 @@ static void adpt_i2o_sys_shutdown(void) kfree(p1); } // spin_unlock_irqrestore(&adpt_post_wait_lock, flags); - adpt_post_wait_queue = 0; + adpt_post_wait_queue = NULL; printk(KERN_INFO "Adaptec I2O controllers down.\n"); } diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index 09f49cbb5539..0153b774757b 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -492,7 +492,7 @@ void scsi_exit_devinfo(void) struct scsi_dev_info_list *devinfo; #ifdef CONFIG_SCSI_PROC_FS - remove_proc_entry("scsi/device_info", 0); + remove_proc_entry("scsi/device_info", NULL); #endif list_for_each_safe(lh, lh_next, &scsi_dev_info_list) { diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index 92faba6450d4..a50958b1b6ee 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -312,7 +312,7 @@ int __init scsi_init_procfs(void) { struct proc_dir_entry *pde; - proc_scsi = proc_mkdir("scsi", 0); + proc_scsi = proc_mkdir("scsi", NULL); if (!proc_scsi) goto err1; @@ -324,13 +324,13 @@ int __init scsi_init_procfs(void) return 0; err2: - remove_proc_entry("scsi", 0); + remove_proc_entry("scsi", NULL); err1: return -ENOMEM; } void scsi_exit_procfs(void) { - remove_proc_entry("scsi/scsi", 0); - remove_proc_entry("scsi", 0); + remove_proc_entry("scsi/scsi", NULL); + remove_proc_entry("scsi", NULL); } diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index fec122a8d690..a8855d324306 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -625,4 +625,4 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost) /* A blank transport template that is used in drivers that don't * yet implement Transport Attributes */ -struct scsi_transport_template blank_transport_template = { 0, }; +struct scsi_transport_template blank_transport_template = { NULL, }; diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 3dfe20e69755..23375e4d738a 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -2404,7 +2404,7 @@ sg_add_sfp(Sg_device * sdp, int dev) Sg_fd *sfp; unsigned long iflags; - sfp = (Sg_fd *) sg_page_malloc(sizeof (Sg_fd), 0, 0); + sfp = (Sg_fd *) sg_page_malloc(sizeof (Sg_fd), 0, NULL); if (!sfp) return NULL; memset(sfp, 0, sizeof (Sg_fd)); @@ -2814,7 +2814,7 @@ sg_proc_write_adio(struct file *filp, const char __user *buffer, if (copy_from_user(buff, buffer, num)) return -EFAULT; buff[num] = '\0'; - sg_allow_dio = simple_strtoul(buff, 0, 10) ? 1 : 0; + sg_allow_dio = simple_strtoul(buff, NULL, 10) ? 1 : 0; return count; } @@ -2837,7 +2837,7 @@ sg_proc_write_dressz(struct file *filp, const char __user *buffer, if (copy_from_user(buff, buffer, num)) return -EFAULT; buff[num] = '\0'; - k = simple_strtoul(buff, 0, 10); + k = simple_strtoul(buff, NULL, 10); if (k <= 1048576) { /* limit "big buff" to 1 MB */ sg_big_buff = k; return count; diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c index 3b3427e0bc83..f12002f617f8 100644 --- a/drivers/serial/8250_pci.c +++ b/drivers/serial/8250_pci.c @@ -497,7 +497,7 @@ static struct timedia_struct { { 2, timedia_dual_port }, { 4, timedia_quad_port }, { 8, timedia_eight_port }, - { 0, 0 } + { 0, NULL } }; static int __devinit pci_timedia_init(struct pci_dev *dev) diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c index 2f215ce80c86..b8510bbb7891 100644 --- a/drivers/serial/8250_pnp.c +++ b/drivers/serial/8250_pnp.c @@ -334,7 +334,7 @@ static char *modem_names[] __devinitdata = { "MODEM", "Modem", "modem", "FAX", "Fax", "fax", "56K", "56k", "K56", "33.6", "28.8", "14.4", "33,600", "28,800", "14,400", "33.600", "28.800", "14.400", - "33600", "28800", "14400", "V.90", "V.34", "V.32", 0 + "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL }; static int __devinit check_name(char *name) diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 20a717fac9ba..b6da40067c0e 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -851,7 +851,7 @@ static int usblp_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *dev = interface_to_usbdev (intf); - struct usblp *usblp = 0; + struct usblp *usblp = NULL; int protocol; int retval; @@ -1019,7 +1019,7 @@ static int usblp_select_alts(struct usblp *usblp) continue; /* Look for bulk OUT and IN endpoints. */ - epwrite = epread = 0; + epwrite = epread = NULL; for (e = 0; e < ifd->desc.bNumEndpoints; e++) { epd = &ifd->endpoint[e].desc; diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index a649e32d9dde..1e2a42ad34a4 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -94,7 +94,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd) struct dma_pool *pool = hcd->pool [i]; if (pool) { dma_pool_destroy (pool); - hcd->pool [i] = 0; + hcd->pool[i] = NULL; } } } diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c index 06f667d33ea9..ae7ec74052fb 100644 --- a/drivers/usb/core/config.c +++ b/drivers/usb/core/config.c @@ -414,7 +414,7 @@ void usb_destroy_configuration(struct usb_device *dev) kfree(dev->rawdescriptors[i]); kfree(dev->rawdescriptors); - dev->rawdescriptors = 0; + dev->rawdescriptors = NULL; } for (c = 0; c < dev->descriptor.bNumConfigurations; c++) { @@ -426,7 +426,7 @@ void usb_destroy_configuration(struct usb_device *dev) } } kfree(dev->config); - dev->config = 0; + dev->config = NULL; } diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 6f61c8fb58a2..e5ac6f83dbe1 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1090,10 +1090,10 @@ static int proc_ioctl (struct dev_state *ps, void __user *arg) { struct usbdevfs_ioctl ctrl; int size; - void *buf = 0; + void *buf = NULL; int retval = 0; - struct usb_interface *intf = 0; - struct usb_driver *driver = 0; + struct usb_interface *intf = NULL; + struct usb_driver *driver = NULL; /* get input parameters and alloc buffer */ if (copy_from_user(&ctrl, arg, sizeof (ctrl))) diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 3a710e037c70..e7a7ba51371f 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c @@ -247,7 +247,7 @@ void usb_hcd_pci_remove (struct pci_dev *dev) hcd->driver->stop (hcd); hcd_buffer_destroy (hcd); hcd->state = USB_STATE_HALT; - pci_set_drvdata (dev, 0); + pci_set_drvdata(dev, NULL); free_irq (hcd->irq, hcd); if (hcd->driver->flags & HCD_MEMORY) { diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index ecac9fac2727..705b16c99a9d 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -326,7 +326,7 @@ static int rh_call_control (struct usb_hcd *hcd, struct urb *urb) { struct usb_ctrlrequest *cmd; u16 typeReq, wValue, wIndex, wLength; - const u8 *bufp = 0; + const u8 *bufp = NULL; u8 *ubuf = urb->transfer_buffer; int len = 0; int patch_wakeup = 0; @@ -536,7 +536,7 @@ static void rh_report_status (unsigned long ptr) hcd->rh_timer.data = 0; urb->actual_length = length; urb->status = 0; - urb->hcpriv = 0; + urb->hcpriv = NULL; } else mod_timer (&hcd->rh_timer, jiffies + HZ/4); spin_unlock (&hcd_data_lock); @@ -578,7 +578,7 @@ void usb_rh_status_dequeue (struct usb_hcd *hcd, struct urb *urb) hcd->rh_timer.data = 0; local_irq_save (flags); - urb->hcpriv = 0; + urb->hcpriv = NULL; usb_hcd_giveback_urb (hcd, urb, NULL); local_irq_restore (flags); } @@ -1207,8 +1207,8 @@ static void unlink_complete (struct urb *urb, struct pt_regs *regs) static int hcd_unlink_urb (struct urb *urb) { struct hcd_dev *dev; - struct usb_hcd *hcd = 0; - struct device *sys = 0; + struct usb_hcd *hcd = NULL; + struct device *sys = NULL; unsigned long flags; struct completion_splice splice; struct list_head *tmp; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 37f8ab3c8dae..093f2d032345 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -288,9 +288,9 @@ done: static inline int hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt) { - return usb_control_msg (hdev, usb_rcvctrlpipe (hdev, 0), - HUB_CLEAR_TT_BUFFER, USB_RT_PORT, - devinfo, tt, 0, 0, HZ); + return usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), + HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo, + tt, NULL, 0, HZ); } /* diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 18a5da45e673..9c55d91da87b 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -91,8 +91,8 @@ int usb_internal_control_msg(struct usb_device *usb_dev, unsigned int pipe, if (!urb) return -ENOMEM; - usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char*)cmd, data, len, - usb_api_blocking_completion, 0); + usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, + len, usb_api_blocking_completion, NULL); retv = usb_start_wait_urb(urb, timeout, &length); if (retv < 0) @@ -190,7 +190,7 @@ int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, return -ENOMEM; usb_fill_bulk_urb(urb, usb_dev, pipe, data, len, - usb_api_blocking_completion, 0); + usb_api_blocking_completion, NULL); return usb_start_wait_urb(urb,timeout,actual_length); } @@ -203,11 +203,11 @@ static void sg_clean (struct usb_sg_request *io) while (io->entries--) usb_free_urb (io->urbs [io->entries]); kfree (io->urbs); - io->urbs = 0; + io->urbs = NULL; } if (io->dev->dev.dma_mask != 0) usb_buffer_unmap_sg (io->dev, io->pipe, io->sg, io->nents); - io->dev = 0; + io->dev = NULL; } static void sg_complete (struct urb *urb, struct pt_regs *regs) @@ -260,7 +260,7 @@ static void sg_complete (struct urb *urb, struct pt_regs *regs) found = 1; } } - urb->dev = 0; + urb->dev = NULL; /* on the last completion, signal usb_sg_wait() */ io->bytes += urb->actual_length; @@ -356,7 +356,7 @@ int usb_sg_init ( goto nomem; } - io->urbs [i]->dev = 0; + io->urbs [i]->dev = NULL; io->urbs [i]->pipe = pipe; io->urbs [i]->interval = period; io->urbs [i]->transfer_flags = urb_flags; @@ -459,7 +459,7 @@ void usb_sg_wait (struct usb_sg_request *io) case -ENXIO: // hc didn't queue this one case -EAGAIN: case -ENOMEM: - io->urbs [i]->dev = 0; + io->urbs[i]->dev = NULL; retval = 0; i--; yield (); @@ -485,7 +485,7 @@ void usb_sg_wait (struct usb_sg_request *io) complete (&io->complete); spin_unlock_irq (&io->lock); - io->urbs [i]->dev = 0; + io->urbs[i]->dev = NULL; io->urbs [i]->status = retval; dev_dbg (&io->dev->dev, "%s, submit --> %d\n", __FUNCTION__, retval); @@ -838,7 +838,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0) put_device (&dev->actconfig->interface[i]->dev); dev->actconfig->interface[i] = NULL; } - dev->actconfig = 0; + dev->actconfig = NULL; if (dev->state == USB_STATE_CONFIGURED) usb_set_device_state(dev, USB_STATE_ADDRESS); } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 3a16e07d0185..e2fc7d5c1c3a 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -649,7 +649,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, scratch += length; } - envp [i++] = 0; + envp[i++] = NULL; return 0; } @@ -975,7 +975,7 @@ void *usb_buffer_alloc ( ) { if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_alloc) - return 0; + return NULL; return dev->bus->op->buffer_alloc (dev->bus, size, mem_flags, dma); } @@ -1027,7 +1027,7 @@ struct urb *usb_buffer_map (struct urb *urb) || !urb->dev || !(bus = urb->dev->bus) || !(controller = bus->controller)) - return 0; + return NULL; if (controller->dma_mask) { urb->transfer_dma = dma_map_single (controller, diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index fc5ba40c0fa1..506006be87d7 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -415,7 +415,7 @@ static int ehci_start (struct usb_hcd *hcd) else // N microframes cached ehci->i_thresh = 2 + HCC_ISOC_THRES (hcc_params); - ehci->reclaim = 0; + ehci->reclaim = NULL; ehci->next_uframe = -1; /* controller state: unknown --> reset */ @@ -462,7 +462,7 @@ static int ehci_start (struct usb_hcd *hcd) * its dummy is used in hw_alt_next of many tds, to prevent the qh * from automatically advancing to the next td after short reads. */ - ehci->async->qh_next.qh = 0; + ehci->async->qh_next.qh = NULL; ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma); ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD); ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT); @@ -985,7 +985,7 @@ idle_timeout: list_empty (&qh->qtd_list) ? "" : "(has tds)"); break; } - dev->ep [epnum] = 0; + dev->ep[epnum] = NULL; done: spin_unlock_irqrestore (&ehci->lock, flags); return; diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index f7210234507f..452c73ede7df 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -71,7 +71,7 @@ static int ehci_hub_suspend (struct usb_hcd *hcd) writel (ehci->command & ~CMD_RUN, &ehci->regs->command); if (ehci->reclaim) ehci->reclaim_ready = 1; - ehci_work (ehci, 0); + ehci_work(ehci, NULL); (void) handshake (&ehci->regs->status, STS_HALT, STS_HALT, 2000); root->dev.power.power_state = 3; diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c index 5f9381622584..31f311d53b05 100644 --- a/drivers/usb/host/ehci-mem.c +++ b/drivers/usb/host/ehci-mem.c @@ -47,7 +47,7 @@ static struct usb_hcd *ehci_hcd_alloc (void) ehci->hcd.product_desc = "EHCI Host Controller"; return &ehci->hcd; } - return 0; + return NULL; } static void ehci_hcd_free (struct usb_hcd *hcd) @@ -125,7 +125,7 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, int flags) if (qh->dummy == 0) { ehci_dbg (ehci, "no dummy td\n"); dma_pool_free (ehci->qh_pool, qh, qh->qh_dma); - qh = 0; + qh = NULL; } return qh; } @@ -153,36 +153,36 @@ static void ehci_mem_cleanup (struct ehci_hcd *ehci) { if (ehci->async) qh_put (ehci->async); - ehci->async = 0; + ehci->async = NULL; /* DMA consistent memory and pools */ if (ehci->qtd_pool) dma_pool_destroy (ehci->qtd_pool); - ehci->qtd_pool = 0; + ehci->qtd_pool = NULL; if (ehci->qh_pool) { dma_pool_destroy (ehci->qh_pool); - ehci->qh_pool = 0; + ehci->qh_pool = NULL; } if (ehci->itd_pool) dma_pool_destroy (ehci->itd_pool); - ehci->itd_pool = 0; + ehci->itd_pool = NULL; if (ehci->sitd_pool) dma_pool_destroy (ehci->sitd_pool); - ehci->sitd_pool = 0; + ehci->sitd_pool = NULL; if (ehci->periodic) dma_free_coherent (ehci->hcd.self.controller, ehci->periodic_size * sizeof (u32), ehci->periodic, ehci->periodic_dma); - ehci->periodic = 0; + ehci->periodic = NULL; /* shadow periodic table */ if (ehci->pshadow) kfree (ehci->pshadow); - ehci->pshadow = 0; + ehci->pshadow = NULL; } /* remember to add cleanup code (above) if you add anything here */ diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 7c39b86d1fd7..be39e7abadc1 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -197,7 +197,7 @@ ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb, struct pt_regs *regs) } spin_lock (&urb->lock); - urb->hcpriv = 0; + urb->hcpriv = NULL; switch (urb->status) { case -EINPROGRESS: /* success */ urb->status = 0; @@ -242,7 +242,7 @@ ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb, struct pt_regs *regs) static unsigned qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs) { - struct ehci_qtd *last = 0, *end = qh->dummy; + struct ehci_qtd *last = NULL, *end = qh->dummy; struct list_head *entry, *tmp; int stopped; unsigned count = 0; @@ -282,7 +282,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs) count++; } ehci_qtd_free (ehci, last); - last = 0; + last = NULL; } /* ignore urbs submitted during completions we reported */ @@ -383,7 +383,7 @@ halt: struct ehci_qtd, qtd_list); /* first qtd may already be partially processed */ if (cpu_to_le32 (end->qtd_dma) == qh->hw_current) - end = 0; + end = NULL; } if (end) qh_update (ehci, qh, end); @@ -440,7 +440,7 @@ qh_urb_transaction ( */ qtd = ehci_qtd_alloc (ehci, flags); if (unlikely (!qtd)) - return 0; + return NULL; list_add_tail (&qtd->qtd_list, head); qtd->urb = urb; @@ -555,7 +555,7 @@ qh_urb_transaction ( cleanup: qtd_list_free (ehci, urb, head); - return 0; + return NULL; } /*-------------------------------------------------------------------------*/ @@ -709,7 +709,7 @@ qh_make ( dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed); done: qh_put (qh); - return 0; + return NULL; } /* NOTE: if (PIPE_INTERRUPT) { scheduler sets s-mask } */ @@ -780,19 +780,19 @@ static struct ehci_qh *qh_append_tds ( void **ptr ) { - struct ehci_qh *qh = 0; + struct ehci_qh *qh = NULL; qh = (struct ehci_qh *) *ptr; - if (unlikely (qh == 0)) { + if (unlikely (qh == NULL)) { /* can't sleep here, we have ehci->lock... */ qh = qh_make (ehci, urb, GFP_ATOMIC); *ptr = qh; } - if (likely (qh != 0)) { + if (likely (qh != NULL)) { struct ehci_qtd *qtd; if (unlikely (list_empty (qtd_list))) - qtd = 0; + qtd = NULL; else qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); @@ -900,7 +900,7 @@ submit_async ( struct hcd_dev *dev; int epnum; unsigned long flags; - struct ehci_qh *qh = 0; + struct ehci_qh *qh = NULL; qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); dev = (struct hcd_dev *)urb->dev->hcpriv; @@ -950,14 +950,14 @@ static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs) // qh->hw_next = cpu_to_le32 (qh->qh_dma); qh->qh_state = QH_STATE_IDLE; - qh->qh_next.qh = 0; + qh->qh_next.qh = NULL; qh_put (qh); // refcount from reclaim /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ next = qh->reclaim; ehci->reclaim = next; ehci->reclaim_ready = 0; - qh->reclaim = 0; + qh->reclaim = NULL; qh_completions (ehci, qh, regs); @@ -976,7 +976,7 @@ static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs) } if (next) { - ehci->reclaim = 0; + ehci->reclaim = NULL; start_unlink_async (ehci, next); } } diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index d3bcf48187f4..597fec73d900 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c @@ -89,7 +89,7 @@ static int periodic_unlink (struct ehci_hcd *ehci, unsigned frame, void *ptr) /* unlink from shadow list; HCD won't see old structure again */ *prev_p = *next_p; - next_p->ptr = 0; + next_p->ptr = NULL; return 1; } @@ -317,7 +317,7 @@ static void intr_deschedule ( } while (frame < ehci->periodic_size); qh->qh_state = QH_STATE_UNLINK; - qh->qh_next.ptr = 0; + qh->qh_next.ptr = NULL; ehci->periodic_sched--; /* maybe turn off periodic schedule */ @@ -718,7 +718,7 @@ iso_stream_put(struct ehci_hcd *ehci, struct ehci_iso_stream *stream) is_in = (stream->bEndpointAddress & USB_DIR_IN) ? 0x10 : 0; stream->bEndpointAddress &= 0x0f; - dev->ep [is_in + stream->bEndpointAddress] = 0; + dev->ep[is_in + stream->bEndpointAddress] = NULL; if (stream->rescheduled) { ehci_info (ehci, "ep%d%s-iso rescheduled " @@ -772,7 +772,7 @@ iso_stream_find (struct ehci_hcd *ehci, struct urb *urb) ehci_dbg (ehci, "dev %s ep%d%s, not iso??\n", urb->dev->devpath, epnum & 0x0f, (epnum & 0x10) ? "in" : "out"); - stream = 0; + stream = NULL; } /* caller guarantees an eventual matching iso_stream_put */ @@ -896,7 +896,7 @@ itd_urb_transaction ( list_del (&itd->itd_list); itd_dma = itd->itd_dma; } else - itd = 0; + itd = NULL; if (!itd) { spin_unlock_irqrestore (&ehci->lock, flags); @@ -1116,7 +1116,7 @@ iso_stream_schedule ( fail: iso_sched_free (stream, sched); - urb->hcpriv = 0; + urb->hcpriv = NULL; return status; ready: @@ -1215,8 +1215,8 @@ itd_link_urb ( hcd_to_bus (&ehci->hcd)->bandwidth_isoc_reqs++; /* fill iTDs uframe by uframe */ - for (packet = 0, itd = 0; packet < urb->number_of_packets; ) { - if (itd == 0) { + for (packet = 0, itd = NULL; packet < urb->number_of_packets; ) { + if (itd == NULL) { /* ASSERT: we have all necessary itds */ // BUG_ON (list_empty (&iso_sched->td_list)); @@ -1247,14 +1247,14 @@ itd_link_urb ( if (((next_uframe >> 3) != frame) || packet == urb->number_of_packets) { itd_link (ehci, frame % ehci->periodic_size, itd); - itd = 0; + itd = NULL; } } stream->next_uframe = next_uframe; /* don't need that schedule data any more */ iso_sched_free (stream, iso_sched); - urb->hcpriv = 0; + urb->hcpriv = NULL; timer_action (ehci, TIMER_IO_WATCHDOG); if (unlikely (!ehci->periodic_sched++)) @@ -1311,8 +1311,8 @@ itd_complete ( } usb_put_urb (urb); - itd->urb = 0; - itd->stream = 0; + itd->urb = NULL; + itd->stream = NULL; list_move (&itd->itd_list, &stream->free_list); iso_stream_put (ehci, stream); @@ -1328,7 +1328,7 @@ itd_complete ( /* give urb back to the driver ... can be out-of-order */ dev = usb_get_dev (urb->dev); ehci_urb_done (ehci, urb, regs); - urb = 0; + urb = NULL; /* defer stopping schedule; completion can submit */ ehci->periodic_sched--; @@ -1903,7 +1903,7 @@ restart: dbg ("corrupt type %d frame %d shadow %p", type, frame, q.ptr); // BUG (); - q.ptr = 0; + q.ptr = NULL; } /* assume completion callbacks modify the queue */ diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index aefc4950b4c9..1ae4aa4b6e3e 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -2533,7 +2533,7 @@ static int __init uhci_hcd_init(void) } #ifdef CONFIG_PROC_FS - uhci_proc_root = create_proc_entry("driver/uhci", S_IFDIR, 0); + uhci_proc_root = create_proc_entry("driver/uhci", S_IFDIR, NULL); if (!uhci_proc_root) goto proc_failed; #endif @@ -2556,7 +2556,7 @@ init_failed: up_failed: #ifdef CONFIG_PROC_FS - remove_proc_entry("driver/uhci", 0); + remove_proc_entry("driver/uhci", NULL); proc_failed: #endif @@ -2576,7 +2576,7 @@ static void __exit uhci_hcd_cleanup(void) warn("not all urb_priv's were freed!"); #ifdef CONFIG_PROC_FS - remove_proc_entry("driver/uhci", 0); + remove_proc_entry("driver/uhci", NULL); #endif if (errbuf) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index c2ccdabd01fb..ad22739bee82 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -211,7 +211,7 @@ static struct us_unusual_dev us_unusual_dev_list[] = { .useTransport = US_PR_BULK}, /* Terminating entry */ - { 0 } + { NULL } }; struct usb_driver usb_storage_driver = { diff --git a/fs/dcookies.c b/fs/dcookies.c index 70fd5f13874b..8ecfe5ecb3c3 100644 --- a/fs/dcookies.c +++ b/fs/dcookies.c @@ -60,7 +60,7 @@ static size_t dcookie_hash(unsigned long dcookie) static struct dcookie_struct * find_dcookie(unsigned long dcookie) { - struct dcookie_struct * found = 0; + struct dcookie_struct *found = NULL; struct dcookie_struct * dcs; struct list_head * pos; struct list_head * list; diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 454cde6adbd8..694e6ee40690 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -133,7 +133,7 @@ static int ext2_alloc_block (struct inode * inode, unsigned long goal, int *err) &ei->i_prealloc_count, &ei->i_prealloc_block, err); else - result = ext2_new_block (inode, goal, 0, 0, err); + result = ext2_new_block(inode, goal, NULL, NULL, err); } #else result = ext2_new_block (inode, goal, 0, 0, err); diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c index 76ad9815fb20..b2bb90817371 100644 --- a/fs/ext3/dir.c +++ b/fs/ext3/dir.c @@ -129,7 +129,7 @@ static int ext3_readdir(struct file * filp, while (!error && !stored && filp->f_pos < inode->i_size) { blk = (filp->f_pos) >> EXT3_BLOCK_SIZE_BITS(sb); - bh = ext3_bread (0, inode, blk, 0, &err); + bh = ext3_bread(NULL, inode, blk, 0, &err); if (!bh) { ext3_error (sb, "ext3_readdir", "directory #%lu contains a hole at offset %lu", @@ -295,14 +295,14 @@ static void free_rb_tree_fname(struct rb_root *root) kfree (old); } if (!parent) - root->rb_node = 0; + root->rb_node = NULL; else if (parent->rb_left == n) - parent->rb_left = 0; + parent->rb_left = NULL; else if (parent->rb_right == n) - parent->rb_right = 0; + parent->rb_right = NULL; n = parent; } - root->rb_node = 0; + root->rb_node = NULL; } @@ -313,9 +313,9 @@ struct dir_private_info *create_dir_info(loff_t pos) p = kmalloc(sizeof(struct dir_private_info), GFP_KERNEL); if (!p) return NULL; - p->root.rb_node = 0; - p->curr_node = 0; - p->extra_fname = 0; + p->root.rb_node = NULL; + p->curr_node = NULL; + p->extra_fname = NULL; p->last_pos = 0; p->curr_hash = pos2maj_hash(pos); p->curr_minor_hash = pos2min_hash(pos); @@ -447,8 +447,8 @@ static int ext3_dx_readdir(struct file * filp, /* Some one has messed with f_pos; reset the world */ if (info->last_pos != filp->f_pos) { free_rb_tree_fname(&info->root); - info->curr_node = 0; - info->extra_fname = 0; + info->curr_node = NULL; + info->extra_fname = NULL; info->curr_hash = pos2maj_hash(filp->f_pos); info->curr_minor_hash = pos2min_hash(filp->f_pos); } @@ -472,7 +472,7 @@ static int ext3_dx_readdir(struct file * filp, */ if ((!info->curr_node) || (filp->f_version != inode->i_version)) { - info->curr_node = 0; + info->curr_node = NULL; free_rb_tree_fname(&info->root); filp->f_version = inode->i_version; ret = ext3_htree_fill_tree(filp, info->curr_hash, diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 8cb394f616ba..909b7d9779f7 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -287,7 +287,7 @@ static int ext3_alloc_block (handle_t *handle, &ei->i_prealloc_count, &ei->i_prealloc_block, err); else - result = ext3_new_block (inode, goal, 0, 0, err); + result = ext3_new_block(inode, goal, NULL, NULL, err); /* * AKPM: this is somewhat sticky. I'm not surprised it was * disabled in 2.2's ext3. Need to integrate b_committed_data @@ -296,7 +296,7 @@ static int ext3_alloc_block (handle_t *handle, */ } #else - result = ext3_new_block (handle, inode, goal, 0, 0, err); + result = ext3_new_block(handle, inode, goal, NULL, NULL, err); #endif return result; } @@ -859,7 +859,7 @@ changed: static int ext3_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { - handle_t *handle = 0; + handle_t *handle = NULL; int ret; if (create) { diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 4ee524bee217..36e5b4ec3daf 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -604,7 +604,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash, } hinfo.hash = start_hash; hinfo.minor_hash = 0; - frame = dx_probe(0, dir_file->f_dentry->d_inode, &hinfo, frames, &err); + frame = dx_probe(NULL, dir_file->f_dentry->d_inode, &hinfo, frames, &err); if (!frame) return err; @@ -930,7 +930,7 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry, struct inode *dir = dentry->d_parent->d_inode; sb = dir->i_sb; - if (!(frame = dx_probe (dentry, 0, &hinfo, frames, err))) + if (!(frame = dx_probe(dentry, NULL, &hinfo, frames, err))) return NULL; hash = hinfo.hash; do { @@ -956,7 +956,7 @@ static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry, brelse (bh); /* Check to see if we should continue to search */ retval = ext3_htree_next_block(dir, hash, frame, - frames, 0); + frames, NULL); if (retval < 0) { ext3_warning(sb, __FUNCTION__, "error reading index page in directory #%lu", @@ -1392,7 +1392,7 @@ static int ext3_add_entry (handle_t *handle, struct dentry *dentry, bh = ext3_bread(handle, dir, block, 0, &retval); if(!bh) return retval; - retval = add_dirent_to_buf(handle, dentry, inode, 0, bh); + retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); if (retval != -ENOSPC) return retval; @@ -1429,7 +1429,7 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry, struct ext3_dir_entry_2 *de; int err; - frame = dx_probe(dentry, 0, &hinfo, frames, &err); + frame = dx_probe(dentry, NULL, &hinfo, frames, &err); if (!frame) return err; entries = frame->entries; @@ -1443,9 +1443,9 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry, if (err) goto journal_error; - err = add_dirent_to_buf(handle, dentry, inode, 0, bh); + err = add_dirent_to_buf(handle, dentry, inode, NULL, bh); if (err != -ENOSPC) { - bh = 0; + bh = NULL; goto cleanup; } @@ -1537,7 +1537,7 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry, if (!de) goto cleanup; err = add_dirent_to_buf(handle, dentry, inode, de, bh); - bh = 0; + bh = NULL; goto cleanup; journal_error: diff --git a/fs/ext3/super.c b/fs/ext3/super.c index ad0977b1716e..b50e468c1ca7 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -356,7 +356,7 @@ static int ext3_blkdev_remove(struct ext3_sb_info *sbi) bdev = sbi->journal_bdev; if (bdev) { ret = ext3_blkdev_put(bdev); - sbi->journal_bdev = 0; + sbi->journal_bdev = NULL; } return ret; } @@ -1201,7 +1201,7 @@ static unsigned long descriptor_loc(struct super_block *sb, static int ext3_fill_super (struct super_block *sb, void *data, int silent) { struct buffer_head * bh; - struct ext3_super_block *es = 0; + struct ext3_super_block *es = NULL; struct ext3_sb_info *sbi; unsigned long block; unsigned long sb_block = get_sb_block(&data); @@ -1473,7 +1473,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) #endif INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */ - sb->s_root = 0; + sb->s_root = NULL; needs_recovery = (es->s_last_orphan != 0 || EXT3_HAS_INCOMPAT_FEATURE(sb, diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index e818beec46a5..163db30a214e 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c @@ -786,8 +786,8 @@ ext3_xattr_set_handle2(handle_t *handle, struct inode *inode, EXT3_SB(sb)->s_es->s_first_data_block) + EXT3_I(inode)->i_block_group * EXT3_BLOCKS_PER_GROUP(sb); - int block = ext3_new_block(handle, - inode, goal, 0, 0, &error); + int block = ext3_new_block(handle, inode, goal, + NULL, NULL, &error); if (error) goto cleanup; ea_idebug(inode, "creating block %d", block); diff --git a/fs/isofs/rock.c b/fs/isofs/rock.c index df78cece6a74..c09d4bd4b55a 100644 --- a/fs/isofs/rock.c +++ b/fs/isofs/rock.c @@ -41,7 +41,7 @@ #define CONTINUE_DECLS \ int cont_extent = 0, cont_offset = 0, cont_size = 0; \ - void * buffer = 0 + void *buffer = NULL #define CHECK_CE \ {cont_extent = isonum_733(rr->u.CE.extent); \ diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 72e56d62c373..a540c7f03da6 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c @@ -362,7 +362,7 @@ write_out_data: */ commit_transaction->t_state = T_COMMIT; - descriptor = 0; + descriptor = NULL; bufs = 0; while (commit_transaction->t_buffers) { diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 946eec5e1c31..1cf23ff17c4a 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -1617,7 +1617,7 @@ static void journal_destroy_journal_head_cache(void) { J_ASSERT(journal_head_cache != NULL); kmem_cache_destroy(journal_head_cache); - journal_head_cache = 0; + journal_head_cache = NULL; } /* diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c index 6bbd73644e8f..87cd0501dfb1 100644 --- a/fs/jbd/revoke.c +++ b/fs/jbd/revoke.c @@ -187,9 +187,9 @@ int __init journal_init_revoke_caches(void) void journal_destroy_revoke_caches(void) { kmem_cache_destroy(revoke_record_cache); - revoke_record_cache = 0; + revoke_record_cache = NULL; kmem_cache_destroy(revoke_table_cache); - revoke_table_cache = 0; + revoke_table_cache = NULL; } /* Initialise the revoke table for a given journal to a given size. */ diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 21ddf0b28b73..149fac70deec 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c @@ -1480,7 +1480,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh) if (*list == jh) { *list = jh->b_tnext; if (*list == jh) - *list = 0; + *list = NULL; } jh->b_tprev->b_tnext = jh->b_tnext; jh->b_tnext->b_tprev = jh->b_tprev; @@ -1499,7 +1499,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh) */ void __journal_unfile_buffer(struct journal_head *jh) { - struct journal_head **list = 0; + struct journal_head **list = NULL; transaction_t *transaction; struct buffer_head *bh = jh2bh(jh); @@ -1930,7 +1930,7 @@ int journal_invalidatepage(journal_t *journal, void __journal_file_buffer(struct journal_head *jh, transaction_t *transaction, int jlist) { - struct journal_head **list = 0; + struct journal_head **list = NULL; int was_dirty = 0; struct buffer_head *bh = jh2bh(jh); diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index 5d4b339df1e5..a76c496a5f0d 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c @@ -190,7 +190,7 @@ nlm_encode_testres(u32 *p, struct nlm_res *resp) s32 start, len; if (!(p = nlm_encode_cookie(p, &resp->cookie))) - return 0; + return NULL; *p++ = resp->status; if (resp->status == nlm_lck_denied) { @@ -201,7 +201,7 @@ nlm_encode_testres(u32 *p, struct nlm_res *resp) /* Encode owner handle. */ if (!(p = xdr_encode_netobj(p, &resp->lock.oh))) - return 0; + return NULL; start = loff_t_to_s32(fl->fl_start); if (fl->fl_end == OFFSET_MAX) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 2b30f49b6f8f..9c9399258afd 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -470,7 +470,7 @@ static int __init init_nfsd(void) #ifdef CONFIG_NFSD_V4 nfsd_idmap_init(); /* Name to ID mapping */ #endif /* CONFIG_NFSD_V4 */ - if (proc_mkdir("fs/nfs", 0)) { + if (proc_mkdir("fs/nfs", NULL)) { struct proc_dir_entry *entry; entry = create_proc_entry("fs/nfs/exports", 0, NULL); if (entry) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index 3b1f58300d36..f7c0cda58f82 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -82,7 +82,7 @@ kclist_del(void *addr) } } write_unlock(&kclist_lock); - return 0; + return NULL; } static size_t get_kcore_size(int *nphdr, size_t *elf_buflen) diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c index 211b1fe2a825..10d37bf25206 100644 --- a/fs/proc/kmsg.c +++ b/fs/proc/kmsg.c @@ -33,7 +33,7 @@ static int kmsg_release(struct inode * inode, struct file * file) static ssize_t kmsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - if ((file->f_flags & O_NONBLOCK) && !do_syslog(9, 0, 0)) + if ((file->f_flags & O_NONBLOCK) && !do_syslog(9, NULL, 0)) return -EAGAIN; return do_syslog(2, buf, count); } @@ -41,7 +41,7 @@ static ssize_t kmsg_read(struct file *file, char __user *buf, static unsigned int kmsg_poll(struct file *file, poll_table *wait) { poll_wait(file, &log_wait, wait); - if (do_syslog(9, 0, 0)) + if (do_syslog(9, NULL, 0)) return POLLIN | POLLRDNORM; return 0; } diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c index 401688e36559..a0d4404cc916 100644 --- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c @@ -217,7 +217,7 @@ void proc_tty_unregister_driver(struct tty_driver *driver) remove_proc_entry(driver->driver_name, proc_tty_driver); - driver->proc_entry = 0; + driver->proc_entry = NULL; } /* @@ -226,18 +226,18 @@ void proc_tty_unregister_driver(struct tty_driver *driver) void __init proc_tty_init(void) { struct proc_dir_entry *entry; - if (!proc_mkdir("tty", 0)) + if (!proc_mkdir("tty", NULL)) return; - proc_tty_ldisc = proc_mkdir("tty/ldisc", 0); + proc_tty_ldisc = proc_mkdir("tty/ldisc", NULL); /* * /proc/tty/driver/serial reveals the exact character counts for * serial links which is just too easy to abuse for inferring * password lengths and inter-keystroke timings during password * entry. */ - proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR | S_IXUSR, 0); + proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR | S_IXUSR, NULL); - create_proc_read_entry("tty/ldiscs", 0, 0, tty_ldiscs_read_proc,NULL); + create_proc_read_entry("tty/ldiscs", 0, NULL, tty_ldiscs_read_proc, NULL); entry = create_proc_entry("tty/drivers", 0, NULL); if (entry) entry->proc_fops = &proc_tty_drivers_operations; diff --git a/fs/proc/root.c b/fs/proc/root.c index bf4b5d299843..4ece27d02514 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -52,29 +52,29 @@ void __init proc_root_init(void) return; } proc_misc_init(); - proc_net = proc_mkdir("net", 0); + proc_net = proc_mkdir("net", NULL); #ifdef CONFIG_SYSVIPC - proc_mkdir("sysvipc", 0); + proc_mkdir("sysvipc", NULL); #endif #ifdef CONFIG_SYSCTL - proc_sys_root = proc_mkdir("sys", 0); + proc_sys_root = proc_mkdir("sys", NULL); #endif #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - proc_mkdir("sys/fs", 0); - proc_mkdir("sys/fs/binfmt_misc", 0); + proc_mkdir("sys/fs", NULL); + proc_mkdir("sys/fs/binfmt_misc", NULL); #endif - proc_root_fs = proc_mkdir("fs", 0); - proc_root_driver = proc_mkdir("driver", 0); - proc_mkdir("fs/nfsd", 0); /* somewhere for the nfsd filesystem to be mounted */ + proc_root_fs = proc_mkdir("fs", NULL); + proc_root_driver = proc_mkdir("driver", NULL); + proc_mkdir("fs/nfsd", NULL); /* somewhere for the nfsd filesystem to be mounted */ #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE) /* just give it a mountpoint */ - proc_mkdir("openprom", 0); + proc_mkdir("openprom", NULL); #endif proc_tty_init(); #ifdef CONFIG_PROC_DEVICETREE proc_device_tree_init(); #endif - proc_bus = proc_mkdir("bus", 0); + proc_bus = proc_mkdir("bus", NULL); } static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentry, struct nameidata *nd) diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index c05024715231..ed8abf22dac9 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c @@ -1614,6 +1614,7 @@ pagebuf_daemon( { struct list_head tmp; unsigned long age; + xfs_buftarg_t *target; xfs_buf_t *pb, *n; /* Set up the thread */ @@ -1656,9 +1657,12 @@ pagebuf_daemon( while (!list_empty(&tmp)) { pb = list_entry(tmp.next, xfs_buf_t, pb_list); + target = pb->pb_target; + list_del_init(&pb->pb_list); pagebuf_iostrategy(pb); - blk_run_address_space(pb->pb_target->pbr_mapping); + + blk_run_address_space(target->pbr_mapping); } if (as_list_len > 0) diff --git a/include/asm-arm/arch-omap/pm.h b/include/asm-arm/arch-omap/pm.h index 2976b46c3a3d..83911b919b2a 100644 --- a/include/asm-arm/arch-omap/pm.h +++ b/include/asm-arm/arch-omap/pm.h @@ -85,9 +85,6 @@ extern void omap_pm_idle(void); extern void omap_pm_suspend(void); extern int omap_cpu_suspend(unsigned short, unsigned short); extern int omap_idle_loop_suspend(void); -extern struct async_struct *omap_pm_sercons; -extern unsigned int serial_in(struct async_struct *, int); -extern unsigned int serial_out(struct async_struct *, int, int); #ifdef CONFIG_ARCH_OMAP1510 #define OMAP_SRAM_IDLE_SUSPEND 0xd002F000 diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h index b95fedb5b32d..a22128c2604e 100644 --- a/include/asm-i386/pgtable.h +++ b/include/asm-i386/pgtable.h @@ -285,7 +285,7 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) * Chop off the NX bit (if present), and add the NX portion of * the newprot (if present): */ - pte.pte_high &= -1 ^ (1 << (_PAGE_BIT_NX - 32)); + pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32)); pte.pte_high |= (pgprot_val(newprot) >> 32) & \ (__supported_pte_mask >> 32); #endif @@ -344,6 +344,26 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) #define pte_offset_kernel(dir, address) \ ((pte_t *) pmd_page_kernel(*(dir)) + pte_index(address)) +/* + * Helper function that returns the kernel pagetable entry controlling + * the virtual address 'address'. NULL means no pagetable entry present. + * NOTE: the return type is pte_t but if the pmd is PSE then we return it + * as a pte too. + */ +extern pte_t *lookup_address(unsigned long address); + +/* + * Make a given kernel text page executable/non-executable. + * Returns the previous executability setting of that page (which + * is used to restore the previous state). Used by the SMP bootup code. + * NOTE: this is an __init function for security reasons. + */ +#ifdef CONFIG_X86_PAE + extern int set_kernel_exec(unsigned long vaddr, int enable); +#else + static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;} +#endif + #if defined(CONFIG_HIGHPTE) #define pte_offset_map(dir, address) \ ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 29189706ea57..9937c8df8d7c 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h @@ -54,7 +54,7 @@ #define INIT_SIGHAND(sighand) { \ .count = ATOMIC_INIT(1), \ - .action = { {{0,}}, }, \ + .action = { {{NULL,}}, }, \ .siglock = SPIN_LOCK_UNLOCKED, \ } diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 2299b75b0518..0a73d0d2c271 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -1176,7 +1176,8 @@ #define PCI_DEVICE_ID_VIA_8763_0 0x0198 #define PCI_DEVICE_ID_VIA_8380_0 0x0204 #define PCI_DEVICE_ID_VIA_PX8X0_0 0x0259 -#define PCI_DEVICE_ID_VIA_8363_0 0x0305 +#define PCI_DEVICE_ID_VIA_K8T800PRO_0 0x0282 +#define PCI_DEVICE_ID_VIA_8363_0 0x0305 #define PCI_DEVICE_ID_VIA_8371_0 0x0391 #define PCI_DEVICE_ID_VIA_8501_0 0x0501 #define PCI_DEVICE_ID_VIA_82C505 0x0505 diff --git a/ipc/msg.c b/ipc/msg.c index 5f256af8bdf7..63777b6e9ea0 100644 --- a/ipc/msg.c +++ b/ipc/msg.c @@ -80,7 +80,7 @@ void __init msg_init (void) ipc_init_ids(&msg_ids,msg_ctlmni); #ifdef CONFIG_PROC_FS - create_proc_read_entry("sysvipc/msg", 0, 0, sysvipc_msg_read_proc, NULL); + create_proc_read_entry("sysvipc/msg", 0, NULL, sysvipc_msg_read_proc, NULL); #endif } diff --git a/ipc/sem.c b/ipc/sem.c index 6316aca9cc19..6ed70962c94f 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -116,7 +116,7 @@ void __init sem_init (void) ipc_init_ids(&sem_ids,sc_semmni); #ifdef CONFIG_PROC_FS - create_proc_read_entry("sysvipc/sem", 0, 0, sysvipc_sem_read_proc, NULL); + create_proc_read_entry("sysvipc/sem", 0, NULL, sysvipc_sem_read_proc, NULL); #endif } diff --git a/ipc/shm.c b/ipc/shm.c index 9761e3bcbe8e..d519c9bb2b25 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -60,7 +60,7 @@ void __init shm_init (void) { ipc_init_ids(&shm_ids, 1); #ifdef CONFIG_PROC_FS - create_proc_read_entry("sysvipc/shm", 0, 0, sysvipc_shm_read_proc, NULL); + create_proc_read_entry("sysvipc/shm", 0, NULL, sysvipc_shm_read_proc, NULL); #endif } diff --git a/kernel/exit.c b/kernel/exit.c index 9cb99b471d2e..cf71b30d8bd5 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -594,7 +594,8 @@ static inline void reparent_thread(task_t *p, task_t *father, int traced) * group, and if no such member exists, give it to * the global child reaper process (ie "init") */ -static inline void forget_original_parent(struct task_struct * father) +static inline void forget_original_parent(struct task_struct * father, + struct list_head *to_release) { struct task_struct *p, *reaper = father; struct list_head *_p, *_n; @@ -612,16 +613,34 @@ static inline void forget_original_parent(struct task_struct * father) * Search them and reparent children. */ list_for_each_safe(_p, _n, &father->children) { + int ptrace; p = list_entry(_p,struct task_struct,sibling); + + ptrace = p->ptrace; + + /* if father isn't the real parent, then ptrace must be enabled */ + BUG_ON(father != p->real_parent && !ptrace); + if (father == p->real_parent) { + /* reparent with a reaper, real father it's us */ choose_new_parent(p, reaper, child_reaper); reparent_thread(p, father, 0); } else { - ptrace_unlink (p); + /* reparent ptraced task to its real parent */ + __ptrace_unlink (p); if (p->state == TASK_ZOMBIE && p->exit_signal != -1 && thread_group_empty(p)) do_notify_parent(p, p->exit_signal); } + + /* + * if the ptraced child is a zombie with exit_signal == -1 + * we must collect it before we exit, or it will remain + * zombie forever since we prevented it from self-reap itself + * while it was being traced by us, to be able to see it in wait4. + */ + if (unlikely(ptrace && p->state == TASK_ZOMBIE && p->exit_signal == -1)) + list_add(&p->ptrace_list, to_release); } list_for_each_safe(_p, _n, &father->ptrace_children) { p = list_entry(_p,struct task_struct,ptrace_list); @@ -638,6 +657,7 @@ static void exit_notify(struct task_struct *tsk) { int state; struct task_struct *t; + struct list_head ptrace_dead, *_p, *_n; if (signal_pending(tsk) && !tsk->signal->group_exit && !thread_group_empty(tsk)) { @@ -673,8 +693,10 @@ static void exit_notify(struct task_struct *tsk) * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2) */ - forget_original_parent(tsk); + INIT_LIST_HEAD(&ptrace_dead); + forget_original_parent(tsk, &ptrace_dead); BUG_ON(!list_empty(&tsk->children)); + BUG_ON(!list_empty(&tsk->ptrace_children)); /* * Check to see if any process groups have become orphaned @@ -759,6 +781,12 @@ static void exit_notify(struct task_struct *tsk) _raw_write_unlock(&tasklist_lock); local_irq_enable(); + list_for_each_safe(_p, _n, &ptrace_dead) { + list_del_init(_p); + t = list_entry(_p,struct task_struct,ptrace_list); + release_task(t); + } + /* If the process is dead, release it - nobody will wait for it */ if (state == TASK_DEAD) release_task(tsk); diff --git a/kernel/futex.c b/kernel/futex.c index abae250cf73d..d9b9694fd2e8 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -276,7 +276,7 @@ static void wake_futex(struct futex_q *q) * The waiting task can free the futex_q as soon as this is written, * without taking any locks. This must come last. */ - q->lock_ptr = 0; + q->lock_ptr = NULL; } /* diff --git a/kernel/power/pm.c b/kernel/power/pm.c index 09d55363cefc..d1bc943072d4 100644 --- a/kernel/power/pm.c +++ b/kernel/power/pm.c @@ -282,7 +282,7 @@ struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from) return dev; entry = entry->next; } - return 0; + return NULL; } EXPORT_SYMBOL(pm_register); diff --git a/mm/filemap.c b/mm/filemap.c index 42a2f6024048..99a858500f12 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2021,7 +2021,7 @@ out_status: err = written ? written : status; out: pagevec_lru_add(&lru_pvec); - current->backing_dev_info = 0; + current->backing_dev_info = NULL; return err; } diff --git a/mm/rmap.c b/mm/rmap.c index e578fed907d3..4e954017e526 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -740,7 +740,7 @@ static inline int try_to_unmap_file(struct page *page) list_for_each_entry(vma, &mapping->i_mmap_nonlinear, shared.vm_set.list) { if (!(vma->vm_flags & VM_RESERVED)) - vma->vm_private_data = 0; + vma->vm_private_data = NULL; } relock: page_map_lock(page); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 20f1616508b8..46d26fc928f2 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -356,7 +356,7 @@ static int netdev_hotplug(struct class_device *cd, char **envp, if ((size <= 0) || (i >= num_envp)) return -ENOMEM; - envp[i] = 0; + envp[i] = NULL; return 0; } #endif diff --git a/net/core/sock.c b/net/core/sock.c index cd927e1fc2f1..64937e857ddc 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -667,7 +667,7 @@ void sk_free(struct sock *sk) void __init sk_init(void) { sk_cachep = kmem_cache_create("sock", sizeof(struct sock), 0, - SLAB_HWCACHE_ALIGN, 0, 0); + SLAB_HWCACHE_ALIGN, NULL, NULL); if (!sk_cachep) printk(KERN_CRIT "sk_init: Cannot create sock SLAB cache!"); diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1939a76e6308..aa46503d8629 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1018,13 +1018,13 @@ static int __init inet_init(void) tcp_sk_cachep = kmem_cache_create("tcp_sock", sizeof(struct tcp_sock), 0, - SLAB_HWCACHE_ALIGN, 0, 0); + SLAB_HWCACHE_ALIGN, NULL, NULL); udp_sk_cachep = kmem_cache_create("udp_sock", sizeof(struct udp_sock), 0, - SLAB_HWCACHE_ALIGN, 0, 0); + SLAB_HWCACHE_ALIGN, NULL, NULL); raw4_sk_cachep = kmem_cache_create("raw4_sock", sizeof(struct raw_sock), 0, - SLAB_HWCACHE_ALIGN, 0, 0); + SLAB_HWCACHE_ALIGN, NULL, NULL); if (!tcp_sk_cachep || !udp_sk_cachep || !raw4_sk_cachep) printk(KERN_CRIT "inet_init: Can't create protocol sock SLAB caches!\n"); diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 149dc862776c..d98038648150 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -279,7 +279,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) skb = alloc_skb(size + LL_RESERVED_SPACE(dev), GFP_ATOMIC); if (skb == NULL) - return 0; + return NULL; { struct flowi fl = { .oif = dev->ifindex, @@ -288,13 +288,13 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) .proto = IPPROTO_IGMP }; if (ip_route_output_key(&rt, &fl)) { kfree_skb(skb); - return 0; + return NULL; } } if (rt->rt_src == 0) { kfree_skb(skb); ip_rt_put(rt); - return 0; + return NULL; } skb->dst = &rt->u.dst; @@ -361,7 +361,7 @@ static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc, if (!skb) skb = igmpv3_newpack(dev, dev->mtu); if (!skb) - return 0; + return NULL; pgr = (struct igmpv3_grec *)skb_put(skb, sizeof(struct igmpv3_grec)); pgr->grec_type = type; pgr->grec_auxwords = 0; @@ -381,7 +381,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, { struct net_device *dev = pmc->interface->dev; struct igmpv3_report *pih; - struct igmpv3_grec *pgr = 0; + struct igmpv3_grec *pgr = NULL; struct ip_sf_list *psf, *psf_next, *psf_prev, **psf_list; int scount, first, isquery, truncate; @@ -406,13 +406,13 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, if (skb && AVAILABLE(skb) < sizeof(struct igmpv3_grec)+ sizeof(__u32)) { igmpv3_sendpack(skb); - skb = 0; /* add_grhead will get a new one */ + skb = NULL; /* add_grhead will get a new one */ } skb = add_grhead(skb, pmc, type, &pgr); } return skb; } - pih = skb ? (struct igmpv3_report *)skb->h.igmph : 0; + pih = skb ? (struct igmpv3_report *)skb->h.igmph : NULL; /* EX and TO_EX get a fresh packet, if needed */ if (truncate) { @@ -425,7 +425,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, } first = 1; scount = 0; - psf_prev = 0; + psf_prev = NULL; for (psf=*psf_list; psf; psf=psf_next) { u32 *psrc; @@ -483,7 +483,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc, static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc) { - struct sk_buff *skb = 0; + struct sk_buff *skb = NULL; int type; if (!pmc) { @@ -521,7 +521,7 @@ static void igmpv3_clear_zeros(struct ip_sf_list **ppsf) { struct ip_sf_list *psf_prev, *psf_next, *psf; - psf_prev = 0; + psf_prev = NULL; for (psf=*ppsf; psf; psf = psf_next) { psf_next = psf->sf_next; if (psf->sf_crcount == 0) { @@ -538,14 +538,14 @@ static void igmpv3_clear_zeros(struct ip_sf_list **ppsf) static void igmpv3_send_cr(struct in_device *in_dev) { struct ip_mc_list *pmc, *pmc_prev, *pmc_next; - struct sk_buff *skb = 0; + struct sk_buff *skb = NULL; int type, dtype; read_lock(&in_dev->lock); write_lock_bh(&in_dev->mc_lock); /* deleted MCA's */ - pmc_prev = 0; + pmc_prev = NULL; for (pmc=in_dev->mc_tomb; pmc; pmc=pmc_next) { pmc_next = pmc->next; if (pmc->sfmode == MCAST_INCLUDE) { @@ -681,7 +681,7 @@ static void igmp_gq_timer_expire(unsigned long data) struct in_device *in_dev = (struct in_device *)data; in_dev->mr_gq_running = 0; - igmpv3_send_report(in_dev, 0); + igmpv3_send_report(in_dev, NULL); __in_dev_put(in_dev); } @@ -976,7 +976,7 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im) pmc->tomb = im->tomb; pmc->sources = im->sources; - im->tomb = im->sources = 0; + im->tomb = im->sources = NULL; for (psf=pmc->sources; psf; psf=psf->sf_next) psf->sf_crcount = pmc->crcount; } @@ -994,7 +994,7 @@ static void igmpv3_del_delrec(struct in_device *in_dev, __u32 multiaddr) struct ip_sf_list *psf, *psf_next; write_lock_bh(&in_dev->mc_lock); - pmc_prev = 0; + pmc_prev = NULL; for (pmc=in_dev->mc_tomb; pmc; pmc=pmc->next) { if (pmc->multiaddr == multiaddr) break; @@ -1023,7 +1023,7 @@ static void igmpv3_clear_delrec(struct in_device *in_dev) write_lock_bh(&in_dev->mc_lock); pmc = in_dev->mc_tomb; - in_dev->mc_tomb = 0; + in_dev->mc_tomb = NULL; write_unlock_bh(&in_dev->mc_lock); for (; pmc; pmc = nextpmc) { @@ -1039,7 +1039,7 @@ static void igmpv3_clear_delrec(struct in_device *in_dev) spin_lock_bh(&pmc->lock); psf = pmc->tomb; - pmc->tomb = 0; + pmc->tomb = NULL; spin_unlock_bh(&pmc->lock); for (; psf; psf=psf_next) { psf_next = psf->sf_next; @@ -1135,7 +1135,7 @@ void ip_mc_inc_group(struct in_device *in_dev, u32 addr) for (im=in_dev->mc_list; im; im=im->next) { if (im->multiaddr == addr) { im->users++; - ip_mc_add_src(in_dev, &addr, MCAST_EXCLUDE, 0, 0, 0); + ip_mc_add_src(in_dev, &addr, MCAST_EXCLUDE, 0, NULL, 0); goto out; } } @@ -1152,8 +1152,8 @@ void ip_mc_inc_group(struct in_device *in_dev, u32 addr) im->sfmode = MCAST_EXCLUDE; im->sfcount[MCAST_INCLUDE] = 0; im->sfcount[MCAST_EXCLUDE] = 1; - im->sources = 0; - im->tomb = 0; + im->sources = NULL; + im->tomb = NULL; im->crcount = 0; atomic_set(&im->refcnt, 1); spin_lock_init(&im->lock); @@ -1238,7 +1238,7 @@ void ip_mc_init_dev(struct in_device *in_dev) { ASSERT_RTNL(); - in_dev->mc_tomb = 0; + in_dev->mc_tomb = NULL; #ifdef CONFIG_IP_MULTICAST in_dev->mr_gq_running = 0; init_timer(&in_dev->mr_gq_timer); @@ -1339,7 +1339,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode, struct ip_sf_list *psf, *psf_prev; int rv = 0; - psf_prev = 0; + psf_prev = NULL; for (psf=pmc->sources; psf; psf=psf->sf_next) { if (psf->sf_inaddr == *psfsrc) break; @@ -1453,7 +1453,7 @@ static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode, { struct ip_sf_list *psf, *psf_prev; - psf_prev = 0; + psf_prev = NULL; for (psf=pmc->sources; psf; psf=psf->sf_next) { if (psf->sf_inaddr == *psfsrc) break; @@ -1594,12 +1594,12 @@ static void ip_mc_clear_src(struct ip_mc_list *pmc) nextpsf = psf->sf_next; kfree(psf); } - pmc->tomb = 0; + pmc->tomb = NULL; for (psf=pmc->sources; psf; psf=nextpsf) { nextpsf = psf->sf_next; kfree(psf); } - pmc->sources = 0; + pmc->sources = NULL; pmc->sfmode = MCAST_EXCLUDE; pmc->sfcount[MCAST_EXCLUDE] = 0; pmc->sfcount[MCAST_EXCLUDE] = 1; @@ -1673,13 +1673,13 @@ int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml, if (iml->sflist == 0) { /* any-source empty exclude case */ return ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr, - iml->sfmode, 0, 0, 0); + iml->sfmode, 0, NULL, 0); } err = ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr, iml->sfmode, iml->sflist->sl_count, iml->sflist->sl_addr, 0); sock_kfree_s(sk, iml->sflist, IP_SFLSIZE(iml->sflist->sl_max)); - iml->sflist = 0; + iml->sflist = NULL; return err; } @@ -1731,7 +1731,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct struct ip_mreqn imr; u32 addr = mreqs->imr_multiaddr; struct ip_mc_socklist *pmc; - struct in_device *in_dev = 0; + struct in_device *in_dev = NULL; struct inet_opt *inet = inet_sk(sk); struct ip_sf_socklist *psl; int i, j, rv; @@ -1764,9 +1764,9 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct goto done; } else if (pmc->sfmode != omode) { /* allow mode switches for empty-set filters */ - ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 0, 0, 0); + ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 0, NULL, 0); ip_mc_del_src(in_dev, &mreqs->imr_multiaddr, pmc->sfmode, 0, - 0, 0); + NULL, 0); pmc->sfmode = omode; } @@ -1896,7 +1896,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) goto done; } } else - newpsl = 0; + newpsl = NULL; psl = pmc->sflist; if (psl) { (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, @@ -1904,7 +1904,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) sock_kfree_s(sk, psl, IP_SFLSIZE(psl->sl_max)); } else (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, - 0, 0, 0); + 0, NULL, 0); pmc->sflist = newpsl; pmc->sfmode = msf->imsf_fmode; done: diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 2e04043e0e2d..51b3b465a006 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -512,7 +512,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) err = 0; offset = 0; frag = skb_shinfo(skb)->frag_list; - skb_shinfo(skb)->frag_list = 0; + skb_shinfo(skb)->frag_list = NULL; skb->data_len = first_len - skb_headlen(skb); skb->len = first_len; iph->tot_len = htons(first_len); diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 58ff4c0303c2..8bb874be141a 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -775,8 +775,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, extern int sysctl_optmem_max; extern int sysctl_igmp_max_msf; struct sockaddr_in *psin; - struct ip_msfilter *msf = 0; - struct group_filter *gsf = 0; + struct ip_msfilter *msf = NULL; + struct group_filter *gsf = NULL; int msize, i, ifindex; if (optlen < GROUP_FILTER_SIZE(0)) @@ -829,7 +829,7 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, msf->imsf_slist[i] = psin->sin_addr.s_addr; } kfree(gsf); - gsf = 0; + gsf = NULL; err = ip_mc_msfilter(sk, msf, ifindex); mc_msf_out: diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c index 42c5ca84a998..61bdc9754a06 100644 --- a/net/sunrpc/pmap_clnt.c +++ b/net/sunrpc/pmap_clnt.c @@ -58,7 +58,7 @@ rpc_getport(struct rpc_task *task, struct rpc_clnt *clnt) spin_lock(&pmap_lock); if (map->pm_binding) { - rpc_sleep_on(&map->pm_bindwait, task, NULL, 0); + rpc_sleep_on(&map->pm_bindwait, task, NULL, NULL); spin_unlock(&pmap_lock); return; } diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 7f9e6ce36a74..ad353ae90634 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1016,7 +1016,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) rqstp->rq_arg.page_len = len - rqstp->rq_arg.head[0].iov_len; } - rqstp->rq_skbuff = 0; + rqstp->rq_skbuff = NULL; rqstp->rq_prot = IPPROTO_TCP; /* Reset TCP read info */ diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 3cf0917741d6..bc1e344e3bfc 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -807,7 +807,7 @@ static int snd_mem_proc_read(char *page, char **start, off_t off, static int __init snd_mem_init(void) { #ifdef CONFIG_PROC_FS - create_proc_read_entry("driver/snd-page-alloc", 0, 0, snd_mem_proc_read, NULL); + create_proc_read_entry("driver/snd-page-alloc", 0, NULL, snd_mem_proc_read, NULL); #endif preallocate_cards(); return 0; diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 65b5017e46e6..6130c578afac 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -192,7 +192,7 @@ static int snd_pcm_oss_period_size(snd_pcm_substream_t *substream, params_channels(oss_params) / 8; oss_buffer_size = snd_pcm_plug_client_size(substream, - snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0)) * oss_frame_size; + snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size; oss_buffer_size = 1 << ld2(oss_buffer_size); if (atomic_read(&runtime->mmap_count)) { if (oss_buffer_size > runtime->oss.mmap_bytes) @@ -228,14 +228,14 @@ static int snd_pcm_oss_period_size(snd_pcm_substream_t *substream, } min_period_size = snd_pcm_plug_client_size(substream, - snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 0)); + snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); min_period_size *= oss_frame_size; min_period_size = 1 << (ld2(min_period_size - 1) + 1); if (oss_period_size < min_period_size) oss_period_size = min_period_size; max_period_size = snd_pcm_plug_client_size(substream, - snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 0)); + snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL)); max_period_size *= oss_frame_size; max_period_size = 1 << ld2(max_period_size); if (oss_period_size > max_period_size) @@ -248,13 +248,13 @@ static int snd_pcm_oss_period_size(snd_pcm_substream_t *substream, oss_periods = substream->oss.setup->periods; } - s = snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, 0); + s = snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL); if (runtime->oss.maxfrags && s > runtime->oss.maxfrags) s = runtime->oss.maxfrags; if (oss_periods > s) oss_periods = s; - s = snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, 0); + s = snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL); if (s < 2) s = 2; if (oss_periods < s) @@ -307,7 +307,7 @@ static int choose_rate(snd_pcm_substream_t *substream, /* not found, use the nearest rate */ kfree(save); - return snd_pcm_hw_param_near(substream, params, SNDRV_PCM_HW_PARAM_RATE, best_rate, 0); + return snd_pcm_hw_param_near(substream, params, SNDRV_PCM_HW_PARAM_RATE, best_rate, NULL); } static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) @@ -357,7 +357,7 @@ static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) goto failure; } choose_rate(substream, sparams, runtime->oss.rate); - snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_CHANNELS, runtime->oss.channels, 0); + snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_CHANNELS, runtime->oss.channels, NULL); format = snd_pcm_oss_format_from(runtime->oss.format); @@ -440,14 +440,14 @@ static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) goto failure; n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); - err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, 0); + err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); snd_assert(err >= 0, goto failure); err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, - runtime->oss.periods, 0); + runtime->oss.periods, NULL); snd_assert(err >= 0, goto failure); - snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, 0); + snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); if ((err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_HW_PARAMS, sparams)) < 0) { snd_printd("HW_PARAMS failed: %i\n", err); @@ -564,7 +564,7 @@ static int snd_pcm_oss_prepare(snd_pcm_substream_t *substream) int err; snd_pcm_runtime_t *runtime = substream->runtime; - err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, 0); + err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL); if (err < 0) { snd_printd("snd_pcm_oss_prepare: SNDRV_PCM_IOCTL_PREPARE failed\n"); return err; @@ -932,12 +932,12 @@ static int snd_pcm_oss_reset(snd_pcm_oss_file_t *pcm_oss_file) substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; if (substream != NULL) { - snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DROP, 0); + snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); substream->runtime->oss.prepare = 1; } substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; if (substream != NULL) { - snd_pcm_kernel_capture_ioctl(substream, SNDRV_PCM_IOCTL_DROP, 0); + snd_pcm_kernel_capture_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); substream->runtime->oss.prepare = 1; } return 0; @@ -952,7 +952,7 @@ static int snd_pcm_oss_post(snd_pcm_oss_file_t *pcm_oss_file) if (substream != NULL) { if ((err = snd_pcm_oss_make_ready(substream)) < 0) return err; - snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_START, 0); + snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_START, NULL); } /* note: all errors from the start action are ignored */ /* OSS apps do not know, how to handle them */ @@ -1078,7 +1078,7 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file) __direct: saved_f_flags = substream->ffile->f_flags; substream->ffile->f_flags &= ~O_NONBLOCK; - err = snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, 0); + err = snd_pcm_kernel_playback_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL); substream->ffile->f_flags = saved_f_flags; if (err < 0) return err; @@ -1090,7 +1090,7 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file) if ((err = snd_pcm_oss_make_ready(substream)) < 0) return err; runtime = substream->runtime; - err = snd_pcm_kernel_capture_ioctl(substream, SNDRV_PCM_IOCTL_DROP, 0); + err = snd_pcm_kernel_capture_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); if (err < 0) return err; runtime->oss.buffer_used = 0; @@ -1402,7 +1402,7 @@ static int snd_pcm_oss_set_trigger(snd_pcm_oss_file_t *pcm_oss_file, int trigger cmd = SNDRV_PCM_IOCTL_DROP; runtime->oss.prepare = 1; } - err = snd_pcm_kernel_playback_ioctl(psubstream, cmd, 0); + err = snd_pcm_kernel_playback_ioctl(psubstream, cmd, NULL); if (err < 0) return err; } @@ -1423,7 +1423,7 @@ static int snd_pcm_oss_set_trigger(snd_pcm_oss_file_t *pcm_oss_file, int trigger cmd = SNDRV_PCM_IOCTL_DROP; runtime->oss.prepare = 1; } - err = snd_pcm_kernel_capture_ioctl(csubstream, cmd, 0); + err = snd_pcm_kernel_capture_ioctl(csubstream, cmd, NULL); if (err < 0) return err; } diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index 958cc3fd569d..6fd63ca66a6a 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -797,7 +797,7 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(snd_pcm_plug_t *plug, snd_pcm_plug frames = plugin->src_frames(plugin, frames1); } } else - dst_channels = 0; + dst_channels = NULL; pdprintf("write plugin: %s, %li\n", plugin->name, frames); if ((frames = plugin->transfer(plugin, src_channels, dst_channels, frames)) < 0) return frames; @@ -818,7 +818,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(snd_pcm_plug_t *plug, snd_pcm_plugi if (frames < 0) return frames; - src_channels = 0; + src_channels = NULL; plugin = snd_pcm_plug_first(plug); while (plugin && frames > 0) { if ((next = plugin->next) != NULL) { diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c index fadc265a0cc5..a33764fd6de9 100644 --- a/sound/core/oss/route.c +++ b/sound/core/oss/route.c @@ -95,7 +95,7 @@ static void route_to_channel_from_one(snd_pcm_plugin_t *plugin, #undef CONV_LABELS route_t *data = (route_t *)plugin->extra_data; void *conv; - const snd_pcm_plugin_channel_t *src_channel = 0; + const snd_pcm_plugin_channel_t *src_channel = NULL; unsigned int srcidx; char *src, *dst; int src_step, dst_step; @@ -149,11 +149,11 @@ static void route_to_channel(snd_pcm_plugin_t *plugin, #endif }; /* sum_type att shift */ - static void *norm_labels[3 * 2 * 4] = { 0, + static void *norm_labels[3 * 2 * 4] = { NULL, &&norm_int32_8_noatt, &&norm_int32_16_noatt, &&norm_int32_24_noatt, - 0, + NULL, &&norm_int32_8_att, &&norm_int32_16_att, &&norm_int32_24_att, @@ -462,7 +462,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin, for(srcidx = 0; srcidx < nsrcs; srcidx++) dptr->srcs[srcidx] = srcs[srcidx]; } else - dptr->srcs = 0; + dptr->srcs = NULL; dptr++; } return 0; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 61d1c38fba95..b104d3815d60 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1559,7 +1559,7 @@ int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, if (err < 0) return err; } - return snd_pcm_hw_param_value(params, var, 0); + return snd_pcm_hw_param_value(params, var, NULL); } int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, @@ -1735,28 +1735,28 @@ int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) { int err; - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_ACCESS, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_ACCESS, NULL); assert(err >= 0); - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_FORMAT, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_FORMAT, NULL); assert(err >= 0); - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_SUBFORMAT, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_SUBFORMAT, NULL); assert(err >= 0); - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_CHANNELS, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_CHANNELS, NULL); assert(err >= 0); - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_RATE, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_RATE, NULL); assert(err >= 0); - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_PERIOD_TIME, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_PERIOD_TIME, NULL); assert(err >= 0); - err = snd_pcm_hw_param_last(pcm, params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 0); + err = snd_pcm_hw_param_last(pcm, params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL); assert(err >= 0); - err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_TICK_TIME, 0); + err = snd_pcm_hw_param_first(pcm, params, SNDRV_PCM_HW_PARAM_TICK_TIME, NULL); assert(err >= 0); return 0; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 15ed2b9b3c11..6d5271f3f0a9 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1100,7 +1100,7 @@ static int snd_pcm_pre_reset(snd_pcm_substream_t * substream, int state) static int snd_pcm_do_reset(snd_pcm_substream_t * substream, int state) { snd_pcm_runtime_t *runtime = substream->runtime; - int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, 0); + int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); if (err < 0) return err; // snd_assert(runtime->status->hw_ptr < runtime->buffer_size, ); @@ -1475,18 +1475,18 @@ static struct file *snd_pcm_file_fd(int fd) unsigned short minor; file = fget(fd); if (!file) - return 0; + return NULL; inode = file->f_dentry->d_inode; if (!S_ISCHR(inode->i_mode) || imajor(inode) != snd_major) { fput(file); - return 0; + return NULL; } minor = iminor(inode); if (minor >= 256 || minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) { fput(file); - return 0; + return NULL; } return file; } @@ -1701,23 +1701,23 @@ int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream) snd_interval_setinteger(constrs_interval(constrs, SNDRV_PCM_HW_PARAM_FRAME_BITS)); err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, - snd_pcm_hw_rule_format, 0, + snd_pcm_hw_rule_format, NULL, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - snd_pcm_hw_rule_sample_bits, 0, + snd_pcm_hw_rule_sample_bits, NULL, SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - snd_pcm_hw_rule_div, 0, + snd_pcm_hw_rule_div, NULL, SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, - snd_pcm_hw_rule_mul, 0, + snd_pcm_hw_rule_mul, NULL, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1); if (err < 0) return err; @@ -1732,7 +1732,7 @@ int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream) if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, - snd_pcm_hw_rule_div, 0, + snd_pcm_hw_rule_div, NULL, SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); if (err < 0) return err; @@ -1747,12 +1747,12 @@ int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream) if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, - snd_pcm_hw_rule_div, 0, + snd_pcm_hw_rule_div, NULL, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1); if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - snd_pcm_hw_rule_div, 0, + snd_pcm_hw_rule_div, NULL, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_PERIODS, -1); if (err < 0) return err; @@ -1767,7 +1767,7 @@ int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream) if (err < 0) return err; err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - snd_pcm_hw_rule_mul, 0, + snd_pcm_hw_rule_mul, NULL, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIODS, -1); if (err < 0) return err; diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 74bdb4a228b2..b2c3544bf77b 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -84,9 +84,11 @@ MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC); module_param_array(enable, bool, boot_devs, 0444); MODULE_PARM_DESC(enable, "Enable InterWave soundcard."); MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC); +#ifdef CONFIG_PNP module_param_array(isapnp, bool, boot_devs, 0444); MODULE_PARM_DESC(isapnp, "ISA PnP detection for specified soundcard."); MODULE_PARM_SYNTAX(isapnp, SNDRV_ISAPNP_DESC); +#endif module_param_array(port, long, boot_devs, 0444); MODULE_PARM_DESC(port, "Port # for InterWave driver."); MODULE_PARM_SYNTAX(port, SNDRV_ENABLED ",allows:{{0x210,0x260,0x10}},dialog:list"); diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index e6b14ad77ab5..5493667dd0c9 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2617,7 +2617,7 @@ static struct shortname_table { { 0x746d, "AMD AMD8111" }, { 0x7445, "AMD AMD768" }, { 0x5455, "ALi M5455" }, - { 0, 0 }, + { 0, NULL }, }; static int __devinit snd_intel8x0_probe(struct pci_dev *pci, |
