--- a/arch/alpha/kernel/core_apecs.c +++ b/arch/alpha/kernel/core_apecs.c @@ -182,7 +182,7 @@ conf_read(unsigned long addr, unsigned c if (stat0 & 0xffe0U) { /* If not NDEV, print status. */ if (!(stat0 & 0x0800)) { - printk("apecs.c:conf_read: got stat0=%x\n", stat0); + printk(KERN_INFO "apecs.c:conf_read: got stat0=%x\n", stat0); } /* Reset error status. */ @@ -251,7 +251,7 @@ conf_write(unsigned long addr, unsigned if (stat0 & 0xffe0U) { /* If not NDEV, print status. */ if (!(stat0 & 0x0800)) { - printk("apecs.c:conf_write: got stat0=%x\n", stat0); + printk(KERN_INFO "apecs.c:conf_write: got stat0=%x\n", stat0); } /* Reset error status. */ --- a/arch/alpha/kernel/core_cia.c +++ b/arch/alpha/kernel/core_cia.c @@ -428,7 +428,7 @@ verify_tb_operation(void) mcheck_expected(0) = 0; mb(); if (mcheck_taken(0)) { - printk("pci: failed sg loopback i/o read test (mcheck)\n"); + printk(KERN_WARNING "pci: failed sg loopback i/o read test (mcheck)\n"); goto failed; } if (temp != data0) { @@ -445,9 +445,9 @@ verify_tb_operation(void) temp = *(vip)CIA_IOC_TB_TAGn(0); if (temp & 1) { use_tbia_try2 = 1; - printk("pci: failed tbia test; workaround available\n"); + printk(KERN_WARNING "pci: failed tbia test; workaround available\n"); } else { - printk("pci: passed tbia test\n"); + printk(KERN_INFO "pci: passed tbia test\n"); } } @@ -465,7 +465,7 @@ verify_tb_operation(void) mcheck_expected(0) = 0; mb(); if (mcheck_taken(0)) { - printk("pci: failed pte write cache snoop test (mcheck)\n"); + printk(KERN_WARNING "pci: failed pte write cache snoop test (mcheck)\n"); goto failed; } if (temp != data0) { @@ -512,7 +512,7 @@ verify_tb_operation(void) mb(); mcheck_expected(0) = 0; mb(); - printk("pci: %s pci machine check test\n", + printk(KERN_INFO "pci: %s pci machine check test\n", mcheck_taken(0) ? "passed" : "failed"); /* Clean up after the tests. */ @@ -529,7 +529,7 @@ verify_tb_operation(void) *(vip)CIA_IOC_TB_TAGn(2) = 2; *(vip)CIA_IOC_TB_TAGn(3) = 2; - printk("pci: tbia workaround enabled\n"); + printk(KERN_INFO "pci: tbia workaround enabled\n"); } alpha_mv.mv_pci_tbi(arena->hose, 0, -1); @@ -546,7 +546,7 @@ exit: return; failed: - printk("pci: disabling sg translation window\n"); + printk(KERN_INFO "pci: disabling sg translation window\n"); *(vip)CIA_IOC_PCI_W0_BASE = 0; *(vip)CIA_IOC_PCI_W1_BASE = 0; pci_isa_hose->sg_isa = NULL; @@ -632,7 +632,7 @@ do_init_arch(int is_pyxis) int temp, cia_rev, tbia_window; cia_rev = *(vip)CIA_IOC_CIA_REV & CIA_REV_MASK; - printk("pci: cia revision %d%s\n", + printk(KERN_INFO "pci: cia revision %d%s\n", cia_rev, is_pyxis ? " (pyxis)" : ""); if (alpha_using_srm) --- a/arch/alpha/kernel/core_irongate.c +++ b/arch/alpha/kernel/core_irongate.c @@ -169,13 +169,13 @@ irongate_pci_clr_err(void) again: IRONGATE_jd = IRONGATE0->stat_cmd; - printk("Iron stat_cmd %x\n", IRONGATE_jd); + printk(KERN_INFO "Iron stat_cmd %x\n", IRONGATE_jd); IRONGATE0->stat_cmd = IRONGATE_jd; /* write again clears error bits */ mb(); IRONGATE_jd = IRONGATE0->stat_cmd; /* re-read to force write */ IRONGATE_jd = *IronECC; - printk("Iron ECC %x\n", IRONGATE_jd); + printk(KERN_INFO "Iron ECC %x\n", IRONGATE_jd); *IronECC = IRONGATE_jd; /* write again clears error bits */ mb(); IRONGATE_jd = *IronECC; /* re-read to force write */ @@ -351,7 +351,7 @@ irongate_ioremap(unsigned long addr, uns * Adjust the limits (mappings must be page aligned) */ if (addr & ~PAGE_MASK) { - printk("AGP ioremap failed... addr not page aligned (0x%lx)\n", + printk(KERN_WARNING "AGP ioremap failed... addr not page aligned (0x%lx)\n", addr); return (void __iomem *)(addr + IRONGATE_MEM); } @@ -359,17 +359,17 @@ irongate_ioremap(unsigned long addr, uns size = PAGE_ALIGN(last) - addr; #if 0 - printk("irongate_ioremap(0x%lx, 0x%lx)\n", addr, size); - printk("irongate_ioremap: gart_bus_addr 0x%lx\n", gart_bus_addr); - printk("irongate_ioremap: gart_aper_size 0x%lx\n", gart_aper_size); - printk("irongate_ioremap: mmio_regs %p\n", mmio_regs); - printk("irongate_ioremap: gatt_pages %p\n", gatt_pages); + printk(KERN_DEBUG "irongate_ioremap(0x%lx, 0x%lx)\n", addr, size); + printk(KERN_DEBUG "irongate_ioremap: gart_bus_addr 0x%lx\n", gart_bus_addr); + printk(KERN_DEBUG "irongate_ioremap: gart_aper_size 0x%lx\n", gart_aper_size); + printk(KERN_DEBUG "irongate_ioremap: mmio_regs %p\n", mmio_regs); + printk(KERN_DEBUG "irongate_ioremap: gatt_pages %p\n", gatt_pages); for(baddr = addr; baddr <= last; baddr += PAGE_SIZE) { cur_gatt = phys_to_virt(GET_GATT(baddr) & ~1); pte = cur_gatt[GET_GATT_OFF(baddr)] & ~1; - printk("irongate_ioremap: cur_gatt %p pte 0x%x\n", + printk(KERN_DEBUG "irongate_ioremap: cur_gatt %p pte 0x%x\n", cur_gatt, pte); } #endif @@ -389,7 +389,7 @@ irongate_ioremap(unsigned long addr, uns if (__alpha_remap_area_pages(vaddr, pte, PAGE_SIZE, 0)) { - printk("AGP ioremap: FAILED to map...\n"); + printk(KERN_WARNING "AGP ioremap: FAILED to map...\n"); vfree(area->addr); return NULL; } @@ -399,7 +399,7 @@ irongate_ioremap(unsigned long addr, uns vaddr = (unsigned long)area->addr + (addr & ~PAGE_MASK); #if 0 - printk("irongate_ioremap(0x%lx, 0x%lx) returning 0x%lx\n", + printk(KERN_DEBUG "irongate_ioremap(0x%lx, 0x%lx) returning 0x%lx\n", addr, size, vaddr); #endif return (void __iomem *)vaddr; --- a/arch/alpha/kernel/core_lca.c +++ b/arch/alpha/kernel/core_lca.c @@ -334,23 +334,23 @@ lca_init_arch(void) static void mem_error(unsigned long esr, unsigned long ear) { - printk(" %s %s error to %s occurred at address %x\n", + printk(KERN_ERR " %s %s error to %s occurred at address %x\n", ((esr & ESR_CEE) ? "Correctable" : (esr & ESR_UEE) ? "Uncorrectable" : "A"), (esr & ESR_WRE) ? "write" : "read", (esr & ESR_SOR) ? "memory" : "b-cache", (unsigned) (ear & 0x1ffffff8)); if (esr & ESR_CTE) { - printk(" A b-cache tag parity error was detected.\n"); + printk(KERN_ERR " A b-cache tag parity error was detected.\n"); } if (esr & ESR_MSE) { - printk(" Several other correctable errors occurred.\n"); + printk(KERN_ERR " Several other correctable errors occurred.\n"); } if (esr & ESR_MHE) { - printk(" Several other uncorrectable errors occurred.\n"); + printk(KERN_ERR " Several other uncorrectable errors occurred.\n"); } if (esr & ESR_NXM) { - printk(" Attempted to access non-existent memory.\n"); + printk(KERN_ERR " Attempted to access non-existent memory.\n"); } } @@ -372,16 +372,16 @@ ioc_error(__u32 stat0, __u32 stat1) unsigned code = (stat0 & IOC_CODE) >> IOC_CODE_SHIFT; unsigned cmd = (stat0 & IOC_CMD) >> IOC_CMD_SHIFT; - printk(" %s initiated PCI %s cycle to address %x" + printk(KERN_ERR " %s initiated PCI %s cycle to address %x" " failed due to %s.\n", code > 3 ? "PCI" : "CPU", pci_cmd[cmd], stat1, err_name[code]); if (code == 5 || code == 6) { - printk(" (Error occurred at PCI memory address %x.)\n", + printk(KERN_ERR " (Error occurred at PCI memory address %x.)\n", (stat0 & ~IOC_P_NBR)); } if (stat0 & IOC_LOST) { - printk(" Other PCI errors occurred simultaneously.\n"); + printk(KERN_ERR " Other PCI errors occurred simultaneously.\n"); } } @@ -482,12 +482,12 @@ lca_clock_print(void) pmr_reg = LCA_READ_PMR; - printk("Status of clock control:\n"); - printk("\tPrimary clock divisor\t0x%lx\n", LCA_GET_PRIMARY(pmr_reg)); - printk("\tOverride clock divisor\t0x%lx\n", LCA_GET_OVERRIDE(pmr_reg)); - printk("\tInterrupt override is %s\n", + printk(KERN_INFO "Status of clock control:\n"); + printk(KERN_INFO "\tPrimary clock divisor\t0x%lx\n", LCA_GET_PRIMARY(pmr_reg)); + printk(KERN_INFO "\tOverride clock divisor\t0x%lx\n", LCA_GET_OVERRIDE(pmr_reg)); + printk(KERN_INFO "\tInterrupt override is %s\n", (pmr_reg & LCA_PMR_INTO) ? "on" : "off"); - printk("\tDMA override is %s\n", + printk(KERN_INFO "\tDMA override is %s\n", (pmr_reg & LCA_PMR_DMAO) ? "on" : "off"); } --- a/arch/alpha/kernel/core_marvel.c +++ b/arch/alpha/kernel/core_marvel.c @@ -332,7 +332,7 @@ marvel_init_io7(struct io7 *io7) { int i; - printk("Initializing IO7 at PID %d\n", io7->pe); + printk(KERN_INFO "Initializing IO7 at PID %d\n", io7->pe); /* * Get the Port 7 CSR pointer. @@ -361,7 +361,7 @@ marvel_io7_present(gct6_node *node) return; pe = (node->id >> 8) & 0xff; - printk("Found an IO7 at PID %d\n", pe); + printk(KERN_INFO "Found an IO7 at PID %d\n", pe); alloc_io7(pe); } @@ -383,7 +383,7 @@ marvel_init_vga_hose(void) * need to fix this decode when the console * changes its encoding */ - printk("console graphics is on hose %d (console)\n", h); + printk(KERN_INFO "console graphics is on hose %d (console)\n", h); /* * The console's hose numbering is: @@ -399,7 +399,7 @@ marvel_init_vga_hose(void) hose = io7->ports[port].hose; if (hose) { - printk("Console graphics on hose %d\n", hose->index); + printk(KERN_INFO "Console graphics on hose %d\n", hose->index); pci_vga_hose = hose; } } @@ -426,7 +426,7 @@ marvel_specify_io7(char *str) do { pid = simple_strtoul(str, &pchar, 0); if (pchar != str) { - printk("User-specified IO7 at PID %lu\n", pid); + printk(KERN_INFO "User-specified IO7 at PID %lu\n", pid); io7 = alloc_io7(pid); if (io7) marvel_init_io7(io7); } @@ -759,7 +759,7 @@ marvel_ioremap(unsigned long addr, unsig baddr += PAGE_SIZE, vaddr += PAGE_SIZE) { pfn = ptes[baddr >> PAGE_SHIFT]; if (!(pfn & 1)) { - printk("ioremap failed... pte not valid...\n"); + printk(KERN_ERR "ioremap failed... pte not valid...\n"); vfree(area->addr); return NULL; } @@ -768,7 +768,7 @@ marvel_ioremap(unsigned long addr, unsig if (__alpha_remap_area_pages(vaddr, pfn << PAGE_SHIFT, PAGE_SIZE, 0)) { - printk("FAILED to map...\n"); + printk(KERN_ERR "FAILED to map...\n"); vfree(area->addr); return NULL; } @@ -1002,7 +1002,7 @@ marvel_agp_configure(alpha_agp_info *agp * Don't know what this PLL setting is, take the requested * rate, but warn the user. */ - printk("%s: unknown PLL setting RNGB=%lx (PLL6_CTL=%016lx)\n", + printk(KERN_INFO "%s: unknown PLL setting RNGB=%lx (PLL6_CTL=%016lx)\n", __FUNCTION__, IO7_PLL_RNGB(agp_pll), agp_pll); break; } @@ -1011,7 +1011,7 @@ marvel_agp_configure(alpha_agp_info *agp * Set the new rate, if necessary. */ if (new_rate) { - printk("Requested AGP Rate %dX not compatible " + printk(KERN_INFO "Requested AGP Rate %dX not compatible " "with PLL setting - using %dX\n", agp->mode.bits.rate, new_rate); @@ -1019,7 +1019,7 @@ marvel_agp_configure(alpha_agp_info *agp agp->mode.bits.rate = new_rate; } - printk("Enabling AGP on hose %d: %dX%s RQ %d\n", + printk(KERN_INFO "Enabling AGP on hose %d: %dX%s RQ %d\n", agp->hose->index, agp->mode.bits.rate, agp->mode.bits.sba ? " - SBA" : "", agp->mode.bits.rq); @@ -1053,13 +1053,13 @@ marvel_agp_translate(alpha_agp_info *agp if (addr < agp->aperture.bus_base || addr >= agp->aperture.bus_base + agp->aperture.size) { - printk("%s: addr out of range\n", __FUNCTION__); + printk(KERN_ERR "%s: addr out of range\n", __FUNCTION__); return -EINVAL; } pte = aper->arena->ptes[baddr >> PAGE_SHIFT]; if (!(pte & 1)) { - printk("%s: pte not valid\n", __FUNCTION__); + printk(KERN_ERR "%s: pte not valid\n", __FUNCTION__); return -EINVAL; } return (pte >> 1) << PAGE_SHIFT; @@ -1109,7 +1109,7 @@ marvel_agp_info(void) if (!hose || !hose->sg_pci) return NULL; - printk("MARVEL - using hose %d as AGP\n", hose->index); + printk(KERN_INFO "MARVEL - using hose %d as AGP\n", hose->index); /* * Get the csrs from the hose. --- a/arch/alpha/kernel/core_mcpcia.c +++ b/arch/alpha/kernel/core_mcpcia.c @@ -433,7 +433,7 @@ mcpcia_init_hoses(void) } } - printk("mcpcia_init_hoses: found %d hoses\n", hose_count); + printk(KERN_INFO "mcpcia_init_hoses: found %d hoses\n", hose_count); /* Now do init for each hose. */ for (hose = hose_head; hose; hose = hose->next) @@ -450,65 +450,65 @@ mcpcia_print_uncorrectable(struct el_MCP /* Print PAL fields */ for (i = 0; i < 24; i += 2) { - printk(" paltmp[%d-%d] = %16lx %16lx\n", + printk(KERN_INFO " paltmp[%d-%d] = %16lx %16lx\n", i, i+1, frame->paltemp[i], frame->paltemp[i+1]); } for (i = 0; i < 8; i += 2) { - printk(" shadow[%d-%d] = %16lx %16lx\n", + printk(KERN_INFO " shadow[%d-%d] = %16lx %16lx\n", i, i+1, frame->shadow[i], frame->shadow[i+1]); } - printk(" Addr of excepting instruction = %16lx\n", + printk(KERN_INFO " Addr of excepting instruction = %16lx\n", frame->exc_addr); - printk(" Summary of arithmetic traps = %16lx\n", + printk(KERN_INFO " Summary of arithmetic traps = %16lx\n", frame->exc_sum); - printk(" Exception mask = %16lx\n", + printk(KERN_INFO " Exception mask = %16lx\n", frame->exc_mask); - printk(" Base address for PALcode = %16lx\n", + printk(KERN_INFO " Base address for PALcode = %16lx\n", frame->pal_base); - printk(" Interrupt Status Reg = %16lx\n", + printk(KERN_INFO " Interrupt Status Reg = %16lx\n", frame->isr); - printk(" CURRENT SETUP OF EV5 IBOX = %16lx\n", + printk(KERN_INFO " CURRENT SETUP OF EV5 IBOX = %16lx\n", frame->icsr); - printk(" I-CACHE Reg %s parity error = %16lx\n", + printk(KERN_INFO " I-CACHE Reg %s parity error = %16lx\n", (frame->ic_perr_stat & 0x800L) ? "Data" : "Tag", frame->ic_perr_stat); - printk(" D-CACHE error Reg = %16lx\n", + printk(KERN_INFO " D-CACHE error Reg = %16lx\n", frame->dc_perr_stat); if (frame->dc_perr_stat & 0x2) { switch (frame->dc_perr_stat & 0x03c) { case 8: - printk(" Data error in bank 1\n"); + printk(KERN_INFO " Data error in bank 1\n"); break; case 4: - printk(" Data error in bank 0\n"); + printk(KERN_INFO " Data error in bank 0\n"); break; case 20: - printk(" Tag error in bank 1\n"); + printk(KERN_INFO " Tag error in bank 1\n"); break; case 10: - printk(" Tag error in bank 0\n"); + printk(KERN_INFO " Tag error in bank 0\n"); break; } } - printk(" Effective VA = %16lx\n", + printk(KERN_INFO " Effective VA = %16lx\n", frame->va); - printk(" Reason for D-stream = %16lx\n", + printk(KERN_INFO " Reason for D-stream = %16lx\n", frame->mm_stat); - printk(" EV5 SCache address = %16lx\n", + printk(KERN_INFO " EV5 SCache address = %16lx\n", frame->sc_addr); - printk(" EV5 SCache TAG/Data parity = %16lx\n", + printk(KERN_INFO " EV5 SCache TAG/Data parity = %16lx\n", frame->sc_stat); - printk(" EV5 BC_TAG_ADDR = %16lx\n", + printk(KERN_INFO " EV5 BC_TAG_ADDR = %16lx\n", frame->bc_tag_addr); - printk(" EV5 EI_ADDR: Phys addr of Xfer = %16lx\n", + printk(KERN_INFO " EV5 EI_ADDR: Phys addr of Xfer = %16lx\n", frame->ei_addr); - printk(" Fill Syndrome = %16lx\n", + printk(KERN_INFO " Fill Syndrome = %16lx\n", frame->fill_syndrome); - printk(" EI_STAT reg = %16lx\n", + printk(KERN_INFO " EI_STAT reg = %16lx\n", frame->ei_stat); - printk(" LD_LOCK = %16lx\n", + printk(KERN_INFO " LD_LOCK = %16lx\n", frame->ld_lock); } @@ -549,25 +549,25 @@ mcpcia_print_system_area(unsigned long l for (hose = hose_head; hose; hose = hose->next, iodpp++) { - printk("IOD %d Register Subpacket - Bridge Base Address %16lx\n", + printk(KERN_INFO "IOD %d Register Subpacket - Bridge Base Address %16lx\n", hose->index, iodpp->base); - printk(" WHOAMI = %8x\n", iodpp->whoami); - printk(" PCI_REV = %8x\n", iodpp->pci_rev); - printk(" CAP_CTRL = %8x\n", iodpp->cap_ctrl); - printk(" HAE_MEM = %8x\n", iodpp->hae_mem); - printk(" HAE_IO = %8x\n", iodpp->hae_io); - printk(" INT_CTL = %8x\n", iodpp->int_ctl); - printk(" INT_REG = %8x\n", iodpp->int_reg); - printk(" INT_MASK0 = %8x\n", iodpp->int_mask0); - printk(" INT_MASK1 = %8x\n", iodpp->int_mask1); - printk(" MC_ERR0 = %8x\n", iodpp->mc_err0); - printk(" MC_ERR1 = %8x\n", iodpp->mc_err1); - printk(" CAP_ERR = %8x\n", iodpp->cap_err); - printk(" PCI_ERR1 = %8x\n", iodpp->pci_err1); - printk(" MDPA_STAT = %8x\n", iodpp->mdpa_stat); - printk(" MDPA_SYN = %8x\n", iodpp->mdpa_syn); - printk(" MDPB_STAT = %8x\n", iodpp->mdpb_stat); - printk(" MDPB_SYN = %8x\n", iodpp->mdpb_syn); + printk(KERN_INFO " WHOAMI = %8x\n", iodpp->whoami); + printk(KERN_INFO " PCI_REV = %8x\n", iodpp->pci_rev); + printk(KERN_INFO " CAP_CTRL = %8x\n", iodpp->cap_ctrl); + printk(KERN_INFO " HAE_MEM = %8x\n", iodpp->hae_mem); + printk(KERN_INFO " HAE_IO = %8x\n", iodpp->hae_io); + printk(KERN_INFO " INT_CTL = %8x\n", iodpp->int_ctl); + printk(KERN_INFO " INT_REG = %8x\n", iodpp->int_reg); + printk(KERN_INFO " INT_MASK0 = %8x\n", iodpp->int_mask0); + printk(KERN_INFO " INT_MASK1 = %8x\n", iodpp->int_mask1); + printk(KERN_INFO " MC_ERR0 = %8x\n", iodpp->mc_err0); + printk(KERN_INFO " MC_ERR1 = %8x\n", iodpp->mc_err1); + printk(KERN_INFO " CAP_ERR = %8x\n", iodpp->cap_err); + printk(KERN_INFO " PCI_ERR1 = %8x\n", iodpp->pci_err1); + printk(KERN_INFO " MDPA_STAT = %8x\n", iodpp->mdpa_stat); + printk(KERN_INFO " MDPA_SYN = %8x\n", iodpp->mdpa_syn); + printk(KERN_INFO " MDPB_STAT = %8x\n", iodpp->mdpb_stat); + printk(KERN_INFO " MDPB_SYN = %8x\n", iodpp->mdpb_syn); } } --- a/arch/alpha/kernel/core_polaris.c +++ b/arch/alpha/kernel/core_polaris.c @@ -152,7 +152,7 @@ polaris_init_arch(void) * already. */ #if 0 - printk("polaris_init_arch(): trusting firmware for setup\n"); + printk(KERN_INFO "polaris_init_arch(): trusting firmware for setup\n"); #endif /* --- a/arch/alpha/kernel/core_t2.c +++ b/arch/alpha/kernel/core_t2.c @@ -335,7 +335,7 @@ t2_direct_map_window1(unsigned long base *(vulp)T2_TBASE1 = 0; #if DEBUG_PRINT_FINAL_SETTINGS - printk("%s: setting WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n", + printk(KERN_DEBUG "%s: setting WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n", __FUNCTION__, *(vulp)T2_WBASE1, *(vulp)T2_WMASK1, @@ -365,7 +365,7 @@ t2_sg_map_window2(struct pci_controller t2_pci_tbi(hose, 0, -1); /* flush TLB all */ #if DEBUG_PRINT_FINAL_SETTINGS - printk("%s: setting WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n", + printk(KERN_DEBUG "%s: setting WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n", __FUNCTION__, *(vulp)T2_WBASE2, *(vulp)T2_WMASK2, @@ -377,15 +377,15 @@ static void __init t2_save_configuration(void) { #if DEBUG_PRINT_INITIAL_SETTINGS - printk("%s: HAE_1 was 0x%lx\n", __FUNCTION__, srm_hae); /* HW is 0 */ - printk("%s: HAE_2 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_2); - printk("%s: HAE_3 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_3); - printk("%s: HAE_4 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_4); - printk("%s: HBASE was 0x%lx\n", __FUNCTION__, *(vulp)T2_HBASE); + printk(KERN_DEBUG "%s: HAE_1 was 0x%lx\n", __FUNCTION__, srm_hae); /* HW is 0 */ + printk(KERN_DEBUG "%s: HAE_2 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_2); + printk(KERN_DEBUG "%s: HAE_3 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_3); + printk(KERN_DEBUG "%s: HAE_4 was 0x%lx\n", __FUNCTION__, *(vulp)T2_HAE_4); + printk(KERN_DEBUG "%s: HBASE was 0x%lx\n", __FUNCTION__, *(vulp)T2_HBASE); - printk("%s: WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n", __FUNCTION__, + printk(KERN_DEBUG "%s: WBASE1=0x%lx WMASK1=0x%lx TBASE1=0x%lx\n", __FUNCTION__, *(vulp)T2_WBASE1, *(vulp)T2_WMASK1, *(vulp)T2_TBASE1); - printk("%s: WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n", __FUNCTION__, + printk(KERN_DEBUG "%s: WBASE2=0x%lx WMASK2=0x%lx TBASE2=0x%lx\n", __FUNCTION__, *(vulp)T2_WBASE2, *(vulp)T2_WMASK2, *(vulp)T2_TBASE2); #endif @@ -423,7 +423,7 @@ t2_init_arch(void) /* Enable scatter/gather TLB use. */ temp = *(vulp)T2_IOCSR; if (!(temp & (0x1UL << 26))) { - printk("t2_init_arch: enabling SG TLB, IOCSR was 0x%lx\n", + printk(KERN_INFO "t2_init_arch: enabling SG TLB, IOCSR was 0x%lx\n", temp); *(vulp)T2_IOCSR = temp | (0x1UL << 26); mb(); @@ -580,7 +580,7 @@ t2_machine_check(unsigned long vector, u */ #ifdef CONFIG_VERBOSE_MCHECK if (alpha_verbose_mcheck > 1) { - printk("t2_machine_check(cpu%d): any_expected 0x%x -" + printk(KERN_INFO "t2_machine_check(cpu%d): any_expected 0x%x -" " (assumed) spurious -" " code 0x%x\n", cpu, t2_mcheck_any_expected, (unsigned int)mchk_header->code); @@ -593,7 +593,7 @@ t2_machine_check(unsigned long vector, u if (t2_mcheck_last_taken & (1 << cpu)) { #ifdef CONFIG_VERBOSE_MCHECK if (alpha_verbose_mcheck > 1) { - printk("t2_machine_check(cpu%d): last_taken 0x%x - " + printk(KERN_INFO "t2_machine_check(cpu%d): last_taken 0x%x - " "unexpected mcheck - code 0x%x\n", cpu, t2_mcheck_last_taken, (unsigned int)mchk_header->code); @@ -610,7 +610,7 @@ t2_machine_check(unsigned long vector, u #ifdef CONFIG_VERBOSE_MCHECK if (alpha_verbose_mcheck > 1) { - printk("%s t2_mcheck(cpu%d): last_taken 0x%x - " + printk(KERN_INFO "%s t2_mcheck(cpu%d): last_taken 0x%x - " "any_expected 0x%x - code 0x%x\n", (mcheck_expected(cpu) ? "EX" : "UN"), cpu, t2_mcheck_last_taken, t2_mcheck_any_expected, --- a/arch/alpha/kernel/core_titan.c +++ b/arch/alpha/kernel/core_titan.c @@ -374,7 +374,7 @@ titan_init_vga_hose(void) } if (hose) { - printk("Console graphics on hose %d\n", hose->index); + printk(KERN_INFO "Console graphics on hose %d\n", hose->index); pci_vga_hose = hose; } } @@ -385,21 +385,21 @@ void __init titan_init_arch(void) { #if 0 - printk("%s: titan_init_arch()\n", __FUNCTION__); - printk("%s: CChip registers:\n", __FUNCTION__); - printk("%s: CSR_CSC 0x%lx\n", __FUNCTION__, TITAN_cchip->csc.csr); - printk("%s: CSR_MTR 0x%lx\n", __FUNCTION__, TITAN_cchip->mtr.csr); - printk("%s: CSR_MISC 0x%lx\n", __FUNCTION__, TITAN_cchip->misc.csr); - printk("%s: CSR_DIM0 0x%lx\n", __FUNCTION__, TITAN_cchip->dim0.csr); - printk("%s: CSR_DIM1 0x%lx\n", __FUNCTION__, TITAN_cchip->dim1.csr); - printk("%s: CSR_DIR0 0x%lx\n", __FUNCTION__, TITAN_cchip->dir0.csr); - printk("%s: CSR_DIR1 0x%lx\n", __FUNCTION__, TITAN_cchip->dir1.csr); - printk("%s: CSR_DRIR 0x%lx\n", __FUNCTION__, TITAN_cchip->drir.csr); - - printk("%s: DChip registers:\n", __FUNCTION__); - printk("%s: CSR_DSC 0x%lx\n", __FUNCTION__, TITAN_dchip->dsc.csr); - printk("%s: CSR_STR 0x%lx\n", __FUNCTION__, TITAN_dchip->str.csr); - printk("%s: CSR_DREV 0x%lx\n", __FUNCTION__, TITAN_dchip->drev.csr); + printk(KERN_DEBUG "%s: titan_init_arch()\n", __FUNCTION__); + printk(KERN_DEBUG "%s: CChip registers:\n", __FUNCTION__); + printk(KERN_DEBUG "%s: CSR_CSC 0x%lx\n", __FUNCTION__, TITAN_cchip->csc.csr); + printk(KERN_DEBUG "%s: CSR_MTR 0x%lx\n", __FUNCTION__, TITAN_cchip->mtr.csr); + printk(KERN_DEBUG "%s: CSR_MISC 0x%lx\n", __FUNCTION__, TITAN_cchip->misc.csr); + printk(KERN_DEBUG "%s: CSR_DIM0 0x%lx\n", __FUNCTION__, TITAN_cchip->dim0.csr); + printk(KERN_DEBUG "%s: CSR_DIM1 0x%lx\n", __FUNCTION__, TITAN_cchip->dim1.csr); + printk(KERN_DEBUG "%s: CSR_DIR0 0x%lx\n", __FUNCTION__, TITAN_cchip->dir0.csr); + printk(KERN_DEBUG "%s: CSR_DIR1 0x%lx\n", __FUNCTION__, TITAN_cchip->dir1.csr); + printk(KERN_DEBUG "%s: CSR_DRIR 0x%lx\n", __FUNCTION__, TITAN_cchip->drir.csr); + + printk(KERN_DEBUG "%s: DChip registers:\n", __FUNCTION__); + printk(KERN_DEBUG "%s: CSR_DSC 0x%lx\n", __FUNCTION__, TITAN_dchip->dsc.csr); + printk(KERN_DEBUG "%s: CSR_STR 0x%lx\n", __FUNCTION__, TITAN_dchip->str.csr); + printk(KERN_DEBUG "%s: CSR_DREV 0x%lx\n", __FUNCTION__, TITAN_dchip->drev.csr); #endif boot_cpuid = __hard_smp_processor_id(); @@ -530,7 +530,7 @@ titan_ioremap(unsigned long addr, unsign baddr += PAGE_SIZE, vaddr += PAGE_SIZE) { pfn = ptes[baddr >> PAGE_SHIFT]; if (!(pfn & 1)) { - printk("ioremap failed... pte not valid...\n"); + printk(KERN_ERR "ioremap failed... pte not valid...\n"); vfree(area->addr); return NULL; } @@ -539,7 +539,7 @@ titan_ioremap(unsigned long addr, unsign if (__alpha_remap_area_pages(vaddr, pfn << PAGE_SHIFT, PAGE_SIZE, 0)) { - printk("FAILED to map...\n"); + printk(KERN_ERR "FAILED to map...\n"); vfree(area->addr); return NULL; } @@ -711,13 +711,13 @@ titan_agp_translate(alpha_agp_info *agp, if (addr < agp->aperture.bus_base || addr >= agp->aperture.bus_base + agp->aperture.size) { - printk("%s: addr out of range\n", __FUNCTION__); + printk(KERN_ERR "%s: addr out of range\n", __FUNCTION__); return -EINVAL; } pte = aper->arena->ptes[baddr >> PAGE_SHIFT]; if (!(pte & 1)) { - printk("%s: pte not valid\n", __FUNCTION__); + printk(KERN_ERR "%s: pte not valid\n", __FUNCTION__); return -EINVAL; } --- a/arch/alpha/kernel/core_tsunami.c +++ b/arch/alpha/kernel/core_tsunami.c @@ -211,7 +211,7 @@ tsunami_probe_read(volatile unsigned lon mcheck_taken(cpu) = 0; setipl(s); - printk("dont_care == 0x%lx\n", dont_care); + printk(KERN_INFO "dont_care == 0x%lx\n", dont_care); return probe_result; } @@ -229,7 +229,7 @@ tsunami_probe_write(volatile unsigned lo int source = (TSUNAMI_cchip->misc.csr >> 29) & 7; TSUNAMI_cchip->misc.csr |= (1L << 28); /* ...and unlock NXS. */ probe_result = 0; - printk("tsunami_probe_write: unit %d at 0x%016lx\n", source, + printk(KERN_INFO "tsunami_probe_write: unit %d at 0x%016lx\n", source, (unsigned long)vaddr); } if (probe_result) @@ -362,27 +362,27 @@ tsunami_init_arch(void) /* NXMs just don't matter to Tsunami--unless they make it choke completely. */ tmp = (unsigned long)(TSUNAMI_cchip - 1); - printk("%s: probing bogus address: 0x%016lx\n", FN, bogus_addr); - printk("\tprobe %s\n", + printk(KERN_INFO "%s: probing bogus address: 0x%016lx\n", FN, bogus_addr); + printk(KERN_INFO "\tprobe %s\n", tsunami_probe_write((unsigned long *)bogus_addr) ? "succeeded" : "failed"); #endif /* NXM_MACHINE_CHECKS_ON_TSUNAMI */ #if 0 - printk("%s: CChip registers:\n", FN); - printk("%s: CSR_CSC 0x%lx\n", FN, TSUNAMI_cchip->csc.csr); - printk("%s: CSR_MTR 0x%lx\n", FN, TSUNAMI_cchip.mtr.csr); - printk("%s: CSR_MISC 0x%lx\n", FN, TSUNAMI_cchip->misc.csr); - printk("%s: CSR_DIM0 0x%lx\n", FN, TSUNAMI_cchip->dim0.csr); - printk("%s: CSR_DIM1 0x%lx\n", FN, TSUNAMI_cchip->dim1.csr); - printk("%s: CSR_DIR0 0x%lx\n", FN, TSUNAMI_cchip->dir0.csr); - printk("%s: CSR_DIR1 0x%lx\n", FN, TSUNAMI_cchip->dir1.csr); - printk("%s: CSR_DRIR 0x%lx\n", FN, TSUNAMI_cchip->drir.csr); - - printk("%s: DChip registers:\n"); - printk("%s: CSR_DSC 0x%lx\n", FN, TSUNAMI_dchip->dsc.csr); - printk("%s: CSR_STR 0x%lx\n", FN, TSUNAMI_dchip->str.csr); - printk("%s: CSR_DREV 0x%lx\n", FN, TSUNAMI_dchip->drev.csr); + printk(KERN_DEBUG "%s: CChip registers:\n", FN); + printk(KERN_DEBUG "%s: CSR_CSC 0x%lx\n", FN, TSUNAMI_cchip->csc.csr); + printk(KERN_DEBUG "%s: CSR_MTR 0x%lx\n", FN, TSUNAMI_cchip.mtr.csr); + printk(KERN_DEBUG "%s: CSR_MISC 0x%lx\n", FN, TSUNAMI_cchip->misc.csr); + printk(KERN_DEBUG "%s: CSR_DIM0 0x%lx\n", FN, TSUNAMI_cchip->dim0.csr); + printk(KERN_DEBUG "%s: CSR_DIM1 0x%lx\n", FN, TSUNAMI_cchip->dim1.csr); + printk(KERN_DEBUG "%s: CSR_DIR0 0x%lx\n", FN, TSUNAMI_cchip->dir0.csr); + printk(KERN_DEBUG "%s: CSR_DIR1 0x%lx\n", FN, TSUNAMI_cchip->dir1.csr); + printk(KERN_DEBUG "%s: CSR_DRIR 0x%lx\n", FN, TSUNAMI_cchip->drir.csr); + + printk(KERN_DEBUG "%s: DChip registers:\n"); + printk(KERN_DEBUG "%s: CSR_DSC 0x%lx\n", FN, TSUNAMI_dchip->dsc.csr); + printk(KERN_DEBUG "%s: CSR_STR 0x%lx\n", FN, TSUNAMI_dchip->str.csr); + printk(KERN_DEBUG "%s: CSR_DREV 0x%lx\n", FN, TSUNAMI_dchip->drev.csr); #endif /* With multiple PCI busses, we play with I/O as physical addrs. */ ioport_resource.end = ~0UL; --- a/arch/alpha/kernel/module.c +++ b/arch/alpha/kernel/module.c @@ -119,8 +119,7 @@ module_frob_arch_sections(Elf64_Ehdr *hd } nsyms = symtab->sh_size / sizeof(Elf64_Sym); - chains = kmalloc(nsyms * sizeof(struct got_entry), GFP_KERNEL); - memset(chains, 0, nsyms * sizeof(struct got_entry)); + chains = kcalloc(nsyms, sizeof(struct got_entry), GFP_KERNEL); got->sh_size = 0; got->sh_addralign = 8; --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c @@ -408,7 +408,7 @@ pcibios_set_master(struct pci_dev *dev) u8 lat; pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); if (lat >= 16) return; - printk("PCI: Setting latency timer of device %s to 64\n", + printk(KERN_INFO "PCI: Setting latency timer of device %s to 64\n", pci_name(dev)); pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); } --- a/arch/alpha/kernel/pci_iommu.c +++ b/arch/alpha/kernel/pci_iommu.c @@ -79,7 +79,7 @@ iommu_arena_new_node(int nid, struct pci if (!NODE_DATA(nid) || (NULL == (arena = alloc_bootmem_node(NODE_DATA(nid), sizeof(*arena))))) { - printk("%s: couldn't allocate arena from node %d\n" + printk(KERN_WARNING "%s: couldn't allocate arena from node %d\n" " falling back to system-wide allocation\n", __FUNCTION__, nid); arena = alloc_bootmem(sizeof(*arena)); @@ -90,7 +90,7 @@ iommu_arena_new_node(int nid, struct pci mem_size, align, 0)))) { - printk("%s: couldn't allocate arena ptes from node %d\n" + printk(KERN_WARNING "%s: couldn't allocate arena ptes from node %d\n" " falling back to system-wide allocation\n", __FUNCTION__, nid); arena->ptes = __alloc_bootmem(mem_size, align, 0); --- a/arch/alpha/kernel/ptrace.c +++ b/arch/alpha/kernel/ptrace.c @@ -239,7 +239,7 @@ ptrace_cancel_bpt(struct task_struct * c task_thread_info(child)->bpt_nsaved = 0; if (nsaved > 2) { - printk("ptrace_cancel_bpt: bogus nsaved: %d!\n", nsaved); + printk(KERN_ERR "ptrace_cancel_bpt: bogus nsaved: %d!\n", nsaved); nsaved = 2; } --- a/arch/alpha/kernel/semaphore.c +++ b/arch/alpha/kernel/semaphore.c @@ -68,7 +68,7 @@ __down_failed(struct semaphore *sem) DECLARE_WAITQUEUE(wait, tsk); #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down failed(%p)\n", + printk(KERN_DEBUG "%s(%d): down failed(%p)\n", tsk->comm, tsk->pid, sem); #endif @@ -97,7 +97,7 @@ __down_failed(struct semaphore *sem) wake_up(&sem->wait); #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down acquired(%p)\n", + printk(KERN_DEBUG "%s(%d): down acquired(%p)\n", tsk->comm, tsk->pid, sem); #endif } @@ -110,7 +110,7 @@ __down_failed_interruptible(struct semap long ret = 0; #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down failed(%p)\n", + printk(KERN_DEBUG "%s(%d): down failed(%p)\n", tsk->comm, tsk->pid, sem); #endif @@ -138,7 +138,7 @@ __down_failed_interruptible(struct semap wake_up(&sem->wait); #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down %s(%p)\n", + printk(KERN_DEBUG "%s(%d): down %s(%p)\n", current->comm, current->pid, (ret < 0 ? "interrupted" : "acquired"), sem); #endif @@ -167,7 +167,7 @@ down(struct semaphore *sem) CHECK_MAGIC(sem->__magic); #endif #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down(%p) from %p\n", + printk(KERN_DEBUG "%s(%d): down(%p) from %p\n", current->comm, current->pid, sem, atomic_read(&sem->count), __builtin_return_address(0)); #endif @@ -181,7 +181,7 @@ down_interruptible(struct semaphore *sem CHECK_MAGIC(sem->__magic); #endif #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down(%p) from %p\n", + printk(KERN_DEBUG "%s(%d): down(%p) from %p\n", current->comm, current->pid, sem, atomic_read(&sem->count), __builtin_return_address(0)); #endif @@ -200,7 +200,7 @@ down_trylock(struct semaphore *sem) ret = __down_trylock(sem); #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): down_trylock %s from %p\n", + printk(KERN_DEBUG "%s(%d): down_trylock %s from %p\n", current->comm, current->pid, ret ? "failed" : "acquired", __builtin_return_address(0)); @@ -216,7 +216,7 @@ up(struct semaphore *sem) CHECK_MAGIC(sem->__magic); #endif #ifdef CONFIG_DEBUG_SEMAPHORE - printk("%s(%d): up(%p) from %p\n", + printk(KERN_DEBUG "%s(%d): up(%p) from %p\n", current->comm, current->pid, sem, atomic_read(&sem->count), __builtin_return_address(0)); #endif --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -284,7 +284,7 @@ move_initrd(unsigned long mem_limit) memmove(start, (void *)initrd_start, size); initrd_start = (unsigned long)start; initrd_end = initrd_start + size; - printk("initrd moved to %p\n", start); + printk(KERN_INFO "initrd moved to %p\n", start); return start; } #endif @@ -305,7 +305,7 @@ setup_memory(void *kernel_end) (hwrpb->mddt_offset + (unsigned long) hwrpb); for_each_mem_cluster(memdesc, cluster, i) { - printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n", + printk(KERN_INFO "memcluster %lu, usage %01lx, start %8lu, end %8lu\n", i, cluster->usage, cluster->start_pfn, cluster->start_pfn + cluster->numpages); @@ -340,7 +340,7 @@ setup_memory(void *kernel_end) if (mem_size_limit && max_low_pfn >= mem_size_limit) { - printk("setup: forcing memory size to %ldK (from %ldK).\n", + printk(KERN_INFO "setup: forcing memory size to %ldK (from %ldK).\n", mem_size_limit << (PAGE_SHIFT - 10), max_low_pfn << (PAGE_SHIFT - 10)); max_low_pfn = mem_size_limit; @@ -409,7 +409,7 @@ setup_memory(void *kernel_end) free_bootmem(PFN_PHYS(start), (PFN_PHYS(start_kernel_pfn) - PFN_PHYS(start))); - printk("freeing pages %ld:%ld\n", + printk(KERN_INFO "freeing pages %ld:%ld\n", start, start_kernel_pfn); start = end_kernel_pfn; } else if (end > start_kernel_pfn) @@ -420,23 +420,23 @@ setup_memory(void *kernel_end) continue; free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start)); - printk("freeing pages %ld:%ld\n", start, end); + printk(KERN_INFO "freeing pages %ld:%ld\n", start, end); } /* Reserve the bootmap memory. */ reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size); - printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size)); + printk(KERN_INFO "reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size)); #ifdef CONFIG_BLK_DEV_INITRD initrd_start = INITRD_START; if (initrd_start) { initrd_end = initrd_start+INITRD_SIZE; - printk("Initial ramdisk at: 0x%p (%lu bytes)\n", + printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n", (void *) initrd_start, INITRD_SIZE); if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) { if (!move_initrd(PFN_PHYS(max_low_pfn))) - printk("initrd extends beyond end of memory " + printk(KERN_INFO "initrd extends beyond end of memory " "(0x%08lx > 0x%p)\ndisabling initrd\n", initrd_end, phys_to_virt(PFN_PHYS(max_low_pfn))); @@ -657,7 +657,7 @@ setup_arch(char **cmdline_p) #endif "\n"); - printk("Command line: %s\n", command_line); + printk(KERN_INFO "Command line: %s\n", command_line); /* * Sync up the HAE. @@ -711,7 +711,7 @@ setup_arch(char **cmdline_p) */ if (hwrpb->max_asn != MAX_ASN) { - printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn); + printk(KERN_INFO "Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn); } /* @@ -1302,7 +1302,7 @@ external_cache_probe(int minsize, int wi cycles = read_mem_block(__va(0), stride, size); if (cycles > prev_cycles * 2) { /* Fine, we exceed the cache. */ - printk("%ldK Bcache detected; load hit latency %d " + printk(KERN_INFO "%ldK Bcache detected; load hit latency %d " "cycles, load miss latency %d cycles\n", size >> 11, prev_cycles, cycles); return CSHAPE(size >> 1, width, 1); --- a/arch/alpha/kernel/signal.c +++ b/arch/alpha/kernel/signal.c @@ -478,7 +478,7 @@ setup_frame(int sig, struct k_sigaction wrusp((unsigned long) frame); #if DEBUG_SIG - printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", + printk(KERN_DEBUG "SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", current->comm, current->pid, frame, regs->pc, regs->r26); #endif @@ -540,7 +540,7 @@ setup_rt_frame(int sig, struct k_sigacti wrusp((unsigned long) frame); #if DEBUG_SIG - printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", + printk(KERN_DEBUG "SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", current->comm, current->pid, frame, regs->pc, regs->r26); #endif --- a/arch/alpha/kernel/smc37c669.c +++ b/arch/alpha/kernel/smc37c669.c @@ -1898,45 +1898,45 @@ static unsigned int __init SMC37c669_get void __init SMC37c669_display_device_info ( void ) { if ( SMC37c669_is_device_enabled( SERIAL_0 ) ) { - printk( " Serial 0: Enabled [ Port 0x%x, IRQ %d ]\n", + printk(KERN_INFO " Serial 0: Enabled [ Port 0x%x, IRQ %d ]\n", local_config[ SERIAL_0 ].port1, local_config[ SERIAL_0 ].irq ); } else { - printk( " Serial 0: Disabled\n" ); + printk(KERN_INFO " Serial 0: Disabled\n" ); } if ( SMC37c669_is_device_enabled( SERIAL_1 ) ) { - printk( " Serial 1: Enabled [ Port 0x%x, IRQ %d ]\n", + printk(KERN_INFO " Serial 1: Enabled [ Port 0x%x, IRQ %d ]\n", local_config[ SERIAL_1 ].port1, local_config[ SERIAL_1 ].irq ); } else { - printk( " Serial 1: Disabled\n" ); + printk(KERN_INFO " Serial 1: Disabled\n" ); } if ( SMC37c669_is_device_enabled( PARALLEL_0 ) ) { - printk( " Parallel: Enabled [ Port 0x%x, IRQ %d/%d ]\n", + printk(KERN_INFO " Parallel: Enabled [ Port 0x%x, IRQ %d/%d ]\n", local_config[ PARALLEL_0 ].port1, local_config[ PARALLEL_0 ].irq, local_config[ PARALLEL_0 ].drq ); } else { - printk( " Parallel: Disabled\n" ); + printk(KERN_INFO " Parallel: Disabled\n" ); } if ( SMC37c669_is_device_enabled( FLOPPY_0 ) ) { - printk( " Floppy Ctrl: Enabled [ Port 0x%x, IRQ %d/%d ]\n", + printk(KERN_INFO " Floppy Ctrl: Enabled [ Port 0x%x, IRQ %d/%d ]\n", local_config[ FLOPPY_0 ].port1, local_config[ FLOPPY_0 ].irq, local_config[ FLOPPY_0 ].drq ); } else { - printk( " Floppy Ctrl: Disabled\n" ); + printk(KERN_INFO " Floppy Ctrl: Disabled\n" ); } if ( SMC37c669_is_device_enabled( IDE_0 ) ) { @@ -1946,7 +1946,7 @@ void __init SMC37c669_display_device_inf ); } else { - printk( " IDE 0: Disabled\n" ); + printk(KERN_INFO " IDE 0: Disabled\n" ); } } @@ -2452,7 +2452,7 @@ SMC37c669_dump_registers(void) { int i; for (i = 0; i <= 0x29; i++) - printk("-- CR%02x : %02x\n", i, SMC37c669_read_config(i)); + printk(KERN_DEBUG "-- CR%02x : %02x\n", i, SMC37c669_read_config(i)); } /*+ * ============================================================================ @@ -2542,13 +2542,13 @@ void __init SMC669_Init ( int index ) SMC37c669_display_device_info( ); #endif local_irq_restore(flags); - printk( "SMC37c669 Super I/O Controller found @ 0x%lx\n", + printk(KERN_INFO "SMC37c669 Super I/O Controller found @ 0x%lx\n", (unsigned long) SMC_base ); } else { local_irq_restore(flags); #if SMC_DEBUG - printk( "No SMC37c669 Super I/O Controller found\n" ); + printk(KERN_INFO "No SMC37c669 Super I/O Controller found\n" ); #endif } } --- a/arch/alpha/kernel/smc37c93x.c +++ b/arch/alpha/kernel/smc37c93x.c @@ -265,7 +265,7 @@ int __init SMC93x_Init(void) #endif SMCRunState(SMCUltraBase); local_irq_restore(flags); - printk("SMC FDC37C93X Ultra I/O Controller found @ 0x%lx\n", + printk(KERN_INFO "SMC FDC37C93X Ultra I/O Controller found @ 0x%lx\n", SMCUltraBase); return 1; } --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c @@ -148,7 +148,7 @@ int __init scoop_probe(struct platform_d platform_set_drvdata(pdev, devptr); - printk("Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base); + printk(KERN_INFO "Sharp Scoop Device found at 0x%08x -> 0x%08x\n",(unsigned int)mem->start,(unsigned int)devptr->base); SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140; reset_scoop(&pdev->dev); --- a/arch/arm/kernel/apm.c +++ b/arch/arm/kernel/apm.c @@ -514,6 +514,7 @@ static int kapmd(void *arg) static int __init apm_init(void) { + struct proc_dir_entry *proc_entry; int ret; if (apm_disabled) { @@ -530,7 +531,9 @@ static int __init apm_init(void) } #ifdef CONFIG_PROC_FS - create_proc_info_entry("apm", 0, NULL, apm_get_info); + proc_entry = create_proc_info_entry("apm", 0, NULL, apm_get_info); + if (proc_entry == NULL) + printk(KERN_WARNING "apm: Unable to create apm proc entry.\n"); #endif ret = misc_register(&apm_device); --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -48,7 +48,8 @@ static void pcibios_bus_report_status(st pci_write_config_word(dev, PCI_STATUS, status & status_mask); if (warn) - printk("(%s: %04X) ", pci_name(dev), status); + printk(KERN_WARNING "(%s: %04X) ", + pci_name(dev), status); } list_for_each_entry(dev, &bus->devices, bus_list) @@ -283,7 +284,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_C void __devinit pcibios_update_irq(struct pci_dev *dev, int irq) { if (debug_pci) - printk("PCI: Assigning IRQ %02d to %s\n", irq, pci_name(dev)); + printk(KERN_DEBUG "PCI: Assigning IRQ %02d to %s\n", irq, pci_name(dev)); pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); } @@ -509,7 +510,7 @@ static u8 __devinit pcibios_swizzle(stru slot = sys->swizzle(dev, pin); if (debug_pci) - printk("PCI: %s swizzling pin %d => pin %d slot %d\n", + printk(KERN_DEBUG "PCI: %s swizzling pin %d => pin %d slot %d\n", pci_name(dev), oldpin, *pin, slot); return slot; @@ -527,7 +528,7 @@ static int pcibios_map_irq(struct pci_de irq = sys->map_irq(dev, slot, pin); if (debug_pci) - printk("PCI: %s mapping slot %d pin %d => irq %d\n", + printk(KERN_DEBUG "PCI: %s mapping slot %d pin %d => irq %d\n", pci_name(dev), slot, pin, irq); return irq; @@ -680,7 +681,7 @@ int pcibios_enable_device(struct pci_dev cmd |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY; if (cmd != old_cmd) { - printk("PCI: enabling device %s (%04x -> %04x)\n", + printk(KERN_INFO "PCI: enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd); pci_write_config_word(dev, PCI_COMMAND, cmd); } --- a/arch/arm/kernel/ecard.c +++ b/arch/arm/kernel/ecard.c @@ -510,13 +510,13 @@ static void ecard_dump_irq_state(void) { ecard_t *ec; - printk("Expansion card IRQ state:\n"); + printk(KERN_DEBUG "Expansion card IRQ state:\n"); for (ec = cards; ec; ec = ec->next) { if (ec->slot_no == 8) continue; - printk(" %d: %sclaimed, ", + printk(KERN_DEBUG " %d: %sclaimed, ", ec->slot_no, ec->claimed ? "" : "not "); if (ec->ops && ec->ops->irqpending && @@ -777,9 +777,19 @@ static struct proc_dir_entry *proc_bus_e static void ecard_proc_init(void) { + struct proc_dir_entry *proc_entry; + proc_bus_ecard_dir = proc_mkdir("ecard", proc_bus); - create_proc_info_entry("devices", 0, proc_bus_ecard_dir, - get_ecard_dev_info); + if (proc_bus_ecard_dir == NULL) + printk(KERN_WARNING + "ecard: unable to create proc dir entry\n"); + else { + proc_entry = create_proc_info_entry("devices", 0, + proc_bus_ecard_dir, get_ecard_dev_info); + if (proc_entry == NULL) + printk(KERN_WARNING + "ecard: unable to create proc entry\n"); + } } #define ec_set_resource(ec,nr,st,sz) \ @@ -1067,7 +1077,7 @@ static int __init ecard_init(void) return ret; } - printk("Probing expansion cards\n"); + printk(KERN_INFO "Probing expansion cards\n"); for (slot = 0; slot < 8; slot ++) { if (ecard_probe(slot, ECARD_EASI) == -ENODEV) --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -213,7 +213,7 @@ int __cpuexit __cpu_disable(void) void __cpuexit __cpu_die(unsigned int cpu) { if (!platform_cpu_kill(cpu)) - printk("CPU%u: unable to kill\n", cpu); + printk(KERN_WARNING "CPU%u: unable to kill\n", cpu); } /* @@ -258,7 +258,7 @@ asmlinkage void __cpuinit secondary_star struct mm_struct *mm = &init_mm; unsigned int cpu = smp_processor_id(); - printk("CPU%u: Booted secondary processor\n", cpu); + printk(KERN_INFO "CPU%u: Booted secondary processor\n", cpu); /* * All kernel threads share the same mm context; grab a --- a/arch/arm/mach-footbridge/cats-pci.c +++ b/arch/arm/mach-footbridge/cats-pci.c @@ -25,7 +25,7 @@ static int __init cats_map_irq(struct pc return irqmap_cats[dev->irq - 1]; if (dev->irq != 0) - printk("PCI: device %02x:%02x has unknown irq line %x\n", + printk(KERN_INFO "PCI: device %02x:%02x has unknown irq line %x\n", dev->bus->number, dev->devfn, dev->irq); return -1; --- a/arch/arm/plat-omap/clock.c +++ b/arch/arm/plat-omap/clock.c @@ -10,7 +10,6 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#include #include #include #include --- a/arch/arm26/kernel/ecard.c +++ b/arch/arm26/kernel/ecard.c @@ -522,9 +522,16 @@ static struct proc_dir_entry *proc_bus_e static void ecard_proc_init(void) { + struct proc_dir_entry *proc_entry; proc_bus_ecard_dir = proc_mkdir("ecard", proc_bus); - create_proc_info_entry("devices", 0, proc_bus_ecard_dir, - get_ecard_dev_info); + if (!proc_bus_ecard_dir) + printk(KERN_WARNING "ecard.c: unable to create ecard proc dir entry\n"); + else { + proc_entry = create_proc_info_entry("devices", 0, + proc_bus_ecard_dir, get_ecard_dev_info); + if (!proc_entry) + printk(KERN_WARNING "ecard.c: unable to create devices proc entry\n"); + } } #define ec_set_resource(ec,nr,st,sz,flg) \ @@ -621,12 +628,10 @@ ecard_probe(int slot, card_type_t type) struct ex_ecid cid; int i, rc = -ENOMEM; - ec = kmalloc(sizeof(ecard_t), GFP_KERNEL); + ec = kzalloc(sizeof(ecard_t), GFP_KERNEL); if (!ec) goto nomem; - memset(ec, 0, sizeof(ecard_t)); - ec->slot_no = slot; ec->type = type; ec->irq = NO_IRQ; --- a/arch/arm26/Makefile +++ b/arch/arm26/Makefile @@ -16,7 +16,7 @@ CPPFLAGS_vmlinux.lds = -DTEXTADDR=$(TEXT OBJCOPYFLAGS :=-O binary -R .note -R .comment -S GZFLAGS :=-9 -ifeq ($(CONFIG_FRAME_POINTER),y) +ifdef CONFIG_FRAME_POINTER CFLAGS +=-fno-omit-frame-pointer -mno-sched-prolog endif @@ -24,7 +24,7 @@ CFLAGS_BOOT :=-mapcs-26 -mcpu=arm3 -msof CFLAGS +=-mapcs-26 -mcpu=arm3 -msoft-float -Uarm AFLAGS +=-mapcs-26 -mcpu=arm3 -msoft-float -ifeq ($(CONFIG_XIP_KERNEL),y) +ifdef CONFIG_XIP_KERNEL TEXTADDR := 0x03880000 DATAADDR := 0x02080000 else --- a/arch/arm26/nwfpe/fpmodule.c +++ b/arch/arm26/nwfpe/fpmodule.c @@ -24,7 +24,6 @@ #include "fpa11.h" #include -#include #include /* XXX */ --- a/arch/cris/arch-v10/drivers/axisflashmap.c +++ b/arch/cris/arch-v10/drivers/axisflashmap.c @@ -397,7 +397,7 @@ static int __init init_axis_flash(void) struct partitiontable_head *ptable_head = NULL; struct partitiontable_entry *ptable; int use_default_ptable = 1; /* Until proven otherwise. */ - const char *pmsg = " /dev/flash%d at 0x%08x, size 0x%08x\n"; + const char pmsg[] = " /dev/flash%d at 0x%08x, size 0x%08x\n"; if (!(mymtd = flash_probe())) { /* There's no reason to use this module if no flash chip can --- a/arch/cris/arch-v32/drivers/pcf8563.c +++ b/arch/cris/arch-v32/drivers/pcf8563.c @@ -325,14 +325,12 @@ pcf8563_ioctl(struct inode *inode, struc int pcf8563_open(struct inode *inode, struct file *filp) { - MOD_INC_USE_COUNT; return 0; } int pcf8563_release(struct inode *inode, struct file *filp) { - MOD_DEC_USE_COUNT; return 0; } --- a/arch/cris/arch-v32/kernel/fasttimer.c +++ b/arch/cris/arch-v32/kernel/fasttimer.c @@ -604,23 +604,8 @@ void schedule_usleep(unsigned long us) #ifdef CONFIG_PROC_FS static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) - ,int *eof, void *data_unused -#else - ,int unused -#endif - ); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) + ,int *eof, void *data_unused); static struct proc_dir_entry *fasttimer_proc_entry; -#else -static struct proc_dir_entry fasttimer_proc_entry = -{ - 0, 9, "fasttimer", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &proc_fasttimer_read /* get_info */, -}; -#endif #endif /* CONFIG_PROC_FS */ #ifdef CONFIG_PROC_FS @@ -629,12 +614,7 @@ static struct proc_dir_entry fasttimer_p #define BIG_BUF_SIZE (500 + NUM_TIMER_STATS * 300) static int proc_fasttimer_read(char *buf, char **start, off_t offset, int len -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) - ,int *eof, void *data_unused -#else - ,int unused -#endif - ) + ,int *eof, void *data_unused) { unsigned long flags; int i = 0; @@ -809,9 +789,7 @@ static int proc_fasttimer_read(char *buf memcpy(buf, bigbuf + offset, len); *start = buf; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) *eof = 1; -#endif return len; } @@ -975,12 +953,8 @@ void fast_timer_init(void) printk("fast_timer_init()\n"); #ifdef CONFIG_PROC_FS -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0) if ((fasttimer_proc_entry = create_proc_entry( "fasttimer", 0, 0 ))) fasttimer_proc_entry->read_proc = proc_fasttimer_read; -#else - proc_register_dynamic(&proc_root, &fasttimer_proc_entry); -#endif #endif /* PROC_FS */ if(request_irq(TIMER_INTR_VECT, timer_trig_interrupt, SA_INTERRUPT, "fast timer int", NULL)) --- a/arch/frv/kernel/setup.c +++ b/arch/frv/kernel/setup.c @@ -814,7 +814,7 @@ void __init setup_arch(char **cmdline_p) * - by now the stack is part of the init task */ printk("Memory %08lx-%08lx\n", memory_start, memory_end); - if (memory_start == memory_end) BUG(); + BUG_ON(memory_start == memory_end); init_mm.start_code = (unsigned long) &_stext; init_mm.end_code = (unsigned long) &_etext; --- a/arch/i386/kernel/apic.c +++ b/arch/i386/kernel/apic.c @@ -68,7 +68,7 @@ static void apic_pm_activate(void); */ void ack_bad_irq(unsigned int irq) { - printk("unexpected IRQ trap at vector %02x\n", irq); + printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq); /* * Currently unexpected vectors happen only on SMP and APIC. * We _must_ ack these because every local APIC has only N @@ -572,9 +572,9 @@ void __devinit setup_local_APIC(void) * ESR disabled - we can't do anything useful with the * errors anyway - mbligh */ - printk("Leaving ESR disabled.\n"); + printk(KERN_INFO "Leaving ESR disabled.\n"); else - printk("No ESR for 82489DX.\n"); + printk(KERN_INFO "No ESR for 82489DX.\n"); } if (nmi_watchdog == NMI_LOCAL_APIC) @@ -786,7 +786,7 @@ static int __init detect_init_APIC (void * APIC only if "lapic" specified. */ if (enable_local_apic <= 0) { - printk("Local APIC disabled by BIOS -- " + printk(KERN_INFO "Local APIC disabled by BIOS -- " "you can enable it with \"lapic\"\n"); return -1; } @@ -798,7 +798,7 @@ static int __init detect_init_APIC (void */ rdmsr(MSR_IA32_APICBASE, l, h); if (!(l & MSR_IA32_APICBASE_ENABLE)) { - printk("Local APIC disabled by BIOS -- reenabling.\n"); + printk(KERN_INFO "Local APIC disabled by BIOS -- reenabling.\n"); l &= ~MSR_IA32_APICBASE_BASE; l |= MSR_IA32_APICBASE_ENABLE | APIC_DEFAULT_PHYS_BASE; wrmsr(MSR_IA32_APICBASE, l, h); @@ -811,7 +811,7 @@ static int __init detect_init_APIC (void */ features = cpuid_edx(1); if (!(features & (1 << X86_FEATURE_APIC))) { - printk("Could not enable APIC!\n"); + printk(KERN_WARNING "Could not enable APIC!\n"); return -1; } set_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); @@ -825,14 +825,14 @@ static int __init detect_init_APIC (void if (nmi_watchdog != NMI_NONE) nmi_watchdog = NMI_LOCAL_APIC; - printk("Found and enabled local APIC!\n"); + printk(KERN_INFO "Found and enabled local APIC!\n"); apic_pm_activate(); return 0; no_apic: - printk("No local APIC present or hardware disabled\n"); + printk(KERN_INFO "No local APIC present or hardware disabled\n"); return -1; } --- a/arch/i386/kernel/cpu/intel_cacheinfo.c +++ b/arch/i386/kernel/cpu/intel_cacheinfo.c @@ -231,7 +231,7 @@ unsigned int __cpuinit init_intel_cachei */ if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) { /* supports eax=2 call */ - int i, j, n; + int j, n; int regs[4]; unsigned char *dp = (unsigned char *)regs; int only_trace = 0; @@ -393,12 +393,10 @@ static int __cpuinit detect_cache_attrib if (num_cache_leaves == 0) return -ENOENT; - cpuid4_info[cpu] = kmalloc( - sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL); + cpuid4_info[cpu] = kcalloc(num_cache_leaves, + sizeof(struct _cpuid4_info), GFP_KERNEL); if (unlikely(cpuid4_info[cpu] == NULL)) return -ENOMEM; - memset(cpuid4_info[cpu], 0, - sizeof(struct _cpuid4_info) * num_cache_leaves); oldmask = current->cpus_allowed; retval = set_cpus_allowed(current, cpumask_of_cpu(cpu)); @@ -571,17 +569,14 @@ static int __cpuinit cpuid4_cache_sysfs_ return -ENOENT; /* Allocate all required memory */ - cache_kobject[cpu] = kmalloc(sizeof(struct kobject), GFP_KERNEL); + cache_kobject[cpu] = kzalloc(sizeof(struct kobject), GFP_KERNEL); if (unlikely(cache_kobject[cpu] == NULL)) goto err_out; - memset(cache_kobject[cpu], 0, sizeof(struct kobject)); - index_kobject[cpu] = kmalloc( - sizeof(struct _index_kobject ) * num_cache_leaves, GFP_KERNEL); + index_kobject[cpu] = kcalloc(num_cache_leaves, + sizeof(struct _index_kobject), GFP_KERNEL); if (unlikely(index_kobject[cpu] == NULL)) goto err_out; - memset(index_kobject[cpu], 0, - sizeof(struct _index_kobject) * num_cache_leaves); return 0; --- a/arch/i386/kernel/cpu/mtrr/if.c +++ b/arch/i386/kernel/cpu/mtrr/if.c @@ -44,10 +44,9 @@ mtrr_file_add(unsigned long base, unsign max = num_var_ranges; if (fcount == NULL) { - fcount = kmalloc(max * sizeof *fcount, GFP_KERNEL); + fcount = kcalloc(max, sizeof(*fcount), GFP_KERNEL); if (!fcount) return -ENOMEM; - memset(fcount, 0, max * sizeof *fcount); FILE_FCOUNT(file) = fcount; } if (!page) { --- a/arch/i386/kernel/cpu/mtrr/main.c +++ b/arch/i386/kernel/cpu/mtrr/main.c @@ -565,10 +565,8 @@ static int mtrr_save(struct sys_device * int i; int size = num_var_ranges * sizeof(struct mtrr_value); - mtrr_state = kmalloc(size,GFP_ATOMIC); - if (mtrr_state) - memset(mtrr_state,0,size); - else + mtrr_state = kzalloc(size,GFP_ATOMIC); + if (!mtrr_state) return -ENOMEM; for (i = 0; i < num_var_ranges; i++) { --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -616,14 +616,12 @@ static int __init balanced_irq_init(void physical_balance = 1; for_each_online_cpu(i) { - irq_cpu_data[i].irq_delta = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL); - irq_cpu_data[i].last_irq = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL); + irq_cpu_data[i].irq_delta = kzalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL); + irq_cpu_data[i].last_irq = kzalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL); if (irq_cpu_data[i].irq_delta == NULL || irq_cpu_data[i].last_irq == NULL) { printk(KERN_ERR "balanced_irq_init: out of memory"); goto failed; } - memset(irq_cpu_data[i].irq_delta,0,sizeof(unsigned long) * NR_IRQS); - memset(irq_cpu_data[i].last_irq,0,sizeof(unsigned long) * NR_IRQS); } printk(KERN_INFO "Starting balanced_irq\n"); --- a/arch/i386/kernel/irq.c +++ b/arch/i386/kernel/irq.c @@ -29,7 +29,7 @@ EXPORT_PER_CPU_SYMBOL(irq_stat); */ void ack_bad_irq(unsigned int irq) { - printk("unexpected IRQ trap at vector %02x\n", irq); + printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq); } #endif @@ -69,7 +69,7 @@ fastcall unsigned int do_IRQ(struct pt_r __asm__ __volatile__("andl %%esp,%0" : "=r" (esp) : "0" (THREAD_SIZE - 1)); if (unlikely(esp < (sizeof(struct thread_info) + STACK_WARN))) { - printk("do_IRQ: stack overflow: %ld\n", + printk(KERN_ERR "do_IRQ: stack overflow: %ld\n", esp - sizeof(struct thread_info)); dump_stack(); } @@ -152,7 +152,7 @@ void irq_ctx_init(int cpu) softirq_ctx[cpu] = irqctx; - printk("CPU %u irqstacks, hard=%p soft=%p\n", + printk(KERN_INFO "CPU %u irqstacks, hard=%p soft=%p\n", cpu,hardirq_ctx[cpu],softirq_ctx[cpu]); } @@ -279,13 +279,13 @@ void fixup_irqs(cpumask_t map) cpus_and(mask, irq_affinity[irq], map); if (any_online_cpu(mask) == NR_CPUS) { - printk("Breaking affinity for irq %i\n", irq); + printk(KERN_ERR "Breaking affinity for irq %i\n", irq); mask = map; } if (irq_desc[irq].handler->set_affinity) irq_desc[irq].handler->set_affinity(irq, mask); else if (irq_desc[irq].action && !(warned++)) - printk("Cannot set affinity for irq %i\n", irq); + printk(KERN_ERR "Cannot set affinity for irq %i\n", irq); } #if 0 --- a/arch/i386/kernel/machine_kexec.c +++ b/arch/i386/kernel/machine_kexec.c @@ -133,9 +133,9 @@ typedef asmlinkage NORET_TYPE void (*rel unsigned long start_address, unsigned int has_pae) ATTRIB_NORET; -const extern unsigned char relocate_new_kernel[]; +extern const unsigned char relocate_new_kernel[]; extern void relocate_new_kernel_end(void); -const extern unsigned int relocate_new_kernel_size; +extern const unsigned int relocate_new_kernel_size; /* * A architecture hook called to validate the --- a/arch/i386/kernel/mca.c +++ b/arch/i386/kernel/mca.c @@ -283,10 +283,9 @@ static int __init mca_init(void) bus->f.mca_transform_memory = mca_dummy_transform_memory; /* get the motherboard device */ - mca_dev = kmalloc(sizeof(struct mca_device), GFP_KERNEL); + mca_dev = kzalloc(sizeof(struct mca_device), GFP_KERNEL); if(unlikely(!mca_dev)) goto out_nomem; - memset(mca_dev, 0, sizeof(struct mca_device)); /* * We do not expect many MCA interrupts during initialization, @@ -310,10 +309,9 @@ static int __init mca_init(void) mca_dev->slot = MCA_MOTHERBOARD; mca_register_device(MCA_PRIMARY_BUS, mca_dev); - mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC); + mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC); if(unlikely(!mca_dev)) goto out_unlock_nomem; - memset(mca_dev, 0, sizeof(struct mca_device)); /* Put motherboard into video setup mode, read integrated video @@ -349,10 +347,9 @@ static int __init mca_init(void) } if(which_scsi) { /* found a scsi card */ - mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC); + mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC); if(unlikely(!mca_dev)) goto out_unlock_nomem; - memset(mca_dev, 0, sizeof(struct mca_device)); for(j = 0; j < 8; j++) mca_dev->pos[j] = pos[j]; @@ -378,10 +375,9 @@ static int __init mca_init(void) if(!mca_read_and_store_pos(pos)) continue; - mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC); + mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC); if(unlikely(!mca_dev)) goto out_unlock_nomem; - memset(mca_dev, 0, sizeof(struct mca_device)); for(j=0; j<8; j++) mca_dev->pos[j]=pos[j]; --- a/arch/i386/kernel/pci-dma.c +++ b/arch/i386/kernel/pci-dma.c @@ -92,14 +92,12 @@ int dma_declare_coherent_memory(struct d if (!mem_base) goto out; - dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); + dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); if (!dev->dma_mem) goto out; - memset(dev->dma_mem, 0, sizeof(struct dma_coherent_mem)); - dev->dma_mem->bitmap = kmalloc(bitmap_size, GFP_KERNEL); + dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); if (!dev->dma_mem->bitmap) goto free1_out; - memset(dev->dma_mem->bitmap, 0, bitmap_size); dev->dma_mem->virt_base = mem_base; dev->dma_mem->device_base = device_addr; --- a/arch/i386/mach-voyager/voyager_cat.c +++ b/arch/i386/mach-voyager/voyager_cat.c @@ -644,20 +644,18 @@ voyager_cat_init(void) } CDEBUG(("VOYAGER DEBUG: found module id 0x%x, %s\n", i, cat_module_name(i))); - *modpp = kmalloc(sizeof(voyager_module_t), GFP_KERNEL); /*&voyager_module_storage[cat_count++];*/ + *modpp = kzalloc(sizeof(voyager_module_t), GFP_KERNEL); /*&voyager_module_storage[cat_count++];*/ if(*modpp == NULL) { printk("**WARNING** kmalloc failure in cat_init\n"); continue; } - memset(*modpp, 0, sizeof(voyager_module_t)); /* need temporary asic for cat_subread. It will be * filled in correctly later */ - (*modpp)->asic = kmalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count];*/ + (*modpp)->asic = kzalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count];*/ if((*modpp)->asic == NULL) { printk("**WARNING** kmalloc failure in cat_init\n"); continue; } - memset((*modpp)->asic, 0, sizeof(voyager_asic_t)); (*modpp)->asic->asic_id = VOYAGER_CAT_ID; (*modpp)->asic->subaddr = VOYAGER_SUBADDR_HI; (*modpp)->module_addr = i; @@ -772,7 +770,7 @@ voyager_cat_init(void) for(asic=0; asic < (*modpp)->num_asics; asic++) { int j; voyager_asic_t *asicp = *asicpp - = kmalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/ + = kzalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/ voyager_sp_table_t *sp_table; voyager_at_t *asic_table; voyager_jtt_t *jtag_table; @@ -781,7 +779,6 @@ voyager_cat_init(void) printk("**WARNING** kmalloc failure in cat_init\n"); continue; } - memset(asicp, 0, sizeof(voyager_asic_t)); asicpp = &(asicp->next); asicp->asic_location = asic; sp_table = (voyager_sp_table_t *)(eprom_buf + sp_offset); @@ -847,8 +844,7 @@ voyager_cat_init(void) #endif { - struct resource *res = kmalloc(sizeof(struct resource),GFP_KERNEL); - memset(res, 0, sizeof(struct resource)); + struct resource *res = kzalloc(sizeof(struct resource),GFP_KERNEL); res->name = kmalloc(128, GFP_KERNEL); sprintf((char *)res->name, "Voyager %s Quad CPI", cat_module_name(i)); res->start = qic_addr; --- a/arch/i386/math-emu/reg_divide.c +++ b/arch/i386/math-emu/reg_divide.c @@ -150,7 +150,6 @@ int FPU_div(int flags, int rm, int contr if ( flags & DEST_RM ) { - int tag; tag = FPU_gettag0(); if ( tag == TAG_Special ) tag = FPU_Special(st0_ptr); @@ -158,7 +157,6 @@ int FPU_div(int flags, int rm, int contr } else { - int tag; tag = FPU_gettagi(rm); if ( tag == TAG_Special ) tag = FPU_Special(&st(rm)); --- a/arch/i386/pci/pcbios.c +++ b/arch/i386/pci/pcbios.c @@ -445,9 +445,8 @@ struct irq_routing_table * __devinit pci if (ret & 0xff00) printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff); else if (opt.size) { - rt = kmalloc(sizeof(struct irq_routing_table) + opt.size, GFP_KERNEL); + rt = kzalloc(sizeof(struct irq_routing_table) + opt.size, GFP_KERNEL); if (rt) { - memset(rt, 0, sizeof(struct irq_routing_table)); rt->size = opt.size + sizeof(struct irq_routing_table); rt->exclusive_irqs = map; memcpy(rt->slots, (void *) page, opt.size); --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c @@ -1673,15 +1673,13 @@ ioc_sac_init(struct ioc *ioc) * SAC (single address cycle) addressable, so allocate a * pseudo-device to enforce that. */ - sac = kmalloc(sizeof(*sac), GFP_KERNEL); + sac = kzalloc(sizeof(*sac), GFP_KERNEL); if (!sac) panic(PFX "Couldn't allocate struct pci_dev"); - memset(sac, 0, sizeof(*sac)); - controller = kmalloc(sizeof(*controller), GFP_KERNEL); + controller = kzalloc(sizeof(*controller), GFP_KERNEL); if (!controller) panic(PFX "Couldn't allocate struct pci_controller"); - memset(controller, 0, sizeof(*controller)); controller->iommu = ioc; sac->sysdata = controller; @@ -1738,12 +1736,10 @@ ioc_init(u64 hpa, void *handle) struct ioc *ioc; struct ioc_iommu *info; - ioc = kmalloc(sizeof(*ioc), GFP_KERNEL); + ioc = kzalloc(sizeof(*ioc), GFP_KERNEL); if (!ioc) return NULL; - memset(ioc, 0, sizeof(*ioc)); - ioc->next = ioc_list; ioc_list = ioc; --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c @@ -685,12 +685,11 @@ static int get_async_struct(int line, st *ret_info = sstate->info; return 0; } - info = kmalloc(sizeof(struct async_struct), GFP_KERNEL); + info = kzalloc(sizeof(struct async_struct), GFP_KERNEL); if (!info) { sstate->count--; return -ENOMEM; } - memset(info, 0, sizeof(struct async_struct)); init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); init_waitqueue_head(&info->delta_msr_wait); --- a/arch/ia64/kernel/cpufreq/acpi-cpufreq.c +++ b/arch/ia64/kernel/cpufreq/acpi-cpufreq.c @@ -280,12 +280,10 @@ acpi_cpufreq_cpu_init ( dprintk("acpi_cpufreq_cpu_init\n"); - data = kmalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); + data = kzalloc(sizeof(struct cpufreq_acpi_io), GFP_KERNEL); if (!data) return (-ENOMEM); - memset(data, 0, sizeof(struct cpufreq_acpi_io)); - acpi_io_data[cpu] = data; result = acpi_processor_register_performance(&data->acpi_data, cpu); --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c @@ -847,11 +847,9 @@ pfm_context_alloc(void) * allocate context descriptor * must be able to free with interrupts disabled */ - ctx = kmalloc(sizeof(pfm_context_t), GFP_KERNEL); - if (ctx) { - memset(ctx, 0, sizeof(pfm_context_t)); + ctx = kzalloc(sizeof(pfm_context_t), GFP_KERNEL); + if (ctx) DPRINT(("alloc ctx @%p\n", ctx)); - } return ctx; } --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -127,11 +127,10 @@ alloc_pci_controller (int seg) { struct pci_controller *controller; - controller = kmalloc(sizeof(*controller), GFP_KERNEL); + controller = kzalloc(sizeof(*controller), GFP_KERNEL); if (!controller) return NULL; - memset(controller, 0, sizeof(*controller)); controller->segment = seg; controller->node = -1; return controller; --- a/arch/m68k/amiga/chipram.c +++ b/arch/m68k/amiga/chipram.c @@ -53,10 +53,9 @@ void *amiga_chip_alloc(unsigned long siz #ifdef DEBUG printk("amiga_chip_alloc: allocate %ld bytes\n", size); #endif - res = kmalloc(sizeof(struct resource), GFP_KERNEL); + res = kzalloc(sizeof(struct resource), GFP_KERNEL); if (!res) return NULL; - memset(res, 0, sizeof(struct resource)); res->name = name; if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) { --- a/arch/m68k/atari/hades-pci.c +++ b/arch/m68k/atari/hades-pci.c @@ -376,10 +376,9 @@ struct pci_bus_info * __init init_hades_ * Allocate memory for bus info structure. */ - bus = kmalloc(sizeof(struct pci_bus_info), GFP_KERNEL); + bus = kzalloc(sizeof(struct pci_bus_info), GFP_KERNEL); if (!bus) return NULL; - memset(bus, 0, sizeof(struct pci_bus_info)); /* * Claim resources. The m68k has no separate I/O space, both --- a/arch/m68k/atari/time.c +++ b/arch/m68k/atari/time.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -97,7 +98,7 @@ static void mste_write(struct MSTE_RTC * } while(0) -#define HWCLK_POLL_INTERVAL 5 +#define HWCLK_POLL_INTERVAL 50 /* ms */ int atari_mste_hwclk( int op, struct rtc_time *t ) { @@ -213,7 +214,7 @@ int atari_tt_hwclk( int op, struct rtc_t */ while( RTC_READ(RTC_FREQ_SELECT) & RTC_UIP ) - schedule_timeout_interruptible(HWCLK_POLL_INTERVAL); + msleep_interruptible(HWCLK_POLL_INTERVAL); local_irq_save(flags); RTC_WRITE( RTC_CONTROL, ctrl | RTC_SET ); --- a/arch/powerpc/kernel/ibmebus.c +++ b/arch/powerpc/kernel/ibmebus.c @@ -210,11 +210,10 @@ static struct ibmebus_dev* __devinit ibm return NULL; } - dev = kmalloc(sizeof(struct ibmebus_dev), GFP_KERNEL); + dev = kzalloc(sizeof(struct ibmebus_dev), GFP_KERNEL); if (!dev) { return NULL; } - memset(dev, 0, sizeof(struct ibmebus_dev)); dev->ofdev.node = of_node_get(dn); --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -364,7 +364,7 @@ struct pci_dev *of_create_pci_dev(struct struct pci_dev *dev; const char *type; - dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); + dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); if (!dev) return NULL; type = get_property(node, "device_type", NULL); @@ -373,7 +373,6 @@ struct pci_dev *of_create_pci_dev(struct DBG(" create device, devfn: %x, type: %s\n", devfn, type); - memset(dev, 0, sizeof(struct pci_dev)); dev->bus = bus; dev->sysdata = node; dev->dev.parent = bus->bridge; --- a/arch/powerpc/kernel/smp-tbsync.c +++ b/arch/powerpc/kernel/smp-tbsync.c @@ -116,8 +116,7 @@ void __devinit smp_generic_give_timebase printk("Synchronizing timebase\n"); /* if this fails then this kernel won't work anyway... */ - tbsync = kmalloc( sizeof(*tbsync), GFP_KERNEL ); - memset( tbsync, 0, sizeof(*tbsync) ); + tbsync = kzalloc(sizeof(*tbsync), GFP_KERNEL); mb(); running = 1; --- a/arch/powerpc/platforms/iseries/iommu.c +++ b/arch/powerpc/platforms/iseries/iommu.c @@ -107,12 +107,10 @@ void iommu_table_getparms_iSeries(unsign { struct iommu_table_cb *parms; - parms = kmalloc(sizeof(*parms), GFP_KERNEL); + parms = kzalloc(sizeof(*parms), GFP_KERNEL); if (parms == NULL) panic("PCI_DMA: TCE Table Allocation failed."); - memset(parms, 0, sizeof(*parms)); - parms->itc_busno = busno; parms->itc_slotno = slotno; parms->itc_virtbus = virtbus; --- a/arch/powerpc/platforms/iseries/pci.c +++ b/arch/powerpc/platforms/iseries/pci.c @@ -207,10 +207,9 @@ static struct device_node *build_device_ struct device_node *node; struct pci_dn *pdn; - node = kmalloc(sizeof(struct device_node), GFP_KERNEL); + node = kzalloc(sizeof(struct device_node), GFP_KERNEL); if (node == NULL) return NULL; - memset(node, 0, sizeof(struct device_node)); pdn = kzalloc(sizeof(*pdn), GFP_KERNEL); if (pdn == NULL) { kfree(node); --- a/arch/powerpc/platforms/iseries/vio.c +++ b/arch/powerpc/platforms/iseries/vio.c @@ -53,10 +53,9 @@ static struct vio_dev *__init vio_regist struct vio_dev *viodev; /* allocate a vio_dev for this device */ - viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL); + viodev = kzalloc(sizeof(struct vio_dev), GFP_KERNEL); if (!viodev) return NULL; - memset(viodev, 0, sizeof(struct vio_dev)); snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num); --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -268,11 +268,10 @@ static char * parse_next_property(char * static struct property *new_property(const char *name, const int length, const unsigned char *value, struct property *last) { - struct property *new = kmalloc(sizeof(*new), GFP_KERNEL); + struct property *new = kzalloc(sizeof(*new), GFP_KERNEL); if (!new) return NULL; - memset(new, 0, sizeof(*new)); if (!(new->name = kmalloc(strlen(name) + 1, GFP_KERNEL))) goto cleanup; --- a/arch/powerpc/platforms/pseries/vio.c +++ b/arch/powerpc/platforms/pseries/vio.c @@ -167,11 +167,10 @@ struct vio_dev * __devinit vio_register_ } /* allocate a vio_dev for this node */ - viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL); + viodev = kzalloc(sizeof(struct vio_dev), GFP_KERNEL); if (!viodev) { return NULL; } - memset(viodev, 0, sizeof(struct vio_dev)); viodev->dev.platform_data = of_node_get(of_node); --- a/arch/ppc/4xx_io/serial_sicc.c +++ b/arch/ppc/4xx_io/serial_sicc.c @@ -58,125 +58,121 @@ #include #include - #include - /* ----------------------------------------------------------------------------- * From STB03xxx SICC UART Specification * ----------------------------------------------------------------------------- * UART Register Offsets. */ -#define BL_SICC_LSR 0x0000000 /* line status register read/clear */ -#define BL_SICC_LSRS 0x0000001 /* set line status register read/set */ -#define BL_SICC_HSR 0x0000002 /* handshake status register r/clear */ -#define BL_SICC_HSRS 0x0000003 /* set handshake status register r/set */ -#define BL_SICC_BRDH 0x0000004 /* baudrate divisor high reg r/w */ -#define BL_SICC_BRDL 0x0000005 /* baudrate divisor low reg r/w */ -#define BL_SICC_LCR 0x0000006 /* control register r/w */ -#define BL_SICC_RCR 0x0000007 /* receiver command register r/w */ -#define BL_SICC_TxCR 0x0000008 /* transmitter command register r/w */ -#define BL_SICC_RBR 0x0000009 /* receive buffer r */ -#define BL_SICC_TBR 0x0000009 /* transmit buffer w */ -#define BL_SICC_CTL2 0x000000A /* added for Vesta */ -#define BL_SICC_IrCR 0x000000B /* added for Vesta IR */ +#define BL_SICC_LSR 0x0000000 /* line status register read/clear */ +#define BL_SICC_LSRS 0x0000001 /* set line status register read/set */ +#define BL_SICC_HSR 0x0000002 /* handshake status register r/clear */ +#define BL_SICC_HSRS 0x0000003 /* set handshake status register r/set */ +#define BL_SICC_BRDH 0x0000004 /* baudrate divisor high reg r/w */ +#define BL_SICC_BRDL 0x0000005 /* baudrate divisor low reg r/w */ +#define BL_SICC_LCR 0x0000006 /* control register r/w */ +#define BL_SICC_RCR 0x0000007 /* receiver command register r/w */ +#define BL_SICC_TxCR 0x0000008 /* transmitter command register r/w */ +#define BL_SICC_RBR 0x0000009 /* receive buffer r */ +#define BL_SICC_TBR 0x0000009 /* transmit buffer w */ +#define BL_SICC_CTL2 0x000000A /* added for Vesta */ +#define BL_SICC_IrCR 0x000000B /* added for Vesta IR */ /* masks and definitions for serial port control register */ -#define _LCR_LM_MASK 0xc0 /* loop back modes */ -#define _LCR_DTR_MASK 0x20 /* data terminal ready 0-inactive */ -#define _LCR_RTS_MASK 0x10 /* request to send 0-inactive */ -#define _LCR_DB_MASK 0x08 /* data bits mask */ -#define _LCR_PE_MASK 0x04 /* parity enable */ -#define _LCR_PTY_MASK 0x02 /* parity */ -#define _LCR_SB_MASK 0x01 /* stop bit mask */ - -#define _LCR_LM_NORM 0x00 /* normal operation */ -#define _LCR_LM_LOOP 0x40 /* internal loopback mode */ -#define _LCR_LM_ECHO 0x80 /* automatic echo mode */ -#define _LCR_LM_RES 0xc0 /* reserved */ - -#define _LCR_DTR_ACTIVE _LCR_DTR_MASK /* DTR is active */ -#define _LCR_RTS_ACTIVE _LCR_RTS_MASK /* RTS is active */ -#define _LCR_DB_8_BITS _LCR_DB_MASK /* 8 data bits */ -#define _LCR_DB_7_BITS 0x00 /* 7 data bits */ -#define _LCR_PE_ENABLE _LCR_PE_MASK /* parity enabled */ -#define _LCR_PE_DISABLE 0x00 /* parity disabled */ -#define _LCR_PTY_EVEN 0x00 /* even parity */ -#define _LCR_PTY_ODD _LCR_PTY_MASK /* odd parity */ -#define _LCR_SB_1_BIT 0x00 /* one stop bit */ -#define _LCR_SB_2_BIT _LCR_SB_MASK /* two stop bit */ +#define _LCR_LM_MASK 0xc0 /* loop back modes */ +#define _LCR_DTR_MASK 0x20 /* data terminal ready 0-inactive */ +#define _LCR_RTS_MASK 0x10 /* request to send 0-inactive */ +#define _LCR_DB_MASK 0x08 /* data bits mask */ +#define _LCR_PE_MASK 0x04 /* parity enable */ +#define _LCR_PTY_MASK 0x02 /* parity */ +#define _LCR_SB_MASK 0x01 /* stop bit mask */ + +#define _LCR_LM_NORM 0x00 /* normal operation */ +#define _LCR_LM_LOOP 0x40 /* internal loopback mode */ +#define _LCR_LM_ECHO 0x80 /* automatic echo mode */ +#define _LCR_LM_RES 0xc0 /* reserved */ + +#define _LCR_DTR_ACTIVE _LCR_DTR_MASK /* DTR is active */ +#define _LCR_RTS_ACTIVE _LCR_RTS_MASK /* RTS is active */ +#define _LCR_DB_8_BITS _LCR_DB_MASK /* 8 data bits */ +#define _LCR_DB_7_BITS 0x00 /* 7 data bits */ +#define _LCR_PE_ENABLE _LCR_PE_MASK /* parity enabled */ +#define _LCR_PE_DISABLE 0x00 /* parity disabled */ +#define _LCR_PTY_EVEN 0x00 /* even parity */ +#define _LCR_PTY_ODD _LCR_PTY_MASK /* odd parity */ +#define _LCR_SB_1_BIT 0x00 /* one stop bit */ +#define _LCR_SB_2_BIT _LCR_SB_MASK /* two stop bit */ /* serial port handshake register */ -#define _HSR_DIS_MASK 0x80 /* DSR input inactive error mask */ -#define _HSR_CS_MASK 0x40 /* CTS input inactive error mask */ -#define _HSR_DIS_ACT 0x00 /* dsr input is active */ -#define _HSR_DIS_INACT _HSR_DIS_MASK /* dsr input is inactive */ -#define _HSR_CS_ACT 0x00 /* cts input is active */ -#define _HSR_CS_INACT _HSR_CS_MASK /* cts input is active */ +#define _HSR_DIS_MASK 0x80 /* DSR input inactive error mask */ +#define _HSR_CS_MASK 0x40 /* CTS input inactive error mask */ +#define _HSR_DIS_ACT 0x00 /* dsr input is active */ +#define _HSR_DIS_INACT _HSR_DIS_MASK /* dsr input is inactive */ +#define _HSR_CS_ACT 0x00 /* cts input is active */ +#define _HSR_CS_INACT _HSR_CS_MASK /* cts input is active */ /* serial port line status register */ -#define _LSR_RBR_MASK 0x80 /* receive buffer ready mask */ -#define _LSR_FE_MASK 0x40 /* framing error */ -#define _LSR_OE_MASK 0x20 /* overrun error */ -#define _LSR_PE_MASK 0x10 /* parity error */ -#define _LSR_LB_MASK 0x08 /* line break */ -#define _LSR_TBR_MASK 0x04 /* transmit buffer ready */ -#define _LSR_TSR_MASK 0x02 /* transmit shift register ready */ - -#define _LSR_RBR_FULL _LSR_RBR_MASK /* receive buffer is full */ -#define _LSR_FE_ERROR _LSR_FE_MASK /* framing error detected */ -#define _LSR_OE_ERROR _LSR_OE_MASK /* overrun error detected */ -#define _LSR_PE_ERROR _LSR_PE_MASK /* parity error detected */ -#define _LSR_LB_BREAK _LSR_LB_MASK /* line break detected */ -#define _LSR_TBR_EMPTY _LSR_TBR_MASK /* transmit buffer is ready */ -#define _LSR_TSR_EMPTY _LSR_TSR_MASK /* transmit shift register is empty */ -#define _LSR_TX_ALL 0x06 /* all physical transmit is done */ +#define _LSR_RBR_MASK 0x80 /* receive buffer ready mask */ +#define _LSR_FE_MASK 0x40 /* framing error */ +#define _LSR_OE_MASK 0x20 /* overrun error */ +#define _LSR_PE_MASK 0x10 /* parity error */ +#define _LSR_LB_MASK 0x08 /* line break */ +#define _LSR_TBR_MASK 0x04 /* transmit buffer ready */ +#define _LSR_TSR_MASK 0x02 /* transmit shift register ready */ + +#define _LSR_RBR_FULL _LSR_RBR_MASK /* receive buffer is full */ +#define _LSR_FE_ERROR _LSR_FE_MASK /* framing error detected */ +#define _LSR_OE_ERROR _LSR_OE_MASK /* overrun error detected */ +#define _LSR_PE_ERROR _LSR_PE_MASK /* parity error detected */ +#define _LSR_LB_BREAK _LSR_LB_MASK /* line break detected */ +#define _LSR_TBR_EMPTY _LSR_TBR_MASK /* transmit buffer is ready */ +#define _LSR_TSR_EMPTY _LSR_TSR_MASK /* transmit shift register is empty */ +#define _LSR_TX_ALL 0x06 /* all physical transmit is done */ #define _LSR_RX_ERR (_LSR_LB_BREAK | _LSR_FE_MASK | _LSR_OE_MASK | \ _LSR_PE_MASK ) /* serial port receiver command register */ -#define _RCR_ER_MASK 0x80 /* enable receiver mask */ -#define _RCR_DME_MASK 0x60 /* dma mode */ -#define _RCR_EIE_MASK 0x10 /* error interrupt enable mask */ -#define _RCR_PME_MASK 0x08 /* pause mode mask */ - -#define _RCR_ER_ENABLE _RCR_ER_MASK /* receiver enabled */ -#define _RCR_DME_DISABLE 0x00 /* dma disabled */ -#define _RCR_DME_RXRDY 0x20 /* dma disabled, RxRDY interrupt enabled*/ -#define _RCR_DME_ENABLE2 0x40 /* dma enabled,receiver src channel 2 */ -#define _RCR_DME_ENABLE3 0x60 /* dma enabled,receiver src channel 3 */ -#define _RCR_PME_HARD _RCR_PME_MASK /* RTS controlled by hardware */ -#define _RCR_PME_SOFT 0x00 /* RTS controlled by software */ +#define _RCR_ER_MASK 0x80 /* enable receiver mask */ +#define _RCR_DME_MASK 0x60 /* dma mode */ +#define _RCR_EIE_MASK 0x10 /* error interrupt enable mask */ +#define _RCR_PME_MASK 0x08 /* pause mode mask */ + +#define _RCR_ER_ENABLE _RCR_ER_MASK /* receiver enabled */ +#define _RCR_DME_DISABLE 0x00 /* dma disabled */ +#define _RCR_DME_RXRDY 0x20 /* dma disabled, RxRDY interrupt enabled */ +#define _RCR_DME_ENABLE2 0x40 /* dma enabled,receiver src channel 2 */ +#define _RCR_DME_ENABLE3 0x60 /* dma enabled,receiver src channel 3 */ +#define _RCR_PME_HARD _RCR_PME_MASK /* RTS controlled by hardware */ +#define _RCR_PME_SOFT 0x00 /* RTS controlled by software */ /* serial port transmit command register */ -#define _TxCR_ET_MASK 0x80 /* transmiter enable mask */ -#define _TxCR_DME_MASK 0x60 /* dma mode mask */ -#define _TxCR_TIE_MASK 0x10 /* empty interrupt enable mask */ -#define _TxCR_EIE_MASK 0x08 /* error interrupt enable mask */ -#define _TxCR_SPE_MASK 0x04 /* stop/pause mask */ -#define _TxCR_TB_MASK 0x02 /* transmit break mask */ - -#define _TxCR_ET_ENABLE _TxCR_ET_MASK /* transmiter enabled */ -#define _TxCR_DME_DISABLE 0x00 /* transmiter disabled, TBR intr disabled */ -#define _TxCR_DME_TBR 0x20 /* transmiter disabled, TBR intr enabled */ -#define _TxCR_DME_CHAN_2 0x40 /* dma enabled, destination chann 2 */ -#define _TxCR_DME_CHAN_3 0x60 /* dma enabled, destination chann 3 */ +#define _TxCR_ET_MASK 0x80 /* transmiter enable mask */ +#define _TxCR_DME_MASK 0x60 /* dma mode mask */ +#define _TxCR_TIE_MASK 0x10 /* empty interrupt enable mask */ +#define _TxCR_EIE_MASK 0x08 /* error interrupt enable mask */ +#define _TxCR_SPE_MASK 0x04 /* stop/pause mask */ +#define _TxCR_TB_MASK 0x02 /* transmit break mask */ + +#define _TxCR_ET_ENABLE _TxCR_ET_MASK /* transmiter enabled */ +#define _TxCR_DME_DISABLE 0x00 /* transmiter disabled, TBR intr disabled */ +#define _TxCR_DME_TBR 0x20 /* transmiter disabled, TBR intr enabled */ +#define _TxCR_DME_CHAN_2 0x40 /* dma enabled, destination chann 2 */ +#define _TxCR_DME_CHAN_3 0x60 /* dma enabled, destination chann 3 */ /* serial ctl reg 2 - added for Vesta */ -#define _CTL2_EXTERN 0x80 /* */ -#define _CTL2_USEFIFO 0x40 /* */ -#define _CTL2_RESETRF 0x08 /* */ -#define _CTL2_RESETTF 0x04 /* */ - - +#define _CTL2_EXTERN 0x80 /* */ +#define _CTL2_USEFIFO 0x40 /* */ +#define _CTL2_RESETRF 0x08 /* */ +#define _CTL2_RESETTF 0x04 /* */ #define SERIAL_SICC_NAME "ttySICC" #define SERIAL_SICC_MAJOR 150 @@ -223,46 +219,46 @@ static u_char *tmp_buf; #define EVT_WRITE_WAKEUP 0 struct SICC_icount { - __u32 cts; - __u32 dsr; - __u32 rng; - __u32 dcd; - __u32 rx; - __u32 tx; - __u32 frame; - __u32 overrun; - __u32 parity; - __u32 brk; - __u32 buf_overrun; + __u32 cts; + __u32 dsr; + __u32 rng; + __u32 dcd; + __u32 rx; + __u32 tx; + __u32 frame; + __u32 overrun; + __u32 parity; + __u32 brk; + __u32 buf_overrun; }; /* * Static information about the port */ struct SICC_port { - unsigned int uart_base; - unsigned int uart_base_phys; - unsigned int irqrx; - unsigned int irqtx; - unsigned int uartclk; - unsigned int fifosize; - unsigned int tiocm_support; - void (*set_mctrl)(struct SICC_port *, u_int mctrl); + unsigned int uart_base; + unsigned int uart_base_phys; + unsigned int irqrx; + unsigned int irqtx; + unsigned int uartclk; + unsigned int fifosize; + unsigned int tiocm_support; + void (*set_mctrl) (struct SICC_port *, u_int mctrl); }; /* * This is the state information which is persistent across opens */ struct SICC_state { - struct SICC_icount icount; - unsigned int line; - unsigned int close_delay; - unsigned int closing_wait; - unsigned int custom_divisor; - unsigned int flags; - int count; - struct SICC_info *info; - spinlock_t sicc_lock; + struct SICC_icount icount; + unsigned int line; + unsigned int close_delay; + unsigned int closing_wait; + unsigned int custom_divisor; + unsigned int flags; + int count; + struct SICC_info *info; + spinlock_t sicc_lock; }; #define SICC_XMIT_SIZE 1024 @@ -270,53 +266,52 @@ struct SICC_state { * This is the state information which is only valid when the port is open. */ struct SICC_info { - struct SICC_port *port; - struct SICC_state *state; - struct tty_struct *tty; - unsigned char x_char; - unsigned char old_status; - unsigned char read_status_mask; - unsigned char ignore_status_mask; - struct circ_buf xmit; - unsigned int flags; + struct SICC_port *port; + struct SICC_state *state; + struct tty_struct *tty; + unsigned char x_char; + unsigned char old_status; + unsigned char read_status_mask; + unsigned char ignore_status_mask; + struct circ_buf xmit; + unsigned int flags; #ifdef SUPPORT_SYSRQ - unsigned long sysrq; + unsigned long sysrq; #endif - unsigned int event; - unsigned int timeout; - unsigned int lcr_h; - unsigned int mctrl; - int blocked_open; - - struct tasklet_struct tlet; - - wait_queue_head_t open_wait; - wait_queue_head_t close_wait; - wait_queue_head_t delta_msr_wait; + unsigned int event; + unsigned int timeout; + unsigned int lcr_h; + unsigned int mctrl; + int blocked_open; + + struct tasklet_struct tlet; + + wait_queue_head_t open_wait; + wait_queue_head_t close_wait; + wait_queue_head_t delta_msr_wait; }; #ifdef CONFIG_SERIAL_SICC_CONSOLE static struct console siccuart_cons; #endif -static void siccuart_change_speed(struct SICC_info *info, struct termios *old_termios); +static void siccuart_change_speed(struct SICC_info *info, + struct termios *old_termios); static void siccuart_wait_until_sent(struct tty_struct *tty, int timeout); - - static void powerpcMtcic_cr(unsigned long value) { - mtdcr(DCRN_CICCR, value); + mtdcr(DCRN_CICCR, value); } static unsigned long powerpcMfcic_cr(void) { - return mfdcr(DCRN_CICCR); + return mfdcr(DCRN_CICCR); } static unsigned long powerpcMfclkgpcr(void) { - return mfdcr(DCRN_SCCR); + return mfdcr(DCRN_SCCR); } static void sicc_set_mctrl_null(struct SICC_port *port, u_int mctrl) @@ -324,379 +319,370 @@ static void sicc_set_mctrl_null(struct S } static struct SICC_port sicc_ports[SERIAL_SICC_NR] = { - { - .uart_base = 0, - .uart_base_phys = SICC0_IO_BASE, - .irqrx = SICC0_INTRX, - .irqtx = SICC0_INTTX, + { + .uart_base = 0, + .uart_base_phys = SICC0_IO_BASE, + .irqrx = SICC0_INTRX, + .irqtx = SICC0_INTTX, // .uartclk = 0, - .fifosize = 1, - .set_mctrl = sicc_set_mctrl_null, - } + .fifosize = 1, + .set_mctrl = sicc_set_mctrl_null, + } }; static struct SICC_state sicc_state[SERIAL_SICC_NR]; static void siccuart_enable_rx_interrupt(struct SICC_info *info) { - unsigned char cr; + unsigned char cr; - cr = readb(info->port->uart_base+BL_SICC_RCR); - cr &= ~_RCR_DME_MASK; - cr |= _RCR_DME_RXRDY; - writeb(cr, info->port->uart_base+BL_SICC_RCR); + cr = readb(info->port->uart_base + BL_SICC_RCR); + cr &= ~_RCR_DME_MASK; + cr |= _RCR_DME_RXRDY; + writeb(cr, info->port->uart_base + BL_SICC_RCR); } static void siccuart_disable_rx_interrupt(struct SICC_info *info) { - unsigned char cr; + unsigned char cr; - cr = readb(info->port->uart_base+BL_SICC_RCR); - cr &= ~_RCR_DME_MASK; - cr |= _RCR_DME_DISABLE; - writeb(cr, info->port->uart_base+BL_SICC_RCR); + cr = readb(info->port->uart_base + BL_SICC_RCR); + cr &= ~_RCR_DME_MASK; + cr |= _RCR_DME_DISABLE; + writeb(cr, info->port->uart_base + BL_SICC_RCR); } - static void siccuart_enable_tx_interrupt(struct SICC_info *info) { - unsigned char cr; + unsigned char cr; - cr = readb(info->port->uart_base+BL_SICC_TxCR); - cr &= ~_TxCR_DME_MASK; - cr |= _TxCR_DME_TBR; - writeb(cr, info->port->uart_base+BL_SICC_TxCR); + cr = readb(info->port->uart_base + BL_SICC_TxCR); + cr &= ~_TxCR_DME_MASK; + cr |= _TxCR_DME_TBR; + writeb(cr, info->port->uart_base + BL_SICC_TxCR); } static void siccuart_disable_tx_interrupt(struct SICC_info *info) { - unsigned char cr; + unsigned char cr; - cr = readb(info->port->uart_base+BL_SICC_TxCR); - cr &= ~_TxCR_DME_MASK; - cr |= _TxCR_DME_DISABLE; - writeb(cr, info->port->uart_base+BL_SICC_TxCR); + cr = readb(info->port->uart_base + BL_SICC_TxCR); + cr &= ~_TxCR_DME_MASK; + cr |= _TxCR_DME_DISABLE; + writeb(cr, info->port->uart_base + BL_SICC_TxCR); } - static void siccuart_stop(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; + struct SICC_info *info = tty->driver_data; + unsigned long flags; - /* disable interrupts while stopping serial port interrupts */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - siccuart_disable_tx_interrupt(info); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); + /* disable interrupts while stopping serial port interrupts */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + siccuart_disable_tx_interrupt(info); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); } static void siccuart_start(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; + struct SICC_info *info = tty->driver_data; + unsigned long flags; - /* disable interrupts while starting serial port interrupts */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - if (info->xmit.head != info->xmit.tail - && info->xmit.buf) - siccuart_enable_tx_interrupt(info); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); + /* disable interrupts while starting serial port interrupts */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + if (info->xmit.head != info->xmit.tail && info->xmit.buf) + siccuart_enable_tx_interrupt(info); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); } - /* * This routine is used by the interrupt handler to schedule * processing in the software interrupt portion of the driver. */ static void siccuart_event(struct SICC_info *info, int event) { - info->event |= 1 << event; - tasklet_schedule(&info->tlet); + info->event |= 1 << event; + tasklet_schedule(&info->tlet); } -static void -siccuart_rx_chars(struct SICC_info *info, struct pt_regs *regs) +static void siccuart_rx_chars(struct SICC_info *info, struct pt_regs *regs) { - struct tty_struct *tty = info->tty; - unsigned int status, ch, rsr, flg, ignored = 0; - struct SICC_icount *icount = &info->state->icount; - struct SICC_port *port = info->port; - - status = readb(port->uart_base+BL_SICC_LSR ); - while (status & _LSR_RBR_FULL) { - ch = readb(port->uart_base+BL_SICC_RBR); - - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto ignore_char; - icount->rx++; - - flg = TTY_NORMAL; - - /* - * Note that the error handling code is - * out of the main execution path - */ - rsr = readb(port->uart_base+BL_SICC_LSR); - if (rsr & _LSR_RX_ERR) - goto handle_error; + struct tty_struct *tty = info->tty; + unsigned int status, ch, rsr, flg, ignored = 0; + struct SICC_icount *icount = &info->state->icount; + struct SICC_port *port = info->port; + + status = readb(port->uart_base + BL_SICC_LSR); + while (status & _LSR_RBR_FULL) { + ch = readb(port->uart_base + BL_SICC_RBR); + + if (tty->flip.count >= TTY_FLIPBUF_SIZE) + goto ignore_char; + icount->rx++; + + flg = TTY_NORMAL; + + /* + * Note that the error handling code is + * out of the main execution path + */ + rsr = readb(port->uart_base + BL_SICC_LSR); + if (rsr & _LSR_RX_ERR) + goto handle_error; #ifdef SUPPORT_SYSRQ - if (info->sysrq) { - if (ch && time_before(jiffies, info->sysrq)) { - handle_sysrq(ch, regs, NULL); - info->sysrq = 0; - goto ignore_char; - } - info->sysrq = 0; - } + if (info->sysrq) { + if (ch && time_before(jiffies, info->sysrq)) { + handle_sysrq(ch, regs, NULL); + info->sysrq = 0; + goto ignore_char; + } + info->sysrq = 0; + } #endif - error_return: - *tty->flip.flag_buf_ptr++ = flg; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - ignore_char: - status = readb(port->uart_base+BL_SICC_LSR ); - } -out: - tty_flip_buffer_push(tty); - return; - -handle_error: - if (rsr & _LSR_LB_BREAK) { - rsr &= ~(_LSR_FE_MASK | _LSR_PE_MASK); - icount->brk++; + error_return: + *tty->flip.flag_buf_ptr++ = flg; + *tty->flip.char_buf_ptr++ = ch; + tty->flip.count++; + ignore_char: + status = readb(port->uart_base + BL_SICC_LSR); + } + out: + tty_flip_buffer_push(tty); + return; + + handle_error: + if (rsr & _LSR_LB_BREAK) { + rsr &= ~(_LSR_FE_MASK | _LSR_PE_MASK); + icount->brk++; #ifdef SUPPORT_SYSRQ - if (info->state->line == siccuart_cons.index) { - if (!info->sysrq) { - info->sysrq = jiffies + HZ*5; - goto ignore_char; - } - } + if (info->state->line == siccuart_cons.index) { + if (!info->sysrq) { + info->sysrq = jiffies + HZ * 5; + goto ignore_char; + } + } #endif - } else if (rsr & _LSR_PE_MASK) - icount->parity++; - else if (rsr & _LSR_FE_MASK) - icount->frame++; - if (rsr & _LSR_OE_MASK) - icount->overrun++; - - if (rsr & info->ignore_status_mask) { - if (++ignored > 100) - goto out; - goto ignore_char; - } - rsr &= info->read_status_mask; - - if (rsr & _LSR_LB_BREAK) - flg = TTY_BREAK; - else if (rsr & _LSR_PE_MASK) - flg = TTY_PARITY; - else if (rsr & _LSR_FE_MASK) - flg = TTY_FRAME; - - if (rsr & _LSR_OE_MASK) { - /* - * CHECK: does overrun affect the current character? - * ASSUMPTION: it does not. - */ - *tty->flip.flag_buf_ptr++ = flg; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - goto ignore_char; - ch = 0; - flg = TTY_OVERRUN; - } + } else if (rsr & _LSR_PE_MASK) + icount->parity++; + else if (rsr & _LSR_FE_MASK) + icount->frame++; + if (rsr & _LSR_OE_MASK) + icount->overrun++; + + if (rsr & info->ignore_status_mask) { + if (++ignored > 100) + goto out; + goto ignore_char; + } + rsr &= info->read_status_mask; + + if (rsr & _LSR_LB_BREAK) + flg = TTY_BREAK; + else if (rsr & _LSR_PE_MASK) + flg = TTY_PARITY; + else if (rsr & _LSR_FE_MASK) + flg = TTY_FRAME; + + if (rsr & _LSR_OE_MASK) { + /* + * CHECK: does overrun affect the current character? + * ASSUMPTION: it does not. + */ + *tty->flip.flag_buf_ptr++ = flg; + *tty->flip.char_buf_ptr++ = ch; + tty->flip.count++; + if (tty->flip.count >= TTY_FLIPBUF_SIZE) + goto ignore_char; + ch = 0; + flg = TTY_OVERRUN; + } #ifdef SUPPORT_SYSRQ - info->sysrq = 0; + info->sysrq = 0; #endif - goto error_return; + goto error_return; } static void siccuart_tx_chars(struct SICC_info *info) { - struct SICC_port *port = info->port; - int count; - unsigned char status; - - - if (info->x_char) { - writeb(info->x_char, port->uart_base+ BL_SICC_TBR); - info->state->icount.tx++; - info->x_char = 0; - return; - } - if (info->xmit.head == info->xmit.tail - || info->tty->stopped - || info->tty->hw_stopped) { - siccuart_disable_tx_interrupt(info); - writeb(status&(~_LSR_RBR_MASK),port->uart_base+BL_SICC_LSR); - return; - } - - count = port->fifosize; - do { - writeb(info->xmit.buf[info->xmit.tail], port->uart_base+ BL_SICC_TBR); - info->xmit.tail = (info->xmit.tail + 1) & (SICC_XMIT_SIZE - 1); - info->state->icount.tx++; - if (info->xmit.head == info->xmit.tail) - break; - } while (--count > 0); - - if (CIRC_CNT(info->xmit.head, - info->xmit.tail, - SICC_XMIT_SIZE) < WAKEUP_CHARS) - siccuart_event(info, EVT_WRITE_WAKEUP); - - if (info->xmit.head == info->xmit.tail) { - siccuart_disable_tx_interrupt(info); - } + struct SICC_port *port = info->port; + int count; + unsigned char status; + + if (info->x_char) { + writeb(info->x_char, port->uart_base + BL_SICC_TBR); + info->state->icount.tx++; + info->x_char = 0; + return; + } + if (info->xmit.head == info->xmit.tail + || info->tty->stopped || info->tty->hw_stopped) { + siccuart_disable_tx_interrupt(info); + writeb(status & (~_LSR_RBR_MASK), + port->uart_base + BL_SICC_LSR); + return; + } + + count = port->fifosize; + do { + writeb(info->xmit.buf[info->xmit.tail], + port->uart_base + BL_SICC_TBR); + info->xmit.tail = (info->xmit.tail + 1) & (SICC_XMIT_SIZE - 1); + info->state->icount.tx++; + if (info->xmit.head == info->xmit.tail) + break; + } while (--count > 0); + + if (CIRC_CNT(info->xmit.head, + info->xmit.tail, SICC_XMIT_SIZE) < WAKEUP_CHARS) + siccuart_event(info, EVT_WRITE_WAKEUP); + + if (info->xmit.head == info->xmit.tail) { + siccuart_disable_tx_interrupt(info); + } } - static irqreturn_t siccuart_int_rx(int irq, void *dev_id, struct pt_regs *regs) { - struct SICC_info *info = dev_id; - siccuart_rx_chars(info, regs); - return IRQ_HANDLED; + struct SICC_info *info = dev_id; + siccuart_rx_chars(info, regs); + return IRQ_HANDLED; } - static irqreturn_t siccuart_int_tx(int irq, void *dev_id, struct pt_regs *regs) { - struct SICC_info *info = dev_id; - siccuart_tx_chars(info); - return IRQ_HANDLED; + struct SICC_info *info = dev_id; + siccuart_tx_chars(info); + return IRQ_HANDLED; } static void siccuart_tasklet_action(unsigned long data) { - struct SICC_info *info = (struct SICC_info *)data; - struct tty_struct *tty; + struct SICC_info *info = (struct SICC_info *)data; + struct tty_struct *tty; - tty = info->tty; - if (!tty || !test_and_clear_bit(EVT_WRITE_WAKEUP, &info->event)) - return; - - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); - wake_up_interruptible(&tty->write_wait); + tty = info->tty; + if (!tty || !test_and_clear_bit(EVT_WRITE_WAKEUP, &info->event)) + return; + + if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + tty->ldisc.write_wakeup) + (tty->ldisc.write_wakeup) (tty); + wake_up_interruptible(&tty->write_wait); } static int siccuart_startup(struct SICC_info *info) { - unsigned long flags; - unsigned long page; - int retval = 0; - - if (info->flags & ASYNC_INITIALIZED) { - return 0; - } - - page = get_zeroed_page(GFP_KERNEL); - if (!page) - return -ENOMEM; - - if (info->port->uart_base == 0) - info->port->uart_base = (int)ioremap(info->port->uart_base_phys, PAGE_SIZE); - if (info->port->uart_base == 0) { - free_page(page); - return -ENOMEM; - } - - /* lock access to info while doing setup */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - - if (info->xmit.buf) - free_page(page); - else - info->xmit.buf = (unsigned char *) page; - - - info->mctrl = 0; - if (info->tty->termios->c_cflag & CBAUD) - info->mctrl = TIOCM_RTS | TIOCM_DTR; - info->port->set_mctrl(info->port, info->mctrl); - - /* - * initialise the old status of the modem signals - */ - info->old_status = 0; // UART_GET_FR(info->port) & AMBA_UARTFR_MODEM_ANY; - - - if (info->tty) - clear_bit(TTY_IO_ERROR, &info->tty->flags); - info->xmit.head = info->xmit.tail = 0; - - /* - * Set up the tty->alt_speed kludge - */ - if (info->tty) { - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) - info->tty->alt_speed = 57600; - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) - info->tty->alt_speed = 115200; - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) - info->tty->alt_speed = 230400; - if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) - info->tty->alt_speed = 460800; - } - - - writeb( 0x00, info->port->uart_base + BL_SICC_IrCR ); // disable IrDA - - - /* - * and set the speed of the serial port - */ - siccuart_change_speed(info, 0); - - // enable rx/tx ports - writeb(_RCR_ER_ENABLE /*| _RCR_PME_HARD*/, info->port->uart_base + BL_SICC_RCR); - writeb(_TxCR_ET_ENABLE , info->port->uart_base + BL_SICC_TxCR); - - readb(info->port->uart_base + BL_SICC_RBR); // clear rx port - - writeb(0xf8, info->port->uart_base + BL_SICC_LSR); /* reset bits 0-4 of LSR */ - - /* - * Finally, enable interrupts - */ - - /* - * Allocate the IRQ - */ - retval = request_irq(info->port->irqrx, siccuart_int_rx, 0, "SICC rx", info); - if (retval) { - if (capable(CAP_SYS_ADMIN)) { - if (info->tty) - set_bit(TTY_IO_ERROR, &info->tty->flags); - retval = 0; - } - goto errout; - } - retval = request_irq(info->port->irqtx, siccuart_int_tx, 0, "SICC tx", info); - if (retval) { - if (capable(CAP_SYS_ADMIN)) { - if (info->tty) - set_bit(TTY_IO_ERROR, &info->tty->flags); - retval = 0; - } - free_irq(info->port->irqrx, info); - goto errout; - } - - siccuart_enable_rx_interrupt(info); - - info->flags |= ASYNC_INITIALIZED; - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - return 0; - - -errout: - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - return retval; + unsigned long flags; + unsigned long page; + int retval = 0; + + if (info->flags & ASYNC_INITIALIZED) { + return 0; + } + + page = get_zeroed_page(GFP_KERNEL); + if (!page) + return -ENOMEM; + + if (info->port->uart_base == 0) + info->port->uart_base = + (int)ioremap(info->port->uart_base_phys, PAGE_SIZE); + if (info->port->uart_base == 0) { + free_page(page); + return -ENOMEM; + } + + /* lock access to info while doing setup */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + + if (info->xmit.buf) + free_page(page); + else + info->xmit.buf = (unsigned char *)page; + + info->mctrl = 0; + if (info->tty->termios->c_cflag & CBAUD) + info->mctrl = TIOCM_RTS | TIOCM_DTR; + info->port->set_mctrl(info->port, info->mctrl); + + /* + * initialise the old status of the modem signals + */ + info->old_status = 0; // UART_GET_FR(info->port) & AMBA_UARTFR_MODEM_ANY; + + if (info->tty) + clear_bit(TTY_IO_ERROR, &info->tty->flags); + info->xmit.head = info->xmit.tail = 0; + + /* + * Set up the tty->alt_speed kludge + */ + if (info->tty) { + if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) + info->tty->alt_speed = 57600; + if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) + info->tty->alt_speed = 115200; + if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) + info->tty->alt_speed = 230400; + if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) + info->tty->alt_speed = 460800; + } + + writeb(0x00, info->port->uart_base + BL_SICC_IrCR); // disable IrDA + + /* + * and set the speed of the serial port + */ + siccuart_change_speed(info, 0); + + // enable rx/tx ports + writeb(_RCR_ER_ENABLE /*| _RCR_PME_HARD */ , + info->port->uart_base + BL_SICC_RCR); + writeb(_TxCR_ET_ENABLE, info->port->uart_base + BL_SICC_TxCR); + + readb(info->port->uart_base + BL_SICC_RBR); // clear rx port + + writeb(0xf8, info->port->uart_base + BL_SICC_LSR); /* reset bits 0-4 of LSR */ + + /* + * Finally, enable interrupts + */ + + /* + * Allocate the IRQ + */ + retval = + request_irq(info->port->irqrx, siccuart_int_rx, 0, "SICC rx", info); + if (retval) { + if (capable(CAP_SYS_ADMIN)) { + if (info->tty) + set_bit(TTY_IO_ERROR, &info->tty->flags); + retval = 0; + } + goto errout; + } + retval = + request_irq(info->port->irqtx, siccuart_int_tx, 0, "SICC tx", info); + if (retval) { + if (capable(CAP_SYS_ADMIN)) { + if (info->tty) + set_bit(TTY_IO_ERROR, &info->tty->flags); + retval = 0; + } + free_irq(info->port->irqrx, info); + goto errout; + } + + siccuart_enable_rx_interrupt(info); + + info->flags |= ASYNC_INITIALIZED; + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + return 0; + + errout: + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + return retval; } /* @@ -705,302 +691,299 @@ errout: */ static void siccuart_shutdown(struct SICC_info *info) { - unsigned long flags; + unsigned long flags; - if (!(info->flags & ASYNC_INITIALIZED)) - return; + if (!(info->flags & ASYNC_INITIALIZED)) + return; - /* lock while shutting down port */ - spin_lock_irqsave(&info->state->sicc_lock,flags); /* Disable interrupts */ + /* lock while shutting down port */ + spin_lock_irqsave(&info->state->sicc_lock, flags); /* Disable interrupts */ - /* - * clear delta_msr_wait queue to avoid mem leaks: we may free the irq - * here so the queue might never be woken up - */ - wake_up_interruptible(&info->delta_msr_wait); - - /* - * disable all interrupts, disable the port - */ - siccuart_disable_rx_interrupt(info); - siccuart_disable_tx_interrupt(info); - - /* - * Free the IRQ - */ - free_irq(info->port->irqtx, info); - free_irq(info->port->irqrx, info); - - if (info->xmit.buf) { - unsigned long pg = (unsigned long) info->xmit.buf; - info->xmit.buf = NULL; - free_page(pg); - } - - - if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) - info->mctrl &= ~(TIOCM_DTR|TIOCM_RTS); - info->port->set_mctrl(info->port, info->mctrl); - - /* kill off our tasklet */ - tasklet_kill(&info->tlet); - if (info->tty) - set_bit(TTY_IO_ERROR, &info->tty->flags); - - info->flags &= ~ASYNC_INITIALIZED; - - spin_unlock_irqrestore(&info->state->sicc_lock,flags); -} - - -static void siccuart_change_speed(struct SICC_info *info, struct termios *old_termios) -{ - unsigned int lcr_h, baud, quot, cflag, old_rcr, old_tcr, bits; - unsigned long flags; - - if (!info->tty || !info->tty->termios) - return; - - cflag = info->tty->termios->c_cflag; - - pr_debug("siccuart_set_cflag(0x%x) called\n", cflag); - /* byte size and parity */ - switch (cflag & CSIZE) { - case CS7: lcr_h = _LCR_PE_DISABLE | _LCR_DB_7_BITS | _LCR_SB_1_BIT; bits = 9; break; - default: lcr_h = _LCR_PE_DISABLE | _LCR_DB_8_BITS | _LCR_SB_1_BIT; bits = 10; break; // CS8 - } - if (cflag & CSTOPB) { - lcr_h |= _LCR_SB_2_BIT; - bits ++; - } - if (cflag & PARENB) { - lcr_h |= _LCR_PE_ENABLE; - bits++; - if (!(cflag & PARODD)) - lcr_h |= _LCR_PTY_ODD; - else - lcr_h |= _LCR_PTY_EVEN; - } - - do { - /* Determine divisor based on baud rate */ - baud = tty_get_baud_rate(info->tty); - if (!baud) - baud = 9600; - - - { - // here is ppc403SetBaud(com_port, baud); - unsigned long divisor, clockSource, temp; - - /* Ensure CICCR[7] is 0 to select Internal Baud Clock */ - powerpcMtcic_cr((unsigned long)(powerpcMfcic_cr() & 0xFEFFFFFF)); - - /* Determine Internal Baud Clock Frequency */ - /* powerpcMfclkgpcr() reads DCR 0x120 - the*/ - /* SCCR (Serial Clock Control Register) on Vesta */ - temp = powerpcMfclkgpcr(); - - if(temp & 0x00000080) { - clockSource = 324000000; - } - else { - clockSource = 216000000; - } - clockSource = clockSource/(unsigned long)((temp&0x00FC0000)>>18); - divisor = clockSource/(16*baud) - 1; - /* divisor has only 12 bits of resolution */ - if(divisor>0x00000FFF){ - divisor=0x00000FFF; - } - - quot = divisor; - } - - if (baud == 38400 && - ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) - quot = info->state->custom_divisor; - - if (!quot && old_termios) { - info->tty->termios->c_cflag &= ~CBAUD; - info->tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD); - old_termios = NULL; - } - } while (quot == 0 && old_termios); - - /* As a last resort, if the quotient is zero, default to 9600 bps */ - if (!quot) - quot = (info->port->uartclk / (16 * 9600)) - 1; - - info->timeout = info->port->fifosize * HZ * bits / baud; - info->timeout += HZ/50; /* Add .02 seconds of slop */ - - if (cflag & CRTSCTS) - info->flags |= ASYNC_CTS_FLOW; - else - info->flags &= ~ASYNC_CTS_FLOW; - if (cflag & CLOCAL) - info->flags &= ~ASYNC_CHECK_CD; - else - info->flags |= ASYNC_CHECK_CD; - - /* - * Set up parity check flag - */ + /* + * clear delta_msr_wait queue to avoid mem leaks: we may free the irq + * here so the queue might never be woken up + */ + wake_up_interruptible(&info->delta_msr_wait); + + /* + * disable all interrupts, disable the port + */ + siccuart_disable_rx_interrupt(info); + siccuart_disable_tx_interrupt(info); + + /* + * Free the IRQ + */ + free_irq(info->port->irqtx, info); + free_irq(info->port->irqrx, info); + + if (info->xmit.buf) { + unsigned long pg = (unsigned long)info->xmit.buf; + info->xmit.buf = NULL; + free_page(pg); + } + + if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) + info->mctrl &= ~(TIOCM_DTR | TIOCM_RTS); + info->port->set_mctrl(info->port, info->mctrl); + + /* kill off our tasklet */ + tasklet_kill(&info->tlet); + if (info->tty) + set_bit(TTY_IO_ERROR, &info->tty->flags); + + info->flags &= ~ASYNC_INITIALIZED; + + spin_unlock_irqrestore(&info->state->sicc_lock, flags); +} + +static void siccuart_change_speed(struct SICC_info *info, + struct termios *old_termios) +{ + unsigned int lcr_h, baud, quot, cflag, old_rcr, old_tcr, bits; + unsigned long flags; + + if (!info->tty || !info->tty->termios) + return; + + cflag = info->tty->termios->c_cflag; + + pr_debug("siccuart_set_cflag(0x%x) called\n", cflag); + /* byte size and parity */ + switch (cflag & CSIZE) { + case CS7: + lcr_h = _LCR_PE_DISABLE | _LCR_DB_7_BITS | _LCR_SB_1_BIT; + bits = 9; + break; + default: + lcr_h = _LCR_PE_DISABLE | _LCR_DB_8_BITS | _LCR_SB_1_BIT; + bits = 10; + break; // CS8 + } + if (cflag & CSTOPB) { + lcr_h |= _LCR_SB_2_BIT; + bits++; + } + if (cflag & PARENB) { + lcr_h |= _LCR_PE_ENABLE; + bits++; + if (!(cflag & PARODD)) + lcr_h |= _LCR_PTY_ODD; + else + lcr_h |= _LCR_PTY_EVEN; + } + + do { + /* Determine divisor based on baud rate */ + baud = tty_get_baud_rate(info->tty); + if (!baud) + baud = 9600; + + { + // here is ppc403SetBaud(com_port, baud); + unsigned long divisor, clockSource, temp; + + /* Ensure CICCR[7] is 0 to select Internal Baud Clock */ + powerpcMtcic_cr((unsigned long)(powerpcMfcic_cr() & + 0xFEFFFFFF)); + + /* Determine Internal Baud Clock Frequency */ + /* powerpcMfclkgpcr() reads DCR 0x120 - the */ + /* SCCR (Serial Clock Control Register) on Vesta */ + temp = powerpcMfclkgpcr(); + + if (temp & 0x00000080) { + clockSource = 324000000; + } else { + clockSource = 216000000; + } + clockSource = + clockSource / + (unsigned long)((temp & 0x00FC0000) >> 18); + divisor = clockSource / (16 * baud) - 1; + /* divisor has only 12 bits of resolution */ + if (divisor > 0x00000FFF) { + divisor = 0x00000FFF; + } + + quot = divisor; + } + + if (baud == 38400 && + ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) + quot = info->state->custom_divisor; + + if (!quot && old_termios) { + info->tty->termios->c_cflag &= ~CBAUD; + info->tty->termios->c_cflag |= + (old_termios->c_cflag & CBAUD); + old_termios = NULL; + } + } while (quot == 0 && old_termios); + + /* As a last resort, if the quotient is zero, default to 9600 bps */ + if (!quot) + quot = (info->port->uartclk / (16 * 9600)) - 1; + + info->timeout = info->port->fifosize * HZ * bits / baud; + info->timeout += HZ / 50; /* Add .02 seconds of slop */ + + if (cflag & CRTSCTS) + info->flags |= ASYNC_CTS_FLOW; + else + info->flags &= ~ASYNC_CTS_FLOW; + if (cflag & CLOCAL) + info->flags &= ~ASYNC_CHECK_CD; + else + info->flags |= ASYNC_CHECK_CD; + + /* + * Set up parity check flag + */ #define RELEVENT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) - info->read_status_mask = _LSR_OE_MASK; - if (I_INPCK(info->tty)) - info->read_status_mask |= _LSR_FE_MASK | _LSR_PE_MASK; - if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) - info->read_status_mask |= _LSR_LB_MASK; - - /* - * Characters to ignore - */ - info->ignore_status_mask = 0; - if (I_IGNPAR(info->tty)) - info->ignore_status_mask |= _LSR_FE_MASK | _LSR_PE_MASK; - if (I_IGNBRK(info->tty)) { - info->ignore_status_mask |= _LSR_LB_MASK; - /* - * If we're ignoring parity and break indicators, - * ignore overruns to (for real raw support). - */ - if (I_IGNPAR(info->tty)) - info->ignore_status_mask |= _LSR_OE_MASK; - } - - /* disable interrupts while reading and clearing registers */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - - old_rcr = readb(info->port->uart_base + BL_SICC_RCR); - old_tcr = readb(info->port->uart_base + BL_SICC_TxCR); - - - writeb(0, info->port->uart_base + BL_SICC_RCR); - writeb(0, info->port->uart_base + BL_SICC_TxCR); - - /*RLBtrace (&ppc403Chan0, 0x2000000c, 0, 0);*/ + info->read_status_mask = _LSR_OE_MASK; + if (I_INPCK(info->tty)) + info->read_status_mask |= _LSR_FE_MASK | _LSR_PE_MASK; + if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) + info->read_status_mask |= _LSR_LB_MASK; + + /* + * Characters to ignore + */ + info->ignore_status_mask = 0; + if (I_IGNPAR(info->tty)) + info->ignore_status_mask |= _LSR_FE_MASK | _LSR_PE_MASK; + if (I_IGNBRK(info->tty)) { + info->ignore_status_mask |= _LSR_LB_MASK; + /* + * If we're ignoring parity and break indicators, + * ignore overruns to (for real raw support). + */ + if (I_IGNPAR(info->tty)) + info->ignore_status_mask |= _LSR_OE_MASK; + } + + /* disable interrupts while reading and clearing registers */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + + old_rcr = readb(info->port->uart_base + BL_SICC_RCR); + old_tcr = readb(info->port->uart_base + BL_SICC_TxCR); + + writeb(0, info->port->uart_base + BL_SICC_RCR); + writeb(0, info->port->uart_base + BL_SICC_TxCR); + + /*RLBtrace (&ppc403Chan0, 0x2000000c, 0, 0); */ + + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + + /* Set baud rate */ + writeb((quot & 0x00000F00) >> 8, info->port->uart_base + BL_SICC_BRDH); + writeb(quot & 0x00000FF, info->port->uart_base + BL_SICC_BRDL); + + /* Set CTL2 reg to use external clock (ExtClk) and enable FIFOs. */ + /* For now, do NOT use FIFOs since 403 UART did not have this */ + /* capability and this driver was inherited from 403UART. */ + writeb(_CTL2_EXTERN, info->port->uart_base + BL_SICC_CTL2); + writeb(lcr_h, info->port->uart_base + BL_SICC_LCR); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - - - /* Set baud rate */ - writeb((quot & 0x00000F00)>>8, info->port->uart_base + BL_SICC_BRDH ); - writeb( quot & 0x00000FF, info->port->uart_base + BL_SICC_BRDL ); - - /* Set CTL2 reg to use external clock (ExtClk) and enable FIFOs. */ - /* For now, do NOT use FIFOs since 403 UART did not have this */ - /* capability and this driver was inherited from 403UART. */ - writeb(_CTL2_EXTERN, info->port->uart_base + BL_SICC_CTL2); - - writeb(lcr_h, info->port->uart_base + BL_SICC_LCR); - - writeb(old_rcr, info->port->uart_base + BL_SICC_RCR); // restore rcr - writeb(old_tcr, info->port->uart_base + BL_SICC_TxCR); // restore txcr + writeb(old_rcr, info->port->uart_base + BL_SICC_RCR); // restore rcr + writeb(old_tcr, info->port->uart_base + BL_SICC_TxCR); // restore txcr } - static void siccuart_put_char(struct tty_struct *tty, u_char ch) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; + struct SICC_info *info = tty->driver_data; + unsigned long flags; - if (!tty || !info->xmit.buf) - return; + if (!tty || !info->xmit.buf) + return; - /* lock info->xmit while adding character to tx buffer */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE) != 0) { - info->xmit.buf[info->xmit.head] = ch; - info->xmit.head = (info->xmit.head + 1) & (SICC_XMIT_SIZE - 1); - } - spin_unlock_irqrestore(&info->state->sicc_lock,flags); + /* lock info->xmit while adding character to tx buffer */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE) != 0) { + info->xmit.buf[info->xmit.head] = ch; + info->xmit.head = (info->xmit.head + 1) & (SICC_XMIT_SIZE - 1); + } + spin_unlock_irqrestore(&info->state->sicc_lock, flags); } static void siccuart_flush_chars(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; + struct SICC_info *info = tty->driver_data; + unsigned long flags; - if (info->xmit.head == info->xmit.tail - || tty->stopped - || tty->hw_stopped - || !info->xmit.buf) - return; - - /* disable interrupts while transmitting characters */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - siccuart_enable_tx_interrupt(info); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); -} - -static int siccuart_write(struct tty_struct *tty, - const u_char * buf, int count) -{ - struct SICC_info *info = tty->driver_data; - unsigned long flags; - int c, ret = 0; - - if (!tty || !info->xmit.buf || !tmp_buf) - return 0; - - /* lock info->xmit while removing characters from buffer */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - while (1) { - c = CIRC_SPACE_TO_END(info->xmit.head, - info->xmit.tail, - SICC_XMIT_SIZE); - if (count < c) - c = count; - if (c <= 0) - break; - memcpy(info->xmit.buf + info->xmit.head, buf, c); - info->xmit.head = (info->xmit.head + c) & - (SICC_XMIT_SIZE - 1); - buf += c; - count -= c; - ret += c; - } - if (info->xmit.head != info->xmit.tail - && !tty->stopped - && !tty->hw_stopped) - siccuart_enable_tx_interrupt(info); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - return ret; + if (info->xmit.head == info->xmit.tail + || tty->stopped || tty->hw_stopped || !info->xmit.buf) + return; + + /* disable interrupts while transmitting characters */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + siccuart_enable_tx_interrupt(info); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); +} + +static int siccuart_write(struct tty_struct *tty, const u_char * buf, int count) +{ + struct SICC_info *info = tty->driver_data; + unsigned long flags; + int c, ret = 0; + + if (!tty || !info->xmit.buf || !tmp_buf) + return 0; + + /* lock info->xmit while removing characters from buffer */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + while (1) { + c = CIRC_SPACE_TO_END(info->xmit.head, + info->xmit.tail, SICC_XMIT_SIZE); + if (count < c) + c = count; + if (c <= 0) + break; + memcpy(info->xmit.buf + info->xmit.head, buf, c); + info->xmit.head = (info->xmit.head + c) & (SICC_XMIT_SIZE - 1); + buf += c; + count -= c; + ret += c; + } + if (info->xmit.head != info->xmit.tail + && !tty->stopped && !tty->hw_stopped) + siccuart_enable_tx_interrupt(info); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + return ret; } static int siccuart_write_room(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; + struct SICC_info *info = tty->driver_data; - return CIRC_SPACE(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE); + return CIRC_SPACE(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE); } static int siccuart_chars_in_buffer(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; + struct SICC_info *info = tty->driver_data; - return CIRC_CNT(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE); + return CIRC_CNT(info->xmit.head, info->xmit.tail, SICC_XMIT_SIZE); } static void siccuart_flush_buffer(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; + struct SICC_info *info = tty->driver_data; + unsigned long flags; - pr_debug("siccuart_flush_buffer(%d) called\n", tty->index); - /* lock info->xmit while zeroing buffer counts */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - info->xmit.head = info->xmit.tail = 0; - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - wake_up_interruptible(&tty->write_wait); - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); + pr_debug("siccuart_flush_buffer(%d) called\n", tty->index); + /* lock info->xmit while zeroing buffer counts */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + info->xmit.head = info->xmit.tail = 0; + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + wake_up_interruptible(&tty->write_wait); + if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + tty->ldisc.write_wakeup) + (tty->ldisc.write_wakeup) (tty); } /* @@ -1009,716 +992,711 @@ static void siccuart_flush_buffer(struct */ static void siccuart_send_xchar(struct tty_struct *tty, char ch) { - struct SICC_info *info = tty->driver_data; + struct SICC_info *info = tty->driver_data; - info->x_char = ch; - if (ch) - siccuart_enable_tx_interrupt(info); + info->x_char = ch; + if (ch) + siccuart_enable_tx_interrupt(info); } static void siccuart_throttle(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; + struct SICC_info *info = tty->driver_data; + unsigned long flags; - if (I_IXOFF(tty)) - siccuart_send_xchar(tty, STOP_CHAR(tty)); + if (I_IXOFF(tty)) + siccuart_send_xchar(tty, STOP_CHAR(tty)); - if (tty->termios->c_cflag & CRTSCTS) { - /* disable interrupts while setting modem control lines */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - info->mctrl &= ~TIOCM_RTS; - info->port->set_mctrl(info->port, info->mctrl); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - } + if (tty->termios->c_cflag & CRTSCTS) { + /* disable interrupts while setting modem control lines */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + info->mctrl &= ~TIOCM_RTS; + info->port->set_mctrl(info->port, info->mctrl); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + } } static void siccuart_unthrottle(struct tty_struct *tty) { - struct SICC_info *info = (struct SICC_info *) tty->driver_data; - unsigned long flags; + struct SICC_info *info = (struct SICC_info *)tty->driver_data; + unsigned long flags; - if (I_IXOFF(tty)) { - if (info->x_char) - info->x_char = 0; - else - siccuart_send_xchar(tty, START_CHAR(tty)); - } - - if (tty->termios->c_cflag & CRTSCTS) { - /* disable interrupts while setting modem control lines */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - info->mctrl |= TIOCM_RTS; - info->port->set_mctrl(info->port, info->mctrl); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - } -} - -static int get_serial_info(struct SICC_info *info, struct serial_struct *retinfo) -{ - struct SICC_state *state = info->state; - struct SICC_port *port = info->port; - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); - tmp.type = 0; - tmp.line = state->line; - tmp.port = port->uart_base; - if (HIGH_BITS_OFFSET) - tmp.port_high = port->uart_base >> HIGH_BITS_OFFSET; - tmp.irq = port->irqrx; - tmp.flags = 0; - tmp.xmit_fifo_size = port->fifosize; - tmp.baud_base = port->uartclk / 16; - tmp.close_delay = state->close_delay; - tmp.closing_wait = state->closing_wait; - tmp.custom_divisor = state->custom_divisor; - - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; - return 0; + if (I_IXOFF(tty)) { + if (info->x_char) + info->x_char = 0; + else + siccuart_send_xchar(tty, START_CHAR(tty)); + } + + if (tty->termios->c_cflag & CRTSCTS) { + /* disable interrupts while setting modem control lines */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + info->mctrl |= TIOCM_RTS; + info->port->set_mctrl(info->port, info->mctrl); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + } +} + +static int get_serial_info(struct SICC_info *info, + struct serial_struct *retinfo) +{ + struct SICC_state *state = info->state; + struct SICC_port *port = info->port; + struct serial_struct tmp; + + memset(&tmp, 0, sizeof(tmp)); + tmp.type = 0; + tmp.line = state->line; + tmp.port = port->uart_base; + if (HIGH_BITS_OFFSET) + tmp.port_high = port->uart_base >> HIGH_BITS_OFFSET; + tmp.irq = port->irqrx; + tmp.flags = 0; + tmp.xmit_fifo_size = port->fifosize; + tmp.baud_base = port->uartclk / 16; + tmp.close_delay = state->close_delay; + tmp.closing_wait = state->closing_wait; + tmp.custom_divisor = state->custom_divisor; + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return -EFAULT; + return 0; } static int set_serial_info(struct SICC_info *info, - struct serial_struct *newinfo) + struct serial_struct *newinfo) { - struct serial_struct new_serial; - struct SICC_state *state, old_state; - struct SICC_port *port; - unsigned long new_port; - unsigned int i, change_irq, change_port; - int retval = 0; - - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) - return -EFAULT; - - state = info->state; - old_state = *state; - port = info->port; - - new_port = new_serial.port; - if (HIGH_BITS_OFFSET) - new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET; - - change_irq = new_serial.irq != port->irqrx; - change_port = new_port != port->uart_base; - - if (!capable(CAP_SYS_ADMIN)) { - if (change_irq || change_port || - (new_serial.baud_base != port->uartclk / 16) || - (new_serial.close_delay != state->close_delay) || - (new_serial.xmit_fifo_size != port->fifosize) || - ((new_serial.flags & ~ASYNC_USR_MASK) != - (state->flags & ~ASYNC_USR_MASK))) - return -EPERM; - state->flags = ((state->flags & ~ASYNC_USR_MASK) | - (new_serial.flags & ASYNC_USR_MASK)); - info->flags = ((info->flags & ~ASYNC_USR_MASK) | - (new_serial.flags & ASYNC_USR_MASK)); - state->custom_divisor = new_serial.custom_divisor; - goto check_and_exit; - } - - if ((new_serial.irq >= NR_IRQS) || (new_serial.irq < 0) || - (new_serial.baud_base < 9600)) - return -EINVAL; - - if (new_serial.type && change_port) { - for (i = 0; i < SERIAL_SICC_NR; i++) - if ((port != sicc_ports + i) && - sicc_ports[i].uart_base != new_port) - return -EADDRINUSE; - } - - if ((change_port || change_irq) && (state->count > 1)) - return -EBUSY; - - /* - * OK, past this point, all the error checking has been done. - * At this point, we start making changes..... - */ - port->uartclk = new_serial.baud_base * 16; - state->flags = ((state->flags & ~ASYNC_FLAGS) | - (new_serial.flags & ASYNC_FLAGS)); - info->flags = ((state->flags & ~ASYNC_INTERNAL_FLAGS) | - (info->flags & ASYNC_INTERNAL_FLAGS)); - state->custom_divisor = new_serial.custom_divisor; - state->close_delay = msecs_to_jiffies(10 * new_serial.close_delay); - state->closing_wait = msecs_to_jiffies(10 * new_serial.closing_wait); - info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; - port->fifosize = new_serial.xmit_fifo_size; - - if (change_port || change_irq) { - /* - * We need to shutdown the serial port at the old - * port/irq combination. - */ - siccuart_shutdown(info); - port->irqrx = new_serial.irq; - port->uart_base = new_port; - } - -check_and_exit: - if (!port->uart_base) - return 0; - if (info->flags & ASYNC_INITIALIZED) { - if ((old_state.flags & ASYNC_SPD_MASK) != - (state->flags & ASYNC_SPD_MASK) || - (old_state.custom_divisor != state->custom_divisor)) { - if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) - info->tty->alt_speed = 57600; - if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) - info->tty->alt_speed = 115200; - if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) - info->tty->alt_speed = 230400; - if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) - info->tty->alt_speed = 460800; - siccuart_change_speed(info, NULL); - } - } else - retval = siccuart_startup(info); - return retval; + struct serial_struct new_serial; + struct SICC_state *state, old_state; + struct SICC_port *port; + unsigned long new_port; + unsigned int i, change_irq, change_port; + int retval = 0; + + if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) + return -EFAULT; + + state = info->state; + old_state = *state; + port = info->port; + + new_port = new_serial.port; + if (HIGH_BITS_OFFSET) + new_port += + (unsigned long)new_serial.port_high << HIGH_BITS_OFFSET; + + change_irq = new_serial.irq != port->irqrx; + change_port = new_port != port->uart_base; + + if (!capable(CAP_SYS_ADMIN)) { + if (change_irq || change_port || + (new_serial.baud_base != port->uartclk / 16) || + (new_serial.close_delay != state->close_delay) || + (new_serial.xmit_fifo_size != port->fifosize) || + ((new_serial.flags & ~ASYNC_USR_MASK) != + (state->flags & ~ASYNC_USR_MASK))) + return -EPERM; + state->flags = ((state->flags & ~ASYNC_USR_MASK) | + (new_serial.flags & ASYNC_USR_MASK)); + info->flags = ((info->flags & ~ASYNC_USR_MASK) | + (new_serial.flags & ASYNC_USR_MASK)); + state->custom_divisor = new_serial.custom_divisor; + goto check_and_exit; + } + + if ((new_serial.irq >= NR_IRQS) || (new_serial.irq < 0) || + (new_serial.baud_base < 9600)) + return -EINVAL; + + if (new_serial.type && change_port) { + for (i = 0; i < SERIAL_SICC_NR; i++) + if ((port != sicc_ports + i) && + sicc_ports[i].uart_base != new_port) + return -EADDRINUSE; + } + + if ((change_port || change_irq) && (state->count > 1)) + return -EBUSY; + + /* + * OK, past this point, all the error checking has been done. + * At this point, we start making changes..... + */ + port->uartclk = new_serial.baud_base * 16; + state->flags = ((state->flags & ~ASYNC_FLAGS) | + (new_serial.flags & ASYNC_FLAGS)); + info->flags = ((state->flags & ~ASYNC_INTERNAL_FLAGS) | + (info->flags & ASYNC_INTERNAL_FLAGS)); + state->custom_divisor = new_serial.custom_divisor; + state->close_delay = msecs_to_jiffies(10 * new_serial.close_delay); + state->closing_wait = msecs_to_jiffies(10 * new_serial.closing_wait); + info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + port->fifosize = new_serial.xmit_fifo_size; + + if (change_port || change_irq) { + /* + * We need to shutdown the serial port at the old + * port/irq combination. + */ + siccuart_shutdown(info); + port->irqrx = new_serial.irq; + port->uart_base = new_port; + } + + check_and_exit: + if (!port->uart_base) + return 0; + if (info->flags & ASYNC_INITIALIZED) { + if ((old_state.flags & ASYNC_SPD_MASK) != + (state->flags & ASYNC_SPD_MASK) || + (old_state.custom_divisor != state->custom_divisor)) { + if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) + info->tty->alt_speed = 57600; + if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) + info->tty->alt_speed = 115200; + if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) + info->tty->alt_speed = 230400; + if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) + info->tty->alt_speed = 460800; + siccuart_change_speed(info, NULL); + } + } else + retval = siccuart_startup(info); + return retval; } - /* * get_lsr_info - get line status register info */ static int get_lsr_info(struct SICC_info *info, unsigned int *value) { - unsigned int result, status; - unsigned long flags; + unsigned int result, status; + unsigned long flags; - /* disable interrupts while reading status from port */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - status = readb(info->port->uart_base + BL_SICC_LSR); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - result = status & _LSR_TSR_EMPTY ? TIOCSER_TEMT : 0; - - /* - * If we're about to load something into the transmit - * register, we'll pretend the transmitter isn't empty to - * avoid a race condition (depending on when the transmit - * interrupt happens). - */ - if (info->x_char || - ((CIRC_CNT(info->xmit.head, info->xmit.tail, - SICC_XMIT_SIZE) > 0) && - !info->tty->stopped && !info->tty->hw_stopped)) - result &= TIOCSER_TEMT; + /* disable interrupts while reading status from port */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + status = readb(info->port->uart_base + BL_SICC_LSR); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + result = status & _LSR_TSR_EMPTY ? TIOCSER_TEMT : 0; + + /* + * If we're about to load something into the transmit + * register, we'll pretend the transmitter isn't empty to + * avoid a race condition (depending on when the transmit + * interrupt happens). + */ + if (info->x_char || + ((CIRC_CNT(info->xmit.head, info->xmit.tail, + SICC_XMIT_SIZE) > 0) && + !info->tty->stopped && !info->tty->hw_stopped)) + result &= TIOCSER_TEMT; - return put_user(result, value); + return put_user(result, value); } static int get_modem_info(struct SICC_info *info, unsigned int *value) { - unsigned int result = info->mctrl; + unsigned int result = info->mctrl; - return put_user(result, value); + return put_user(result, value); } static int set_modem_info(struct SICC_info *info, unsigned int cmd, - unsigned int *value) + unsigned int *value) { - unsigned int arg, old; - unsigned long flags; + unsigned int arg, old; + unsigned long flags; - if (get_user(arg, value)) - return -EFAULT; + if (get_user(arg, value)) + return -EFAULT; - old = info->mctrl; - switch (cmd) { - case TIOCMBIS: - info->mctrl |= arg; - break; - - case TIOCMBIC: - info->mctrl &= ~arg; - break; - - case TIOCMSET: - info->mctrl = arg; - break; - - default: - return -EINVAL; - } - /* disable interrupts while setting modem control lines */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - if (old != info->mctrl) - info->port->set_mctrl(info->port, info->mctrl); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - return 0; + old = info->mctrl; + switch (cmd) { + case TIOCMBIS: + info->mctrl |= arg; + break; + + case TIOCMBIC: + info->mctrl &= ~arg; + break; + + case TIOCMSET: + info->mctrl = arg; + break; + + default: + return -EINVAL; + } + /* disable interrupts while setting modem control lines */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + if (old != info->mctrl) + info->port->set_mctrl(info->port, info->mctrl); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + return 0; } static void siccuart_break_ctl(struct tty_struct *tty, int break_state) { - struct SICC_info *info = tty->driver_data; - unsigned long flags; - unsigned int lcr_h; - - - /* disable interrupts while setting break state */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - lcr_h = readb(info->port + BL_SICC_LSR); - if (break_state == -1) - lcr_h |= _LSR_LB_MASK; - else - lcr_h &= ~_LSR_LB_MASK; - writeb(lcr_h, info->port + BL_SICC_LSRS); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); + struct SICC_info *info = tty->driver_data; + unsigned long flags; + unsigned int lcr_h; + + /* disable interrupts while setting break state */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + lcr_h = readb(info->port + BL_SICC_LSR); + if (break_state == -1) + lcr_h |= _LSR_LB_MASK; + else + lcr_h &= ~_LSR_LB_MASK; + writeb(lcr_h, info->port + BL_SICC_LSRS); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); } static int siccuart_ioctl(struct tty_struct *tty, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { - struct SICC_info *info = tty->driver_data; - struct SICC_icount cnow; - struct serial_icounter_struct icount; - unsigned long flags; - - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && - (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && - (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { - if (tty->flags & (1 << TTY_IO_ERROR)) - return -EIO; - } - - switch (cmd) { - case TIOCMGET: - return get_modem_info(info, (unsigned int *)arg); - case TIOCMBIS: - case TIOCMBIC: - case TIOCMSET: - return set_modem_info(info, cmd, (unsigned int *)arg); - case TIOCGSERIAL: - return get_serial_info(info, - (struct serial_struct *)arg); - case TIOCSSERIAL: - return set_serial_info(info, - (struct serial_struct *)arg); - case TIOCSERGETLSR: /* Get line status register */ - return get_lsr_info(info, (unsigned int *)arg); - /* - * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change - * - mask passed in arg for lines of interest - * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) - * Caller should use TIOCGICOUNT to see which one it was - */ - case TIOCMIWAIT: - return 0; - /* - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) - * Return: write counters to the user passed counter struct - * NB: both 1->0 and 0->1 transitions are counted except for - * RI where only 0->1 is counted. - */ - case TIOCGICOUNT: - /* disable interrupts while getting interrupt count */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - cnow = info->state->icount; - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - icount.cts = cnow.cts; - icount.dsr = cnow.dsr; - icount.rng = cnow.rng; - icount.dcd = cnow.dcd; - icount.rx = cnow.rx; - icount.tx = cnow.tx; - icount.frame = cnow.frame; - icount.overrun = cnow.overrun; - icount.parity = cnow.parity; - icount.brk = cnow.brk; - icount.buf_overrun = cnow.buf_overrun; - - return copy_to_user((void *)arg, &icount, sizeof(icount)) - ? -EFAULT : 0; - - default: - return -ENOIOCTLCMD; - } - return 0; -} - -static void siccuart_set_termios(struct tty_struct *tty, struct termios *old_termios) -{ - struct SICC_info *info = tty->driver_data; - unsigned long flags; - unsigned int cflag = tty->termios->c_cflag; - - if ((cflag ^ old_termios->c_cflag) == 0 && - RELEVENT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) - return; - - siccuart_change_speed(info, old_termios); - - /* Handle transition to B0 status */ - if ((old_termios->c_cflag & CBAUD) && - !(cflag & CBAUD)) { - /* disable interrupts while setting break state */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - info->mctrl &= ~(TIOCM_RTS | TIOCM_DTR); - info->port->set_mctrl(info->port, info->mctrl); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - } - - /* Handle transition away from B0 status */ - if (!(old_termios->c_cflag & CBAUD) && - (cflag & CBAUD)) { - /* disable interrupts while setting break state */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - info->mctrl |= TIOCM_DTR; - if (!(cflag & CRTSCTS) || - !test_bit(TTY_THROTTLED, &tty->flags)) - info->mctrl |= TIOCM_RTS; - info->port->set_mctrl(info->port, info->mctrl); - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - } - - /* Handle turning off CRTSCTS */ - if ((old_termios->c_cflag & CRTSCTS) && - !(cflag & CRTSCTS)) { - tty->hw_stopped = 0; - siccuart_start(tty); - } - + struct SICC_info *info = tty->driver_data; + struct SICC_icount cnow; + struct serial_icounter_struct icount; + unsigned long flags; + + if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && + (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && + (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { + if (tty->flags & (1 << TTY_IO_ERROR)) + return -EIO; + } + + switch (cmd) { + case TIOCMGET: + return get_modem_info(info, (unsigned int *)arg); + case TIOCMBIS: + case TIOCMBIC: + case TIOCMSET: + return set_modem_info(info, cmd, (unsigned int *)arg); + case TIOCGSERIAL: + return get_serial_info(info, (struct serial_struct *)arg); + case TIOCSSERIAL: + return set_serial_info(info, (struct serial_struct *)arg); + case TIOCSERGETLSR: /* Get line status register */ + return get_lsr_info(info, (unsigned int *)arg); + /* + * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change + * - mask passed in arg for lines of interest + * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) + * Caller should use TIOCGICOUNT to see which one it was + */ + case TIOCMIWAIT: + return 0; + /* + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) + * Return: write counters to the user passed counter struct + * NB: both 1->0 and 0->1 transitions are counted except for + * RI where only 0->1 is counted. + */ + case TIOCGICOUNT: + /* disable interrupts while getting interrupt count */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + cnow = info->state->icount; + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + icount.cts = cnow.cts; + icount.dsr = cnow.dsr; + icount.rng = cnow.rng; + icount.dcd = cnow.dcd; + icount.rx = cnow.rx; + icount.tx = cnow.tx; + icount.frame = cnow.frame; + icount.overrun = cnow.overrun; + icount.parity = cnow.parity; + icount.brk = cnow.brk; + icount.buf_overrun = cnow.buf_overrun; + + return copy_to_user((void *)arg, &icount, sizeof(icount)) + ? -EFAULT : 0; + + default: + return -ENOIOCTLCMD; + } + return 0; +} + +static void siccuart_set_termios(struct tty_struct *tty, + struct termios *old_termios) +{ + struct SICC_info *info = tty->driver_data; + unsigned long flags; + unsigned int cflag = tty->termios->c_cflag; + + if ((cflag ^ old_termios->c_cflag) == 0 && + RELEVENT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) + return; + + siccuart_change_speed(info, old_termios); + + /* Handle transition to B0 status */ + if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD)) { + /* disable interrupts while setting break state */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + info->mctrl &= ~(TIOCM_RTS | TIOCM_DTR); + info->port->set_mctrl(info->port, info->mctrl); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + } + + /* Handle transition away from B0 status */ + if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) { + /* disable interrupts while setting break state */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + info->mctrl |= TIOCM_DTR; + if (!(cflag & CRTSCTS) || !test_bit(TTY_THROTTLED, &tty->flags)) + info->mctrl |= TIOCM_RTS; + info->port->set_mctrl(info->port, info->mctrl); + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + } + + /* Handle turning off CRTSCTS */ + if ((old_termios->c_cflag & CRTSCTS) && !(cflag & CRTSCTS)) { + tty->hw_stopped = 0; + siccuart_start(tty); + } #if 0 - /* - * No need to wake up processes in open wait, since they - * sample the CLOCAL flag once, and don't recheck it. - * XXX It's not clear whether the current behavior is correct - * or not. Hence, this may change..... - */ - if (!(old_termios->c_cflag & CLOCAL) && - (tty->termios->c_cflag & CLOCAL)) - wake_up_interruptible(&info->open_wait); + /* + * No need to wake up processes in open wait, since they + * sample the CLOCAL flag once, and don't recheck it. + * XXX It's not clear whether the current behavior is correct + * or not. Hence, this may change..... + */ + if (!(old_termios->c_cflag & CLOCAL) && + (tty->termios->c_cflag & CLOCAL)) + wake_up_interruptible(&info->open_wait); #endif } static void siccuart_close(struct tty_struct *tty, struct file *filp) { - struct SICC_info *info = tty->driver_data; - struct SICC_state *state; - unsigned long flags; - - if (!info) - return; - - state = info->state; - - //pr_debug("siccuart_close() called\n"); - - /* lock tty->driver_data while closing port */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - - if (tty_hung_up_p(filp)) { - goto quick_close; - } - - if ((tty->count == 1) && (state->count != 1)) { - /* - * Uh, oh. tty->count is 1, which means that the tty - * structure will be freed. state->count should always - * be one in these conditions. If it's greater than - * one, we've got real problems, since it means the - * serial port won't be shutdown. - */ - printk("siccuart_close: bad serial port count; tty->count is 1, state->count is %d\n", state->count); - state->count = 1; - } - if (--state->count < 0) { - printk("rs_close: bad serial port count for %s: %d\n", tty->name, state->count); - state->count = 0; - } - if (state->count) { - goto quick_close; - } - info->flags |= ASYNC_CLOSING; - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - /* - * Now we wait for the transmit buffer to clear; and we notify - * the line discipline to only process XON/XOFF characters. - */ - tty->closing = 1; - if (info->state->closing_wait != ASYNC_CLOSING_WAIT_NONE) - tty_wait_until_sent(tty, info->state->closing_wait); - /* - * At this point, we stop accepting input. To do this, we - * disable the receive line status interrupts. - */ - if (info->flags & ASYNC_INITIALIZED) { - siccuart_disable_rx_interrupt(info); - /* - * Before we drop DTR, make sure the UART transmitter - * has completely drained; this is especially - * important if there is a transmit FIFO! - */ - siccuart_wait_until_sent(tty, info->timeout); - } - siccuart_shutdown(info); - if (tty->driver->flush_buffer) - tty->driver->flush_buffer(tty); - if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer(tty); - tty->closing = 0; - info->event = 0; - info->tty = NULL; - if (info->blocked_open) { - if (info->state->close_delay) - schedule_timeout_interruptible(info->state->close_delay); - wake_up_interruptible(&info->open_wait); - } - info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); - wake_up_interruptible(&info->close_wait); - return; - -quick_close: - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - return; + struct SICC_info *info = tty->driver_data; + struct SICC_state *state; + unsigned long flags; + + if (!info) + return; + + state = info->state; + + //pr_debug("siccuart_close() called\n"); + + /* lock tty->driver_data while closing port */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + + if (tty_hung_up_p(filp)) { + goto quick_close; + } + + if ((tty->count == 1) && (state->count != 1)) { + /* + * Uh, oh. tty->count is 1, which means that the tty + * structure will be freed. state->count should always + * be one in these conditions. If it's greater than + * one, we've got real problems, since it means the + * serial port won't be shutdown. + */ + printk + ("siccuart_close: bad serial port count; tty->count is 1, state->count is %d\n", + state->count); + state->count = 1; + } + if (--state->count < 0) { + printk("rs_close: bad serial port count for %s: %d\n", + tty->name, state->count); + state->count = 0; + } + if (state->count) { + goto quick_close; + } + info->flags |= ASYNC_CLOSING; + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + /* + * Now we wait for the transmit buffer to clear; and we notify + * the line discipline to only process XON/XOFF characters. + */ + tty->closing = 1; + if (info->state->closing_wait != ASYNC_CLOSING_WAIT_NONE) + tty_wait_until_sent(tty, info->state->closing_wait); + /* + * At this point, we stop accepting input. To do this, we + * disable the receive line status interrupts. + */ + if (info->flags & ASYNC_INITIALIZED) { + siccuart_disable_rx_interrupt(info); + /* + * Before we drop DTR, make sure the UART transmitter + * has completely drained; this is especially + * important if there is a transmit FIFO! + */ + siccuart_wait_until_sent(tty, info->timeout); + } + siccuart_shutdown(info); + if (tty->driver->flush_buffer) + tty->driver->flush_buffer(tty); + if (tty->ldisc.flush_buffer) + tty->ldisc.flush_buffer(tty); + tty->closing = 0; + info->event = 0; + info->tty = NULL; + if (info->blocked_open) { + if (info->state->close_delay) + schedule_timeout_interruptible(info->state-> + close_delay); + wake_up_interruptible(&info->open_wait); + } + info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); + wake_up_interruptible(&info->close_wait); + return; + + quick_close: + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + return; } static void siccuart_wait_until_sent(struct tty_struct *tty, int timeout) { - struct SICC_info *info = (struct SICC_info *) tty->driver_data; - unsigned long char_time, expire; + struct SICC_info *info = (struct SICC_info *)tty->driver_data; + unsigned long char_time, expire; - if (info->port->fifosize == 0) - return; + if (info->port->fifosize == 0) + return; - /* - * Set the check interval to be 1/5 of the estimated time to - * send a single character, and make it at least 1. The check - * interval should also be less than the timeout. - * - * Note: we have to use pretty tight timings here to satisfy - * the NIST-PCTS. - */ - char_time = (info->timeout - msecs_to_jiffies(20)) / info->port->fifosize; - char_time = char_time / 5; - if (char_time == 0) - char_time = 1; - - // Crazy!! sometimes the input arg 'timeout' can be negtive numbers :-( - if (timeout >= 0 && timeout < char_time) - char_time = timeout; - /* - * If the transmitter hasn't cleared in twice the approximate - * amount of time to send the entire FIFO, it probably won't - * ever clear. This assumes the UART isn't doing flow - * control, which is currently the case. Hence, if it ever - * takes longer than info->timeout, this is probably due to a - * UART bug of some kind. So, we clamp the timeout parameter at - * 2*info->timeout. - */ - if (!timeout || timeout > 2 * info->timeout) - timeout = 2 * info->timeout; - - expire = jiffies + timeout; - pr_debug("siccuart_wait_until_sent(%d), jiff=%lu, expire=%lu char_time=%lu...\n", - tty->index, jiffies, - expire, char_time); - while ((readb(info->port->uart_base + BL_SICC_LSR) & _LSR_TX_ALL) != _LSR_TX_ALL) { - schedule_timeout_interruptible(char_time); - if (signal_pending(current)) - break; - if (timeout && time_after(jiffies, expire)) - break; - } - set_current_state(TASK_RUNNING); + /* + * Set the check interval to be 1/5 of the estimated time to + * send a single character, and make it at least 1. The check + * interval should also be less than the timeout. + * + * Note: we have to use pretty tight timings here to satisfy + * the NIST-PCTS. + */ + char_time = + (info->timeout - msecs_to_jiffies(20)) / info->port->fifosize; + char_time = char_time / 5; + if (char_time == 0) + char_time = 1; + + // Crazy!! sometimes the input arg 'timeout' can be negtive numbers :-( + if (timeout >= 0 && timeout < char_time) + char_time = timeout; + /* + * If the transmitter hasn't cleared in twice the approximate + * amount of time to send the entire FIFO, it probably won't + * ever clear. This assumes the UART isn't doing flow + * control, which is currently the case. Hence, if it ever + * takes longer than info->timeout, this is probably due to a + * UART bug of some kind. So, we clamp the timeout parameter at + * 2*info->timeout. + */ + if (!timeout || timeout > 2 * info->timeout) + timeout = 2 * info->timeout; + + expire = jiffies + timeout; + pr_debug + ("siccuart_wait_until_sent(%d), jiff=%lu, expire=%lu char_time=%lu...\n", + tty->index, jiffies, expire, char_time); + while ((readb(info->port->uart_base + BL_SICC_LSR) & _LSR_TX_ALL) != + _LSR_TX_ALL) { + schedule_timeout_interruptible(char_time); + if (signal_pending(current)) + break; + if (timeout && time_after(jiffies, expire)) + break; + } + set_current_state(TASK_RUNNING); } static void siccuart_hangup(struct tty_struct *tty) { - struct SICC_info *info = tty->driver_data; - struct SICC_state *state = info->state; + struct SICC_info *info = tty->driver_data; + struct SICC_state *state = info->state; - siccuart_flush_buffer(tty); - if (info->flags & ASYNC_CLOSING) - return; - siccuart_shutdown(info); - info->event = 0; - state->count = 0; - info->flags &= ~ASYNC_NORMAL_ACTIVE; - info->tty = NULL; - wake_up_interruptible(&info->open_wait); + siccuart_flush_buffer(tty); + if (info->flags & ASYNC_CLOSING) + return; + siccuart_shutdown(info); + info->event = 0; + state->count = 0; + info->flags &= ~ASYNC_NORMAL_ACTIVE; + info->tty = NULL; + wake_up_interruptible(&info->open_wait); } static int block_til_ready(struct tty_struct *tty, struct file *filp, - struct SICC_info *info) + struct SICC_info *info) { - DECLARE_WAITQUEUE(wait, current); - struct SICC_state *state = info->state; - unsigned long flags; - int do_clocal = 0, extra_count = 0, retval; - - /* - * If the device is in the middle of being closed, then block - * until it's done, and then try again. - */ - if (tty_hung_up_p(filp) || - (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); - return (info->flags & ASYNC_HUP_NOTIFY) ? - -EAGAIN : -ERESTARTSYS; - } - - /* - * If non-blocking mode is set, or the port is not enabled, - * then make the check up front and then exit. - */ - if ((filp->f_flags & O_NONBLOCK) || - (tty->flags & (1 << TTY_IO_ERROR))) { - info->flags |= ASYNC_NORMAL_ACTIVE; - return 0; - } - - if (tty->termios->c_cflag & CLOCAL) - do_clocal = 1; - - /* - * Block waiting for the carrier detect and the line to become - * free (i.e., not in use by the callout). While we are in - * this loop, state->count is dropped by one, so that - * rs_close() knows when to free things. We restore it upon - * exit, either normal or abnormal. - */ - retval = 0; - add_wait_queue(&info->open_wait, &wait); - /* lock while decrementing state->count */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - if (!tty_hung_up_p(filp)) { - extra_count = 1; - state->count--; - } - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - info->blocked_open++; - while (1) { - /* disable interrupts while setting modem control lines */ - spin_lock_irqsave(&info->state->sicc_lock,flags); - if (tty->termios->c_cflag & CBAUD) { - info->mctrl = TIOCM_DTR | TIOCM_RTS; - info->port->set_mctrl(info->port, info->mctrl); - } - spin_unlock_irqrestore(&info->state->sicc_lock,flags); - set_current_state(TASK_INTERRUPTIBLE); - if (tty_hung_up_p(filp) || - !(info->flags & ASYNC_INITIALIZED)) { - if (info->flags & ASYNC_HUP_NOTIFY) - retval = -EAGAIN; - else - retval = -ERESTARTSYS; - break; - } - if (!(info->flags & ASYNC_CLOSING) && - (do_clocal /*|| (UART_GET_FR(info->port) & SICC_UARTFR_DCD)*/)) - break; - if (signal_pending(current)) { - retval = -ERESTARTSYS; - break; - } - schedule(); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&info->open_wait, &wait); - if (extra_count) - state->count++; - info->blocked_open--; - if (retval) - return retval; - info->flags |= ASYNC_NORMAL_ACTIVE; - return 0; + DECLARE_WAITQUEUE(wait, current); + struct SICC_state *state = info->state; + unsigned long flags; + int do_clocal = 0, extra_count = 0, retval; + + /* + * If the device is in the middle of being closed, then block + * until it's done, and then try again. + */ + if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { + if (info->flags & ASYNC_CLOSING) + interruptible_sleep_on(&info->close_wait); + return (info->flags & ASYNC_HUP_NOTIFY) ? + -EAGAIN : -ERESTARTSYS; + } + + /* + * If non-blocking mode is set, or the port is not enabled, + * then make the check up front and then exit. + */ + if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { + info->flags |= ASYNC_NORMAL_ACTIVE; + return 0; + } + + if (tty->termios->c_cflag & CLOCAL) + do_clocal = 1; + + /* + * Block waiting for the carrier detect and the line to become + * free (i.e., not in use by the callout). While we are in + * this loop, state->count is dropped by one, so that + * rs_close() knows when to free things. We restore it upon + * exit, either normal or abnormal. + */ + retval = 0; + add_wait_queue(&info->open_wait, &wait); + /* lock while decrementing state->count */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + if (!tty_hung_up_p(filp)) { + extra_count = 1; + state->count--; + } + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + info->blocked_open++; + while (1) { + /* disable interrupts while setting modem control lines */ + spin_lock_irqsave(&info->state->sicc_lock, flags); + if (tty->termios->c_cflag & CBAUD) { + info->mctrl = TIOCM_DTR | TIOCM_RTS; + info->port->set_mctrl(info->port, info->mctrl); + } + spin_unlock_irqrestore(&info->state->sicc_lock, flags); + set_current_state(TASK_INTERRUPTIBLE); + if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)) { + if (info->flags & ASYNC_HUP_NOTIFY) + retval = -EAGAIN; + else + retval = -ERESTARTSYS; + break; + } + if (!(info->flags & ASYNC_CLOSING) && + (do_clocal + /*|| (UART_GET_FR(info->port) & SICC_UARTFR_DCD) */ )) + break; + if (signal_pending(current)) { + retval = -ERESTARTSYS; + break; + } + schedule(); + } + set_current_state(TASK_RUNNING); + remove_wait_queue(&info->open_wait, &wait); + if (extra_count) + state->count++; + info->blocked_open--; + if (retval) + return retval; + info->flags |= ASYNC_NORMAL_ACTIVE; + return 0; } static struct SICC_info *siccuart_get(int line) { - struct SICC_info *info; - struct SICC_state *state = sicc_state + line; + struct SICC_info *info; + struct SICC_state *state = sicc_state + line; - state->count++; - if (state->info) - return state->info; - info = kzalloc(sizeof(struct SICC_info), GFP_KERNEL); - if (info) { - init_waitqueue_head(&info->open_wait); - init_waitqueue_head(&info->close_wait); - init_waitqueue_head(&info->delta_msr_wait); - info->flags = state->flags; - info->state = state; - info->port = sicc_ports + line; - tasklet_init(&info->tlet, siccuart_tasklet_action, - (unsigned long)info); - } - if (state->info) { - kfree(info); - return state->info; - } - state->info = info; - return info; + state->count++; + if (state->info) + return state->info; + info = kzalloc(sizeof(struct SICC_info), GFP_KERNEL); + if (info) { + init_waitqueue_head(&info->open_wait); + init_waitqueue_head(&info->close_wait); + init_waitqueue_head(&info->delta_msr_wait); + info->flags = state->flags; + info->state = state; + info->port = sicc_ports + line; + tasklet_init(&info->tlet, siccuart_tasklet_action, + (unsigned long)info); + } + if (state->info) { + kfree(info); + return state->info; + } + state->info = info; + return info; } static int siccuart_open(struct tty_struct *tty, struct file *filp) { - struct SICC_info *info; - int retval, line = tty->index; - - - // is this a line that we've got? - if (line >= SERIAL_SICC_NR) { - return -ENODEV; - } - - info = siccuart_get(line); - if (!info) - return -ENOMEM; - - tty->driver_data = info; - info->tty = tty; - info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; - - /* - * Make sure we have the temporary buffer allocated - */ - if (!tmp_buf) { - unsigned long page = get_zeroed_page(GFP_KERNEL); - if (tmp_buf) - free_page(page); - else if (!page) { - return -ENOMEM; - } - tmp_buf = (u_char *)page; - } - - /* - * If the port is in the middle of closing, bail out now. - */ - if (tty_hung_up_p(filp) || - (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); - return -EAGAIN; - } - - /* - * Start up the serial port - */ - retval = siccuart_startup(info); - if (retval) { - return retval; - } - - retval = block_til_ready(tty, filp, info); - if (retval) { - return retval; - } + struct SICC_info *info; + int retval, line = tty->index; + // is this a line that we've got? + if (line >= SERIAL_SICC_NR) { + return -ENODEV; + } + + info = siccuart_get(line); + if (!info) + return -ENOMEM; + + tty->driver_data = info; + info->tty = tty; + info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; + + /* + * Make sure we have the temporary buffer allocated + */ + if (!tmp_buf) { + unsigned long page = get_zeroed_page(GFP_KERNEL); + if (tmp_buf) + free_page(page); + else if (!page) { + return -ENOMEM; + } + tmp_buf = (u_char *) page; + } + + /* + * If the port is in the middle of closing, bail out now. + */ + if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { + if (info->flags & ASYNC_CLOSING) + interruptible_sleep_on(&info->close_wait); + return -EAGAIN; + } + + /* + * Start up the serial port + */ + retval = siccuart_startup(info); + if (retval) { + return retval; + } + + retval = block_til_ready(tty, filp, info); + if (retval) { + return retval; + } #ifdef CONFIG_SERIAL_SICC_CONSOLE - if (siccuart_cons.cflag && siccuart_cons.index == line) { - tty->termios->c_cflag = siccuart_cons.cflag; - siccuart_cons.cflag = 0; - siccuart_change_speed(info, NULL); - } + if (siccuart_cons.cflag && siccuart_cons.index == line) { + tty->termios->c_cflag = siccuart_cons.cflag; + siccuart_cons.cflag = 0; + siccuart_change_speed(info, NULL); + } #endif - return 0; + return 0; } static struct tty_operations sicc_ops = { @@ -1729,7 +1707,7 @@ static struct tty_operations sicc_ops = .flush_chars = siccuart_flush_chars, .write_room = siccuart_write_room, .chars_in_buffer = siccuart_chars_in_buffer, - .flush_buffer = siccuart_flush_buffer, + .flush_buffer = siccuart_flush_buffer, .ioctl = siccuart_ioctl, .throttle = siccuart_throttle, .unthrottle = siccuart_unthrottle, @@ -1744,36 +1722,37 @@ static struct tty_operations sicc_ops = int __init siccuart_init(void) { - int i; - siccnormal_driver = alloc_tty_driver(SERIAL_SICC_NR); - if (!siccnormal_driver) - return -ENOMEM; - printk("IBM Vesta SICC serial port driver V 0.1 by Yudong Yang and Yi Ge / IBM CRL .\n"); - siccnormal_driver->driver_name = "serial_sicc"; - siccnormal_driver->owner = THIS_MODULE; - siccnormal_driver->name = SERIAL_SICC_NAME; - siccnormal_driver->major = SERIAL_SICC_MAJOR; - siccnormal_driver->minor_start = SERIAL_SICC_MINOR; - siccnormal_driver->type = TTY_DRIVER_TYPE_SERIAL; - siccnormal_driver->subtype = SERIAL_TYPE_NORMAL; - siccnormal_driver->init_termios = tty_std_termios; - siccnormal_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; - siccnormal_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; - tty_set_operations(siccnormal_driver, &sicc_ops); - - if (tty_register_driver(siccnormal_driver)) - panic("Couldn't register SICC serial driver\n"); - - for (i = 0; i < SERIAL_SICC_NR; i++) { - struct SICC_state *state = sicc_state + i; - state->line = i; - state->close_delay = msecs_to_jiffies(500); - state->closing_wait = 30 * HZ; - spin_lock_init(&state->sicc_lock); - } - + int i; + siccnormal_driver = alloc_tty_driver(SERIAL_SICC_NR); + if (!siccnormal_driver) + return -ENOMEM; + printk + ("IBM Vesta SICC serial port driver V 0.1 by Yudong Yang and Yi Ge / IBM CRL .\n"); + siccnormal_driver->driver_name = "serial_sicc"; + siccnormal_driver->owner = THIS_MODULE; + siccnormal_driver->name = SERIAL_SICC_NAME; + siccnormal_driver->major = SERIAL_SICC_MAJOR; + siccnormal_driver->minor_start = SERIAL_SICC_MINOR; + siccnormal_driver->type = TTY_DRIVER_TYPE_SERIAL; + siccnormal_driver->subtype = SERIAL_TYPE_NORMAL; + siccnormal_driver->init_termios = tty_std_termios; + siccnormal_driver->init_termios.c_cflag = + B9600 | CS8 | CREAD | HUPCL | CLOCAL; + siccnormal_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; + tty_set_operations(siccnormal_driver, &sicc_ops); + + if (tty_register_driver(siccnormal_driver)) + panic("Couldn't register SICC serial driver\n"); + + for (i = 0; i < SERIAL_SICC_NR; i++) { + struct SICC_state *state = sicc_state + i; + state->line = i; + state->close_delay = msecs_to_jiffies(500); + state->closing_wait = 30 * HZ; + spin_lock_init(&state->sicc_lock); + } - return 0; + return 0; } __initcall(siccuart_init); @@ -1790,26 +1769,26 @@ __initcall(siccuart_init); #ifdef used_and_not_const_char_pointer static int siccuart_console_read(struct console *co, const char *s, u_int count) { - struct SICC_port *port = &sicc_ports[co->index]; - unsigned int status; - char *w; - int c; - - pr_debug("siccuart_console_read() called\n"); - - c = 0; - w = s; - while (c < count) { - if(readb(port->uart_base + BL_SICC_LSR) & _LSR_RBR_FULL) { - *w++ = readb(port->uart_base + BL_SICC_RBR); - c++; - } else { - // nothing more to get, return - return c; - } - } - // return the count - return c; + struct SICC_port *port = &sicc_ports[co->index]; + unsigned int status; + char *w; + int c; + + pr_debug("siccuart_console_read() called\n"); + + c = 0; + w = s; + while (c < count) { + if (readb(port->uart_base + BL_SICC_LSR) & _LSR_RBR_FULL) { + *w++ = readb(port->uart_base + BL_SICC_RBR); + c++; + } else { + // nothing more to get, return + return c; + } + } + // return the count + return c; } #endif @@ -1819,36 +1798,40 @@ static int siccuart_console_read(struct * * The console_lock must be held when we get here. */ -static void siccuart_console_write(struct console *co, const char *s, u_int count) +static void siccuart_console_write(struct console *co, const char *s, + u_int count) { - struct SICC_port *port = &sicc_ports[co->index]; - unsigned int old_cr; - int i; - - /* - * First save the CR then disable the interrupts - */ - old_cr = readb(port->uart_base + BL_SICC_TxCR); - writeb(old_cr & ~_TxCR_DME_MASK, port->uart_base + BL_SICC_TxCR); - - /* - * Now, do each character - */ - for (i = 0; i < count; i++) { - while ((readb(port->uart_base + BL_SICC_LSR)&_LSR_TX_ALL) != _LSR_TX_ALL); - writeb(s[i], port->uart_base + BL_SICC_TBR); - if (s[i] == '\n') { - while ((readb(port->uart_base + BL_SICC_LSR)&_LSR_TX_ALL) != _LSR_TX_ALL); - writeb('\r', port->uart_base + BL_SICC_TBR); - } - } - - /* - * Finally, wait for transmitter to become empty - * and restore the TCR - */ - while ((readb(port->uart_base + BL_SICC_LSR)&_LSR_TX_ALL) != _LSR_TX_ALL); - writeb(old_cr, port->uart_base + BL_SICC_TxCR); + struct SICC_port *port = &sicc_ports[co->index]; + unsigned int old_cr; + int i; + + /* + * First save the CR then disable the interrupts + */ + old_cr = readb(port->uart_base + BL_SICC_TxCR); + writeb(old_cr & ~_TxCR_DME_MASK, port->uart_base + BL_SICC_TxCR); + + /* + * Now, do each character + */ + for (i = 0; i < count; i++) { + while ((readb(port->uart_base + BL_SICC_LSR) & _LSR_TX_ALL) != + _LSR_TX_ALL) ; + writeb(s[i], port->uart_base + BL_SICC_TBR); + if (s[i] == '\n') { + while ((readb(port->uart_base + BL_SICC_LSR) & + _LSR_TX_ALL) != _LSR_TX_ALL) ; + writeb('\r', port->uart_base + BL_SICC_TBR); + } + } + + /* + * Finally, wait for transmitter to become empty + * and restore the TCR + */ + while ((readb(port->uart_base + BL_SICC_LSR) & _LSR_TX_ALL) != + _LSR_TX_ALL) ; + writeb(old_cr, port->uart_base + BL_SICC_TxCR); } /* @@ -1856,12 +1839,12 @@ static void siccuart_console_write(struc */ static int siccuart_console_wait_key(struct console *co) { - struct SICC_port *port = &sicc_ports[co->index]; - int c; + struct SICC_port *port = &sicc_ports[co->index]; + int c; - while(!(readb(port->uart_base + BL_SICC_LSR) & _LSR_RBR_FULL)); - c = readb(port->uart_base + BL_SICC_RBR); - return c; + while (!(readb(port->uart_base + BL_SICC_LSR) & _LSR_RBR_FULL)) ; + c = readb(port->uart_base + BL_SICC_RBR); + return c; } static struct tty_driver *siccuart_console_device(struct console *c, int *index) @@ -1872,135 +1855,164 @@ static struct tty_driver *siccuart_conso static int __init siccuart_console_setup(struct console *co, char *options) { - struct SICC_port *port; - int baud = 9600; - int bits = 8; - int parity = 'n'; - u_int cflag = CREAD | HUPCL | CLOCAL; - u_int lcr_h, quot; - - - if (co->index >= SERIAL_SICC_NR) - co->index = 0; - - port = &sicc_ports[co->index]; - - if (port->uart_base == 0) - port->uart_base = (int)ioremap(port->uart_base_phys, PAGE_SIZE); - - if (options) { - char *s = options; - baud = simple_strtoul(s, NULL, 10); - while (*s >= '0' && *s <= '9') - s++; - if (*s) parity = *s++; - if (*s) bits = *s - '0'; - } - - /* - * Now construct a cflag setting. - */ - switch (baud) { - case 1200: cflag |= B1200; break; - case 2400: cflag |= B2400; break; - case 4800: cflag |= B4800; break; - default: cflag |= B9600; baud = 9600; break; - case 19200: cflag |= B19200; break; - case 38400: cflag |= B38400; break; - case 57600: cflag |= B57600; break; - case 115200: cflag |= B115200; break; - } - switch (bits) { - case 7: cflag |= CS7; lcr_h = _LCR_PE_DISABLE | _LCR_DB_7_BITS | _LCR_SB_1_BIT; break; - default: cflag |= CS8; lcr_h = _LCR_PE_DISABLE | _LCR_DB_8_BITS | _LCR_SB_1_BIT; break; - } - switch (parity) { - case 'o': - case 'O': cflag |= PARODD; lcr_h |= _LCR_PTY_ODD; break; - case 'e': - case 'E': cflag |= PARENB; lcr_h |= _LCR_PE_ENABLE | _LCR_PTY_ODD; break; - } - - co->cflag = cflag; - - - { - // a copy of is inserted here ppc403SetBaud(com_port, (int)9600); - unsigned long divisor, clockSource, temp; - unsigned int rate = baud; - - /* Ensure CICCR[7] is 0 to select Internal Baud Clock */ - powerpcMtcic_cr((unsigned long)(powerpcMfcic_cr() & 0xFEFFFFFF)); - - /* Determine Internal Baud Clock Frequency */ - /* powerpcMfclkgpcr() reads DCR 0x120 - the*/ - /* SCCR (Serial Clock Control Register) on Vesta */ - temp = powerpcMfclkgpcr(); - - if(temp & 0x00000080) { - clockSource = 324000000; - } - else { - clockSource = 216000000; - } - clockSource = clockSource/(unsigned long)((temp&0x00FC0000)>>18); - divisor = clockSource/(16*rate) - 1; - /* divisor has only 12 bits of resolution */ - if(divisor>0x00000FFF){ - divisor=0x00000FFF; - } - - quot = divisor; - } - - writeb((quot & 0x00000F00)>>8, port->uart_base + BL_SICC_BRDH ); - writeb( quot & 0x00000FF, port->uart_base + BL_SICC_BRDL ); - - /* Set CTL2 reg to use external clock (ExtClk) and enable FIFOs. */ - /* For now, do NOT use FIFOs since 403 UART did not have this */ - /* capability and this driver was inherited from 403UART. */ - writeb(_CTL2_EXTERN, port->uart_base + BL_SICC_CTL2); - - writeb(lcr_h, port->uart_base + BL_SICC_LCR); - writeb(_RCR_ER_ENABLE | _RCR_PME_HARD, port->uart_base + BL_SICC_RCR); - writeb( _TxCR_ET_ENABLE , port->uart_base + BL_SICC_TxCR); - - // writeb(, info->port->uart_base + BL_SICC_RCR ); - /* - * Transmitter Command Register: Transmitter enabled & DMA + TBR interrupt - * + Transmitter Empty interrupt + Transmitter error interrupt disabled & - * Stop mode when CTS active enabled & Transmit Break + Pattern Generation - * mode disabled. - */ - - writeb( 0x00, port->uart_base + BL_SICC_IrCR ); // disable IrDA - - readb(port->uart_base + BL_SICC_RBR); - - writeb(0xf8, port->uart_base + BL_SICC_LSR); /* reset bits 0-4 of LSR */ - - /* we will enable the port as we need it */ - - return 0; -} - -static struct console siccuart_cons = -{ - .name = SERIAL_SICC_NAME, - .write = siccuart_console_write, + struct SICC_port *port; + int baud = 9600; + int bits = 8; + int parity = 'n'; + u_int cflag = CREAD | HUPCL | CLOCAL; + u_int lcr_h, quot; + + if (co->index >= SERIAL_SICC_NR) + co->index = 0; + + port = &sicc_ports[co->index]; + + if (port->uart_base == 0) + port->uart_base = (int)ioremap(port->uart_base_phys, PAGE_SIZE); + + if (options) { + char *s = options; + baud = simple_strtoul(s, NULL, 10); + while (*s >= '0' && *s <= '9') + s++; + if (*s) + parity = *s++; + if (*s) + bits = *s - '0'; + } + + /* + * Now construct a cflag setting. + */ + switch (baud) { + case 1200: + cflag |= B1200; + break; + case 2400: + cflag |= B2400; + break; + case 4800: + cflag |= B4800; + break; + default: + cflag |= B9600; + baud = 9600; + break; + case 19200: + cflag |= B19200; + break; + case 38400: + cflag |= B38400; + break; + case 57600: + cflag |= B57600; + break; + case 115200: + cflag |= B115200; + break; + } + switch (bits) { + case 7: + cflag |= CS7; + lcr_h = _LCR_PE_DISABLE | _LCR_DB_7_BITS | _LCR_SB_1_BIT; + break; + default: + cflag |= CS8; + lcr_h = _LCR_PE_DISABLE | _LCR_DB_8_BITS | _LCR_SB_1_BIT; + break; + } + switch (parity) { + case 'o': + case 'O': + cflag |= PARODD; + lcr_h |= _LCR_PTY_ODD; + break; + case 'e': + case 'E': + cflag |= PARENB; + lcr_h |= _LCR_PE_ENABLE | _LCR_PTY_ODD; + break; + } + + co->cflag = cflag; + + { + // a copy of is inserted here ppc403SetBaud(com_port, (int)9600); + unsigned long divisor, clockSource, temp; + unsigned int rate = baud; + + /* Ensure CICCR[7] is 0 to select Internal Baud Clock */ + powerpcMtcic_cr((unsigned long)(powerpcMfcic_cr() & + 0xFEFFFFFF)); + + /* Determine Internal Baud Clock Frequency */ + /* powerpcMfclkgpcr() reads DCR 0x120 - the */ + /* SCCR (Serial Clock Control Register) on Vesta */ + temp = powerpcMfclkgpcr(); + + if (temp & 0x00000080) { + clockSource = 324000000; + } else { + clockSource = 216000000; + } + clockSource = + clockSource / (unsigned long)((temp & 0x00FC0000) >> 18); + divisor = clockSource / (16 * rate) - 1; + /* divisor has only 12 bits of resolution */ + if (divisor > 0x00000FFF) { + divisor = 0x00000FFF; + } + + quot = divisor; + } + + writeb((quot & 0x00000F00) >> 8, port->uart_base + BL_SICC_BRDH); + writeb(quot & 0x00000FF, port->uart_base + BL_SICC_BRDL); + + /* Set CTL2 reg to use external clock (ExtClk) and enable FIFOs. */ + /* For now, do NOT use FIFOs since 403 UART did not have this */ + /* capability and this driver was inherited from 403UART. */ + writeb(_CTL2_EXTERN, port->uart_base + BL_SICC_CTL2); + + writeb(lcr_h, port->uart_base + BL_SICC_LCR); + writeb(_RCR_ER_ENABLE | _RCR_PME_HARD, port->uart_base + BL_SICC_RCR); + writeb(_TxCR_ET_ENABLE, port->uart_base + BL_SICC_TxCR); + + // writeb(, info->port->uart_base + BL_SICC_RCR ); + /* + * Transmitter Command Register: Transmitter enabled & DMA + TBR interrupt + * + Transmitter Empty interrupt + Transmitter error interrupt disabled & + * Stop mode when CTS active enabled & Transmit Break + Pattern Generation + * mode disabled. + */ + + writeb(0x00, port->uart_base + BL_SICC_IrCR); // disable IrDA + + readb(port->uart_base + BL_SICC_RBR); + + writeb(0xf8, port->uart_base + BL_SICC_LSR); /* reset bits 0-4 of LSR */ + + /* we will enable the port as we need it */ + + return 0; +} + +static struct console siccuart_cons = { + .name = SERIAL_SICC_NAME, + .write = siccuart_console_write, #ifdef used_and_not_const_char_pointer - .read = siccuart_console_read, + .read = siccuart_console_read, #endif - .device = siccuart_console_device, - .wait_key = siccuart_console_wait_key, - .setup = siccuart_console_setup, - .flags = CON_PRINTBUFFER, - .index = -1, + .device = siccuart_console_device, + .wait_key = siccuart_console_wait_key, + .setup = siccuart_console_setup, + .flags = CON_PRINTBUFFER, + .index = -1, }; void __init sicc_console_init(void) { - register_console(&siccuart_cons); + register_console(&siccuart_cons); } -#endif /* CONFIG_SERIAL_SICC_CONSOLE */ +#endif /* CONFIG_SERIAL_SICC_CONSOLE */ --- a/arch/ppc/8260_io/fcc_enet.c +++ b/arch/ppc/8260_io/fcc_enet.c @@ -1305,11 +1305,9 @@ static void mii_parse_dm9161_scsr(uint m static void mii_dm9161_wait(uint mii_reg, struct net_device *dev) { - int timeout = HZ; - /* Davicom takes a bit to come up after a reset, * so wait here for a bit */ - schedule_timeout_uninterruptible(timeout); + ssleep(1); } static phy_info_t phy_info_dm9161 = { --- a/arch/ppc/syslib/Makefile +++ b/arch/ppc/syslib/Makefile @@ -37,7 +37,6 @@ endif endif obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \ ppc_sys.o mpc8xx_devices.o mpc8xx_sys.o -obj-$(CONFIG_PCI_QSPAN) += qspan_pci.o obj-$(CONFIG_PPC_PREP) += open_pic.o todc_time.o obj-$(CONFIG_BAMBOO) += pci_auto.o todc_time.o obj-$(CONFIG_CPCI690) += todc_time.o pci_auto.o --- a/arch/ppc/syslib/qspan_pci.c +++ b/arch/ppc/syslib/qspan_pci.c 1970-01-01 03:00:00.000000000 +0300 @@ -1,381 +0,0 @@ -/* - * QSpan pci routines. - * Most 8xx boards use the QSpan PCI bridge. The config address register - * is located 0x500 from the base of the bridge control/status registers. - * The data register is located at 0x504. - * This is a two step operation. First, the address register is written, - * then the data register is read/written as required. - * I don't know what to do about interrupts (yet). - * - * The RPX Classic implementation shares a chip select for normal - * PCI access and QSpan control register addresses. The selection is - * further selected by a bit setting in a board control register. - * Although it should happen, we disable interrupts during this operation - * to make sure some driver doesn't accidentally access the PCI while - * we have switched the chip select. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -/* - * This blows...... - * When reading the configuration space, if something does not respond - * the bus times out and we get a machine check interrupt. So, the - * good ol' exception tables come to mind to trap it and return some - * value. - * - * On an error we just return a -1, since that is what the caller wants - * returned if nothing is present. I copied this from __get_user_asm, - * with the only difference of returning -1 instead of EFAULT. - * There is an associated hack in the machine check trap code. - * - * The QSPAN is also a big endian device, that is it makes the PCI - * look big endian to us. This presents a problem for the Linux PCI - * functions, which assume little endian. For example, we see the - * first 32-bit word like this: - * ------------------------ - * | Device ID | Vendor ID | - * ------------------------ - * If we read/write as a double word, that's OK. But in our world, - * when read as a word, device ID is at location 0, not location 2 as - * the little endian PCI would believe. We have to switch bits in - * the PCI addresses given to us to get the data to/from the correct - * byte lanes. - * - * The QSPAN only supports 4 bits of "slot" in the dev_fn instead of 5. - * It always forces the MS bit to zero. Therefore, dev_fn values - * greater than 128 are returned as "no device found" errors. - * - * The QSPAN can only perform long word (32-bit) configuration cycles. - * The "offset" must have the two LS bits set to zero. Read operations - * require we read the entire word and then sort out what should be - * returned. Write operations other than long word require that we - * read the long word, update the proper word or byte, then write the - * entire long word back. - * - * PCI Bridge hack. We assume (correctly) that bus 0 is the primary - * PCI bus from the QSPAN. If we are called with a bus number other - * than zero, we create a Type 1 configuration access that a downstream - * PCI bridge will interpret. - */ - -#define __get_qspan_pci_config(x, addr, op) \ - __asm__ __volatile__( \ - "1: "op" %0,0(%1)\n" \ - " eieio\n" \ - "2:\n" \ - ".section .fixup,\"ax\"\n" \ - "3: li %0,-1\n" \ - " b 2b\n" \ - ".section __ex_table,\"a\"\n" \ - " .align 2\n" \ - " .long 1b,3b\n" \ - ".text" \ - : "=r"(x) : "r"(addr) : " %0") - -#define QS_CONFIG_ADDR ((volatile uint *)(PCI_CSR_ADDR + 0x500)) -#define QS_CONFIG_DATA ((volatile uint *)(PCI_CSR_ADDR + 0x504)) - -#define mk_config_addr(bus, dev, offset) \ - (((bus)<<16) | ((dev)<<8) | (offset & 0xfc)) - -#define mk_config_type1(bus, dev, offset) \ - mk_config_addr(bus, dev, offset) | 1; - -static DEFINE_SPINLOCK(pcibios_lock); - -int qspan_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned char *val) -{ - uint temp; - u_char *cp; -#ifdef CONFIG_RPXCLASSIC - unsigned long flags; -#endif - - if ((bus > 7) || (dev_fn > 127)) { - *val = 0xff; - return PCIBIOS_DEVICE_NOT_FOUND; - } - -#ifdef CONFIG_RPXCLASSIC - /* disable interrupts */ - spin_lock_irqsave(&pcibios_lock, flags); - *((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL; - eieio(); -#endif - - if (bus == 0) - *QS_CONFIG_ADDR = mk_config_addr(bus, dev_fn, offset); - else - *QS_CONFIG_ADDR = mk_config_type1(bus, dev_fn, offset); - __get_qspan_pci_config(temp, QS_CONFIG_DATA, "lwz"); - -#ifdef CONFIG_RPXCLASSIC - *((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL; - eieio(); - spin_unlock_irqrestore(&pcibios_lock, flags); -#endif - - offset ^= 0x03; - cp = ((u_char *)&temp) + (offset & 0x03); - *val = *cp; - return PCIBIOS_SUCCESSFUL; -} - -int qspan_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned short *val) -{ - uint temp; - ushort *sp; -#ifdef CONFIG_RPXCLASSIC - unsigned long flags; -#endif - - if ((bus > 7) || (dev_fn > 127)) { - *val = 0xffff; - return PCIBIOS_DEVICE_NOT_FOUND; - } - -#ifdef CONFIG_RPXCLASSIC - /* disable interrupts */ - spin_lock_irqsave(&pcibios_lock, flags); - *((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL; - eieio(); -#endif - - if (bus == 0) - *QS_CONFIG_ADDR = mk_config_addr(bus, dev_fn, offset); - else - *QS_CONFIG_ADDR = mk_config_type1(bus, dev_fn, offset); - __get_qspan_pci_config(temp, QS_CONFIG_DATA, "lwz"); - offset ^= 0x02; - -#ifdef CONFIG_RPXCLASSIC - *((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL; - eieio(); - spin_unlock_irqrestore(&pcibios_lock, flags); -#endif - - sp = ((ushort *)&temp) + ((offset >> 1) & 1); - *val = *sp; - return PCIBIOS_SUCCESSFUL; -} - -int qspan_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned int *val) -{ -#ifdef CONFIG_RPXCLASSIC - unsigned long flags; -#endif - - if ((bus > 7) || (dev_fn > 127)) { - *val = 0xffffffff; - return PCIBIOS_DEVICE_NOT_FOUND; - } - -#ifdef CONFIG_RPXCLASSIC - /* disable interrupts */ - spin_lock_irqsave(&pcibios_lock, flags); - *((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL; - eieio(); -#endif - - if (bus == 0) - *QS_CONFIG_ADDR = mk_config_addr(bus, dev_fn, offset); - else - *QS_CONFIG_ADDR = mk_config_type1(bus, dev_fn, offset); - __get_qspan_pci_config(*val, QS_CONFIG_DATA, "lwz"); - -#ifdef CONFIG_RPXCLASSIC - *((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL; - eieio(); - spin_unlock_irqrestore(&pcibios_lock, flags); -#endif - - return PCIBIOS_SUCCESSFUL; -} - -int qspan_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned char val) -{ - uint temp; - u_char *cp; -#ifdef CONFIG_RPXCLASSIC - unsigned long flags; -#endif - - if ((bus > 7) || (dev_fn > 127)) - return PCIBIOS_DEVICE_NOT_FOUND; - - qspan_pcibios_read_config_dword(bus, dev_fn, offset, &temp); - - offset ^= 0x03; - cp = ((u_char *)&temp) + (offset & 0x03); - *cp = val; - -#ifdef CONFIG_RPXCLASSIC - /* disable interrupts */ - spin_lock_irqsave(&pcibios_lock, flags); - *((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL; - eieio(); -#endif - - if (bus == 0) - *QS_CONFIG_ADDR = mk_config_addr(bus, dev_fn, offset); - else - *QS_CONFIG_ADDR = mk_config_type1(bus, dev_fn, offset); - *QS_CONFIG_DATA = temp; - -#ifdef CONFIG_RPXCLASSIC - *((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL; - eieio(); - spin_unlock_irqrestore(&pcibios_lock, flags); -#endif - - return PCIBIOS_SUCCESSFUL; -} - -int qspan_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned short val) -{ - uint temp; - ushort *sp; -#ifdef CONFIG_RPXCLASSIC - unsigned long flags; -#endif - - if ((bus > 7) || (dev_fn > 127)) - return PCIBIOS_DEVICE_NOT_FOUND; - - qspan_pcibios_read_config_dword(bus, dev_fn, offset, &temp); - - offset ^= 0x02; - sp = ((ushort *)&temp) + ((offset >> 1) & 1); - *sp = val; - -#ifdef CONFIG_RPXCLASSIC - /* disable interrupts */ - spin_lock_irqsave(&pcibios_lock, flags); - *((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL; - eieio(); -#endif - - if (bus == 0) - *QS_CONFIG_ADDR = mk_config_addr(bus, dev_fn, offset); - else - *QS_CONFIG_ADDR = mk_config_type1(bus, dev_fn, offset); - *QS_CONFIG_DATA = temp; - -#ifdef CONFIG_RPXCLASSIC - *((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL; - eieio(); - spin_unlock_irqrestore(&pcibios_lock, flags); -#endif - - return PCIBIOS_SUCCESSFUL; -} - -int qspan_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn, - unsigned char offset, unsigned int val) -{ -#ifdef CONFIG_RPXCLASSIC - unsigned long flags; -#endif - - if ((bus > 7) || (dev_fn > 127)) - return PCIBIOS_DEVICE_NOT_FOUND; - -#ifdef CONFIG_RPXCLASSIC - /* disable interrupts */ - spin_lock_irqsave(&pcibios_lock, flags); - *((uint *)RPX_CSR_ADDR) &= ~BCSR2_QSPACESEL; - eieio(); -#endif - - if (bus == 0) - *QS_CONFIG_ADDR = mk_config_addr(bus, dev_fn, offset); - else - *QS_CONFIG_ADDR = mk_config_type1(bus, dev_fn, offset); - *(unsigned int *)QS_CONFIG_DATA = val; - -#ifdef CONFIG_RPXCLASSIC - *((uint *)RPX_CSR_ADDR) |= BCSR2_QSPACESEL; - eieio(); - spin_unlock_irqrestore(&pcibios_lock, flags); -#endif - - return PCIBIOS_SUCCESSFUL; -} - -int qspan_pcibios_find_device(unsigned short vendor, unsigned short dev_id, - unsigned short index, unsigned char *bus_ptr, - unsigned char *dev_fn_ptr) -{ - int num, devfn; - unsigned int x, vendev; - - if (vendor == 0xffff) - return PCIBIOS_BAD_VENDOR_ID; - vendev = (dev_id << 16) + vendor; - num = 0; - for (devfn = 0; devfn < 32; devfn++) { - qspan_pcibios_read_config_dword(0, devfn<<3, PCI_VENDOR_ID, &x); - if (x == vendev) { - if (index == num) { - *bus_ptr = 0; - *dev_fn_ptr = devfn<<3; - return PCIBIOS_SUCCESSFUL; - } - ++num; - } - } - return PCIBIOS_DEVICE_NOT_FOUND; -} - -int qspan_pcibios_find_class(unsigned int class_code, unsigned short index, - unsigned char *bus_ptr, unsigned char *dev_fn_ptr) -{ - int devnr, x, num; - - num = 0; - for (devnr = 0; devnr < 32; devnr++) { - qspan_pcibios_read_config_dword(0, devnr<<3, PCI_CLASS_REVISION, &x); - if ((x>>8) == class_code) { - if (index == num) { - *bus_ptr = 0; - *dev_fn_ptr = devnr<<3; - return PCIBIOS_SUCCESSFUL; - } - ++num; - } - } - return PCIBIOS_DEVICE_NOT_FOUND; -} - -void __init -m8xx_pcibios_fixup(void)) -{ - /* Lots to do here, all board and configuration specific. */ -} - -void __init -m8xx_setup_pci_ptrs(void)) -{ - set_config_access_method(qspan); - - ppc_md.pcibios_fixup = m8xx_pcibios_fixup; -} - --- a/arch/sh/drivers/dma/dma-api.c +++ b/arch/sh/drivers/dma/dma-api.c @@ -288,10 +288,13 @@ void unregister_dmac(struct dma_info *in static int __init dma_api_init(void) { + struct proc_dir_entry *ent; printk("DMA: Registering DMA API.\n"); #ifdef CONFIG_PROC_FS - create_proc_read_entry("dma", 0, 0, dma_read_proc, 0); + ent = create_proc_read_entry("dma", 0, 0, dma_read_proc, 0); + if (!ent) + printk(KERN_WARNING "dma-api.c: unable to create /proc entry\n"); #endif return 0; --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -423,10 +423,14 @@ static struct miscdevice sq_dev = { static int __init sq_api_init(void) { + struct proc_dir_entry *ent; printk(KERN_NOTICE "sq: Registering store queue API.\n"); #ifdef CONFIG_PROC_FS - create_proc_read_entry("sq_mapping", 0, 0, sq_mapping_read_proc, 0); + ent = create_proc_read_entry("sq_mapping", 0, 0, + sq_mapping_read_proc, 0); + if (!ent) + printk(KERN_WARNING "sq: unable to create /proc entry\n"); #endif return misc_register(&sq_dev); --- a/arch/sh64/kernel/process.c +++ b/arch/sh64/kernel/process.c @@ -927,7 +927,11 @@ asids_proc_info(char *buf, char **start, static int __init register_proc_asids(void) { - create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL); + struct proc_dir_entry *ent; + ent = create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL); + if (!ent) + printk(KERN_WARNING + "process.c: unable to create asids /proc entry\n"); return 0; } --- a/arch/sh64/mm/fault.c +++ b/arch/sh64/mm/fault.c @@ -592,8 +592,11 @@ tlb_proc_info(char *buf, char **start, o static int __init register_proc_tlb(void) { - create_proc_read_entry("tlb", 0, NULL, tlb_proc_info, NULL); - return 0; + struct proc_dir_entry *ent; + ent = create_proc_read_entry("tlb", 0, NULL, tlb_proc_info, NULL); + if (!ent) + printk(KERN_WARNING "fault.c: unable to create tlb /proc entry\n"); + return 0; } __initcall(register_proc_tlb); --- a/arch/sh64/mm/ioremap.c +++ b/arch/sh64/mm/ioremap.c @@ -459,7 +459,11 @@ ioremap_proc_info(char *buf, char **star static int __init register_proc_onchip(void) { #ifdef CONFIG_PROC_FS - create_proc_read_entry("io_map",0,0, ioremap_proc_info, &shmedia_iomap); + struct proc_dir_entry *ent; + ent = create_proc_read_entry("io_map",0,0, + ioremap_proc_info, &shmedia_iomap); + if (!ent) + printk(KERN_WARNING "ioremap.c: unable to create /proc entry\n"); #endif return 0; } --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c @@ -255,9 +255,8 @@ void *sbus_alloc_consistent(struct sbus_ if ((va = __get_free_pages(GFP_KERNEL|__GFP_COMP, order)) == 0) goto err_nopages; - if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) + if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) goto err_nomem; - memset((char*)res, 0, sizeof(struct resource)); if (allocate_resource(&_sparc_dvma, res, len_total, _sparc_dvma.start, _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) { @@ -437,12 +436,11 @@ void *pci_alloc_consistent(struct pci_de return NULL; } - if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) { + if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) { free_pages(va, order); printk("pci_alloc_consistent: no core\n"); return NULL; } - memset((char*)res, 0, sizeof(struct resource)); if (allocate_resource(&_sparc_dvma, res, len_total, _sparc_dvma.start, _sparc_dvma.end, PAGE_SIZE, NULL, NULL) != 0) { @@ -715,7 +713,16 @@ _sparc_find_resource(struct resource *ro void register_proc_sparc_ioport(void) { #ifdef CONFIG_PROC_FS - create_proc_read_entry("io_map",0,NULL,_sparc_io_get_info,&sparc_iomap); - create_proc_read_entry("dvma_map",0,NULL,_sparc_io_get_info,&_sparc_dvma); + struct proc_dir_entry *ent; + ent = create_proc_read_entry("io_map",0,NULL, + _sparc_io_get_info,&sparc_iomap); + if (!ent) + printk(KERN_WARNING + "ioport.c: unable to create io_map /proc entry\n"); + ent = create_proc_read_entry("dvma_map",0,NULL, + _sparc_io_get_info,&_sparc_dvma); + if (!ent) + printk(KERN_WARNING + "ioport.c: unable to create dvma_map /proc entry\n"); #endif } --- a/arch/sparc/kernel/sun4d_irq.c +++ b/arch/sparc/kernel/sun4d_irq.c @@ -542,8 +542,7 @@ void __init sun4d_init_sbi_irq(void) nsbi = 0; for_each_sbus(sbus) nsbi++; - sbus_actions = (struct sbus_action *)kmalloc (nsbi * 8 * 4 * sizeof(struct sbus_action), GFP_ATOMIC); - memset (sbus_actions, 0, (nsbi * 8 * 4 * sizeof(struct sbus_action))); + sbus_actions = kzalloc(nsbi * 8 * 4 * sizeof(struct sbus_action), GFP_ATOMIC); for_each_sbus(sbus) { #ifdef CONFIG_SMP extern unsigned char boot_cpu_id; --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c @@ -42,9 +42,8 @@ iounit_init(int sbi_node, int io_node, s struct linux_prom_registers iommu_promregs[PROMREG_MAX]; struct resource r; - iounit = kmalloc(sizeof(struct iounit_struct), GFP_ATOMIC); + iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC); - memset(iounit, 0, sizeof(*iounit)); iounit->limit[0] = IOUNIT_BMAP1_START; iounit->limit[1] = IOUNIT_BMAP2_START; iounit->limit[2] = IOUNIT_BMAPM_START; --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c @@ -2006,12 +2006,11 @@ static int __init ioapic_init_sysfs(void for (i = 0; i < nr_ioapics; i++ ) { size = sizeof(struct sys_device) + nr_ioapic_registers[i] * sizeof(struct IO_APIC_route_entry); - mp_ioapic_data[i] = kmalloc(size, GFP_KERNEL); + mp_ioapic_data[i] = kzalloc(size, GFP_KERNEL); if (!mp_ioapic_data[i]) { printk(KERN_ERR "Can't suspend/resume IOAPIC %d\n", i); continue; } - memset(mp_ioapic_data[i], 0, size); dev = &mp_ioapic_data[i]->dev; dev->id = i; dev->cls = &ioapic_sysdev_class; --- a/arch/x86_64/kernel/mce_amd.c +++ b/arch/x86_64/kernel/mce_amd.c @@ -342,12 +342,11 @@ static __cpuinit int threshold_create_ba } #endif - b = kmalloc(sizeof(struct threshold_bank), GFP_KERNEL); + b = kzalloc(sizeof(struct threshold_bank), GFP_KERNEL); if (!b) { err = -ENOMEM; goto out; } - memset(b, 0, sizeof(struct threshold_bank)); b->cpu = cpu; b->bank = bank; --- a/arch/x86_64/Makefile +++ b/arch/x86_64/Makefile @@ -44,7 +44,7 @@ CFLAGS += -Wno-sign-compare ifneq ($(CONFIG_UNWIND_INFO),y) CFLAGS += -fno-asynchronous-unwind-tables endif -ifneq ($(CONFIG_DEBUG_INFO),y) +ifndef CONFIG_DEBUG_INFO # -fweb shrinks the kernel a bit, but the difference is very small # it also messes up debugging, so don't use it for now. #CFLAGS += $(call cc-option,-fweb) --- a/Documentation/connector/cn_test.c +++ b/Documentation/connector/cn_test.c @@ -124,10 +124,8 @@ static void cn_test_timer_func(unsigned struct cn_msg *m; char data[32]; - m = kmalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC); + m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC); if (m) { - memset(m, 0, sizeof(*m) + sizeof(data)); - memcpy(&m->id, &cn_test_id, sizeof(m->id)); m->seq = cn_test_timer_counter; m->len = sizeof(data); --- a/Documentation/DMA-mapping.txt +++ b/Documentation/DMA-mapping.txt @@ -194,7 +194,7 @@ document for how to handle this case. Finally, if your device can only drive the low 24-bits of address during PCI bus mastering you might do something like: - if (pci_set_dma_mask(pdev, 0x00ffffff)) { + if (pci_set_dma_mask(pdev, DMA_24BIT_MASK)) { printk(KERN_WARNING "mydev: 24-bit DMA addressing not available.\n"); goto ignore_this_device; @@ -212,7 +212,7 @@ functions (for example a sound card prov functions) and the various different functions have _different_ DMA addressing limitations, you may wish to probe each mask and only provide the functionality which the machine can handle. It -is important that the last call to pci_set_dma_mask() be for the +is important that the last call to pci_set_dma_mask() be for the most specific mask. Here is pseudo-code showing how this might be done: --- a/Documentation/filesystems/configfs/configfs_example.c +++ b/Documentation/filesystems/configfs/configfs_example.c @@ -268,12 +268,10 @@ static struct config_item *simple_childr { struct simple_child *simple_child; - simple_child = kmalloc(sizeof(struct simple_child), GFP_KERNEL); + simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL); if (!simple_child) return NULL; - memset(simple_child, 0, sizeof(struct simple_child)); - config_item_init_type_name(&simple_child->item, name, &simple_child_type); @@ -353,13 +351,11 @@ static struct config_group *group_childr { struct simple_children *simple_children; - simple_children = kmalloc(sizeof(struct simple_children), + simple_children = kzalloc(sizeof(struct simple_children), GFP_KERNEL); if (!simple_children) return NULL; - memset(simple_children, 0, sizeof(struct simple_children)); - config_group_init_type_name(&simple_children->group, name, &simple_children_type); --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -1123,8 +1123,8 @@ if ((err = pci_enable_device(pci)) < 0) return err; /* check PCI availability (28bit DMA) */ - if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || - pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { + if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || + pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { printk(KERN_ERR "error to set 28bit mask DMA\n"); pci_disable_device(pci); return -ENXIO; @@ -1216,7 +1216,7 @@ The allocation of PCI resources is done in the probe() function, and usually an extra xxx_create() function is written for this - purpose. + purpose. @@ -1225,7 +1225,7 @@ allocating resources. Also, you need to set the proper PCI DMA mask to limit the accessed i/o range. In some cases, you might need to call pci_set_master() function, - too. + too. @@ -1236,8 +1236,8 @@ Now assume that this PCI device has an I/O port with 8 bytes and an interrupt. Then struct mychip will have the - following fields: + following fields: --- a/drivers/acorn/block/fd1772.c +++ b/drivers/acorn/block/fd1772.c @@ -124,6 +124,8 @@ * Minor parameter, name layouts for 2.4.x differences */ +#undef DEBUG /* define to enable debugging statements */ + #include #include #include @@ -165,13 +167,6 @@ /* Ditto worries for Arc - DAG */ #define FD_MAX_UNITS 4 #define TRACKBUFFER 0 -/*#define DEBUG*/ - -#ifdef DEBUG -#define DPRINT(a) printk a -#else -#define DPRINT(a) -#endif static struct request_queue *floppy_queue; @@ -180,6 +175,9 @@ static struct request_queue *floppy_queu #define DEVICE_NAME "floppy" #define QUEUE (floppy_queue) #define CURRENT elv_next_request(floppy_queue) +#define PFX DEVICE_NAME ": " + +#define DBG(fmt, args...) pr_debug(PFX "%s: " fmt, __FUNCTION__ , ## args) /* Disk types: DD */ static struct archy_disk_type { @@ -240,9 +238,9 @@ extern volatile int fdc1772_fdc_int_done void FDC1772_WRITE(int reg, unsigned char val) { if (reg == FDC1772REG_CMD) { - DPRINT(("FDC1772_WRITE new command 0x%x @ %d\n", val,jiffies)); + DBG("new command 0x%x @ %d\n", val,jiffies); if (fdc1772_fdc_int_done) { - DPRINT(("FDC1772_WRITE: Hmm fdc1772_fdc_int_done true - resetting\n")); + DBG("Hmm fdc1772_fdc_int_done true - resetting\n"); fdc1772_fdc_int_done = 0; }; }; @@ -405,9 +403,7 @@ static void fd_select_side(int side) static void fd_select_drive(int drive) { -#ifdef DEBUG - printk("fd_select_drive:%d\n", drive); -#endif + DBG("%d\n", drive); /* Hmm - nowhere do we seem to turn the motor on - I'm going to do it here! */ oldlatch_aupdate(LATCHA_MOTOR | LATCHA_INUSE, 0); @@ -430,7 +426,7 @@ static void fd_deselect(void) { unsigned long flags; - DPRINT(("fd_deselect\n")); + DBG("start\n"); oldlatch_aupdate(LATCHA_FDSELALL | LATCHA_MOTOR | LATCHA_INUSE, 0xf | LATCHA_MOTOR | LATCHA_INUSE); @@ -470,7 +466,7 @@ static void fd_motor_off_timer(unsigned * off on the Arc, since the motor control is actually on * Latch A */ - DPRINT(("fdc1772: deselecting in fd_motor_off_timer\n")); + DBG("deselecting\n"); fd_deselect(); MotorOn = 0; restore_flags(flags); @@ -519,7 +515,7 @@ static void check_change(unsigned long d /* The idea here is that if the write protect line has changed then the disc must have changed */ if (stat != unit[drive].wpstat) { - DPRINT(("wpstat[%d] = %d\n", drive, stat)); + DBG("wpstat[%d] = %d\n", drive, stat); unit[drive].wpstat = stat; set_bit(drive, &changed_floppies); } @@ -575,12 +571,13 @@ static void floppy_irqconsequencehandler if (handler) { nop(); status = (unsigned char) fdc1772_comendstatus; - DPRINT(("FDC1772 irq, status = %02x handler = %08lx\n", (unsigned int) status, (unsigned long) handler)); + DBG("status = %02x handler = %08lx\n", (unsigned int) status, + (unsigned long) handler); handler(status); } else { - DPRINT(("FDC1772 irq, no handler status=%02x\n", fdc1772_comendstatus)); + DBG("no handler status=%02x\n", fdc1772_comendstatus); } - DPRINT(("FDC1772 irq: end of floppy_irq\n")); + DBG("end\n"); } @@ -590,16 +587,16 @@ static void floppy_irqconsequencehandler static void fd_error(void) { - printk("FDC1772: fd_error\n"); + DBG("start\n"); /*panic("fd1772: fd_error"); *//* DAG tmp */ if (!CURRENT) return; CURRENT->errors++; if (CURRENT->errors >= MAX_ERRORS) { - printk("fd%d: too many errors.\n", SelectedDrive); + printk(KERN_ERR "fd%d: too many errors, giving up\n", SelectedDrive); end_request(CURRENT, 0); } else if (CURRENT->errors == RECALIBRATE_ERRORS) { - printk("fd%d: recalibrating\n", SelectedDrive); + printk(KERN_ERR "fd%d: error, recalibrating...\n", SelectedDrive); if (SelectedDrive != -1) unit[SelectedDrive].track = -1; } @@ -623,7 +620,7 @@ static void fd_error(void) static void do_fd_action(int drive) { struct request *req; - DPRINT(("do_fd_action unit[drive].track=%d\n", unit[drive].track)); + DBG("unit[drive].track=%d\n", unit[drive].track); #ifdef TRACKBUFFER repeat: @@ -671,12 +668,12 @@ repeat: static void fd_calibrate(void) { - DPRINT(("fd_calibrate\n")); + DBG("start\n"); if (unit[SelectedDrive].track >= 0) { fd_calibrate_done(0); return; } - DPRINT(("fd_calibrate (after track compare)\n")); + DBG("(after track compare)\n"); SET_IRQ_HANDLER(fd_calibrate_done); /* we can't verify, since the speed may be incorrect */ FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_RESTORE | unit[SelectedDrive].steprate); @@ -690,12 +687,12 @@ static void fd_calibrate(void) static void fd_calibrate_done(int status) { - DPRINT(("fd_calibrate_done()\n")); + DBG("start\n"); STOP_TIMEOUT(); /* set the correct speed now */ if (status & FDC1772STAT_RECNF) { - printk("fd%d: restore failed\n", SelectedDrive); + printk(KERN_ERR "fd%d: restore failed\n", SelectedDrive); fd_error(); } else { unit[SelectedDrive].track = 0; @@ -711,8 +708,8 @@ static void fd_calibrate_done(int status static void fd_seek(void) { unsigned long flags; - DPRINT(("fd_seek() to track %d (unit[SelectedDrive].track=%d)\n", ReqTrack, - unit[SelectedDrive].track)); + DBG("to track %d (unit[SelectedDrive].track=%d)\n", ReqTrack, + unit[SelectedDrive].track); if (unit[SelectedDrive].track == ReqTrack << unit[SelectedDrive].disktype->stretch) { fd_seek_done(0); @@ -738,12 +735,12 @@ static void fd_seek(void) static void fd_seek_done(int status) { - DPRINT(("fd_seek_done()\n")); + DBG("start\n"); STOP_TIMEOUT(); /* set the correct speed */ if (status & FDC1772STAT_RECNF) { - printk("fd%d: seek error (to track %d)\n", + printk(KERN_ERR "fd%d: seek error (to track %d)\n", SelectedDrive, ReqTrack); /* we don't know exactly which track we are on now! */ unit[SelectedDrive].track = -1; @@ -772,7 +769,7 @@ static void fd_rwsec(void) unsigned int rwflag, old_motoron; unsigned int track; - DPRINT(("fd_rwsec(), Sec=%d, Access=%c\n", ReqSector, ReqCmd == WRITE ? 'w' : 'r')); + DBG("Sec=%d, Access=%c\n", ReqSector, ReqCmd == WRITE ? 'w' : 'r'); if (ReqCmd == WRITE) { /*cache_push( (unsigned long)ReqData, 512 ); */ paddr = (unsigned long) ReqData; @@ -786,11 +783,11 @@ static void fd_rwsec(void) rwflag = 0; } - DPRINT(("fd_rwsec() before sidesel rwflag=%d sec=%d trk=%d\n", rwflag, - ReqSector, FDC1772_READ(FDC1772REG_TRACK))); + DBG("before sidesel rwflag=%d sec=%d trk=%d\n", rwflag, + ReqSector, FDC1772_READ(FDC1772REG_TRACK)); fd_select_side(ReqSide); - /*DPRINT(("fd_rwsec() before start sector \n")); */ + /*DBG("before start sector\n"); */ /* Start sector of this operation */ #ifdef TRACKBUFFER FDC1772_WRITE( FDC1772REG_SECTOR, !read_track ? ReqSector : 1 ); @@ -806,7 +803,7 @@ static void fd_rwsec(void) } udelay(25); - DPRINT(("fd_rwsec() before setup DMA \n")); + DBG("before setup DMA\n"); /* Setup DMA - Heavily modified by DAG */ save_flags(flags); clf(); @@ -834,7 +831,7 @@ static void fd_rwsec(void) )); restore_flags(flags); - DPRINT(("fd_rwsec() after DMA setup flags=0x%08x\n", flags)); + DBG("after DMA setup flags=0x%08x\n", flags); /*sti(); *//* DAG - Hmm */ /* Hmm - should do something DAG */ old_motoron = MotorOn; @@ -853,15 +850,15 @@ static void fd_rwsec(void) */ /* 1 rot. + 5 rot.s if motor was off */ mod_timer(&readtrack_timer, jiffies + HZ/5 + (old_motoron ? 0 : HZ)); - DPRINT(("Setting readtrack_timer to %d @ %d\n", - readtrack_timer.expires,jiffies)); + DBG("setting readtrack_timer to %d @ %d\n", + readtrack_timer.expires,jiffies); MultReadInProgress = 1; } #endif - /*DPRINT(("fd_rwsec() before START_TIMEOUT \n")); */ + /*DBG("before START_TIMEOUT\n"); */ START_TIMEOUT(); - /*DPRINT(("fd_rwsec() after START_TIMEOUT \n")); */ + /*DBG("after START_TIMEOUT\n"); */ } @@ -872,7 +869,7 @@ static void fd_readtrack_check(unsigned unsigned long flags, addr; extern unsigned char *fdc1772_dataaddr; - DPRINT(("fd_readtrack_check @ %d\n",jiffies)); + DBG("%d jiffies\n", jiffies); save_flags(flags); clf(); @@ -892,7 +889,7 @@ static void fd_readtrack_check(unsigned /* get the current DMA address */ addr=(unsigned long)fdc1772_dataaddr; /* DAG - ? */ - DPRINT(("fd_readtrack_check: addr=%x PhysTrackBuffer=%x\n",addr,PhysTrackBuffer)); + DBG("addr=%x PhysTrackBuffer=%x\n",addr,PhysTrackBuffer); if (addr >= (unsigned int)PhysTrackBuffer + unit[SelectedDrive].disktype->spt*512) { /* already read enough data, force an FDC interrupt to stop @@ -900,7 +897,7 @@ static void fd_readtrack_check(unsigned */ SET_IRQ_HANDLER( NULL ); restore_flags(flags); - DPRINT(("fd_readtrack_check(): done\n")); + DBG("done\n"); FDC1772_WRITE( FDC1772REG_CMD, FDC1772CMD_FORCI ); udelay(25); @@ -911,7 +908,7 @@ static void fd_readtrack_check(unsigned } else { /* not yet finished, wait another tenth rotation */ restore_flags(flags); - DPRINT(("fd_readtrack_check(): not yet finished\n")); + DBG("not yet finished\n"); readtrack_timer.expires = jiffies + HZ/5/10; add_timer( &readtrack_timer ); } @@ -923,7 +920,7 @@ static void fd_rwsec_done(int status) { unsigned int track; - DPRINT(("fd_rwsec_done() status=%d @ %d\n", status,jiffies)); + DBG("status=%d @ %d\n", status,jiffies); #ifdef TRACKBUFFER if (read_track && !MultReadInProgress) @@ -945,7 +942,7 @@ static void fd_rwsec_done(int status) unit[SelectedDrive].disktype->stretch); } if (ReqCmd == WRITE && (status & FDC1772STAT_WPROT)) { - printk("fd%d: is write protected\n", SelectedDrive); + printk(KERN_ERR "fd%d: is write protected\n", SelectedDrive); goto err_end; } if ((status & FDC1772STAT_RECNF) @@ -982,17 +979,17 @@ static void fd_rwsec_done(int status) do_fd_action(SelectedDrive); return; } - printk("fd%d: sector %d not found (side %d, track %d)\n", + printk(KERN_ERR "fd%d: sector %d not found (side %d, track %d)\n", SelectedDrive, FDC1772_READ(FDC1772REG_SECTOR), ReqSide, ReqTrack); goto err_end; } if (status & FDC1772STAT_CRC) { - printk("fd%d: CRC error (side %d, track %d, sector %d)\n", + printk(KERN_ERR "fd%d: CRC error (side %d, track %d, sector %d)\n", SelectedDrive, ReqSide, ReqTrack, FDC1772_READ(FDC1772REG_SECTOR)); goto err_end; } if (status & FDC1772STAT_LOST) { - printk("fd%d: lost data (side %d, track %d, sector %d)\n", + printk(KERN_ERR "fd%d: lost data (side %d, track %d, sector %d)\n", SelectedDrive, ReqSide, ReqTrack, FDC1772_READ(FDC1772REG_SECTOR)); goto err_end; } @@ -1046,7 +1043,7 @@ static void fd_times_out(unsigned long d FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI); udelay(25); - printk("floppy timeout\n"); + printk(KERN_WARNING "floppy timeout\n"); STOP_TIMEOUT(); /* hmm - should we do this ? */ fd_error(); } @@ -1068,7 +1065,7 @@ static void finish_fdc(void) if (!NeedSeek) { finish_fdc_done(0); } else { - DPRINT(("finish_fdc: dummy seek started\n")); + DBG("dummy seek started\n"); FDC1772_WRITE(FDC1772REG_DATA, unit[SelectedDrive].track); SET_IRQ_HANDLER(finish_fdc_done); FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK); @@ -1086,7 +1083,7 @@ static void finish_fdc_done(int dummy) { unsigned long flags; - DPRINT(("finish_fdc_done entered\n")); + DBG("start\n"); STOP_TIMEOUT(); NeedSeek = 0; @@ -1109,7 +1106,7 @@ static void finish_fdc_done(int dummy) wake_up(&fdc_wait); restore_flags(flags); - DPRINT(("finish_fdc() finished\n")); + DBG("end\n"); } @@ -1189,8 +1186,8 @@ static void setup_req_params(int drive) read_track = (ReqCmd == READ && CURRENT->errors == 0); #endif - DPRINT(("Request params: Si=%d Tr=%d Se=%d Data=%08lx\n", ReqSide, - ReqTrack, ReqSector, (unsigned long) ReqData)); + DBG("Request params: Si=%d Tr=%d Se=%d Data=%08lx\n", ReqSide, + ReqTrack, ReqSector, (unsigned long) ReqData); } @@ -1199,9 +1196,9 @@ static void redo_fd_request(void) int drive, type; struct archy_floppy_struct *floppy; - DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n", + DBG("CURRENT=%p dev=%s CURRENT->sector=%ld\n" CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "", - CURRENT ? CURRENT->sector : 0)); + CURRENT ? CURRENT->sector : 0); repeat: @@ -1214,7 +1211,7 @@ repeat: if (!floppy->connected) { /* drive not connected */ - printk("Unknown Device: fd%d\n", drive); + printk(KERN_ERR "Unknown Device: fd%d\n", drive); end_request(CURRENT, 0); goto repeat; } @@ -1229,7 +1226,7 @@ repeat: /* user supplied disk type */ --type; if (type >= NUM_DISK_TYPES) { - printk("fd%d: invalid disk format", drive); + printk(KERN_ERR "fd%d: invalid disk format", drive); end_request(CURRENT, 0); goto repeat; } @@ -1275,7 +1272,7 @@ static void do_fd_request(request_queue_ { unsigned long flags; - DPRINT(("do_fd_request for pid %d\n", current->pid)); + DBG("pid %d\n", current->pid); if (fdc_busy) return; save_flags(flags); cli(); @@ -1354,7 +1351,7 @@ static int fd_test_drive_present(int dri unsigned char status; int ok; - printk("fd_test_drive_present %d\n", drive); + DBG("drive %d\n", drive); if (drive > 1) return (0); return (1); /* Simple hack for the moment - the autodetect doesn't seem to work on arc */ @@ -1392,15 +1389,15 @@ static int fd_test_drive_present(int dri /* dummy seek command to make WP bit accessible */ FDC1772_WRITE(FDC1772REG_DATA, 0); FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK); - printk("fd_test_drive_present: just before wait for int\n"); + DBG("just before wait for int\n"); /* DAG: Guess means wait for interrupt */ while (!(ioc_readb(IOC_FIQSTAT) & 2)); - printk("fd_test_drive_present: just after wait for int\n"); + DBG("just after wait for int\n"); status = FDC1772_READ(FDC1772REG_STATUS); } - printk("fd_test_drive_present: just before ENABLE_IRQ\n"); + DBG("just before ENABLE_IRQ\n"); ENABLE_IRQ(); - printk("fd_test_drive_present: about to return\n"); + DBG("about to return\n"); return (ok); } @@ -1413,14 +1410,15 @@ static void config_types(void) { int drive, cnt = 0; - printk("Probing floppy drive(s):\n"); + pr_info("Probing floppy drive(s):"); for (drive = 0; drive < FD_MAX_UNITS; drive++) { fd_probe(drive); if (unit[drive].connected) { - printk("fd%d\n", drive); + printk(" fd%d", drive); ++cnt; } } + printk ("\n"); if (FDC1772_READ(FDC1772REG_STATUS) & FDC1772STAT_BUSY) { /* If FDC1772 is still busy from probing, give it another FORCI @@ -1490,7 +1488,7 @@ static int floppy_release(struct inode * if (fd_ref[drive] < 0) fd_ref[drive] = 0; else if (!fd_ref[drive]--) { - printk("floppy_release with fd_ref == 0"); + printk(KERN_WARNING "floppy_release with fd_ref == 0\n"); fd_ref[drive] = 0; } @@ -1535,12 +1533,12 @@ int fd1772_init(void) err = -EBUSY; if (request_dma(FLOPPY_DMA, "fd1772")) { - printk("Unable to grab DMA%d for the floppy (1772) driver\n", FLOPPY_DMA); + printk(KERN_ERR "Unable to grab DMA%d for the floppy (1772) driver\n", FLOPPY_DMA); goto err_blkdev; }; if (request_dma(FIQ_FD1772, "fd1772 end")) { - printk("Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772); + printk(KERN_ERR "Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772); goto err_dma1; }; --- a/drivers/acorn/block/mfmhd.c +++ b/drivers/acorn/block/mfmhd.c @@ -98,6 +98,8 @@ * This would be a performance boost with dual drive systems. */ +#undef DEBUG /* define to enable debugging statements */ + #include #include #include @@ -126,6 +128,7 @@ static void (*do_mfm)(void) = NULL; static struct request_queue *mfm_queue; static DEFINE_SPINLOCK(mfm_lock); +#define PFX "mfm: " #define MAJOR_NR MFM_ACORN_MAJOR #define QUEUE (mfm_queue) #define CURRENT elv_next_request(mfm_queue) @@ -140,12 +143,7 @@ static DEFINE_SPINLOCK(mfm_lock); * Linux I/O address of onboard MFM controller or 0 to disable this */ #define ONBOARD_MFM_ADDRESS ((0x002d0000 >> 2) | 0x80000000) -/* - * Uncomment this to enable debugging in the MFM driver... - */ -#ifndef DEBUG -/*#define DEBUG */ -#endif + /* * End of configuration */ @@ -287,28 +285,8 @@ int number_mfm_drives = 1; #define STAT_POL 0x0200 /* Polling */ /* ------------------------------------------------------------------------------------------ */ -#ifdef DEBUG -static void console_printf(const char *fmt,...) -{ - static char buffer[2048]; /* Arbitary! */ - extern void console_print(const char *); - unsigned long flags; - va_list ap; - - local_irq_save(flags); - - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - console_print(buffer); - va_end(fmt); - local_irq_restore(flags); -}; /* console_printf */ - -#define DBG(x...) console_printf(x) -#else -#define DBG(x...) -#endif +#define DBG(fmt, args...) pr_debug(PFX "%s: " fmt, __FUNCTION__ , ## args) static void print_status(void) { @@ -364,23 +342,23 @@ static void issue_command(int command, u int status; #ifdef DEBUG int i; - console_printf("issue_command: %02X: ", command); + DBG("%02X:", command); for (i = 0; i < len; i++) - console_printf("%02X ", cmdb[i]); - console_printf("\n"); + printk(" %02X", cmdb[i]); + printk("\n"); #endif do { status = inw(MFM_STATUS); } while (status & (STAT_BSY | STAT_POL)); - DBG("issue_command: status after pol/bsy loop: %02X:\n ", status >> 8); + DBG("status after pol/bsy loop: %02X:\n", status >> 8); if (status & (STAT_CPR | STAT_CED | STAT_SED | STAT_DER | STAT_ABN)) { outw(CMD_RCAL, MFM_COMMAND); while (inw(MFM_STATUS) & STAT_BSY); } status = inw(MFM_STATUS); - DBG("issue_command: status before parameter issue: %02X:\n ", status >> 8); + DBG("status before parameter issue: %02X:\n", status >> 8); while (len > 0) { outw(cmdb[1] | (cmdb[0] << 8), MFM_DATAOUT); @@ -388,11 +366,11 @@ static void issue_command(int command, u cmdb += 2; } status = inw(MFM_STATUS); - DBG("issue_command: status before command issue: %02X:\n ", status >> 8); + DBG("status before command issue: %02X:\n", status >> 8); outw(command, MFM_COMMAND); status = inw(MFM_STATUS); - DBG("issue_command: status immediately after command issue: %02X:\n ", status >> 8); + DBG("status immediately after command issue: %02X:\n", status >> 8); } static void wait_for_completion(void) @@ -421,7 +399,7 @@ static void mfm_rw_intr(void) { int old_status; /* Holds status on entry, we read to see if the command just finished */ #ifdef DEBUG - console_printf("mfm_rw_intr...dataleft=%d\n", hdc63463_dataleft); + DBG("dataleft=%d ", hdc63463_dataleft); print_status(); #endif @@ -430,7 +408,7 @@ static void mfm_rw_intr(void) /* Something has gone wrong - let's try that again */ outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ if (cont) { - DBG("mfm_rw_intr: DER/ABN err\n"); + DBG("DER/ABN err\n"); cont->error(); cont->redo(); }; @@ -444,7 +422,7 @@ static void mfm_rw_intr(void) if (CURRENT->cmd == WRITE) { extern void hdc63463_writedma(void); if ((hdc63463_dataleft <= 0) && (!(mfm_status & STAT_CED))) { - printk("mfm_rw_intr: Apparent DMA write request when no more to DMA\n"); + printk(KERN_WARNING PFX "mfm_rw_intr: Apparent DMA write request when no more to DMA\n"); if (cont) { cont->error(); cont->redo(); @@ -455,7 +433,7 @@ static void mfm_rw_intr(void) } else { extern void hdc63463_readdma(void); if ((hdc63463_dataleft <= 0) && (!(mfm_status & STAT_CED))) { - printk("mfm_rw_intr: Apparent DMA read request when no more to DMA\n"); + printk(KERN_WARNING PFX "mfm_rw_intr: Apparent DMA read request when no more to DMA\n"); if (cont) { cont->error(); cont->redo(); @@ -469,7 +447,7 @@ static void mfm_rw_intr(void) if (hdc63463_dataptr != ((unsigned int) Copy_buffer + 256)) { /* If we didn't actually manage to get any data on this interrupt - but why? We got the interrupt */ /* Ah - well looking at the status its just when we get command end; so no problem */ - /*console_printf("mfm: dataptr mismatch. dataptr=0x%08x Copy_buffer+256=0x%08p\n", + /*DBG("dataptr mismatch. dataptr=0x%08x Copy_buffer+256=0x%08p ", hdc63463_dataptr,Copy_buffer+256); print_status(); */ } else { @@ -479,7 +457,7 @@ static void mfm_rw_intr(void) /* We have come to the end of this request */ if (!Sectors256LeftInCurrent) { - DBG("mfm: end_request for CURRENT=0x%p CURRENT(sector=%d current_nr_sectors=%d nr_sectors=%d)\n", + DBG("end_request for CURRENT=0x%p CURRENT(sector=%d current_nr_sectors=%d nr_sectors=%d)\n", CURRENT, CURRENT->sector, CURRENT->current_nr_sectors, CURRENT->nr_sectors); CURRENT->nr_sectors -= CURRENT->current_nr_sectors; @@ -498,10 +476,10 @@ static void mfm_rw_intr(void) if (Copy_Sector != CURRENT->sector * 2) #ifdef DEBUG - /*console_printf*/printk("mfm: Copy_Sector mismatch. Copy_Sector=%d CURRENT->sector*2=%d\n", + DBG("Copy_Sector mismatch. Copy_Sector=%d CURRENT->sector*2=%d\n", Copy_Sector, CURRENT->sector * 2); #else - printk("mfm: Copy_Sector mismatch! Eek!\n"); + printk(KERN_ERR PFX "Copy_Sector mismatch! Eek!\n"); #endif }; /* CURRENT */ }; /* Sectors256LeftInCurrent */ @@ -512,7 +490,7 @@ static void mfm_rw_intr(void) if (mfm_status & (STAT_DER | STAT_ABN)) { /* Something has gone wrong - let's try that again */ if (cont) { - DBG("mfm_rw_intr: DER/ABN error\n"); + DBG("DER/ABN error\n"); cont->error(); cont->redo(); }; @@ -534,7 +512,7 @@ static void mfm_rw_intr(void) }; }; /* Result read */ - /*console_printf ("mfm_rw_intr nearexit [%02X]\n", __raw_readb(mfm_IRQPollLoc)); */ + /*DBG("nearexit [%02X]\n", __raw_readb(mfm_IRQPollLoc)); */ /* If end of command move on */ if (mfm_status & (STAT_CED)) { @@ -543,7 +521,7 @@ static void mfm_rw_intr(void) if (cont) { cont->done(1); } - DBG("mfm_rw_intr: returned from cont->done\n"); + DBG("returned from cont->done\n"); } else { /* Its going to generate another interrupt */ do_mfm = mfm_rw_intr; @@ -552,7 +530,7 @@ static void mfm_rw_intr(void) static void mfm_setup_rw(void) { - DBG("setting up for rw...\n"); + DBG("start\n"); do_mfm = mfm_rw_intr; issue_command(raw_cmd.cmdcode, raw_cmd.cmddata, raw_cmd.cmdlen); @@ -561,12 +539,12 @@ static void mfm_setup_rw(void) static void mfm_recal_intr(void) { #ifdef DEBUG - console_printf("recal intr - status = "); + DBG("status = "); print_status(); #endif outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ if (mfm_status & (STAT_DER | STAT_ABN)) { - printk("recal failed\n"); + printk(KERN_ERR PFX "recal failed\n"); MFM_DRV_INFO.cylinder = NEED_2_RECAL; if (cont) { cont->error(); @@ -588,18 +566,18 @@ static void mfm_recal_intr(void) issue_command(CMD_POL, NULL, 0); return; } - printk("recal: unknown status\n"); + printk(KERN_ERR PFX "recal: unknown status\n"); } static void mfm_seek_intr(void) { #ifdef DEBUG - console_printf("seek intr - status = "); + DBG("status = "); print_status(); #endif outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ if (mfm_status & (STAT_DER | STAT_ABN)) { - printk("seek failed\n"); + printk(KERN_ERR PFX "seek failed\n"); MFM_DRV_INFO.cylinder = NEED_2_RECAL; if (cont) { cont->error(); @@ -618,7 +596,7 @@ static void mfm_seek_intr(void) issue_command(CMD_POL, NULL, 0); return; } - printk("seek: unknown status\n"); + printk(KERN_ERR PFX "seek: unknown status\n"); } /* IDEA2 seems to work better - its what RiscOS sets my @@ -673,7 +651,7 @@ static void mfm_seek(void) DBG("seeking...\n"); if (MFM_DRV_INFO.cylinder < 0) { do_mfm = mfm_recal_intr; - DBG("mfm_seek: about to call specify\n"); + DBG("about to call specify\n"); mfm_specify (); /* DAG added this */ cmdb[0] = raw_cmd.dev + 1; @@ -696,19 +674,20 @@ static void mfm_seek(void) static void mfm_initialise(void) { - DBG("init...\n"); + DBG("start\n"); mfm_seek(); } static void request_done(int uptodate) { - DBG("mfm:request_done\n"); + DBG("start\n"); if (uptodate) { unsigned char block[2] = {0, 0}; /* Apparently worked - let's check bytes left to DMA */ if (hdc63463_dataleft != (PartFragRead_SectorsLeft * 256)) { - printk("mfm: request_done - dataleft=%d - should be %d - Eek!\n", hdc63463_dataleft, PartFragRead_SectorsLeft * 256); + printk(KERN_ERR PFX "request_done - dataleft=%d - should be %d - Eek!\n", + hdc63463_dataleft, PartFragRead_SectorsLeft * 256); end_request(CURRENT, 0); Busy = 0; }; @@ -727,7 +706,8 @@ static void request_done(int uptodate) /* ah well - perhaps there is another fragment to go */ /* Increment pointers/counts to start of next fragment */ - if (SectorsLeftInRequest > 0) printk("mfm: SectorsLeftInRequest>0 - Eek! Shouldn't happen!\n"); + if (SectorsLeftInRequest > 0) + printk(KERN_CRIT PFX "SectorsLeftInRequest > 0 - Eek! Shouldn't happen!\n"); /* No - its the end of the line */ /* end_request's should have happened at the end of sector DMAs */ @@ -736,12 +716,12 @@ static void request_done(int uptodate) issue_command(CMD_CKV, block, 2); Busy = 0; - DBG("request_done: About to mfm_request\n"); + DBG("About to mfm_request\n"); /* Next one please */ mfm_request(); /* Moved from mfm_rw_intr */ - DBG("request_done: returned from mfm_request\n"); + DBG("returned from mfm_request\n"); } else { - printk("mfm:request_done: update=0\n"); + DBG("update=0\n"); end_request(CURRENT, 0); Busy = 0; } @@ -749,7 +729,7 @@ static void request_done(int uptodate) static void error_handler(void) { - printk("error detected... status = "); + printk(KERN_ERR PFX "error detected... status = "); print_status(); (*errors)++; if (*errors > MFM_DRV_INFO.errors.abort) @@ -760,7 +740,7 @@ static void error_handler(void) static void rw_interrupt(void) { - printk("rw_interrupt\n"); + DBG("start\n"); } static struct cont rw_cont = @@ -794,7 +774,7 @@ static void issue_request(unsigned int b /* Then add in the number of sectors left on this track */ sectors_to_next_cyl += (p->sectors - start_sector); - DBG("issue_request: mfm_info[dev].sectors=%d track=%d\n", p->sectors, track); + DBG("mfm_info[dev].sectors=%d track=%d\n", p->sectors, track); raw_cmd.dev = dev; raw_cmd.sector = start_sector; @@ -856,7 +836,7 @@ static void issue_request(unsigned int b */ static void mfm_rerequest(void) { - DBG("mfm_rerequest\n"); + DBG("start\n"); cli(); Busy = 0; mfm_request(); @@ -866,12 +846,12 @@ static struct gendisk *mfm_gendisk[2]; static void mfm_request(void) { - DBG("mfm_request CURRENT=%p Busy=%d\n", CURRENT, Busy); + DBG("CURRENT=%p Busy=%d\n", CURRENT, Busy); /* If we are still processing then return; we will get called again */ if (Busy) { /* Again seems to be common in 1.3.45 */ - /*DBG*/printk("mfm_request: Exiting due to busy\n"); + DBG("Exiting due to busy\n"); return; } Busy = 1; @@ -880,28 +860,28 @@ static void mfm_request(void) unsigned int block, nsect; struct gendisk *disk; - DBG("mfm_request: loop start\n"); + DBG("loop start\n"); sti(); - DBG("mfm_request: before !CURRENT\n"); + DBG("before !CURRENT\n"); if (!CURRENT) { - printk("mfm_request: Exiting due to empty queue (pre)\n"); + DBG("Exiting due to empty queue (pre)\n"); do_mfm = NULL; Busy = 0; return; } - DBG("mfm_request: before arg extraction\n"); + DBG("before arg extraction\n"); disk = CURRENT->rq_disk; block = CURRENT->sector; nsect = CURRENT->nr_sectors; if (block >= get_capacity(disk) || block+nsect > get_capacity(disk)) { - printk("%s: bad access: block=%d, count=%d, nr_sects=%ld\n", + printk(KERN_ERR "%s: bad access: block=%d, count=%d, nr_sects=%ld\n", disk->disk_name, block, nsect, get_capacity(disk)); - printk("mfm: continue 1\n"); + DBG("continue 1\n"); end_request(CURRENT, 0); Busy = 0; continue; @@ -917,25 +897,25 @@ static void mfm_request(void) Copy_buffer = CURRENT->buffer; Copy_Sector = CURRENT->sector << 1; - DBG("mfm_request: block after offset=%d\n", block); + DBG("block after offset=%d\n", block); if (CURRENT->cmd != READ && CURRENT->cmd != WRITE) { - printk("unknown mfm-command %d\n", CURRENT->cmd); + printk(KERN_ERR "unknown mfm-command %d\n", CURRENT->cmd); end_request(CURRENT, 0); Busy = 0; - printk("mfm: continue 4\n"); + DBG("continue 4\n"); continue; } issue_request(block, nsect, CURRENT); break; } - DBG("mfm_request: Dropping out bottom\n"); + DBG("Dropping out bottom\n"); } static void do_mfm_request(request_queue_t *q) { - DBG("do_mfm_request: about to mfm_request\n"); + DBG("about to mfm_request\n"); mfm_request(); } @@ -945,7 +925,7 @@ static void mfm_interrupt_handler(int un do_mfm = NULL; - DBG("mfm_interrupt_handler (handler=0x%p)\n", handler); + DBG("(handler=0x%p)\n", handler); mfm_status = inw(MFM_STATUS); @@ -965,7 +945,7 @@ static void mfm_interrupt_handler(int un return; } outw (CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */ - printk ("mfm: unexpected interrupt - status = "); + printk (KERN_WARNING PFX "unexpected interrupt - status = "); print_status (); while (1); } @@ -983,7 +963,7 @@ static void mfm_geometry(int drive) struct gendisk *disk = mfm_gendisk[drive]; disk->private_data = p; if (p->cylinders) - printk ("%s: %dMB CHS=%d/%d/%d LCC=%d RECOMP=%d\n", + pr_info ("%s: %dMB CHS=%d/%d/%d LCC=%d RECOMP=%d\n", disk->disk_name, p->cylinders * p->heads * p->sectors / 4096, p->cylinders, p->heads, p->sectors, @@ -1095,7 +1075,8 @@ static int mfm_initdrives(void) if (number_mfm_drives > MFM_MAXDRIVES) { number_mfm_drives = MFM_MAXDRIVES; - printk("No. of ADFS MFM drives is greater than MFM_MAXDRIVES - you can't have that many!\n"); + printk(KERN_WARNING "No. of ADFS MFM drives is greater than " + "MFM_MAXDRIVES - you can't have that many!\n"); } for (drive = 0; drive < number_mfm_drives; drive++) { @@ -1177,7 +1158,7 @@ void xd_set_geometry(struct block_device p->cylinders = discsize / (secsptrack * heads * secsize); if ((heads < 1) || (p->cylinders > 1024)) { - printk("%s: Insane disc shape! Setting to 512/4/32\n", + printk(KERN_WARNING "%s: Insane disc shape! Setting to 512/4/32\n", bdev->bd_disk->disk_name); /* These values are fairly arbitary, but are there so that if your @@ -1238,7 +1219,7 @@ static int mfm_do_init(unsigned char irq { int i, ret; - printk("mfm: found at address %08X, interrupt %d\n", mfm_addr, mfm_irq); + pr_info(PFX "controller found at address %08X, interrupt %d\n", mfm_addr, mfm_irq); ret = -EBUSY; if (!request_region (mfm_addr, 10, "mfm")) @@ -1277,11 +1258,11 @@ static int mfm_do_init(unsigned char irq mfm_gendisk[i] = disk; } - printk("mfm: detected %d hard drive%s\n", mfm_drives, + pr_info(PFX "detected %d hard drive%s\n", mfm_drives, mfm_drives == 1 ? "" : "s"); ret = request_irq(mfm_irq, mfm_interrupt_handler, SA_INTERRUPT, "MFM harddisk", NULL); if (ret) { - printk("mfm: unable to get IRQ%d\n", mfm_irq); + printk(KERN_ERR PFX "unable to get IRQ%d\n", mfm_irq); goto out4; } --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -55,11 +55,10 @@ pcf8583_attach(struct i2c_adapter *adap, } }; - c = kmalloc(sizeof(*c), GFP_KERNEL); + c = kzalloc(sizeof(*c), GFP_KERNEL); if (!c) return -ENOMEM; - memset(c, 0, sizeof(*c)); c->addr = addr; c->adapter = adap; c->driver = &pcf8583_driver; --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c @@ -750,14 +750,14 @@ static int proc_write_brn(struct file *file, const char __user * buffer, unsigned long count, void *data) { - int value; + int value, i; - count = parse_arg(buffer, count, &value); - if (count > 0) { + i = parse_arg(buffer, count, &value); + if (i > 0) { value = (0 < value) ? ((15 < value) ? 15 : value) : 0; /* 0 <= value <= 15 */ set_brightness(value); - } else if (count < 0) { + } else if (i < 0) { printk(KERN_WARNING "Asus ACPI: Error reading user input\n"); } @@ -800,12 +800,12 @@ static int proc_write_disp(struct file *file, const char __user * buffer, unsigned long count, void *data) { - int value; + int value,i; - count = parse_arg(buffer, count, &value); - if (count > 0) + i = parse_arg(buffer, count, &value); + if (i > 0) set_display(value); - else if (count < 0) + else if (i < 0) printk(KERN_WARNING "Asus ACPI: Error reading user input\n"); return count; --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c @@ -164,7 +164,7 @@ static void container_notify_cb(acpi_han case ACPI_NOTIFY_BUS_CHECK: /* Fall through */ case ACPI_NOTIFY_DEVICE_CHECK: - printk("Container driver received %s event\n", + printk(KERN_INFO "Container driver received %s event\n", (type == ACPI_NOTIFY_BUS_CHECK) ? "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); status = acpi_bus_get_device(handle, &device); --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -1169,9 +1169,8 @@ acpi_ec_io_ports(struct acpi_resource *r addr = &ec->common.data_addr; } else if (ec->common.command_addr.register_bit_width == 0) { addr = &ec->common.command_addr; - } else { + } else return AE_CTRL_TERMINATE; - } addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; addr->register_bit_width = 8; --- a/drivers/acpi/hotkey.c +++ b/drivers/acpi/hotkey.c @@ -723,6 +723,8 @@ get_parms(char *config_record, goto do_fail; count = tmp1 - tmp; *action_handle = (char *)kmalloc(count + 1, GFP_KERNEL); + if (!*action_handle) + goto do_fail; strncpy(*action_handle, tmp, count); *(*action_handle + count) = 0; --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -305,7 +305,7 @@ acpi_status acpi_os_remove_interrupt_han void acpi_os_sleep(acpi_integer ms) { - schedule_timeout_interruptible(msecs_to_jiffies(ms)); + msleep_interruptible((unsigned int)ms); } EXPORT_SYMBOL(acpi_os_sleep); @@ -801,7 +801,7 @@ acpi_status acpi_os_wait_semaphore(acpi_ // TODO: A better timeout algorithm? { int i = 0; - static const int quantum_ms = 1000 / HZ; + unsigned int quantum_ms = jiffies_to_msecs(1); ret = down_trylock(sem); for (i = timeout; (i > 0 && ret != 0); i -= quantum_ms) { --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c @@ -361,7 +361,7 @@ static int acpi_pci_link_set(struct acpi /* ignore resource_source, it's optional */ break; default: - printk("ACPI BUG: resource_type %d\n", link->irq.resource_type); + printk(KERN_ERR "ACPI BUG: resource_type %d\n", link->irq.resource_type); result = -EINVAL; goto end; --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -229,7 +229,6 @@ static int acpi_pci_root_add(struct acpi if ((tmp->id.segment == root->id.segment) && (tmp->id.bus == root->id.bus)) { int bus = 0; - acpi_status status; ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c @@ -137,9 +137,8 @@ static int __init acpi_system_init(void) entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); if (!entry) goto Error; - else { + else entry->proc_fops = &acpi_system_info_ops; - } /* 'dsdt' [R] */ name = ACPI_SYSTEM_FILE_DSDT; --- a/drivers/atm/adummy.c +++ b/drivers/atm/adummy.c @@ -4,7 +4,6 @@ #include #include -#include #include #include #include --- a/drivers/atm/firestream.c +++ b/drivers/atm/firestream.c @@ -615,11 +615,11 @@ static void submit_qentry (struct fs_dev static int c; if (!(c++ % 100)) { - int rp, wp; + int rp, w; rp = read_fs (dev, Q_RP(q->offset)); - wp = read_fs (dev, Q_WP(q->offset)); + w = read_fs (dev, Q_WP(q->offset)); fs_dprintk (FS_DEBUG_TXQ, "q at %d: %x-%x: %x entries.\n", - q->offset, rp, wp, wp-rp); + q->offset, rp, w, w-rp); } } } @@ -734,8 +734,8 @@ static void process_txdone_queue (struct skb = td->skb; if (skb == FS_VCC (ATM_SKB(skb)->vcc)->last_skb) { - wake_up_interruptible (& FS_VCC (ATM_SKB(skb)->vcc)->close_wait); FS_VCC (ATM_SKB(skb)->vcc)->last_skb = NULL; + wake_up_interruptible (& FS_VCC (ATM_SKB(skb)->vcc)->close_wait); } td->dev->ntxpckts--; @@ -1113,10 +1113,10 @@ static void fs_close(struct atm_vcc *atm be impolite not to send them don't you think? XXX We don't know which packets didn't get sent. So if we get interrupted in - this sleep_on, we'll lose any reference to these packets. Memory leak! + this wait_event, we'll lose any reference to these packets. Memory leak! On the other hand, it's awfully convenient that we can abort a "close" that is taking too long. Maybe just use non-interruptible sleep on? -- REW */ - interruptible_sleep_on (& vcc->close_wait); + wait_event_interruptible (vcc->close_wait, !vcc->last_skb); } txtp = &atm_vcc->qos.txtp; --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -1905,7 +1905,7 @@ static int push_scqe(ns_dev *card, vc_ma scq->full = 1; spin_unlock_irqrestore(&scq->lock, flags); - interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT); + wait_event_interruptible_timeout(scq->scqfull_waitq, !scq->full, SCQFULL_TIMEOUT); ns_grab_scq_lock(card, scq, flags); if (scq->full) { @@ -1954,7 +1954,7 @@ static int push_scqe(ns_dev *card, vc_ma scq->full = 1; if (has_run++) break; spin_unlock_irqrestore(&scq->lock, flags); - interruptible_sleep_on_timeout(&scq->scqfull_waitq, SCQFULL_TIMEOUT); + wait_event_interruptible_timeout(scq->scqfull_waitq, !scq->full, SCQFULL_TIMEOUT); ns_grab_scq_lock(card, scq, flags); } --- a/drivers/block/acsi_slm.c +++ b/drivers/block/acsi_slm.c @@ -67,6 +67,7 @@ not be guaranteed. There are several way #include #include #include +#include #include #include @@ -623,12 +624,10 @@ static ssize_t slm_write( struct file *f int device = iminor(node); int n, filled, w, h; - while( SLMState == PRINTING || - (SLMState == FILLING && SLMBufOwner != device) ) { - interruptible_sleep_on( &slm_wait ); - if (signal_pending(current)) - return( -ERESTARTSYS ); - } + wait_event_interruptible(slm_wait, (SLMState != PRINTING && + (SLMState != FILLING || SLMBufOwner == device))); + if (signal_pending(current)) + return -ERESTARTSYS; if (SLMState == IDLE) { /* first data of page: get current page size */ if (slm_get_pagesize( device, &w, &h )) @@ -652,6 +651,7 @@ static ssize_t slm_write( struct file *f filled += n; if (filled == BufferSize) { + DEFINE_WAIT(wait); /* Check the paper size again! The user may have switched it in the * time between starting the data and finishing them. Would end up in * a trashy page... */ @@ -670,7 +670,9 @@ static ssize_t slm_write( struct file *f #endif start_print( device ); - sleep_on( &print_wait ); + prepare_to_wait(&print_wait, &wait, TASK_UNINTERRUPTIBLE); + schedule(); + finish_wait(&print_wait, &wait); if (SLMError && IS_REAL_ERROR(SLMError)) { printk( KERN_ERR "slm%d: %s\n", device, slm_errstr(SLMError) ); n = -EIO; --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -367,7 +367,10 @@ static void __devinit cciss_procinit(int pde = create_proc_read_entry(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, proc_cciss, cciss_proc_get_info, hba[i]); - pde->write_proc = cciss_proc_write; + if (!pde) + printk(KERN_WARNING "cciss: unable to create /proc entry\n"); + else + pde->write_proc = cciss_proc_write; } #endif /* CONFIG_PROC_FS */ @@ -2816,8 +2819,7 @@ static int cciss_pci_init(ctlr_info_t *c scratchpad = readl(c->vaddr + SA5_SCRATCHPAD_OFFSET); if (scratchpad == CCISS_FIRMWARE_READY) break; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ / 10); /* wait 100ms */ + msleep(100); } if (scratchpad != CCISS_FIRMWARE_READY) { printk(KERN_WARNING "cciss: Board not ready. Timed out.\n"); --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -65,8 +66,6 @@ MODULE_LICENSE("GPL"); #define MAX_CTLR 8 #define CTLR_SHIFT 8 -#define CPQARRAY_DMA_MASK 0xFFFFFFFF /* 32 bit DMA */ - static int nr_ctlr; static ctlr_info_t *hba[MAX_CTLR]; @@ -215,13 +214,18 @@ static struct proc_dir_entry *proc_array */ static void __init ida_procinit(int i) { + struct proc_dir_entry *ent; + if (proc_array == NULL) { proc_array = proc_mkdir("cpqarray", proc_root_driver); if (!proc_array) return; } - create_proc_read_entry(hba[i]->devname, 0, proc_array, + ent = create_proc_read_entry(hba[i]->devname, 0, proc_array, ida_proc_get_info, hba[i]); + if (!ent) + printk(KERN_WARNING + "cpqarray: unable to create /proc entry\n"); } /* @@ -628,7 +632,7 @@ static int cpqarray_pci_init(ctlr_info_t for(i=0; i<6; i++) addr[i] = pci_resource_start(pdev, i); - if (pci_set_dma_mask(pdev, CPQARRAY_DMA_MASK) != 0) + if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) { printk(KERN_ERR "cpqarray: Unable to set DMA mask\n"); return -1; --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include "DAC960.h" @@ -2519,7 +2520,7 @@ static boolean DAC960_RegisterBlockDevic /* for now, let all request queues share controller's lock */ RequestQueue = blk_init_queue(DAC960_RequestFunction,&Controller->queue_lock); if (!RequestQueue) { - printk("DAC960: failure to allocate request queue\n"); + printk(KERN_WARNING "DAC960: failure to allocate request queue\n"); continue; } Controller->RequestQueue[n] = RequestQueue; @@ -3591,7 +3592,7 @@ static void DAC960_V1_ProcessCompletedCo #ifdef FORCE_RETRY_FAILURE_DEBUG if (!(++retry_count % 10000)) { - printk("V1 error retry failure test\n"); + printk(KERN_DEBUG "V1 error retry failure test\n"); normal_completion = false; DAC960_V1_ReadWriteError(Command); } @@ -4679,7 +4680,7 @@ static void DAC960_V2_ProcessCompletedCo #ifdef FORCE_RETRY_FAILURE_DEBUG if (!(++retry_count % 10000)) { - printk("V2 error retry failure test\n"); + printk(KERN_DEBUG "V2 error retry failure test\n"); normal_completion = false; DAC960_V2_ReadWriteError(Command); } @@ -6224,6 +6225,7 @@ static boolean DAC960_V2_TranslatePhysic static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller, unsigned char *UserCommand) { + DEFINE_WAIT(wait); DAC960_Command_T *Command; DAC960_V2_CommandMailbox_T *CommandMailbox; unsigned long flags; @@ -6414,7 +6416,9 @@ static boolean DAC960_V2_ExecuteUserComm while (Controller->V2.NewControllerInformation->PhysicalScanActive) { DAC960_ExecuteCommand(Command); - sleep_on_timeout(&Controller->CommandWaitQueue, HZ); + prepare_to_wait(&Controller->CommandWaitQueue, &wait, TASK_UNINTERRUPTIBLE); + schedule_timeout(HZ); + finish_wait(&Controller->CommandWaitQueue, &wait); } DAC960_UserCritical("Discovery Completed\n", Controller); } @@ -7014,15 +7018,13 @@ static int DAC960_gam_ioctl(struct inode GetHealthStatus.HealthStatusBuffer, sizeof(DAC960_V2_HealthStatusBuffer_T))) return -EFAULT; - while (Controller->V2.HealthStatusBuffer->StatusChangeCounter - == HealthStatusBuffer.StatusChangeCounter && - Controller->V2.HealthStatusBuffer->NextEventSequenceNumber - == HealthStatusBuffer.NextEventSequenceNumber) - { - interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue, - DAC960_MonitoringTimerInterval); - if (signal_pending(current)) return -EINTR; - } + wait_event_interruptible_timeout(Controller->HealthStatusWaitQueue, + (Controller->V2.HealthStatusBuffer->StatusChangeCounter + != HealthStatusBuffer.StatusChangeCounter || + Controller->V2.HealthStatusBuffer->NextEventSequenceNumber + != HealthStatusBuffer.NextEventSequenceNumber), + DAC960_MonitoringTimerInterval); + if (signal_pending(current)) return -EINTR; if (copy_to_user(GetHealthStatus.HealthStatusBuffer, Controller->V2.HealthStatusBuffer, sizeof(DAC960_V2_HealthStatusBuffer_T))) --- a/drivers/block/paride/comm.c +++ b/drivers/block/paride/comm.c @@ -180,7 +180,7 @@ static void comm_log_adapter( PIA *pi, c { char *mode_string[5] = {"4-bit","8-bit","EPP-8","EPP-16","EPP-32"}; - printk("%s: comm %s, DataStor Commuter at 0x%x, ", + printk(KERN_INFO "%s: comm %s, DataStor Commuter at 0x%x, ", pi->device,COMM_VERSION,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/dstr.c +++ b/drivers/block/paride/dstr.c @@ -195,7 +195,7 @@ static void dstr_log_adapter( PIA *pi, c { char *mode_string[5] = {"4-bit","8-bit","EPP-8", "EPP-16","EPP-32"}; - printk("%s: dstr %s, DataStor EP2000 at 0x%x, ", + printk(KERN_INFO "%s: dstr %s, DataStor EP2000 at 0x%x, ", pi->device,DSTR_VERSION,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/epat.c +++ b/drivers/block/paride/epat.c @@ -280,7 +280,7 @@ static int epat_test_proto( PIA *pi, cha epat_disconnect(pi); if (verbose) { - printk("%s: epat: port 0x%x, mode %d, ccr %x, test=(%d,%d,%d)\n", + printk(KERN_DEBUG "%s: epat: port 0x%x, mode %d, ccr %x, test=(%d,%d,%d)\n", pi->device,pi->port,pi->mode,cc,e[0],e[1],f); } @@ -298,7 +298,7 @@ static void epat_log_adapter( PIA *pi, c ver = RR(0xb); epat_disconnect(pi); - printk("%s: epat %s, Shuttle EPAT chip %x at 0x%x, ", + printk(KERN_INFO "%s: epat %s, Shuttle EPAT chip %x at 0x%x, ", pi->device,EPAT_VERSION,ver,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/epia.c +++ b/drivers/block/paride/epia.c @@ -263,7 +263,7 @@ static int epia_test_proto( PIA *pi, cha epia_disconnect(pi); if (verbose) { - printk("%s: epia: port 0x%x, mode %d, test=(%d,%d,%d)\n", + printk(KERN_DEBUG "%s: epia: port 0x%x, mode %d, test=(%d,%d,%d)\n", pi->device,pi->port,pi->mode,e[0],e[1],f); } @@ -277,7 +277,7 @@ static void epia_log_adapter( PIA *pi, c { char *mode_string[6] = {"4-bit","5/3","8-bit", "EPP-8","EPP-16","EPP-32"}; - printk("%s: epia %s, Shuttle EPIA at 0x%x, ", + printk(KERN_INFO "%s: epia %s, Shuttle EPIA at 0x%x, ", pi->device,EPIA_VERSION,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/fit2.c +++ b/drivers/block/paride/fit2.c @@ -115,7 +115,7 @@ static void fit2_disconnect ( PIA *pi ) static void fit2_log_adapter( PIA *pi, char * scratch, int verbose ) -{ printk("%s: fit2 %s, FIT 2000 adapter at 0x%x, delay %d\n", +{ printk(KERN_INFO "%s: fit2 %s, FIT 2000 adapter at 0x%x, delay %d\n", pi->device,FIT2_VERSION,pi->port,pi->delay); } --- a/drivers/block/paride/fit3.c +++ b/drivers/block/paride/fit3.c @@ -173,7 +173,7 @@ static void fit3_log_adapter( PIA *pi, c { char *mode_string[3] = {"4-bit","8-bit","EPP"}; - printk("%s: fit3 %s, FIT 3000 adapter at 0x%x, " + printk(KERN_INFO "%s: fit3 %s, FIT 3000 adapter at 0x%x, " "mode %d (%s), delay %d\n", pi->device,FIT3_VERSION,pi->port, pi->mode,mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/friq.c +++ b/drivers/block/paride/friq.c @@ -208,7 +208,7 @@ static int friq_test_proto( PIA *pi, cha friq_disconnect(pi); if (verbose) { - printk("%s: friq: port 0x%x, mode %d, test=(%d,%d,%d)\n", + printk(KERN_DEBUG "%s: friq: port 0x%x, mode %d, test=(%d,%d,%d)\n", pi->device,pi->port,pi->mode,e[0],e[1],r); } @@ -221,7 +221,7 @@ static void friq_log_adapter( PIA *pi, c { char *mode_string[6] = {"4-bit","8-bit", "EPP-8","EPP-16","EPP-32"}; - printk("%s: friq %s, Freecom IQ ASIC-2 adapter at 0x%x, ", pi->device, + printk(KERN_INFO "%s: friq %s, Freecom IQ ASIC-2 adapter at 0x%x, ", pi->device, FRIQ_VERSION,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/frpw.c +++ b/drivers/block/paride/frpw.c @@ -231,14 +231,14 @@ static int frpw_test_proto( PIA *pi, cha if (((pi->private%2) == 0) && (pi->mode > 2)) { if (verbose) - printk("%s: frpw: Xilinx does not support mode %d\n", + printk(KERN_DEBUG "%s: frpw: Xilinx does not support mode %d\n", pi->device, pi->mode); return 1; } if (((pi->private%2) == 1) && (pi->mode == 2)) { if (verbose) - printk("%s: frpw: ASIC does not support mode 2\n", + printk(KERN_DEBUG "%s: frpw: ASIC does not support mode 2\n", pi->device); return 1; } @@ -261,7 +261,7 @@ static int frpw_test_proto( PIA *pi, cha frpw_disconnect(pi); if (verbose) { - printk("%s: frpw: port 0x%x, chip %ld, mode %d, test=(%d,%d,%d)\n", + printk(KERN_DEBUG "%s: frpw: port 0x%x, chip %ld, mode %d, test=(%d,%d,%d)\n", pi->device,pi->port,(pi->private%2),pi->mode,e[0],e[1],r); } @@ -274,7 +274,7 @@ static void frpw_log_adapter( PIA *pi, c { char *mode_string[6] = {"4-bit","8-bit","EPP", "EPP-8","EPP-16","EPP-32"}; - printk("%s: frpw %s, Freecom (%s) adapter at 0x%x, ", pi->device, + printk(KERN_INFO "%s: frpw %s, Freecom (%s) adapter at 0x%x, ", pi->device, FRPW_VERSION,((pi->private%2) == 0)?"Xilinx":"ASIC",pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/kbic.c +++ b/drivers/block/paride/kbic.c @@ -232,7 +232,7 @@ static void kbic_log_adapter( PIA *pi, c { char *mode_string[6] = {"4-bit","5/3","8-bit", "EPP-8","EPP_16","EPP-32"}; - printk("%s: kbic %s, KingByte %s at 0x%x, ", + printk(KERN_INFO "%s: kbic %s, KingByte %s at 0x%x, ", pi->device,KBIC_VERSION,chip,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/ktti.c +++ b/drivers/block/paride/ktti.c @@ -92,7 +92,7 @@ static void ktti_disconnect ( PIA *pi ) static void ktti_log_adapter( PIA *pi, char * scratch, int verbose ) -{ printk("%s: ktti %s, KT adapter at 0x%x, delay %d\n", +{ printk(KERN_INFO "%s: ktti %s, KT adapter at 0x%x, delay %d\n", pi->device,KTTI_VERSION,pi->port,pi->delay); } --- a/drivers/block/paride/on20.c +++ b/drivers/block/paride/on20.c @@ -115,7 +115,7 @@ static void on20_log_adapter( PIA *pi, c { char *mode_string[2] = {"4-bit","8-bit"}; - printk("%s: on20 %s, OnSpec 90c20 at 0x%x, ", + printk(KERN_INFO "%s: on20 %s, OnSpec 90c20 at 0x%x, ", pi->device,ON20_VERSION,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/on26.c +++ b/drivers/block/paride/on26.c @@ -167,7 +167,7 @@ static int on26_test_port( PIA *pi) /* } if (i == RESET_WAIT) - printk("on26: Device reset failed (%x,%x)\n",x,y); + printk(KERN_NOTICE "on26: Device reset failed (%x,%x)\n",x,y); w0(4); P1; w0(4); P1; } @@ -280,7 +280,7 @@ static void on26_log_adapter( PIA *pi, c { char *mode_string[5] = {"4-bit","8-bit","EPP-8", "EPP-16","EPP-32"}; - printk("%s: on26 %s, OnSpec 90c26 at 0x%x, ", + printk(KERN_INFO "%s: on26 %s, OnSpec 90c26 at 0x%x, ", pi->device,ON26_VERSION,pi->port); printk("mode %d (%s), delay %d\n",pi->mode, mode_string[pi->mode],pi->delay); --- a/drivers/block/paride/paride.c +++ b/drivers/block/paride/paride.c @@ -209,7 +209,7 @@ static int default_test_proto(PIA * pi, pi->proto->disconnect(pi); if (verbose) - printk("%s: %s: port 0x%x, mode %d, test=(%d,%d)\n", + printk(KERN_INFO "%s: %s: port 0x%x, mode %d, test=(%d,%d)\n", pi->device, pi->proto->name, pi->port, pi->mode, e[0], e[1]); @@ -236,7 +236,7 @@ int pi_register(PIP * pr) for (k = 0; k < MAX_PROTOS; k++) if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) { - printk("paride: %s protocol already registered\n", + printk(KERN_DEBUG "paride: %s protocol already registered\n", pr->name); return 0; } @@ -244,12 +244,12 @@ int pi_register(PIP * pr) while ((k < MAX_PROTOS) && (protocols[k])) k++; if (k == MAX_PROTOS) { - printk("paride: protocol table full\n"); + printk(KERN_INFO "paride: protocol table full\n"); return 0; } protocols[k] = pr; pr->index = k; - printk("paride: %s registered as protocol %d\n", pr->name, k); + printk(KERN_INFO "paride: %s registered as protocol %d\n", pr->name, k); return 1; } @@ -260,7 +260,7 @@ void pi_unregister(PIP * pr) if (!pr) return; if (protocols[pr->index] != pr) { - printk("paride: %s not registered\n", pr->name); + printk(KERN_INFO "paride: %s not registered\n", pr->name); return; } protocols[pr->index] = NULL; @@ -288,7 +288,7 @@ static int pi_register_parport(PIA * pi, init_waitqueue_head(&pi->parq); if (verbose) - printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name); + printk(KERN_DEBUG "%s: 0x%x is %s\n", pi->device, pi->port, port->name); pi->parname = (char *) port->name; #endif @@ -390,7 +390,7 @@ int pi_init(PIA * pi, int autoprobe, int } else if ((s < 0) || (s >= MAX_PROTOS) || (port <= 0) || (!protocols[s]) || (unit < 0) || (unit >= protocols[s]->max_units)) { - printk("%s: Invalid parameters\n", device); + printk(KERN_NOTICE "%s: Invalid parameters\n", device); return 0; } @@ -443,9 +443,9 @@ int pi_init(PIA * pi, int autoprobe, int if (!pi->port) { if (autoprobe) - printk("%s: Autoprobe failed\n", device); + printk(KERN_INFO "%s: Autoprobe failed\n", device); else - printk("%s: Adapter not found\n", device); + printk(KERN_INFO "%s: Adapter not found\n", device); return 0; } #ifndef CONFIG_PARPORT @@ -457,7 +457,7 @@ int pi_init(PIA * pi, int autoprobe, int #endif /* !CONFIG_PARPORT */ if (pi->parname) - printk("%s: Sharing %s at 0x%x\n", pi->device, + printk(KERN_INFO "%s: Sharing %s at 0x%x\n", pi->device, pi->parname, pi->port); pi->proto->log_adapter(pi, scratch, verbose); --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -401,7 +401,7 @@ static void pkt_dump_sense(struct packet int i; struct request_sense *sense = cgc->sense; - printk("pktcdvd:"); + printk(KERN_INFO "pktcdvd:"); for (i = 0; i < CDROM_PACKET_SIZE; i++) printk(" %02x", cgc->cmd[i]); printk(" - "); @@ -601,7 +601,7 @@ static int pkt_set_segment_merging(struc set_bit(PACKET_MERGE_SEGS, &pd->flags); return 0; } else { - printk("pktcdvd: cdrom max_phys_segments too small\n"); + printk(KERN_WARNING "pktcdvd: cdrom max_phys_segments too small\n"); return -EIO; } } @@ -1287,7 +1287,7 @@ work_to_do: static void pkt_print_settings(struct pktcdvd_device *pd) { - printk("pktcdvd: %s packets, ", pd->settings.fp ? "Fixed" : "Variable"); + printk(KERN_INFO "pktcdvd: %s packets, ", pd->settings.fp ? "Fixed" : "Variable"); printk("%u blocks, ", pd->settings.size >> 2); printk("Mode-%c disc\n", pd->settings.block_mode == 8 ? '1' : '2'); } @@ -1472,7 +1472,7 @@ static int pkt_set_write_settings(struct /* * paranoia */ - printk("pktcdvd: write mode wrong %d\n", wp->data_block_type); + printk(KERN_WARNING "pktcdvd: write mode wrong %d\n", wp->data_block_type); return 1; } wp->packet_size = cpu_to_be32(pd->settings.size >> 2); @@ -1583,7 +1583,7 @@ static int pkt_probe_settings(struct pkt memset(&ti, 0, sizeof(track_information)); if ((ret = pkt_get_disc_info(pd, &di))) { - printk("failed get_disc\n"); + printk(KERN_INFO "failed get_disc\n"); return ret; } @@ -1689,10 +1689,10 @@ static int pkt_write_caching(struct pktc cgc.buflen = cgc.cmd[8] = 2 + ((buf[0] << 8) | (buf[1] & 0xff)); ret = pkt_mode_select(pd, &cgc); if (ret) { - printk("pktcdvd: write caching control failed\n"); + printk(KERN_INFO "pktcdvd: write caching control failed\n"); pkt_dump_sense(&cgc); } else if (!ret && set) - printk("pktcdvd: enabled write caching on %s\n", pd->name); + printk(KERN_INFO "pktcdvd: enabled write caching on %s\n", pd->name); return ret; } @@ -1806,11 +1806,11 @@ static int pkt_media_speed(struct pktcdv } if (!buf[6] & 0x40) { - printk("pktcdvd: Disc type is not CD-RW\n"); + printk(KERN_INFO "pktcdvd: Disc type is not CD-RW\n"); return 1; } if (!buf[6] & 0x4) { - printk("pktcdvd: A1 values on media are not valid, maybe not CDRW?\n"); + printk(KERN_INFO "pktcdvd: A1 values on media are not valid, maybe not CDRW?\n"); return 1; } @@ -1830,14 +1830,14 @@ static int pkt_media_speed(struct pktcdv *speed = us_clv_to_speed[sp]; break; default: - printk("pktcdvd: Unknown disc sub-type %d\n",st); + printk(KERN_INFO "pktcdvd: Unknown disc sub-type %d\n",st); return 1; } if (*speed) { - printk("pktcdvd: Max. media speed: %d\n",*speed); + printk(KERN_INFO "pktcdvd: Max. media speed: %d\n",*speed); return 0; } else { - printk("pktcdvd: Unknown speed %d for sub-type %d\n",sp,st); + printk(KERN_INFO "pktcdvd: Unknown speed %d for sub-type %d\n",sp,st); return 1; } } @@ -1930,7 +1930,7 @@ static int pkt_open_dev(struct pktcdvd_d goto out_putdev; if ((ret = pkt_get_last_written(pd, &lba))) { - printk("pktcdvd: pkt_get_last_written failed\n"); + printk(KERN_ERR "pktcdvd: pkt_get_last_written failed\n"); goto out_unclaim; } @@ -1960,11 +1960,11 @@ static int pkt_open_dev(struct pktcdvd_d if (write) { if (!pkt_grow_pktlist(pd, CONFIG_CDROM_PKTCDVD_BUFFERS)) { - printk("pktcdvd: not enough memory for buffers\n"); + printk(KERN_ERR "pktcdvd: not enough memory for buffers\n"); ret = -ENOMEM; goto out_unclaim; } - printk("pktcdvd: %lukB available on disc\n", lba << 1); + printk(KERN_INFO "pktcdvd: %lukB available on disc\n", lba << 1); } return 0; @@ -2089,7 +2089,7 @@ static int pkt_make_request(request_queu pd = q->queuedata; if (!pd) { - printk("pktcdvd: %s incorrect request queue\n", bdevname(bio->bi_bdev, b)); + printk(KERN_WARNING "pktcdvd: %s incorrect request queue\n", bdevname(bio->bi_bdev, b)); goto end_io; } @@ -2111,13 +2111,13 @@ static int pkt_make_request(request_queu } if (!test_bit(PACKET_WRITABLE, &pd->flags)) { - printk("pktcdvd: WRITE for ro device %s (%llu)\n", + printk(KERN_INFO "pktcdvd: WRITE for ro device %s (%llu)\n", pd->name, (unsigned long long)bio->bi_sector); goto end_io; } if (!bio->bi_size || (bio->bi_size % CD_FRAMESIZE)) { - printk("pktcdvd: wrong bio size\n"); + printk(KERN_WARNING "pktcdvd: wrong bio size\n"); goto end_io; } @@ -2320,7 +2320,7 @@ static int pkt_new_dev(struct pktcdvd_de struct block_device *bdev; if (pd->pkt_dev == dev) { - printk("pktcdvd: Recursive setup not allowed\n"); + printk(KERN_ERR "pktcdvd: Recursive setup not allowed\n"); return -EBUSY; } for (i = 0; i < MAX_WRITERS; i++) { @@ -2328,11 +2328,11 @@ static int pkt_new_dev(struct pktcdvd_de if (!pd2) continue; if (pd2->bdev->bd_dev == dev) { - printk("pktcdvd: %s already setup\n", bdevname(pd2->bdev, b)); + printk(KERN_INFO "pktcdvd: %s already setup\n", bdevname(pd2->bdev, b)); return -EBUSY; } if (pd2->pkt_dev == dev) { - printk("pktcdvd: Can't chain pktcdvd devices\n"); + printk(KERN_INFO "pktcdvd: Can't chain pktcdvd devices\n"); return -EBUSY; } } @@ -2355,7 +2355,7 @@ static int pkt_new_dev(struct pktcdvd_de atomic_set(&pd->cdrw.pending_bios, 0); pd->cdrw.thread = kthread_run(kcdrwd, pd, "%s", pd->name); if (IS_ERR(pd->cdrw.thread)) { - printk("pktcdvd: can't start kernel thread\n"); + printk(KERN_ERR "pktcdvd: can't start kernel thread\n"); ret = -ENOMEM; goto out_mem; } @@ -2447,7 +2447,7 @@ static int pkt_setup_dev(struct pkt_ctrl if (!pkt_devs[idx]) break; if (idx == MAX_WRITERS) { - printk("pktcdvd: max %d writers supported\n", MAX_WRITERS); + printk(KERN_INFO "pktcdvd: max %d writers supported\n", MAX_WRITERS); return -EBUSY; } @@ -2627,7 +2627,7 @@ static int __init pkt_init(void) ret = register_blkdev(pkt_major, "pktcdvd"); if (ret < 0) { - printk("pktcdvd: Unable to register block device\n"); + printk(KERN_ERR "pktcdvd: Unable to register block device\n"); goto out2; } if (!pkt_major) @@ -2635,7 +2635,7 @@ static int __init pkt_init(void) ret = misc_register(&pkt_misc); if (ret) { - printk("pktcdvd: Unable to register misc device\n"); + printk(KERN_ERR "pktcdvd: Unable to register misc device\n"); goto out; } --- a/drivers/block/ps2esdi.c +++ b/drivers/block/ps2esdi.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -460,8 +461,7 @@ static void __init ps2esdi_get_device_cf cmd_blk[1] = 0; no_int_yet = TRUE; ps2esdi_out_cmd_blk(cmd_blk); - if (no_int_yet) - sleep_on(&ps2esdi_int); + wait_event(ps2esdi_int, !no_int_yet); if (ps2esdi_drives > 1) { printk("%s: Drive 1\n", DEVICE_NAME); /*BA */ @@ -469,8 +469,7 @@ static void __init ps2esdi_get_device_cf cmd_blk[1] = 0; no_int_yet = TRUE; ps2esdi_out_cmd_blk(cmd_blk); - if (no_int_yet) - sleep_on(&ps2esdi_int); + wait_event(ps2esdi_int, !no_int_yet); } /* if second physical drive is present */ return; } --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -821,13 +821,15 @@ static void release_drive(struct floppy_ static int fd_eject(struct floppy_state *fs) { - int err, n; + int err; + unsigned long end_jiffies; err = grab_drive(fs, ejecting, 1); if (err) return err; swim3_action(fs, EJECT); - for (n = 20; n > 0; --n) { + end_jiffies = jiffies + 20; + while (time_before(jiffies, end_jiffies)) { if (signal_pending(current)) { err = -EINTR; break; @@ -880,7 +882,8 @@ static int floppy_open(struct inode *ino { struct floppy_state *fs = inode->i_bdev->bd_disk->private_data; struct swim3 __iomem *sw = fs->swim3; - int n, err = 0; + int err = 0; + unsigned long end_jiffies, check_jiffies; if (fs->ref_count == 0) { #ifdef CONFIG_PMAC_MEDIABAY @@ -896,8 +899,11 @@ static int floppy_open(struct inode *ino swim3_action(fs, MOTOR_ON); fs->write_prot = -1; fs->cur_cyl = -1; - for (n = 0; n < 2 * HZ; ++n) { - if (n >= HZ/30 && swim3_readbit(fs, SEEK_COMPLETE)) + end_jiffies = jiffies + 2 * HZ; + check_jiffies = jiffies + HZ/30; + while (time_before(jiffies, end_jiffies)) { + if (time_after(jiffies, check_jiffies) && + swim3_readbit(fs, SEEK_COMPLETE)) break; if (signal_pending(current)) { err = -EINTR; @@ -968,7 +974,8 @@ static int floppy_revalidate(struct gend { struct floppy_state *fs = disk->private_data; struct swim3 __iomem *sw; - int ret, n; + int ret; + unsigned long end_jiffies; #ifdef CONFIG_PMAC_MEDIABAY if (fs->media_bay && check_media_bay(fs->media_bay, MB_FD)) @@ -983,7 +990,8 @@ static int floppy_revalidate(struct gend fs->write_prot = -1; fs->cur_cyl = -1; mdelay(1); - for (n = HZ; n > 0; --n) { + end_jiffies = jiffies + HZ; + while (time_before(jiffies, end_jiffies)) { if (swim3_readbit(fs, SEEK_COMPLETE)) break; if (signal_pending(current)) --- a/drivers/block/swim_iop.c +++ b/drivers/block/swim_iop.c @@ -317,7 +317,8 @@ static void swimiop_status_update(int dr static int swimiop_eject(struct floppy_state *fs) { - int err, n; + int err; + unsigned long end_jiffies; struct swim_iop_req req; struct swimcmd_eject *cmd = (struct swimcmd_eject *) &req.command[0]; @@ -332,8 +333,8 @@ static int swimiop_eject(struct floppy_s release_drive(fs); return err; } - for (n = 2*HZ; n > 0; --n) { - if (req.complete) break; + end_jiffies = jiffies + 2 * HZ; + while (!reg.complete && time_before(jiffies, end_jiffies)) { if (signal_pending(current)) { err = -EINTR; break; @@ -426,23 +427,27 @@ static int grab_drive(struct floppy_stat int interruptible) { unsigned long flags; + int err = 0; local_irq_save(flags); - if (fs->state != idle) { + while ((fs->state != idle) && !err) { ++fs->wanted; - while (fs->state != available) { - if (interruptible && signal_pending(current)) { - --fs->wanted; - local_irq_restore(flags); - return -EINTR; - } - interruptible_sleep_on(&fs->wait); + local_irq_restore(flags); + if (interruptible) { + err = wait_event_interruptible(fs->wait, + fs->state == available); + if (err) + err = -EINTR; + } else { + wait_event(fs->wait, fs->state == available); } + local_irq_save(flags); --fs->wanted; } - fs->state = state; + if (!err) + fs->state = state; local_irq_restore(flags); - return 0; + return err; } static void release_drive(struct floppy_state *fs) --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -551,9 +551,10 @@ static struct carm_request *carm_get_spe unsigned long flags; struct carm_request *crq = NULL; struct request *rq; - int tries = 5000; + unsigned long end_time; - while (tries-- > 0) { + end_time = jiffies + msecs_to_jiffies(50000); + while (time_before(jiffies, end_time)) { spin_lock_irqsave(&host->lock, flags); crq = carm_get_request(host); spin_unlock_irqrestore(&host->lock, flags); --- a/drivers/block/xd.c +++ b/drivers/block/xd.c @@ -539,6 +539,7 @@ static inline u_char xd_waitport (u_shor static inline u_int xd_wait_for_IRQ (void) { + DEFINE_WAIT(wait); unsigned long flags; xd_watchdog_int.expires = jiffies + 8 * HZ; add_timer(&xd_watchdog_int); @@ -547,7 +548,9 @@ static inline u_int xd_wait_for_IRQ (voi enable_dma(xd_dma); release_dma_lock(flags); - sleep_on(&xd_wait_int); + prepare_to_wait(&xd_wait_int, &wait, TASK_UNINTERRUPTIBLE); + schedule(); + finish_wait(&xd_wait_int, &wait); del_timer(&xd_watchdog_int); xdc_busy = 0; --- a/drivers/cdrom/aztcd.c +++ b/drivers/cdrom/aztcd.c @@ -427,11 +427,12 @@ static void dten_low(void) * may cause kernel panic when used in the wrong place */ #define STEN_LOW_WAIT statusAzt() +#define STATUS_AZT_WAKEUP_COND (!(inb(STATUS_PORT) & AFL_STATUS)) static void statusAzt(void) { AztTimeout = AZT_STATUS_DELAY; SET_TIMER(aztStatTimer, HZ / 100); - sleep_on(&azt_waitq); + wait_event(azt_waitq, (STATUS_AZT_WAKEUP_COND || AztTimeout <= 0)); if (AztTimeout <= 0) printk("aztcd: Error Wait STEN_LOW_WAIT command:%x\n", aztCmd); @@ -440,7 +441,7 @@ static void statusAzt(void) static void aztStatTimer(void) { - if (!(inb(STATUS_PORT) & AFL_STATUS)) { + if (STATUS_AZT_WAKEUP_COND) { wake_up(&azt_waitq); return; } --- a/drivers/cdrom/mcdx.c +++ b/drivers/cdrom/mcdx.c @@ -67,6 +67,7 @@ static const char *mcdx_c_version #include #include #include +#include #include #include #include @@ -835,11 +836,14 @@ static void mcdx_delay(struct s_drive_st * May be we could use a simple count loop w/ jumps to itself, but * I wanna make this independent of cpu speed. [1 jiffy is 1/HZ] sec */ { + DEFINE_WAIT(wait); if (jifs < 0) return; xtrace(SLEEP, "*** delay: sleepq\n"); - interruptible_sleep_on_timeout(&stuff->sleepq, jifs); + prepare_to_wait(&stuff->sleepq, &wait, TASK_INTERRUPTIBLE); + schedule_timeout(jifs); + finish_wait(&stuff->sleepq, &wait); xtrace(SLEEP, "delay awoken\n"); if (signal_pending(current)) { xtrace(SLEEP, "got signal\n"); @@ -907,11 +911,9 @@ static int mcdx_talk(struct s_drive_stuf if ((discard = (buffer == NULL))) buffer = &c; - while (stuffp->lock) { - xtrace(SLEEP, "*** talk: lockq\n"); - interruptible_sleep_on(&stuffp->lockq); - xtrace(SLEEP, "talk: awoken\n"); - } + xtrace(SLEEP, "*** talk: lockq\n"); + wait_event(stuffp->lockq, !stuffp->lock); + xtrace(SLEEP, "talk: awoken\n"); stuffp->lock = 1; @@ -998,7 +1000,7 @@ static int mcdx_talk(struct s_drive_stuf #endif stuffp->lock = 0; - wake_up_interruptible(&stuffp->lockq); + wake_up(&stuffp->lockq); xtrace(TALK, "talk() done with 0x%02x\n", st); return st; @@ -1318,6 +1320,7 @@ static int mcdx_xfer(struct s_drive_stuf Return: -1 on timeout or other error else status byte (as in stuff->st) */ { + DEFINE_WAIT(wait); int border; int done = 0; long timeout; @@ -1332,9 +1335,7 @@ static int mcdx_xfer(struct s_drive_stuf return -1; } - while (stuffp->lock) { - interruptible_sleep_on(&stuffp->lockq); - } + wait_event(stuffp->lockq, !stuffp->lock); if (stuffp->valid && (sector >= stuffp->pending) && (sector < stuffp->low_border)) { @@ -1356,10 +1357,10 @@ static int mcdx_xfer(struct s_drive_stuf do { while (stuffp->busy) { - - timeout = - interruptible_sleep_on_timeout - (&stuffp->busyq, 5 * HZ); + prepare_to_wait(&stuffp->busyq, &wait, + TASK_INTERRUPTIBLE); + timeout = schedule_timeout(5 * HZ); + finish_wait(&stuffp->busyq, &wait); if (!stuffp->introk) { xtrace(XFER, @@ -1375,7 +1376,7 @@ static int mcdx_xfer(struct s_drive_stuf stuffp->busy = 0; stuffp->valid = 0; - wake_up_interruptible(&stuffp->lockq); + wake_up(&stuffp->lockq); xtrace(XFER, "transfer() done (-1)\n"); return -1; } @@ -1411,7 +1412,7 @@ static int mcdx_xfer(struct s_drive_stuf } while (++(stuffp->pending) < border); stuffp->lock = 0; - wake_up_interruptible(&stuffp->lockq); + wake_up(&stuffp->lockq); } else { --- a/drivers/cdrom/optcd.c +++ b/drivers/cdrom/optcd.c @@ -292,7 +292,7 @@ static int sleep_flag_low(int flag, unsi flag_high = inb(STATUS_PORT) & flag; if (flag_high && sleep_timeout > 0) { mod_timer(&delay_timer, jiffies + HZ/100); - sleep_on(&waitq); + wait_event(waitq, ((inb(STATUS_PORT) & FL_STDT) != FL_STDT || sleep_timeout <= 0)); flag_high = inb(STATUS_PORT) & flag; } --- a/drivers/cdrom/sjcd.c +++ b/drivers/cdrom/sjcd.c @@ -70,6 +70,7 @@ #include #include #include +#include #include #include @@ -407,9 +408,12 @@ static void sjcd_status_timer(void) */ static int sjcd_wait_for_status(void) { + DEFINE_WAIT(wait); sjcd_status_timeout = SJCD_WAIT_FOR_STATUS_TIMEOUT; SJCD_SET_TIMER(sjcd_status_timer, 1); - sleep_on(&sjcd_waitq); + prepare_to_wait(&sjcd_waitq, &wait, TASK_UNINTERRUPTIBLE); + schedule(); + finish_wait(&sjcd_waitq, &wait); #if defined( SJCD_DIAGNOSTIC ) || defined ( SJCD_TRACE ) if (sjcd_status_timeout <= 0) printk("SJCD: Error Wait For Status.\n"); --- a/drivers/cdrom/sonycd535.c +++ b/drivers/cdrom/sonycd535.c @@ -129,6 +129,7 @@ #include #include #include +#include #define REALLY_SLOW_IO #include @@ -896,9 +897,8 @@ do_cdu535_request(request_queue_t * q) } if (readStatus == BAD_STATUS) { /* Sleep for a while, then retry */ - set_current_state(TASK_INTERRUPTIBLE); spin_unlock_irq(&sonycd535_lock); - schedule_timeout(RETRY_FOR_BAD_STATUS*HZ/10); + msleep(RETRY_FOR_BAD_STATUS*100); spin_lock_irq(&sonycd535_lock); } #if DEBUG > 0 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c @@ -1642,8 +1642,8 @@ static int block_til_ready(struct tty_st */ if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING) == 0); #ifdef SERIAL_DO_RESTART return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); @@ -1742,12 +1742,11 @@ static int get_async_struct(int line, st *ret_info = sstate->info; return 0; } - info = kmalloc(sizeof(struct async_struct), GFP_KERNEL); + info = kzalloc(sizeof(struct async_struct), GFP_KERNEL); if (!info) { sstate->count--; return -ENOMEM; } - memset(info, 0, sizeof(struct async_struct)); #ifdef DECLARE_WAITQUEUE init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->close_wait); @@ -1815,8 +1814,8 @@ static int rs_open(struct tty_struct *tt */ if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING) == 0); #ifdef SERIAL_DO_RESTART return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); @@ -1872,6 +1871,17 @@ static inline int line_info(char *buf, s info->quot = 0; info->tty = NULL; } + + if (info->quot) { + ret += sprintf(buf+ret, " baud:%d", + state->baud_base / info->quot); + } + + if (!capable(CAP_SYS_RAWIO)) { + strcat(buf, "\n"); + return ret + 1; + } + local_irq_save(flags); status = ciab.pra; control = info ? info->MCR : status; @@ -1890,11 +1900,6 @@ static inline int line_info(char *buf, s if(!(status & SER_DCD)) strcat(stat_buf, "|CD"); - if (info->quot) { - ret += sprintf(buf+ret, " baud:%d", - state->baud_base / info->quot); - } - ret += sprintf(buf+ret, " tx:%d rx:%d", state->icount.tx, state->icount.rx); --- a/drivers/char/consolemap.c +++ b/drivers/char/consolemap.c @@ -193,11 +193,10 @@ static void set_inverse_transl(struct vc q = p->inverse_translations[i]; if (!q) { - q = p->inverse_translations[i] = (unsigned char *) - kmalloc(MAX_GLYPH, GFP_KERNEL); + q = p->inverse_translations[i] = + kzalloc(MAX_GLYPH, GFP_KERNEL); if (!q) return; } - memset(q, 0, MAX_GLYPH); for (j = 0; j < E_TABSZ; j++) { glyph = conv_uni_to_pc(conp, t[j]); @@ -444,12 +443,11 @@ int con_clear_unimap(struct vc_data *vc, p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc; if (p && p->readonly) return -EIO; if (!p || --p->refcount) { - q = (struct uni_pagedir *)kmalloc(sizeof(*p), GFP_KERNEL); + q = kzalloc(sizeof(*p), GFP_KERNEL); if (!q) { if (p) p->refcount++; return -ENOMEM; } - memset(q, 0, sizeof(*q)); q->refcount=1; *vc->vc_uni_pagedir_loc = (unsigned long)q; } else { --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c @@ -2291,9 +2291,8 @@ block_til_ready(struct tty_struct *tty, * until it's done, and then try again. */ if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&info->close_wait); - } + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING)==0); return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } @@ -2560,8 +2559,8 @@ cy_open(struct tty_struct *tty, struct f * If the port is the middle of closing, bail out now */ if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING)==0); return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } @@ -5144,7 +5143,11 @@ cyclades_get_proc_info(char *buf, char * int size; __u32 cur_jifs = jiffies; - size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn IdleIn Overruns Ldisc\n"); + if (capable(CAP_SYS_RAWIO)) { + size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn IdleIn Overruns Ldisc\n"); + } else { + size = sprintf(buf, "Dev Ldisc\n"); + } pos += size; len += size; @@ -5153,21 +5156,29 @@ cyclades_get_proc_info(char *buf, char * for (i = 0; i < NR_PORTS && cy_port[i].line >= 0; i++) { info = &cy_port[i]; - if (info->count) - size = sprintf(buf+len, - "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", - info->line, - JIFFIES_DIFF(info->idle_stats.in_use, cur_jifs) / HZ, - info->idle_stats.xmit_bytes, - JIFFIES_DIFF(info->idle_stats.xmit_idle, cur_jifs) / HZ, - info->idle_stats.recv_bytes, - JIFFIES_DIFF(info->idle_stats.recv_idle, cur_jifs) / HZ, - info->idle_stats.overruns, - (long) info->tty->ldisc.num); - else - size = sprintf(buf+len, - "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", - info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); + if (capable(CAP_SYS_RAWIO)) { + if (info->count) + size = sprintf(buf+len, + "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", + info->line, + JIFFIES_DIFF(info->idle_stats.in_use, cur_jifs) / HZ, + info->idle_stats.xmit_bytes, + JIFFIES_DIFF(info->idle_stats.xmit_idle, cur_jifs) / HZ, + info->idle_stats.recv_bytes, + JIFFIES_DIFF(info->idle_stats.recv_idle, cur_jifs) / HZ, + info->idle_stats.overruns, + (long) info->tty->ldisc.num); + else + size = sprintf(buf+len, + "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", + info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); + } else { + if (info->count) + size = sprintf(buf+len, "%3d %6ld\n", info->line, + (long) info->tty->ldisc.num); + else + size = sprintf(buf+len, "%3d %6ld\n", info->line, 0L); + } len += size; pos = begin + len; --- a/drivers/char/drm/ffb_drv.c +++ b/drivers/char/drm/ffb_drv.c @@ -219,10 +219,9 @@ static int ffb_presetup(drm_device_t * d return -ENODEV; /* code used to use numdevs no numdevs anymore */ - ffb_priv = kmalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL); + ffb_priv = kzalloc(sizeof(ffb_dev_priv_t), GFP_KERNEL); if (!ffb_priv) return -ENOMEM; - memset(ffb_priv, 0, sizeof(*ffb_priv)); dev->dev_private = ffb_priv; ret = ffb_init_one(dev, ffb_position[i].node, ffb_position[i].root, i); --- a/drivers/char/drm/i830_dma.c +++ b/drivers/char/drm/i830_dma.c @@ -587,26 +587,7 @@ static void i830EmitTexBlendVerified(drm static void i830EmitTexPalette(drm_device_t * dev, unsigned int *palette, int number, int is_shared) { - drm_i830_private_t *dev_priv = dev->dev_private; - int i; - RING_LOCALS; - return; - - BEGIN_LP_RING(258); - - if (is_shared == 1) { - OUT_RING(CMD_OP_MAP_PALETTE_LOAD | - MAP_PALETTE_NUM(0) | MAP_PALETTE_BOTH); - } else { - OUT_RING(CMD_OP_MAP_PALETTE_LOAD | MAP_PALETTE_NUM(number)); - } - for (i = 0; i < 256; i++) { - OUT_RING(palette[i]); - } - OUT_RING(0); - /* KW: WHERE IS THE ADVANCE_LP_RING? This is effectively a noop! - */ } /* Need to do some additional checking when setting the dest buffer. --- a/drivers/char/drm/i830_irq.c +++ b/drivers/char/drm/i830_irq.c @@ -32,6 +32,7 @@ #include "i830_drv.h" #include /* For task queue support */ #include +#include /* For wait_event */ irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS) { @@ -73,9 +74,7 @@ static int i830_emit_irq(drm_device_t * static int i830_wait_irq(drm_device_t * dev, int irq_nr) { drm_i830_private_t *dev_priv = (drm_i830_private_t *) dev->dev_private; - DECLARE_WAITQUEUE(entry, current); - unsigned long end = jiffies + HZ * 3; - int ret = 0; + int ret; DRM_DEBUG("%s\n", __FUNCTION__); @@ -84,31 +83,23 @@ static int i830_wait_irq(drm_device_t * dev_priv->sarea_priv->perf_boxes |= I830_BOX_WAIT; - add_wait_queue(&dev_priv->irq_queue, &entry); + ret = wait_event_interruptible_timeout(dev_priv->irq_queue, + (atomic_read(&dev_priv->irq_received) >= irq_nr), + HZ*3); + + if (ret == 0) { + DRM_ERROR("timeout iir %x imr %x ier %x hwstam %x\n", + I830_READ16( I830REG_INT_IDENTITY_R ), + I830_READ16( I830REG_INT_MASK_R ), + I830_READ16( I830REG_INT_ENABLE_R ), + I830_READ16( I830REG_HWSTAM )); + + ret = -EBUSY; /* Lockup? Missed irq? */ + } else if (ret == -ERESTARTSYS) { + ret = -EINTR; /* interrupted */ + } else + ret = 0; /* condition */ - for (;;) { - __set_current_state(TASK_INTERRUPTIBLE); - if (atomic_read(&dev_priv->irq_received) >= irq_nr) - break; - if ((signed)(end - jiffies) <= 0) { - DRM_ERROR("timeout iir %x imr %x ier %x hwstam %x\n", - I830_READ16(I830REG_INT_IDENTITY_R), - I830_READ16(I830REG_INT_MASK_R), - I830_READ16(I830REG_INT_ENABLE_R), - I830_READ16(I830REG_HWSTAM)); - - ret = -EBUSY; /* Lockup? Missed irq? */ - break; - } - schedule_timeout(HZ * 3); - if (signal_pending(current)) { - ret = -EINTR; - break; - } - } - - __set_current_state(TASK_RUNNING); - remove_wait_queue(&dev_priv->irq_queue, &entry); return ret; } --- a/drivers/char/drm/via_dmablit.c +++ b/drivers/char/drm/via_dmablit.c @@ -268,10 +268,10 @@ via_alloc_desc_pages(drm_via_sg_info_t * vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) / vsg->descriptors_per_page; - if (NULL == (vsg->desc_pages = kmalloc(sizeof(void *) * vsg->num_desc_pages, GFP_KERNEL))) + if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, + sizeof(void *), GFP_KERNEL))) return DRM_ERR(ENOMEM); - memset(vsg->desc_pages, 0, sizeof(void *) * vsg->num_desc_pages); vsg->state = dr_via_desc_pages_alloc; for (i=0; inum_desc_pages; ++i) { if (NULL == (vsg->desc_pages[i] = --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c @@ -60,11 +60,13 @@ #define handshake(count, maxio, timeout, ENABLE, f) \ { \ - long i, t, m; \ + long i, m; \ + unsigned long end_time; \ while (count > 0) { \ m = min_t(unsigned long, count, maxio); \ for (i = 0; i < m; i++) { \ - for (t = 0; t < timeout && !ENABLE; t++) \ + end_time = jiffies + msecs_to_jiffies((timeout) * 20); \ + while (time_before(jiffies, end_time) && !ENABLE) { \ msleep(20); \ if(!ENABLE) \ return -EIO; \ @@ -77,8 +79,8 @@ #define tx_wait(n) \ { \ - int t; \ - for(t = 0; t < n && !DSP56K_TRANSMIT; t++) \ + unsigned long end_time = jiffies + msecs_to_jiffies((n) * 10); \ + while (time_before(jiffies, end_time) && !DSP56K_TRANSMIT) \ msleep(10); \ if(!DSP56K_TRANSMIT) { \ return -EIO; \ @@ -87,8 +89,8 @@ #define rx_wait(n) \ { \ - int t; \ - for(t = 0; t < n && !DSP56K_RECEIVE; t++) \ + unsigned long end_time = jiffies + msecs_to_jiffies((n) * 10); \ + while (time_before(jiffies, end_time) && !DSP56K_RECEIVE) \ msleep(10); \ if(!DSP56K_RECEIVE) { \ return -EIO; \ --- a/drivers/char/epca.c +++ b/drivers/char/epca.c @@ -893,7 +893,8 @@ static int block_til_ready(struct tty_st until it's done, and then try again. -------------------------------------------------------------------- */ if (ch->asyncflags & ASYNC_CLOSING) { - interruptible_sleep_on(&ch->close_wait); + wait_event_interruptible(ch->close_wait, + (ch->asyncflags & ASYNC_CLOSING) == 0); if (ch->asyncflags & ASYNC_HUP_NOTIFY) return -EAGAIN; --- a/drivers/char/esp.c +++ b/drivers/char/esp.c @@ -2141,8 +2141,8 @@ static int block_til_ready(struct tty_st */ if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING) == 0); #ifdef SERIAL_DO_RESTART if (info->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; --- a/drivers/char/ftape/lowlevel/ftape-buffer.c +++ b/drivers/char/ftape/lowlevel/ftape-buffer.c @@ -74,11 +74,10 @@ static int add_one_buffer(void) if (ft_nr_buffers >= FT_MAX_NR_BUFFERS) { TRACE_EXIT -ENOMEM; } - ft_buffer[ft_nr_buffers] = kmalloc(sizeof(buffer_struct), GFP_KERNEL); + ft_buffer[ft_nr_buffers] = kzalloc(sizeof(buffer_struct), GFP_KERNEL); if (ft_buffer[ft_nr_buffers] == NULL) { TRACE_EXIT -ENOMEM; } - memset(ft_buffer[ft_nr_buffers], 0, sizeof(buffer_struct)); ft_buffer[ft_nr_buffers]->address = dmaalloc(FT_BUFF_SIZE); if (ft_buffer[ft_nr_buffers]->address == NULL) { kfree(ft_buffer[ft_nr_buffers]); --- a/drivers/char/ftape/zftape/zftape-buffers.c +++ b/drivers/char/ftape/zftape/zftape-buffers.c @@ -112,10 +112,9 @@ void *zft_kmalloc(size_t size) { void *new; - while ((new = kmalloc(size, GFP_KERNEL)) == NULL) { + while ((new = kzalloc(size, GFP_KERNEL)) == NULL) { msleep_interruptible(100); } - memset(new, 0, size); used_memory += size; if (peak_memory < used_memory) { peak_memory = used_memory; --- a/drivers/char/generic_serial.c +++ b/drivers/char/generic_serial.c @@ -534,7 +534,8 @@ int gs_block_til_ready(void *port_, stru * until it's done, and then try again. */ if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&port->close_wait); + wait_event_interruptible(port->close_wait, + (port->flags & ASYNC_CLOSING) == 0); if (port->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; else --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c @@ -734,12 +734,10 @@ struct hvc_struct __devinit *hvc_alloc(u struct hvc_struct *hp; int i; - hp = kmalloc(sizeof(*hp), GFP_KERNEL); + hp = kzalloc(sizeof(*hp), GFP_KERNEL); if (!hp) return ERR_PTR(-ENOMEM); - memset(hp, 0x00, sizeof(*hp)); - hp->vtermno = vtermno; hp->irq = irq; hp->ops = ops; --- a/drivers/char/hvcs.c +++ b/drivers/char/hvcs.c @@ -622,13 +622,10 @@ static int __devinit hvcs_probe( return -EFAULT; } - hvcsd = kmalloc(sizeof(*hvcsd), GFP_KERNEL); + hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL); if (!hvcsd) return -ENODEV; - /* hvcsd->tty is zeroed out with the memset */ - memset(hvcsd, 0x00, sizeof(*hvcsd)); - spin_lock_init(&hvcsd->lock); /* Automatically incs the refcount the first time */ kobject_init(&hvcsd->kobj); --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c @@ -896,7 +896,8 @@ static int block_til_ready(struct tty_st if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { pr_dbg("block_til_ready: close in progress.\n"); - interruptible_sleep_on(&port->close_wait); + wait_event_interruptible(port->close_wait, + (port->flags & ASYNC_CLOSING)==0); if (port->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; else --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c @@ -1035,7 +1035,8 @@ static int stli_open(struct tty_struct * * for it is done with the same context. */ if (portp->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&portp->close_wait); + wait_event_interruptible(portp->close_wait, + (portp->flags & ASYNC_CLOSING) == 0); if (portp->flags & ASYNC_HUP_NOTIFY) return(-EAGAIN); return(-ERESTARTSYS); @@ -1075,7 +1076,8 @@ static int stli_open(struct tty_struct * * for it is done with the same context. */ if (portp->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&portp->close_wait); + wait_event_interruptible(portp->close_wait, + (portp->flags & ASYNC_CLOSING) == 0); if (portp->flags & ASYNC_HUP_NOTIFY) return(-EAGAIN); return(-ERESTARTSYS); @@ -2493,7 +2495,7 @@ static int stli_portinfo(stlibrd_t *brdp sp = pos; sp += sprintf(sp, "%d: uart:%s ", portnr, uart); - if ((brdp->state & BST_STARTED) && (rc >= 0)) { + if (capable(CAP_SYS_RAWIO) && (brdp->state & BST_STARTED) && (rc >= 0)) { sp += sprintf(sp, "tx:%d rx:%d", (int) stli_comstats.txtotal, (int) stli_comstats.rxtotal); --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c @@ -1055,7 +1055,7 @@ static int emulate_raw(struct vc_data *v put_queue(vc, 0x1d | up_flag); put_queue(vc, 0x45 | up_flag); return 0; - case KEY_HANGUEL: + case KEY_HANGEUL: if (!up_flag) put_queue(vc, 0xf1); return 0; case KEY_HANJA: @@ -1272,9 +1272,8 @@ static struct input_handle *kbd_connect( if (i == BTN_MISC && !test_bit(EV_SND, dev->evbit)) return NULL; - if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) + if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL))) return NULL; - memset(handle, 0, sizeof(struct input_handle)); handle->dev = dev; handle->handler = handler; --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c @@ -1003,8 +1003,8 @@ static int block_till_ready(struct tty_s * until it's done, and then try again. */ if (tty_hung_up_p(filp) || (ch->asyncflags & ASYNC_CLOSING)) { - if (ch->asyncflags & ASYNC_CLOSING) - interruptible_sleep_on(&ch->close_wait); + wait_event_interruptible(ch->close_wait, + (ch->asyncflags & ASYNC_CLOSING)==0); #ifdef SERIAL_DO_RESTART if (ch->asyncflags & ASYNC_HUP_NOTIFY) return (-EAGAIN); --- a/drivers/char/n_hdlc.c +++ b/drivers/char/n_hdlc.c @@ -802,13 +802,11 @@ static struct n_hdlc *n_hdlc_alloc(void) { struct n_hdlc_buf *buf; int i; - struct n_hdlc *n_hdlc = kmalloc(sizeof(*n_hdlc), GFP_KERNEL); + struct n_hdlc *n_hdlc = kzalloc(sizeof(*n_hdlc), GFP_KERNEL); if (!n_hdlc) return NULL; - memset(n_hdlc, 0, sizeof(*n_hdlc)); - n_hdlc_buf_list_init(&n_hdlc->rx_free_buf_list); n_hdlc_buf_list_init(&n_hdlc->tx_free_buf_list); n_hdlc_buf_list_init(&n_hdlc->rx_buf_list); --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -2725,8 +2725,8 @@ static int mgslpc_open(struct tty_struct /* If port is closing, signal caller to try again */ if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING)==0); retval = ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); goto cleanup; @@ -2787,6 +2787,11 @@ static inline int line_info(char *buf, M ret = sprintf(buf, "%s:io:%04X irq:%d", info->device_name, info->io_base, info->irq_level); + if (!capable(CAP_SYS_RAWIO)) { + strcat(buf, "\n"); + return ret + 1; + } + /* output current serial signal states */ spin_lock_irqsave(&info->lock,flags); get_signals(info); @@ -4008,8 +4013,8 @@ BOOLEAN irq_test(MGSLPC_INFO *info) spin_unlock_irqrestore(&info->lock,flags); - end_time=100; - while(end_time-- && !info->irq_occurred) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time) && !info->irq_occurred) { msleep_interruptible(10); } --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -912,11 +912,9 @@ void rand_initialize_irq(int irq) * If kmalloc returns null, we just won't use that entropy * source. */ - state = kmalloc(sizeof(struct timer_rand_state), GFP_KERNEL); - if (state) { - memset(state, 0, sizeof(struct timer_rand_state)); + state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL); + if (state) irq_timer_state[irq] = state; - } } void rand_initialize_disk(struct gendisk *disk) @@ -927,11 +925,9 @@ void rand_initialize_disk(struct gendisk * If kmalloc returns null, we just won't use that entropy * source. */ - state = kmalloc(sizeof(struct timer_rand_state), GFP_KERNEL); - if (state) { - memset(state, 0, sizeof(struct timer_rand_state)); + state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL); + if (state) disk->random = state; - } } static ssize_t --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c @@ -799,19 +799,6 @@ static int rio_init_drivers(void) return 1; } - -static void *ckmalloc(int size) -{ - void *p; - - p = kmalloc(size, GFP_KERNEL); - if (p) - memset(p, 0, size); - return p; -} - - - static int rio_init_datastructures(void) { int i; @@ -830,18 +817,18 @@ static int rio_init_datastructures(void) #define TMIO_SZ sizeof(struct termios *) rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); - if (!(p = ckmalloc(RI_SZ))) + if (!(p = kzalloc(RI_SZ, GFP_KERNEL))) goto free0; - if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ))) + if (!(p->RIOHosts = kzalloc(RIO_HOSTS * HOST_SZ, GFP_KERNEL))) goto free1; - if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ))) + if (!(p->RIOPortp = kzalloc(RIO_PORTS * PORT_SZ, GFP_KERNEL))) goto free2; p->RIOConf = RIOConf; rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp); #if 1 for (i = 0; i < RIO_PORTS; i++) { - port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port)); + port = p->RIOPortp[i] = kzalloc(sizeof(struct Port), GFP_KERNEL); if (!port) { goto free6; } --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c @@ -941,7 +941,8 @@ static int block_til_ready(struct tty_st * until it's done, and then try again. */ if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&port->close_wait); + wait_event_interruptible(port->close_wait, + (port->flags & ASYNC_CLOSING) == 0); if (port->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; else --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c @@ -654,12 +654,11 @@ static void init_r_port(int board, int a ctlp = sCtlNumToCtlPtr(board); /* Get a r_port struct for the port, fill it in and save it globally, indexed by line number */ - info = kmalloc(sizeof (struct r_port), GFP_KERNEL); + info = kzalloc(sizeof(struct r_port), GFP_KERNEL); if (!info) { printk(KERN_INFO "Couldn't allocate info struct for line #%d\n", line); return; } - memset(info, 0, sizeof (struct r_port)); info->magic = RPORT_MAGIC; info->line = line; @@ -898,7 +897,8 @@ static int block_til_ready(struct tty_st if (tty_hung_up_p(filp)) return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); if (info->flags & ROCKET_CLOSING) { - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ROCKET_CLOSING)==0); return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } @@ -1003,7 +1003,8 @@ static int rp_open(struct tty_struct *tt return -ENOMEM; if (info->flags & ROCKET_CLOSING) { - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ROCKET_CLOSING)==0); free_page(page); return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c @@ -1851,7 +1851,8 @@ block_til_ready(struct tty_struct *tty, * until it's done, and then try again. */ if (info->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING) == 0); if (info->flags & ASYNC_HUP_NOTIFY){ return -EAGAIN; }else{ --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -724,7 +724,8 @@ static void sonypi_camera_off(void) /* Turns the camera on */ static void sonypi_camera_on(void) { - int i, j; + int j; + unsigned long end_time; if (sonypi_device.camera_power) return; @@ -735,12 +736,13 @@ static void sonypi_camera_on(void) msleep(10); sonypi_call1(0x93); - for (i = 400; i > 0; i--) { + end_time = jiffies + msecs_to_jiffies(4000); + while (time_before(jiffies, end_time)) { if (sonypi_camera_ready()) break; msleep(10); } - if (i) + if (time_before(jiffies, end_time)) break; } --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c @@ -1404,7 +1404,8 @@ static int block_til_ready(struct tty_st * until it's done, and then try again. */ if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&port->close_wait); + wait_event_interruptible(port->close_wait, + (port->flags & ASYNC_CLOSING)==0); if (port->flags & ASYNC_HUP_NOTIFY) { func_exit(); return -EAGAIN; --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c @@ -1027,7 +1027,8 @@ static int stl_open(struct tty_struct *t * for it is done with the same context. */ if (portp->flags & ASYNC_CLOSING) { - interruptible_sleep_on(&portp->close_wait); + wait_event_interruptible(portp->close_wait, + (portp->flags & ASYNC_CLOSING) == 0); if (portp->flags & ASYNC_HUP_NOTIFY) return -EAGAIN; return -ERESTARTSYS; @@ -1829,28 +1830,37 @@ static int stl_portinfo(stlport_t *portp int sigs, cnt; sp = pos; - sp += sprintf(sp, "%d: uart:%s tx:%d rx:%d", - portnr, (portp->hwid == 1) ? "SC26198" : "CD1400", - (int) portp->stats.txtotal, (int) portp->stats.rxtotal); - - if (portp->stats.rxframing) - sp += sprintf(sp, " fe:%d", (int) portp->stats.rxframing); - if (portp->stats.rxparity) - sp += sprintf(sp, " pe:%d", (int) portp->stats.rxparity); - if (portp->stats.rxbreaks) - sp += sprintf(sp, " brk:%d", (int) portp->stats.rxbreaks); - if (portp->stats.rxoverrun) - sp += sprintf(sp, " oe:%d", (int) portp->stats.rxoverrun); - - sigs = stl_getsignals(portp); - cnt = sprintf(sp, "%s%s%s%s%s ", - (sigs & TIOCM_RTS) ? "|RTS" : "", - (sigs & TIOCM_CTS) ? "|CTS" : "", - (sigs & TIOCM_DTR) ? "|DTR" : "", - (sigs & TIOCM_CD) ? "|DCD" : "", - (sigs & TIOCM_DSR) ? "|DSR" : ""); - *sp = ' '; - sp += cnt; + sp += sprintf(sp, "%d: uart:%s", + portnr, (portp->hwid == 1) ? "SC26198" : "CD1400"); + + if (capable(CAP_SYS_RAWIO)) { + sp += sprintf(sp, " tx:%d rx:%d", + (int) portp->stats.txtotal, + (int) portp->stats.rxtotal); + + if (portp->stats.rxframing) + sp += sprintf(sp, " fe:%d", + (int) portp->stats.rxframing); + if (portp->stats.rxparity) + sp += sprintf(sp, " pe:%d", + (int) portp->stats.rxparity); + if (portp->stats.rxbreaks) + sp += sprintf(sp, " brk:%d", + (int) portp->stats.rxbreaks); + if (portp->stats.rxoverrun) + sp += sprintf(sp, " oe:%d", + (int) portp->stats.rxoverrun); + + sigs = stl_getsignals(portp); + cnt = sprintf(sp, "%s%s%s%s%s ", + (sigs & TIOCM_RTS) ? "|RTS" : "", + (sigs & TIOCM_CTS) ? "|CTS" : "", + (sigs & TIOCM_DTR) ? "|DTR" : "", + (sigs & TIOCM_CD) ? "|DCD" : "", + (sigs & TIOCM_DSR) ? "|DSR" : ""); + *sp = ' '; + sp += cnt; + } for (cnt = (sp - pos); (cnt < (MAXLINE - 1)); cnt++) *sp++ = ' '; --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -1510,8 +1510,7 @@ static int sx_open (struct tty_struct * static void sx_close (void *ptr) { struct sx_port *port = ptr; - /* Give the port 5 seconds to close down. */ - int to = 5 * HZ; + unsigned long start_time, end_time; func_enter (); @@ -1519,9 +1518,13 @@ static void sx_close (void *ptr) sx_reconfigure_port(port); sx_send_command (port, HS_CLOSE, 0, 0); - while (to-- && (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED)) + /* Give the port 5 seconds to close down. */ + start_time = jiffies; + end_time = start_time + msecs_to_jiffies(5000); + while (time_before(jiffies, end_time) && (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED)) if (msleep_interruptible(10)) break; + end_time = jiffies; if (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED) { if (sx_send_command (port, HS_FORCE_CLOSED, -1, HS_IDLE_CLOSED) != 1) { printk (KERN_ERR @@ -1530,8 +1533,8 @@ static void sx_close (void *ptr) sx_dprintk (SX_DEBUG_CLOSE, "sent the force_close command.\n"); } - sx_dprintk (SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n", - 5 * HZ - to - 1, port->gs.count); + sx_dprintk (SX_DEBUG_CLOSE, "waited %ld jiffies for close. count=%d\n", + end_time - start_time, port->gs.count); if(port->gs.count) { sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", port->gs.count); @@ -2278,18 +2281,6 @@ static int sx_init_drivers(void) return 0; } - -static void * ckmalloc (int size) -{ - void *p; - - p = kmalloc(size, GFP_KERNEL); - if (p) - memset(p, 0, size); - return p; -} - - static int sx_init_portstructs (int nboards, int nports) { struct sx_board *board; @@ -2302,7 +2293,7 @@ static int sx_init_portstructs (int nboa /* Many drivers statically allocate the maximum number of ports There is no reason not to allocate them dynamically. Is there? -- REW */ - sx_ports = ckmalloc(nports * sizeof (struct sx_port)); + sx_ports = kcalloc(nports, sizeof(struct sx_port), GFP_KERNEL); if (!sx_ports) return -ENOMEM; --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c @@ -3453,8 +3453,8 @@ static int mgsl_open(struct tty_struct * /* If port is closing, signal caller to try again */ if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING)==0); retval = ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); goto cleanup; @@ -3523,6 +3523,11 @@ static inline int line_info(char *buf, s info->irq_level, info->dma_level); } + if (!capable(CAP_SYS_RAWIO)) { + strcat(buf, "\n"); + return ret + 1; + } + /* output current serial signal states */ spin_lock_irqsave(&info->irq_spinlock,flags); usc_get_serial_signals(info); @@ -4328,13 +4333,11 @@ static struct mgsl_struct* mgsl_allocate { struct mgsl_struct *info; - info = (struct mgsl_struct *)kmalloc(sizeof(struct mgsl_struct), - GFP_KERNEL); + info = kzalloc(sizeof(struct mgsl_struct), GFP_KERNEL); if (!info) { printk("Error can't allocate device instance data\n"); } else { - memset(info, 0, sizeof(struct mgsl_struct)); info->magic = MGSL_MAGIC; INIT_WORK(&info->task, mgsl_bh_handler, info); info->max_frame_size = 4096; @@ -7071,8 +7074,8 @@ static BOOLEAN mgsl_register_test( struc */ static BOOLEAN mgsl_irq_test( struct mgsl_struct *info ) { - unsigned long EndTime; unsigned long flags; + unsigned long end_time; spin_lock_irqsave(&info->irq_spinlock,flags); usc_reset(info); @@ -7099,8 +7102,8 @@ static BOOLEAN mgsl_irq_test( struct mgs spin_unlock_irqrestore(&info->irq_spinlock,flags); - EndTime=100; - while( EndTime-- && !info->irq_occurred ) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time) && !info->irq_occurred) { msleep_interruptible(10); } --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c @@ -48,7 +48,6 @@ #include #include -#include #include #include #include --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c @@ -757,8 +757,8 @@ static int open(struct tty_struct *tty, /* If port is closing, signal caller to try again */ if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ - if (info->flags & ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ASYNC_CLOSING) == 0); retval = ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); goto cleanup; @@ -1422,6 +1422,10 @@ static inline int line_info(char *buf, S info->irq_level, info->max_frame_size ); + if (!capable(CAP_SYS_RAWIO)) { + return ret; + } + /* output current serial signal states */ spin_lock_irqsave(&info->lock,flags); get_signals(info); @@ -5128,8 +5132,8 @@ int register_test(SLMP_INFO *info) int irq_test(SLMP_INFO *info) { - unsigned long timeout; unsigned long flags; + unsigned long end_time; unsigned char timer = (info->port_num & 1) ? TIMER2 : TIMER0; @@ -5163,8 +5167,8 @@ int irq_test(SLMP_INFO *info) spin_unlock_irqrestore(&info->lock,flags); - timeout=100; - while( timeout-- && !info->irq_occurred ) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time) && !info->irq_occurred) { msleep_interruptible(10); } --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c @@ -136,15 +136,17 @@ static int empty_fifo(struct tpm_chip *c static int wait(struct tpm_chip *chip, int wait_for_bit) { int status; - int i; - for (i = 0; i < TPM_MAX_TRIES; i++) { + unsigned long end_time; + + end_time = jiffies + msecs_to_jiffies(TPM_MAX_TRIES * TPM_MSLEEP_TIME); + while (time_before(jiffies, end_time)) { status = inb(chip->vendor->base + STAT); /* check the status-register if wait_for_bit is set */ if (status & 1 << wait_for_bit) break; msleep(TPM_MSLEEP_TIME); } - if (i == TPM_MAX_TRIES) { /* timeout occurs */ + if (time_after_eq(jiffies, end_time)) { /* timeout occurs */ if (wait_for_bit == STAT_XFE) dev_err(chip->dev, "Timeout in wait(STAT_XFE)\n"); if (wait_for_bit == STAT_RDA) --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -158,12 +158,7 @@ static void release_mem(struct tty_struc static struct tty_struct *alloc_tty_struct(void) { - struct tty_struct *tty; - - tty = kmalloc(sizeof(struct tty_struct), GFP_KERNEL); - if (tty) - memset(tty, 0, sizeof(struct tty_struct)); - return tty; + return kzalloc(sizeof(struct tty_struct), GFP_KERNEL); } static void tty_buffer_free_all(struct tty_struct *); @@ -1503,11 +1498,9 @@ static int init_dev(struct tty_driver *d } if (!*ltp_loc) { - ltp = (struct termios *) kmalloc(sizeof(struct termios), - GFP_KERNEL); + ltp = kzalloc(sizeof(struct termios), GFP_KERNEL); if (!ltp) goto free_mem_out; - memset(ltp, 0, sizeof(struct termios)); } if (driver->type == TTY_DRIVER_TYPE_PTY) { @@ -1536,11 +1529,9 @@ static int init_dev(struct tty_driver *d } if (!*o_ltp_loc) { - o_ltp = (struct termios *) - kmalloc(sizeof(struct termios), GFP_KERNEL); + o_ltp = kzalloc(sizeof(struct termios), GFP_KERNEL); if (!o_ltp) goto free_mem_out; - memset(o_ltp, 0, sizeof(struct termios)); } /* @@ -2994,9 +2985,8 @@ struct tty_driver *alloc_tty_driver(int { struct tty_driver *driver; - driver = kmalloc(sizeof(struct tty_driver), GFP_KERNEL); + driver = kzalloc(sizeof(struct tty_driver), GFP_KERNEL); if (driver) { - memset(driver, 0, sizeof(struct tty_driver)); driver->magic = TTY_DRIVER_MAGIC; driver->num = lines; /* later we'll move allocation of tables here */ @@ -3055,10 +3045,9 @@ int tty_register_driver(struct tty_drive return 0; if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM)) { - p = kmalloc(driver->num * 3 * sizeof(void *), GFP_KERNEL); + p = kcalloc(driver->num, 3 * sizeof(void *), GFP_KERNEL); if (!p) return -ENOMEM; - memset(p, 0, driver->num * 3 * sizeof(void *)); } if (!driver->major) { --- a/drivers/char/vt.c +++ b/drivers/char/vt.c @@ -709,10 +709,9 @@ int vc_allocate(unsigned int currcons) / /* although the numbers above are not valid since long ago, the point is still up-to-date and the comment still has its value even if only as a historical artifact. --mj, July 1998 */ - vc = kmalloc(sizeof(struct vc_data), GFP_KERNEL); + vc = kzalloc(sizeof(struct vc_data), GFP_KERNEL); if (!vc) return -ENOMEM; - memset(vc, 0, sizeof(*vc)); vc_cons[currcons].d = vc; visual_init(vc, currcons, 1); if (!*vc->vc_uni_pagedir_loc) --- a/drivers/char/watchdog/mpcore_wdt.c +++ b/drivers/char/watchdog/mpcore_wdt.c @@ -329,12 +329,11 @@ static int __devinit mpcore_wdt_probe(st goto err_out; } - wdt = kmalloc(sizeof(struct mpcore_wdt), GFP_KERNEL); + wdt = kzalloc(sizeof(struct mpcore_wdt), GFP_KERNEL); if (!wdt) { ret = -ENOMEM; goto err_out; } - memset(wdt, 0, sizeof(struct mpcore_wdt)); wdt->dev = &dev->dev; wdt->irq = platform_get_irq(dev, 0); --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c @@ -597,12 +597,11 @@ static int usb_pcwd_probe(struct usb_int maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); /* allocate memory for our device and initialize it */ - usb_pcwd = kmalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL); + usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL); if (usb_pcwd == NULL) { printk(KERN_ERR PFX "Out of memory\n"); goto error; } - memset (usb_pcwd, 0x00, sizeof (*usb_pcwd)); usb_pcwd_device = usb_pcwd; --- a/drivers/char/watchdog/wdt285.c +++ b/drivers/char/watchdog/wdt285.c @@ -204,11 +204,11 @@ static int __init footbridge_watchdog_in if (retval < 0) return retval; - printk("Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n", + printk(KERN_INFO "Footbridge Watchdog Timer: 0.01, timer margin: %d sec\n", soft_margin); if (machine_is_cats()) - printk("Warning: Watchdog reset may not work on this machine.\n"); + printk(KERN_WARNING "Warning: Watchdog reset may not work on this machine.\n"); return 0; } --- a/drivers/i2c/algos/i2c-algo-pca.c +++ b/drivers/i2c/algos/i2c-algo-pca.c @@ -187,9 +187,10 @@ static int pca_xfer(struct i2c_adapter * int numbytes = 0; int state; int ret; - int timeout = 100; + unsigned long end_time; - while ((state = pca_status(adap)) != 0xf8 && timeout--) { + end_time = jiffies + msecs_to_jiffies(1000); + while ((state = pca_status(adap)) != 0xf8 && time_before(jiffies, end_time)) { msleep(10); } if (state != 0xf8) { --- a/drivers/i2c/busses/i2c-ali1535.c +++ b/drivers/i2c/busses/i2c-ali1535.c @@ -208,7 +208,7 @@ static int ali1535_transaction(struct i2 { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, TYP=%02x, " "CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -273,15 +273,15 @@ static int ali1535_transaction(struct i2 outb_p(0xFF, SMBHSTPORT); /* We will always wait for a fraction of a second! */ - timeout = 0; + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inb_p(SMBHSTSTS); } while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE)) - && (timeout++ < MAX_TIMEOUT)); + && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { result = -1; dev_err(&adap->dev, "SMBus Timeout!\n"); } @@ -340,18 +340,18 @@ static s32 ali1535_access(struct i2c_ada { int i, len; int temp; - int timeout; s32 result = 0; + unsigned long end_time; /* make sure SMBus is idle */ temp = inb_p(SMBHSTSTS); - for (timeout = 0; - (timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE); - timeout++) { + + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); + while (time_before(jiffies, end_time) && !(temp & ALI1535_STS_IDLE)) { msleep(1); temp = inb_p(SMBHSTSTS); } - if (timeout >= MAX_TIMEOUT) + if (time_after_eq(jiffies, end_time)) dev_warn(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp); /* clear status register (clear-on-write) */ --- a/drivers/i2c/busses/i2c-ali1563.c +++ b/drivers/i2c/busses/i2c-ali1563.c @@ -66,7 +66,8 @@ static unsigned short ali1563_smba; static int ali1563_transaction(struct i2c_adapter * a, int size) { u32 data; - int timeout; + unsigned long end_time; + int timeout_reached; dev_dbg(&a->dev, "Transaction (pre): STS=%02x, CNTL1=%02x, " "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -84,10 +85,11 @@ static int ali1563_transaction(struct i2 } outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2); - timeout = ALI1563_MAX_TIMEOUT; + end_time = jiffies + msecs_to_jiffies(ALI1563_MAX_TIMEOUT); do msleep(1); - while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && --timeout); + while (((data = inb_p(SMB_HST_STS)) & HST_STS_BUSY) && time_before(jiffies, end_time)); + timeout_reached = time_after_eq(jiffies, end_time); dev_dbg(&a->dev, "Transaction (post): STS=%02x, CNTL1=%02x, " "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -95,10 +97,10 @@ static int ali1563_transaction(struct i2 inb_p(SMB_HST_CMD), inb_p(SMB_HST_ADD), inb_p(SMB_HST_DAT0), inb_p(SMB_HST_DAT1)); - if (timeout && !(data & HST_STS_BAD)) + if (timeout_reached && !(data & HST_STS_BAD)) return 0; - if (!timeout) { + if (!timeout_reached) { dev_err(&a->dev, "Timeout - Trying to KILL transaction!\n"); /* Issue 'kill' to host controller */ outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); @@ -128,7 +130,8 @@ static int ali1563_transaction(struct i2 static int ali1563_block_start(struct i2c_adapter * a) { u32 data; - int timeout; + unsigned long end_time; + int timeout_reached; dev_dbg(&a->dev, "Block (pre): STS=%02x, CNTL1=%02x, " "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -151,10 +154,11 @@ static int ali1563_block_start(struct i2 /* Start transaction and wait for byte-ready bit to be set */ outb_p(inb_p(SMB_HST_CNTL2) | HST_CNTL2_START, SMB_HST_CNTL2); - timeout = ALI1563_MAX_TIMEOUT; + end_time = jiffies + msecs_to_jiffies(ALI1563_MAX_TIMEOUT); do msleep(1); - while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && --timeout); + while (!((data = inb_p(SMB_HST_STS)) & HST_STS_DONE) && time_before(jiffies, end_time)); + timeout_reached = time_after_eq(jiffies, end_time); dev_dbg(&a->dev, "Block (post): STS=%02x, CNTL1=%02x, " "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -162,10 +166,10 @@ static int ali1563_block_start(struct i2 inb_p(SMB_HST_CMD), inb_p(SMB_HST_ADD), inb_p(SMB_HST_DAT0), inb_p(SMB_HST_DAT1)); - if (timeout && !(data & HST_STS_BAD)) + if (timeout_reached && !(data & HST_STS_BAD)) return 0; dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n", - timeout ? "Timeout " : "", + timeout_reached ? "Timeout " : "", data & HST_STS_FAIL ? "Transaction Failed " : "", data & HST_STS_BUSERR ? "No response or Bus Collision " : "", data & HST_STS_DEVERR ? "Device Error " : "", --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -231,7 +231,7 @@ static int ali15x3_transaction(struct i2 { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, " "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), @@ -296,15 +296,15 @@ static int ali15x3_transaction(struct i2 outb_p(0xFF, SMBHSTSTART); /* We will always wait for a fraction of a second! */ - timeout = 0; + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inb_p(SMBHSTSTS); } while ((!(temp & (ALI15X3_STS_ERR | ALI15X3_STS_DONE))) - && (timeout++ < MAX_TIMEOUT)); + && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { result = -1; dev_err(&adap->dev, "SMBus Timeout!\n"); } @@ -346,19 +346,19 @@ static s32 ali15x3_access(struct i2c_ada { int i, len; int temp; - int timeout; + unsigned long end_time; /* clear all the bits (clear-on-write) */ outb_p(0xFF, SMBHSTSTS); /* make sure SMBus is idle */ temp = inb_p(SMBHSTSTS); - for (timeout = 0; - (timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE); - timeout++) { + + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); + while (time_before(jiffies, end_time) && !(temp & ALI15X3_STS_IDLE)) { msleep(1); temp = inb_p(SMBHSTSTS); } - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_err(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp); } --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -113,7 +113,7 @@ static int amd756_transaction(struct i2c { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; dev_dbg(&adap->dev, "Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, " "DAT=%04x\n", inw_p(SMB_GLOBAL_STATUS), @@ -123,30 +123,32 @@ static int amd756_transaction(struct i2c /* Make sure the SMBus host is ready to start transmitting */ if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) { dev_dbg(&adap->dev, "SMBus busy (%04x). Waiting...\n", temp); + + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inw_p(SMB_GLOBAL_STATUS); } while ((temp & (GS_HST_STS | GS_SMB_STS)) && - (timeout++ < MAX_TIMEOUT)); + time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp); goto abort; } - timeout = 0; } /* start the transaction by setting the start bit */ outw_p(inw(SMB_GLOBAL_ENABLE) | GE_HOST_STC, SMB_GLOBAL_ENABLE); /* We will always wait for a fraction of a second! */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inw_p(SMB_GLOBAL_STATUS); - } while ((temp & GS_HST_STS) && (timeout++ < MAX_TIMEOUT)); + } while ((temp & GS_HST_STS) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&adap->dev, "Completion timeout!\n"); goto abort; } --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -182,7 +182,7 @@ static int i801_transaction(void) { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; dev_dbg(&I801_dev->dev, "Transaction (pre): CNT=%02x, CMD=%02x, " "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), @@ -206,13 +206,14 @@ static int i801_transaction(void) outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT); /* We will always wait for a fraction of a second! */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inb_p(SMBHSTSTS); - } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); + } while ((temp & 0x01) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); result = -1; } @@ -256,8 +257,8 @@ static int i801_block_transaction(union int smbcmd; int temp; int result = 0; - int timeout; unsigned char hostc, errmask; + unsigned long end_time; if (command == I2C_SMBUS_I2C_BLOCK_DATA) { if (read_write == I2C_SMBUS_WRITE) { @@ -332,16 +333,15 @@ static int i801_block_transaction(union outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT); /* We will always wait for a fraction of a second! */ - timeout = 0; + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { temp = inb_p(SMBHSTSTS); msleep(1); - } - while ((!(temp & 0x80)) - && (timeout++ < MAX_TIMEOUT)); + } while ((!(temp & 0x80)) + && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { result = -1; dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); } @@ -391,14 +391,14 @@ static int i801_block_transaction(union if (hwpec) { /* wait for INTR bit as advised by Intel */ - timeout = 0; + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { temp = inb_p(SMBHSTSTS); msleep(1); } while ((!(temp & 0x02)) - && (timeout++ < MAX_TIMEOUT)); + && time_before(jiffies, end_time)); - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&I801_dev->dev, "PEC Timeout!\n"); } outb_p(temp, SMBHSTSTS); --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -234,7 +234,7 @@ static int piix4_transaction(void) { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), @@ -258,13 +258,14 @@ static int piix4_transaction(void) outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inb_p(SMBHSTSTS); - } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); + } while ((temp & 0x01) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); result = -1; } --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -191,20 +191,23 @@ static void i2c_pxa_abort(struct pxa_i2c static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c) { - int timeout = DEF_TIMEOUT; + int timeout_reached; + unsigned long end_time; - while (timeout-- && ISR & (ISR_IBB | ISR_UB)) { + end_time = jiffies + msecs_to_jiffies(DEF_TIMEOUT * 2); + while (time_before(jiffies, end_time) && ISR & (ISR_IBB | ISR_UB)) { if ((ISR & ISR_SAD) != 0) - timeout += 4; + end_time += msecs_to_jiffies(8); msleep(2); show_state(i2c); } + timeout_reached = time_after_eq(jiffies, end_time); - if (timeout <= 0) + if (timeout_reached) show_state(i2c); - return timeout <= 0 ? I2C_RETRY : 0; + return timeout_reached ? I2C_RETRY : 0; } static int i2c_pxa_wait_master(struct pxa_i2c *i2c) --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -465,9 +465,10 @@ static irqreturn_t s3c24xx_i2c_irq(int i static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c) { unsigned long iicstat; - int timeout = 400; + unsigned long end_time; - while (timeout-- > 0) { + end_time = jiffies + msecs_to_jiffies(400); + while (time_before(jiffies, end_time)) { iicstat = readl(i2c->regs + S3C2410_IICSTAT); if (!(iicstat & S3C2410_IICSTAT_BUSBUSY)) --- a/drivers/i2c/busses/i2c-sis5595.c +++ b/drivers/i2c/busses/i2c-sis5595.c @@ -225,7 +225,7 @@ static int sis5595_transaction(struct i2 { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; /* Make sure the SMBus host is ready to start transmitting */ temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8); @@ -245,13 +245,14 @@ static int sis5595_transaction(struct i2 sis5595_write(SMB_CTL_LO, sis5595_read(SMB_CTL_LO) | 0x10); /* We will always wait for a fraction of a second! */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = sis5595_read(SMB_STS_LO); - } while (!(temp & 0x40) && (timeout++ < MAX_TIMEOUT)); + } while (!(temp & 0x40) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&adap->dev, "SMBus Timeout!\n"); result = -1; } --- a/drivers/i2c/busses/i2c-sis630.c +++ b/drivers/i2c/busses/i2c-sis630.c @@ -163,19 +163,21 @@ static int sis630_transaction_start(stru static int sis630_transaction_wait(struct i2c_adapter *adap, int size) { - int temp, result = 0, timeout = 0; + int temp, result = 0; + unsigned long end_time; /* We will always wait for a fraction of a second! */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = sis630_read(SMB_STS); /* check if block transmitted */ if (size == SIS630_BLOCK_DATA && (temp & 0x10)) break; - } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); + } while (!(temp & 0x0e) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&adap->dev, "SMBus Timeout!\n"); result = -1; } --- a/drivers/i2c/busses/i2c-sis96x.c +++ b/drivers/i2c/busses/i2c-sis96x.c @@ -103,7 +103,7 @@ static int sis96x_transaction(int size) { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; dev_dbg(&sis96x_adapter.dev, "SMBus transaction %d\n", size); @@ -136,13 +136,14 @@ static int sis96x_transaction(int size) sis96x_write(SMB_HOST_CNT, 0x10 | (size & 0x07)); /* We will always wait for a fraction of a second! */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = sis96x_read(SMB_STS); - } while (!(temp & 0x0e) && (timeout++ < MAX_TIMEOUT)); + } while (!(temp & 0x0e) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp); result = -1; } --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c @@ -135,7 +135,7 @@ static int vt596_transaction(u8 size) { int temp; int result = 0; - int timeout = 0; + unsigned long end_time; vt596_dump_regs("Transaction (pre)", size); @@ -156,13 +156,14 @@ static int vt596_transaction(u8 size) outb_p(0x40 | size, SMBHSTCNT); /* We will always wait for a fraction of a second */ + end_time = jiffies + msecs_to_jiffies(MAX_TIMEOUT); do { msleep(1); temp = inb_p(SMBHSTSTS); - } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT)); + } while ((temp & 0x01) && time_before(jiffies, end_time)); /* If the SMBus is still busy, we give up */ - if (timeout >= MAX_TIMEOUT) { + if (time_after_eq(jiffies, end_time)) { result = -1; dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); } --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1041,7 +1041,7 @@ int ide_read_setting (ide_drive_t *drive int ide_spin_wait_hwgroup (ide_drive_t *drive) { - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; unsigned long timeout = jiffies + (3 * HZ); spin_lock_irq(&ide_lock); @@ -1366,13 +1366,12 @@ int generic_ide_ioctl(ide_drive_t *drive ide_abort(drive, "drive reset"); - if(HWGROUP(drive)->handler) - BUG(); + BUG_ON(drive->hwif->hwgroup->handler); /* Ensure nothing gets queued after we drop the lock. Reset will clear the busy */ - HWGROUP(drive)->busy = 1; + drive->hwif->hwgroup->busy = 1; spin_unlock_irqrestore(&ide_lock, flags); (void) ide_do_reset(drive); --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -591,7 +591,7 @@ static void cdrom_queue_request_sense(id static void cdrom_end_request (ide_drive_t *drive, int uptodate) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; int nsectors = rq->hard_cur_sectors; if ((rq->flags & REQ_SENSE) && uptodate) { @@ -637,7 +637,7 @@ static void cdrom_end_request (ide_drive Returns 1 if the request was ended. */ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; int stat, err, sense_key; /* Check for errors. */ @@ -701,7 +701,7 @@ static int cdrom_decode_status(ide_drive if (stat & ERR_STAT) { spin_lock_irqsave(&ide_lock, flags); blkdev_dequeue_request(rq); - HWGROUP(drive)->rq = NULL; + drive->hwif->hwgroup->rq = NULL; spin_unlock_irqrestore(&ide_lock, flags); cdrom_queue_request_sense(drive, rq->sense, rq); @@ -800,7 +800,7 @@ static int cdrom_decode_status(ide_drive static int cdrom_timer_expiry(ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; unsigned long wait = 0; /* @@ -1025,7 +1025,7 @@ static ide_startstop_t cdrom_read_intr ( u8 lowcyl = 0, highcyl = 0; int dma = info->dma, dma_error = 0; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; /* * handle dma case @@ -1152,7 +1152,7 @@ static ide_startstop_t cdrom_read_intr ( static int cdrom_read_from_buffer (ide_drive_t *drive) { struct cdrom_info *info = drive->driver_data; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; unsigned short sectors_per_frame; sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; @@ -1212,7 +1212,7 @@ static int cdrom_read_from_buffer (ide_d */ static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; unsigned short sectors_per_frame; int nskip; @@ -1275,7 +1275,7 @@ static ide_startstop_t cdrom_seek_intr ( static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; sector_t frame = rq->sector; sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); @@ -1320,7 +1320,7 @@ static void restore_request (struct requ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block) { struct cdrom_info *info = drive->driver_data; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; unsigned short sectors_per_frame; sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS; @@ -1354,7 +1354,7 @@ static ide_startstop_t cdrom_start_read static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) { int ireason, len, thislen; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; u8 lowcyl = 0, highcyl = 0; int stat; @@ -1463,7 +1463,7 @@ confused: static ide_startstop_t cdrom_do_pc_continuation (ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; if (!rq->timeout) rq->timeout = ATAPI_WAIT_PC; @@ -1476,7 +1476,7 @@ static ide_startstop_t cdrom_do_pc_conti static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive) { int len; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; struct cdrom_info *info = drive->driver_data; info->dma = 0; @@ -1604,7 +1604,7 @@ typedef void (xfer_func_t)(ide_drive_t * static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) { struct cdrom_info *info = drive->driver_data; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; int dma_error, dma, stat, ireason, len, thislen; u8 lowcyl, highcyl; xfer_func_t *xferfunc; @@ -1722,9 +1722,6 @@ static ide_startstop_t cdrom_newpc_intr( } } - if (HWGROUP(drive)->handler != NULL) - BUG(); - ide_set_handler(drive, cdrom_newpc_intr, rq->timeout, NULL); return ide_started; @@ -1735,7 +1732,7 @@ end_request: spin_lock_irqsave(&ide_lock, flags); blkdev_dequeue_request(rq); end_that_request_last(rq, 1); - HWGROUP(drive)->rq = NULL; + drive->hwif->hwgroup->rq = NULL; spin_unlock_irqrestore(&ide_lock, flags); return ide_stopped; } @@ -1747,7 +1744,7 @@ static ide_startstop_t cdrom_write_intr( int dma_error = 0, dma = info->dma; u8 lowcyl = 0, highcyl = 0; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; /* Check for errors. */ if (dma) { @@ -1840,7 +1837,7 @@ static ide_startstop_t cdrom_write_intr( static ide_startstop_t cdrom_start_write_cont(ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; #if 0 /* the immediate bit */ rq->cmd[1] = 1 << 3; @@ -1887,7 +1884,7 @@ static ide_startstop_t cdrom_start_write static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; if (!rq->timeout) rq->timeout = ATAPI_WAIT_PC; --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -170,7 +170,7 @@ ide_startstop_t ide_dma_intr (ide_drive_ stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */ if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { if (!dma_stat) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; if (rq->rq_disk) { ide_driver_t *drv; @@ -206,8 +206,7 @@ int ide_build_sglist(ide_drive_t *drive, ide_hwif_t *hwif = HWIF(drive); struct scatterlist *sg = hwif->sg_table; - if ((rq->flags & REQ_DRIVE_TASKFILE) && rq->nr_sectors > 256) - BUG(); + BUG_ON((rq->flags & REQ_DRIVE_TASKFILE) && rq->nr_sectors > 256); ide_map_sg(drive, rq); @@ -403,7 +402,7 @@ static int dma_timer_expiry (ide_drive_t if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */ return WAIT_CMD; - HWGROUP(drive)->expiry = NULL; /* one free ride for now */ + drive->hwif->hwgroup->expiry = NULL; /* one free ride for now */ /* 1 dmaing, 2 error, 4 intr */ if (dma_stat & 2) /* ERROR */ @@ -553,7 +552,7 @@ EXPORT_SYMBOL(__ide_dma_check); int ide_dma_setup(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; unsigned int reading; u8 dma_stat; @@ -947,8 +946,7 @@ void ide_setup_dma (ide_hwif_t *hwif, un } printk("\n"); - if (!(hwif->dma_master)) - BUG(); + BUG_ON(!(hwif->dma_master)); } EXPORT_SYMBOL_GPL(ide_setup_dma); --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -574,7 +574,7 @@ static void idefloppy_write_zeros (ide_d static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) { idefloppy_floppy_t *floppy = drive->driver_data; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; int error; debug_log(KERN_INFO "Reached idefloppy_end_request\n"); @@ -898,8 +898,6 @@ static ide_startstop_t idefloppy_pc_intr "to send us more data than expected " "- discarding data\n"); idefloppy_discard_data(drive,bcount.all); - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, @@ -932,8 +930,6 @@ static ide_startstop_t idefloppy_pc_intr pc->actually_transferred += bcount.all; pc->current_position += bcount.all; - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* And set the interrupt handler again */ return ide_started; } @@ -960,8 +956,6 @@ static ide_startstop_t idefloppy_transfe "issuing a packet command\n"); return ide_do_reset(drive); } - if (HWGROUP(drive)->handler != NULL) - BUG(); /* Set the interrupt routine */ ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); /* Send the actual packet */ @@ -1017,8 +1011,6 @@ static ide_startstop_t idefloppy_transfe * 40 and 50msec work well. idefloppy_pc_intr will not be actually * used until after the packet is moved in about 50 msec. */ - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &idefloppy_pc_intr, /* service routine for packet command */ floppy->ticks, /* wait this long before "failing" */ --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -78,13 +78,13 @@ static int __ide_end_request(ide_drive_t */ if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) { drive->state = 0; - HWGROUP(drive)->hwif->ide_dma_on(drive); + drive->hwif->hwgroup->hwif->ide_dma_on(drive); } if (!end_that_request_first(rq, uptodate, nr_sectors)) { add_disk_randomness(rq->rq_disk); blkdev_dequeue_request(rq); - HWGROUP(drive)->rq = NULL; + drive->hwif->hwgroup->rq = NULL; end_that_request_last(rq, uptodate); ret = 0; } @@ -114,7 +114,7 @@ int ide_end_request (ide_drive_t *drive, * need the queue lock held at all */ spin_lock_irqsave(&ide_lock, flags); - rq = HWGROUP(drive)->rq; + rq = drive->hwif->hwgroup->rq; if (!nr_sectors) nr_sectors = rq->hard_cur_sectors; @@ -243,7 +243,7 @@ static void ide_complete_pm_request (ide blk_start_queue(drive->queue); } blkdev_dequeue_request(rq); - HWGROUP(drive)->rq = NULL; + drive->hwif->hwgroup->rq = NULL; end_that_request_last(rq, 1); spin_unlock_irqrestore(&ide_lock, flags); } @@ -304,7 +304,7 @@ void ide_end_drive_cmd (ide_drive_t *dri struct request *rq; spin_lock_irqsave(&ide_lock, flags); - rq = HWGROUP(drive)->rq; + rq = drive->hwif->hwgroup->rq; spin_unlock_irqrestore(&ide_lock, flags); if (rq->flags & REQ_DRIVE_CMD) { @@ -374,7 +374,7 @@ void ide_end_drive_cmd (ide_drive_t *dri spin_lock_irqsave(&ide_lock, flags); blkdev_dequeue_request(rq); - HWGROUP(drive)->rq = NULL; + drive->hwif->hwgroup->rq = NULL; rq->errors = err; end_that_request_last(rq, !rq->errors); spin_unlock_irqrestore(&ide_lock, flags); @@ -523,7 +523,7 @@ ide_startstop_t ide_error (ide_drive_t * err = ide_dump_status(drive, msg, stat); - if ((rq = HWGROUP(drive)->rq) == NULL) + if ((rq = drive->hwif->hwgroup->rq) == NULL) return ide_stopped; /* retry only "normal" I/O: */ @@ -574,7 +574,7 @@ ide_startstop_t ide_abort(ide_drive_t *d { struct request *rq; - if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL) + if (drive == NULL || (rq = drive->hwif->hwgroup->rq) == NULL) return ide_stopped; /* retry only "normal" I/O: */ @@ -627,7 +627,7 @@ static void ide_cmd (ide_drive_t *drive, static ide_startstop_t drive_cmd_intr (ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; ide_hwif_t *hwif = HWIF(drive); u8 *args = (u8 *) rq->buffer; u8 stat = hwif->INB(IDE_STATUS_REG); @@ -1235,7 +1235,7 @@ void do_ide_request(request_queue_t *q) { ide_drive_t *drive = q->queuedata; - ide_do_request(HWGROUP(drive), IDE_NO_IRQ); + ide_do_request(drive->hwif->hwgroup, IDE_NO_IRQ); } /* @@ -1276,8 +1276,8 @@ static ide_startstop_t ide_dma_timeout_r * un-busy drive etc (hwgroup->busy is cleared on return) and * make sure request is sane */ - rq = HWGROUP(drive)->rq; - HWGROUP(drive)->rq = NULL; + rq = drive->hwif->hwgroup->rq; + drive->hwif->hwgroup->rq = NULL; rq->errors = 0; @@ -1635,7 +1635,7 @@ EXPORT_SYMBOL(ide_init_drive_cmd); int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action) { unsigned long flags; - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; DECLARE_COMPLETION(wait); int where = ELEVATOR_INSERT_BACK, err; int must_wait = (action == ide_wait || action == ide_head_wait); --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -768,7 +768,7 @@ int ide_config_drive_speed (ide_drive_t int i, error = 1; u8 stat; -// while (HWGROUP(drive)->busy) +// while (drive->hwif->hwgroup->busy) // msleep(50); #ifdef CONFIG_BLK_DEV_IDEDMA @@ -893,12 +893,13 @@ EXPORT_SYMBOL(ide_config_drive_speed); static void __ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry) { - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; if (hwgroup->handler != NULL) { printk(KERN_CRIT "%s: ide_set_handler: handler not null; " "old=%p, new=%p\n", drive->name, hwgroup->handler, handler); + BUG(); } hwgroup->handler = handler; hwgroup->expiry = expiry; @@ -934,13 +935,12 @@ EXPORT_SYMBOL(ide_set_handler); void ide_execute_command(ide_drive_t *drive, task_ioreg_t cmd, ide_handler_t *handler, unsigned timeout, ide_expiry_t *expiry) { unsigned long flags; - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; ide_hwif_t *hwif = HWIF(drive); spin_lock_irqsave(&ide_lock, flags); - if(hwgroup->handler) - BUG(); + BUG_ON(hwgroup->handler); hwgroup->handler = handler; hwgroup->expiry = expiry; hwgroup->timer.expires = jiffies + timeout; @@ -970,7 +970,7 @@ static ide_startstop_t do_reset1 (ide_dr */ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) { - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; ide_hwif_t *hwif = HWIF(drive); u8 stat; @@ -981,8 +981,6 @@ static ide_startstop_t atapi_reset_pollf printk("%s: ATAPI reset complete\n", drive->name); } else { if (time_before(jiffies, hwgroup->poll_timeout)) { - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); /* continue polling */ return ide_started; @@ -1007,7 +1005,7 @@ static ide_startstop_t atapi_reset_pollf */ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) { - ide_hwgroup_t *hwgroup = HWGROUP(drive); + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; ide_hwif_t *hwif = HWIF(drive); u8 tmp; @@ -1021,8 +1019,6 @@ static ide_startstop_t reset_pollfunc (i if (!OK_STAT(tmp = hwif->INB(IDE_STATUS_REG), 0, BUSY_STAT)) { if (time_before(jiffies, hwgroup->poll_timeout)) { - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); /* continue polling */ return ide_started; @@ -1135,11 +1131,10 @@ static ide_startstop_t do_reset1 (ide_dr spin_lock_irqsave(&ide_lock, flags); hwif = HWIF(drive); - hwgroup = HWGROUP(drive); + hwgroup = drive->hwif->hwgroup; /* We must not reset with running handlers */ - if(hwgroup->handler != NULL) - BUG(); + BUG_ON(hwgroup->handler != NULL); /* For an ATAPI device, first try an ATAPI SRST. */ if (drive->media != ide_disk && !do_not_try_atapi) { --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c @@ -164,8 +164,7 @@ u8 ide_rate_filter (u8 mode, u8 speed) // printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); /* So that we remember to update this if new modes appear */ - if (mode > 4) - BUG(); + BUG_ON(mode > 4); return min(speed, speed_max[mode]); #else /* !CONFIG_BLK_DEV_IDEDMA */ return min(speed, (u8)XFER_PIO_4); @@ -453,8 +452,8 @@ static void ide_dump_opcode(ide_drive_t spin_lock(&ide_lock); rq = NULL; - if (HWGROUP(drive)) - rq = HWGROUP(drive)->rq; + if (drive->hwif->hwgroup) + rq = drive->hwif->hwgroup->rq; spin_unlock(&ide_lock); if (!rq) return; @@ -539,9 +538,10 @@ static u8 ide_dump_ata_status(ide_drive_ hwif->INB(IDE_SECTOR_REG)); } } - if (HWGROUP(drive) && HWGROUP(drive)->rq) + if (drive->hwif->hwgroup && drive->hwif->hwgroup->rq) printk(", sector=%llu", - (unsigned long long)HWGROUP(drive)->rq->sector); + (unsigned long long) + drive->hwif->hwgroup->rq->sector); } printk("\n"); } --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -1682,7 +1682,7 @@ static void idetape_abort_pipeline(ide_d */ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; idetape_tape_t *tape = drive->driver_data; unsigned long flags; int error; @@ -1845,7 +1845,7 @@ static void idetape_postpone_request (id if (tape->debug_level >= 4) printk(KERN_INFO "ide-tape: idetape_postpone_request\n"); #endif - tape->postponed_rq = HWGROUP(drive)->rq; + tape->postponed_rq = drive->hwif->hwgroup->rq; ide_stall_queue(drive, tape->dsc_polling_frequency); } @@ -2323,7 +2323,7 @@ static ide_startstop_t idetape_media_acc static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) { idetape_tape_t *tape = drive->driver_data; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; int blocks = tape->pc->actually_transferred / tape->tape_block_size; tape->avg_size += blocks * tape->tape_block_size; --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -196,8 +196,6 @@ ide_startstop_t set_geometry_intr (ide_d if (stat & (ERR_STAT|DRQ_STAT)) return ide_error(drive, "set_geometry_intr", stat); - if (HWGROUP(drive)->handler != NULL) - BUG(); ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); return ide_started; } @@ -220,7 +218,7 @@ ide_startstop_t recal_intr (ide_drive_t */ ide_startstop_t task_no_data_intr (ide_drive_t *drive) { - ide_task_t *args = HWGROUP(drive)->rq->special; + ide_task_t *args = drive->hwif->hwgroup->rq->special; ide_hwif_t *hwif = HWIF(drive); u8 stat; @@ -390,7 +388,7 @@ static void task_end_request(ide_drive_t ide_startstop_t task_in_intr (ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; u8 stat = hwif->INB(IDE_STATUS_REG); /* new way for dealing with premature shared PCI interrupts */ @@ -426,7 +424,7 @@ EXPORT_SYMBOL(task_in_intr); static ide_startstop_t task_out_intr (ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; u8 stat = hwif->INB(IDE_STATUS_REG); if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) --- a/drivers/ide/legacy/hd.c +++ b/drivers/ide/legacy/hd.c @@ -456,11 +456,6 @@ ok_to_read: req->errors = 0; i = --req->nr_sectors; --req->current_nr_sectors; -#ifdef DEBUG - printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n", - req->rq_disk->disk_name, req->sector, req->nr_sectors, - req->buffer+512)); -#endif if (req->current_nr_sectors <= 0) end_request(req, 1); if (i > 0) { @@ -542,12 +537,8 @@ static void hd_times_out(unsigned long d reset = 1; name = CURRENT->rq_disk->disk_name; printk("%s: timeout\n", name); - if (++CURRENT->errors >= MAX_ERRORS) { -#ifdef DEBUG - printk("%s: too many errors\n", name); -#endif + if (++CURRENT->errors >= MAX_ERRORS) end_request(CURRENT, 0); - } local_irq_disable(); hd_request(); enable_irq(HD_IRQ); @@ -621,11 +612,6 @@ repeat: track = block / disk->sect; head = track % disk->head; cyl = track / disk->head; -#ifdef DEBUG - printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n", - req->rq_disk->disk_name, (req->cmd == READ)?"read":"writ", - cyl, head, sec, nsect, req->buffer); -#endif if (req->flags & REQ_CMD) { switch (rq_data_dir(req)) { case READ: --- a/drivers/ide/mips/au1xxx-ide.c +++ b/drivers/ide/mips/au1xxx-ide.c @@ -273,7 +273,7 @@ static int auide_build_dmatable(ide_driv int i, iswrite, count = 0; ide_hwif_t *hwif = HWIF(drive); - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; struct scatterlist *sg; @@ -379,7 +379,7 @@ static void auide_dma_exec_cmd(ide_drive static int auide_dma_setup(ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; if (!auide_build_dmatable(drive)) { ide_map_sg(drive, rq); --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c @@ -413,7 +413,7 @@ static void pdc202xx_old_ide_dma_start(i if (drive->current_speed > XFER_UDMA_2) pdc_old_enable_66MHz_clock(drive->hwif); if (drive->addressing == 1) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; ide_hwif_t *hwif = HWIF(drive); // struct pci_dev *dev = hwif->pci_dev; // unsgned long high_16 = pci_resource_start(dev, 4); --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c @@ -547,7 +547,7 @@ use_pio_instead: static int sgiioc4_ide_dma_setup(ide_drive_t *drive) { - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; unsigned int count = 0; int ddir; --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c @@ -474,7 +474,7 @@ static int siimage_io_ide_dma_test_irq ( static int siimage_mmio_ide_dma_count (ide_drive_t *drive) { #ifdef SIIMAGE_VIRTUAL_DMAPIO - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; ide_hwif_t *hwif = HWIF(drive); u32 count = (rq->nr_sectors * SECTOR_SIZE); u32 rcount = 0; @@ -596,7 +596,7 @@ static int siimage_reset_poll (ide_drive if ((hwif->INL(SATA_STATUS_REG) & 0x03) != 0x03) { printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", hwif->name, hwif->INL(SATA_STATUS_REG)); - HWGROUP(drive)->polling = 0; + drive->hwif->hwgroup->polling = 0; return ide_started; } return 0; --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c @@ -183,8 +183,6 @@ static void trm290_ide_dma_exec_cmd(ide_ { ide_hwif_t *hwif = HWIF(drive); - if (HWGROUP(drive)->handler != NULL) /* paranoia check */ - BUG(); ide_set_handler(drive, &ide_dma_intr, WAIT_CMD, NULL); /* issue cmd to drive */ hwif->OUTB(command, IDE_COMMAND_REG); --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c @@ -1966,7 +1966,7 @@ pmac_ide_dma_setup(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); pmac_ide_hwif_t* pmif = (pmac_ide_hwif_t *)hwif->hwif_data; - struct request *rq = HWGROUP(drive)->rq; + struct request *rq = drive->hwif->hwgroup->rq; u8 unit = (drive->select.b.unit & 0x01); u8 ata4; --- a/drivers/infiniband/hw/mthca/mthca_reset.c +++ b/drivers/infiniband/hw/mthca/mthca_reset.c @@ -153,9 +153,10 @@ int mthca_reset(struct mthca_dev *mdev) /* Now wait for PCI device to start responding again */ { u32 v; - int c = 0; + unsigned long end_time; - for (c = 0; c < 100; ++c) { + end_time = jiffies + msecs_to_jiffies(10000); + while (time_before(jiffies, end_time)) { if (pci_read_config_dword(bridge ? bridge : mdev->pdev, 0, &v)) { err = -ENODEV; mthca_err(mdev, "Couldn't access HCA after reset, " --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c @@ -576,6 +576,7 @@ static int analog_init_masks(struct anal static int analog_init_port(struct gameport *gameport, struct gameport_driver *drv, struct analog_port *port) { int i, t, u, v; + unsigned long end_time; port->gameport = gameport; @@ -591,7 +592,8 @@ static int analog_init_port(struct gamep port->mask = (gameport_read(gameport) ^ t) & t & 0xf; port->fuzz = (port->speed * ANALOG_FUZZ_MAGIC) / port->loop / 1000 + ANALOG_FUZZ_BITS; - for (i = 0; i < ANALOG_INIT_RETRIES; i++) { + end_time = jiffies + msecs_to_jiffies(ANALOG_MAX_TIME * ANALOG_INIT_RETRIES); + while (time_before(jiffies, end_time)) { if (!analog_cooked_read(port)) break; msleep(ANALOG_MAX_TIME); --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -150,7 +150,7 @@ static unsigned char atkbd_unxlate_table #define ATKBD_RET_EMUL0 0xe0 #define ATKBD_RET_EMUL1 0xe1 #define ATKBD_RET_RELEASE 0xf0 -#define ATKBD_RET_HANGUEL 0xf1 +#define ATKBD_RET_HANGEUL 0xf1 #define ATKBD_RET_HANJA 0xf2 #define ATKBD_RET_ERR 0xff @@ -304,7 +304,7 @@ static irqreturn_t atkbd_interrupt(struc if (atkbd->emul || (code != ATKBD_RET_EMUL0 && code != ATKBD_RET_EMUL1 && - code != ATKBD_RET_HANGUEL && code != ATKBD_RET_HANJA && + code != ATKBD_RET_HANGEUL && code != ATKBD_RET_HANJA && (code != ATKBD_RET_ERR || atkbd->err_xl) && (code != ATKBD_RET_BAT || atkbd->bat_xl))) { atkbd->release = code >> 7; @@ -333,8 +333,8 @@ static irqreturn_t atkbd_interrupt(struc case ATKBD_RET_RELEASE: atkbd->release = 1; goto out; - case ATKBD_RET_HANGUEL: - atkbd_report_key(atkbd->dev, regs, KEY_HANGUEL, 3); + case ATKBD_RET_HANGEUL: + atkbd_report_key(atkbd->dev, regs, KEY_HANGEUL, 3); goto out; case ATKBD_RET_HANJA: atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3); --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c @@ -690,14 +690,24 @@ static struct miscdevice hp_sdc_rtc_dev static int __init hp_sdc_rtc_init(void) { int ret; + struct proc_dir_entry* proc_de; init_MUTEX(&i8042tregs); if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) return ret; - misc_register(&hp_sdc_rtc_dev); - create_proc_read_entry ("driver/rtc", 0, 0, + ret = misc_register(&hp_sdc_rtc_dev); + if (ret) { + printk(KERN_WARNING "hp_sdc_rtc: " + "Unable to register misc device.\n"); + return ret; + } + proc_de = create_proc_read_entry("driver/rtc", 0, 0, hp_sdc_rtc_read_proc, NULL); + if (proc_de == NULL) { + printk(KERN_WARNING "hp_sdc_rtc: " + "Unable to create proc dir entry.\n"); + } printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded " "(RTC v " RTC_VERSION ")\n"); --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c @@ -674,13 +674,8 @@ capi_read(struct file *file, char __user if (file->f_flags & O_NONBLOCK) return -EAGAIN; - for (;;) { - interruptible_sleep_on(&cdev->recvwait); - if ((skb = skb_dequeue(&cdev->recvqueue)) != 0) - break; - if (signal_pending(current)) - break; - } + wait_event_interruptible(cdev->recvwait, + ((skb = skb_dequeue(&cdev->recvqueue)) == 0)); if (skb == 0) return -ERESTARTNOHAND; } --- a/drivers/isdn/hardware/eicon/debug.c +++ b/drivers/isdn/hardware/eicon/debug.c @@ -756,14 +756,14 @@ int diva_get_driver_info (dword id, byte data_length -= 9; - if ((to_copy = MIN(strlen(clients[id].drvName), data_length-1))) { + if ((to_copy = min(strlen(clients[id].drvName), data_length-1))) { memcpy (p, clients[id].drvName, to_copy); p += to_copy; data_length -= to_copy; if ((data_length >= 4) && clients[id].hDbg->drvTag[0]) { *p++ = '('; data_length -= 1; - if ((to_copy = MIN(strlen(clients[id].hDbg->drvTag), data_length-2))) { + if ((to_copy = min(strlen(clients[id].hDbg->drvTag), data_length-2))) { memcpy (p, clients[id].hDbg->drvTag, to_copy); p += to_copy; data_length -= to_copy; --- a/drivers/isdn/hardware/eicon/io.c +++ b/drivers/isdn/hardware/eicon/io.c @@ -262,7 +262,7 @@ void request(PISDN_ADAPTER IoAdapter, EN case IDI_SYNC_REQ_XDI_GET_CAPI_PARAMS: { diva_xdi_get_capi_parameters_t prms, *pI = &syncReq->xdi_capi_prms.info; memset (&prms, 0x00, sizeof(prms)); - prms.structure_length = MIN(sizeof(prms), pI->structure_length); + prms.structure_length = min(sizeof(prms), pI->structure_length); memset (pI, 0x00, pI->structure_length); prms.flag_dynamic_l1_down = (IoAdapter->capi_cfg.cfg_1 & \ DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? 1 : 0; --- a/drivers/isdn/hardware/eicon/platform.h +++ b/drivers/isdn/hardware/eicon/platform.h @@ -228,7 +228,7 @@ void PCIread (byte bus, byte func, int o /* ** I/O Port utilities */ -int diva_os_register_io_port (void *adapter, int register, unsigned long port, +int diva_os_register_io_port (void *adapter, int on, unsigned long port, unsigned long length, const char* name, int id); /* ** I/O port access abstraction --- a/drivers/isdn/hisax/diva.c +++ b/drivers/isdn/hisax/diva.c @@ -1101,6 +1101,7 @@ setup_diva(struct IsdnCard *card) bytecnt = 32; } } + goto ready; /* Assure that `ready' is used even if `__ISAPNP__' isn't. */ ready: printk(KERN_INFO "Diva: %s card configured at %#lx IRQ %d\n", --- a/drivers/isdn/hisax/hisax_fcpcipnp.c +++ b/drivers/isdn/hisax/hisax_fcpcipnp.c @@ -997,18 +997,16 @@ static int __init hisax_fcpcipnp_init(vo printk(KERN_INFO "hisax_fcpcipnp: Fritz!Card PCI/PCIv2/PnP ISDN driver v0.0.1\n"); retval = pci_register_driver(&fcpci_driver); - if (retval) - goto out; + if (! retval) + { #ifdef __ISAPNP__ - retval = pnp_register_driver(&fcpnp_driver); - if (retval < 0) - goto out_unregister_pci; + retval = pnp_register_driver(&fcpnp_driver); + if (retval < 0) + pci_unregister_driver(&fcpci_driver); + else #endif - return 0; - - out_unregister_pci: - pci_unregister_driver(&fcpci_driver); - out: + retval = 0; + } return retval; } --- a/drivers/isdn/hisax/isdnhdlc.h +++ b/drivers/isdn/hisax/isdnhdlc.h @@ -41,10 +41,10 @@ struct isdnhdlc_vars { unsigned char shift_reg; unsigned char ffvalue; - int data_received:1; // set if transferring data - int dchannel:1; // set if D channel (send idle instead of flags) - int do_adapt56:1; // set if 56K adaptation - int do_closing:1; // set if in closing phase (need to send CRC + flag + unsigned int data_received:1; // set if transferring data + unsigned int dchannel:1; // set if D channel (send idle instead of flags) + unsigned int do_adapt56:1; // set if 56K adaptation + unsigned int do_closing:1; // set if in closing phase (need to send CRC + flag }; --- a/drivers/isdn/hysdn/boardergo.c +++ b/drivers/isdn/hysdn/boardergo.c @@ -330,14 +330,16 @@ static int ergo_waitpofready(struct HYSDN_CARD *card) { tErgDpram *dpr = card->dpram; /* pointer to DPRAM structure */ - int timecnt = 10000 / 50; /* timeout is 10 secs max. */ + unsigned long end_time; unsigned long flags; int msg_size; int i; if (card->debug_flags & LOG_POF_CARD) hysdn_addlog(card, "ERGO: waiting for pof ready"); - while (timecnt--) { + + end_time = jiffies + msecs_to_jiffies(10000); /* timeout is 10 secs max. */ + while (time_before(jiffies, end_time)) { /* wait until timeout */ if (dpr->ToPcFlag) { --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "isdn_common.h" #include "isdn_tty.h" #include "isdn_net.h" @@ -1177,8 +1178,8 @@ isdn_write(struct file *file, const char goto out; } chidx = isdn_minor2chan(minor); - while (isdn_writebuf_stub(drvidx, chidx, buf, count) != count) - interruptible_sleep_on(&dev->drv[drvidx]->snd_waitq[chidx]); + wait_event(dev->drv[drvidx]->snd_waitq[chidx], + (isdn_writebuf_stub(drvidx, chidx, buf, count) == count)); retval = count; goto out; } --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -1500,8 +1500,8 @@ isdn_tty_block_til_ready(struct tty_stru */ if (tty_hung_up_p(filp) || (info->flags & ISDN_ASYNC_CLOSING)) { - if (info->flags & ISDN_ASYNC_CLOSING) - interruptible_sleep_on(&info->close_wait); + wait_event_interruptible(info->close_wait, + (info->flags & ISDN_ASYNC_CLOSING)==0); #ifdef MODEM_DO_RESTART if (info->flags & ISDN_ASYNC_HUP_NOTIFY) return -EAGAIN; --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c @@ -179,7 +179,7 @@ u8 adb_to_linux_keycodes[128] = { /* 0x65 */ KEY_F9, /* 67 */ /* 0x66 */ KEY_HANJA, /* 123 */ /* 0x67 */ KEY_F11, /* 87 */ - /* 0x68 */ KEY_HANGUEL, /* 122 */ + /* 0x68 */ KEY_HANGEUL, /* 122 */ /* 0x69 */ KEY_SYSRQ, /* 99 */ /* 0x6a */ 0, /* 0x6b */ KEY_SCROLLLOCK, /* 70 */ --- a/drivers/macintosh/apm_emu.c +++ b/drivers/macintosh/apm_emu.c @@ -520,6 +520,7 @@ static struct miscdevice apm_device = { static int __init apm_emu_init(void) { struct proc_dir_entry *apm_proc; + int rc; if (sys_ctrler != SYS_CTRLER_PMU) { printk(KERN_INFO "apm_emu: Requires a machine with a PMU.\n"); @@ -530,7 +531,12 @@ static int __init apm_emu_init(void) if (apm_proc) apm_proc->owner = THIS_MODULE; - misc_register(&apm_device); + rc = misc_register(&apm_device); + if (rc < 0) { + remove_proc_entry("apm", NULL); + printk(KERN_ERR "apm_emu: Failed to register APM Emulation.\n"); + return rc; + } pmu_register_sleep_notifier(&apm_sleep_notifier); --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c @@ -407,10 +407,9 @@ static struct macio_dev * macio_add_one_ if (np == NULL) return NULL; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return NULL; - memset(dev, 0, sizeof(*dev)); dev->bus = &chip->lbus; dev->media_bay = in_bay; --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -1033,10 +1033,9 @@ static int smu_open(struct inode *inode, struct smu_private *pp; unsigned long flags; - pp = kmalloc(sizeof(struct smu_private), GFP_KERNEL); + pp = kzalloc(sizeof(struct smu_private), GFP_KERNEL); if (pp == 0) return -ENOMEM; - memset(pp, 0, sizeof(struct smu_private)); spin_lock_init(&pp->lock); pp->mode = smu_file_commands; init_waitqueue_head(&pp->wait); --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -379,13 +379,11 @@ static int attach_one_thermostat(struct if (thermostat) return 0; - th = (struct thermostat *) - kmalloc(sizeof(struct thermostat), GFP_KERNEL); + th = kzalloc(sizeof(struct thermostat), GFP_KERNEL); if (!th) return -ENOMEM; - memset(th, 0, sizeof(*th)); th->clt.addr = addr; th->clt.adapter = adapter; th->clt.driver = &thermostat_driver; --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c @@ -306,10 +306,9 @@ static struct i2c_client *attach_i2c_chi if (adap == NULL) return NULL; - clt = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); + clt = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); if (clt == NULL) return NULL; - memset(clt, 0, sizeof(struct i2c_client)); clt->addr = (id >> 1) & 0x7f; clt->adapter = adap; --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -431,9 +431,8 @@ do_probe( struct i2c_adapter *adapter, i | I2C_FUNC_SMBUS_WRITE_BYTE) ) return 0; - if( !(cl=kmalloc(sizeof(*cl), GFP_KERNEL)) ) + if( !(cl=kzalloc(sizeof(*cl), GFP_KERNEL)) ) return -ENOMEM; - memset( cl, 0, sizeof(struct i2c_client) ); cl->addr = addr; cl->adapter = adapter; --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -1815,8 +1815,7 @@ pmu_register_sleep_notifier(struct pmu_s struct list_head *list; struct pmu_sleep_notifier *notifier; - for (list = sleep_notifiers.next; list != &sleep_notifiers; - list = list->next) { + list_for_each(list, &sleep_notifiers) { notifier = list_entry(list, struct pmu_sleep_notifier, list); if (n->priority > notifier->priority) break; @@ -1848,8 +1847,7 @@ broadcast_sleep(int when, int fallback) struct list_head *list; struct pmu_sleep_notifier *notifier; - for (list = sleep_notifiers.prev; list != &sleep_notifiers; - list = list->prev) { + list_for_each_prev(list, &sleep_notifiers) { notifier = list_entry(list, struct pmu_sleep_notifier, list); ret = notifier->notifier_call(notifier, when); if (ret != PBOOK_SLEEP_OK) { @@ -1870,14 +1868,10 @@ static int broadcast_wake(void) { int ret = PBOOK_SLEEP_OK; - struct list_head *list; struct pmu_sleep_notifier *notifier; - for (list = sleep_notifiers.next; list != &sleep_notifiers; - list = list->next) { - notifier = list_entry(list, struct pmu_sleep_notifier, list); + list_for_each_entry(notifier, &sleep_notifiers, list) notifier->notifier_call(notifier, PBOOK_WAKE); - } return ret; } @@ -2492,15 +2486,13 @@ static void pmu_pass_intr(unsigned char *data, int len) { struct pmu_private *pp; - struct list_head *list; int i; unsigned long flags; if (len > sizeof(pp->rb_buf[0].data)) len = sizeof(pp->rb_buf[0].data); spin_lock_irqsave(&all_pvt_lock, flags); - for (list = &all_pmu_pvt; (list = list->next) != &all_pmu_pvt; ) { - pp = list_entry(list, struct pmu_private, list); + list_for_each_entry(pp, &all_pmu_pvt, list) { spin_lock(&pp->lock); i = pp->rb_put + 1; if (i >= RB_SIZE) --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c @@ -117,10 +117,9 @@ static struct wf_lm75_sensor *wf_lm75_cr DBG("wf_lm75: creating %s device at address 0x%02x\n", ds1775 ? "ds1775" : "lm75", addr); - lm = kmalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL); + lm = kzalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL); if (lm == NULL) return NULL; - memset(lm, 0, sizeof(struct wf_lm75_sensor)); /* Usual rant about sensor names not beeing very consistent in * the device-tree, oh well ... --- a/drivers/mca/mca-bus.c +++ b/drivers/mca/mca-bus.c @@ -130,10 +130,9 @@ struct mca_bus * __devinit mca_attach_bu return NULL; } - mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL); + mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL); if (!mca_bus) return NULL; - memset(mca_bus, 0, sizeof(struct mca_bus)); sprintf(mca_bus->dev.bus_id,"mca%d",bus); sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); device_register(&mca_bus->dev); --- a/drivers/mca/mca-proc.c +++ b/drivers/mca/mca-proc.c @@ -184,8 +184,14 @@ void __init mca_do_proc_init(void) struct mca_device *mca_dev; proc_mca = proc_mkdir("mca", &proc_root); - create_proc_read_entry("pos",0,proc_mca,get_mca_info,NULL); - create_proc_read_entry("machine",0,proc_mca,get_mca_machine_info,NULL); + node = create_proc_read_entry("pos",0,proc_mca,get_mca_info,NULL); + if (!node) + printk(KERN_WARNING "MCA: Unable to create mca /proc entry.\n"); + node = create_proc_read_entry("machine",0,proc_mca, + get_mca_machine_info,NULL); + if (!node) + printk(KERN_WARNING + "MCA: Unable to create machine /proc entry.\n"); /* Initialize /proc/mca entries for existing adapters */ --- a/drivers/md/dm-emc.c +++ b/drivers/md/dm-emc.c @@ -221,12 +221,10 @@ fail_path: static struct emc_handler *alloc_emc_handler(void) { - struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL); + struct emc_handler *h = kzalloc(sizeof(*h), GFP_KERNEL); - if (h) { - memset(h, 0, sizeof(*h)); + if (h) spin_lock_init(&h->lock); - } return h; } --- a/drivers/md/dm-hw-handler.c +++ b/drivers/md/dm-hw-handler.c @@ -91,12 +91,10 @@ void dm_put_hw_handler(struct hw_handler static struct hwh_internal *_alloc_hw_handler(struct hw_handler_type *hwht) { - struct hwh_internal *hwhi = kmalloc(sizeof(*hwhi), GFP_KERNEL); + struct hwh_internal *hwhi = kzalloc(sizeof(*hwhi), GFP_KERNEL); - if (hwhi) { - memset(hwhi, 0, sizeof(*hwhi)); + if (hwhi) hwhi->hwht = *hwht; - } return hwhi; } --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -113,12 +113,10 @@ static void trigger_event(void *data); static struct pgpath *alloc_pgpath(void) { - struct pgpath *pgpath = kmalloc(sizeof(*pgpath), GFP_KERNEL); + struct pgpath *pgpath = kzalloc(sizeof(*pgpath), GFP_KERNEL); - if (pgpath) { - memset(pgpath, 0, sizeof(*pgpath)); + if (pgpath) pgpath->path.is_active = 1; - } return pgpath; } @@ -132,11 +130,10 @@ static struct priority_group *alloc_prio { struct priority_group *pg; - pg = kmalloc(sizeof(*pg), GFP_KERNEL); + pg = kzalloc(sizeof(*pg), GFP_KERNEL); if (!pg) return NULL; - memset(pg, 0, sizeof(*pg)); INIT_LIST_HEAD(&pg->pgpaths); return pg; @@ -171,9 +168,8 @@ static struct multipath *alloc_multipath { struct multipath *m; - m = kmalloc(sizeof(*m), GFP_KERNEL); + m = kzalloc(sizeof(*m), GFP_KERNEL); if (m) { - memset(m, 0, sizeof(*m)); INIT_LIST_HEAD(&m->priority_groups); spin_lock_init(&m->lock); m->queue_io = 1; --- a/drivers/md/dm-path-selector.c +++ b/drivers/md/dm-path-selector.c @@ -94,12 +94,10 @@ out: static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst) { - struct ps_internal *psi = kmalloc(sizeof(*psi), GFP_KERNEL); + struct ps_internal *psi = kzalloc(sizeof(*psi), GFP_KERNEL); - if (psi) { - memset(psi, 0, sizeof(*psi)); + if (psi) psi->pst = *pst; - } return psi; } --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -211,12 +211,11 @@ static int alloc_targets(struct dm_table int dm_table_create(struct dm_table **result, int mode, unsigned num_targets, struct mapped_device *md) { - struct dm_table *t = kmalloc(sizeof(*t), GFP_KERNEL); + struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL); if (!t) return -ENOMEM; - memset(t, 0, sizeof(*t)); INIT_LIST_HEAD(&t->devices); atomic_set(&t->holders, 1); --- a/drivers/md/dm-target.c +++ b/drivers/md/dm-target.c @@ -86,12 +86,10 @@ void dm_put_target_type(struct target_ty static struct tt_internal *alloc_target(struct target_type *t) { - struct tt_internal *ti = kmalloc(sizeof(*ti), GFP_KERNEL); + struct tt_internal *ti = kzalloc(sizeof(*ti), GFP_KERNEL); - if (ti) { - memset(ti, 0, sizeof(*ti)); + if (ti) ti->tt = *t; - } return ti; } --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c @@ -182,9 +182,11 @@ EXPORT_SYMBOL(dst_pio_disable); int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode) { u8 reply; - int i; + int i = 0; + unsigned long end_time; - for (i = 0; i < 200; i++) { + end_time = jiffies + msecs_to_jiffies(2000); + while (time_before(jiffies, end_time)) { if (dst_gpio_inb(state, &reply) < 0) { dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !"); return -1; @@ -194,6 +196,7 @@ int dst_wait_dst_ready(struct dst_state return 1; } msleep(10); + ++i; } dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i); --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -881,12 +881,11 @@ static int cinergyt2_probe (struct usb_i struct cinergyt2 *cinergyt2; int err; - if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { + if (!(cinergyt2 = kzalloc(sizeof(struct cinergyt2), GFP_KERNEL))) { dprintk(1, "out of memory?!?\n"); return -ENOMEM; } - memset (cinergyt2, 0, sizeof (struct cinergyt2)); usb_set_intfdata (intf, (void *) cinergyt2); mutex_init(&cinergyt2->sem); --- a/drivers/media/dvb/frontends/l64781.c +++ b/drivers/media/dvb/frontends/l64781.c @@ -37,7 +37,7 @@ struct l64781_state { struct dvb_frontend frontend; /* private demodulator data */ - int first:1; + unsigned int first:1; }; #define dprintk(args...) \ --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c @@ -1813,7 +1813,7 @@ static int nexusca_stv0297_pll_set(struc u8 data[4]; struct i2c_msg msg = { .addr = 0x63, .flags = 0, .buf = data, .len = sizeof(data) }; struct i2c_msg readmsg = { .addr = 0x63, .flags = I2C_M_RD, .buf = data, .len = 1 }; - int i; + unsigned long end_time; div = (params->frequency + 36150000 + 31250) / 62500; @@ -1839,8 +1839,8 @@ static int nexusca_stv0297_pll_set(struc } // wait for PLL lock - for(i = 0; i < 20; i++) { - + end_time = jiffies + msecs_to_jiffies(200); + while (time_before(jiffies, end_time)) { stv0297_enable_plli2c(fe); if (i2c_transfer(&av7110->i2c_adap, &readmsg, 1) == 1) if (data[0] & 0x40) break; --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -193,7 +193,7 @@ static int ciintf_slot_reset(struct dvb_ { struct budget_av *budget_av = (struct budget_av *) ca->data; struct saa7146_dev *saa = budget_av->budget.dev; - int timeout = 50; // 5 seconds (4.4.6 Ready) + unsigned long end_time; if (slot != 0) return -EINVAL; @@ -211,13 +211,14 @@ static int ciintf_slot_reset(struct dvb_ /* This should have been based on pin 16 READY of the pcmcia port, * but AFAICS it is not routed to the saa7146 */ - while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d) + end_time = jiffies + msecs_to_jiffies(5000); // 5 seconds (4.4.6 Ready) + while (time_before(jiffies, end_time) && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d) msleep(100); /* reinitialise the frontend */ dvb_frontend_reinitialise(budget_av->budget.dvb_frontend); - if (timeout <= 0) + if (time_after_eq(jiffies, end_time)) { printk(KERN_ERR "budget-av: cam reset failed (timeout).\n"); saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */ --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c @@ -341,7 +341,7 @@ static ssize_t cadet_read(struct file *f if(rdsin==rdsout) { if (file->f_flags & O_NONBLOCK) return -EWOULDBLOCK; - interruptible_sleep_on(&read_queue); + wait_event_interruptible(read_queue, rdsin != rdsout); } while( ipll.pll_crystal) return; @@ -787,7 +787,8 @@ static void set_pll(struct bttv *btv) btv->pll.pll_ifreq, btv->pll.pll_ofreq); set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); - for (i=0; i<10; i++) { + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { /* Let other people run while the PLL stabilizes */ bttv_printk("."); msleep(10); --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c @@ -193,9 +193,6 @@ enum { #define DARK_TIME 3 #define LIGHT_TIME 3 -/* Maximum number of 10ms loops to wait for the stream to become ready */ -#define READY_TIMEOUT 100 - /* Developer's Guide Table 5 p 3-34 * indexed by [mains][sensorFps.baserate][sensorFps.divisor]*/ static u8 flicker_jumps[2][2][4] = @@ -2829,6 +2826,7 @@ static int fetch_frame(void *data) int image_size, retry; struct cam_data *cam = (struct cam_data *)data; unsigned long oldjif, rate, diff; + unsigned long end_time; /* Allow up to two bad images in a row to be read and * ignored before an error is reported */ @@ -2857,10 +2855,10 @@ static int fetch_frame(void *data) if (cam->ops->wait_for_stream_ready) { /* loop until image ready */ - int count = 0; do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0); + end_time = jiffies + msecs_to_jiffies(1000); while (cam->params.status.streamState != STREAM_READY) { - if(++count > READY_TIMEOUT) + if(time_after(jiffies, end_time)) break; if(cam->params.status.streamState == STREAM_PAUSED) { --- a/drivers/media/video/c-qcam.c +++ b/drivers/media/video/c-qcam.c @@ -92,7 +92,7 @@ static unsigned int qcam_await_ready1(st int value) { unsigned long oldjiffies = jiffies; - unsigned int i; + unsigned long end_time; for (oldjiffies = jiffies; (jiffies - oldjiffies) < (HZ/25); ) if (qcam_ready1(qcam) == value) @@ -100,7 +100,8 @@ static unsigned int qcam_await_ready1(st /* If the camera didn't respond within 1/25 second, poll slowly for a while. */ - for (i = 0; i < 50; i++) + end_time = jiffies + msecs_to_jiffies(5000); + while (time_before(jiffies, end_time)) { if (qcam_ready1(qcam) == value) return 0; @@ -117,7 +118,7 @@ static unsigned int qcam_await_ready1(st static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value) { unsigned long oldjiffies = jiffies; - unsigned int i; + unsigned long end_time; for (oldjiffies = jiffies; (jiffies - oldjiffies) < (HZ/25); ) if (qcam_ready2(qcam) == value) @@ -125,7 +126,8 @@ static unsigned int qcam_await_ready2(st /* If the camera didn't respond within 1/25 second, poll slowly for a while. */ - for (i = 0; i < 50; i++) + end_time = jiffies + msecs_to_jiffies(5000); + while (time_before(jiffies, end_time)) { if (qcam_ready2(qcam) == value) return 0; --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c @@ -413,11 +413,9 @@ static int snd_cx88_hw_params(struct snd dprintk(1,"Setting buffer\n"); - buf = kmalloc(sizeof(*buf),GFP_KERNEL); + buf = kzalloc(sizeof(*buf),GFP_KERNEL); if (NULL == buf) return -ENOMEM; - memset(buf,0,sizeof(*buf)); - buf->vb.memory = V4L2_MEMORY_MMAP; buf->vb.width = chip->period_size; --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c @@ -752,7 +752,7 @@ static int set_pll(struct cx88_core *cor static u32 pre[] = { 0, 0, 0, 3, 2, 1 }; u64 pll; u32 reg; - int i; + unsigned long end_time; if (prescale < 2) prescale = 2; @@ -770,7 +770,9 @@ static int set_pll(struct cx88_core *cor dprintk(1,"set_pll: MO_PLL_REG 0x%08x [old=0x%08x,freq=%d]\n", reg, cx_read(MO_PLL_REG), ofreq); cx_write(MO_PLL_REG, reg); - for (i = 0; i < 100; i++) { + + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time)) { reg = cx_read(MO_DEVICE_STATUS); if (reg & (1<<2)) { dprintk(1,"pll locked [pre=%d,ofreq=%d]\n", --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c @@ -399,18 +399,6 @@ static u32 functionality(struct i2c_adap return I2C_FUNC_SMBUS_EMUL; } -#ifndef I2C_PEC -static void inc_use(struct i2c_adapter *adap) -{ - MOD_INC_USE_COUNT; -} - -static void dec_use(struct i2c_adapter *adap) -{ - MOD_DEC_USE_COUNT; -} -#endif - static int em28xx_set_tuner(int check_eeprom, struct i2c_client *client) { struct em28xx *dev = client->adapter->algo_data; @@ -480,12 +468,7 @@ static struct i2c_algorithm em28xx_algo }; static struct i2c_adapter em28xx_adap_template = { -#ifdef I2C_PEC .owner = THIS_MODULE, -#else - .inc_use = inc_use, - .dec_use = dec_use, -#endif .class = I2C_CLASS_TV_ANALOG, .name = "em28xx", .id = I2C_HW_B_EM28XX, --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c @@ -558,15 +558,19 @@ static void mchip_dma_free(void) reset the dma engine */ static void mchip_hic_stop(void) { - int i, j; + unsigned long end_time, end_time2; meye.mchip_mode = MCHIP_HIC_MODE_NOOP; if (!(mchip_read(MCHIP_HIC_STATUS) & MCHIP_HIC_STATUS_BUSY)) return; - for (i = 0; i < 20; ++i) { + + end_time = jiffies + msecs_to_jiffies(7000); + while (time_before(jiffies, end_time)) { mchip_set(MCHIP_HIC_CMD, MCHIP_HIC_CMD_STOP); mchip_delay(MCHIP_HIC_CMD, 0); - for (j = 0; j < 100; ++j) { + + end_time2 = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time2)) { if (mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE)) return; @@ -660,7 +664,7 @@ static int mchip_comp_read_frame(u32 v, /* take a picture into SDRAM */ static void mchip_take_picture(void) { - int i; + unsigned long end_time; mchip_hic_stop(); mchip_subsample(); @@ -671,7 +675,8 @@ static void mchip_take_picture(void) mchip_delay(MCHIP_HIC_CMD, 0); - for (i = 0; i < 100; ++i) { + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { if (mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE)) break; msleep(1); @@ -683,12 +688,14 @@ static void mchip_get_picture(u8 *buf, i { u32 v; int i; + unsigned long end_time; mchip_set(MCHIP_HIC_MODE, MCHIP_HIC_MODE_STILL_OUT); mchip_set(MCHIP_HIC_CMD, MCHIP_HIC_CMD_START); mchip_delay(MCHIP_HIC_CMD, 0); - for (i = 0; i < 100; ++i) { + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { if (mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE)) break; msleep(1); @@ -724,6 +731,7 @@ static int mchip_compress_frame(u8 *buf, { u32 v; int len = -1, i; + unsigned long end_time; mchip_vrj_setup(0x3f); udelay(50); @@ -732,7 +740,9 @@ static int mchip_compress_frame(u8 *buf, mchip_set(MCHIP_HIC_CMD, MCHIP_HIC_CMD_START); mchip_delay(MCHIP_HIC_CMD, 0); - for (i = 0; i < 100; ++i) { + + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { if (mchip_delay(MCHIP_HIC_STATUS, MCHIP_HIC_STATUS_IDLE)) break; msleep(1); --- a/drivers/media/video/msp3400-driver.c +++ b/drivers/media/video/msp3400-driver.c @@ -853,10 +853,9 @@ static int msp_attach(struct i2c_adapter int msp_product, msp_prod_hi, msp_prod_lo; int msp_rom; - client = kmalloc(sizeof(*client), GFP_KERNEL); + client = kzalloc(sizeof(*client), GFP_KERNEL); if (client == NULL) return -ENOMEM; - memset(client, 0, sizeof(*client)); client->addr = address; client->adapter = adapter; client->driver = &i2c_driver; @@ -868,14 +867,13 @@ static int msp_attach(struct i2c_adapter return -1; } - state = kmalloc(sizeof(*state), GFP_KERNEL); + state = kzalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) { kfree(client); return -ENOMEM; } i2c_set_clientdata(client, state); - memset(state, 0, sizeof(*state)); state->v4l2_std = V4L2_STD_NTSC; state->audmode = V4L2_TUNER_MODE_STEREO; state->volume = 58880; /* 0db gain */ --- a/drivers/media/video/planb.c +++ b/drivers/media/video/planb.c @@ -352,9 +352,8 @@ static int planb_prepare_open(struct pla * PLANB_DUMMY)*sizeof(struct dbdma_cmd) +(PLANB_MAXLINES*((PLANB_MAXPIXELS+7)& ~7))/8 +MAX_GBUFFERS*sizeof(unsigned int); - if ((pb->priv_space = kmalloc (size, GFP_KERNEL)) == 0) + if ((pb->priv_space = kzalloc(size, GFP_KERNEL)) == 0) return -ENOMEM; - memset ((void *) pb->priv_space, 0, size); pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *) DBDMA_ALIGN (pb->priv_space); pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size; --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "saa7134-reg.h" #include "saa7134.h" @@ -870,7 +871,7 @@ static int __devinit saa7134_initdev(str pci_name(pci_dev), dev->pci_rev, pci_dev->irq, dev->pci_lat,pci_resource_start(pci_dev,0)); pci_set_master(pci_dev); - if (!pci_dma_supported(pci_dev,0xffffffff)) { + if (!pci_dma_supported(pci_dev, DMA_32BIT_MASK)) { printk("%s: Oops: no 32bit PCI DMA ???\n",dev->name); err = -EIO; goto fail1; --- a/drivers/media/video/videocodec.h +++ b/drivers/media/video/videocodec.h @@ -222,14 +222,14 @@ M zr36055[1] 0001 /* ========================= */ struct vfe_polarity { - int vsync_pol:1; - int hsync_pol:1; - int field_pol:1; - int blank_pol:1; - int subimg_pol:1; - int poe_pol:1; - int pvalid_pol:1; - int vclk_pol:1; + unsigned int vsync_pol:1; + unsigned int hsync_pol:1; + unsigned int field_pol:1; + unsigned int blank_pol:1; + unsigned int subimg_pol:1; + unsigned int poe_pol:1; + unsigned int pvalid_pol:1; + unsigned int vclk_pol:1; }; struct vfe_settings { --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -2894,6 +2894,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFw u32 fwSize; u32 diag0val; int count; + unsigned long end_time; u32 *ptrFw; u32 diagRwData; u32 nextImage; @@ -2922,7 +2923,9 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFw diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); - for (count = 0; count < 30; count ++) { + count = 0; + end_time = jiffies + msecs_to_jiffies(3000); + while (time_before(jiffies, end_time)) { diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) { ddlprintk((MYIOC_s_INFO_FMT "RESET_ADAPTER cleared, count=%d\n", @@ -2935,9 +2938,10 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFw } else { mdelay (100); } + ++count; } - if ( count == 30 ) { + if (diag0val & MPI_DIAG_RESET_ADAPTER) { ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! " "Unable to get MPI_DIAG_DRWE mode, diag0val=%x\n", ioc->name, diag0val)); @@ -3052,7 +3056,9 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFw } } - for (count=0; countname, count, ioc_state)); @@ -3073,6 +3079,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFw } else { mdelay (10); } + ++count; } ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! IocState=%x\n", ioc->name, ioc_state)); @@ -3110,7 +3117,8 @@ KickStart(MPT_ADAPTER *ioc, int force, i { int hard_reset_done = 0; u32 ioc_state=0; - int cnt,cntdn; + int cnt; + unsigned long end_time; dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); if (ioc->bus_type == SPI) { @@ -3133,8 +3141,9 @@ KickStart(MPT_ADAPTER *ioc, int force, i dinitprintk((MYIOC_s_INFO_FMT "Diagnostic reset successful!\n", ioc->name)); - cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */ - for (cnt=0; cntchip->IntStatus, 0); @@ -3200,6 +3211,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign * or if the reset history is 0 */ if (ignore || !(diag0val & MPI_DIAG_RESET_HISTORY)) { + end_time = jiffies + msecs_to_jiffies(2000); while ((diag0val & MPI_DIAG_DRWE) == 0) { /* Write magic sequence to WriteSequence register * Loop until in diagnostic mode @@ -3218,12 +3230,10 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign mdelay (100); } - count++; - if (count > 20) { + if (time_after(jiffies, end_time)) { printk(MYIOC_s_ERR_FMT "Enable Diagnostic mode FAILED! (%02xh)\n", ioc->name, diag0val); return -2; - } diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); @@ -3284,7 +3294,8 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign * IOC will be left unusable. This is a fatal error * case. _diag_reset will return < 0 */ - for (count = 0; count < 30; count ++) { + end_time = jiffies + msecs_to_jiffies(30000); + while (time_before(jiffies, end_time)) { diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) { break; @@ -3310,7 +3321,8 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign * If fail, no error will check again * with calling program. */ - for (count = 0; count < 60; count ++) { + end_time = jiffies + msecs_to_jiffies(60000); + while (time_before(jiffies, end_time)) { doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); doorbell &= MPI_IOC_STATE_MASK; --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -962,10 +962,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i * structures for the SG elements. */ i = MAX_SGL_BYTES / 8; - buflist = kmalloc(i, GFP_USER); + buflist = kzalloc(i, GFP_USER); if (buflist == NULL) return NULL; - memset(buflist, 0, i); buflist_ent = 0; /* Allocate a single block of memory to store the sg elements and @@ -1377,13 +1376,12 @@ mptctl_gettargetinfo (unsigned long arg) * 15- 8: Bus Number * 7- 0: Target ID */ - pmem = kmalloc(numBytes, GFP_KERNEL); + pmem = kzalloc(numBytes, GFP_KERNEL); if (pmem == NULL) { printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", __FILE__, __LINE__); return -ENOMEM; } - memset(pmem, 0, numBytes); pdata = (int *) pmem; /* Get number of devices @@ -1617,12 +1615,11 @@ mptctl_eventenable (unsigned long arg) /* Have not yet allocated memory - do so now. */ int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); - ioc->events = kmalloc(sz, GFP_KERNEL); + ioc->events = kzalloc(sz, GFP_KERNEL); if (ioc->events == NULL) { printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); return -ENOMEM; } - memset(ioc->events, 0, sz); ioc->alloc_total += sz; ioc->eventContext = 0; @@ -2888,13 +2885,12 @@ mptctl_probe(struct pci_dev *pdev, const * Allocate and inite a MPT_IOCTL structure */ sz = sizeof (MPT_IOCTL); - mem = kmalloc(sz, GFP_KERNEL); + mem = kzalloc(sz, GFP_KERNEL); if (mem == NULL) { err = -ENOMEM; goto out_fail; } - memset(mem, 0, sz); ioc->ioctl = (MPT_IOCTL *) mem; ioc->ioctl->ioc = ioc; mutex_init(&ioc->ioctl->ioctl_mutex); --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1879,10 +1879,11 @@ static int mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd) { unsigned long flags; - int loop_count = 4 * 10; /* Wait 10 seconds */ int status = FAILED; + unsigned long end_time; - do { + end_time = jiffies + msecs_to_jiffies(10000); /* Wait 10 seconds */ + while (time_before(jiffies, end_time)) { spin_lock_irqsave(&hd->ioc->FreeQlock, flags); if (hd->tmState == TM_STATE_NONE) { hd->tmState = TM_STATE_IN_PROGRESS; @@ -1893,7 +1894,7 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * } spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); msleep(250); - } while (--loop_count); + } return status; } @@ -1909,10 +1910,11 @@ static int mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout ) { unsigned long flags; - int loop_count = 4 * timeout; int status = FAILED; + unsigned long end_time; - do { + end_time = jiffies + msecs_to_jiffies(timeout * 1000); + while (time_before(jiffies, end_time)) { spin_lock_irqsave(&hd->ioc->FreeQlock, flags); if(hd->tmPending == 0) { status = SUCCESS; @@ -1921,7 +1923,7 @@ mptscsih_tm_wait_for_completion(MPT_SCSI } spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags); msleep_interruptible(250); - } while (--loop_count); + } return status; } --- a/drivers/mfd/mcp-core.c +++ b/drivers/mfd/mcp-core.c @@ -200,9 +200,8 @@ struct mcp *mcp_host_alloc(struct device { struct mcp *mcp; - mcp = kmalloc(sizeof(struct mcp) + size, GFP_KERNEL); + mcp = kzalloc(sizeof(struct mcp) + size, GFP_KERNEL); if (mcp) { - memset(mcp, 0, sizeof(struct mcp) + size); spin_lock_init(&mcp->lock); mcp->attached_device.parent = parent; mcp->attached_device.bus = &mcp_bus_type; --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c @@ -483,13 +483,11 @@ static int ucb1x00_probe(struct mcp *mcp goto err_disable; } - ucb = kmalloc(sizeof(struct ucb1x00), GFP_KERNEL); + ucb = kzalloc(sizeof(struct ucb1x00), GFP_KERNEL); ret = -ENOMEM; if (!ucb) goto err_disable; - memset(ucb, 0, sizeof(struct ucb1x00)); - ucb->cdev.class = &ucb1x00_class; ucb->cdev.dev = &mcp->attached_device; strlcpy(ucb->cdev.class_id, "ucb1x00", sizeof(ucb->cdev.class_id)); --- a/drivers/misc/ibmasm/command.c +++ b/drivers/misc/ibmasm/command.c @@ -41,18 +41,15 @@ struct command *ibmasm_new_command(struc if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE) return NULL; - cmd = kmalloc(sizeof(struct command), GFP_KERNEL); + cmd = kzalloc(sizeof(struct command), GFP_KERNEL); if (cmd == NULL) return NULL; - memset(cmd, 0, sizeof(*cmd)); - - cmd->buffer = kmalloc(buffer_size, GFP_KERNEL); + cmd->buffer = kzalloc(buffer_size, GFP_KERNEL); if (cmd->buffer == NULL) { kfree(cmd); return NULL; } - memset(cmd->buffer, 0, buffer_size); cmd->buffer_size = buffer_size; kobject_init(&cmd->kobj); --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -563,12 +563,10 @@ static ssize_t remote_settings_file_writ if (*offset != 0) return 0; - buff = kmalloc (count + 1, GFP_KERNEL); + buff = kzalloc (count + 1, GFP_KERNEL); if (!buff) return -ENOMEM; - memset(buff, 0x0, count + 1); - if (copy_from_user(buff, ubuff, count)) { kfree(buff); return -EFAULT; --- a/drivers/misc/ibmasm/module.c +++ b/drivers/misc/ibmasm/module.c @@ -77,13 +77,12 @@ static int __devinit ibmasm_init_one(str /* vnc client won't work without bus-mastering */ pci_set_master(pdev); - sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); + sp = kzalloc(sizeof(struct service_processor), GFP_KERNEL); if (sp == NULL) { dev_err(&pdev->dev, "Failed to allocate memory\n"); result = -ENOMEM; goto error_kmalloc; } - memset(sp, 0, sizeof(struct service_processor)); sp->lock = SPIN_LOCK_UNLOCKED; INIT_LIST_HEAD(&sp->command_queue); --- a/drivers/mtd/afs.c +++ b/drivers/mtd/afs.c @@ -207,11 +207,10 @@ static int parse_afs_partitions(struct m if (!sz) return ret; - parts = kmalloc(sz, GFP_KERNEL); + parts = kzalloc(sz, GFP_KERNEL); if (!parts) return -ENOMEM; - memset(parts, 0, sz); str = (char *)(parts + idx); /* --- a/drivers/mtd/chips/amd_flash.c +++ b/drivers/mtd/chips/amd_flash.c @@ -650,13 +650,12 @@ static struct mtd_info *amd_flash_probe( int reg_idx; int offset; - mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL); + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) { printk(KERN_WARNING "%s: kmalloc failed for info structure\n", map->name); return NULL; } - memset(mtd, 0, sizeof(*mtd)); mtd->priv = map; memset(&temp, 0, sizeof(temp)); --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c @@ -344,12 +344,11 @@ struct mtd_info *cfi_cmdset_0001(struct struct mtd_info *mtd; int i; - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) { printk(KERN_ERR "Failed to allocate memory for MTD device\n"); return NULL; } - memset(mtd, 0, sizeof(*mtd)); mtd->priv = map; mtd->type = MTD_NORFLASH; --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -218,12 +218,11 @@ struct mtd_info *cfi_cmdset_0002(struct struct mtd_info *mtd; int i; - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) { printk(KERN_WARNING "Failed to allocate memory for MTD device\n"); return NULL; } - memset(mtd, 0, sizeof(*mtd)); mtd->priv = map; mtd->type = MTD_NORFLASH; --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c @@ -101,13 +101,12 @@ static struct cfi_private *genprobe_iden */ max_chips = map->size >> cfi.chipshift; mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0); - chip_map = kmalloc(mapsize, GFP_KERNEL); + chip_map = kzalloc(mapsize, GFP_KERNEL); if (!chip_map) { printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); kfree(cfi.cfiq); return NULL; } - memset (chip_map, 0, mapsize); set_bit(0, chip_map); /* Mark first chip valid */ --- a/drivers/mtd/chips/jedec.c +++ b/drivers/mtd/chips/jedec.c @@ -116,11 +116,10 @@ static struct mtd_info *jedec_probe(stru char Part[200]; memset(&priv,0,sizeof(priv)); - MTD = kmalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); + MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); if (!MTD) return NULL; - memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private)); priv = (struct jedec_private *)&MTD[1]; my_bank_size = map->size; --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c @@ -55,12 +55,10 @@ static struct mtd_info *map_ram_probe(st #endif /* OK. It seems to be RAM. */ - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) return NULL; - memset(mtd, 0, sizeof(*mtd)); - map->fldrv = &mapram_chipdrv; mtd->priv = map; mtd->name = map->name; --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c @@ -31,12 +31,10 @@ static struct mtd_info *map_rom_probe(st { struct mtd_info *mtd; - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) return NULL; - memset(mtd, 0, sizeof(*mtd)); - map->fldrv = &maprom_chipdrv; mtd->priv = map; mtd->name = map->name; --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -293,10 +293,9 @@ static struct block2mtd_dev *add_device( if (!devname) return NULL; - dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); + dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); if (!dev) return NULL; - memset(dev, 0, sizeof(*dev)); /* Get a handle on the device */ bdev = open_bdev_excl(devname, O_RDWR, NULL); --- a/drivers/mtd/devices/ms02-nv.c +++ b/drivers/mtd/devices/ms02-nv.c @@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulong int ret = -ENODEV; /* The module decodes 8MiB of address space. */ - mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL); + mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL); if (!mod_res) return -ENOMEM; - memset(mod_res, 0, sizeof(*mod_res)); mod_res->name = ms02nv_name; mod_res->start = addr; mod_res->end = addr + MS02NV_SLOT_SIZE - 1; @@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong } ret = -ENOMEM; - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); if (!mtd) goto err_out_mod_res_rel; - memset(mtd, 0, sizeof(*mtd)); - mp = kmalloc(sizeof(*mp), GFP_KERNEL); + mp = kzalloc(sizeof(*mp), GFP_KERNEL); if (!mp) goto err_out_mtd; - memset(mp, 0, sizeof(*mp)); mtd->priv = mp; mp->resource.module = mod_res; /* Firmware's diagnostic NVRAM area. */ - diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL); + diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL); if (!diag_res) goto err_out_mp; - memset(diag_res, 0, sizeof(*diag_res)); diag_res->name = ms02nv_res_diag_ram; diag_res->start = addr; diag_res->end = addr + MS02NV_RAM - 1; @@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong mp->resource.diag_ram = diag_res; /* User-available general-purpose NVRAM area. */ - user_res = kmalloc(sizeof(*user_res), GFP_KERNEL); + user_res = kzalloc(sizeof(*user_res), GFP_KERNEL); if (!user_res) goto err_out_diag_res; - memset(user_res, 0, sizeof(*user_res)); user_res->name = ms02nv_res_user_ram; user_res->start = addr + MS02NV_RAM; user_res->end = addr + size - 1; @@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong mp->resource.user_ram = user_res; /* Control and status register. */ - csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL); + csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL); if (!csr_res) goto err_out_user_res; - memset(csr_res, 0, sizeof(*csr_res)); csr_res->name = ms02nv_res_csr; csr_res->start = addr + MS02NV_CSR; csr_res->end = addr + MS02NV_CSR + 3; --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -126,12 +126,10 @@ static int register_device(char *name, u struct phram_mtd_list *new; int ret = -ENOMEM; - new = kmalloc(sizeof(*new), GFP_KERNEL); + new = kzalloc(sizeof(*new), GFP_KERNEL); if (!new) goto out0; - memset(new, 0, sizeof(*new)); - ret = -EIO; new->mtd.priv = ioremap(start, len); if (!new->mtd.priv) { --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c @@ -712,21 +712,18 @@ static int __init init_pmc551(void) msize = length; } - mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); + mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); if (!mtd) { printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n"); break; } - memset(mtd, 0, sizeof(struct mtd_info)); - - priv = kmalloc (sizeof(struct mypriv), GFP_KERNEL); + priv = kzalloc (sizeof(struct mypriv), GFP_KERNEL); if (!priv) { printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n"); kfree(mtd); break; } - memset(priv, 0, sizeof(*priv)); mtd->priv = priv; priv->dev = PCI_Device; --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c @@ -168,19 +168,16 @@ static int register_device(char *name, u E("slram: Cannot allocate new MTD device.\n"); return(-ENOMEM); } - (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); + (*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); (*curmtd)->next = NULL; if ((*curmtd)->mtdinfo) { - memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info)); (*curmtd)->mtdinfo->priv = - kmalloc(sizeof(slram_priv_t), GFP_KERNEL); + kzalloc(sizeof(slram_priv_t), GFP_KERNEL); if (!(*curmtd)->mtdinfo->priv) { kfree((*curmtd)->mtdinfo); (*curmtd)->mtdinfo = NULL; - } else { - memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t)); } } --- a/drivers/mtd/maps/ceiva.c +++ b/drivers/mtd/maps/ceiva.c @@ -123,10 +123,9 @@ static int __init clps_setup_mtd(struct /* * Allocate the map_info structs in one go. */ - maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL); + maps = kcalloc(nr, sizeof(struct map_info), GFP_KERNEL); if (!maps) return -ENOMEM; - memset(maps, 0, sizeof(struct map_info) * nr); /* * Claim and then map the memory regions. */ --- a/drivers/mtd/maps/omap_nor.c +++ b/drivers/mtd/maps/omap_nor.c @@ -78,12 +78,10 @@ static int __devinit omapflash_probe(str struct resource *res = pdev->resource; unsigned long size = res->end - res->start + 1; - info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL); + info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL); if (!info) return -ENOMEM; - memset(info, 0, sizeof(struct omapflash_info)); - if (!request_mem_region(res->start, size, "flash")) { err = -EBUSY; goto out_free_info; --- a/drivers/mtd/maps/tqm834x.c +++ b/drivers/mtd/maps/tqm834x.c @@ -133,20 +133,16 @@ static int __init init_tqm834x_mtd(void) pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx); - map_banks[idx] = - (struct map_info *)kmalloc(sizeof(struct map_info), - GFP_KERNEL); + map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); if (map_banks[idx] == NULL) { ret = -ENOMEM; goto error_mem; } - memset((void *)map_banks[idx], 0, sizeof(struct map_info)); - map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); + map_banks[idx]->name = kzalloc(16, GFP_KERNEL); if (map_banks[idx]->name == NULL) { ret = -ENOMEM; goto error_mem; } - memset((void *)map_banks[idx]->name, 0, 16); sprintf(map_banks[idx]->name, "TQM834x-%d", idx); map_banks[idx]->size = flash_size; --- a/drivers/mtd/maps/tqm8xxl.c +++ b/drivers/mtd/maps/tqm8xxl.c @@ -135,14 +135,13 @@ int __init init_tqm_mtd(void) printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx); - map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL); + map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); if(map_banks[idx] == NULL) { ret = -ENOMEM; /* FIXME: What if some MTD devices were probed already? */ goto error_mem; } - memset((void *)map_banks[idx], 0, sizeof(struct map_info)); map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); if (!map_banks[idx]->name) { --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -372,12 +372,10 @@ int register_mtd_blktrans(struct mtd_blk if (!blktrans_notifier.list.next) register_mtd_user(&blktrans_notifier); - tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); + tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); if (!tr->blkcore_priv) return -ENOMEM; - memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); - mutex_lock(&mtd_table_mutex); ret = register_blkdev(tr->major, tr->name); --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c @@ -278,11 +278,10 @@ static int mtdblock_open(struct mtd_blkt } /* OK, it's not open. Create cache info for it */ - mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); + mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); if (!mtdblk) return -ENOMEM; - memset(mtdblk, 0, sizeof(*mtdblk)); mtdblk->count = 1; mtdblk->mtd = mtd; @@ -340,13 +339,11 @@ static int mtdblock_flush(struct mtd_blk static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { - struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); + struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return; - memset(dev, 0, sizeof(*dev)); - dev->mtd = mtd; dev->devnum = mtd->index; dev->blksize = 512; --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c @@ -33,13 +33,11 @@ static int mtdblock_writesect(struct mtd static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { - struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); + struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return; - memset(dev, 0, sizeof(*dev)); - dev->mtd = mtd; dev->devnum = mtd->index; dev->blksize = 512; --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c @@ -20,18 +20,7 @@ #include #include -/* fixme: this is ugly */ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0) #include -#else -#include -#ifdef CONFIG_MIPS_PB1550 -#include -#endif -#ifdef CONFIG_MIPS_DB1550 -#include -#endif -#endif /* * MTD structure for NAND controller --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -1645,13 +1645,12 @@ static int __init doc_probe(unsigned lon sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); - mtd = kmalloc(len, GFP_KERNEL); + mtd = kzalloc(len, GFP_KERNEL); if (!mtd) { printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); ret = -ENOMEM; goto fail; } - memset(mtd, 0, len); nand = (struct nand_chip *) (mtd + 1); doc = (struct doc_priv *) (nand + 1); --- a/drivers/mtd/onenand/generic.c +++ b/drivers/mtd/onenand/generic.c @@ -45,12 +45,10 @@ static int __devinit generic_onenand_pro unsigned long size = res->end - res->start + 1; int err; - info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL); + info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL); if (!info) return -ENOMEM; - memset(info, 0, sizeof(struct onenand_info)); - if (!request_mem_region(res->start, size, dev->driver->name)) { err = -EBUSY; goto out_free_info; --- a/drivers/net/3c515.c +++ b/drivers/net/3c515.c @@ -1025,7 +1025,7 @@ static int corkscrew_start_xmit(struct s spin_lock_irqsave(&vp->lock, flags); outw(DownStall, ioaddr + EL3_CMD); /* Wait for the stall to complete. */ - for (i = 20; i >= 0; i--) + for (i = 20; i > 0; i--) if ((inw(ioaddr + EL3_STATUS) & CmdInProgress) == 0) break; if (prev_entry) --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -3340,7 +3340,7 @@ static int __init vortex_init(void) { int pci_rc, eisa_rc; - pci_rc = pci_module_init(&vortex_driver); + pci_rc = pci_register_driver(&vortex_driver); eisa_rc = vortex_eisa_init(); if (pci_rc == 0) --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c @@ -1940,7 +1940,7 @@ static int __init cp_init (void) #ifdef MODULE printk("%s", version); #endif - return pci_module_init (&cp_driver); + return pci_register_driver (&cp_driver); } static void __exit cp_exit (void) --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -2627,7 +2627,7 @@ static int __init rtl8139_init_module (v printk (KERN_INFO RTL8139_DRIVER_NAME "\n"); #endif - return pci_module_init (&rtl8139_pci_driver); + return pci_register_driver (&rtl8139_pci_driver); } --- a/drivers/net/acenic.c +++ b/drivers/net/acenic.c @@ -730,7 +730,7 @@ static struct pci_driver acenic_pci_driv static int __init acenic_init(void) { - return pci_module_init(&acenic_pci_driver); + return pci_register_driver(&acenic_pci_driver); } static void __exit acenic_exit(void) --- a/drivers/net/amd8111e.c +++ b/drivers/net/amd8111e.c @@ -2159,7 +2159,7 @@ static struct pci_driver amd8111e_driver static int __init amd8111e_init(void) { - return pci_module_init(&amd8111e_driver); + return pci_register_driver(&amd8111e_driver); } static void __exit amd8111e_cleanup(void) --- a/drivers/net/arcnet/com20020-pci.c +++ b/drivers/net/arcnet/com20020-pci.c @@ -177,7 +177,7 @@ static struct pci_driver com20020pci_dri static int __init com20020pci_init(void) { BUGLVL(D_NORMAL) printk(VERSION); - return pci_module_init(&com20020pci_driver); + return pci_register_driver(&com20020pci_driver); } static void __exit com20020pci_cleanup(void) --- a/drivers/net/b44.c +++ b/drivers/net/b44.c @@ -2152,7 +2152,7 @@ static int __init b44_init(void) dma_desc_align_mask = ~(dma_desc_align_size - 1); dma_desc_sync_size = max_t(unsigned int, dma_desc_align_size, sizeof(struct dma_desc)); - return pci_module_init(&b44_driver); + return pci_register_driver(&b44_driver); } static void __exit b44_cleanup(void) --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c @@ -3982,8 +3982,8 @@ bnx2_test_link(struct bnx2 *bp) static int bnx2_test_intr(struct bnx2 *bp) { - int i; u16 status_idx; + unsigned long end_time; if (!netif_running(bp->dev)) return -ENODEV; @@ -3994,7 +3994,8 @@ bnx2_test_intr(struct bnx2 *bp) REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW); REG_RD(bp, BNX2_HC_COMMAND); - for (i = 0; i < 10; i++) { + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { if ((REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff) != status_idx) { @@ -4003,7 +4004,7 @@ bnx2_test_intr(struct bnx2 *bp) msleep_interruptible(10); } - if (i < 10) + if (time_before(jiffies, end_time)) return 0; return -ENODEV; --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1323,14 +1323,12 @@ int bond_enslave(struct net_device *bond goto err_undo_flags; } - new_slave = kmalloc(sizeof(struct slave), GFP_KERNEL); + new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL); if (!new_slave) { res = -ENOMEM; goto err_undo_flags; } - memset(new_slave, 0, sizeof(struct slave)); - /* save slave's original flags before calling * netdev_set_master and dev_open */ --- a/drivers/net/chelsio/mv88x201x.c +++ b/drivers/net/chelsio/mv88x201x.c @@ -205,11 +205,10 @@ static struct cphy *mv88x201x_phy_create struct mdio_ops *mdio_ops) { u32 val; - struct cphy *cphy = kmalloc(sizeof(*cphy), GFP_KERNEL); + struct cphy *cphy = kzalloc(sizeof(*cphy), GFP_KERNEL); if (!cphy) return NULL; - memset(cphy, 0, sizeof(*cphy)); cphy_init(cphy, adapter, phy_addr, &mv88x201x_ops, mdio_ops); /* Commands the PHY to enable XFP's clock. */ --- a/drivers/net/chelsio/sge.c +++ b/drivers/net/chelsio/sge.c @@ -336,10 +336,9 @@ static int alloc_rx_resources(struct sge goto err_no_mem; memset(q->entries, 0, size); size = sizeof(struct freelQ_ce) * q->size; - q->centries = kmalloc(size, GFP_KERNEL); + q->centries = kzalloc(size, GFP_KERNEL); if (!q->centries) goto err_no_mem; - memset(q->centries, 0, size); } /* @@ -464,10 +463,9 @@ static int alloc_tx_resources(struct sge goto err_no_mem; memset(q->entries, 0, size); size = sizeof(struct cmdQ_ce) * q->size; - q->centries = kmalloc(size, GFP_KERNEL); + q->centries = kzalloc(size, GFP_KERNEL); if (!q->centries) goto err_no_mem; - memset(q->centries, 0, size); } /* @@ -1648,11 +1646,10 @@ static void espibug_workaround(void *dat struct sge * __devinit t1_sge_create(struct adapter *adapter, struct sge_params *p) { - struct sge *sge = kmalloc(sizeof(*sge), GFP_KERNEL); + struct sge *sge = kzalloc(sizeof(*sge), GFP_KERNEL); if (!sge) return NULL; - memset(sge, 0, sizeof(*sge)); sge->adapter = adapter; sge->netdev = adapter->port[0].dev; --- a/drivers/net/defxx.c +++ b/drivers/net/defxx.c @@ -3444,7 +3444,7 @@ static int __init dfx_init(void) { int rc_pci, rc_eisa; - rc_pci = pci_module_init(&dfx_driver); + rc_pci = pci_register_driver(&dfx_driver); if (rc_pci >= 0) dfx_have_pci = 1; rc_eisa = dfx_eisa_init(); --- a/drivers/net/dl2k.c +++ b/drivers/net/dl2k.c @@ -1853,7 +1853,7 @@ static struct pci_driver rio_driver = { static int __init rio_init (void) { - return pci_module_init (&rio_driver); + return pci_register_driver (&rio_driver); } static void __exit --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c @@ -636,20 +636,18 @@ e1000_set_ringparam(struct net_device *n tx_old = adapter->tx_ring; rx_old = adapter->rx_ring; - adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL); + adapter->tx_ring = kzalloc(tx_ring_size, GFP_KERNEL); if (!adapter->tx_ring) { err = -ENOMEM; goto err_setup_rx; } - memset(adapter->tx_ring, 0, tx_ring_size); - adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL); + adapter->rx_ring = kzalloc(rx_ring_size, GFP_KERNEL); if (!adapter->rx_ring) { kfree(adapter->tx_ring); err = -ENOMEM; goto err_setup_rx; } - memset(adapter->rx_ring, 0, rx_ring_size); txdr = adapter->tx_ring; rxdr = adapter->rx_ring; @@ -1013,11 +1011,10 @@ e1000_setup_desc_rings(struct e1000_adap txdr->count = E1000_DEFAULT_TXD; size = txdr->count * sizeof(struct e1000_buffer); - if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) { + if (!(txdr->buffer_info = kzalloc(size, GFP_KERNEL))) { ret_val = 1; goto err_nomem; } - memset(txdr->buffer_info, 0, size); txdr->size = txdr->count * sizeof(struct e1000_tx_desc); E1000_ROUNDUP(txdr->size, 4096); @@ -1069,11 +1066,10 @@ e1000_setup_desc_rings(struct e1000_adap rxdr->count = E1000_DEFAULT_RXD; size = rxdr->count * sizeof(struct e1000_buffer); - if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) { + if (!(rxdr->buffer_info = kzalloc(size, GFP_KERNEL))) { ret_val = 4; goto err_nomem; } - memset(rxdr->buffer_info, 0, size); rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc); if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) { --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c @@ -1055,28 +1055,25 @@ e1000_alloc_queues(struct e1000_adapter int size; size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues; - adapter->tx_ring = kmalloc(size, GFP_KERNEL); + adapter->tx_ring = kzalloc(size, GFP_KERNEL); if (!adapter->tx_ring) return -ENOMEM; - memset(adapter->tx_ring, 0, size); size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues; - adapter->rx_ring = kmalloc(size, GFP_KERNEL); + adapter->rx_ring = kzalloc(size, GFP_KERNEL); if (!adapter->rx_ring) { kfree(adapter->tx_ring); return -ENOMEM; } - memset(adapter->rx_ring, 0, size); #ifdef CONFIG_E1000_NAPI size = sizeof(struct net_device) * adapter->num_rx_queues; - adapter->polling_netdev = kmalloc(size, GFP_KERNEL); + adapter->polling_netdev = kzalloc(size, GFP_KERNEL); if (!adapter->polling_netdev) { kfree(adapter->tx_ring); kfree(adapter->rx_ring); return -ENOMEM; } - memset(adapter->polling_netdev, 0, size); #endif return E1000_SUCCESS; @@ -1450,17 +1447,16 @@ e1000_setup_rx_resources(struct e1000_ad memset(rxdr->buffer_info, 0, size); size = sizeof(struct e1000_ps_page) * rxdr->count; - rxdr->ps_page = kmalloc(size, GFP_KERNEL); + rxdr->ps_page = kzalloc(size, GFP_KERNEL); if (!rxdr->ps_page) { vfree(rxdr->buffer_info); DPRINTK(PROBE, ERR, "Unable to allocate memory for the receive descriptor ring\n"); return -ENOMEM; } - memset(rxdr->ps_page, 0, size); size = sizeof(struct e1000_ps_page_dma) * rxdr->count; - rxdr->ps_page_dma = kmalloc(size, GFP_KERNEL); + rxdr->ps_page_dma = kzalloc(size, GFP_KERNEL); if (!rxdr->ps_page_dma) { vfree(rxdr->buffer_info); kfree(rxdr->ps_page); @@ -1468,7 +1464,6 @@ e1000_setup_rx_resources(struct e1000_ad "Unable to allocate memory for the receive descriptor ring\n"); return -ENOMEM; } - memset(rxdr->ps_page_dma, 0, size); if (adapter->hw.mac_type <= e1000_82547_rev_2) desc_len = sizeof(struct e1000_rx_desc); --- a/drivers/net/e100.c +++ b/drivers/net/e100.c @@ -1931,9 +1931,8 @@ static int e100_rx_alloc_list(struct nic nic->rx_to_use = nic->rx_to_clean = NULL; nic->ru_running = RU_UNINITIALIZED; - if(!(nic->rxs = kmalloc(sizeof(struct rx) * count, GFP_ATOMIC))) + if(!(nic->rxs = kcalloc(count, sizeof(struct rx), GFP_ATOMIC))) return -ENOMEM; - memset(nic->rxs, 0, sizeof(struct rx) * count); for(rx = nic->rxs, i = 0; i < count; rx++, i++) { rx->next = (i + 1 < count) ? rx + 1 : nic->rxs; @@ -2799,7 +2798,7 @@ static int __init e100_init_module(void) printk(KERN_INFO PFX "%s, %s\n", DRV_DESCRIPTION, DRV_VERSION); printk(KERN_INFO PFX "%s\n", DRV_COPYRIGHT); } - return pci_module_init(&e100_driver); + return pci_register_driver(&e100_driver); } static void __exit e100_cleanup_module(void) --- a/drivers/net/eepro100.c +++ b/drivers/net/eepro100.c @@ -2391,7 +2391,7 @@ static int __init eepro100_init_module(v #ifdef MODULE printk(version); #endif - return pci_module_init(&eepro100_driver); + return pci_register_driver(&eepro100_driver); } static void __exit eepro100_cleanup_module(void) --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c @@ -1673,7 +1673,7 @@ static int __init epic_init (void) version, version2, version3); #endif - return pci_module_init (&epic_driver); + return pci_register_driver (&epic_driver); } --- a/drivers/net/fealnx.c +++ b/drivers/net/fealnx.c @@ -1992,7 +1992,7 @@ static int __init fealnx_init(void) printk(version); #endif - return pci_module_init(&fealnx_driver); + return pci_register_driver(&fealnx_driver); } static void __exit fealnx_exit(void) --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -692,10 +692,13 @@ fec_enet_mii(struct net_device *dev) volatile fec_t *ep; mii_list_t *mip; uint mii_reg; + unsigned long flags; fep = netdev_priv(dev); ep = fep->hwp; mii_reg = ep->fec_mii_data; + + spin_lock_irqsave(&mii_lock, flags); if ((mip = mii_head) == NULL) { printk("MII and no head!\n"); @@ -711,6 +714,8 @@ fec_enet_mii(struct net_device *dev) if ((mip = mii_head) != NULL) ep->fec_mii_data = mip->mii_regval; + + spin_unlock_irqrestore(&mii_lock, flags); } static int @@ -728,8 +733,7 @@ mii_queue(struct net_device *dev, int re retval = 0; - save_flags(flags); - cli(); + spin_lock_irqsave(&mii_lock, flags); if ((mip = mii_free) != NULL) { mii_free = mip->mii_next; @@ -749,7 +753,7 @@ mii_queue(struct net_device *dev, int re retval = 1; } - restore_flags(flags); + spin_unlock_irqrestore(&mii_lock, flags); return(retval); } --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -3251,7 +3251,7 @@ static struct pci_driver driver = { static int __init init_nic(void) { printk(KERN_INFO "forcedeth.c: Reverse Engineered nForce ethernet driver. Version %s.\n", FORCEDETH_VERSION); - return pci_module_init(&driver); + return pci_register_driver(&driver); } static void __exit exit_nic(void) --- a/drivers/net/fs_enet/fs_enet-mii.c +++ b/drivers/net/fs_enet/fs_enet-mii.c @@ -389,12 +389,11 @@ static struct fs_enet_mii_bus *create_bu struct fs_enet_mii_bus *bus; int ret = 0; - bus = kmalloc(sizeof(*bus), GFP_KERNEL); + bus = kzalloc(sizeof(*bus), GFP_KERNEL); if (bus == NULL) { ret = -ENOMEM; goto err; } - memset(bus, 0, sizeof(*bus)); spin_lock_init(&bus->mii_lock); bus->bus_info = bi; bus->refs = 0; --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c @@ -35,7 +35,6 @@ #include #include -#include #include "gianfar.h" --- a/drivers/net/gt64240eth.h +++ b/drivers/net/gt64240eth.h 1970-01-01 03:00:00.000000000 +0300 @@ -1,402 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 2001 Patton Electronics Company - * Copyright (C) 2002 Momentum Computer - * - * Copyright 2000 MontaVista Software Inc. - * Author: MontaVista Software, Inc. - * stevel@mvista.com or support@mvista.com - * - * This program is free software; you can distribute it and/or modify it - * under the terms of the GNU General Public License (Version 2) as - * published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Ethernet driver definitions for the MIPS GT96100 Advanced - * Communication Controller. - * - * Modified for the Marvellous GT64240 Retarded Communication Controller. - */ -#ifndef _GT64240ETH_H -#define _GT64240ETH_H - -#include - -#define ETHERNET_PORTS_DIFFERENCE_OFFSETS 0x400 - -/* Translate those weanie names from Galileo/VxWorks header files: */ - -#define GT64240_MRR MAIN_ROUTING_REGISTER -#define GT64240_CIU_ARBITER_CONFIG COMM_UNIT_ARBITER_CONFIGURATION_REGISTER -#define GT64240_CIU_ARBITER_CONTROL COMM_UNIT_ARBITER_CONTROL -#define GT64240_MAIN_LOW_CAUSE LOW_INTERRUPT_CAUSE_REGISTER -#define GT64240_MAIN_HIGH_CAUSE HIGH_INTERRUPT_CAUSE_REGISTER -#define GT64240_CPU_LOW_MASK CPU_INTERRUPT_MASK_REGISTER_LOW -#define GT64240_CPU_HIGH_MASK CPU_INTERRUPT_MASK_REGISTER_HIGH -#define GT64240_CPU_SELECT_CAUSE CPU_SELECT_CAUSE_REGISTER - -#define GT64240_ETH_PHY_ADDR_REG ETHERNET_PHY_ADDRESS_REGISTER -#define GT64240_ETH_PORT_CONFIG ETHERNET0_PORT_CONFIGURATION_REGISTER -#define GT64240_ETH_PORT_CONFIG_EXT ETHERNET0_PORT_CONFIGURATION_EXTEND_REGISTER -#define GT64240_ETH_PORT_COMMAND ETHERNET0_PORT_COMMAND_REGISTER -#define GT64240_ETH_PORT_STATUS ETHERNET0_PORT_STATUS_REGISTER -#define GT64240_ETH_IO_SIZE ETHERNET_PORTS_DIFFERENCE_OFFSETS -#define GT64240_ETH_SMI_REG ETHERNET_SMI_REGISTER -#define GT64240_ETH_MIB_COUNT_BASE ETHERNET0_MIB_COUNTER_BASE -#define GT64240_ETH_SDMA_CONFIG ETHERNET0_SDMA_CONFIGURATION_REGISTER -#define GT64240_ETH_SDMA_COMM ETHERNET0_SDMA_COMMAND_REGISTER -#define GT64240_ETH_INT_MASK ETHERNET0_INTERRUPT_MASK_REGISTER -#define GT64240_ETH_INT_CAUSE ETHERNET0_INTERRUPT_CAUSE_REGISTER -#define GT64240_ETH_CURR_TX_DESC_PTR0 ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER0 -#define GT64240_ETH_CURR_TX_DESC_PTR1 ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER1 -#define GT64240_ETH_1ST_RX_DESC_PTR0 ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER0 -#define GT64240_ETH_CURR_RX_DESC_PTR0 ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER0 -#define GT64240_ETH_HASH_TBL_PTR ETHERNET0_HASH_TABLE_POINTER_REGISTER - -/* Turn on NAPI by default */ - -#define GT64240_NAPI 1 - -/* Some 64240 settings that SHOULD eventually be setup in PROM monitor: */ -/* (Board-specific to the DSL3224 Rev A board ONLY!) */ -#define D3224_MPP_CTRL0_SETTING 0x66669900 -#define D3224_MPP_CTRL1_SETTING 0x00000000 -#define D3224_MPP_CTRL2_SETTING 0x00887700 -#define D3224_MPP_CTRL3_SETTING 0x00000044 -#define D3224_GPP_IO_CTRL_SETTING 0x0000e800 -#define D3224_GPP_LEVEL_CTRL_SETTING 0xf001f703 -#define D3224_GPP_VALUE_SETTING 0x00000000 - -/* Keep the ring sizes a power of two for efficiency. */ -//-#define TX_RING_SIZE 16 -#define TX_RING_SIZE 64 /* TESTING !!! */ -#define RX_RING_SIZE 32 -#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */ - -#define RX_HASH_TABLE_SIZE 16384 -#define HASH_HOP_NUMBER 12 - -#define NUM_INTERFACES 3 - -#define GT64240ETH_TX_TIMEOUT HZ/4 - -#define MIPS_GT64240_BASE 0xf4000000 -#define GT64240_ETH0_BASE (MIPS_GT64240_BASE + GT64240_ETH_PORT_CONFIG) -#define GT64240_ETH1_BASE (GT64240_ETH0_BASE + GT64240_ETH_IO_SIZE) -#define GT64240_ETH2_BASE (GT64240_ETH1_BASE + GT64240_ETH_IO_SIZE) - -#if defined(CONFIG_MIPS_DSL3224) -#define GT64240_ETHER0_IRQ 4 -#define GT64240_ETHER1_IRQ 4 -#else -#define GT64240_ETHER0_IRQ -1 -#define GT64240_ETHER1_IRQ -1 -#endif - -#define REV_GT64240 0x1 -#define REV_GT64240A 0x10 - -#define GT64240ETH_READ(gp, offset) \ - GT_READ((gp)->port_offset + (offset)) - -#define GT64240ETH_WRITE(gp, offset, data) \ - GT_WRITE((gp)->port_offset + (offset), (data)) - -#define GT64240ETH_SETBIT(gp, offset, bits) \ - GT64240ETH_WRITE((gp), (offset), \ - GT64240ETH_READ((gp), (offset)) | (bits)) - -#define GT64240ETH_CLRBIT(gp, offset, bits) \ - GT64240ETH_WRITE((gp), (offset), \ - GT64240ETH_READ((gp), (offset)) & ~(bits)) - -#define GT64240_READ(ofs) GT_READ(ofs) -#define GT64240_WRITE(ofs, data) GT_WRITE((ofs), (data)) - -/* Bit definitions of the SMI Reg */ -enum { - smirDataMask = 0xffff, - smirPhyAdMask = 0x1f << 16, - smirPhyAdBit = 16, - smirRegAdMask = 0x1f << 21, - smirRegAdBit = 21, - smirOpCode = 1 << 26, - smirReadValid = 1 << 27, - smirBusy = 1 << 28 -}; - -/* Bit definitions of the Port Config Reg */ -enum pcr_bits { - pcrPM = 1 << 0, - pcrRBM = 1 << 1, - pcrPBF = 1 << 2, - pcrEN = 1 << 7, - pcrLPBKMask = 0x3 << 8, - pcrLPBKBit = 1 << 8, - pcrFC = 1 << 10, - pcrHS = 1 << 12, - pcrHM = 1 << 13, - pcrHDM = 1 << 14, - pcrHD = 1 << 15, - pcrISLMask = 0x7 << 28, - pcrISLBit = 28, - pcrACCS = 1 << 31 -}; - -/* Bit definitions of the Port Config Extend Reg */ -enum pcxr_bits { - pcxrIGMP = 1, - pcxrSPAN = 2, - pcxrPAR = 4, - pcxrPRIOtxMask = 0x7 << 3, - pcxrPRIOtxBit = 3, - pcxrPRIOrxMask = 0x3 << 6, - pcxrPRIOrxBit = 6, - pcxrPRIOrxOverride = 1 << 8, - pcxrDPLXen = 1 << 9, - pcxrFCTLen = 1 << 10, - pcxrFLP = 1 << 11, - pcxrFCTL = 1 << 12, - pcxrMFLMask = 0x3 << 14, - pcxrMFLBit = 14, - pcxrMIBclrMode = 1 << 16, - pcxrSpeed = 1 << 18, - pcxrSpeeden = 1 << 19, - pcxrRMIIen = 1 << 20, - pcxrDSCPen = 1 << 21 -}; - -/* Bit definitions of the Port Command Reg */ -enum pcmr_bits { - pcmrFJ = 1 << 15 -}; - - -/* Bit definitions of the Port Status Reg */ -enum psr_bits { - psrSpeed = 1, - psrDuplex = 2, - psrFctl = 4, - psrLink = 8, - psrPause = 1 << 4, - psrTxLow = 1 << 5, - psrTxHigh = 1 << 6, - psrTxInProg = 1 << 7 -}; - -/* Bit definitions of the SDMA Config Reg */ -enum sdcr_bits { - sdcrRCMask = 0xf << 2, - sdcrRCBit = 2, - sdcrBLMR = 1 << 6, - sdcrBLMT = 1 << 7, - sdcrPOVR = 1 << 8, - sdcrRIFB = 1 << 9, - sdcrBSZMask = 0x3 << 12, - sdcrBSZBit = 12 -}; - -/* Bit definitions of the SDMA Command Reg */ -enum sdcmr_bits { - sdcmrERD = 1 << 7, - sdcmrAR = 1 << 15, - sdcmrSTDH = 1 << 16, - sdcmrSTDL = 1 << 17, - sdcmrTXDH = 1 << 23, - sdcmrTXDL = 1 << 24, - sdcmrAT = 1 << 31 -}; - -/* Bit definitions of the Interrupt Cause Reg */ -enum icr_bits { - icrRxBuffer = 1, - icrTxBufferHigh = 1 << 2, - icrTxBufferLow = 1 << 3, - icrTxEndHigh = 1 << 6, - icrTxEndLow = 1 << 7, - icrRxError = 1 << 8, - icrTxErrorHigh = 1 << 10, - icrTxErrorLow = 1 << 11, - icrRxOVR = 1 << 12, - icrTxUdr = 1 << 13, - icrRxBufferQ0 = 1 << 16, - icrRxBufferQ1 = 1 << 17, - icrRxBufferQ2 = 1 << 18, - icrRxBufferQ3 = 1 << 19, - icrRxErrorQ0 = 1 << 20, - icrRxErrorQ1 = 1 << 21, - icrRxErrorQ2 = 1 << 22, - icrRxErrorQ3 = 1 << 23, - icrMIIPhySTC = 1 << 28, - icrSMIdone = 1 << 29, - icrEtherIntSum = 1 << 31 -}; - - -/* The Rx and Tx descriptor lists. */ -#ifdef __LITTLE_ENDIAN -typedef struct { - u32 cmdstat; - u16 reserved; //-prk21aug01 u32 reserved:16; - u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16; - u32 buff_ptr; - u32 next; -} gt64240_td_t; - -typedef struct { - u32 cmdstat; - u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16; - u16 buff_sz; //-prk21aug01 u32 buff_sz:16; - u32 buff_ptr; - u32 next; -} gt64240_rd_t; -#elif defined(__BIG_ENDIAN) -typedef struct { - u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16; - u16 reserved; //-prk21aug01 u32 reserved:16; - u32 cmdstat; - u32 next; - u32 buff_ptr; -} gt64240_td_t; - -typedef struct { - u16 buff_sz; //-prk21aug01 u32 buff_sz:16; - u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16; - u32 cmdstat; - u32 next; - u32 buff_ptr; -} gt64240_rd_t; -#else -#error Either __BIG_ENDIAN or __LITTLE_ENDIAN must be defined! -#endif - - -/* Values for the Tx command-status descriptor entry. */ -enum td_cmdstat { - txOwn = 1 << 31, - txAutoMode = 1 << 30, - txEI = 1 << 23, - txGenCRC = 1 << 22, - txPad = 1 << 18, - txFirst = 1 << 17, - txLast = 1 << 16, - txErrorSummary = 1 << 15, - txReTxCntMask = 0x0f << 10, - txReTxCntBit = 10, - txCollision = 1 << 9, - txReTxLimit = 1 << 8, - txUnderrun = 1 << 6, - txLateCollision = 1 << 5 -}; - - -/* Values for the Rx command-status descriptor entry. */ -enum rd_cmdstat { - rxOwn = 1 << 31, - rxAutoMode = 1 << 30, - rxEI = 1 << 23, - rxFirst = 1 << 17, - rxLast = 1 << 16, - rxErrorSummary = 1 << 15, - rxIGMP = 1 << 14, - rxHashExpired = 1 << 13, - rxMissedFrame = 1 << 12, - rxFrameType = 1 << 11, - rxShortFrame = 1 << 8, - rxMaxFrameLen = 1 << 7, - rxOverrun = 1 << 6, - rxCollision = 1 << 4, - rxCRCError = 1 -}; - -/* Bit fields of a Hash Table Entry */ -enum hash_table_entry { - hteValid = 1, - hteSkip = 2, - hteRD = 4 -}; - -// The MIB counters -typedef struct { - u32 byteReceived; - u32 byteSent; - u32 framesReceived; - u32 framesSent; - u32 totalByteReceived; - u32 totalFramesReceived; - u32 broadcastFramesReceived; - u32 multicastFramesReceived; - u32 cRCError; - u32 oversizeFrames; - u32 fragments; - u32 jabber; - u32 collision; - u32 lateCollision; - u32 frames64; - u32 frames65_127; - u32 frames128_255; - u32 frames256_511; - u32 frames512_1023; - u32 frames1024_MaxSize; - u32 macRxError; - u32 droppedFrames; - u32 outMulticastFrames; - u32 outBroadcastFrames; - u32 undersizeFrames; -} mib_counters_t; - - -struct gt64240_private { - gt64240_rd_t *rx_ring; - gt64240_td_t *tx_ring; - // The Rx and Tx rings must be 16-byte aligned - dma_addr_t rx_ring_dma; - dma_addr_t tx_ring_dma; - char *hash_table; - // The Hash Table must be 8-byte aligned - dma_addr_t hash_table_dma; - int hash_mode; - - // The Rx buffers must be 8-byte aligned - char *rx_buff; - dma_addr_t rx_buff_dma; - // Tx buffers (tx_skbuff[i]->data) with less than 8 bytes - // of payload must be 8-byte aligned - struct sk_buff *tx_skbuff[TX_RING_SIZE]; - int rx_next_out; /* The next free ring entry to receive */ - int tx_next_in; /* The next free ring entry to send */ - int tx_next_out; /* The last ring entry the ISR processed */ - int tx_count; /* current # of pkts waiting to be sent in Tx ring */ - int intr_work_done; /* number of Rx and Tx pkts processed in the isr */ - int tx_full; /* Tx ring is full */ - - mib_counters_t mib; - struct net_device_stats stats; - - int io_size; - int port_num; // 0 or 1 - u32 port_offset; - - int phy_addr; // PHY address - u32 last_psr; // last value of the port status register - - int options; /* User-settable misc. driver options. */ - int drv_flags; - spinlock_t lock; /* Serialise access to device */ - struct mii_if_info mii_if; - - u32 msg_enable; -}; - -#endif /* _GT64240ETH_H */ --- a/drivers/net/hp100.c +++ b/drivers/net/hp100.c @@ -406,7 +406,7 @@ struct net_device * __init hp100_probe(i #ifdef HP100_DEBUG_B hp100_outw(0x4200, TRACE); - printk("hp100: %s: probe\n", dev->name); + printk(KERN_DEBUG "hp100: %s: probe\n", dev->name); #endif if (unit >= 0) { @@ -442,7 +442,7 @@ static int __devinit hp100_probe1(struct #ifdef HP100_DEBUG_B hp100_outw(0x4201, TRACE); - printk("hp100: %s: probe1\n", dev->name); + printk(KERN_DEBUG "hp100: %s: probe1\n", dev->name); #endif /* memory region for programmed i/o */ @@ -455,13 +455,13 @@ static int __devinit hp100_probe1(struct chip = hp100_inw(PAGING) & HP100_CHIPID_MASK; #ifdef HP100_DEBUG if (chip == HP100_CHIPID_SHASTA) - printk("hp100: %s: Shasta Chip detected. (This is a pre 802.12 chip)\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Shasta Chip detected. (This is a pre 802.12 chip)\n", dev->name); else if (chip == HP100_CHIPID_RAINIER) - printk("hp100: %s: Rainier Chip detected. (This is a pre 802.12 chip)\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Rainier Chip detected. (This is a pre 802.12 chip)\n", dev->name); else if (chip == HP100_CHIPID_LASSEN) - printk("hp100: %s: Lassen Chip detected.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Lassen Chip detected.\n", dev->name); else - printk("hp100: %s: Warning: Unknown CASCADE chip (id=0x%.4x).\n", dev->name, chip); + printk(KERN_DEBUG "hp100: %s: Warning: Unknown CASCADE chip (id=0x%.4x).\n", dev->name, chip); #endif dev->base_addr = ioaddr; @@ -518,7 +518,7 @@ static int __devinit hp100_probe1(struct if (local_mode < 1 || local_mode > 4) local_mode = 1; /* default */ #ifdef HP100_DEBUG - printk("hp100: %s: original LSW = 0x%x\n", dev->name, + printk(KERN_DEBUG "hp100: %s: original LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW)); #endif @@ -526,17 +526,17 @@ static int __devinit hp100_probe1(struct hp100_outw(HP100_MEM_EN | HP100_RESET_LB, OPTION_LSW); hp100_outw(HP100_IO_EN | HP100_SET_LB, OPTION_LSW); hp100_outw(HP100_BM_WRITE | HP100_BM_READ | HP100_RESET_HB, OPTION_LSW); - printk("hp100: IO mapped mode forced.\n"); + printk(KERN_INFO "hp100: IO mapped mode forced.\n"); } else if (local_mode == 2) { hp100_outw(HP100_MEM_EN | HP100_SET_LB, OPTION_LSW); hp100_outw(HP100_IO_EN | HP100_SET_LB, OPTION_LSW); hp100_outw(HP100_BM_WRITE | HP100_BM_READ | HP100_RESET_HB, OPTION_LSW); - printk("hp100: Shared memory mode requested.\n"); + printk(KERN_INFO "hp100: Shared memory mode requested.\n"); } else if (local_mode == 4) { if (chip == HP100_CHIPID_LASSEN) { hp100_outw(HP100_BM_WRITE | HP100_BM_READ | HP100_SET_HB, OPTION_LSW); hp100_outw(HP100_IO_EN | HP100_MEM_EN | HP100_RESET_LB, OPTION_LSW); - printk("hp100: Busmaster mode requested.\n"); + printk(KERN_INFO "hp100: Busmaster mode requested.\n"); } local_mode = 1; } @@ -547,7 +547,7 @@ static int __devinit hp100_probe1(struct if ((lsw & HP100_IO_EN) && (~lsw & HP100_MEM_EN) && (~lsw & (HP100_BM_WRITE | HP100_BM_READ))) { #ifdef HP100_DEBUG - printk("hp100: %s: IO_EN bit is set on card.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: IO_EN bit is set on card.\n", dev->name); #endif local_mode = 3; } else if (chip == HP100_CHIPID_LASSEN && @@ -562,13 +562,13 @@ static int __devinit hp100_probe1(struct /* Gracefully fallback to shared memory */ goto busmasterfail; } - printk("hp100: Busmaster mode enabled.\n"); + printk(KERN_INFO "hp100: Busmaster mode enabled.\n"); hp100_outw(HP100_MEM_EN | HP100_IO_EN | HP100_RESET_LB, OPTION_LSW); } else { busmasterfail: #ifdef HP100_DEBUG - printk("hp100: %s: Card not configured for BM or BM not supported with this card.\n", dev->name); - printk("hp100: %s: Trying shared memory mode.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Card not configured for BM or BM not supported with this card.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Trying shared memory mode.\n", dev->name); #endif /* In this case, try shared memory mode */ local_mode = 2; @@ -577,7 +577,7 @@ static int __devinit hp100_probe1(struct } } #ifdef HP100_DEBUG - printk("hp100: %s: new LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW)); + printk(KERN_DEBUG "hp100: %s: new LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW)); #endif /* Check for shared memory on the card, eventually remap it */ @@ -594,7 +594,7 @@ static int __devinit hp100_probe1(struct mem_ptr_phys &= ~0x1fff; /* 8k alignment */ if (bus == HP100_BUS_ISA && (mem_ptr_phys & ~0xfffff) != 0) { - printk("hp100: Can only use programmed i/o mode.\n"); + printk(KERN_INFO "hp100: Can only use programmed i/o mode.\n"); mem_ptr_phys = 0; mem_mapped = 0; local_mode = 3; /* Use programmed i/o */ @@ -607,18 +607,18 @@ static int __devinit hp100_probe1(struct for (virt_memory_size = memory_size; virt_memory_size > 16383; virt_memory_size >>= 1) { if ((mem_ptr_virt = ioremap((u_long) mem_ptr_phys, virt_memory_size)) == NULL) { #ifdef HP100_DEBUG - printk("hp100: %s: ioremap for 0x%x bytes high PCI memory at 0x%lx failed\n", dev->name, virt_memory_size, mem_ptr_phys); + printk(KERN_DEBUG "hp100: %s: ioremap for 0x%x bytes high PCI memory at 0x%lx failed\n", dev->name, virt_memory_size, mem_ptr_phys); #endif } else { #ifdef HP100_DEBUG - printk("hp100: %s: remapped 0x%x bytes high PCI memory at 0x%lx to %p.\n", dev->name, virt_memory_size, mem_ptr_phys, mem_ptr_virt); + printk(KERN_DEBUG "hp100: %s: remapped 0x%x bytes high PCI memory at 0x%lx to %p.\n", dev->name, virt_memory_size, mem_ptr_phys, mem_ptr_virt); #endif break; } } if (mem_ptr_virt == NULL) { /* all ioremap tries failed */ - printk("hp100: Failed to ioremap the PCI card memory. Will have to use i/o mapped mode.\n"); + printk(KERN_WARNING "hp100: Failed to ioremap the PCI card memory. Will have to use i/o mapped mode.\n"); local_mode = 3; virt_memory_size = 0; } @@ -629,7 +629,7 @@ static int __devinit hp100_probe1(struct mem_mapped = 0; mem_ptr_phys = 0; mem_ptr_virt = NULL; - printk("hp100: Using (slow) programmed i/o mode.\n"); + printk(KERN_INFO "hp100: Using (slow) programmed i/o mode.\n"); } /* Initialise the "private" data structure for this card. */ @@ -711,7 +711,7 @@ static int __devinit hp100_probe1(struct lp->whatever_offset = ((u_long) page_baddr) - ((u_long) lp->page_vaddr_algn); #ifdef HP100_DEBUG_BM - printk("hp100: %s: Reserved DMA memory from 0x%x to 0x%x\n", dev->name, (u_int) lp->page_vaddr_algn, (u_int) lp->page_vaddr_algn + MAX_RINGSIZE); + printk(KERN_DEBUG "hp100: %s: Reserved DMA memory from 0x%x to 0x%x\n", dev->name, (u_int) lp->page_vaddr_algn, (u_int) lp->page_vaddr_algn + MAX_RINGSIZE); #endif lp->rxrcommit = lp->txrcommit = 0; lp->rxrhead = lp->rxrtail = &(lp->rxring[0]); @@ -729,7 +729,7 @@ static int __devinit hp100_probe1(struct lp->lan_type = hp100_sense_lan(dev); /* Print out a message what about what we think we have probed. */ - printk("hp100: at 0x%x, IRQ %d, ", ioaddr, dev->irq); + printk(KERN_INFO "hp100: at 0x%x, IRQ %d, ", ioaddr, dev->irq); switch (bus) { case HP100_BUS_EISA: printk("EISA"); @@ -744,7 +744,7 @@ static int __devinit hp100_probe1(struct printk(" bus, %dk SRAM (rx/tx %d%%).\n", lp->memory_size >> 10, lp->rx_ratio); if (lp->mode == 2) { /* memory mapped */ - printk("hp100: Memory area at 0x%lx-0x%lx", mem_ptr_phys, + printk(KERN_INFO "hp100: Memory area at 0x%lx-0x%lx", mem_ptr_phys, (mem_ptr_phys + (mem_ptr_phys > 0x100000 ? (u_long) lp->memory_size : 16 * 1024)) - 1); if (mem_ptr_virt) printk(" (virtual base %p)", mem_ptr_virt); @@ -755,7 +755,7 @@ static int __devinit hp100_probe1(struct dev->mem_end = mem_ptr_phys + lp->memory_size; } - printk("hp100: "); + printk(KERN_INFO "hp100: "); if (lp->lan_type != HP100_LAN_ERR) printk("Adapter is attached to "); switch (lp->lan_type) { @@ -798,7 +798,7 @@ static void hp100_hwinit(struct net_devi #ifdef HP100_DEBUG_B hp100_outw(0x4202, TRACE); - printk("hp100: %s: hwinit\n", dev->name); + printk(KERN_DEBUG "hp100: %s: hwinit\n", dev->name); #endif /* Initialise the card. -------------------------------------------- */ @@ -893,12 +893,12 @@ static void hp100_mmuinit(struct net_dev #ifdef HP100_DEBUG_B hp100_outw(0x4203, TRACE); - printk("hp100: %s: mmuinit\n", dev->name); + printk(KERN_DEBUG "hp100: %s: mmuinit\n", dev->name); #endif #ifdef HP100_DEBUG if (0 != (hp100_inw(OPTION_LSW) & HP100_HW_RST)) { - printk("hp100: %s: Not in reset when entering mmuinit. Fix me.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Not in reset when entering mmuinit. Fix me.\n", dev->name); return; } #endif @@ -991,7 +991,7 @@ static void hp100_mmuinit(struct net_dev recv_stop = (xmit_stop * (lp->rx_ratio) / 100) & ~(0x03ff); hp100_outw((pdl_stop >> 4) - 1, PDL_MEM_STOP); #ifdef HP100_DEBUG_BM - printk("hp100: %s: PDL_STOP = 0x%x\n", dev->name, pdl_stop); + printk(KERN_DEBUG "hp100: %s: PDL_STOP = 0x%x\n", dev->name, pdl_stop); #endif } else { /* ETR chip (Lassen) in busmaster mode */ @@ -1002,16 +1002,16 @@ static void hp100_mmuinit(struct net_dev hp100_outw(xmit_stop >> 4, TX_MEM_STOP); hp100_outw(recv_stop >> 4, RX_MEM_STOP); #ifdef HP100_DEBUG_BM - printk("hp100: %s: TX_STOP = 0x%x\n", dev->name, xmit_stop >> 4); - printk("hp100: %s: RX_STOP = 0x%x\n", dev->name, recv_stop >> 4); + printk(KERN_DEBUG "hp100: %s: TX_STOP = 0x%x\n", dev->name, xmit_stop >> 4); + printk(KERN_DEBUG "hp100: %s: RX_STOP = 0x%x\n", dev->name, recv_stop >> 4); #endif } else { /* Slave modes (memory mapped and programmed io) */ hp100_outw((((lp->memory_size * lp->rx_ratio) / 100) >> 4), RX_MEM_STOP); hp100_outw(((lp->memory_size - 1) >> 4), TX_MEM_STOP); #ifdef HP100_DEBUG - printk("hp100: %s: TX_MEM_STOP: 0x%x\n", dev->name, hp100_inw(TX_MEM_STOP)); - printk("hp100: %s: RX_MEM_STOP: 0x%x\n", dev->name, hp100_inw(RX_MEM_STOP)); + printk(KERN_DEBUG "hp100: %s: TX_MEM_STOP: 0x%x\n", dev->name, hp100_inw(TX_MEM_STOP)); + printk(KERN_DEBUG "hp100: %s: RX_MEM_STOP: 0x%x\n", dev->name, hp100_inw(RX_MEM_STOP)); #endif } @@ -1073,7 +1073,7 @@ static int hp100_open(struct net_device #ifdef HP100_DEBUG_B hp100_outw(0x4204, TRACE); - printk("hp100: %s: open\n", dev->name); + printk(KERN_DEBUG "hp100: %s: open\n", dev->name); #endif /* New: if bus is PCI or EISA, interrupts might be shared interrupts */ @@ -1081,7 +1081,7 @@ static int hp100_open(struct net_device lp->bus == HP100_BUS_PCI || lp->bus == HP100_BUS_EISA ? SA_SHIRQ : SA_INTERRUPT, "hp100", dev)) { - printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq); + printk(KERN_WARNING "hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq); return -EAGAIN; } @@ -1110,7 +1110,7 @@ static int hp100_close(struct net_device #ifdef HP100_DEBUG_B hp100_outw(0x4205, TRACE); - printk("hp100: %s: close\n", dev->name); + printk(KERN_DEBUG "hp100: %s: close\n", dev->name); #endif hp100_page(PERFORMANCE); @@ -1126,7 +1126,7 @@ static int hp100_close(struct net_device free_irq(dev->irq, dev); #ifdef HP100_DEBUG - printk("hp100: %s: close LSW = 0x%x\n", dev->name, + printk(KERN_DEBUG "hp100: %s: close LSW = 0x%x\n", dev->name, hp100_inw(OPTION_LSW)); #endif @@ -1150,11 +1150,11 @@ static void hp100_init_pdls(struct net_d #ifdef HP100_DEBUG_B hp100_outw(0x4206, TRACE); - printk("hp100: %s: init pdls\n", dev->name); + printk(KERN_DEBUG "hp100: %s: init pdls\n", dev->name); #endif if (0 == lp->page_vaddr_algn) - printk("hp100: %s: Warning: lp->page_vaddr_algn not initialised!\n", dev->name); + printk(KERN_WARNING "hp100: %s: Warning: lp->page_vaddr_algn not initialised!\n", dev->name); else { /* pageptr shall point into the DMA accessible memory region */ /* we use this pointer to status the upper limit of allocated */ @@ -1194,7 +1194,7 @@ static int hp100_init_rxpdl(struct net_d /* pdlptr is starting address for this pdl */ if (0 != (((unsigned long) pdlptr) & 0xf)) - printk("hp100: %s: Init rxpdl: Unaligned pdlptr 0x%lx.\n", + printk(KERN_INFO "hp100: %s: Init rxpdl: Unaligned pdlptr 0x%lx.\n", dev->name, (unsigned long) pdlptr); ringptr->pdl = pdlptr + 1; @@ -1221,7 +1221,7 @@ static int hp100_init_txpdl(struct net_d register u32 * pdlptr) { if (0 != (((unsigned long) pdlptr) & 0xf)) - printk("hp100: %s: Init txpdl: Unaligned pdlptr 0x%lx.\n", dev->name, (unsigned long) pdlptr); + printk(KERN_INFO "hp100: %s: Init txpdl: Unaligned pdlptr 0x%lx.\n", dev->name, (unsigned long) pdlptr); ringptr->pdl = pdlptr; /* +1; */ ringptr->pdl_paddr = virt_to_whatever(dev, pdlptr); /* +1 */ @@ -1249,7 +1249,7 @@ static int hp100_build_rx_pdl(hp100_ring #ifdef HP100_DEBUG_B hp100_outw(0x4207, TRACE); - printk("hp100: %s: build rx pdl\n", dev->name); + printk(KERN_DEBUG "hp100: %s: build rx pdl\n", dev->name); #endif /* Allocate skb buffer of maximum size */ @@ -1277,7 +1277,7 @@ static int hp100_build_rx_pdl(hp100_ring * directly before the PDL. */ #ifdef HP100_DEBUG_BM - printk("hp100: %s: build_rx_pdl: PDH@0x%x, skb->data (len %d) at 0x%x\n", + printk(KERN_DEBUG "hp100: %s: build_rx_pdl: PDH@0x%x, skb->data (len %d) at 0x%x\n", dev->name, (u_int) ringptr->pdl, ((MAX_ETHER_SIZE + 2 + 3) / 4) * 4, (unsigned int) ringptr->skb->data); @@ -1292,7 +1292,7 @@ static int hp100_build_rx_pdl(hp100_ring #ifdef HP100_DEBUG_BM for (p = (ringptr->pdl); p < (ringptr->pdl + 5); p++) - printk("hp100: %s: Adr 0x%.8x = 0x%.8x\n", dev->name, (u_int) p, (u_int) * p); + printk(KERN_DEBUG "hp100: %s: Adr 0x%.8x = 0x%.8x\n", dev->name, (u_int) p, (u_int) * p); #endif return (1); } @@ -1302,7 +1302,7 @@ static int hp100_build_rx_pdl(hp100_ring * making the PDL only 1 fragment (i.e. the 4 byte packet status) */ #ifdef HP100_DEBUG_BM - printk("hp100: %s: build_rx_pdl: PDH@0x%x, No space for skb.\n", dev->name, (u_int) ringptr->pdl); + printk(KERN_DEBUG "hp100: %s: build_rx_pdl: PDH@0x%x, No space for skb.\n", dev->name, (u_int) ringptr->pdl); #endif ringptr->pdl[0] = 0x00010000; /* PDH: Count=1 Fragment */ @@ -1329,7 +1329,7 @@ static void hp100_rxfill(struct net_devi #ifdef HP100_DEBUG_B hp100_outw(0x4208, TRACE); - printk("hp100: %s: rxfill\n", dev->name); + printk(KERN_DEBUG "hp100: %s: rxfill\n", dev->name); #endif hp100_page(PERFORMANCE); @@ -1346,7 +1346,7 @@ static void hp100_rxfill(struct net_devi /* Hand this PDL over to the card */ /* Note: This needs performance page selected! */ #ifdef HP100_DEBUG_BM - printk("hp100: %s: rxfill: Hand to card: pdl #%d @0x%x phys:0x%x, buffer: 0x%x\n", + printk(KERN_DEBUG "hp100: %s: rxfill: Hand to card: pdl #%d @0x%x phys:0x%x, buffer: 0x%x\n", dev->name, lp->rxrcommit, (u_int) ringptr->pdl, (u_int) ringptr->pdl_paddr, (u_int) ringptr->pdl[3]); #endif @@ -1370,7 +1370,7 @@ static void hp100_BM_shutdown(struct net #ifdef HP100_DEBUG_B hp100_outw(0x4209, TRACE); - printk("hp100: %s: bm shutdown\n", dev->name); + printk(KERN_DEBUG "hp100: %s: bm shutdown\n", dev->name); #endif hp100_page(PERFORMANCE); @@ -1419,7 +1419,7 @@ static void hp100_BM_shutdown(struct net } if (time >= 10000) - printk("hp100: %s: BM shutdown error.\n", dev->name); + printk(KERN_INFO "hp100: %s: BM shutdown error.\n", dev->name); /* To ensure all bus master outloading activity has ceased, * wait until the Tx PDA count goes to zero or no more Tx space @@ -1451,7 +1451,7 @@ static int hp100_check_lan(struct net_de if (lp->lan_type < 0) { /* no LAN type detected yet? */ hp100_stop_interface(dev); if ((lp->lan_type = hp100_sense_lan(dev)) < 0) { - printk("hp100: %s: no connection found - check wire\n", dev->name); + printk(KERN_INFO "hp100: %s: no connection found - check wire\n", dev->name); hp100_start_interface(dev); /* 10Mb/s RX packets maybe handled */ return -EIO; } @@ -1477,7 +1477,7 @@ static int hp100_start_xmit_bm(struct sk #ifdef HP100_DEBUG_B hp100_outw(0x4210, TRACE); - printk("hp100: %s: start_xmit_bm\n", dev->name); + printk(KERN_DEBUG "hp100: %s: start_xmit_bm\n", dev->name); #endif if (skb == NULL) { @@ -1497,7 +1497,7 @@ static int hp100_start_xmit_bm(struct sk if (lp->txrtail->next == lp->txrhead) { /* No memory. */ #ifdef HP100_DEBUG - printk("hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: start_xmit_bm: No TX PDL available.\n", dev->name); #endif /* not waited long enough since last tx? */ if (time_before(jiffies, dev->trans_start + HZ)) @@ -1508,7 +1508,7 @@ static int hp100_start_xmit_bm(struct sk if (lp->lan_type == HP100_LAN_100 && lp->hub_status < 0) { /* we have a 100Mb/s adapter but it isn't connected to hub */ - printk("hp100: %s: login to 100Mb/s hub retry\n", dev->name); + printk(KERN_INFO "hp100: %s: login to 100Mb/s hub retry\n", dev->name); hp100_stop_interface(dev); lp->hub_status = hp100_login_to_vg_hub(dev, 0); hp100_start_interface(dev); @@ -1519,17 +1519,17 @@ static int hp100_start_xmit_bm(struct sk hp100_ints_on(); spin_unlock_irqrestore(&lp->lock, flags); if (i == HP100_LAN_ERR) - printk("hp100: %s: link down detected\n", dev->name); + printk(KERN_INFO "hp100: %s: link down detected\n", dev->name); else if (lp->lan_type != i) { /* cable change! */ /* it's very hard - all network settings must be changed!!! */ - printk("hp100: %s: cable change 10Mb/s <-> 100Mb/s detected\n", dev->name); + printk(KERN_INFO "hp100: %s: cable change 10Mb/s <-> 100Mb/s detected\n", dev->name); lp->lan_type = i; hp100_stop_interface(dev); if (lp->lan_type == HP100_LAN_100) lp->hub_status = hp100_login_to_vg_hub(dev, 0); hp100_start_interface(dev); } else { - printk("hp100: %s: interface reset\n", dev->name); + printk(KERN_INFO "hp100: %s: interface reset\n", dev->name); hp100_stop_interface(dev); if (lp->lan_type == HP100_LAN_100) lp->hub_status = hp100_login_to_vg_hub(dev, 0); @@ -1596,7 +1596,7 @@ static void hp100_clean_txring(struct ne #ifdef HP100_DEBUG_B hp100_outw(0x4211, TRACE); - printk("hp100: %s: clean txring\n", dev->name); + printk(KERN_DEBUG "hp100: %s: clean txring\n", dev->name); #endif /* How many PDLs have been transmitted? */ @@ -1604,12 +1604,12 @@ static void hp100_clean_txring(struct ne #ifdef HP100_DEBUG if (donecount > MAX_TX_PDL) - printk("hp100: %s: Warning: More PDLs transmitted than commited to card???\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Warning: More PDLs transmitted than commited to card???\n", dev->name); #endif for (; 0 != donecount; donecount--) { #ifdef HP100_DEBUG_BM - printk("hp100: %s: Free skb: data @0x%.8x txrcommit=0x%x TXPDL=0x%x, done=0x%x\n", + printk(KERN_DEBUG "hp100: %s: Free skb: data @0x%.8x txrcommit=0x%x TXPDL=0x%x, done=0x%x\n", dev->name, (u_int) lp->txrhead->skb->data, lp->txrcommit, hp100_inb(TX_PDL), donecount); #endif @@ -1633,7 +1633,7 @@ static int hp100_start_xmit(struct sk_bu #ifdef HP100_DEBUG_B hp100_outw(0x4212, TRACE); - printk("hp100: %s: start_xmit\n", dev->name); + printk(KERN_DEBUG "hp100: %s: start_xmit\n", dev->name); #endif if (skb == NULL) { @@ -1650,19 +1650,19 @@ static int hp100_start_xmit(struct sk_bu i = hp100_inl(TX_MEM_FREE) & 0x7fffffff; if (!(((i / 2) - 539) > (skb->len + 16) && (hp100_inb(TX_PKT_CNT) < 255))) { #ifdef HP100_DEBUG - printk("hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i); + printk(KERN_DEBUG "hp100: %s: start_xmit: tx free mem = 0x%x\n", dev->name, i); #endif /* not waited long enough since last failed tx try? */ if (time_before(jiffies, dev->trans_start + HZ)) { #ifdef HP100_DEBUG - printk("hp100: %s: trans_start timing problem\n", + printk(KERN_DEBUG "hp100: %s: trans_start timing problem\n", dev->name); #endif return -EAGAIN; } if (lp->lan_type == HP100_LAN_100 && lp->hub_status < 0) { /* we have a 100Mb/s adapter but it isn't connected to hub */ - printk("hp100: %s: login to 100Mb/s hub retry\n", dev->name); + printk(KERN_DEBUG "hp100: %s: login to 100Mb/s hub retry\n", dev->name); hp100_stop_interface(dev); lp->hub_status = hp100_login_to_vg_hub(dev, 0); hp100_start_interface(dev); @@ -1673,17 +1673,17 @@ static int hp100_start_xmit(struct sk_bu hp100_ints_on(); spin_unlock_irqrestore(&lp->lock, flags); if (i == HP100_LAN_ERR) - printk("hp100: %s: link down detected\n", dev->name); + printk(KERN_DEBUG "hp100: %s: link down detected\n", dev->name); else if (lp->lan_type != i) { /* cable change! */ /* it's very hard - all network setting must be changed!!! */ - printk("hp100: %s: cable change 10Mb/s <-> 100Mb/s detected\n", dev->name); + printk(KERN_INFO "hp100: %s: cable change 10Mb/s <-> 100Mb/s detected\n", dev->name); lp->lan_type = i; hp100_stop_interface(dev); if (lp->lan_type == HP100_LAN_100) lp->hub_status = hp100_login_to_vg_hub(dev, 0); hp100_start_interface(dev); } else { - printk("hp100: %s: interface reset\n", dev->name); + printk(KERN_INFO "hp100: %s: interface reset\n", dev->name); hp100_stop_interface(dev); if (lp->lan_type == HP100_LAN_100) lp->hub_status = hp100_login_to_vg_hub(dev, 0); @@ -1697,7 +1697,7 @@ static int hp100_start_xmit(struct sk_bu for (i = 0; i < 6000 && (hp100_inb(OPTION_MSW) & HP100_TX_CMD); i++) { #ifdef HP100_DEBUG_TX - printk("hp100: %s: start_xmit: busy\n", dev->name); + printk(KERN_DEBUG "hp100: %s: start_xmit: busy\n", dev->name); #endif } @@ -1708,7 +1708,7 @@ static int hp100_start_xmit(struct sk_bu * when the current packet being transmitted on the wire is completed. */ hp100_outw(HP100_TX_COMPLETE, IRQ_STATUS); #ifdef HP100_DEBUG_TX - printk("hp100: %s: start_xmit: irq_status=0x%.4x, irqmask=0x%.4x, len=%d\n", + printk(KERN_DEBUG "hp100: %s: start_xmit: irq_status=0x%.4x, irqmask=0x%.4x, len=%d\n", dev->name, val, hp100_inw(IRQ_MASK), (int) skb->len); #endif @@ -1742,7 +1742,7 @@ static int hp100_start_xmit(struct sk_bu dev_kfree_skb_any(skb); #ifdef HP100_DEBUG_TX - printk("hp100: %s: start_xmit: end\n", dev->name); + printk(KERN_DEBUG "hp100: %s: start_xmit: end\n", dev->name); #endif return 0; @@ -1768,7 +1768,7 @@ static void hp100_rx(struct net_device * #ifdef DEBUG_B hp100_outw(0x4213, TRACE); - printk("hp100: %s: rx\n", dev->name); + printk(KERN_DEBUG "hp100: %s: rx\n", dev->name); #endif /* First get indication of received lan packet */ @@ -1777,7 +1777,7 @@ static void hp100_rx(struct net_device * packets = hp100_inb(RX_PKT_CNT); #ifdef HP100_DEBUG_RX if (packets > 1) - printk("hp100: %s: rx: waiting packets = %d\n", dev->name, packets); + printk(KERN_DEBUG "hp100: %s: rx: waiting packets = %d\n", dev->name, packets); #endif while (packets-- > 0) { @@ -1785,7 +1785,7 @@ static void hp100_rx(struct net_device * /* really advanced to the next packet. */ for (pkt_len = 0; pkt_len < 6000 && (hp100_inb(OPTION_MSW) & HP100_ADV_NXT_PKT); pkt_len++) { #ifdef HP100_DEBUG_RX - printk ("hp100: %s: rx: busy, remaining packets = %d\n", dev->name, packets); + printk (KERN_DEBUG "hp100: %s: rx: busy, remaining packets = %d\n", dev->name, packets); #endif } @@ -1799,7 +1799,7 @@ static void hp100_rx(struct net_device * pkt_len = ((header & HP100_PKT_LEN_MASK) + 3) & ~3; #ifdef HP100_DEBUG_RX - printk("hp100: %s: rx: new packet - length=%d, errors=0x%x, dest=0x%x\n", + printk(KERN_DEBUG "hp100: %s: rx: new packet - length=%d, errors=0x%x, dest=0x%x\n", dev->name, header & HP100_PKT_LEN_MASK, (header >> 16) & 0xfff8, (header >> 16) & 7); #endif @@ -1808,7 +1808,7 @@ static void hp100_rx(struct net_device * skb = dev_alloc_skb(pkt_len+2); if (skb == NULL) { /* Not enough memory->drop packet */ #ifdef HP100_DEBUG - printk("hp100: %s: rx: couldn't allocate a sk_buff of size %d\n", + printk(KERN_DEBUG "hp100: %s: rx: couldn't allocate a sk_buff of size %d\n", dev->name, pkt_len); #endif lp->stats.rx_dropped++; @@ -1832,7 +1832,7 @@ static void hp100_rx(struct net_device * skb->protocol = eth_type_trans(skb, dev); #ifdef HP100_DEBUG_RX - printk("hp100: %s: rx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", + printk(KERN_DEBUG "hp100: %s: rx: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", dev->name, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], ptr[8], ptr[9], ptr[10], ptr[11]); @@ -1854,7 +1854,7 @@ static void hp100_rx(struct net_device * } } /* end of while(there are packets) loop */ #ifdef HP100_DEBUG_RX - printk("hp100_rx: %s: end\n", dev->name); + printk(KERN_DEBUG "hp100_rx: %s: end\n", dev->name); #endif } @@ -1871,18 +1871,18 @@ static void hp100_rx_bm(struct net_devic #ifdef HP100_DEBUG_B hp100_outw(0x4214, TRACE); - printk("hp100: %s: rx_bm\n", dev->name); + printk(KERN_DEBUG "hp100: %s: rx_bm\n", dev->name); #endif #ifdef HP100_DEBUG if (0 == lp->rxrcommit) { - printk("hp100: %s: rx_bm called although no PDLs were committed to adapter?\n", dev->name); + printk(KERN_DEBUG "hp100: %s: rx_bm called although no PDLs were committed to adapter?\n", dev->name); return; } else /* RX_PKT_CNT states how many PDLs are currently formatted and available to * the cards BM engine */ if ((hp100_inw(RX_PKT_CNT) & 0x00ff) >= lp->rxrcommit) { - printk("hp100: %s: More packets received than commited? RX_PKT_CNT=0x%x, commit=0x%x\n", + printk(KERN_DEBUG "hp100: %s: More packets received than commited? RX_PKT_CNT=0x%x, commit=0x%x\n", dev->name, hp100_inw(RX_PKT_CNT) & 0x00ff, lp->rxrcommit); return; @@ -1907,10 +1907,10 @@ static void hp100_rx_bm(struct net_devic pci_unmap_single(lp->pci_dev, (dma_addr_t) ptr->pdl[3], MAX_ETHER_SIZE, PCI_DMA_FROMDEVICE); #ifdef HP100_DEBUG_BM - printk("hp100: %s: rx_bm: header@0x%x=0x%x length=%d, errors=0x%x, dest=0x%x\n", + printk(KERN_DEBUG "hp100: %s: rx_bm: header@0x%x=0x%x length=%d, errors=0x%x, dest=0x%x\n", dev->name, (u_int) (ptr->pdl - 1), (u_int) header, pkt_len, (header >> 16) & 0xfff8, (header >> 16) & 7); - printk("hp100: %s: RX_PDL_COUNT:0x%x TX_PDL_COUNT:0x%x, RX_PKT_CNT=0x%x PDH=0x%x, Data@0x%x len=0x%x\n", + printk(KERN_DEBUG "hp100: %s: RX_PDL_COUNT:0x%x TX_PDL_COUNT:0x%x, RX_PKT_CNT=0x%x PDH=0x%x, Data@0x%x len=0x%x\n", dev->name, hp100_inb(RX_PDL), hp100_inb(TX_PDL), hp100_inb(RX_PKT_CNT), (u_int) * (ptr->pdl), (u_int) * (ptr->pdl + 3), (u_int) * (ptr->pdl + 4)); @@ -1919,7 +1919,7 @@ static void hp100_rx_bm(struct net_devic if ((pkt_len >= MIN_ETHER_SIZE) && (pkt_len <= MAX_ETHER_SIZE)) { if (ptr->skb == NULL) { - printk("hp100: %s: rx_bm: skb null\n", dev->name); + printk(KERN_DEBUG "hp100: %s: rx_bm: skb null\n", dev->name); /* can happen if we only allocated room for the pdh due to memory shortage. */ lp->stats.rx_dropped++; } else { @@ -1942,7 +1942,7 @@ static void hp100_rx_bm(struct net_devic } } else { #ifdef HP100_DEBUG - printk("hp100: %s: rx_bm: Received bad packet (length=%d)\n", dev->name, pkt_len); + printk(KERN_DEBUG "hp100: %s: rx_bm: Received bad packet (length=%d)\n", dev->name, pkt_len); #endif if (ptr->skb != NULL) dev_kfree_skb_any(ptr->skb); @@ -1955,7 +1955,7 @@ static void hp100_rx_bm(struct net_devic if (0 == hp100_build_rx_pdl(lp->rxrtail, dev)) { /* No space for skb, header can still be received. */ #ifdef HP100_DEBUG - printk("hp100: %s: rx_bm: No space for new PDL.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: rx_bm: No space for new PDL.\n", dev->name); #endif return; } else { /* successfully allocated new PDL - put it in ringlist at tail. */ @@ -1995,7 +1995,7 @@ static void hp100_update_stats(struct ne #ifdef HP100_DEBUG_B hp100_outw(0x4216, TRACE); - printk("hp100: %s: update-stats\n", dev->name); + printk(KERN_DEBUG "hp100: %s: update-stats\n", dev->name); #endif /* Note: Statistics counters clear when read. */ @@ -2022,7 +2022,7 @@ static void hp100_misc_interrupt(struct #ifdef HP100_DEBUG_B int ioaddr = dev->base_addr; hp100_outw(0x4216, TRACE); - printk("hp100: %s: misc_interrupt\n", dev->name); + printk(KERN_DEBUG "hp100: %s: misc_interrupt\n", dev->name); #endif /* Note: Statistics counters clear when read. */ @@ -2036,7 +2036,7 @@ static void hp100_clear_stats(struct hp1 #ifdef HP100_DEBUG_B hp100_outw(0x4217, TRACE); - printk("hp100: %s: clear_stats\n", dev->name); + printk(KERN_DEBUG "hp100: %s: clear_stats\n", dev->name); #endif spin_lock_irqsave(&lp->lock, flags); @@ -2065,7 +2065,7 @@ static void hp100_set_multicast_list(str #ifdef HP100_DEBUG_B hp100_outw(0x4218, TRACE); - printk("hp100: %s: set_mc_list\n", dev->name); + printk(KERN_DEBUG "hp100: %s: set_mc_list\n", dev->name); #endif spin_lock_irqsave(&lp->lock, flags); @@ -2091,13 +2091,13 @@ static void hp100_set_multicast_list(str memset(&lp->hash_bytes, 0x00, 8); #ifdef HP100_DEBUG - printk("hp100: %s: computing hash filter - mc_count = %i\n", dev->name, dev->mc_count); + printk(KERN_DEBUG "hp100: %s: computing hash filter - mc_count = %i\n", dev->name, dev->mc_count); #endif for (i = 0, dmi = dev->mc_list; i < dev->mc_count; i++, dmi = dmi->next) { addrs = dmi->dmi_addr; if ((*addrs & 0x01) == 0x01) { /* multicast address? */ #ifdef HP100_DEBUG - printk("hp100: %s: multicast = %02x:%02x:%02x:%02x:%02x:%02x, ", + printk(KERN_DEBUG "hp100: %s: multicast = %02x:%02x:%02x:%02x:%02x:%02x, ", dev->name, addrs[0], addrs[1], addrs[2], addrs[3], addrs[4], addrs[5]); #endif @@ -2106,7 +2106,7 @@ static void hp100_set_multicast_list(str printk(":%02x:", idx); } #ifdef HP100_DEBUG - printk("idx = %i\n", idx); + printk(KERN_DEBUG "idx = %i\n", idx); #endif lp->hash_bytes[idx >> 3] |= (1 << (idx & 7)); } @@ -2133,7 +2133,7 @@ static void hp100_set_multicast_list(str for (i = 0; i < 8; i++) hp100_outb(lp->hash_bytes[i], HASH_BYTE0 + i); #ifdef HP100_DEBUG - printk("hp100: %s: mac1 = 0x%x, mac2 = 0x%x, multicast hash = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", + printk(KERN_DEBUG "hp100: %s: mac1 = 0x%x, mac2 = 0x%x, multicast hash = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, lp->mac1_mode, lp->mac2_mode, lp->hash_bytes[0], lp->hash_bytes[1], lp->hash_bytes[2], lp->hash_bytes[3], @@ -2143,7 +2143,7 @@ static void hp100_set_multicast_list(str if (lp->lan_type == HP100_LAN_100) { #ifdef HP100_DEBUG - printk("hp100: %s: 100VG MAC settings have changed - relogin.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: 100VG MAC settings have changed - relogin.\n", dev->name); #endif lp->hub_status = hp100_login_to_vg_hub(dev, 1); /* force a relogin to the hub */ } @@ -2158,7 +2158,7 @@ static void hp100_set_multicast_list(str for (i = 0; i < 8; i++) hp100_outb(lp->hash_bytes[i], HASH_BYTE0 + i); #ifdef HP100_DEBUG - printk("hp100: %s: multicast hash = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", + printk(KERN_DEBUG "hp100: %s: multicast hash = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, lp->hash_bytes[0], lp->hash_bytes[1], lp->hash_bytes[2], lp->hash_bytes[3], lp->hash_bytes[4], @@ -2168,7 +2168,7 @@ static void hp100_set_multicast_list(str if (lp->lan_type == HP100_LAN_100) { #ifdef HP100_DEBUG - printk("hp100: %s: 100VG MAC settings have changed - relogin.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: 100VG MAC settings have changed - relogin.\n", dev->name); #endif lp->hub_status = hp100_login_to_vg_hub(dev, 1); /* force a relogin to the hub */ } @@ -2211,7 +2211,7 @@ static irqreturn_t hp100_interrupt(int i /* hp100_page( PERFORMANCE ); */ val = hp100_inw(IRQ_STATUS); #ifdef HP100_DEBUG_IRQ - printk("hp100: %s: mode=%x,IRQ_STAT=0x%.4x,RXPKTCNT=0x%.2x RXPDL=0x%.2x TXPKTCNT=0x%.2x TXPDL=0x%.2x\n", + printk(KERN_DEBUG "hp100: %s: mode=%x,IRQ_STAT=0x%.4x,RXPKTCNT=0x%.2x RXPDL=0x%.2x TXPKTCNT=0x%.2x TXPDL=0x%.2x\n", dev->name, lp->mode, (u_int) val, hp100_inb(RX_PKT_CNT), hp100_inb(RX_PDL), hp100_inb(TX_PKT_CNT), hp100_inb(TX_PDL)); #endif @@ -2233,7 +2233,7 @@ static irqreturn_t hp100_interrupt(int i if (lp->mode == 1) hp100_rx_bm(dev); else { - printk("hp100: %s: rx_pdl_fill_compl interrupt although not busmaster?\n", dev->name); + printk(KERN_INFO "hp100: %s: rx_pdl_fill_compl interrupt although not busmaster?\n", dev->name); } } @@ -2270,7 +2270,7 @@ static irqreturn_t hp100_interrupt(int i */ if (val & (HP100_TX_ERROR | HP100_RX_ERROR)) { #ifdef HP100_DEBUG_IRQ - printk("hp100: %s: TX/RX Error IRQ\n", dev->name); + printk(KERN_DEBUG "hp100: %s: TX/RX Error IRQ\n", dev->name); #endif hp100_update_stats(dev); if (lp->mode == 1) { @@ -2299,7 +2299,7 @@ static irqreturn_t hp100_interrupt(int i if (val & HP100_MISC_ERROR) { /* New for J2585B */ #ifdef HP100_DEBUG_IRQ printk - ("hp100: %s: Misc. Error Interrupt - Check cabling.\n", + (KERN_DEBUG "hp100: %s: Misc. Error Interrupt - Check cabling.\n", dev->name); #endif if (lp->mode == 1) { @@ -2326,7 +2326,7 @@ static void hp100_start_interface(struct #ifdef HP100_DEBUG_B hp100_outw(0x4220, TRACE); - printk("hp100: %s: hp100_start_interface\n", dev->name); + printk(KERN_DEBUG "hp100: %s: hp100_start_interface\n", dev->name); #endif spin_lock_irqsave(&lp->lock, flags); @@ -2386,7 +2386,7 @@ static void hp100_stop_interface(struct u_int val; #ifdef HP100_DEBUG_B - printk("hp100: %s: hp100_stop_interface\n", dev->name); + printk(KERN_DEBUG "hp100: %s: hp100_stop_interface\n", dev->name); hp100_outw(0x4221, TRACE); #endif @@ -2410,7 +2410,7 @@ static void hp100_stop_interface(struct hp100_page(PERFORMANCE); return; } - printk("hp100: %s: hp100_stop_interface - timeout\n", dev->name); + printk(KERN_INFO "hp100: %s: hp100_stop_interface - timeout\n", dev->name); hp100_page(PERFORMANCE); } } @@ -2430,7 +2430,7 @@ static void hp100_load_eeprom(struct net for (i = 0; i < 10000; i++) if (!(hp100_inb(OPTION_MSW) & HP100_EE_LOAD)) return; - printk("hp100: %s: hp100_load_eeprom - timeout\n", dev->name); + printk(KERN_INFO "hp100: %s: hp100_load_eeprom - timeout\n", dev->name); } /* Sense connection status. @@ -2453,7 +2453,7 @@ static int hp100_sense_lan(struct net_de val_VG = hp100_inb(VG_LAN_CFG_1); hp100_page(PERFORMANCE); #ifdef HP100_DEBUG - printk("hp100: %s: sense_lan: val_VG = 0x%04x, val_10 = 0x%04x\n", + printk(KERN_DEBUG "hp100: %s: sense_lan: val_VG = 0x%04x, val_10 = 0x%04x\n", dev->name, val_VG, val_10); #endif @@ -2495,7 +2495,7 @@ static int hp100_down_vg_link(struct net #ifdef HP100_DEBUG_B hp100_outw(0x4224, TRACE); - printk("hp100: %s: down_vg_link\n", dev->name); + printk(KERN_DEBUG "hp100: %s: down_vg_link\n", dev->name); #endif hp100_page(MAC_CTRL); @@ -2526,7 +2526,7 @@ static int hp100_down_vg_link(struct net #ifdef HP100_DEBUG if (time_after_eq(jiffies, time)) - printk("hp100: %s: down_vg_link: Link does not go down?\n", dev->name); + printk(KERN_DEBUG "hp100: %s: down_vg_link: Link does not go down?\n", dev->name); #endif /* To prevent condition where Rev 1 VG MAC and old hubs do not complete */ @@ -2577,7 +2577,7 @@ static int hp100_down_vg_link(struct net if (time_before_eq(time, jiffies)) { #ifdef HP100_DEBUG - printk("hp100: %s: down_vg_link: timeout\n", dev->name); + printk(KERN_DEBUG "hp100: %s: down_vg_link: timeout\n", dev->name); #endif return -EIO; } @@ -2601,7 +2601,7 @@ static int hp100_login_to_vg_hub(struct #ifdef HP100_DEBUG_B hp100_outw(0x4225, TRACE); - printk("hp100: %s: login_to_vg_hub\n", dev->name); + printk(KERN_DEBUG "hp100: %s: login_to_vg_hub\n", dev->name); #endif /* Initiate a login sequence iff VG MAC is enabled and either Load Address @@ -2612,7 +2612,7 @@ static int hp100_login_to_vg_hub(struct startst = hp100_inb(VG_LAN_CFG_1); if ((force_relogin == 1) || (hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST)) { #ifdef HP100_DEBUG_TRAINING - printk("hp100: %s: Start training\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Start training\n", dev->name); #endif /* Ensure VG Reset bit is 1 (i.e., do not reset) */ @@ -2627,7 +2627,7 @@ static int hp100_login_to_vg_hub(struct hp100_andb(~(HP100_LINK_CMD /* |HP100_LOAD_ADDR */ ), VG_LAN_CFG_1); #ifdef HP100_DEBUG_TRAINING - printk("hp100: %s: Bring down the link\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Bring down the link\n", dev->name); #endif /* Wait for link to drop */ @@ -2677,12 +2677,12 @@ static int hp100_login_to_vg_hub(struct if (time_after_eq(jiffies, time)) { #ifdef HP100_DEBUG_TRAINING - printk("hp100: %s: Link cable status not ok? Training aborted.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Link cable status not ok? Training aborted.\n", dev->name); #endif } else { #ifdef HP100_DEBUG_TRAINING printk - ("hp100: %s: HUB tones detected. Trying to train.\n", + (KERN_DEBUG "hp100: %s: HUB tones detected. Trying to train.\n", dev->name); #endif @@ -2691,7 +2691,7 @@ static int hp100_login_to_vg_hub(struct val = hp100_inb(VG_LAN_CFG_1); if ((val & (HP100_LINK_UP_ST))) { #ifdef HP100_DEBUG_TRAINING - printk("hp100: %s: Passed training.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Passed training.\n", dev->name); #endif break; } @@ -2703,30 +2703,30 @@ static int hp100_login_to_vg_hub(struct /* If LINK_UP_ST is set, then we are logged into the hub. */ if (time_before_eq(jiffies, time) && (val & HP100_LINK_UP_ST)) { #ifdef HP100_DEBUG_TRAINING - printk("hp100: %s: Successfully logged into the HUB.\n", dev->name); + printk(KERN_DEBUG "hp100: %s: Successfully logged into the HUB.\n", dev->name); if (lp->chip == HP100_CHIPID_LASSEN) { val = hp100_inw(TRAIN_ALLOW); - printk("hp100: %s: Card supports 100VG MAC Version \"%s\" ", + printk(KERN_DEBUG "hp100: %s: Card supports 100VG MAC Version \"%s\" ", dev->name, (hp100_inw(TRAIN_REQUEST) & HP100_CARD_MACVER) ? "802.12" : "Pre"); printk("Driver will use MAC Version \"%s\"\n", (val & HP100_HUB_MACVER) ? "802.12" : "Pre"); - printk("hp100: %s: Frame format is %s.\n", dev->name, (val & HP100_MALLOW_FRAMEFMT) ? "802.5" : "802.3"); + printk(KERN_DEBUG "hp100: %s: Frame format is %s.\n", dev->name, (val & HP100_MALLOW_FRAMEFMT) ? "802.5" : "802.3"); } #endif } else { /* If LINK_UP_ST is not set, login was not successful */ - printk("hp100: %s: Problem logging into the HUB.\n", dev->name); + printk(KERN_INFO "hp100: %s: Problem logging into the HUB.\n", dev->name); if (lp->chip == HP100_CHIPID_LASSEN) { /* Check allowed Register to find out why there is a problem. */ val = hp100_inw(TRAIN_ALLOW); /* won't work on non-ETR card */ #ifdef HP100_DEBUG_TRAINING - printk("hp100: %s: MAC Configuration requested: 0x%04x, HUB allowed: 0x%04x\n", dev->name, hp100_inw(TRAIN_REQUEST), val); + printk(KERN_DEBUG "hp100: %s: MAC Configuration requested: 0x%04x, HUB allowed: 0x%04x\n", dev->name, hp100_inw(TRAIN_REQUEST), val); #endif if (val & HP100_MALLOW_ACCDENIED) - printk("hp100: %s: HUB access denied.\n", dev->name); + printk(KERN_INFO "hp100: %s: HUB access denied.\n", dev->name); if (val & HP100_MALLOW_CONFIGURE) - printk("hp100: %s: MAC Configuration is incompatible with the Network.\n", dev->name); + printk(KERN_INFO "hp100: %s: MAC Configuration is incompatible with the Network.\n", dev->name); if (val & HP100_MALLOW_DUPADDR) - printk("hp100: %s: Duplicate MAC Address on the Network.\n", dev->name); + printk(KERN_INFO "hp100: %s: Duplicate MAC Address on the Network.\n", dev->name); } } @@ -2747,7 +2747,7 @@ static int hp100_login_to_vg_hub(struct if (val & HP100_LINK_UP_ST) return (0); /* login was ok */ else { - printk("hp100: %s: Training failed.\n", dev->name); + printk(KERN_INFO "hp100: %s: Training failed.\n", dev->name); hp100_down_vg_link(dev); return -EIO; } @@ -2763,7 +2763,7 @@ static void hp100_cascade_reset(struct n #ifdef HP100_DEBUG_B hp100_outw(0x4226, TRACE); - printk("hp100: %s: cascade_reset\n", dev->name); + printk(KERN_DEBUG "hp100: %s: cascade_reset\n", dev->name); #endif if (enable) { @@ -2795,21 +2795,21 @@ void hp100_RegisterDump(struct net_devic int Register; /* Dump common registers */ - printk("hp100: %s: Cascade Register Dump\n", dev->name); - printk("hardware id #1: 0x%.2x\n", hp100_inb(HW_ID)); - printk("hardware id #2/paging: 0x%.2x\n", hp100_inb(PAGING)); - printk("option #1: 0x%.4x\n", hp100_inw(OPTION_LSW)); - printk("option #2: 0x%.4x\n", hp100_inw(OPTION_MSW)); + printk(KERN_INFO "hp100: %s: Cascade Register Dump\n", dev->name); + printk(KERN_INFO "hardware id #1: 0x%.2x\n", hp100_inb(HW_ID)); + printk(KERN_INFO "hardware id #2/paging: 0x%.2x\n", hp100_inb(PAGING)); + printk(KERN_INFO "option #1: 0x%.4x\n", hp100_inw(OPTION_LSW)); + printk(KERN_INFO "option #2: 0x%.4x\n", hp100_inw(OPTION_MSW)); /* Dump paged registers */ for (Page = 0; Page < 8; Page++) { /* Dump registers */ - printk("page: 0x%.2x\n", Page); + printk(KERN_INFO "page: 0x%.2x\n", Page); outw(Page, ioaddr + 0x02); for (Register = 0x8; Register < 0x22; Register += 2) { /* Display Register contents except data port */ if (((Register != 0x10) && (Register != 0x12)) || (Page > 0)) { - printk("0x%.2x = 0x%.4x\n", Register, inw(ioaddr + Register)); + printk(KERN_INFO "0x%.2x = 0x%.4x\n", Register, inw(ioaddr + Register)); } } } @@ -2853,7 +2853,7 @@ static int __init hp100_eisa_probe (stru goto out1; #ifdef HP100_DEBUG - printk("hp100: %s: EISA adapter found at 0x%x\n", dev->name, + printk(KERN_DEBUG "hp100: %s: EISA adapter found at 0x%x\n", dev->name, dev->base_addr); #endif gendev->driver_data = dev; @@ -2904,7 +2904,7 @@ static int __devinit hp100_pci_probe (st pci_read_config_word(pdev, PCI_COMMAND, &pci_command); if (!(pci_command & PCI_COMMAND_IO)) { #ifdef HP100_DEBUG - printk("hp100: %s: PCI I/O Bit has not been set. Setting...\n", dev->name); + printk(KERN_DEBUG "hp100: %s: PCI I/O Bit has not been set. Setting...\n", dev->name); #endif pci_command |= PCI_COMMAND_IO; pci_write_config_word(pdev, PCI_COMMAND, pci_command); @@ -2912,7 +2912,7 @@ static int __devinit hp100_pci_probe (st if (!(pci_command & PCI_COMMAND_MASTER)) { #ifdef HP100_DEBUG - printk("hp100: %s: PCI Master Bit has not been set. Setting...\n", dev->name); + printk(KERN_DEBUG "hp100: %s: PCI Master Bit has not been set. Setting...\n", dev->name); #endif pci_command |= PCI_COMMAND_MASTER; pci_write_config_word(pdev, PCI_COMMAND, pci_command); @@ -2924,7 +2924,7 @@ static int __devinit hp100_pci_probe (st goto out1; #ifdef HP100_DEBUG - printk("hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr); + printk(KERN_DEBUG "hp100: %s: PCI adapter found at 0x%x\n", dev->name, ioaddr); #endif pci_set_drvdata(pdev, dev); return 0; @@ -3035,7 +3035,7 @@ static int __init hp100_module_init(void goto out2; #endif #ifdef CONFIG_PCI - err = pci_module_init(&hp100_pci_driver); + err = pci_register_driver(&hp100_pci_driver); if (err && err != -ENODEV) goto out3; #endif --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1344,10 +1344,9 @@ static inline struct irda_class_desc *ir struct irda_class_desc *desc; int ret; - desc = kmalloc(sizeof (*desc), GFP_KERNEL); + desc = kzalloc(sizeof (*desc), GFP_KERNEL); if (desc == NULL) return NULL; - memset(desc, 0, sizeof(*desc)); /* USB-IrDA class spec 1.0: * 6.1.3: Standard "Get Descriptor" Device Request is not @@ -1496,12 +1495,10 @@ static int irda_usb_probe(struct usb_int /* Don't change this buffer size and allocation without doing * some heavy and complete testing. Don't ask why :-( * Jean II */ - self->speed_buff = (char *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); + self->speed_buff = kzalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL); if (self->speed_buff == NULL) goto err_out_3; - memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU); - ret = irda_usb_open(self); if (ret) goto err_out_4; --- a/drivers/net/irda/irtty-sir.c +++ b/drivers/net/irda/irtty-sir.c @@ -505,10 +505,9 @@ static int irtty_open(struct tty_struct } /* allocate private device info block */ - priv = kmalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) goto out_put; - memset(priv, 0, sizeof(*priv)); priv->magic = IRTTY_MAGIC; priv->tty = tty; --- a/drivers/net/irda/sir_kthread.c +++ b/drivers/net/irda/sir_kthread.c @@ -140,9 +140,6 @@ static int irda_thread(void *startup) run_irda_queue(); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,35) - reparent_to_init(); -#endif complete_and_exit(&irda_rq_queue.exit, 0); /* never reached */ return 0; --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c @@ -413,10 +413,9 @@ static struct vlsi_ring *vlsi_alloc_ring if (!size || ((size-1)&size)!=0) /* must be >0 and power of 2 */ return NULL; - r = kmalloc(sizeof(*r) + size * sizeof(struct ring_descr), GFP_KERNEL); + r = kzalloc(sizeof(*r) + size * sizeof(struct ring_descr), GFP_KERNEL); if (!r) return NULL; - memset(r, 0, sizeof(*r)); r->pdev = pdev; r->dir = dir; @@ -429,7 +428,6 @@ static struct vlsi_ring *vlsi_alloc_ring for (i = 0; i < size; i++) { rd = r->rd + i; - memset(rd, 0, sizeof(*rd)); rd->hw = hwmap + i; rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA); if (rd->buf == NULL --- a/drivers/net/irda/vlsi_ir.h +++ b/drivers/net/irda/vlsi_ir.h @@ -41,39 +41,14 @@ #define PCI_CLASS_SUBCLASS_MASK 0xffff #endif -/* in recent 2.5 interrupt handlers have non-void return value */ -#ifndef IRQ_RETVAL -typedef void irqreturn_t; -#define IRQ_NONE -#define IRQ_HANDLED -#define IRQ_RETVAL(x) -#endif - /* some stuff need to check kernelversion. Not all 2.5 stuff was present * in early 2.5.x - the test is merely to separate 2.4 from 2.5 */ #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - -/* PDE() introduced in 2.5.4 */ -#ifdef CONFIG_PROC_FS -#define PDE(inode) ((inode)->u.generic_ip) -#endif - -/* irda crc16 calculation exported in 2.5.42 */ -#define irda_calc_crc16(fcs,buf,len) (GOOD_FCS) - -/* we use this for unified pci device name access */ -#define PCIDEV_NAME(pdev) ((pdev)->name) - -#else /* 2.5 or later */ - /* whatever we get from the associated struct device - bus:slot:dev.fn id */ #define PCIDEV_NAME(pdev) (pci_name(pdev)) -#endif - /* ================================================================ */ /* non-standard PCI registers */ --- a/drivers/net/iseries_veth.c +++ b/drivers/net/iseries_veth.c @@ -820,10 +820,9 @@ static int veth_init_connection(u8 rlp) || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) ) return 0; - cnx = kmalloc(sizeof(*cnx), GFP_KERNEL); + cnx = kzalloc(sizeof(*cnx), GFP_KERNEL); if (! cnx) return -ENOMEM; - memset(cnx, 0, sizeof(*cnx)); cnx->remote_lp = rlp; spin_lock_init(&cnx->lock); @@ -850,14 +849,13 @@ static int veth_init_connection(u8 rlp) if (rc != 0) return rc; - msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL); + msgs = kzalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL); if (! msgs) { veth_error("Can't allocate buffers for LPAR %d.\n", rlp); return -ENOMEM; } cnx->msgs = msgs; - memset(msgs, 0, VETH_NUMBUFFERS * sizeof(struct veth_msg)); for (i = 0; i < VETH_NUMBUFFERS; i++) { msgs[i].token = i; --- a/drivers/net/lance.c +++ b/drivers/net/lance.c @@ -532,11 +532,10 @@ static int __init lance_probe1(struct ne dev->base_addr = ioaddr; /* Make certain the data structures used by the LANCE are aligned and DMAble. */ - lp = kmalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL); + lp = kzalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL); if(lp==NULL) return -ENODEV; if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); - memset(lp, 0, sizeof(*lp)); dev->priv = lp; lp->name = chipname; lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE, --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -224,9 +224,8 @@ int __init loopback_init(void) struct net_device_stats *stats; /* Can survive without statistics */ - stats = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL); + stats = kzalloc(sizeof(struct net_device_stats), GFP_KERNEL); if (stats) { - memset(stats, 0, sizeof(struct net_device_stats)); loopback_dev.priv = stats; loopback_dev.get_stats = &get_stats; } --- a/drivers/net/mipsnet.c +++ b/drivers/net/mipsnet.c @@ -323,12 +323,11 @@ static int __init mipsnet_init_module(vo goto out; } - if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) { + if (!(pldev = kzalloc (sizeof (*pldev), GFP_KERNEL))) { err = -ENOMEM; goto out_unregister_driver; } - memset (pldev, 0, sizeof (*pldev)); pldev->name = mipsnet_string; pldev->id = 0; pldev->dev.release = mipsnet_platform_release; --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c @@ -3360,7 +3360,7 @@ static int __init natsemi_init_mod (void printk(version); #endif - return pci_module_init (&natsemi_driver); + return pci_register_driver (&natsemi_driver); } static void __exit natsemi_exit_mod (void) --- a/drivers/net/ne2k-pci.c +++ b/drivers/net/ne2k-pci.c @@ -701,7 +701,7 @@ static int __init ne2k_pci_init(void) #ifdef MODULE printk(version); #endif - return pci_module_init (&ne2k_driver); + return pci_register_driver (&ne2k_driver); } --- a/drivers/net/ns83820.c +++ b/drivers/net/ns83820.c @@ -2176,7 +2176,7 @@ static struct pci_driver driver = { static int __init ns83820_init(void) { printk(KERN_INFO "ns83820.c: National Semiconductor DP83820 10/100/1000 driver.\n"); - return pci_module_init(&driver); + return pci_register_driver(&driver); } static void __exit ns83820_exit(void) --- a/drivers/net/pci-skeleton.c +++ b/drivers/net/pci-skeleton.c @@ -1963,7 +1963,7 @@ static int __init netdrv_init_module (vo #ifdef MODULE printk(version); #endif - return pci_module_init (&netdrv_pci_driver); + return pci_register_driver (&netdrv_pci_driver); } --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -146,9 +146,8 @@ static int ibmtr_attach(struct pcmcia_de DEBUG(0, "ibmtr_attach()\n"); /* Create new token-ring device */ - info = kmalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; - memset(info,0,sizeof(*info)); dev = alloc_trdev(sizeof(struct tok_info)); if (!dev) { kfree(info); --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -998,7 +998,8 @@ static int pcnet_open(struct net_device link->open++; set_misc_reg(dev); - request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev); + if (request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev) < 0) + return -EBUSY; info->phy_id = info->eth_phy; info->link_status = 0x00; --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -1764,7 +1764,7 @@ init_mii(struct net_device *dev) local_info_t *local = netdev_priv(dev); kio_addr_t ioaddr = dev->base_addr; unsigned control, status, linkpartner; - int i; + unsigned long end_time; if (if_port == 4 || if_port == 1) { /* force 100BaseT or 10BaseT */ dev->if_port = if_port; @@ -1798,13 +1798,13 @@ init_mii(struct net_device *dev) if (local->probe_port) { /* according to the DP83840A specs the auto negotiation process * may take up to 3.5 sec, so we use this also for our ML6692 - * Fixme: Better to use a timer here! */ - for (i=0; i < 35; i++) { - msleep(100); /* wait 100 msec */ - status = mii_rd(ioaddr, 0, 1); - if ((status & 0x0020) && (status & 0x0004)) - break; + end_time = jiffies + msecs_to_jiffies(3500); + while (time_before(jiffies, end_time)) { + msleep(100); /* wait 100 msec */ + status = mii_rd(ioaddr, 0, 1); + if ((status & 0x0020) && (status & 0x0004)) + break; } if (!(status & 0x0020)) { --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c @@ -2733,7 +2733,7 @@ static int __init pcnet32_init_module(vo tx_start = tx_start_pt; /* find the PCI devices */ - if (!pci_module_init(&pcnet32_driver)) + if (!pci_register_driver(&pcnet32_driver)) pcnet32_have_pci = 1; /* should we find any remaining VLbus devices ? */ --- a/drivers/net/ppp_async.c +++ b/drivers/net/ppp_async.c @@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *tty int err; err = -ENOMEM; - ap = kmalloc(sizeof(*ap), GFP_KERNEL); + ap = kzalloc(sizeof(*ap), GFP_KERNEL); if (ap == 0) goto out; /* initialize the asyncppp structure */ - memset(ap, 0, sizeof(*ap)); ap->tty = tty; ap->mru = PPP_MRU; spin_lock_init(&ap->xmit_lock); --- a/drivers/net/ppp_deflate.c +++ b/drivers/net/ppp_deflate.c @@ -121,12 +121,10 @@ static void *z_comp_alloc(unsigned char if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) return NULL; - state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), - GFP_KERNEL); + state = kzalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) return NULL; - memset (state, 0, sizeof (struct ppp_deflate_state)); state->strm.next_in = NULL; state->w_size = w_size; state->strm.workspace = vmalloc(zlib_deflate_workspacesize()); @@ -341,11 +339,10 @@ static void *z_decomp_alloc(unsigned cha if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) return NULL; - state = (struct ppp_deflate_state *) kmalloc(sizeof(*state), GFP_KERNEL); + state = kzalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) return NULL; - memset (state, 0, sizeof (struct ppp_deflate_state)); state->w_size = w_size; state->strm.next_out = NULL; state->strm.workspace = kmalloc(zlib_inflate_workspacesize(), --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c @@ -2006,10 +2006,9 @@ ppp_register_channel(struct ppp_channel { struct channel *pch; - pch = kmalloc(sizeof(struct channel), GFP_KERNEL); + pch = kzalloc(sizeof(struct channel), GFP_KERNEL); if (pch == 0) return -ENOMEM; - memset(pch, 0, sizeof(struct channel)); pch->ppp = NULL; pch->chan = chan; chan->ppp = pch; @@ -2419,13 +2418,12 @@ ppp_create_interface(int unit, int *retp int ret = -ENOMEM; int i; - ppp = kmalloc(sizeof(struct ppp), GFP_KERNEL); + ppp = kzalloc(sizeof(struct ppp), GFP_KERNEL); if (!ppp) goto out; dev = alloc_netdev(0, "", ppp_setup); if (!dev) goto out1; - memset(ppp, 0, sizeof(struct ppp)); ppp->mru = PPP_MRU; init_ppp_file(&ppp->file, INTERFACE); @@ -2717,8 +2715,7 @@ static void cardmap_set(struct cardmap * if (p == NULL || (nr >> p->shift) >= CARDMAP_WIDTH) { do { /* need a new top level */ - struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL); - memset(np, 0, sizeof(*np)); + struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL); np->ptr[0] = p; if (p != NULL) { np->shift = p->shift + CARDMAP_ORDER; @@ -2732,8 +2729,7 @@ static void cardmap_set(struct cardmap * while (p->shift > 0) { i = (nr >> p->shift) & CARDMAP_MASK; if (p->ptr[i] == NULL) { - struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL); - memset(np, 0, sizeof(*np)); + struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL); np->shift = p->shift - CARDMAP_ORDER; np->parent = p; p->ptr[i] = np; --- a/drivers/net/ppp_mppe.c +++ b/drivers/net/ppp_mppe.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -191,12 +190,10 @@ static void *mppe_alloc(unsigned char *o || options[0] != CI_MPPE || options[1] != CILEN_MPPE) goto out; - state = (struct ppp_mppe_state *) kmalloc(sizeof(*state), GFP_KERNEL); + state = kzalloc(sizeof(*state), GFP_KERNEL); if (state == NULL) goto out; - memset(state, 0, sizeof(*state)); - state->arc4 = crypto_alloc_tfm("arc4", 0); if (!state->arc4) goto out_free; --- a/drivers/net/ppp_synctty.c +++ b/drivers/net/ppp_synctty.c @@ -207,13 +207,12 @@ ppp_sync_open(struct tty_struct *tty) struct syncppp *ap; int err; - ap = kmalloc(sizeof(*ap), GFP_KERNEL); + ap = kzalloc(sizeof(*ap), GFP_KERNEL); err = -ENOMEM; if (ap == 0) goto out; /* initialize the syncppp structure */ - memset(ap, 0, sizeof(*ap)); ap->tty = tty; ap->mru = PPP_MRU; spin_lock_init(&ap->xmit_lock); --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c @@ -2817,7 +2817,7 @@ static struct pci_driver rtl8169_pci_dri static int __init rtl8169_init_module(void) { - return pci_module_init(&rtl8169_pci_driver); + return pci_register_driver(&rtl8169_pci_driver); } static void __exit --- a/drivers/net/rrunner.c +++ b/drivers/net/rrunner.c @@ -1737,7 +1737,7 @@ static struct pci_driver rr_driver = { static int __init rr_init_module(void) { - return pci_module_init(&rr_driver); + return pci_register_driver(&rr_driver); } static void __exit rr_cleanup_module(void) --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c @@ -407,14 +407,13 @@ static int init_shared_mem(struct s2io_n for (i = 0; i < config->tx_fifo_num; i++) { int fifo_len = config->tx_cfg[i].fifo_len; int list_holder_size = fifo_len * sizeof(list_info_hold_t); - mac_control->fifos[i].list_info = kmalloc(list_holder_size, + mac_control->fifos[i].list_info = kzalloc(list_holder_size, GFP_KERNEL); if (!mac_control->fifos[i].list_info) { DBG_PRINT(ERR_DBG, "Malloc failed for list_info\n"); return -ENOMEM; } - memset(mac_control->fifos[i].list_info, 0, list_holder_size); } for (i = 0; i < config->tx_fifo_num; i++) { int page_num = TXD_MEM_PAGE_CNT(config->tx_cfg[i].fifo_len, @@ -850,13 +849,13 @@ static int init_nic(struct s2io_nic *nic struct net_device *dev = nic->dev; register u64 val64 = 0; void __iomem *add; - u32 time; int i, j; mac_info_t *mac_control; struct config_param *config; int mdio_cnt = 0, dtx_cnt = 0; unsigned long long mem_share; int mem_size; + unsigned long end_time; mac_control = &nic->mac_control; config = &nic->config; @@ -1372,19 +1371,18 @@ static int init_nic(struct s2io_nic *nic * We wait for a maximum of 500ms for the operation to complete, * if it's not complete by then we return error. */ - time = 0; + end_time = jiffies + msecs_to_jiffies(500); while (TRUE) { val64 = readq(&bar0->tti_command_mem); if (!(val64 & TTI_CMD_MEM_STROBE_NEW_CMD)) { break; } - if (time > 10) { + if (time_after(jiffies, end_time)) { DBG_PRINT(ERR_DBG, "%s: TTI init Failed\n", dev->name); return -1; } msleep(50); - time++; } if (nic->config.bimodal) { @@ -1400,19 +1398,18 @@ static int init_nic(struct s2io_nic *nic * We wait for a maximum of 500ms for the operation to complete, * if it's not complete by then we return error. */ - time = 0; + end_time = jiffies + msecs_to_jiffies(500); while (TRUE) { val64 = readq(&bar0->tti_command_mem); if (!(val64 & TTI_CMD_MEM_STROBE_NEW_CMD)) { break; } - if (time > 10) { + if (time_after(jiffies, end_time)) { DBG_PRINT(ERR_DBG, "%s: TTI init Failed\n", dev->name); return -1; } - time++; msleep(50); } } @@ -1457,18 +1454,17 @@ static int init_nic(struct s2io_nic *nic * for the operation to complete, if it's not complete * by then we return error. */ - time = 0; + end_time = jiffies + msecs_to_jiffies(500); while (TRUE) { val64 = readq(&bar0->rti_command_mem); if (!(val64 & RTI_CMD_MEM_STROBE_NEW_CMD)) { break; } - if (time > 10) { + if (time_after(jiffies, end_time)) { DBG_PRINT(ERR_DBG, "%s: RTI init Failed\n", dev->name); return -1; } - time++; msleep(50); } } @@ -2867,8 +2863,9 @@ static void alarm_intr_handler(struct s2 static int wait_for_cmd_complete(nic_t * sp) { XENA_dev_config_t __iomem *bar0 = sp->bar0; - int ret = FAILURE, cnt = 0; + int ret = FAILURE; u64 val64; + unsigned long end_time = jiffies + msecs_to_jiffies(500); while (TRUE) { val64 = readq(&bar0->rmac_addr_cmd_mem); @@ -2877,7 +2874,7 @@ static int wait_for_cmd_complete(nic_t * break; } msleep(50); - if (cnt++ > 10) + if (time_after(jiffies, end_time)) break; } @@ -3229,24 +3226,21 @@ static int s2io_enable_msi_x(nic_t *nic) u16 msi_control; /* Temp variable */ int ret, i, j, msix_indx = 1; - nic->entries = kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), + nic->entries = kzalloc(MAX_REQUESTED_MSI_X * sizeof(struct msix_entry), GFP_KERNEL); if (nic->entries == NULL) { DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__); return -ENOMEM; } - memset(nic->entries, 0, MAX_REQUESTED_MSI_X * sizeof(struct msix_entry)); nic->s2io_entries = - kmalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), + kzalloc(MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry), GFP_KERNEL); if (nic->s2io_entries == NULL) { DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", __FUNCTION__); kfree(nic->entries); return -ENOMEM; } - memset(nic->s2io_entries, 0, - MAX_REQUESTED_MSI_X * sizeof(struct s2io_msix_entry)); for (i=0; i< MAX_REQUESTED_MSI_X; i++) { nic->entries[i].entry = i; @@ -4892,13 +4886,15 @@ static int s2io_eeprom_test(nic_t * sp, static int s2io_bist_test(nic_t * sp, uint64_t * data) { u8 bist = 0; - int cnt = 0, ret = -1; + int ret = -1; + unsigned long end_time; pci_read_config_byte(sp->pdev, PCI_BIST, &bist); bist |= PCI_BIST_START; pci_write_config_word(sp->pdev, PCI_BIST, bist); - while (cnt < 20) { + end_time = jiffies + msecs_to_jiffies(2000); + while (time_before(jiffies, end_time)) { pci_read_config_byte(sp->pdev, PCI_BIST, &bist); if (!(bist & PCI_BIST_START)) { *data = (bist & PCI_BIST_CODE_MASK); @@ -4906,7 +4902,6 @@ static int s2io_bist_test(nic_t * sp, ui break; } msleep(100); - cnt++; } return ret; @@ -4954,7 +4949,8 @@ static int s2io_rldram_test(nic_t * sp, { XENA_dev_config_t __iomem *bar0 = sp->bar0; u64 val64; - int cnt, iteration = 0, test_fail = 0; + int iteration = 0, test_fail = 0; + unsigned long end_time; val64 = readq(&bar0->adapter_control); val64 &= ~ADAPTER_ECC_EN; @@ -4997,27 +4993,29 @@ static int s2io_rldram_test(nic_t * sp, MC_RLDRAM_TEST_GO; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF); - for (cnt = 0; cnt < 5; cnt++) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time)) { val64 = readq(&bar0->mc_rldram_test_ctrl); if (val64 & MC_RLDRAM_TEST_DONE) break; msleep(200); } - if (cnt == 5) + if (time_after_eq(jiffies, end_time)) break; val64 = MC_RLDRAM_TEST_MODE | MC_RLDRAM_TEST_GO; SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_test_ctrl, LF); - for (cnt = 0; cnt < 5; cnt++) { + end_time = jiffies + msecs_to_jiffies(2500); + while (time_before(jiffies, end_time)) { val64 = readq(&bar0->mc_rldram_test_ctrl); if (val64 & MC_RLDRAM_TEST_DONE) break; msleep(500); } - if (cnt == 5) + if (time_after_eq(jiffies, end_time)) break; val64 = readq(&bar0->mc_rldram_test_ctrl); @@ -5491,10 +5489,10 @@ static void s2io_set_link(unsigned long static void s2io_card_down(nic_t * sp) { - int cnt = 0; XENA_dev_config_t __iomem *bar0 = sp->bar0; unsigned long flags; register u64 val64 = 0; + unsigned long end_time; del_timer_sync(&sp->alarm_timer); /* If s2io_set_link task is executing, wait till it completes. */ @@ -5510,6 +5508,7 @@ static void s2io_card_down(nic_t * sp) tasklet_kill(&sp->task); /* Check if the device is Quiescent and then Reset the NIC */ + end_time = jiffies + msecs_to_jiffies(500); do { val64 = readq(&bar0->adapter_status); if (verify_xena_quiescence(sp, val64, sp->device_enabled_once)) { @@ -5517,8 +5516,7 @@ static void s2io_card_down(nic_t * sp) } msleep(50); - cnt++; - if (cnt == 10) { + if (time_after(jiffies, end_time)) { DBG_PRINT(ERR_DBG, "s2io_close:Device not Quiescent "); DBG_PRINT(ERR_DBG, "adaper status reads 0x%llx\n", @@ -5529,13 +5527,12 @@ static void s2io_card_down(nic_t * sp) s2io_reset(sp); /* Waiting till all Interrupt handlers are complete */ - cnt = 0; - do { + end_time = jiffies + msecs_to_jiffies(50); + while (time_before(jiffies, end_time)) { msleep(10); if (!atomic_read(&sp->isr_cnt)) break; - cnt++; - } while(cnt < 5); + } spin_lock_irqsave(&sp->tx_lock, flags); /* Free all Tx buffers */ @@ -6486,7 +6483,7 @@ static void __devexit s2io_rem_nic(struc int __init s2io_starter(void) { - return pci_module_init(&s2io_driver); + return pci_register_driver(&s2io_driver); } /** --- a/drivers/net/saa9730.c +++ b/drivers/net/saa9730.c @@ -1131,7 +1131,7 @@ static struct pci_driver saa9730_driver static int __init saa9730_init(void) { - return pci_module_init(&saa9730_driver); + return pci_register_driver(&saa9730_driver); } static void __exit saa9730_cleanup(void) --- a/drivers/net/sb1250-mac.c +++ b/drivers/net/sb1250-mac.c @@ -757,9 +757,8 @@ static void sbdma_initctx(sbmacdma_t *d, */ d->sbdma_ctxtable = (struct sk_buff **) - kmalloc(d->sbdma_maxdescr*sizeof(struct sk_buff *), GFP_KERNEL); - - memset(d->sbdma_ctxtable,0,d->sbdma_maxdescr*sizeof(struct sk_buff *)); + kcalloc(d->sbdma_maxdescr, sizeof(struct sk_buff *), + GFP_KERNEL); #ifdef CONFIG_SBMAC_COALESCE /* --- a/drivers/net/shaper.c +++ b/drivers/net/shaper.c @@ -601,10 +601,9 @@ static int __init shaper_init(void) return -ENODEV; alloc_size = sizeof(*dev) * shapers; - devs = kmalloc(alloc_size, GFP_KERNEL); + devs = kzalloc(alloc_size, GFP_KERNEL); if (!devs) return -ENOMEM; - memset(devs, 0, alloc_size); for (i = 0; i < shapers; i++) { --- a/drivers/net/sis190.c +++ b/drivers/net/sis190.c @@ -370,19 +370,20 @@ static const int multicast_filter_limit static void __mdio_cmd(void __iomem *ioaddr, u32 ctl) { - unsigned int i; + unsigned long end_time; SIS_W32(GMIIControl, ctl); msleep(1); - for (i = 0; i < 100; i++) { + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { if (!(SIS_R32(GMIIControl) & EhnMIInotDone)) break; msleep(1); } - if (i > 999) + if (time_after_eq(jiffies, end_time)) printk(KERN_ERR PFX "PHY command failed !\n"); } @@ -424,14 +425,15 @@ static u16 mdio_read_latched(void __iome static u16 __devinit sis190_read_eeprom(void __iomem *ioaddr, u32 reg) { u16 data = 0xffff; - unsigned int i; + unsigned long end_time; if (!(SIS_R32(ROMControl) & 0x0002)) return 0; SIS_W32(ROMInterface, EEREQ | EEROP | (reg << 10)); - for (i = 0; i < 200; i++) { + end_time = jiffies + msecs_to_jiffies(200); + while (time_before(jiffies, end_time)) { if (!(SIS_R32(ROMInterface) & EEREQ)) { data = (SIS_R32(ROMInterface) & 0xffff0000) >> 16; break; --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c @@ -2480,7 +2480,7 @@ static int __init sis900_init_module(voi printk(version); #endif - return pci_module_init(&sis900_pci_driver); + return pci_register_driver(&sis900_pci_driver); } static void __exit sis900_cleanup_module(void) --- a/drivers/net/skfp/skfddi.c +++ b/drivers/net/skfp/skfddi.c @@ -2280,7 +2280,7 @@ static struct pci_driver skfddi_pci_driv static int __init skfd_init(void) { - return pci_module_init(&skfddi_pci_driver); + return pci_register_driver(&skfddi_pci_driver); } static void __exit skfd_exit(void) --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -669,21 +669,21 @@ static void skge_led(struct skge_port *s static int skge_phys_id(struct net_device *dev, u32 data) { struct skge_port *skge = netdev_priv(dev); - unsigned long ms; + unsigned long end_time; enum led_mode mode = LED_MODE_TST; if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) - ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000; + end_time = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT / HZ) * 1000; else - ms = data * 1000; + end_time = data * 1000; - while (ms > 0) { + end_time = jiffies + msecs_to_jiffies(end_time); + while (time_before(jiffies, end_time)) { skge_led(skge, mode); mode ^= LED_MODE_TST; if (msleep_interruptible(BLINK_MS)) break; - ms -= BLINK_MS; } /* back to regular LED state */ --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include --- a/drivers/net/slhc.c +++ b/drivers/net/slhc.c @@ -95,27 +95,23 @@ slhc_init(int rslots, int tslots) register struct cstate *ts; struct slcompress *comp; - comp = (struct slcompress *)kmalloc(sizeof(struct slcompress), - GFP_KERNEL); + comp = kzalloc(sizeof(struct slcompress), GFP_KERNEL); if (! comp) goto out_fail; - memset(comp, 0, sizeof(struct slcompress)); if ( rslots > 0 && rslots < 256 ) { size_t rsize = rslots * sizeof(struct cstate); - comp->rstate = (struct cstate *) kmalloc(rsize, GFP_KERNEL); + comp->rstate = kzalloc(rsize, GFP_KERNEL); if (! comp->rstate) goto out_free; - memset(comp->rstate, 0, rsize); comp->rslot_limit = rslots - 1; } if ( tslots > 0 && tslots < 256 ) { size_t tsize = tslots * sizeof(struct cstate); - comp->tstate = (struct cstate *) kmalloc(tsize, GFP_KERNEL); + comp->tstate = kzalloc(tsize, GFP_KERNEL); if (! comp->tstate) goto out_free2; - memset(comp->tstate, 0, tsize); comp->tslot_limit = tslots - 1; } --- a/drivers/net/starfire.c +++ b/drivers/net/starfire.c @@ -2172,7 +2172,7 @@ static int __init starfire_init (void) return -ENODEV; } - return pci_module_init (&starfire_driver); + return pci_register_driver (&starfire_driver); } --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c @@ -1810,7 +1810,7 @@ static int __init sundance_init(void) #ifdef MODULE printk(version); #endif - return pci_module_init(&sundance_driver); + return pci_register_driver(&sundance_driver); } static void __exit sundance_exit(void) --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c @@ -3191,7 +3191,7 @@ static struct pci_driver gem_driver = { static int __init gem_init(void) { - return pci_module_init(&gem_driver); + return pci_register_driver(&gem_driver); } static void __exit gem_cleanup(void) --- a/drivers/net/tc35815.c +++ b/drivers/net/tc35815.c @@ -1725,7 +1725,7 @@ static struct pci_driver tc35815_driver static int __init tc35815_init_module(void) { - return pci_module_init(&tc35815_driver); + return pci_register_driver(&tc35815_driver); } static void __exit tc35815_cleanup_module(void) --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -6577,7 +6577,8 @@ static int tg3_request_irq(struct tg3 *t static int tg3_test_interrupt(struct tg3 *tp) { struct net_device *dev = tp->dev; - int err, i; + int err; + unsigned long end_time; u32 int_mbox = 0; if (!netif_running(dev)) @@ -6598,7 +6599,8 @@ static int tg3_test_interrupt(struct tg3 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW); - for (i = 0; i < 5; i++) { + end_time = jiffies + msecs_to_jiffies(50); + while (time_before(jiffies, end_time)) { int_mbox = tr32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); if (int_mbox != 0) @@ -11612,7 +11614,7 @@ static struct pci_driver tg3_driver = { static int __init tg3_init(void) { - return pci_module_init(&tg3_driver); + return pci_register_driver(&tg3_driver); } static void __exit tg3_cleanup(void) --- a/drivers/net/tokenring/3c359.c +++ b/drivers/net/tokenring/3c359.c @@ -1816,7 +1816,7 @@ static struct pci_driver xl_3c359_driver static int __init xl_pci_init (void) { - return pci_module_init (&xl_3c359_driver); + return pci_register_driver (&xl_3c359_driver); } --- a/drivers/net/tokenring/ibmtr.c +++ b/drivers/net/tokenring/ibmtr.c @@ -108,6 +108,7 @@ in the event that chatty debug messages #define IBMTR_DEBUG_MESSAGES 0 #include +#include #ifdef PCMCIA /* required for ibmtr_cs.c to build */ #undef MODULE /* yes, really */ @@ -842,6 +843,7 @@ static int __devinit trdev_init(struct n static int tok_init_card(struct net_device *dev) { + DEFINE_WAIT(wait); struct tok_info *ti; short PIOaddr; unsigned long i; @@ -862,13 +864,16 @@ static int tok_init_card(struct net_devi writeb(SRPR_ENABLE_PAGING,ti->mmio+ACA_OFFSET+ACA_RW+SRPR_EVEN); #endif writeb(INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_SET + ISRP_EVEN); - i = sleep_on_timeout(&ti->wait_for_reset, 4 * HZ); + prepare_to_wait(&ti->wait_for_reset, &wait, TASK_UNINTERRUPTIBLE); + i = schedule_timeout(4 * HZ); + finish_wait(&ti->wait_for_reset, &wait); return i? 0 : -EAGAIN; } /*****************************************************************************/ static int tok_open(struct net_device *dev) { + DEFINE_WAIT(wait); struct tok_info *ti = (struct tok_info *) dev->priv; int i; @@ -893,7 +898,9 @@ static int tok_open(struct net_device *d while (1){ tok_open_adapter((unsigned long) dev); - i= interruptible_sleep_on_timeout(&ti->wait_for_reset, 25 * HZ); + prepare_to_wait(&ti->wait_for_reset, &wait, TASK_INTERRUPTIBLE); + i = schedule_timeout(25 * HZ); + finish_wait(&ti->wait_for_reset, &wait); /* sig catch: estimate opening adapter takes more than .5 sec*/ if (i>(245*HZ)/10) break; /* fancier than if (i==25*HZ) */ if (i==0) break; --- a/drivers/net/tokenring/lanstreamer.c +++ b/drivers/net/tokenring/lanstreamer.c @@ -123,6 +123,7 @@ #include #include #include +#include #include @@ -671,17 +672,15 @@ static int streamer_open(struct net_devi writew(LISR_SRB_CMD, streamer_mmio + LISR_SUM); spin_unlock_irqrestore(&streamer_priv->streamer_lock, flags); - while (streamer_priv->srb_queued) { - interruptible_sleep_on_timeout(&streamer_priv->srb_wait, 5 * HZ); - if (signal_pending(current)) { - printk(KERN_WARNING "%s: SRB timed out.\n", dev->name); - printk(KERN_WARNING "SISR=%x MISR=%x, LISR=%x\n", - readw(streamer_mmio + SISR), - readw(streamer_mmio + MISR_RUM), - readw(streamer_mmio + LISR)); - streamer_priv->srb_queued = 0; - break; - } + wait_event_interruptible_timeout(streamer_priv->srb_wait, + !streamer_priv->srb_queued, 5 * HZ); + if (signal_pending(current)) { + printk(KERN_WARNING "%s: SRB timed out.\n", dev->name); + printk(KERN_WARNING "SISR=%x MISR=%x, LISR=%x\n", + readw(streamer_mmio + SISR), + readw(streamer_mmio + MISR_RUM), + readw(streamer_mmio + LISR)); + streamer_priv->srb_queued = 0; } #if STREAMER_DEBUG @@ -1225,20 +1224,15 @@ static int streamer_close(struct net_dev spin_unlock_irqrestore(&streamer_priv->streamer_lock, flags); - while (streamer_priv->srb_queued) - { - interruptible_sleep_on_timeout(&streamer_priv->srb_wait, - jiffies + 60 * HZ); - if (signal_pending(current)) - { - printk(KERN_WARNING "%s: SRB timed out.\n", dev->name); - printk(KERN_WARNING "SISR=%x MISR=%x LISR=%x\n", - readw(streamer_mmio + SISR), - readw(streamer_mmio + MISR_RUM), - readw(streamer_mmio + LISR)); - streamer_priv->srb_queued = 0; - break; - } + wait_event_interruptible_timeout(streamer_priv->srb_wait, + !streamer_priv->srb_queued, 60*HZ); + if (signal_pending(current)) { + printk(KERN_WARNING "%s: SRB timed out.\n", dev->name); + printk(KERN_WARNING "SISR=%x MISR=%x LISR=%x\n", + readw(streamer_mmio + SISR), + readw(streamer_mmio + MISR_RUM), + readw(streamer_mmio + LISR)); + streamer_priv->srb_queued = 0; } streamer_priv->rx_ring_last_received = (streamer_priv->rx_ring_last_received + 1) & (STREAMER_RX_RING_SIZE - 1); @@ -1999,7 +1993,7 @@ static struct pci_driver streamer_pci_dr }; static int __init streamer_init_module(void) { - return pci_module_init(&streamer_pci_driver); + return pci_register_driver(&streamer_pci_driver); } static void __exit streamer_cleanup_module(void) { --- a/drivers/net/tokenring/olympic.c +++ b/drivers/net/tokenring/olympic.c @@ -268,11 +268,16 @@ static int __devinit olympic_probe(struc register_netdev(dev) ; printk("Olympic: %s registered as: %s\n",olympic_priv->olympic_card_name,dev->name); if (olympic_priv->olympic_network_monitor) { /* Must go after register_netdev as we need the device name */ + struct proc_dir_entry *proc_dir_entry; char proc_name[20] ; strcpy(proc_name,"net/olympic_") ; strcat(proc_name,dev->name) ; - create_proc_read_entry(proc_name,0,NULL,olympic_proc_info,(void *)dev) ; - printk("Olympic: Network Monitor information: /proc/%s\n",proc_name); + proc_dir_entry = create_proc_read_entry(proc_name,0,NULL,olympic_proc_info,dev); + + if (proc_dir_entry) + printk(KERN_INFO "Olympic: Network Monitor information: /proc/%s\n",proc_name); + else + printk(KERN_WARNING "Olympic: Network Monitor information: /proc/%s could not be created\n",proc_name); } return 0 ; @@ -1772,7 +1777,7 @@ static struct pci_driver olympic_driver static int __init olympic_pci_init(void) { - return pci_module_init (&olympic_driver) ; + return pci_register_driver (&olympic_driver); } static void __exit olympic_pci_cleanup(void) --- a/drivers/net/tulip/de2104x.c +++ b/drivers/net/tulip/de2104x.c @@ -2172,7 +2172,7 @@ static int __init de_init (void) #ifdef MODULE printk("%s", version); #endif - return pci_module_init (&de_driver); + return pci_register_driver (&de_driver); } static void __exit de_exit (void) --- a/drivers/net/tulip/de4x5.c +++ b/drivers/net/tulip/de4x5.c @@ -4810,7 +4810,8 @@ type3_infoblock(struct net_device *dev, if (lp->state == INITIALISED) { lp->ibn = 3; lp->active = *p++; - if (MOTO_SROM_BUG) lp->active = 0; + if (MOTO_SROM_BUG || lp->active >= DE4X5_MAX_PHY) + lp->active = 0; lp->phy[lp->active].gep = (*p ? p : NULL); p += (2 * (*p) + 1); lp->phy[lp->active].rst = (*p ? p : NULL); p += (2 * (*p) + 1); lp->phy[lp->active].mc = TWIDDLE(p); p += 2; @@ -5111,7 +5112,7 @@ mii_get_phy(struct net_device *dev) break; } if ((j == limit) && (i < DE4X5_MAX_MII)) { - for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY); k++); + for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY - 1); k++); lp->phy[k].addr = i; lp->phy[k].id = id; lp->phy[k].spd.reg = GENERIC_REG; /* ANLPA register */ @@ -5755,7 +5756,7 @@ static int __init de4x5_module_init (voi int err = 0; #ifdef CONFIG_PCI - err = pci_module_init (&de4x5_pci_driver); + err = pci_register_driver (&de4x5_pci_driver); #endif #ifdef CONFIG_EISA err |= eisa_driver_register (&de4x5_eisa_driver); --- a/drivers/net/tulip/dmfe.c +++ b/drivers/net/tulip/dmfe.c @@ -2039,7 +2039,7 @@ static int __init dmfe_init_module(void) if (HPNA_NoiseFloor > 15) HPNA_NoiseFloor = 0; - rc = pci_module_init(&dmfe_driver); + rc = pci_register_driver(&dmfe_driver); if (rc < 0) return rc; --- a/drivers/net/tulip/tulip_core.c +++ b/drivers/net/tulip/tulip_core.c @@ -1854,7 +1854,7 @@ static int __init tulip_init (void) tulip_max_interrupt_work = max_interrupt_work; /* probe for and init boards */ - return pci_module_init (&tulip_driver); + return pci_register_driver (&tulip_driver); } --- a/drivers/net/tulip/winbond-840.c +++ b/drivers/net/tulip/winbond-840.c @@ -1705,7 +1705,7 @@ static struct pci_driver w840_driver = { static int __init w840_init(void) { printk(version); - return pci_module_init(&w840_driver); + return pci_register_driver(&w840_driver); } static void __exit w840_exit(void) --- a/drivers/net/tulip/xircom_tulip_cb.c +++ b/drivers/net/tulip/xircom_tulip_cb.c @@ -1727,7 +1727,7 @@ static int __init xircom_init(void) #ifdef MODULE printk(version); #endif - return pci_module_init(&xircom_driver); + return pci_register_driver(&xircom_driver); } --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c @@ -2659,7 +2659,7 @@ static struct pci_driver typhoon_driver static int __init typhoon_init(void) { - return pci_module_init(&typhoon_driver); + return pci_register_driver(&typhoon_driver); } static void __exit --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c @@ -2070,7 +2070,7 @@ static int __init rhine_init(void) #ifdef MODULE printk(version); #endif - return pci_module_init(&rhine_driver); + return pci_register_driver(&rhine_driver); } --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c @@ -1072,10 +1072,9 @@ static int velocity_init_rd_ring(struct unsigned int rsize = sizeof(struct velocity_rd_info) * vptr->options.numrx; - vptr->rd_info = kmalloc(rsize, GFP_KERNEL); + vptr->rd_info = kzalloc(rsize, GFP_KERNEL); if(vptr->rd_info == NULL) goto out; - memset(vptr->rd_info, 0, rsize); vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0; @@ -1146,14 +1145,13 @@ static int velocity_init_td_ring(struct for (j = 0; j < vptr->num_txq; j++) { curr = vptr->td_pool_dma[j]; - vptr->td_infos[j] = kmalloc(tsize, GFP_KERNEL); + vptr->td_infos[j] = kzalloc(tsize, GFP_KERNEL); if(vptr->td_infos[j] == NULL) { while(--j >= 0) kfree(vptr->td_infos[j]); return -ENOMEM; } - memset(vptr->td_infos[j], 0, tsize); for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) { td = &(vptr->td_rings[j][i]); @@ -2244,7 +2242,7 @@ static int __init velocity_init_module(v int ret; velocity_register_notifier(); - ret = pci_module_init(&velocity_driver); + ret = pci_register_driver(&velocity_driver); if (ret < 0) velocity_unregister_notifier(); return ret; --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -309,12 +309,11 @@ static int __init c101_run(unsigned long return -ENODEV; } - card = kmalloc(sizeof(card_t), GFP_KERNEL); + card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { printk(KERN_ERR "c101: unable to allocate memory\n"); return -ENOBUFS; } - memset(card, 0, sizeof(card_t)); card->dev = alloc_hdlcdev(card); if (!card->dev) { --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c @@ -587,13 +587,12 @@ static int cosa_probe(int base, int irq, sprintf(cosa->name, "cosa%d", cosa->num); /* Initialize the per-channel data */ - cosa->chan = kmalloc(sizeof(struct channel_data)*cosa->nchannels, + cosa->chan = kcalloc(cosa->nchannels, sizeof(struct channel_data), GFP_KERNEL); if (!cosa->chan) { err = -ENOMEM; goto err_out3; } - memset(cosa->chan, 0, sizeof(struct channel_data)*cosa->nchannels); for (i=0; inchannels; i++) { cosa->chan[i].cosa = cosa; cosa->chan[i].num = i; --- a/drivers/net/wan/cycx_drv.c +++ b/drivers/net/wan/cycx_drv.c @@ -383,7 +383,7 @@ static int cycx_code_boot(void __iomem * * o start adapter up */ static int load_cyc2x(struct cycx_hw *hw, struct cycx_firmware *cfm, u32 len) { - int i, j; + unsigned long end_time, end_time2; struct cycx_fw_header *img_hdr; u8 *reset_image, *data_image, @@ -448,7 +448,8 @@ static int load_cyc2x(struct cycx_hw *hw cfm->descr[0] ? cfm->descr : "unknown firmware", cfm->info.codeid); - for (i = 0 ; i < 5 ; i++) { + end_time = jiffies + msecs_to_jiffies(20000); + while (time_before(jiffies, end_time)) { /* Reset Cyclom hardware */ if (!reset_cyc2x(hw->dpmbase)) { printk(KERN_ERR "%s: dpm problem or board not found\n", @@ -462,7 +463,8 @@ static int load_cyc2x(struct cycx_hw *hw writew(GEN_POWER_ON, pt_cycld); msleep_interruptible(1 * 1000); - for (j = 0 ; j < 3 ; j++) + end_time2 = jiffies + msecs_to_jiffies(3000); + while (time_before(jiffies, end_time2)) if (!readw(pt_cycld)) goto reset_loaded; else --- a/drivers/net/wan/cycx_main.c +++ b/drivers/net/wan/cycx_main.c @@ -114,13 +114,11 @@ static int __init cycx_init(void) /* Verify number of cards and allocate adapter data space */ cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS); cycx_ncards = max_t(int, cycx_ncards, 1); - cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards, + cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device), GFP_KERNEL); if (!cycx_card_array) goto out; - memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards); - /* Register adapters with WAN router */ for (cnt = 0; cnt < cycx_ncards; ++cnt) { struct cycx_device *card = &cycx_card_array[cnt]; --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c @@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_de } /* allocate and initialize private data */ - chan = kmalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL); + chan = kzalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL); if (!chan) return -ENOMEM; - memset(chan, 0, sizeof(*chan)); strcpy(chan->name, conf->name); chan->card = card; chan->link = conf->port; --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev * struct dscc4_dev_priv *root; int i, ret = -ENOMEM; - root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL); + root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL); if (!root) { printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME); goto err_out; } - memset(root, 0, dev_per_card*sizeof(*root)); for (i = 0; i < dev_per_card; i++) { root[i].dev = alloc_hdlcdev(root + i); @@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev * goto err_free_dev; } - ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL); + ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL); if (!ppriv) { printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME); goto err_free_dev; } - memset(ppriv, 0, sizeof(struct dscc4_pci_priv)); ppriv->root = root; spin_lock_init(&ppriv->lock); @@ -2062,7 +2060,7 @@ static struct pci_driver dscc4_driver = static int __init dscc4_init_module(void) { - return pci_module_init(&dscc4_driver); + return pci_register_driver(&dscc4_driver); } static void __exit dscc4_cleanup_module(void) --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -2476,13 +2476,12 @@ fst_add_one(struct pci_dev *pdev, const } /* Allocate driver private data */ - card = kmalloc(sizeof (struct fst_card_info), GFP_KERNEL); + card = kzalloc(sizeof (struct fst_card_info), GFP_KERNEL); if (card == NULL) { printk_err("FarSync card found but insufficient memory for" " driver storage\n"); return -ENOMEM; } - memset(card, 0, sizeof (struct fst_card_info)); /* Try to enable the device */ if ((err = pci_enable_device(pdev)) != 0) { @@ -2697,7 +2696,7 @@ fst_init(void) for (i = 0; i < FST_MAX_CARDS; i++) fst_card_array[i] = NULL; spin_lock_init(&fst_work_q_lock); - return pci_module_init(&fst_driver); + return pci_register_driver(&fst_driver); } static void __exit --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -159,11 +159,10 @@ static inline pvc_device* add_pvc(struct pvc_p = &(*pvc_p)->next; } - pvc = kmalloc(sizeof(pvc_device), GFP_ATOMIC); + pvc = kzalloc(sizeof(pvc_device), GFP_ATOMIC); if (!pvc) return NULL; - memset(pvc, 0, sizeof(pvc_device)); pvc->dlci = dlci; pvc->master = dev; pvc->next = *pvc_p; /* Put it in the chain */ --- a/drivers/net/wan/hostess_sv11.c +++ b/drivers/net/wan/hostess_sv11.c @@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(int return NULL; } - sv=(struct sv11_device *)kmalloc(sizeof(struct sv11_device), GFP_KERNEL); + sv = kzalloc(sizeof(struct sv11_device), GFP_KERNEL); if(!sv) goto fail3; - memset(sv, 0, sizeof(*sv)); sv->if_ptr=&sv->netdev; sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup); --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -1790,7 +1790,7 @@ static struct pci_driver lmc_driver = { static int __init init_lmc(void) { - return pci_module_init(&lmc_driver); + return pci_register_driver(&lmc_driver); } static void __exit exit_lmc(void) --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c @@ -351,12 +351,11 @@ static int __init n2_run(unsigned long i return -ENODEV; } - card = kmalloc(sizeof(card_t), GFP_KERNEL); + card = kzalloc(sizeof(card_t), GFP_KERNEL); if (card == NULL) { printk(KERN_ERR "n2: unable to allocate memory\n"); return -ENOBUFS; } - memset(card, 0, sizeof(card_t)); card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -3677,7 +3677,7 @@ static struct pci_driver cpc_driver = { static int __init cpc_init(void) { - return pci_module_init(&cpc_driver); + return pci_register_driver(&cpc_driver); } static void __exit cpc_cleanup_module(void) --- a/drivers/net/wan/pci200syn.c +++ b/drivers/net/wan/pci200syn.c @@ -468,7 +468,7 @@ static int __init pci200_init_module(voi printk(KERN_ERR "pci200syn: Invalid PCI clock frequency\n"); return -EINVAL; } - return pci_module_init(&pci200_pci_driver); + return pci_register_driver(&pci200_pci_driver); } --- a/drivers/net/wan/sdla.c +++ b/drivers/net/wan/sdla.c @@ -1203,10 +1203,9 @@ static int sdla_xfer(struct net_device * if (read) { - temp = kmalloc(mem.len, GFP_KERNEL); + temp = kzalloc(mem.len, GFP_KERNEL); if (!temp) return(-ENOMEM); - memset(temp, 0, mem.len); sdla_read(dev, mem.addr, temp, mem.len); if(copy_to_user(mem.data, temp, mem.len)) { --- a/drivers/net/wan/sdla_chdlc.c +++ b/drivers/net/wan/sdla_chdlc.c @@ -679,13 +679,11 @@ static int new_if(struct wan_device* wan } /* allocate and initialize private data */ - chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL); + chdlc_priv_area = kzalloc(sizeof(chdlc_private_area_t), GFP_KERNEL); if(chdlc_priv_area == NULL) return -ENOMEM; - memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t)); - chdlc_priv_area->card = card; chdlc_priv_area->common.sk = NULL; chdlc_priv_area->common.func = NULL; --- a/drivers/net/wan/sdla_fr.c +++ b/drivers/net/wan/sdla_fr.c @@ -812,12 +812,11 @@ static int new_if(struct wan_device* wan } /* allocate and initialize private data */ - chan = kmalloc(sizeof(fr_channel_t), GFP_KERNEL); + chan = kzalloc(sizeof(fr_channel_t), GFP_KERNEL); if (chan == NULL) return -ENOMEM; - memset(chan, 0, sizeof(fr_channel_t)); strcpy(chan->name, conf->name); chan->card = card; @@ -1214,8 +1213,7 @@ static int if_open(struct net_device* de INIT_WORK(&chan->common.wanpipe_work, (void *)fr_bh, dev); /* Allocate and initialize BH circular buffer */ - chan->bh_head = kmalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC); - memset(chan->bh_head,0,(sizeof(bh_data_t)*MAX_BH_BUFF)); + chan->bh_head = kzalloc((sizeof(bh_data_t)*MAX_BH_BUFF),GFP_ATOMIC); atomic_set(&chan->bh_buff_used, 0); netif_start_queue(dev); --- a/drivers/net/wan/sdlamain.c +++ b/drivers/net/wan/sdlamain.c @@ -257,14 +257,12 @@ static int __init wanpipe_init(void) } /* Verify number of cards and allocate adapter data space */ - card_array = kmalloc(sizeof(sdla_t) * ncards, GFP_KERNEL); + card_array = kcalloc(ncards, sizeof(sdla_t), GFP_KERNEL); if (card_array == NULL) { destroy_workqueue(wanpipe_wq); return -ENOMEM; } - memset(card_array, 0, sizeof(sdla_t) * ncards); - /* Register adapters with WAN router */ for (cnt = 0; cnt < ncards; ++ cnt) { sdla_t* card = &card_array[cnt]; --- a/drivers/net/wan/sdla_ppp.c +++ b/drivers/net/wan/sdla_ppp.c @@ -528,13 +528,11 @@ static int new_if(struct wan_device *wan } /* allocate and initialize private data */ - ppp_priv_area = kmalloc(sizeof(ppp_private_area_t), GFP_KERNEL); + ppp_priv_area = kzalloc(sizeof(ppp_private_area_t), GFP_KERNEL); if( ppp_priv_area == NULL ) return -ENOMEM; - memset(ppp_priv_area, 0, sizeof(ppp_private_area_t)); - ppp_priv_area->card = card; /* initialize data */ --- a/drivers/net/wan/sdla_x25.c +++ b/drivers/net/wan/sdla_x25.c @@ -926,13 +926,11 @@ static int new_if(struct wan_device* wan } /* allocate and initialize private data */ - chan = kmalloc(sizeof(x25_channel_t), GFP_ATOMIC); + chan = kzalloc(sizeof(x25_channel_t), GFP_ATOMIC); if (chan == NULL){ return -ENOMEM; } - memset(chan, 0, sizeof(x25_channel_t)); - /* Bug Fix: Seg Err on PVC startup * It must be here since bind_lcn_to_dev expects * it bellow */ @@ -1194,7 +1192,7 @@ static int if_open(struct net_device* de /* Allocate and initialize BH circular buffer */ /* Add 1 to MAX_BH_BUFF so we don't have test with (MAX_BH_BUFF-1) */ - chan->bh_head = kmalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC); + chan->bh_head = kzalloc((sizeof(bh_data_t)*(MAX_BH_BUFF+1)),GFP_ATOMIC); if (chan->bh_head == NULL){ printk(KERN_INFO "%s: ERROR, failed to allocate memory ! BH_BUFFERS !\n", @@ -1202,7 +1200,6 @@ static int if_open(struct net_device* de return -ENOBUFS; } - memset(chan->bh_head,0,(sizeof(bh_data_t)*(MAX_BH_BUFF+1))); atomic_set(&chan->bh_buff_used, 0); /* Increment the number of interfaces */ --- a/drivers/net/wan/sealevel.c +++ b/drivers/net/wan/sealevel.c @@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_in return NULL; } - b = kmalloc(sizeof(struct slvl_board), GFP_KERNEL); + b = kzalloc(sizeof(struct slvl_board), GFP_KERNEL); if(!b) goto fail3; - memset(b, 0, sizeof(*b)); if (!(b->dev[0]= slvl_alloc(iobase, irq))) goto fail2; --- a/drivers/net/wan/wanpipe_multppp.c +++ b/drivers/net/wan/wanpipe_multppp.c @@ -539,13 +539,11 @@ static int new_if(struct wan_device* wan } /* allocate and initialize private data */ - chdlc_priv_area = kmalloc(sizeof(chdlc_private_area_t), GFP_KERNEL); + chdlc_priv_area = kzalloc(sizeof(chdlc_private_area_t), GFP_KERNEL); if(chdlc_priv_area == NULL) return -ENOMEM; - memset(chdlc_priv_area, 0, sizeof(chdlc_private_area_t)); - chdlc_priv_area->card = card; /* initialize data */ --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -822,7 +822,7 @@ static int __init wanxl_init_module(void #ifdef MODULE printk(KERN_INFO "%s\n", version); #endif - return pci_module_init(&wanxl_pci_driver); + return pci_register_driver(&wanxl_pci_driver); } static void __exit wanxl_cleanup_module(void) --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -1074,8 +1074,8 @@ static const char version[] = "airo.c 0. struct airo_info; static int get_dec_u16( char *buffer, int *start, int limit ); -static void OUT4500( struct airo_info *, u16 register, u16 value ); -static unsigned short IN4500( struct airo_info *, u16 register ); +static void OUT4500( struct airo_info *, u16 reg, u16 value ); +static unsigned short IN4500( struct airo_info *, u16 reg ); static u16 setup_card(struct airo_info*, u8 *mac, int lock); static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ); static void disable_MAC(struct airo_info *ai, int lock); --- a/drivers/net/wireless/atmel_pci.c +++ b/drivers/net/wireless/atmel_pci.c @@ -77,7 +77,7 @@ static void __devexit atmel_pci_remove(s static int __init atmel_init_module(void) { - return pci_module_init(&atmel_driver); + return pci_register_driver(&atmel_driver); } static void __exit atmel_cleanup_module(void) --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c @@ -159,7 +159,6 @@ that only one external action is invoked #include #include #include -#include #include #include #include --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -31,7 +31,6 @@ ******************************************************************************/ #include "ipw2200.h" -#include #define IPW2200_VERSION "git-1.1.1" #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" --- a/drivers/net/wireless/orinoco_pci.c +++ b/drivers/net/wireless/orinoco_pci.c @@ -379,7 +379,7 @@ MODULE_LICENSE("Dual MPL/GPL"); static int __init orinoco_pci_init(void) { printk(KERN_DEBUG "%s\n", version); - return pci_module_init(&orinoco_pci_driver); + return pci_register_driver(&orinoco_pci_driver); } static void __exit orinoco_pci_exit(void) --- a/drivers/net/wireless/orinoco_plx.c +++ b/drivers/net/wireless/orinoco_plx.c @@ -382,7 +382,7 @@ MODULE_LICENSE("Dual MPL/GPL"); static int __init orinoco_plx_init(void) { printk(KERN_DEBUG "%s\n", version); - return pci_module_init(&orinoco_plx_driver); + return pci_register_driver(&orinoco_plx_driver); } static void __exit orinoco_plx_exit(void) --- a/drivers/net/wireless/orinoco_tmd.c +++ b/drivers/net/wireless/orinoco_tmd.c @@ -239,7 +239,7 @@ MODULE_LICENSE("Dual MPL/GPL"); static int __init orinoco_tmd_init(void) { printk(KERN_DEBUG "%s\n", version); - return pci_module_init(&orinoco_tmd_driver); + return pci_register_driver(&orinoco_tmd_driver); } static void __exit orinoco_tmd_exit(void) --- a/drivers/net/yellowfin.c +++ b/drivers/net/yellowfin.c @@ -1473,7 +1473,7 @@ static int __init yellowfin_init (void) #ifdef MODULE printk(version); #endif - return pci_module_init (&yellowfin_driver); + return pci_register_driver (&yellowfin_driver); } --- a/drivers/nubus/nubus.c +++ b/drivers/nubus/nubus.c @@ -467,9 +467,8 @@ static struct nubus_dev* __init parent->base, dir.base); /* Actually we should probably panic if this fails */ - if ((dev = kmalloc(sizeof(*dev), GFP_ATOMIC)) == NULL) + if ((dev = kzalloc(sizeof(*dev), GFP_ATOMIC)) == NULL) return NULL; - memset(dev, 0, sizeof(*dev)); dev->resid = parent->type; dev->directory = dir.base; dev->board = board; @@ -801,9 +800,8 @@ static struct nubus_board* __init nubus_ nubus_rewind(&rp, FORMAT_BLOCK_SIZE, bytelanes); /* Actually we should probably panic if this fails */ - if ((board = kmalloc(sizeof(*board), GFP_ATOMIC)) == NULL) + if ((board = kzalloc(sizeof(*board), GFP_ATOMIC)) == NULL) return NULL; - memset(board, 0, sizeof(*board)); board->fblock = rp; /* Dump the format block for debugging purposes */ --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -106,9 +106,8 @@ static int parport_probe(struct pcmcia_d DEBUG(0, "parport_attach()\n"); /* Create new parport device */ - info = kmalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; - memset(info, 0, sizeof(*info)); link->priv = info; info->p_dev = link; --- a/drivers/parport/parport_serial.c +++ b/drivers/parport/parport_serial.c @@ -326,10 +326,9 @@ static int __devinit parport_serial_pci_ struct parport_serial_private *priv; int err; - priv = kmalloc (sizeof *priv, GFP_KERNEL); + priv = kzalloc (sizeof *priv, GFP_KERNEL); if (!priv) return -ENOMEM; - memset(priv, 0, sizeof(struct parport_serial_private)); pci_set_drvdata (dev, priv); err = pci_enable_device (dev); --- a/drivers/pci/hotplug/ibmphp_hpc.c +++ b/drivers/pci/hotplug/ibmphp_hpc.c @@ -152,11 +152,11 @@ void __init ibmphp_hpc_initvars (void) static u8 i2c_ctrl_read (struct controller *ctlr_ptr, void __iomem *WPGBbar, u8 index) { u8 status; - int i; void __iomem *wpg_addr; // base addr + offset unsigned long wpg_data; // data to/from WPG LOHI format unsigned long ultemp; unsigned long data; // actual data HILO format + unsigned long end_time; debug_polling ("%s - Entry WPGBbar[%p] index[%x] \n", __FUNCTION__, WPGBbar, index); @@ -206,33 +206,31 @@ static u8 i2c_ctrl_read (struct controll //-------------------------------------------------------------------- // READ - step 4 : wait until start operation bit clears - i = CMD_COMPLETE_TOUT_SEC; - while (i) { + end_time = jiffies + msecs_to_jiffies(CMD_COMPLETE_TOUT_SEC * 1000); + while (time_before(jiffies, end_time)) { msleep(10); wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) break; - i--; } - if (i == 0) { + if (data & WPG_I2CMCNTL_STARTOP_MASK) { debug ("%s - Error : WPG timeout\n", __FUNCTION__); return HPC_ERROR; } //-------------------------------------------------------------------- // READ - step 5 : read I2C status register - i = CMD_COMPLETE_TOUT_SEC; - while (i) { + end_time = jiffies + msecs_to_jiffies(CMD_COMPLETE_TOUT_SEC * 1000); + while (time_before(jiffies, end_time)) { msleep(10); wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (HPC_I2CSTATUS_CHECK (data)) break; - i--; } - if (i == 0) { + if (!(HPC_I2CSTATUS_CHECK (data))) { debug ("ctrl_read - Exit Error:I2C timeout\n"); return HPC_ERROR; } @@ -264,7 +262,7 @@ static u8 i2c_ctrl_write (struct control unsigned long wpg_data; // data to/from WPG LOHI format unsigned long ultemp; unsigned long data; // actual data HILO format - int i; + unsigned long end_time; debug_polling ("%s - Entry WPGBbar[%p] index[%x] cmd[%x]\n", __FUNCTION__, WPGBbar, index, cmd); @@ -317,34 +315,32 @@ static u8 i2c_ctrl_write (struct control //-------------------------------------------------------------------- // WRITE - step 4 : wait until start operation bit clears - i = CMD_COMPLETE_TOUT_SEC; - while (i) { + end_time = jiffies + msecs_to_jiffies(CMD_COMPLETE_TOUT_SEC * 1000); + while (time_before(jiffies, end_time)) { msleep(10); wpg_addr = WPGBbar + WPG_I2CMCNTL_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (!(data & WPG_I2CMCNTL_STARTOP_MASK)) break; - i--; } - if (i == 0) { + if (data & WPG_I2CMCNTL_STARTOP_MASK) { debug ("%s - Exit Error:WPG timeout\n", __FUNCTION__); rc = HPC_ERROR; } //-------------------------------------------------------------------- // WRITE - step 5 : read I2C status register - i = CMD_COMPLETE_TOUT_SEC; - while (i) { + end_time = jiffies + msecs_to_jiffies(CMD_COMPLETE_TOUT_SEC * 1000); + while (time_before(jiffies, end_time)) { msleep(10); wpg_addr = WPGBbar + WPG_I2CSTAT_OFFSET; wpg_data = readl (wpg_addr); data = swab32 (wpg_data); if (HPC_I2CSTATUS_CHECK (data)) break; - i--; } - if (i == 0) { + if (!(HPC_I2CSTATUS_CHECK (data))) { debug ("ctrl_read - Error : I2C timeout\n"); rc = HPC_ERROR; } --- a/drivers/pci/hotplug/shpchp_hpc.c +++ b/drivers/pci/hotplug/shpchp_hpc.c @@ -276,7 +276,7 @@ static int shpc_write_cmd(struct slot *s u16 cmd_status; int retval = 0; u16 temp_word; - int i; + unsigned long end_time; DBG_ENTER_ROUTINE @@ -288,7 +288,8 @@ static int shpc_write_cmd(struct slot *s goto out; } - for (i = 0; i < 10; i++) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time)) { cmd_status = readw(php_ctlr->creg + CMD_STATUS); if (!(cmd_status & 0x1)) --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -349,7 +349,8 @@ static void socket_remove_drivers(struct static int socket_reset(struct pcmcia_socket *skt) { - int status, i; + int status; + unsigned long end_time; cs_dbg(skt, 4, "reset\n"); @@ -361,7 +362,8 @@ static int socket_reset(struct pcmcia_so skt->ops->set_socket(skt, &skt->socket); msleep(unreset_delay * 10); - for (i = 0; i < unreset_limit; i++) { + end_time = jiffies + msecs_to_jiffies(unreset_limit * unreset_check * 10); + while (time_before(jiffies, end_time)) { skt->ops->get_status(skt, &status); if (!(status & SS_DETECT)) @@ -416,7 +418,8 @@ static void socket_shutdown(struct pcmci static int socket_setup(struct pcmcia_socket *skt, int initial_delay) { - int status, i; + int status; + unsigned long end_time; cs_dbg(skt, 4, "setup\n"); @@ -426,7 +429,8 @@ static int socket_setup(struct pcmcia_so msleep(initial_delay * 10); - for (i = 0; i < 100; i++) { + end_time = jiffies + msecs_to_jiffies(10000); + while (time_before(jiffies, end_time)) { skt->ops->get_status(skt, &status); if (!(status & SS_DETECT)) return CS_NO_CARD; --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -66,7 +66,7 @@ #ifdef DEBUG static const char version[] = -"i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)"; + "i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)"; static int pc_debug; @@ -83,10 +83,10 @@ module_param(pc_debug, int, 0644); static irqreturn_t i365_count_irq(int, void *, struct pt_regs *); static inline int _check_irq(int irq, int flags) { - if (request_irq(irq, i365_count_irq, flags, "x", i365_count_irq) != 0) - return -1; - free_irq(irq, i365_count_irq); - return 0; + if (request_irq(irq, i365_count_irq, flags, "x", i365_count_irq) != 0) + return -1; + free_irq(irq, i365_count_irq); + return 0; } /*====================================================================*/ @@ -153,31 +153,31 @@ module_param(recov_time, int, 0444); /*====================================================================*/ typedef struct cirrus_state_t { - u_char misc1, misc2; - u_char timer[6]; + u_char misc1, misc2; + u_char timer[6]; } cirrus_state_t; typedef struct vg46x_state_t { - u_char ctl, ema; + u_char ctl, ema; } vg46x_state_t; struct i82365_socket { - u_short type, flags; - struct pcmcia_socket socket; - unsigned int number; - kio_addr_t ioaddr; - u_short psock; - u_char cs_irq, intr; - union { - cirrus_state_t cirrus; - vg46x_state_t vg46x; - } state; + u_short type, flags; + struct pcmcia_socket socket; + unsigned int number; + kio_addr_t ioaddr; + u_short psock; + u_char cs_irq, intr; + union { + cirrus_state_t cirrus; + vg46x_state_t vg46x; + } state; }; /* Where we keep track of our sockets... */ static int sockets = 0; static struct i82365_socket socket[8] = { - { 0, }, /* ... */ + {0,}, /* ... */ }; /* Default ISA interrupt mask */ @@ -194,9 +194,9 @@ static struct timer_list poll_timer; /* These definitions must match the pcic table! */ typedef enum pcic_id { - IS_I82365A, IS_I82365B, IS_I82365DF, - IS_IBM, IS_RF5Cx96, IS_VLSI, IS_VG468, IS_VG469, - IS_PD6710, IS_PD672X, IS_VT83C469, + IS_I82365A, IS_I82365B, IS_I82365DF, + IS_IBM, IS_RF5Cx96, IS_VLSI, IS_VG468, IS_VG469, + IS_PD6710, IS_PD672X, IS_VT83C469, } pcic_id; /* Flags for classifying groups of controllers */ @@ -210,22 +210,22 @@ typedef enum pcic_id { #define IS_ALIVE 0x8000 typedef struct pcic_t { - char *name; - u_short flags; + char *name; + u_short flags; } pcic_t; static pcic_t pcic[] = { - { "Intel i82365sl A step", 0 }, - { "Intel i82365sl B step", 0 }, - { "Intel i82365sl DF", IS_DF_PWR }, - { "IBM Clone", 0 }, - { "Ricoh RF5C296/396", 0 }, - { "VLSI 82C146", 0 }, - { "Vadem VG-468", IS_VADEM }, - { "Vadem VG-469", IS_VADEM|IS_VG_PWR }, - { "Cirrus PD6710", IS_CIRRUS }, - { "Cirrus PD672x", IS_CIRRUS }, - { "VIA VT83C469", IS_CIRRUS|IS_VIA }, + {"Intel i82365sl A step", 0}, + {"Intel i82365sl B step", 0}, + {"Intel i82365sl DF", IS_DF_PWR}, + {"IBM Clone", 0}, + {"Ricoh RF5C296/396", 0}, + {"VLSI 82C146", 0}, + {"Vadem VG-468", IS_VADEM}, + {"Vadem VG-469", IS_VADEM | IS_VG_PWR}, + {"Cirrus PD6710", IS_CIRRUS}, + {"Cirrus PD672x", IS_CIRRUS}, + {"VIA VT83C469", IS_CIRRUS | IS_VIA}, }; #define PCIC_COUNT (sizeof(pcic)/sizeof(pcic_t)) @@ -236,66 +236,68 @@ static DEFINE_SPINLOCK(bus_lock); static u_char i365_get(u_short sock, u_short reg) { - unsigned long flags; - spin_lock_irqsave(&bus_lock,flags); - { - kio_addr_t port = socket[sock].ioaddr; - u_char val; - reg = I365_REG(socket[sock].psock, reg); - outb(reg, port); val = inb(port+1); - spin_unlock_irqrestore(&bus_lock,flags); - return val; - } + unsigned long flags; + spin_lock_irqsave(&bus_lock, flags); + { + kio_addr_t port = socket[sock].ioaddr; + u_char val; + reg = I365_REG(socket[sock].psock, reg); + outb(reg, port); + val = inb(port + 1); + spin_unlock_irqrestore(&bus_lock, flags); + return val; + } } static void i365_set(u_short sock, u_short reg, u_char data) { - unsigned long flags; - spin_lock_irqsave(&bus_lock,flags); - { - kio_addr_t port = socket[sock].ioaddr; - u_char val = I365_REG(socket[sock].psock, reg); - outb(val, port); outb(data, port+1); - spin_unlock_irqrestore(&bus_lock,flags); - } + unsigned long flags; + spin_lock_irqsave(&bus_lock, flags); + { + kio_addr_t port = socket[sock].ioaddr; + u_char val = I365_REG(socket[sock].psock, reg); + outb(val, port); + outb(data, port + 1); + spin_unlock_irqrestore(&bus_lock, flags); + } } static void i365_bset(u_short sock, u_short reg, u_char mask) { - u_char d = i365_get(sock, reg); - d |= mask; - i365_set(sock, reg, d); + u_char d = i365_get(sock, reg); + d |= mask; + i365_set(sock, reg, d); } static void i365_bclr(u_short sock, u_short reg, u_char mask) { - u_char d = i365_get(sock, reg); - d &= ~mask; - i365_set(sock, reg, d); + u_char d = i365_get(sock, reg); + d &= ~mask; + i365_set(sock, reg, d); } static void i365_bflip(u_short sock, u_short reg, u_char mask, int b) { - u_char d = i365_get(sock, reg); - if (b) - d |= mask; - else - d &= ~mask; - i365_set(sock, reg, d); + u_char d = i365_get(sock, reg); + if (b) + d |= mask; + else + d &= ~mask; + i365_set(sock, reg, d); } static u_short i365_get_pair(u_short sock, u_short reg) { - u_short a, b; - a = i365_get(sock, reg); - b = i365_get(sock, reg+1); - return (a + (b<<8)); + u_short a, b; + a = i365_get(sock, reg); + b = i365_get(sock, reg + 1); + return (a + (b << 8)); } static void i365_set_pair(u_short sock, u_short reg, u_short data) { - i365_set(sock, reg, data & 0xff); - i365_set(sock, reg+1, data >> 8); + i365_set(sock, reg, data & 0xff); + i365_set(sock, reg + 1, data >> 8); } /*====================================================================== @@ -313,78 +315,81 @@ static void i365_set_pair(u_short sock, static void cirrus_get_state(u_short s) { - int i; - cirrus_state_t *p = &socket[s].state.cirrus; - p->misc1 = i365_get(s, PD67_MISC_CTL_1); - p->misc1 &= (PD67_MC1_MEDIA_ENA | PD67_MC1_INPACK_ENA); - p->misc2 = i365_get(s, PD67_MISC_CTL_2); - for (i = 0; i < 6; i++) - p->timer[i] = i365_get(s, PD67_TIME_SETUP(0)+i); + int i; + cirrus_state_t *p = &socket[s].state.cirrus; + p->misc1 = i365_get(s, PD67_MISC_CTL_1); + p->misc1 &= (PD67_MC1_MEDIA_ENA | PD67_MC1_INPACK_ENA); + p->misc2 = i365_get(s, PD67_MISC_CTL_2); + for (i = 0; i < 6; i++) + p->timer[i] = i365_get(s, PD67_TIME_SETUP(0) + i); } static void cirrus_set_state(u_short s) { - int i; - u_char misc; - cirrus_state_t *p = &socket[s].state.cirrus; - - misc = i365_get(s, PD67_MISC_CTL_2); - i365_set(s, PD67_MISC_CTL_2, p->misc2); - if (misc & PD67_MC2_SUSPEND) mdelay(50); - misc = i365_get(s, PD67_MISC_CTL_1); - misc &= ~(PD67_MC1_MEDIA_ENA | PD67_MC1_INPACK_ENA); - i365_set(s, PD67_MISC_CTL_1, misc | p->misc1); - for (i = 0; i < 6; i++) - i365_set(s, PD67_TIME_SETUP(0)+i, p->timer[i]); + int i; + u_char misc; + cirrus_state_t *p = &socket[s].state.cirrus; + + misc = i365_get(s, PD67_MISC_CTL_2); + i365_set(s, PD67_MISC_CTL_2, p->misc2); + if (misc & PD67_MC2_SUSPEND) + mdelay(50); + misc = i365_get(s, PD67_MISC_CTL_1); + misc &= ~(PD67_MC1_MEDIA_ENA | PD67_MC1_INPACK_ENA); + i365_set(s, PD67_MISC_CTL_1, misc | p->misc1); + for (i = 0; i < 6; i++) + i365_set(s, PD67_TIME_SETUP(0) + i, p->timer[i]); } static u_int __init cirrus_set_opts(u_short s, char *buf) { - struct i82365_socket *t = &socket[s]; - cirrus_state_t *p = &socket[s].state.cirrus; - u_int mask = 0xffff; - - if (has_ring == -1) has_ring = 1; - flip(p->misc2, PD67_MC2_IRQ15_RI, has_ring); - flip(p->misc2, PD67_MC2_DYNAMIC_MODE, dynamic_mode); - flip(p->misc2, PD67_MC2_FREQ_BYPASS, freq_bypass); - if (p->misc2 & PD67_MC2_IRQ15_RI) - strcat(buf, " [ring]"); - if (p->misc2 & PD67_MC2_DYNAMIC_MODE) - strcat(buf, " [dyn mode]"); - if (p->misc2 & PD67_MC2_FREQ_BYPASS) - strcat(buf, " [freq bypass]"); - if (p->misc1 & PD67_MC1_INPACK_ENA) - strcat(buf, " [inpack]"); - if (p->misc2 & PD67_MC2_IRQ15_RI) - mask &= ~0x8000; - if (has_led > 0) { - strcat(buf, " [led]"); - mask &= ~0x1000; - } - if (has_dma > 0) { - strcat(buf, " [dma]"); - mask &= ~0x0600; - } - if (!(t->flags & IS_VIA)) { - if (setup_time >= 0) - p->timer[0] = p->timer[3] = setup_time; - if (cmd_time > 0) { - p->timer[1] = cmd_time; - p->timer[4] = cmd_time*2+4; - } - if (p->timer[1] == 0) { - p->timer[1] = 6; p->timer[4] = 16; - if (p->timer[0] == 0) - p->timer[0] = p->timer[3] = 1; - } - if (recov_time >= 0) - p->timer[2] = p->timer[5] = recov_time; - buf += strlen(buf); - sprintf(buf, " [%d/%d/%d] [%d/%d/%d]", p->timer[0], p->timer[1], - p->timer[2], p->timer[3], p->timer[4], p->timer[5]); - } - return mask; + struct i82365_socket *t = &socket[s]; + cirrus_state_t *p = &socket[s].state.cirrus; + u_int mask = 0xffff; + + if (has_ring == -1) + has_ring = 1; + flip(p->misc2, PD67_MC2_IRQ15_RI, has_ring); + flip(p->misc2, PD67_MC2_DYNAMIC_MODE, dynamic_mode); + flip(p->misc2, PD67_MC2_FREQ_BYPASS, freq_bypass); + if (p->misc2 & PD67_MC2_IRQ15_RI) + strcat(buf, " [ring]"); + if (p->misc2 & PD67_MC2_DYNAMIC_MODE) + strcat(buf, " [dyn mode]"); + if (p->misc2 & PD67_MC2_FREQ_BYPASS) + strcat(buf, " [freq bypass]"); + if (p->misc1 & PD67_MC1_INPACK_ENA) + strcat(buf, " [inpack]"); + if (p->misc2 & PD67_MC2_IRQ15_RI) + mask &= ~0x8000; + if (has_led > 0) { + strcat(buf, " [led]"); + mask &= ~0x1000; + } + if (has_dma > 0) { + strcat(buf, " [dma]"); + mask &= ~0x0600; + } + if (!(t->flags & IS_VIA)) { + if (setup_time >= 0) + p->timer[0] = p->timer[3] = setup_time; + if (cmd_time > 0) { + p->timer[1] = cmd_time; + p->timer[4] = cmd_time * 2 + 4; + } + if (p->timer[1] == 0) { + p->timer[1] = 6; + p->timer[4] = 16; + if (p->timer[0] == 0) + p->timer[0] = p->timer[3] = 1; + } + if (recov_time >= 0) + p->timer[2] = p->timer[5] = recov_time; + buf += strlen(buf); + sprintf(buf, " [%d/%d/%d] [%d/%d/%d]", p->timer[0], p->timer[1], + p->timer[2], p->timer[3], p->timer[4], p->timer[5]); + } + return mask; } /*====================================================================== @@ -397,43 +402,43 @@ static u_int __init cirrus_set_opts(u_sh static void vg46x_get_state(u_short s) { - vg46x_state_t *p = &socket[s].state.vg46x; - p->ctl = i365_get(s, VG468_CTL); - if (socket[s].type == IS_VG469) - p->ema = i365_get(s, VG469_EXT_MODE); + vg46x_state_t *p = &socket[s].state.vg46x; + p->ctl = i365_get(s, VG468_CTL); + if (socket[s].type == IS_VG469) + p->ema = i365_get(s, VG469_EXT_MODE); } static void vg46x_set_state(u_short s) { - vg46x_state_t *p = &socket[s].state.vg46x; - i365_set(s, VG468_CTL, p->ctl); - if (socket[s].type == IS_VG469) - i365_set(s, VG469_EXT_MODE, p->ema); + vg46x_state_t *p = &socket[s].state.vg46x; + i365_set(s, VG468_CTL, p->ctl); + if (socket[s].type == IS_VG469) + i365_set(s, VG469_EXT_MODE, p->ema); } static u_int __init vg46x_set_opts(u_short s, char *buf) { - vg46x_state_t *p = &socket[s].state.vg46x; - - flip(p->ctl, VG468_CTL_ASYNC, async_clock); - flip(p->ema, VG469_MODE_CABLE, cable_mode); - if (p->ctl & VG468_CTL_ASYNC) - strcat(buf, " [async]"); - if (p->ctl & VG468_CTL_INPACK) - strcat(buf, " [inpack]"); - if (socket[s].type == IS_VG469) { - u_char vsel = i365_get(s, VG469_VSELECT); - if (vsel & VG469_VSEL_EXT_STAT) { - strcat(buf, " [ext mode]"); - if (vsel & VG469_VSEL_EXT_BUS) - strcat(buf, " [isa buf]"); - } - if (p->ema & VG469_MODE_CABLE) - strcat(buf, " [cable]"); - if (p->ema & VG469_MODE_COMPAT) - strcat(buf, " [c step]"); - } - return 0xffff; + vg46x_state_t *p = &socket[s].state.vg46x; + + flip(p->ctl, VG468_CTL_ASYNC, async_clock); + flip(p->ema, VG469_MODE_CABLE, cable_mode); + if (p->ctl & VG468_CTL_ASYNC) + strcat(buf, " [async]"); + if (p->ctl & VG468_CTL_INPACK) + strcat(buf, " [inpack]"); + if (socket[s].type == IS_VG469) { + u_char vsel = i365_get(s, VG469_VSELECT); + if (vsel & VG469_VSEL_EXT_STAT) { + strcat(buf, " [ext mode]"); + if (vsel & VG469_VSEL_EXT_BUS) + strcat(buf, " [isa buf]"); + } + if (p->ema & VG469_MODE_CABLE) + strcat(buf, " [cable]"); + if (p->ema & VG469_MODE_COMPAT) + strcat(buf, " [c step]"); + } + return 0xffff; } /*====================================================================== @@ -444,49 +449,50 @@ static u_int __init vg46x_set_opts(u_sho static void get_bridge_state(u_short s) { - struct i82365_socket *t = &socket[s]; - if (t->flags & IS_CIRRUS) - cirrus_get_state(s); - else if (t->flags & IS_VADEM) - vg46x_get_state(s); + struct i82365_socket *t = &socket[s]; + if (t->flags & IS_CIRRUS) + cirrus_get_state(s); + else if (t->flags & IS_VADEM) + vg46x_get_state(s); } static void set_bridge_state(u_short s) { - struct i82365_socket *t = &socket[s]; - if (t->flags & IS_CIRRUS) - cirrus_set_state(s); - else { - i365_set(s, I365_GBLCTL, 0x00); - i365_set(s, I365_GENCTL, 0x00); - } - i365_bflip(s, I365_INTCTL, I365_INTR_ENA, t->intr); - if (t->flags & IS_VADEM) - vg46x_set_state(s); + struct i82365_socket *t = &socket[s]; + if (t->flags & IS_CIRRUS) + cirrus_set_state(s); + else { + i365_set(s, I365_GBLCTL, 0x00); + i365_set(s, I365_GENCTL, 0x00); + } + i365_bflip(s, I365_INTCTL, I365_INTR_ENA, t->intr); + if (t->flags & IS_VADEM) + vg46x_set_state(s); } static u_int __init set_bridge_opts(u_short s, u_short ns) { - u_short i; - u_int m = 0xffff; - char buf[128]; - - for (i = s; i < s+ns; i++) { - if (socket[i].flags & IS_ALIVE) { - printk(KERN_INFO " host opts [%d]: already alive!\n", i); - continue; - } - buf[0] = '\0'; - get_bridge_state(i); - if (socket[i].flags & IS_CIRRUS) - m = cirrus_set_opts(i, buf); - else if (socket[i].flags & IS_VADEM) - m = vg46x_set_opts(i, buf); - set_bridge_state(i); - printk(KERN_INFO " host opts [%d]:%s\n", i, - (*buf) ? buf : " none"); - } - return m; + u_short i; + u_int m = 0xffff; + char buf[128]; + + for (i = s; i < s + ns; i++) { + if (socket[i].flags & IS_ALIVE) { + printk(KERN_INFO " host opts [%d]: already alive!\n", + i); + continue; + } + buf[0] = '\0'; + get_bridge_state(i); + if (socket[i].flags & IS_CIRRUS) + m = cirrus_set_opts(i, buf); + else if (socket[i].flags & IS_VADEM) + m = vg46x_set_opts(i, buf); + set_bridge_state(i); + printk(KERN_INFO " host opts [%d]:%s\n", i, + (*buf) ? buf : " none"); + } + return m; } /*====================================================================== @@ -500,81 +506,85 @@ static u_short irq_sock; static irqreturn_t i365_count_irq(int irq, void *dev, struct pt_regs *regs) { - i365_get(irq_sock, I365_CSC); - irq_hits++; - debug(2, "-> hit on irq %d\n", irq); - return IRQ_HANDLED; + i365_get(irq_sock, I365_CSC); + irq_hits++; + debug(2, "-> hit on irq %d\n", irq); + return IRQ_HANDLED; } static u_int __init test_irq(u_short sock, int irq) { - debug(2, " testing ISA irq %d\n", irq); - if (request_irq(irq, i365_count_irq, 0, "scan", i365_count_irq) != 0) - return 1; - irq_hits = 0; irq_sock = sock; - msleep(10); - if (irq_hits) { + debug(2, " testing ISA irq %d\n", irq); + if (request_irq(irq, i365_count_irq, 0, "scan", i365_count_irq) != 0) + return 1; + irq_hits = 0; + irq_sock = sock; + msleep(10); + if (irq_hits) { + free_irq(irq, i365_count_irq); + debug(2, " spurious hit!\n"); + return 1; + } + + /* Generate one interrupt */ + i365_set(sock, I365_CSCINT, I365_CSC_DETECT | (irq << 4)); + i365_bset(sock, I365_GENCTL, I365_CTL_SW_IRQ); + udelay(1000); + free_irq(irq, i365_count_irq); - debug(2, " spurious hit!\n"); - return 1; - } - - /* Generate one interrupt */ - i365_set(sock, I365_CSCINT, I365_CSC_DETECT | (irq << 4)); - i365_bset(sock, I365_GENCTL, I365_CTL_SW_IRQ); - udelay(1000); - - free_irq(irq, i365_count_irq); - - /* mask all interrupts */ - i365_set(sock, I365_CSCINT, 0); - debug(2, " hits = %d\n", irq_hits); - - return (irq_hits != 1); + + /* mask all interrupts */ + i365_set(sock, I365_CSCINT, 0); + debug(2, " hits = %d\n", irq_hits); + + return (irq_hits != 1); } static u_int __init isa_scan(u_short sock, u_int mask0) { - u_int mask1 = 0; - int i; + u_int mask1 = 0; + int i; #ifdef __alpha__ #define PIC 0x4d0 - /* Don't probe level-triggered interrupts -- reserved for PCI */ - mask0 &= ~(inb(PIC) | (inb(PIC+1) << 8)); + /* Don't probe level-triggered interrupts -- reserved for PCI */ + mask0 &= ~(inb(PIC) | (inb(PIC + 1) << 8)); #endif - - if (do_scan) { - set_bridge_state(sock); - i365_set(sock, I365_CSCINT, 0); - for (i = 0; i < 16; i++) - if ((mask0 & (1 << i)) && (test_irq(sock, i) == 0)) - mask1 |= (1 << i); - for (i = 0; i < 16; i++) - if ((mask1 & (1 << i)) && (test_irq(sock, i) != 0)) - mask1 ^= (1 << i); - } - - printk(KERN_INFO " ISA irqs ("); - if (mask1) { - printk("scanned"); - } else { - /* Fallback: just find interrupts that aren't in use */ + + if (do_scan) { + set_bridge_state(sock); + i365_set(sock, I365_CSCINT, 0); + for (i = 0; i < 16; i++) + if ((mask0 & (1 << i)) && (test_irq(sock, i) == 0)) + mask1 |= (1 << i); + for (i = 0; i < 16; i++) + if ((mask1 & (1 << i)) && (test_irq(sock, i) != 0)) + mask1 ^= (1 << i); + } + + printk(KERN_INFO " ISA irqs ("); + if (mask1) { + printk("scanned"); + } else { + /* Fallback: just find interrupts that aren't in use */ + for (i = 0; i < 16; i++) + if ((mask0 & (1 << i)) && (_check_irq(i, 0) == 0)) + mask1 |= (1 << i); + printk("default"); + /* If scan failed, default to polled status */ + if (!cs_irq && (poll_interval == 0)) + poll_interval = HZ; + } + printk(") = "); + for (i = 0; i < 16; i++) - if ((mask0 & (1 << i)) && (_check_irq(i, 0) == 0)) - mask1 |= (1 << i); - printk("default"); - /* If scan failed, default to polled status */ - if (!cs_irq && (poll_interval == 0)) poll_interval = HZ; - } - printk(") = "); - - for (i = 0; i < 16; i++) - if (mask1 & (1<= 4) ? IS_VG469 : IS_VG468; - } - - /* Check for Ricoh chips */ - val = i365_get(sockets, RF5C_CHIP_ID); - if ((val == RF5C_CHIP_RF5C296) || (val == RF5C_CHIP_RF5C396)) - type = IS_RF5Cx96; - - /* Check for Cirrus CL-PD67xx chips */ - i365_set(sockets, PD67_CHIP_INFO, 0); - val = i365_get(sockets, PD67_CHIP_INFO); - if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) { + /* Use the next free entry in the socket table */ + socket[sockets].ioaddr = port; + socket[sockets].psock = sock; + + /* Wake up a sleepy Cirrus controller */ + if (wakeup) { + i365_bclr(sockets, PD67_MISC_CTL_2, PD67_MC2_SUSPEND); + /* Pause at least 50 ms */ + mdelay(50); + } + + if ((val = i365_get(sockets, I365_IDENT)) & 0x70) + return -1; + switch (val) { + case 0x82: + type = IS_I82365A; + break; + case 0x83: + type = IS_I82365B; + break; + case 0x84: + type = IS_I82365DF; + break; + case 0x88: + case 0x89: + case 0x8a: + type = IS_IBM; + break; + } + + /* Check for Vadem VG-468 chips */ + outb(0x0e, port); + outb(0x37, port); + i365_bset(sockets, VG468_MISC, VG468_MISC_VADEMREV); + val = i365_get(sockets, I365_IDENT); + if (val & I365_IDENT_VADEM) { + i365_bclr(sockets, VG468_MISC, VG468_MISC_VADEMREV); + type = ((val & 7) >= 4) ? IS_VG469 : IS_VG468; + } + + /* Check for Ricoh chips */ + val = i365_get(sockets, RF5C_CHIP_ID); + if ((val == RF5C_CHIP_RF5C296) || (val == RF5C_CHIP_RF5C396)) + type = IS_RF5Cx96; + + /* Check for Cirrus CL-PD67xx chips */ + i365_set(sockets, PD67_CHIP_INFO, 0); val = i365_get(sockets, PD67_CHIP_INFO); - if ((val & PD67_INFO_CHIP_ID) == 0) { - type = (val & PD67_INFO_SLOTS) ? IS_PD672X : IS_PD6710; - i365_set(sockets, PD67_EXT_INDEX, 0xe5); - if (i365_get(sockets, PD67_EXT_INDEX) != 0xe5) - type = IS_VT83C469; - } - } - return type; -} /* identify */ + if ((val & PD67_INFO_CHIP_ID) == PD67_INFO_CHIP_ID) { + val = i365_get(sockets, PD67_CHIP_INFO); + if ((val & PD67_INFO_CHIP_ID) == 0) { + type = (val & PD67_INFO_SLOTS) ? IS_PD672X : IS_PD6710; + i365_set(sockets, PD67_EXT_INDEX, 0xe5); + if (i365_get(sockets, PD67_EXT_INDEX) != 0xe5) + type = IS_VT83C469; + } + } + return type; +} /* identify */ /*====================================================================== @@ -658,112 +674,114 @@ static int __init identify(kio_addr_t po static int __init is_alive(u_short sock) { - u_char stat; - kio_addr_t start, stop; - - stat = i365_get(sock, I365_STATUS); - start = i365_get_pair(sock, I365_IO(0)+I365_W_START); - stop = i365_get_pair(sock, I365_IO(0)+I365_W_STOP); - if ((stat & I365_CS_DETECT) && (stat & I365_CS_POWERON) && - (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD) && - (i365_get(sock, I365_ADDRWIN) & I365_ENA_IO(0)) && - ((start & 0xfeef) != 0x02e8)) { - if (!request_region(start, stop-start+1, "i82365")) - return 1; - release_region(start, stop-start+1); - } + u_char stat; + kio_addr_t start, stop; + + stat = i365_get(sock, I365_STATUS); + start = i365_get_pair(sock, I365_IO(0) + I365_W_START); + stop = i365_get_pair(sock, I365_IO(0) + I365_W_STOP); + if ((stat & I365_CS_DETECT) && (stat & I365_CS_POWERON) && + (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD) && + (i365_get(sock, I365_ADDRWIN) & I365_ENA_IO(0)) && + ((start & 0xfeef) != 0x02e8)) { + if (!request_region(start, stop - start + 1, "i82365")) + return 1; + release_region(start, stop - start + 1); + } - return 0; + return 0; } /*====================================================================*/ static void __init add_socket(kio_addr_t port, int psock, int type) { - socket[sockets].ioaddr = port; - socket[sockets].psock = psock; - socket[sockets].type = type; - socket[sockets].flags = pcic[type].flags; - if (is_alive(sockets)) - socket[sockets].flags |= IS_ALIVE; - sockets++; + socket[sockets].ioaddr = port; + socket[sockets].psock = psock; + socket[sockets].type = type; + socket[sockets].flags = pcic[type].flags; + if (is_alive(sockets)) + socket[sockets].flags |= IS_ALIVE; + sockets++; } static void __init add_pcic(int ns, int type) { - u_int mask = 0, i, base; - int isa_irq = 0; - struct i82365_socket *t = &socket[sockets-ns]; - - base = sockets-ns; - if (base == 0) printk("\n"); - printk(KERN_INFO " %s", pcic[type].name); - printk(" ISA-to-PCMCIA at port %#lx ofs 0x%02x", - t->ioaddr, t->psock*0x40); - printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : "")); - - /* Set host options, build basic interrupt mask */ - if (irq_list_count == 0) - mask = irq_mask; - else - for (i = mask = 0; i < irq_list_count; i++) - mask |= (1< 0; cs_irq--) - if ((cs_mask & (1 << cs_irq)) && - (_check_irq(cs_irq, 0) == 0)) - break; - if (cs_irq) { - grab_irq = 1; - isa_irq = cs_irq; - printk(" status change on irq %d\n", cs_irq); + u_int mask = 0, i, base; + int isa_irq = 0; + struct i82365_socket *t = &socket[sockets - ns]; + + base = sockets - ns; + if (base == 0) + printk("\n"); + printk(KERN_INFO " %s", pcic[type].name); + printk(" ISA-to-PCMCIA at port %#lx ofs 0x%02x", + t->ioaddr, t->psock * 0x40); + printk(", %d socket%s\n", ns, ((ns > 1) ? "s" : "")); + + /* Set host options, build basic interrupt mask */ + if (irq_list_count == 0) + mask = irq_mask; + else + for (i = mask = 0; i < irq_list_count; i++) + mask |= (1 << irq_list[i]); + mask &= I365_MASK & set_bridge_opts(base, ns); + /* Scan for ISA interrupts */ + mask = isa_scan(base, mask); + + /* Poll if only two interrupts available */ + if (!poll_interval) { + u_int tmp = (mask & 0xff20); + tmp = tmp & (tmp - 1); + if ((tmp & (tmp - 1)) == 0) + poll_interval = HZ; + } + /* Only try an ISA cs_irq if this is the first controller */ + if (!grab_irq && (cs_irq || !poll_interval)) { + /* Avoid irq 12 unless it is explicitly requested */ + u_int cs_mask = mask & ((cs_irq) ? (1 << cs_irq) : ~(1 << 12)); + for (cs_irq = 15; cs_irq > 0; cs_irq--) + if ((cs_mask & (1 << cs_irq)) && + (_check_irq(cs_irq, 0) == 0)) + break; + if (cs_irq) { + grab_irq = 1; + isa_irq = cs_irq; + printk(" status change on irq %d\n", cs_irq); + } + } + + if (!isa_irq) { + if (poll_interval == 0) + poll_interval = HZ; + printk(" polling interval = %d ms\n", + poll_interval * 1000 / HZ); + + } + + /* Update socket interrupt information, capabilities */ + for (i = 0; i < ns; i++) { + t[i].socket.features |= SS_CAP_PCCARD; + t[i].socket.map_size = 0x1000; + t[i].socket.irq_mask = mask; + t[i].cs_irq = isa_irq; } - } - - if (!isa_irq) { - if (poll_interval == 0) - poll_interval = HZ; - printk(" polling interval = %d ms\n", - poll_interval * 1000 / HZ); - - } - - /* Update socket interrupt information, capabilities */ - for (i = 0; i < ns; i++) { - t[i].socket.features |= SS_CAP_PCCARD; - t[i].socket.map_size = 0x1000; - t[i].socket.irq_mask = mask; - t[i].cs_irq = isa_irq; - } -} /* add_pcic */ +} /* add_pcic */ /*====================================================================*/ #ifdef CONFIG_PNP static struct isapnp_device_id id_table[] __initdata = { - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), - ISAPNP_FUNCTION(0x0e00), (unsigned long) "Intel 82365-Compatible" }, - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), - ISAPNP_FUNCTION(0x0e01), (unsigned long) "Cirrus Logic CL-PD6720" }, - { ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), - ISAPNP_FUNCTION(0x0e02), (unsigned long) "VLSI VL82C146" }, - { 0 } + {ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), + ISAPNP_FUNCTION(0x0e00), (unsigned long)"Intel 82365-Compatible"}, + {ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), + ISAPNP_FUNCTION(0x0e01), (unsigned long)"Cirrus Logic CL-PD6720"}, + {ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'), + ISAPNP_FUNCTION(0x0e02), (unsigned long)"VLSI VL82C146"}, + {0} }; + MODULE_DEVICE_TABLE(isapnp, id_table); static struct pnp_dev *i82365_pnpdev; @@ -771,360 +789,425 @@ static struct pnp_dev *i82365_pnpdev; static void __init isa_probe(void) { - int i, j, sock, k, ns, id; - kio_addr_t port; + int i, j, sock, k, ns, id; + kio_addr_t port; #ifdef CONFIG_PNP - struct isapnp_device_id *devid; - struct pnp_dev *dev; - - for (devid = id_table; devid->vendor; devid++) { - if ((dev = pnp_find_dev(NULL, devid->vendor, devid->function, NULL))) { - - if (pnp_device_attach(dev) < 0) - continue; - - if (pnp_activate_dev(dev) < 0) { - printk("activate failed\n"); - pnp_device_detach(dev); - break; - } + struct isapnp_device_id *devid; + struct pnp_dev *dev; - if (!pnp_port_valid(dev, 0)) { - printk("invalid resources ?\n"); - pnp_device_detach(dev); - break; - } - i365_base = pnp_port_start(dev, 0); - i82365_pnpdev = dev; - break; + for (devid = id_table; devid->vendor; devid++) { + if ((dev = + pnp_find_dev(NULL, devid->vendor, devid->function, + NULL))) { + + if (pnp_device_attach(dev) < 0) + continue; + + if (pnp_activate_dev(dev) < 0) { + printk("activate failed\n"); + pnp_device_detach(dev); + break; + } + + if (!pnp_port_valid(dev, 0)) { + printk("invalid resources ?\n"); + pnp_device_detach(dev); + break; + } + i365_base = pnp_port_start(dev, 0); + i82365_pnpdev = dev; + break; + } } - } #endif - if (!request_region(i365_base, 2, "i82365")) { - if (sockets == 0) - printk("port conflict at %#lx\n", i365_base); - return; - } - - id = identify(i365_base, 0); - if ((id == IS_I82365DF) && (identify(i365_base, 1) != id)) { - for (i = 0; i < 4; i++) { - if (i == ignore) continue; - port = i365_base + ((i & 1) << 2) + ((i & 2) << 1); - sock = (i & 1) << 1; - if (identify(port, sock) == IS_I82365DF) { - add_socket(port, sock, IS_VLSI); - add_pcic(1, IS_VLSI); - } - } - } else { - for (i = 0; i < 8; i += 2) { - if (sockets && !extra_sockets && (i == 4)) - break; - port = i365_base + 2*(i>>2); - sock = (i & 3); - id = identify(port, sock); - if (id < 0) continue; - - for (j = ns = 0; j < 2; j++) { - /* Does the socket exist? */ - if ((ignore == i+j) || (identify(port, sock+j) < 0)) - continue; - /* Check for bad socket decode */ - for (k = 0; k <= sockets; k++) - i365_set(k, I365_MEM(0)+I365_W_OFF, k); - for (k = 0; k <= sockets; k++) - if (i365_get(k, I365_MEM(0)+I365_W_OFF) != k) - break; - if (k <= sockets) break; - add_socket(port, sock+j, id); ns++; - } - if (ns != 0) add_pcic(ns, id); + if (!request_region(i365_base, 2, "i82365")) { + if (sockets == 0) + printk("port conflict at %#lx\n", i365_base); + return; + } + + id = identify(i365_base, 0); + if ((id == IS_I82365DF) && (identify(i365_base, 1) != id)) { + for (i = 0; i < 4; i++) { + if (i == ignore) + continue; + port = i365_base + ((i & 1) << 2) + ((i & 2) << 1); + sock = (i & 1) << 1; + if (identify(port, sock) == IS_I82365DF) { + add_socket(port, sock, IS_VLSI); + add_pcic(1, IS_VLSI); + } + } + } else { + for (i = 0; i < 8; i += 2) { + if (sockets && !extra_sockets && (i == 4)) + break; + port = i365_base + 2 * (i >> 2); + sock = (i & 3); + id = identify(port, sock); + if (id < 0) + continue; + + for (j = ns = 0; j < 2; j++) { + /* Does the socket exist? */ + if ((ignore == i + j) + || (identify(port, sock + j) < 0)) + continue; + /* Check for bad socket decode */ + for (k = 0; k <= sockets; k++) + i365_set(k, I365_MEM(0) + I365_W_OFF, + k); + for (k = 0; k <= sockets; k++) + if (i365_get + (k, I365_MEM(0) + I365_W_OFF) != k) + break; + if (k <= sockets) + break; + add_socket(port, sock + j, id); + ns++; + } + if (ns != 0) + add_pcic(ns, id); + } } - } } /*====================================================================*/ -static irqreturn_t pcic_interrupt(int irq, void *dev, - struct pt_regs *regs) +static irqreturn_t pcic_interrupt(int irq, void *dev, struct pt_regs *regs) { - int i, j, csc; - u_int events, active; - u_long flags = 0; - int handled = 0; - - debug(4, "pcic_interrupt(%d)\n", irq); - - for (j = 0; j < 20; j++) { - active = 0; - for (i = 0; i < sockets; i++) { - if (socket[i].cs_irq != irq) - continue; - handled = 1; - ISA_LOCK(i, flags); - csc = i365_get(i, I365_CSC); - if ((csc == 0) || (i365_get(i, I365_IDENT) & 0x70)) { - ISA_UNLOCK(i, flags); - continue; - } - events = (csc & I365_CSC_DETECT) ? SS_DETECT : 0; - - if (i365_get(i, I365_INTCTL) & I365_PC_IOCARD) - events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0; - else { - events |= (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0; - events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0; - events |= (csc & I365_CSC_READY) ? SS_READY : 0; - } - ISA_UNLOCK(i, flags); - debug(2, "socket %d event 0x%02x\n", i, events); - - if (events) - pcmcia_parse_events(&socket[i].socket, events); - - active |= events; - } - if (!active) break; - } - if (j == 20) - printk(KERN_NOTICE "i82365: infinite loop in interrupt handler\n"); - - debug(4, "interrupt done\n"); - return IRQ_RETVAL(handled); -} /* pcic_interrupt */ + int i, j, csc; + u_int events, active; + u_long flags = 0; + int handled = 0; + + debug(4, "pcic_interrupt(%d)\n", irq); + + for (j = 0; j < 20; j++) { + active = 0; + for (i = 0; i < sockets; i++) { + if (socket[i].cs_irq != irq) + continue; + handled = 1; + ISA_LOCK(i, flags); + csc = i365_get(i, I365_CSC); + if ((csc == 0) || (i365_get(i, I365_IDENT) & 0x70)) { + ISA_UNLOCK(i, flags); + continue; + } + events = (csc & I365_CSC_DETECT) ? SS_DETECT : 0; + + if (i365_get(i, I365_INTCTL) & I365_PC_IOCARD) + events |= + (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0; + else { + events |= + (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0; + events |= + (csc & I365_CSC_BVD2) ? SS_BATWARN : 0; + events |= (csc & I365_CSC_READY) ? SS_READY : 0; + } + ISA_UNLOCK(i, flags); + debug(2, "socket %d event 0x%02x\n", i, events); + + if (events) + pcmcia_parse_events(&socket[i].socket, events); + + active |= events; + } + if (!active) + break; + } + if (j == 20) + printk(KERN_NOTICE + "i82365: infinite loop in interrupt handler\n"); + + debug(4, "interrupt done\n"); + return IRQ_RETVAL(handled); +} /* pcic_interrupt */ static void pcic_interrupt_wrapper(u_long data) { - pcic_interrupt(0, NULL, NULL); - poll_timer.expires = jiffies + poll_interval; - add_timer(&poll_timer); + pcic_interrupt(0, NULL, NULL); + poll_timer.expires = jiffies + poll_interval; + add_timer(&poll_timer); } /*====================================================================*/ -static int i365_get_status(u_short sock, u_int *value) +static int i365_get_status(u_short sock, u_int * value) { - u_int status; - - status = i365_get(sock, I365_STATUS); - *value = ((status & I365_CS_DETECT) == I365_CS_DETECT) - ? SS_DETECT : 0; - - if (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD) - *value |= (status & I365_CS_STSCHG) ? 0 : SS_STSCHG; - else { - *value |= (status & I365_CS_BVD1) ? 0 : SS_BATDEAD; - *value |= (status & I365_CS_BVD2) ? 0 : SS_BATWARN; - } - *value |= (status & I365_CS_WRPROT) ? SS_WRPROT : 0; - *value |= (status & I365_CS_READY) ? SS_READY : 0; - *value |= (status & I365_CS_POWERON) ? SS_POWERON : 0; - - if (socket[sock].type == IS_VG469) { - status = i365_get(sock, VG469_VSENSE); - if (socket[sock].psock & 1) { - *value |= (status & VG469_VSENSE_B_VS1) ? 0 : SS_3VCARD; - *value |= (status & VG469_VSENSE_B_VS2) ? 0 : SS_XVCARD; - } else { - *value |= (status & VG469_VSENSE_A_VS1) ? 0 : SS_3VCARD; - *value |= (status & VG469_VSENSE_A_VS2) ? 0 : SS_XVCARD; + u_int status; + + status = i365_get(sock, I365_STATUS); + *value = ((status & I365_CS_DETECT) == I365_CS_DETECT) + ? SS_DETECT : 0; + + if (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD) + *value |= (status & I365_CS_STSCHG) ? 0 : SS_STSCHG; + else { + *value |= (status & I365_CS_BVD1) ? 0 : SS_BATDEAD; + *value |= (status & I365_CS_BVD2) ? 0 : SS_BATWARN; + } + *value |= (status & I365_CS_WRPROT) ? SS_WRPROT : 0; + *value |= (status & I365_CS_READY) ? SS_READY : 0; + *value |= (status & I365_CS_POWERON) ? SS_POWERON : 0; + + if (socket[sock].type == IS_VG469) { + status = i365_get(sock, VG469_VSENSE); + if (socket[sock].psock & 1) { + *value |= (status & VG469_VSENSE_B_VS1) ? 0 : SS_3VCARD; + *value |= (status & VG469_VSENSE_B_VS2) ? 0 : SS_XVCARD; + } else { + *value |= (status & VG469_VSENSE_A_VS1) ? 0 : SS_3VCARD; + *value |= (status & VG469_VSENSE_A_VS2) ? 0 : SS_XVCARD; + } } - } - - debug(1, "GetStatus(%d) = %#4.4x\n", sock, *value); - return 0; -} /* i365_get_status */ + + debug(1, "GetStatus(%d) = %#4.4x\n", sock, *value); + return 0; +} /* i365_get_status */ /*====================================================================*/ -static int i365_set_socket(u_short sock, socket_state_t *state) +static int i365_set_socket(u_short sock, socket_state_t * state) { - struct i82365_socket *t = &socket[sock]; - u_char reg; - - debug(1, "SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, " - "io_irq %d, csc_mask %#2.2x)\n", sock, state->flags, - state->Vcc, state->Vpp, state->io_irq, state->csc_mask); - - /* First set global controller options */ - set_bridge_state(sock); - - /* IO card, RESET flag, IO interrupt */ - reg = t->intr; - reg |= state->io_irq; - reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET; - reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0; - i365_set(sock, I365_INTCTL, reg); - - reg = I365_PWR_NORESET; - if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO; - if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT; - - if (t->flags & IS_CIRRUS) { - if (state->Vpp != 0) { - if (state->Vpp == 120) - reg |= I365_VPP1_12V; - else if (state->Vpp == state->Vcc) - reg |= I365_VPP1_5V; - else return -EINVAL; - } - if (state->Vcc != 0) { - reg |= I365_VCC_5V; - if (state->Vcc == 33) - i365_bset(sock, PD67_MISC_CTL_1, PD67_MC1_VCC_3V); - else if (state->Vcc == 50) - i365_bclr(sock, PD67_MISC_CTL_1, PD67_MC1_VCC_3V); - else return -EINVAL; - } - } else if (t->flags & IS_VG_PWR) { - if (state->Vpp != 0) { - if (state->Vpp == 120) - reg |= I365_VPP1_12V; - else if (state->Vpp == state->Vcc) - reg |= I365_VPP1_5V; - else return -EINVAL; - } - if (state->Vcc != 0) { - reg |= I365_VCC_5V; - if (state->Vcc == 33) - i365_bset(sock, VG469_VSELECT, VG469_VSEL_VCC); - else if (state->Vcc == 50) - i365_bclr(sock, VG469_VSELECT, VG469_VSEL_VCC); - else return -EINVAL; - } - } else if (t->flags & IS_DF_PWR) { - switch (state->Vcc) { - case 0: break; - case 33: reg |= I365_VCC_3V; break; - case 50: reg |= I365_VCC_5V; break; - default: return -EINVAL; - } - switch (state->Vpp) { - case 0: break; - case 50: reg |= I365_VPP1_5V; break; - case 120: reg |= I365_VPP1_12V; break; - default: return -EINVAL; - } - } else { - switch (state->Vcc) { - case 0: break; - case 50: reg |= I365_VCC_5V; break; - default: return -EINVAL; - } - switch (state->Vpp) { - case 0: break; - case 50: reg |= I365_VPP1_5V | I365_VPP2_5V; break; - case 120: reg |= I365_VPP1_12V | I365_VPP2_12V; break; - default: return -EINVAL; + struct i82365_socket *t = &socket[sock]; + u_char reg; + + debug(1, "SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, " + "io_irq %d, csc_mask %#2.2x)\n", sock, state->flags, + state->Vcc, state->Vpp, state->io_irq, state->csc_mask); + + /* First set global controller options */ + set_bridge_state(sock); + + /* IO card, RESET flag, IO interrupt */ + reg = t->intr; + reg |= state->io_irq; + reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET; + reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0; + i365_set(sock, I365_INTCTL, reg); + + reg = I365_PWR_NORESET; + if (state->flags & SS_PWR_AUTO) + reg |= I365_PWR_AUTO; + if (state->flags & SS_OUTPUT_ENA) + reg |= I365_PWR_OUT; + + if (t->flags & IS_CIRRUS) { + if (state->Vpp != 0) { + if (state->Vpp == 120) + reg |= I365_VPP1_12V; + else if (state->Vpp == state->Vcc) + reg |= I365_VPP1_5V; + else + return -EINVAL; + } + if (state->Vcc != 0) { + reg |= I365_VCC_5V; + if (state->Vcc == 33) + i365_bset(sock, PD67_MISC_CTL_1, + PD67_MC1_VCC_3V); + else if (state->Vcc == 50) + i365_bclr(sock, PD67_MISC_CTL_1, + PD67_MC1_VCC_3V); + else + return -EINVAL; + } + } else if (t->flags & IS_VG_PWR) { + if (state->Vpp != 0) { + if (state->Vpp == 120) + reg |= I365_VPP1_12V; + else if (state->Vpp == state->Vcc) + reg |= I365_VPP1_5V; + else + return -EINVAL; + } + if (state->Vcc != 0) { + reg |= I365_VCC_5V; + if (state->Vcc == 33) + i365_bset(sock, VG469_VSELECT, VG469_VSEL_VCC); + else if (state->Vcc == 50) + i365_bclr(sock, VG469_VSELECT, VG469_VSEL_VCC); + else + return -EINVAL; + } + } else if (t->flags & IS_DF_PWR) { + switch (state->Vcc) { + case 0: + break; + case 33: + reg |= I365_VCC_3V; + break; + case 50: + reg |= I365_VCC_5V; + break; + default: + return -EINVAL; + } + switch (state->Vpp) { + case 0: + break; + case 50: + reg |= I365_VPP1_5V; + break; + case 120: + reg |= I365_VPP1_12V; + break; + default: + return -EINVAL; + } + } else { + switch (state->Vcc) { + case 0: + break; + case 50: + reg |= I365_VCC_5V; + break; + default: + return -EINVAL; + } + switch (state->Vpp) { + case 0: + break; + case 50: + reg |= I365_VPP1_5V | I365_VPP2_5V; + break; + case 120: + reg |= I365_VPP1_12V | I365_VPP2_12V; + break; + default: + return -EINVAL; + } + } + + if (reg != i365_get(sock, I365_POWER)) + i365_set(sock, I365_POWER, reg); + + /* Chipset-specific functions */ + if (t->flags & IS_CIRRUS) { + /* Speaker control */ + i365_bflip(sock, PD67_MISC_CTL_1, PD67_MC1_SPKR_ENA, + state->flags & SS_SPKR_ENA); + } + + /* Card status change interrupt mask */ + reg = t->cs_irq << 4; + if (state->csc_mask & SS_DETECT) + reg |= I365_CSC_DETECT; + if (state->flags & SS_IOCARD) { + if (state->csc_mask & SS_STSCHG) + reg |= I365_CSC_STSCHG; + } else { + if (state->csc_mask & SS_BATDEAD) + reg |= I365_CSC_BVD1; + if (state->csc_mask & SS_BATWARN) + reg |= I365_CSC_BVD2; + if (state->csc_mask & SS_READY) + reg |= I365_CSC_READY; } - } - - if (reg != i365_get(sock, I365_POWER)) - i365_set(sock, I365_POWER, reg); + i365_set(sock, I365_CSCINT, reg); + i365_get(sock, I365_CSC); - /* Chipset-specific functions */ - if (t->flags & IS_CIRRUS) { - /* Speaker control */ - i365_bflip(sock, PD67_MISC_CTL_1, PD67_MC1_SPKR_ENA, - state->flags & SS_SPKR_ENA); - } - - /* Card status change interrupt mask */ - reg = t->cs_irq << 4; - if (state->csc_mask & SS_DETECT) reg |= I365_CSC_DETECT; - if (state->flags & SS_IOCARD) { - if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG; - } else { - if (state->csc_mask & SS_BATDEAD) reg |= I365_CSC_BVD1; - if (state->csc_mask & SS_BATWARN) reg |= I365_CSC_BVD2; - if (state->csc_mask & SS_READY) reg |= I365_CSC_READY; - } - i365_set(sock, I365_CSCINT, reg); - i365_get(sock, I365_CSC); - - return 0; -} /* i365_set_socket */ + return 0; +} /* i365_set_socket */ /*====================================================================*/ static int i365_set_io_map(u_short sock, struct pccard_io_map *io) { - u_char map, ioctl; - - debug(1, "SetIOMap(%d, %d, %#2.2x, %d ns, " - "%#lx-%#lx)\n", sock, io->map, io->flags, - io->speed, io->start, io->stop); - map = io->map; - if ((map > 1) || (io->start > 0xffff) || (io->stop > 0xffff) || - (io->stop < io->start)) return -EINVAL; - /* Turn off the window before changing anything */ - if (i365_get(sock, I365_ADDRWIN) & I365_ENA_IO(map)) - i365_bclr(sock, I365_ADDRWIN, I365_ENA_IO(map)); - i365_set_pair(sock, I365_IO(map)+I365_W_START, io->start); - i365_set_pair(sock, I365_IO(map)+I365_W_STOP, io->stop); - ioctl = i365_get(sock, I365_IOCTL) & ~I365_IOCTL_MASK(map); - if (io->speed) ioctl |= I365_IOCTL_WAIT(map); - if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map); - if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map); - if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map); - i365_set(sock, I365_IOCTL, ioctl); - /* Turn on the window if necessary */ - if (io->flags & MAP_ACTIVE) - i365_bset(sock, I365_ADDRWIN, I365_ENA_IO(map)); - return 0; -} /* i365_set_io_map */ + u_char map, ioctl; + + debug(1, "SetIOMap(%d, %d, %#2.2x, %d ns, " + "%#lx-%#lx)\n", sock, io->map, io->flags, + io->speed, io->start, io->stop); + map = io->map; + if ((map > 1) || (io->start > 0xffff) || (io->stop > 0xffff) || + (io->stop < io->start)) + return -EINVAL; + /* Turn off the window before changing anything */ + if (i365_get(sock, I365_ADDRWIN) & I365_ENA_IO(map)) + i365_bclr(sock, I365_ADDRWIN, I365_ENA_IO(map)); + i365_set_pair(sock, I365_IO(map) + I365_W_START, io->start); + i365_set_pair(sock, I365_IO(map) + I365_W_STOP, io->stop); + ioctl = i365_get(sock, I365_IOCTL) & ~I365_IOCTL_MASK(map); + if (io->speed) + ioctl |= I365_IOCTL_WAIT(map); + if (io->flags & MAP_0WS) + ioctl |= I365_IOCTL_0WS(map); + if (io->flags & MAP_16BIT) + ioctl |= I365_IOCTL_16BIT(map); + if (io->flags & MAP_AUTOSZ) + ioctl |= I365_IOCTL_IOCS16(map); + i365_set(sock, I365_IOCTL, ioctl); + /* Turn on the window if necessary */ + if (io->flags & MAP_ACTIVE) + i365_bset(sock, I365_ADDRWIN, I365_ENA_IO(map)); + return 0; +} /* i365_set_io_map */ /*====================================================================*/ static int i365_set_mem_map(u_short sock, struct pccard_mem_map *mem) { - u_short base, i; - u_char map; - - debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, %#lx-%#lx, " - "%#x)\n", sock, mem->map, mem->flags, mem->speed, - mem->res->start, mem->res->end, mem->card_start); - - map = mem->map; - if ((map > 4) || (mem->card_start > 0x3ffffff) || - (mem->res->start > mem->res->end) || (mem->speed > 1000)) - return -EINVAL; - if ((mem->res->start > 0xffffff) || (mem->res->end > 0xffffff)) - return -EINVAL; - - /* Turn off the window before changing anything */ - if (i365_get(sock, I365_ADDRWIN) & I365_ENA_MEM(map)) - i365_bclr(sock, I365_ADDRWIN, I365_ENA_MEM(map)); - - base = I365_MEM(map); - i = (mem->res->start >> 12) & 0x0fff; - if (mem->flags & MAP_16BIT) i |= I365_MEM_16BIT; - if (mem->flags & MAP_0WS) i |= I365_MEM_0WS; - i365_set_pair(sock, base+I365_W_START, i); - - i = (mem->res->end >> 12) & 0x0fff; - switch (to_cycles(mem->speed)) { - case 0: break; - case 1: i |= I365_MEM_WS0; break; - case 2: i |= I365_MEM_WS1; break; - default: i |= I365_MEM_WS1 | I365_MEM_WS0; break; - } - i365_set_pair(sock, base+I365_W_STOP, i); - - i = ((mem->card_start - mem->res->start) >> 12) & 0x3fff; - if (mem->flags & MAP_WRPROT) i |= I365_MEM_WRPROT; - if (mem->flags & MAP_ATTRIB) i |= I365_MEM_REG; - i365_set_pair(sock, base+I365_W_OFF, i); - - /* Turn on the window if necessary */ - if (mem->flags & MAP_ACTIVE) - i365_bset(sock, I365_ADDRWIN, I365_ENA_MEM(map)); - return 0; -} /* i365_set_mem_map */ + u_short base, i; + u_char map; -#if 0 /* driver model ordering issue */ + debug(1, "SetMemMap(%d, %d, %#2.2x, %d ns, %#lx-%#lx, " + "%#x)\n", sock, mem->map, mem->flags, mem->speed, + mem->res->start, mem->res->end, mem->card_start); + + map = mem->map; + if ((map > 4) || (mem->card_start > 0x3ffffff) || + (mem->res->start > mem->res->end) || (mem->speed > 1000)) + return -EINVAL; + if ((mem->res->start > 0xffffff) || (mem->res->end > 0xffffff)) + return -EINVAL; + + /* Turn off the window before changing anything */ + if (i365_get(sock, I365_ADDRWIN) & I365_ENA_MEM(map)) + i365_bclr(sock, I365_ADDRWIN, I365_ENA_MEM(map)); + + base = I365_MEM(map); + i = (mem->res->start >> 12) & 0x0fff; + if (mem->flags & MAP_16BIT) + i |= I365_MEM_16BIT; + if (mem->flags & MAP_0WS) + i |= I365_MEM_0WS; + i365_set_pair(sock, base + I365_W_START, i); + + i = (mem->res->end >> 12) & 0x0fff; + switch (to_cycles(mem->speed)) { + case 0: + break; + case 1: + i |= I365_MEM_WS0; + break; + case 2: + i |= I365_MEM_WS1; + break; + default: + i |= I365_MEM_WS1 | I365_MEM_WS0; + break; + } + i365_set_pair(sock, base + I365_W_STOP, i); + + i = ((mem->card_start - mem->res->start) >> 12) & 0x3fff; + if (mem->flags & MAP_WRPROT) + i |= I365_MEM_WRPROT; + if (mem->flags & MAP_ATTRIB) + i |= I365_MEM_REG; + i365_set_pair(sock, base + I365_W_OFF, i); + + /* Turn on the window if necessary */ + if (mem->flags & MAP_ACTIVE) + i365_bset(sock, I365_ADDRWIN, I365_ENA_MEM(map)); + return 0; +} /* i365_set_mem_map */ + +#if 0 /* driver model ordering issue */ /*====================================================================== Routines for accessing socket information and register dumps via @@ -1134,14 +1217,16 @@ static int i365_set_mem_map(u_short sock static ssize_t show_info(struct class_device *class_dev, char *buf) { - struct i82365_socket *s = container_of(class_dev, struct i82365_socket, socket.dev); - return sprintf(buf, "type: %s\npsock: %d\n", - pcic[s->type].name, s->psock); + struct i82365_socket *s = + container_of(class_dev, struct i82365_socket, socket.dev); + return sprintf(buf, "type: %s\npsock: %d\n", pcic[s->type].name, + s->psock); } static ssize_t show_exca(struct class_device *class_dev, char *buf) { - struct i82365_socket *s = container_of(class_dev, struct i82365_socket, socket.dev); + struct i82365_socket *s = + container_of(class_dev, struct i82365_socket, socket.dev); unsigned short sock; int i; ssize_t ret = 0; @@ -1152,8 +1237,8 @@ static ssize_t show_exca(struct class_de ISA_LOCK(sock, flags); for (i = 0; i < 0x40; i += 4) { ret += sprintf(buf, "%02x %02x %02x %02x%s", - i365_get(sock,i), i365_get(sock,i+1), - i365_get(sock,i+2), i365_get(sock,i+3), + i365_get(sock, i), i365_get(sock, i + 1), + i365_get(sock, i + 2), i365_get(sock, i + 3), ((i % 16) == 12) ? "\n" : " "); buf += ret; } @@ -1178,11 +1263,11 @@ static CLASS_DEVICE_ATTR(info, S_IRUGO, spin_unlock_irqrestore(&isa_lock, flags); \ return retval; \ } while (0) - -static int pcic_get_status(struct pcmcia_socket *s, u_int *value) +static int pcic_get_status(struct pcmcia_socket *s, u_int * value) { - unsigned int sock = container_of(s, struct i82365_socket, socket)->number; + unsigned int sock = + container_of(s, struct i82365_socket, socket)->number; if (socket[sock].flags & IS_ALIVE) { *value = 0; @@ -1192,9 +1277,10 @@ static int pcic_get_status(struct pcmcia LOCKED(i365_get_status(sock, value)); } -static int pcic_set_socket(struct pcmcia_socket *s, socket_state_t *state) +static int pcic_set_socket(struct pcmcia_socket *s, socket_state_t * state) { - unsigned int sock = container_of(s, struct i82365_socket, socket)->number; + unsigned int sock = + container_of(s, struct i82365_socket, socket)->number; if (socket[sock].flags & IS_ALIVE) return -EINVAL; @@ -1204,7 +1290,8 @@ static int pcic_set_socket(struct pcmcia static int pcic_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) { - unsigned int sock = container_of(s, struct i82365_socket, socket)->number; + unsigned int sock = + container_of(s, struct i82365_socket, socket)->number; if (socket[sock].flags & IS_ALIVE) return -EINVAL; @@ -1213,7 +1300,8 @@ static int pcic_set_io_map(struct pcmcia static int pcic_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem) { - unsigned int sock = container_of(s, struct i82365_socket, socket)->number; + unsigned int sock = + container_of(s, struct i82365_socket, socket)->number; if (socket[sock].flags & IS_ALIVE) return -EINVAL; @@ -1223,9 +1311,9 @@ static int pcic_set_mem_map(struct pcmci static int pcic_init(struct pcmcia_socket *s) { int i; - struct resource res = { .start = 0, .end = 0x1000 }; + struct resource res = {.start = 0,.end = 0x1000 }; pccard_io_map io = { 0, 0, 0, 0, 1 }; - pccard_mem_map mem = { .res = &res, }; + pccard_mem_map mem = {.res = &res, }; for (i = 0; i < 2; i++) { io.map = i; @@ -1239,11 +1327,11 @@ static int pcic_init(struct pcmcia_socke } static struct pccard_operations pcic_operations = { - .init = pcic_init, - .get_status = pcic_get_status, - .set_socket = pcic_set_socket, - .set_io_map = pcic_set_io_map, - .set_mem_map = pcic_set_mem_map, + .init = pcic_init, + .get_status = pcic_get_status, + .set_socket = pcic_set_socket, + .set_io_map = pcic_set_io_map, + .set_mem_map = pcic_set_mem_map, }; /*====================================================================*/ @@ -1259,99 +1347,100 @@ static struct platform_device *i82365_de static int __init init_i82365(void) { - int i, ret; + int i, ret; - ret = driver_register(&i82365_driver); - if (ret) - return ret; + ret = driver_register(&i82365_driver); + if (ret) + return ret; - i82365_device = platform_device_alloc("i82365", 0); - if (i82365_device) { - ret = platform_device_add(i82365_device); - if (ret) - platform_device_put(i82365_device); - } else - ret = -ENOMEM; + i82365_device = platform_device_alloc("i82365", 0); + if (i82365_device) { + ret = platform_device_add(i82365_device); + if (ret) + platform_device_put(i82365_device); + } else + ret = -ENOMEM; - if (ret) { - driver_unregister(&i82365_driver); - return ret; - } + if (ret) { + driver_unregister(&i82365_driver); + return ret; + } - printk(KERN_INFO "Intel ISA PCIC probe: "); - sockets = 0; + printk(KERN_INFO "Intel ISA PCIC probe: "); + sockets = 0; - isa_probe(); + isa_probe(); - if (sockets == 0) { - printk("not found.\n"); - platform_device_unregister(i82365_device); - release_region(i365_base, 2); - driver_unregister(&i82365_driver); - return -ENODEV; - } + if (sockets == 0) { + printk("not found.\n"); + platform_device_unregister(i82365_device); + release_region(i365_base, 2); + driver_unregister(&i82365_driver); + return -ENODEV; + } - /* Set up interrupt handler(s) */ - if (grab_irq != 0) - request_irq(cs_irq, pcic_interrupt, 0, "i82365", pcic_interrupt); - - /* register sockets with the pcmcia core */ - for (i = 0; i < sockets; i++) { - socket[i].socket.dev.dev = &i82365_device->dev; - socket[i].socket.ops = &pcic_operations; - socket[i].socket.resource_ops = &pccard_nonstatic_ops; - socket[i].socket.owner = THIS_MODULE; - socket[i].number = i; - ret = pcmcia_register_socket(&socket[i].socket); - if (!ret) - socket[i].flags |= IS_REGISTERED; - -#if 0 /* driver model ordering issue */ - class_device_create_file(&socket[i].socket.dev, - &class_device_attr_info); - class_device_create_file(&socket[i].socket.dev, - &class_device_attr_exca); + /* Set up interrupt handler(s) */ + if (grab_irq != 0) + request_irq(cs_irq, pcic_interrupt, 0, "i82365", + pcic_interrupt); + + /* register sockets with the pcmcia core */ + for (i = 0; i < sockets; i++) { + socket[i].socket.dev.dev = &i82365_device->dev; + socket[i].socket.ops = &pcic_operations; + socket[i].socket.resource_ops = &pccard_nonstatic_ops; + socket[i].socket.owner = THIS_MODULE; + socket[i].number = i; + ret = pcmcia_register_socket(&socket[i].socket); + if (!ret) + socket[i].flags |= IS_REGISTERED; + +#if 0 /* driver model ordering issue */ + class_device_create_file(&socket[i].socket.dev, + &class_device_attr_info); + class_device_create_file(&socket[i].socket.dev, + &class_device_attr_exca); #endif - } + } - /* Finally, schedule a polling interrupt */ - if (poll_interval != 0) { - poll_timer.function = pcic_interrupt_wrapper; - poll_timer.data = 0; - init_timer(&poll_timer); - poll_timer.expires = jiffies + poll_interval; - add_timer(&poll_timer); - } - - return 0; - -} /* init_i82365 */ + /* Finally, schedule a polling interrupt */ + if (poll_interval != 0) { + poll_timer.function = pcic_interrupt_wrapper; + poll_timer.data = 0; + init_timer(&poll_timer); + poll_timer.expires = jiffies + poll_interval; + add_timer(&poll_timer); + } + + return 0; + +} /* init_i82365 */ static void __exit exit_i82365(void) { - int i; + int i; - for (i = 0; i < sockets; i++) { - if (socket[i].flags & IS_REGISTERED) - pcmcia_unregister_socket(&socket[i].socket); - } - platform_device_unregister(i82365_device); - if (poll_interval != 0) - del_timer_sync(&poll_timer); - if (grab_irq != 0) - free_irq(cs_irq, pcic_interrupt); - for (i = 0; i < sockets; i++) { - /* Turn off all interrupt sources! */ - i365_set(i, I365_CSCINT, 0); - release_region(socket[i].ioaddr, 2); - } - release_region(i365_base, 2); + for (i = 0; i < sockets; i++) { + if (socket[i].flags & IS_REGISTERED) + pcmcia_unregister_socket(&socket[i].socket); + } + platform_device_unregister(i82365_device); + if (poll_interval != 0) + del_timer_sync(&poll_timer); + if (grab_irq != 0) + free_irq(cs_irq, pcic_interrupt); + for (i = 0; i < sockets; i++) { + /* Turn off all interrupt sources! */ + i365_set(i, I365_CSCINT, 0); + release_region(socket[i].ioaddr, 2); + } + release_region(i365_base, 2); #ifdef CONFIG_PNP - if (i82365_pnpdev) - pnp_disable_dev(i82365_pnpdev); + if (i82365_pnpdev) + pnp_disable_dev(i82365_pnpdev); #endif - driver_unregister(&i82365_driver); -} /* exit_i82365 */ + driver_unregister(&i82365_driver); +} /* exit_i82365 */ module_init(init_i82365); module_exit(exit_i82365); --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c @@ -298,11 +298,10 @@ static struct rio_dev *rio_setup_device( struct rio_switch *rswitch; int result, rdid; - rdev = kmalloc(sizeof(struct rio_dev), GFP_KERNEL); + rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL); if (!rdev) goto out; - memset(rdev, 0, sizeof(struct rio_dev)); rdev->net = net; rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR, &result); @@ -785,9 +784,8 @@ static struct rio_net __devinit *rio_all { struct rio_net *net; - net = kmalloc(sizeof(struct rio_net), GFP_KERNEL); + net = kzalloc(sizeof(struct rio_net), GFP_KERNEL); if (net) { - memset(net, 0, sizeof(struct rio_net)); INIT_LIST_HEAD(&net->node); INIT_LIST_HEAD(&net->devices); INIT_LIST_HEAD(&net->mports); --- a/drivers/s390/net/lcs.c +++ b/drivers/s390/net/lcs.c @@ -1638,10 +1638,11 @@ lcs_detect(struct lcs_card *card) static int lcs_resetcard(struct lcs_card *card) { - int retries; + unsigned long end_time; LCS_DBF_TEXT(2, trace, "rescard"); - for (retries = 0; retries < 10; retries++) { + end_time = jiffies + msecs_to_jiffies(30000); + while (time_before(jiffies, end_time)) { if (lcs_detect(card) == 0) { netif_wake_queue(card->dev); card->state = DEV_STATE_UP; --- a/drivers/sbus/char/bbc_envctrl.c +++ b/drivers/sbus/char/bbc_envctrl.c @@ -485,11 +485,10 @@ static int kenvctrld(void *__unused) static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx) { - struct bbc_cpu_temperature *tp = kmalloc(sizeof(*tp), GFP_KERNEL); + struct bbc_cpu_temperature *tp = kzalloc(sizeof(*tp), GFP_KERNEL); if (!tp) return; - memset(tp, 0, sizeof(*tp)); tp->client = bbc_i2c_attach(echild); if (!tp->client) { kfree(tp); @@ -531,11 +530,10 @@ static void attach_one_temp(struct linux static void attach_one_fan(struct linux_ebus_child *echild, int fan_idx) { - struct bbc_fan_control *fp = kmalloc(sizeof(*fp), GFP_KERNEL); + struct bbc_fan_control *fp = kzalloc(sizeof(*fp), GFP_KERNEL); if (!fp) return; - memset(fp, 0, sizeof(*fp)); fp->client = bbc_i2c_attach(echild); if (!fp->client) { kfree(fp); --- a/drivers/sbus/char/bbc_i2c.c +++ b/drivers/sbus/char/bbc_i2c.c @@ -155,10 +155,9 @@ struct bbc_i2c_client *bbc_i2c_attach(st if (!bp) return NULL; - client = kmalloc(sizeof(*client), GFP_KERNEL); + client = kzalloc(sizeof(*client), GFP_KERNEL); if (!client) return NULL; - memset(client, 0, sizeof(*client)); client->bp = bp; client->echild = echild; client->bus = echild->resource[0].start; @@ -181,12 +180,13 @@ void bbc_i2c_detach(struct bbc_i2c_clien static int wait_for_pin(struct bbc_i2c_bus *bp, u8 *status) { DECLARE_WAITQUEUE(wait, current); - int limit = 32; int ret = 1; + unsigned long end_time; bp->waiting = 1; add_wait_queue(&bp->wq, &wait); - while (limit-- > 0) { + end_time = jiffies + msecs_to_jiffies(32 * 250); + while (time_before(jiffies, end_time)) { u8 val; set_current_state(TASK_INTERRUPTIBLE); @@ -356,13 +356,12 @@ static void __init reset_one_i2c(struct static int __init attach_one_i2c(struct linux_ebus_device *edev, int index) { - struct bbc_i2c_bus *bp = kmalloc(sizeof(*bp), GFP_KERNEL); + struct bbc_i2c_bus *bp = kzalloc(sizeof(*bp), GFP_KERNEL); struct linux_ebus_child *echild; int entry; if (!bp) return -ENOMEM; - memset(bp, 0, sizeof(*bp)); bp->i2c_control_regs = ioremap(edev->resource[0].start, 0x2); if (!bp->i2c_control_regs) --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c @@ -87,9 +87,8 @@ static int copyin(struct openpromio __us if (bufsize > OPROMMAXPARAM) bufsize = OPROMMAXPARAM; - if (!(*opp_p = kmalloc(sizeof(int) + bufsize + 1, GFP_KERNEL))) + if (!(*opp_p = kzalloc(sizeof(int) + bufsize + 1, GFP_KERNEL))) return -ENOMEM; - memset(*opp_p, 0, sizeof(int) + bufsize + 1); if (copy_from_user(&(*opp_p)->oprom_array, &info->oprom_array, bufsize)) { @@ -107,10 +106,9 @@ static int getstrings(struct openpromio if (!info || !opp_p) return -EFAULT; - if (!(*opp_p = kmalloc(sizeof(int) + OPROMMAXPARAM + 1, GFP_KERNEL))) + if (!(*opp_p = kzalloc(sizeof(int) + OPROMMAXPARAM + 1, GFP_KERNEL))) return -ENOMEM; - memset(*opp_p, 0, sizeof(int) + OPROMMAXPARAM + 1); (*opp_p)->oprom_size = 0; n = bufsize = 0; --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c @@ -264,11 +264,10 @@ static int vfc_debug(struct vfc_dev *dev if (copy_from_user(&inout, argp, sizeof(inout))) return -EFAULT; - buffer = kmalloc(inout.len, GFP_KERNEL); + buffer = kzalloc(inout.len, GFP_KERNEL); if (buffer == NULL) return -ENOMEM; - memset(buffer,0,inout.len); vfc_lock_device(dev); inout.ret= vfc_i2c_recvbuf(dev,inout.addr & 0xff @@ -663,12 +662,9 @@ static int vfc_probe(void) if (!cards) return -ENODEV; - vfc_dev_lst = (struct vfc_dev **)kmalloc(sizeof(struct vfc_dev *) * - (cards+1), - GFP_KERNEL); + vfc_dev_lst = kcalloc((cards+1), sizeof(struct vfc_dev *), GFP_KERNEL); if (vfc_dev_lst == NULL) return -ENOMEM; - memset(vfc_dev_lst, 0, sizeof(struct vfc_dev *) * (cards + 1)); vfc_dev_lst[cards] = NULL; ret = register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops); --- a/drivers/scsi/53c700.h +++ b/drivers/scsi/53c700.h @@ -472,8 +472,7 @@ NCR_700_readl(struct Scsi_Host *host, __ ioread32(hostdata->base + reg); #if 1 /* sanity check the register */ - if((reg & 0x3) != 0) - BUG(); + BUG_ON((reg & 0x3) != 0); #endif return value; @@ -496,8 +495,7 @@ NCR_700_writel(__u32 value, struct Scsi_ #if 1 /* sanity check the register */ - if((reg & 0x3) != 0) - BUG(); + BUG_ON((reg & 0x3) != 0); #endif bEBus ? iowrite32be(value, hostdata->base + reg): --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -389,8 +389,7 @@ static void get_container_name_callback( scsicmd = (struct scsi_cmnd *) context; dprintk((KERN_DEBUG "get_container_name_callback[cpu %d]: t = %ld.\n", smp_processor_id(), jiffies)); - if (fibptr == NULL) - BUG(); + BUG_ON(fibptr == NULL); get_name_reply = (struct aac_get_name_resp *) fib_data(fibptr); /* Failure is irrelevant, using default value instead */ @@ -946,8 +945,7 @@ static void io_callback(void *context, s smp_processor_id(), (unsigned long long)lba, jiffies); } - if (fibptr == NULL) - BUG(); + BUG_ON(fibptr == NULL); if(scsicmd->use_sg) pci_unmap_sg(dev->pdev, @@ -1082,8 +1080,7 @@ static int aac_read(struct scsi_cmnd * s aac_build_sgraw(scsicmd, &readcmd->sg); fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentryraw)); - if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) - BUG(); + BUG_ON(fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ @@ -1249,8 +1246,7 @@ static int aac_write(struct scsi_cmnd * aac_build_sgraw(scsicmd, &writecmd->sg); fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentryraw)); - if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) - BUG(); + BUG_ON(fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))); /* * Now send the Fib to the adapter */ @@ -1892,8 +1888,7 @@ static void aac_srb_callback(void *conte scsicmd = (struct scsi_cmnd *) context; dev = (struct aac_dev *)scsicmd->device->host->hostdata; - if (fibptr == NULL) - BUG(); + BUG_ON(fibptr == NULL); srbreply = (struct aac_srb_reply *) fib_data(fibptr); --- a/drivers/scsi/aacraid/commsup.c +++ b/drivers/scsi/aacraid/commsup.c @@ -229,9 +229,8 @@ void aac_fib_init(struct fib *fibptr) static void fib_dealloc(struct fib * fibptr) { struct hw_fib *hw_fib = fibptr->hw_fib; - if(hw_fib->header.StructType != FIB_MAGIC) - BUG(); - hw_fib->header.XferState = 0; + BUG_ON(hw_fib->header.StructType != FIB_MAGIC); + hw_fib->header.XferState = 0; } /* @@ -534,9 +533,8 @@ int aac_fib_send(u16 command, struct fib } } else down(&fibptr->event_wait); - if(fibptr->done == 0) - BUG(); - + BUG_ON(fibptr->done == 0); + if((fibptr->flags & FIB_CONTEXT_FLAG_TIMED_OUT)){ return -ETIMEDOUT; } else { --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -973,7 +973,7 @@ static int ahci_host_init(struct ata_pro struct pci_dev *pdev = to_pci_dev(probe_ent->dev); void __iomem *mmio = probe_ent->mmio_base; u32 tmp, cap_save; - unsigned int i, j, using_dac; + unsigned int i, using_dac; int rc; void __iomem *port_mmio; @@ -1049,6 +1049,7 @@ static int ahci_host_init(struct ata_pro } for (i = 0; i < probe_ent->n_ports; i++) { + unsigned long end_time; #if 0 /* BIOSen initialize this incorrectly */ if (!(hpriv->port_map & (1 << i))) continue; @@ -1078,13 +1079,12 @@ static int ahci_host_init(struct ata_pro writel(PORT_CMD_SPIN_UP, port_mmio + PORT_CMD); - j = 0; - while (j < 100) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time)) { msleep(10); tmp = readl(port_mmio + PORT_SCR_STAT); if ((tmp & 0xf) == 0x3) break; - j++; } tmp = readl(port_mmio + PORT_SCR_ERR); --- a/drivers/scsi/arm/queue.c +++ b/drivers/scsi/arm/queue.c @@ -118,8 +118,7 @@ int __queue_add(Queue_t *queue, Scsi_Cmn list_del(l); q = list_entry(l, QE_t, list); - if (BAD_MAGIC(q, QUEUE_MAGIC_FREE)) - BUG(); + BUG_ON(BAD_MAGIC(q, QUEUE_MAGIC_FREE)); SET_MAGIC(q, QUEUE_MAGIC_USED); q->SCpnt = SCpnt; @@ -144,8 +143,7 @@ static Scsi_Cmnd *__queue_remove(Queue_t */ list_del(ent); q = list_entry(ent, QE_t, list); - if (BAD_MAGIC(q, QUEUE_MAGIC_USED)) - BUG(); + BUG_ON(BAD_MAGIC(q, QUEUE_MAGIC_USED)); SET_MAGIC(q, QUEUE_MAGIC_FREE); list_add(ent, &queue->free); --- a/drivers/scsi/gdth_proc.c +++ b/drivers/scsi/gdth_proc.c @@ -3,6 +3,7 @@ */ #include +#include #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, --- a/drivers/scsi/ibmmca.c +++ b/drivers/scsi/ibmmca.c @@ -2243,8 +2243,7 @@ static int __ibmmca_host_reset(Scsi_Cmnd int host_index; unsigned long imm_command; - if (cmd == NULL) - BUG(); + BUG_ON(cmd == NULL); ticks = IM_RESET_DELAY * HZ; shpnt = cmd->device->host; --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -600,8 +600,7 @@ static ide_startstop_t idescsi_transfer_ "issuing a packet command\n"); return ide_do_reset (drive); } - if (HWGROUP(drive)->handler != NULL) - BUG(); + BUG_ON(HWGROUP(drive)->handler != NULL); /* Set the interrupt routine */ ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); /* Send the actual packet */ @@ -691,8 +690,7 @@ static ide_startstop_t idescsi_issue_pc set_bit(PC_DMA_OK, &pc->flags); if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) { - if (HWGROUP(drive)->handler != NULL) - BUG(); + BUG_ON(HWGROUP(drive)->handler != NULL); ide_set_handler(drive, &idescsi_transfer_pc, get_timeout(pc), idescsi_expiry); /* Issue the packet command */ --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -952,7 +953,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmn lpfc_sli_poll_fcp_ring (phba); spin_unlock_irq(phba->host->host_lock); - schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ); + ssleep(LPFC_ABORT_WAIT); spin_lock_irq(phba->host->host_lock); if (++loop_count > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT) @@ -1007,7 +1008,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { spin_unlock_irq(phba->host->host_lock); - schedule_timeout_uninterruptible(msecs_to_jiffies(500)); + msleep(500); spin_lock_irq(phba->host->host_lock); } if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE)) @@ -1062,7 +1063,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd loopcnt = 0; while(cnt) { spin_unlock_irq(phba->host->host_lock); - schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); + ssleep(LPFC_RESET_WAIT); spin_lock_irq(phba->host->host_lock); if (++loopcnt @@ -1167,7 +1168,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd loopcnt = 0; while(cnt) { spin_unlock_irq(phba->host->host_lock); - schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); + ssleep(LPFC_RESET_WAIT); spin_lock_irq(phba->host->host_lock); if (++loopcnt --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -2768,6 +2768,7 @@ mbox_post_sync_cmd(adapter_t *adapter, u mbox_t *mbox; uint8_t status; int i; + unsigned long end_time; mbox64 = raid_dev->mbox64; @@ -2799,25 +2800,27 @@ mbox_post_sync_cmd(adapter_t *adapter, u if (mbox->numstatus == 0xFF) { // status not yet available udelay(25); - for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) { + end_time = jiffies + msecs_to_jiffies(1000); + while (mbox->numstatus == 0xFF && time_before(jiffies, end_time)) { rmb(); msleep(1); } - if (i == 1000) { + if (time_after_eq(jiffies, end_time)) { con_log(CL_ANN, (KERN_NOTICE "megaraid mailbox: wait for FW to boot ")); + end_time = jiffies + msecs_to_jiffies(MBOX_RESET_WAIT * 1000); for (i = 0; (mbox->numstatus == 0xFF) && - (i < MBOX_RESET_WAIT); i++) { + time_before(jiffies, end_time); ++i) { rmb(); con_log(CL_ANN, ("\b\b\b\b\b[%03d]", MBOX_RESET_WAIT - i)); msleep(1000); } - if (i == MBOX_RESET_WAIT) { + if (time_after_eq(jiffies, end_time)) { con_log(CL_ANN, ( "\nmegaraid mailbox: status not available\n")); @@ -2832,12 +2835,13 @@ mbox_post_sync_cmd(adapter_t *adapter, u if (mbox->poll != 0x77) { udelay(25); - for (i = 0; (mbox->poll != 0x77) && (i < 1000); i++) { + end_time = jiffies + msecs_to_jiffies(1000); + while ((mbox->poll != 0x77) && time_before(jiffies, end_time)) { rmb(); msleep(1); } - if (i == 1000) { + if (time_after_eq(jiffies, end_time)) { con_log(CL_ANN, (KERN_WARNING "megaraid mailbox: could not get poll semaphore\n")); return -1; @@ -2851,12 +2855,13 @@ mbox_post_sync_cmd(adapter_t *adapter, u if (RDINDOOR(raid_dev) & 0x2) { udelay(25); - for (i = 0; (RDINDOOR(raid_dev) & 0x2) && (i < 1000); i++) { + end_time = jiffies + msecs_to_jiffies(1000); + while ((RDINDOOR(raid_dev) & 0x2) && time_before(jiffies, end_time)) { rmb(); msleep(1); } - if (i == 1000) { + if (time_after_eq(jiffies, end_time)) { con_log(CL_ANN, (KERN_WARNING "megaraid mailbox: could not acknowledge\n")); return -1; @@ -2947,16 +2952,19 @@ static int megaraid_busywait_mbox(mraid_device_t *raid_dev) { mbox_t *mbox = raid_dev->mbox; - int i = 0; + unsigned long end_time; if (mbox->busy) { udelay(25); - for (i = 0; mbox->busy && i < 1000; i++) + end_time = jiffies + msecs_to_jiffies(1000); + while (mbox->busy && time_before(jiffies, end_time)) msleep(1); } - if (i < 1000) return 0; - else return -1; + if (mbox->busy) + return -1; + else + return 0; } --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c @@ -308,8 +308,7 @@ megasas_disable_intr(struct megasas_regi static int megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd) { - int i; - u32 msecs = MFI_POLL_TIMEOUT_SECS * 1000; + unsigned long end_time; struct megasas_header *frame_hdr = &cmd->frame->hdr; @@ -324,7 +323,8 @@ megasas_issue_polled(struct megasas_inst /* * Wait for cmd_status to change */ - for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i++) { + end_time = jiffies + msecs_to_jiffies(MFI_POLL_TIMEOUT_SECS * 1000); + while ((frame_hdr->cmd_status == 0xff) && time_before(jiffies, end_time)) { rmb(); msleep(1); } @@ -822,9 +822,9 @@ static int megasas_slave_configure(struc static int megasas_wait_for_outstanding(struct megasas_instance *instance) { int i; - u32 wait_time = MEGASAS_RESET_WAIT_TIME; + unsigned long end_time = jiffies + msecs_to_jiffies(MEGASAS_RESET_WAIT_TIME * 1000); - for (i = 0; i < wait_time; i++) { + for (i = 0; time_before(jiffies, end_time); ++i) { if (!instance->fw_outstanding) break; @@ -1234,10 +1234,10 @@ static irqreturn_t megasas_isr(int irq, static int megasas_transition_to_ready(struct megasas_instance* instance) { - int i; u8 max_wait; u32 fw_state; u32 cur_state; + unsigned long end_time; fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK; @@ -1316,7 +1316,8 @@ megasas_transition_to_ready(struct megas /* * The cur_state should not last for more than max_wait secs */ - for (i = 0; i < (max_wait * 1000); i++) { + end_time = jiffies + msecs_to_jiffies(max_wait * 1000); + while (time_before(jiffies, end_time)) { fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK ; --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1828,7 +1828,7 @@ mega_build_sglist(adapter_t *adapter, sc scb->dma_type = MEGA_SGLIST; - if( sgcnt > adapter->sglen ) BUG(); + BUG_ON( sgcnt > adapter->sglen ); *len = 0; --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c @@ -916,7 +916,7 @@ static int osst_recover_wait_frame(struc retval = osst_write_error_recovery(STp, aSRpnt, 0); break; } - schedule_timeout_interruptible(HZ / OSST_POLL_PER_SEC); + msleep(1000 / OSST_POLL_PER_SEC); STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24; memset(cmd, 0, MAX_COMMAND_SIZE); @@ -1611,7 +1611,7 @@ static int osst_reposition_and_retry(str osst_set_frame_position(STp, aSRpnt, frame + skip, 1); flag = 0; attempts--; - schedule_timeout_interruptible(msecs_to_jiffies(100)); + msleep(100); } if (osst_get_frame_position(STp, aSRpnt) < 0) { /* additional write error */ #if DEBUG @@ -1672,7 +1672,7 @@ static int osst_reposition_and_retry(str debugging = 0; } #endif - schedule_timeout_interruptible(msecs_to_jiffies(100)); + msleep(100); } printk(KERN_ERR "%s:E: Failed to find valid tape media\n", name); #if DEBUG --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2577,15 +2577,14 @@ qla2x00_timer(scsi_qla_host_t *ha) int qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout) { - const unsigned int step = 100; /* msecs */ - unsigned int iterations = jiffies_to_msecs(timeout)/100; + unsigned long end_time = jiffies + timeout; do { if (!down_trylock(sema)) return 0; - if (msleep_interruptible(step)) + if (msleep_interruptible(100)) break; - } while (--iterations >= 0); + } while (time_before(jiffies, end_time)); return -ETIMEDOUT; } --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@ -1156,6 +1156,7 @@ static unsigned int pdc20621_prog_dimm_g u32 data, spd0; int error, i; void __iomem *mmio = pe->mmio_base; + unsigned long end_time; /* hard-code chip #0 */ mmio += PDC_CHIP0_OFS; @@ -1187,7 +1188,8 @@ static unsigned int pdc20621_prog_dimm_g writel(data, mmio + PDC_SDRAM_CONTROL_OFFSET); error = 1; - for (i = 1; i <= 10; i++) { /* polling ~5 secs */ + end_time = jiffies + msecs_to_jiffies(5600); + for (i = 1; time_before(jiffies, end_time); ++i) { /* polling ~5 secs */ data = readl(mmio + PDC_SDRAM_CONTROL_OFFSET); if (!(data & (1<<19))) { error = 0; --- a/drivers/serial/68360serial.c +++ b/drivers/serial/68360serial.c @@ -1995,6 +1995,17 @@ static inline int line_info(char *buf, s info->quot = 0; info->tty = 0; } + + if (info->quot) { + ret += sprintf(buf+ret, " baud:%d", + state->baud_base / info->quot); + } + + if (!capable(CAP_SYS_RAWIO)) { + strcat(buf, "\n"); + return ret + 1; + } + local_irq_disable(); status = serial_in(info, UART_MSR); control = info ? info->MCR : serial_in(info, UART_MCR); @@ -2015,11 +2026,6 @@ static inline int line_info(char *buf, s if (status & UART_MSR_RI) strcat(stat_buf, "|RI"); - if (info->quot) { - ret += sprintf(buf+ret, " baud:%d", - state->baud_base / info->quot); - } - ret += sprintf(buf+ret, " tx:%d rx:%d", state->icount.tx, state->icount.rx); --- a/drivers/serial/8250_acorn.c +++ b/drivers/serial/8250_acorn.c @@ -47,11 +47,10 @@ serial_card_probe(struct expansion_card unsigned char __iomem *virt_addr; unsigned int i; - info = kmalloc(sizeof(struct serial_card_info), GFP_KERNEL); + info = kzalloc(sizeof(struct serial_card_info), GFP_KERNEL); if (!info) return -ENOMEM; - memset(info, 0, sizeof(struct serial_card_info)); info->num_ports = type->num_ports; bus_addr = ecard_resource_start(ec, type->type); --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c @@ -4700,6 +4700,13 @@ static int line_info(char *buf, struct e return ret; } + ret += sprintf(buf+ret, " baud:%d", info->baud); + + if (!capable(CAP_SYS_RAWIO)) { + strcat(buf, "\n"); + return ret + 1; + } + stat_buf[0] = 0; stat_buf[1] = 0; if (!E100_RTS_GET(info)) --- a/drivers/serial/icom.c +++ b/drivers/serial/icom.c @@ -350,6 +350,7 @@ static void load_code(struct icom_port * unsigned char *new_page = NULL; unsigned char cable_id = NO_CABLE; struct pci_dev *dev = icom_port->adapter->pci_dev; + unsigned long end_time; /* Clear out any pending interrupts */ writew(0x3FFF, icom_port->int_reg); @@ -461,13 +462,14 @@ static void load_code(struct icom_port * writeb(START_DOWNLOAD, &icom_port->dram->sync); /* Wait max 1 Sec for data download and processor to start */ - for (index = 0; index < 10; index++) { + end_time = jiffies + msecs_to_jiffies(1000); + while (time_before(jiffies, end_time)) { msleep(100); if (readb(&icom_port->dram->misc_flags) & ICOM_HDW_ACTIVE) break; } - if (index == 10) + if (time_after_eq(jiffies, end_time)) status = -1; /* @@ -1006,11 +1008,13 @@ static void icom_send_xchar(struct uart_ unsigned char xdata; int index; unsigned long flags; + unsigned long end_time; trace(ICOM_PORT, "SEND_XCHAR", ch); /* wait .1 sec to send char */ - for (index = 0; index < 10; index++) { + end_time = jiffies + msecs_to_jiffies(100); + while (time_before(jiffies, end_time)) { spin_lock_irqsave(&port->lock, flags); xdata = readb(&ICOM_PORT->dram->xchar); if (xdata == 0x00) { --- a/drivers/serial/ioc4_serial.c +++ b/drivers/serial/ioc4_serial.c @@ -1077,13 +1077,12 @@ static int inline ioc4_attach_local(stru /* Create port structures for each port */ for (port_number = 0; port_number < IOC4_NUM_SERIAL_PORTS; port_number++) { - port = kmalloc(sizeof(struct ioc4_port), GFP_KERNEL); + port = kzalloc(sizeof(struct ioc4_port), GFP_KERNEL); if (!port) { printk(KERN_WARNING "IOC4 serial memory not available for port\n"); return -ENOMEM; } - memset(port, 0, sizeof(struct ioc4_port)); spin_lock_init(&port->ip_lock); /* we need to remember the previous ones, to point back to @@ -2814,7 +2813,7 @@ ioc4_serial_attach_one(struct ioc4_drive idd->idd_serial_data = control; /* Allocate the soft structure */ - soft = kmalloc(sizeof(struct ioc4_soft), GFP_KERNEL); + soft = kzalloc(sizeof(struct ioc4_soft), GFP_KERNEL); if (!soft) { printk(KERN_WARNING "ioc4 (%p): unable to get memory for the soft struct\n", @@ -2822,7 +2821,6 @@ ioc4_serial_attach_one(struct ioc4_drive ret = -ENOMEM; goto out3; } - memset(soft, 0, sizeof(struct ioc4_soft)); spin_lock_init(&soft->is_ir_lock); soft->is_ioc4_misc_addr = idd->idd_misc_regs; --- a/drivers/serial/ip22zilog.c +++ b/drivers/serial/ip22zilog.c @@ -923,23 +923,12 @@ static struct zilog_layout **ip22zilog_c static struct uart_ip22zilog_port *ip22zilog_irq_chain; static int zilog_irq = -1; -static void * __init alloc_one_table(unsigned long size) -{ - void *ret; - - ret = kmalloc(size, GFP_KERNEL); - if (ret != NULL) - memset(ret, 0, size); - - return ret; -} - static void __init ip22zilog_alloc_tables(void) { - ip22zilog_port_table = (struct uart_ip22zilog_port *) - alloc_one_table(NUM_CHANNELS * sizeof(struct uart_ip22zilog_port)); - ip22zilog_chip_regs = (struct zilog_layout **) - alloc_one_table(NUM_IP22ZILOG * sizeof(struct zilog_layout *)); + ip22zilog_port_table = + kzalloc(NUM_CHANNELS * sizeof(struct uart_ip22zilog_port), GFP_KERNEL); + ip22zilog_chip_regs = + kzalloc(NUM_IP22ZILOG * sizeof(struct zilog_layout *), GFP_KERNEL); if (ip22zilog_port_table == NULL || ip22zilog_chip_regs == NULL) { panic("IP22-Zilog: Cannot allocate IP22-Zilog tables."); --- a/drivers/serial/jsm/jsm_tty.c +++ b/drivers/serial/jsm/jsm_tty.c @@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port /* Drop locks, as malloc with GFP_KERNEL can sleep */ if (!channel->ch_rqueue) { - channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL); + channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); if (!channel->ch_rqueue) { jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, "unable to allocate read queue buf"); return -ENOMEM; } - memset(channel->ch_rqueue, 0, RQUEUESIZE); } if (!channel->ch_equeue) { - channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL); + channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL); if (!channel->ch_equeue) { jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, "unable to allocate error queue buf"); return -ENOMEM; } - memset(channel->ch_equeue, 0, EQUEUESIZE); } if (!channel->ch_wqueue) { - channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL); + channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL); if (!channel->ch_wqueue) { jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, "unable to allocate write queue buf"); return -ENOMEM; } - memset(channel->ch_wqueue, 0, WQUEUESIZE); } channel->ch_flags &= ~(CH_OPENING); @@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd) * Okay to malloc with GFP_KERNEL, we are not at * interrupt context, and there are no locks held. */ - brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL); + brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL); if (!brd->channels[i]) { jsm_printk(CORE, ERR, &brd->pci_dev, "%s:%d Unable to allocate memory for channel struct\n", __FILE__, __LINE__); } - memset(brd->channels[i], 0, sizeof(struct jsm_channel)); } } --- a/drivers/serial/mcfserial.c +++ b/drivers/serial/mcfserial.c @@ -1602,6 +1602,13 @@ int mcfrs_readproc(char *page, char **st info = &mcfrs_table[i]; len += sprintf((page + len), "%d: port:%x irq=%d baud:%d ", i, (unsigned int) info->addr, info->irq, info->baud); + + if (!capable(CAP_SYS_RAWIO)) { + strcat(page, "\n"); + len++; + continue; + } + if (info->stats.rx || info->stats.tx) len += sprintf((page + len), "tx:%d rx:%d ", info->stats.tx, info->stats.rx); --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c @@ -1517,9 +1517,8 @@ static struct uart_state *uart_get(struc } if (!state->info) { - state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL); + state->info = kzalloc(sizeof(struct uart_info), GFP_KERNEL); if (state->info) { - memset(state->info, 0, sizeof(struct uart_info)); init_waitqueue_head(&state->info->open_wait); init_waitqueue_head(&state->info->delta_msr_wait); @@ -1672,7 +1671,7 @@ static int uart_line_info(char *buf, str return ret + 1; } - if(capable(CAP_SYS_ADMIN)) + if (capable(CAP_SYS_RAWIO)) { spin_lock_irq(&port->lock); status = port->ops->get_mctrl(port); @@ -2174,13 +2173,11 @@ int uart_register_driver(struct uart_dri * Maybe we should be using a slab cache for this, especially if * we have a large number of ports to handle. */ - drv->state = kmalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); + drv->state = kcalloc(drv->nr, sizeof(struct uart_state), GFP_KERNEL); retval = -ENOMEM; if (!drv->state) goto out; - memset(drv->state, 0, sizeof(struct uart_state) * drv->nr); - normal = alloc_tty_driver(drv->nr); if (!normal) goto out; --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -212,10 +212,9 @@ static int serial_probe(struct pcmcia_de DEBUG(0, "serial_attach()\n"); /* Create new serial device */ - info = kmalloc(sizeof (*info), GFP_KERNEL); + info = kzalloc(sizeof (*info), GFP_KERNEL); if (!info) return -ENOMEM; - memset(info, 0, sizeof (*info)); info->p_dev = link; link->priv = info; --- a/drivers/serial/sunsu.c +++ b/drivers/serial/sunsu.c @@ -1301,10 +1301,8 @@ static int __init sunsu_kbd_ms_init(stru sunsu_type(&up->port)); #ifdef CONFIG_SERIO - up->serio = serio = kmalloc(sizeof(struct serio), GFP_KERNEL); + up->serio = serio = kzalloc(sizeof(struct serio), GFP_KERNEL); if (serio) { - memset(serio, 0, sizeof(*serio)); - serio->port_data = up; serio->id.type = SERIO_RS232; --- a/drivers/serial/sunzilog.c +++ b/drivers/serial/sunzilog.c @@ -1022,23 +1022,12 @@ static struct uart_driver sunzilog_reg = .major = TTY_MAJOR, }; -static void * __init alloc_one_table(unsigned long size) -{ - void *ret; - - ret = kmalloc(size, GFP_KERNEL); - if (ret != NULL) - memset(ret, 0, size); - - return ret; -} - static void __init sunzilog_alloc_tables(void) { sunzilog_port_table = - alloc_one_table(NUM_CHANNELS * sizeof(struct uart_sunzilog_port)); + kzalloc(NUM_CHANNELS * sizeof(struct uart_sunzilog_port), GFP_KERNEL); sunzilog_chip_regs = - alloc_one_table(NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *)); + kzalloc(NUM_SUNZILOG * sizeof(struct zilog_layout __iomem *), GFP_KERNEL); if (sunzilog_port_table == NULL || sunzilog_chip_regs == NULL) { prom_printf("SunZilog: Cannot allocate tables.\n"); @@ -1555,10 +1544,8 @@ static void __init sunzilog_register_ser { struct serio *serio; - up->serio = serio = kmalloc(sizeof(struct serio), GFP_KERNEL); + up->serio = serio = kzalloc(sizeof(struct serio), GFP_KERNEL); if (serio) { - memset(serio, 0, sizeof(*serio)); - serio->port_data = up; serio->id.type = SERIO_RS232; --- a/drivers/sh/superhyway/superhyway.c +++ b/drivers/sh/superhyway/superhyway.c @@ -56,11 +56,9 @@ int superhyway_add_device(unsigned long struct superhyway_device *dev = sdev; if (!dev) { - dev = kmalloc(sizeof(struct superhyway_device), GFP_KERNEL); + dev = kzalloc(sizeof(struct superhyway_device), GFP_KERNEL); if (!dev) return -ENOMEM; - - memset(dev, 0, sizeof(struct superhyway_device)); } dev->bus = bus; --- a/drivers/sn/ioc3.c +++ b/drivers/sn/ioc3.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -619,9 +620,9 @@ static int ioc3_probe(struct pci_dev *pd pci_set_master(pdev); #ifdef USE_64BIT_DMA - ret = pci_set_dma_mask(pdev, 0xffffffffffffffffULL); + ret = pci_set_dma_mask(pdev, DMA_64BIT_MASK); if (!ret) { - ret = pci_set_consistent_dma_mask(pdev, 0xffffffffffffffffULL); + ret = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); if (ret < 0) { printk(KERN_WARNING "%s: Unable to obtain 64 bit DMA " "for consistent allocations\n", --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -6802,7 +6802,11 @@ static int ixj_selfprobe(IXJ *j) } } else if (j->dsp.low == 0x22) { j->cardtype = QTI_PHONEJACK_PCI; - request_region(j->XILINXbase, 4, "ixj control"); + if (!request_region(j->XILINXbase, 4, "ixj control")) { + printk(KERN_WARNING "ixj : can't get I/O " + "address 0x%x\n", j->XILINXbase); + return -1; + } j->pld_slicw.pcib.e1 = 1; outb_p(j->pld_slicw.byte, j->XILINXbase); } else --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -46,11 +46,10 @@ static int ixj_probe(struct pcmcia_devic p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_8; p_dev->io.IOAddrLines = 3; p_dev->conf.IntType = INT_MEMORY_AND_IO; - p_dev->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL); + p_dev->priv = kzalloc(sizeof(struct ixj_info_t), GFP_KERNEL); if (!p_dev->priv) { return -ENOMEM; } - memset(p_dev->priv, 0, sizeof(struct ixj_info_t)); return ixj_config(p_dev); } --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1462,9 +1462,10 @@ static int hub_port_wait_reset(struct us int delay_time, ret; u16 portstatus; u16 portchange; + unsigned long end_time = jiffies + msecs_to_jiffies(HUB_RESET_TIMEOUT); for (delay_time = 0; - delay_time < HUB_RESET_TIMEOUT; + time_before(jiffies, end_time); delay_time += delay) { /* wait to give the device a chance to reset */ msleep(delay); @@ -2095,6 +2096,7 @@ static int hub_port_debounce(struct usb_ int total_time, stable_time = 0; u16 portchange, portstatus; unsigned connection = 0xffff; + unsigned long end_time = jiffies + msecs_to_jiffies(HUB_DEBOUNCE_TIMEOUT); for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { ret = hub_port_status(hub, port1, &portstatus, &portchange); @@ -2116,7 +2118,7 @@ static int hub_port_debounce(struct usb_ USB_PORT_FEAT_C_CONNECTION); } - if (total_time >= HUB_DEBOUNCE_TIMEOUT) + if (time_after(jiffies, end_time)) break; msleep(HUB_DEBOUNCE_STEP); } --- a/drivers/usb/input/hid-debug.h +++ b/drivers/usb/input/hid-debug.h @@ -563,7 +563,7 @@ static char *keys[KEY_MAX + 1] = { [KEY_VOLUMEUP] = "VolumeUp", [KEY_POWER] = "Power", [KEY_KPEQUAL] = "KPEqual", [KEY_KPPLUSMINUS] = "KPPlusMinus", [KEY_PAUSE] = "Pause", [KEY_KPCOMMA] = "KPComma", - [KEY_HANGUEL] = "Hanguel", [KEY_HANJA] = "Hanja", + [KEY_HANGEUL] = "Hangeul", [KEY_HANJA] = "Hanja", [KEY_YEN] = "Yen", [KEY_LEFTMETA] = "LeftMeta", [KEY_RIGHTMETA] = "RightMeta", [KEY_COMPOSE] = "Compose", [KEY_STOP] = "Stop", [KEY_AGAIN] = "Again", --- a/drivers/video/atafb.c +++ b/drivers/video/atafb.c @@ -2731,7 +2731,7 @@ int __init atafb_init(void) } fbhw = &st_switch; atafb_ops.fb_setcolreg = &stste_setcolreg; - printk("Cannot determine video hardware; defaulting to ST(e)\n"); + pr_info("Cannot determine video hardware; defaulting to ST(e)\n"); #else /* ATAFB_STE */ /* no default driver included */ /* Nobody will ever see this message :-) */ @@ -2808,13 +2808,13 @@ int __init atafb_init(void) if (register_framebuffer(&fb_info) < 0) return -EINVAL; - printk("Determined %dx%d, depth %d\n", + pr_info("Determined %dx%d, depth %d\n", disp.var.xres, disp.var.yres, disp.var.bits_per_pixel); if ((disp.var.xres != disp.var.xres_virtual) || (disp.var.yres != disp.var.yres_virtual)) printk(" virtual %dx%d\n", disp.var.xres_virtual, disp.var.yres_virtual); - printk("fb%d: %s frame buffer device, using %dK of video memory\n", + pr_info("fb%d: %s frame buffer device, using %dK of video memory\n", fb_info.node, fb_info.modename, screen_len>>10); /* TODO: This driver cannot be unloaded yet */ --- a/drivers/video/aty/mach64_ct.c +++ b/drivers/video/aty/mach64_ct.c @@ -196,7 +196,7 @@ static int aty_dsp_gt(const struct fb_in pll->dsp_on_off = (dsp_on << 16) + dsp_off; pll->dsp_config = (dsp_precision << 20) | (pll->dsp_loop_latency << 16) | dsp_xclks; #ifdef DEBUG - printk("atyfb(%s): dsp_config 0x%08x, dsp_on_off 0x%08x\n", + pr_debug("atyfb(%s): dsp_config 0x%08x, dsp_on_off 0x%08x\n", __FUNCTION__, pll->dsp_config, pll->dsp_on_off); #endif return 0; @@ -224,7 +224,7 @@ static int aty_valid_pll_ct(const struct pllvclk = (1000000 * 2 * pll->vclk_fb_div) / (par->ref_clk_per * pll->pll_ref_div); #ifdef DEBUG - printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n", + pr_debug("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n", __FUNCTION__, pllvclk, pllvclk / pll->vclk_post_div_real); #endif pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */ @@ -268,9 +268,7 @@ static u32 aty_pll_to_var_ct(const struc ret /= pll->ct.xres; } #endif -#ifdef DEBUG - printk("atyfb(%s): calculated 0x%08X(%i)\n", __FUNCTION__, ret, ret); -#endif + pr_debug("atyfb(%s): calculated 0x%08X(%i)\n", __FUNCTION__, ret, ret); return ret; } @@ -281,17 +279,15 @@ void aty_set_pll_ct(const struct fb_info u8 tmp, tmp2; lcd_gen_cntrl = 0; -#ifdef DEBUG - printk("atyfb(%s): about to program:\n" + pr_debug("atyfb(%s): about to program:\n" "pll_ext_cntl=0x%02x pll_gen_cntl=0x%02x pll_vclk_cntl=0x%02x\n", __FUNCTION__, pll->ct.pll_ext_cntl, pll->ct.pll_gen_cntl, pll->ct.pll_vclk_cntl); - printk("atyfb(%s): setting clock %lu for FeedBackDivider %i, ReferenceDivider %i, PostDivider %i(%i)\n", + pr_debug("atyfb(%s): setting clock %lu for FeedBackDivider %i, ReferenceDivider %i, PostDivider %i(%i)\n", __FUNCTION__, par->clk_wr_offset, pll->ct.vclk_fb_div, pll->ct.pll_ref_div, pll->ct.vclk_post_div, pll->ct.vclk_post_div_real); -#endif #ifdef CONFIG_FB_ATY_GENERIC_LCD if (par->lcd_table != 0) { /* turn off LCD */ @@ -426,10 +422,8 @@ static int __init aty_init_pll_ct(const pll->ct.xclk_post_div -= 1; } -#ifdef DEBUG - printk("atyfb(%s): mclk_fb_mult=%d, xclk_post_div=%d\n", + pr_debug("atyfb(%s): mclk_fb_mult=%d, xclk_post_div=%d\n", __FUNCTION__, pll->ct.mclk_fb_mult, pll->ct.xclk_post_div); -#endif memcntl = aty_ld_le32(MEM_CNTL, par); trp = (memcntl & 0x300) >> 8; @@ -539,7 +533,7 @@ static int __init aty_init_pll_ct(const #ifdef DEBUG pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) / (par->ref_clk_per * pll->ct.pll_ref_div); - printk("atyfb(%s): pllmclk=%d MHz, xclk=%d MHz\n", + pr_debug("atyfb(%s): pllmclk=%d MHz, xclk=%d MHz\n", __FUNCTION__, pllmclk, pllmclk / pll->ct.xclk_post_div_real); #endif @@ -580,7 +574,7 @@ static int __init aty_init_pll_ct(const #ifdef DEBUG pllsclk = (1000000 * 2 * sclk_fb_div) / (par->ref_clk_per * pll->ct.pll_ref_div); - printk("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d MHz\n", + pr_debug("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d MHz\n", __FUNCTION__, pllsclk, pllsclk / sclk_post_div_real); #endif /* --- a/drivers/video/aty/radeon_monitor.c +++ b/drivers/video/aty/radeon_monitor.c @@ -178,10 +178,10 @@ static int __devinit radeon_get_panel_in for(i=0; i<24; i++) stmp[i] = BIOS_IN8(tmp+i+1); stmp[24] = 0; - printk("radeonfb: panel ID string: %s\n", stmp); + pr_info("radeonfb: panel ID string: %s\n", stmp); rinfo->panel_info.xres = BIOS_IN16(tmp + 25); rinfo->panel_info.yres = BIOS_IN16(tmp + 27); - printk("radeonfb: detected LVDS panel size from BIOS: %dx%d\n", + pr_info("radeonfb: detected LVDS panel size from BIOS: %dx%d\n", rinfo->panel_info.xres, rinfo->panel_info.yres); rinfo->panel_info.pwr_delay = BIOS_IN16(tmp + 44); @@ -565,7 +565,7 @@ void __devinit radeon_probe_screens(stru ((rinfo->bios_seg && (INREG(BIOS_4_SCRATCH) & 4)) || (INREG(LVDS_GEN_CNTL) & LVDS_ON))) { rinfo->mon1_type = MT_LCD; - printk("Non-DDC laptop panel detected\n"); + pr_info("Non-DDC laptop panel detected\n"); } if (rinfo->mon1_type == MT_NONE) rinfo->mon1_type = radeon_crt_is_connected(rinfo, rinfo->reversed_DAC); --- a/drivers/video/aty/radeon_pm.c +++ b/drivers/video/aty/radeon_pm.c @@ -2722,10 +2722,10 @@ void radeonfb_pm_init(struct radeonfb_in rinfo->dynclk = dynclk; if (dynclk == 1) { radeon_pm_enable_dynamic_mode(rinfo); - printk("radeonfb: Dynamic Clock Power Management enabled\n"); + pr_info("radeonfb: Dynamic Clock Power Management enabled\n"); } else if (dynclk == 0) { radeon_pm_disable_dynamic_mode(rinfo); - printk("radeonfb: Dynamic Clock Power Management disabled\n"); + pr_info("radeonfb: Dynamic Clock Power Management disabled\n"); } #if defined(CONFIG_PM) --- a/drivers/video/bw2.c +++ b/drivers/video/bw2.c @@ -372,7 +372,7 @@ static void bw2_init_one(struct sbus_dev list_add(&all->list, &bw2_list); - printk("bw2: bwtwo at %lx:%lx\n", + pr_info("bw2: bwtwo at %lx:%lx\n", (long) (sdev ? sdev->reg_addrs[0].which_io : 0), (long) all->par.physbase); } --- a/drivers/video/cg3.c +++ b/drivers/video/cg3.c @@ -434,7 +434,7 @@ static void cg3_init_one(struct sbus_dev list_add(&all->list, &cg3_list); - printk("cg3: %s at %lx:%lx\n", + pr_info("cg3: %s at %lx:%lx\n", sdev->prom_name, (long) sdev->reg_addrs[0].which_io, (long) sdev->reg_addrs[0].phys_addr); --- a/drivers/video/cg6.c +++ b/drivers/video/cg6.c @@ -740,7 +740,7 @@ static void cg6_init_one(struct sbus_dev list_add(&all->list, &cg6_list); - printk("cg6: CGsix [%s] at %lx:%lx\n", + pr_info("cg6: CGsix [%s] at %lx:%lx\n", all->info.fix.id, (long) sdev->reg_addrs[0].which_io, (long) sdev->reg_addrs[0].phys_addr); --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c @@ -93,7 +93,7 @@ #ifndef CIRRUSFB_NDEBUG #define assert(expr) \ if(!(expr)) { \ - printk( "Assertion failed! %s,%s,%s,line=%d\n",\ + printk(KERN_DEBUG "Assertion failed! %s,%s,%s,line=%d\n",\ #expr,__FILE__,__FUNCTION__,__LINE__); \ } #else @@ -702,14 +702,14 @@ static int cirrusfb_check_var(struct fb_ den = 1; break; /* 4 bytes per pixel */ default: - printk ("cirrusfb: mode %dx%dx%d rejected...color depth not supported.\n", + printk (KERN_WARNING "cirrusfb: mode %dx%dx%d rejected...color depth not supported.\n", var->xres, var->yres, var->bits_per_pixel); DPRINTK ("EXIT - EINVAL error\n"); return -EINVAL; } if (var->xres * nom / den * var->yres > cinfo->size) { - printk ("cirrusfb: mode %dx%dx%d rejected...resolution too high to fit into video memory!\n", + printk (KERN_WARNING "cirrusfb: mode %dx%dx%d rejected...resolution too high to fit into video memory!\n", var->xres, var->yres, var->bits_per_pixel); DPRINTK ("EXIT - EINVAL error\n"); return -EINVAL; @@ -718,20 +718,20 @@ static int cirrusfb_check_var(struct fb_ /* use highest possible virtual resolution */ if (var->xres_virtual == -1 && var->yres_virtual == -1) { - printk ("cirrusfb: using maximum available virtual resolution\n"); + pr_info ("cirrusfb: using maximum available virtual resolution\n"); for (i = 0; modes[i].xres != -1; i++) { if (modes[i].xres * nom / den * modes[i].yres < cinfo->size / 2) break; } if (modes[i].xres == -1) { - printk ("cirrusfb: could not find a virtual resolution that fits into video memory!!\n"); + printk (KERN_WARNING "cirrusfb: could not find a virtual resolution that fits into video memory!!\n"); DPRINTK ("EXIT - EINVAL error\n"); return -EINVAL; } var->xres_virtual = modes[i].xres; var->yres_virtual = modes[i].yres; - printk ("cirrusfb: virtual resolution set to maximum of %dx%d\n", + pr_info ("cirrusfb: virtual resolution set to maximum of %dx%d\n", var->xres_virtual, var->yres_virtual); } @@ -2171,7 +2171,7 @@ static unsigned int cirrusfb_get_memsize /* 64-bit DRAM data bus width; assume 2MB. Also indicates 2MB memory * on the 5430. */ case 0x18: mem = 2048 * 1024; break; - default: printk ("CLgenfb: Unknown memory size!\n"); + default: printk (KERN_WARNING "CLgenfb: Unknown memory size!\n"); mem = 1024 * 1024; } if (SRF & 0x80) { @@ -2356,7 +2356,7 @@ static void __devexit cirrusfb_cleanup ( unregister_framebuffer (info); fb_dealloc_cmap (&info->cmap); - printk ("Framebuffer unregistered\n"); + pr_info ("Framebuffer unregistered\n"); cinfo->unmap(cinfo); DPRINTK ("EXIT\n"); @@ -2441,6 +2441,9 @@ static int cirrusfb_pci_register (struct cinfo->size = board_size; cinfo->unmap = cirrusfb_pci_unmap; + printk(KERN_INFO "cirrusfb: %s board detected; ", + cirrusfb_board_info[btype].name); + printk (" RAM (%lu kB) at 0xx%lx, ", cinfo->size / KB_, board_addr); printk ("Cirrus Logic chipset on PCI bus\n"); pci_set_drvdata(pdev, info); @@ -2533,7 +2536,7 @@ static int cirrusfb_zorro_register(struc goto err_release_fb; } - printk (" RAM (%lu MB) at $%lx, ", board_size / MB_, board_addr); + pr_info (" RAM (%lu MB) at $%lx, ", board_size / MB_, board_addr); ret = -EIO; --- a/drivers/video/clps711xfb.c +++ b/drivers/video/clps711xfb.c @@ -384,7 +384,7 @@ int __init clps711xfb_init(void) clps7111fb_backlight_proc_entry = create_proc_entry("backlight", 0444, &proc_root); if (clps7111fb_backlight_proc_entry == NULL) { - printk("Couldn't create the /proc entry for the backlight.\n"); + printk(KERN_ERR "Couldn't create the /proc entry for the backlight.\n"); return -EINVAL; } --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -1011,7 +1011,7 @@ static const char *fbcon_startup(void) udelay(20); if (ct == 1000) - printk + pr_info ("fbcon_startup: No VBL detected, using timer based cursor.\n"); free_irq(IRQ_MAC_VBL, fb_vbl_detect); --- a/drivers/video/console/mdacon.c +++ b/drivers/video/console/mdacon.c @@ -326,7 +326,7 @@ static const char __init *mdacon_startup mda_type_name = "MDA"; if (! mda_detect()) { - printk("mdacon: MDA card not detected.\n"); + pr_info("mdacon: MDA card not detected.\n"); return NULL; } @@ -337,7 +337,7 @@ static const char __init *mdacon_startup /* cursor looks ugly during boot-up, so turn it off */ mda_set_cursor(mda_vram_len - 1); - printk("mdacon: %s with %ldK of memory detected.\n", + pr_info("mdacon: %s with %ldK of memory detected.\n", mda_type_name, mda_vram_len/1024); return "MDA-2"; --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -230,7 +230,7 @@ static void newport_get_screensize(void) newport_ysize += linetable[i + 1]; } } - printk("NG1: Screensize %dx%d\n", newport_xsize, newport_ysize); + pr_info("NG1: Screensize %dx%d\n", newport_xsize, newport_ysize); } static void newport_get_revisions(void) @@ -273,7 +273,7 @@ static void newport_get_revisions(void) bt445_rev = (npregs->set.dcbdata0.bybytes.b3 >> 4) - 0x0a; #define L(a) (char)('A'+(a)) - printk + pr_info ("NG1: Revision %d, %d bitplanes, REX3 revision %c, VC2 revision %c, xmap9 revision %c, cmap revision %c, bt445 revision %c\n", board_rev, bitplanes, L(rex3_rev), L(vc2_rev), L(xmap9_rev), L(cmap_rev ? (cmap_rev + 1) : 0), L(bt445_rev)); --- a/drivers/video/cyber2000fb.c +++ b/drivers/video/cyber2000fb.c @@ -1371,7 +1371,7 @@ static int __devinit cyberpro_common_pro err = -EINVAL; if (!fb_find_mode(&cfb->fb.var, &cfb->fb, NULL, NULL, 0, &cyber2000fb_default_mode, 8)) { - printk("%s: no valid mode found\n", cfb->fb.fix.id); + printk(KERN_ERR "%s: no valid mode found\n", cfb->fb.fix.id); goto failed; } --- a/drivers/video/dnfb.c +++ b/drivers/video/dnfb.c @@ -266,7 +266,7 @@ static int __devinit dnfb_probe(struct p out_8(AP_CONTROL_2, S_DATA_PLN); out_be16(AP_ROP_1, SWAP(0x3)); - printk("apollo frame buffer alive and kicking !\n"); + pr_info("apollo frame buffer initialized\n"); return err; } --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -1420,7 +1420,7 @@ fbmem_init(void) devfs_mk_dir("fb"); if (register_chrdev(FB_MAJOR,"fb",&fb_fops)) - printk("unable to get major %d for fb devs\n", FB_MAJOR); + printk(KERN_WARNING "unable to get major %d for fb devs\n", FB_MAJOR); fb_class = class_create(THIS_MODULE, "graphics"); if (IS_ERR(fb_class)) { --- a/drivers/video/fbmon.c +++ b/drivers/video/fbmon.c @@ -44,7 +44,7 @@ #undef DEBUG /* define this for verbose EDID parsing output */ #ifdef DEBUG -#define DPRINTK(fmt, args...) printk(fmt,## args) +#define DPRINTK(fmt, args...) pr_debug("%s(): ", fmt, __FUNCTION__, ## args) #else #define DPRINTK(fmt, args...) #endif @@ -105,7 +105,7 @@ static int check_edid(unsigned char *edi for (i = 0; i < ARRAY_SIZE(brokendb); i++) { if (!strncmp(manufacturer, brokendb[i].manufacturer, 4) && brokendb[i].model == model) { - printk("fbmon: The EDID Block of " + pr_info("fbmon: The EDID Block of " "Manufacturer: %s Model: 0x%x is known to " "be broken,\n", manufacturer, model); fix = brokendb[i].fix; @@ -138,11 +138,11 @@ static void fix_edid(unsigned char *edid switch (fix) { case FBMON_FIX_HEADER: - printk("fbmon: trying a header reconstruct\n"); + pr_info("fbmon: trying a header reconstruct\n"); memcpy(edid, edid_v1_header, 8); break; case FBMON_FIX_INPUT: - printk("fbmon: trying to fix input type\n"); + pr_info("fbmon: trying to fix input type\n"); b = edid + EDID_STRUCT_DISPLAY; b[0] &= ~0x80; edid[127] += 0x80; @@ -771,7 +771,7 @@ static void get_monspecs(unsigned char * specs->misc |= FB_MISC_1ST_DETAIL; } if (c & 0x01) { - printk(" Display is GTF capable\n"); + DPRINTK(" Display is GTF capable\n"); specs->gtf = 1; } } --- a/drivers/video/ffb.c +++ b/drivers/video/ffb.c @@ -930,12 +930,12 @@ static void ffb_init_one(int node, int p struct all_info *all; if (prom_getproperty(node, "reg", (void *) regs, sizeof(regs)) <= 0) { - printk("ffb: Cannot get reg device node property.\n"); + printk(KERN_ERR "ffb: Cannot get reg device node property.\n"); return; } if (ffb_apply_upa_parent_ranges(parent, ®s[0])) { - printk("ffb: Cannot apply parent ranges to regs.\n"); + printk(KERN_ERR "ffb: Cannot apply parent ranges to regs.\n"); return; } @@ -1022,7 +1022,7 @@ static void ffb_init_one(int node, int p list_add(&all->list, &ffb_list); - printk("ffb: %s at %016lx type %d DAC %d\n", + pr_info("ffb: %s at %016lx type %d DAC %d\n", ((all->par.flags & FFB_FLAG_AFB) ? "AFB" : "FFB"), regs[0].phys_addr, all->par.board_type, all->par.dac_rev); } --- a/drivers/video/fm2fb.c +++ b/drivers/video/fm2fb.c @@ -287,7 +287,7 @@ static int __devinit fm2fb_probe(struct zorro_release_device(z); return -EINVAL; } - printk("fb%d: %s frame buffer device\n", info->node, fb_fix.id); + pr_info("fb%d: %s frame buffer device\n", info->node, fb_fix.id); return 0; } --- a/drivers/video/igafb.c +++ b/drivers/video/igafb.c @@ -364,7 +364,7 @@ static int __init iga_init(struct fb_inf if (register_framebuffer(info) < 0) return 0; - printk("fb%d: %s frame buffer device at 0x%08lx [%dMB VRAM]\n", + pr_info("fb%d: %s frame buffer device at 0x%08lx [%dMB VRAM]\n", info->node, info->fix.id, par->frame_buffer_phys, info->fix.smem_len >> 20); @@ -406,7 +406,7 @@ int __init igafb_init(void) info = kmalloc(size, GFP_ATOMIC); if (!info) { - printk("igafb_init: can't alloc fb_info\n"); + printk(KERN_ERR "igafb_init: can't alloc fb_info\n"); return -ENOMEM; } memset(info, 0, size); @@ -415,13 +415,13 @@ int __init igafb_init(void) if ((addr = pdev->resource[0].start) == 0) { - printk("igafb_init: no memory start\n"); + printk(KERN_ERR "igafb_init: no memory start\n"); kfree(info); return -ENXIO; } if ((info->screen_base = ioremap(addr, 1024*1024*2)) == 0) { - printk("igafb_init: can't remap %lx[2M]\n", addr); + printk(KERN_ERR "igafb_init: can't remap %lx[2M]\n", addr); kfree(info); return -ENXIO; } @@ -454,7 +454,7 @@ int __init igafb_init(void) igafb_fix.mmio_start = 0x30000000; /* XXX */ } if ((par->io_base = (int) ioremap(igafb_fix.mmio_start, igafb_fix.smem_len)) == 0) { - printk("igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start); + printk(KERN_ERR "igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start); iounmap((void *)info->screen_base); kfree(info); return -ENXIO; @@ -470,7 +470,7 @@ int __init igafb_init(void) par->mmap_map = kmalloc(4 * sizeof(*par->mmap_map), GFP_ATOMIC); if (!par->mmap_map) { - printk("igafb_init: can't alloc mmap_map\n"); + printk(KERN_ERR "igafb_init: can't alloc mmap_map\n"); iounmap((void *)par->io_base); iounmap(info->screen_base); kfree(info); --- a/drivers/video/imsttfb.c +++ b/drivers/video/imsttfb.c @@ -1421,7 +1421,8 @@ init_imstt(struct fb_info *info) if ((info->var.xres * info->var.yres) * (info->var.bits_per_pixel >> 3) > info->fix.smem_len || !(compute_imstt_regvals(par, info->var.xres, info->var.yres))) { - printk("imsttfb: %ux%ux%u not supported\n", info->var.xres, info->var.yres, info->var.bits_per_pixel); + printk(KERN_ERR "imsttfb: %ux%ux%u not supported\n", + info->var.xres, info->var.yres, info->var.bits_per_pixel); framebuffer_release(info); return; } @@ -1463,7 +1464,7 @@ init_imstt(struct fb_info *info) } tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8; - printk("fb%u: %s frame buffer; %uMB vram; chip version %u\n", + pr_info("fb%u: %s frame buffer; %uMB vram; chip version %u\n", info->node, info->fix.id, info->fix.smem_len >> 20, tmp); } --- a/drivers/video/intelfb/intelfbhw.c +++ b/drivers/video/intelfb/intelfbhw.c @@ -540,10 +540,10 @@ intelfbhw_print_hw_state(struct intelfb_ if (!hw || !dinfo) return; /* Read in as much of the HW state as possible. */ - printk("hw state dump start\n"); - printk(" VGA0_DIVISOR: 0x%08x\n", hw->vga0_divisor); - printk(" VGA1_DIVISOR: 0x%08x\n", hw->vga1_divisor); - printk(" VGAPD: 0x%08x\n", hw->vga_pd); + pr_info("hw state dump start\n"); + pr_info(" VGA0_DIVISOR: 0x%08x\n", hw->vga0_divisor); + pr_info(" VGA1_DIVISOR: 0x%08x\n", hw->vga1_divisor); + pr_info(" VGAPD: 0x%08x\n", hw->vga_pd); n = (hw->vga0_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; m1 = (hw->vga0_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; m2 = (hw->vga0_divisor >> FP_M2_DIVISOR_SHIFT) & FP_DIVISOR_MASK; @@ -552,9 +552,9 @@ intelfbhw_print_hw_state(struct intelfb_ else p1 = (hw->vga_pd >> VGAPD_0_P1_SHIFT) & DPLL_P1_MASK; p2 = (hw->vga_pd >> VGAPD_0_P2_SHIFT) & DPLL_P2_MASK; - printk(" VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", + pr_info(" VGA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", m1, m2, n, p1, p2); - printk(" VGA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); + pr_info(" VGA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); n = (hw->vga1_divisor >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; m1 = (hw->vga1_divisor >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; @@ -564,16 +564,16 @@ intelfbhw_print_hw_state(struct intelfb_ else p1 = (hw->vga_pd >> VGAPD_1_P1_SHIFT) & DPLL_P1_MASK; p2 = (hw->vga_pd >> VGAPD_1_P2_SHIFT) & DPLL_P2_MASK; - printk(" VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", + pr_info(" VGA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", m1, m2, n, p1, p2); - printk(" VGA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); + pr_info(" VGA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); - printk(" DPLL_A: 0x%08x\n", hw->dpll_a); - printk(" DPLL_B: 0x%08x\n", hw->dpll_b); - printk(" FPA0: 0x%08x\n", hw->fpa0); - printk(" FPA1: 0x%08x\n", hw->fpa1); - printk(" FPB0: 0x%08x\n", hw->fpb0); - printk(" FPB1: 0x%08x\n", hw->fpb1); + pr_info(" DPLL_A: 0x%08x\n", hw->dpll_a); + pr_info(" DPLL_B: 0x%08x\n", hw->dpll_b); + pr_info(" FPA0: 0x%08x\n", hw->fpa0); + pr_info(" FPA1: 0x%08x\n", hw->fpa1); + pr_info(" FPB0: 0x%08x\n", hw->fpb0); + pr_info(" FPB1: 0x%08x\n", hw->fpb1); n = (hw->fpa0 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; m1 = (hw->fpa0 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; @@ -583,9 +583,9 @@ intelfbhw_print_hw_state(struct intelfb_ else p1 = (hw->dpll_a >> DPLL_P1_SHIFT) & DPLL_P1_MASK; p2 = (hw->dpll_a >> DPLL_P2_SHIFT) & DPLL_P2_MASK; - printk(" PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", + pr_info(" PLLA0: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", m1, m2, n, p1, p2); - printk(" PLLA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); + pr_info(" PLLA0: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); n = (hw->fpa1 >> FP_N_DIVISOR_SHIFT) & FP_DIVISOR_MASK; m1 = (hw->fpa1 >> FP_M1_DIVISOR_SHIFT) & FP_DIVISOR_MASK; @@ -595,62 +595,62 @@ intelfbhw_print_hw_state(struct intelfb_ else p1 = (hw->dpll_a >> DPLL_P1_SHIFT) & DPLL_P1_MASK; p2 = (hw->dpll_a >> DPLL_P2_SHIFT) & DPLL_P2_MASK; - printk(" PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", + pr_info(" PLLA1: (m1, m2, n, p1, p2) = (%d, %d, %d, %d, %d)\n", m1, m2, n, p1, p2); - printk(" PLLA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); + pr_info(" PLLA1: clock is %d\n", CALC_VCLOCK(m1, m2, n, p1, p2)); #if 0 - printk(" PALETTE_A:\n"); + pr_info(" PALETTE_A:\n"); for (i = 0; i < PALETTE_8_ENTRIES) - printk(" %3d: 0x%08x\n", i, hw->palette_a[i]; - printk(" PALETTE_B:\n"); + pr_info(" %3d: 0x%08x\n", i, hw->palette_a[i]; + pr_info(" PALETTE_B:\n"); for (i = 0; i < PALETTE_8_ENTRIES) - printk(" %3d: 0x%08x\n", i, hw->palette_b[i]; + pr_info(" %3d: 0x%08x\n", i, hw->palette_b[i]; #endif - printk(" HTOTAL_A: 0x%08x\n", hw->htotal_a); - printk(" HBLANK_A: 0x%08x\n", hw->hblank_a); - printk(" HSYNC_A: 0x%08x\n", hw->hsync_a); - printk(" VTOTAL_A: 0x%08x\n", hw->vtotal_a); - printk(" VBLANK_A: 0x%08x\n", hw->vblank_a); - printk(" VSYNC_A: 0x%08x\n", hw->vsync_a); - printk(" SRC_SIZE_A: 0x%08x\n", hw->src_size_a); - printk(" BCLRPAT_A: 0x%08x\n", hw->bclrpat_a); - printk(" HTOTAL_B: 0x%08x\n", hw->htotal_b); - printk(" HBLANK_B: 0x%08x\n", hw->hblank_b); - printk(" HSYNC_B: 0x%08x\n", hw->hsync_b); - printk(" VTOTAL_B: 0x%08x\n", hw->vtotal_b); - printk(" VBLANK_B: 0x%08x\n", hw->vblank_b); - printk(" VSYNC_B: 0x%08x\n", hw->vsync_b); - printk(" SRC_SIZE_B: 0x%08x\n", hw->src_size_b); - printk(" BCLRPAT_B: 0x%08x\n", hw->bclrpat_b); - - printk(" ADPA: 0x%08x\n", hw->adpa); - printk(" DVOA: 0x%08x\n", hw->dvoa); - printk(" DVOB: 0x%08x\n", hw->dvob); - printk(" DVOC: 0x%08x\n", hw->dvoc); - printk(" DVOA_SRCDIM: 0x%08x\n", hw->dvoa_srcdim); - printk(" DVOB_SRCDIM: 0x%08x\n", hw->dvob_srcdim); - printk(" DVOC_SRCDIM: 0x%08x\n", hw->dvoc_srcdim); - printk(" LVDS: 0x%08x\n", hw->lvds); - - printk(" PIPEACONF: 0x%08x\n", hw->pipe_a_conf); - printk(" PIPEBCONF: 0x%08x\n", hw->pipe_b_conf); - printk(" DISPARB: 0x%08x\n", hw->disp_arb); - - printk(" CURSOR_A_CONTROL: 0x%08x\n", hw->cursor_a_control); - printk(" CURSOR_B_CONTROL: 0x%08x\n", hw->cursor_b_control); - printk(" CURSOR_A_BASEADDR: 0x%08x\n", hw->cursor_a_base); - printk(" CURSOR_B_BASEADDR: 0x%08x\n", hw->cursor_b_base); + pr_info(" HTOTAL_A: 0x%08x\n", hw->htotal_a); + pr_info(" HBLANK_A: 0x%08x\n", hw->hblank_a); + pr_info(" HSYNC_A: 0x%08x\n", hw->hsync_a); + pr_info(" VTOTAL_A: 0x%08x\n", hw->vtotal_a); + pr_info(" VBLANK_A: 0x%08x\n", hw->vblank_a); + pr_info(" VSYNC_A: 0x%08x\n", hw->vsync_a); + pr_info(" SRC_SIZE_A: 0x%08x\n", hw->src_size_a); + pr_info(" BCLRPAT_A: 0x%08x\n", hw->bclrpat_a); + pr_info(" HTOTAL_B: 0x%08x\n", hw->htotal_b); + pr_info(" HBLANK_B: 0x%08x\n", hw->hblank_b); + pr_info(" HSYNC_B: 0x%08x\n", hw->hsync_b); + pr_info(" VTOTAL_B: 0x%08x\n", hw->vtotal_b); + pr_info(" VBLANK_B: 0x%08x\n", hw->vblank_b); + pr_info(" VSYNC_B: 0x%08x\n", hw->vsync_b); + pr_info(" SRC_SIZE_B: 0x%08x\n", hw->src_size_b); + pr_info(" BCLRPAT_B: 0x%08x\n", hw->bclrpat_b); + + pr_info(" ADPA: 0x%08x\n", hw->adpa); + pr_info(" DVOA: 0x%08x\n", hw->dvoa); + pr_info(" DVOB: 0x%08x\n", hw->dvob); + pr_info(" DVOC: 0x%08x\n", hw->dvoc); + pr_info(" DVOA_SRCDIM: 0x%08x\n", hw->dvoa_srcdim); + pr_info(" DVOB_SRCDIM: 0x%08x\n", hw->dvob_srcdim); + pr_info(" DVOC_SRCDIM: 0x%08x\n", hw->dvoc_srcdim); + pr_info(" LVDS: 0x%08x\n", hw->lvds); + + pr_info(" PIPEACONF: 0x%08x\n", hw->pipe_a_conf); + pr_info(" PIPEBCONF: 0x%08x\n", hw->pipe_b_conf); + pr_info(" DISPARB: 0x%08x\n", hw->disp_arb); + + pr_info(" CURSOR_A_CONTROL: 0x%08x\n", hw->cursor_a_control); + pr_info(" CURSOR_B_CONTROL: 0x%08x\n", hw->cursor_b_control); + pr_info(" CURSOR_A_BASEADDR: 0x%08x\n", hw->cursor_a_base); + pr_info(" CURSOR_B_BASEADDR: 0x%08x\n", hw->cursor_b_base); - printk(" CURSOR_A_PALETTE: "); + pr_info(" CURSOR_A_PALETTE: "); for (i = 0; i < 4; i++) { printk("0x%08x", hw->cursor_a_palette[i]); if (i < 3) printk(", "); } printk("\n"); - printk(" CURSOR_B_PALETTE: "); + pr_info(" CURSOR_B_PALETTE: "); for (i = 0; i < 4; i++) { printk("0x%08x", hw->cursor_b_palette[i]); if (i < 3) @@ -658,40 +658,40 @@ intelfbhw_print_hw_state(struct intelfb_ } printk("\n"); - printk(" CURSOR_SIZE: 0x%08x\n", hw->cursor_size); + pr_info(" CURSOR_SIZE: 0x%08x\n", hw->cursor_size); - printk(" DSPACNTR: 0x%08x\n", hw->disp_a_ctrl); - printk(" DSPBCNTR: 0x%08x\n", hw->disp_b_ctrl); - printk(" DSPABASE: 0x%08x\n", hw->disp_a_base); - printk(" DSPBBASE: 0x%08x\n", hw->disp_b_base); - printk(" DSPASTRIDE: 0x%08x\n", hw->disp_a_stride); - printk(" DSPBSTRIDE: 0x%08x\n", hw->disp_b_stride); + pr_info(" DSPACNTR: 0x%08x\n", hw->disp_a_ctrl); + pr_info(" DSPBCNTR: 0x%08x\n", hw->disp_b_ctrl); + pr_info(" DSPABASE: 0x%08x\n", hw->disp_a_base); + pr_info(" DSPBBASE: 0x%08x\n", hw->disp_b_base); + pr_info(" DSPASTRIDE: 0x%08x\n", hw->disp_a_stride); + pr_info(" DSPBSTRIDE: 0x%08x\n", hw->disp_b_stride); - printk(" VGACNTRL: 0x%08x\n", hw->vgacntrl); - printk(" ADD_ID: 0x%08x\n", hw->add_id); + pr_info(" VGACNTRL: 0x%08x\n", hw->vgacntrl); + pr_info(" ADD_ID: 0x%08x\n", hw->add_id); for (i = 0; i < 7; i++) { - printk(" SWF0%d 0x%08x\n", i, + pr_info(" SWF0%d 0x%08x\n", i, hw->swf0x[i]); } for (i = 0; i < 7; i++) { - printk(" SWF1%d 0x%08x\n", i, + pr_info(" SWF1%d 0x%08x\n", i, hw->swf1x[i]); } for (i = 0; i < 3; i++) { - printk(" SWF3%d 0x%08x\n", i, + pr_info(" SWF3%d 0x%08x\n", i, hw->swf3x[i]); } for (i = 0; i < 8; i++) - printk(" FENCE%d 0x%08x\n", i, + pr_info(" FENCE%d 0x%08x\n", i, hw->fence[i]); - printk(" INSTPM 0x%08x\n", hw->instpm); - printk(" MEM_MODE 0x%08x\n", hw->mem_mode); - printk(" FW_BLC_0 0x%08x\n", hw->fw_blc_0); - printk(" FW_BLC_1 0x%08x\n", hw->fw_blc_1); + pr_info(" INSTPM 0x%08x\n", hw->instpm); + pr_info(" MEM_MODE 0x%08x\n", hw->mem_mode); + pr_info(" FW_BLC_0 0x%08x\n", hw->fw_blc_0); + pr_info(" FW_BLC_1 0x%08x\n", hw->fw_blc_1); - printk("hw state dump end\n"); + pr_info("hw state dump end\n"); #endif } --- a/drivers/video/kyro/fbdev.c +++ b/drivers/video/kyro/fbdev.c @@ -740,7 +740,7 @@ static int __devinit kyrofb_probe(struct if (register_framebuffer(info) < 0) goto out_unmap; - printk("fb%d: %s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n", + pr_info("fb%d: %s frame buffer device, at %dx%d@%d using %ldk/%ldk of VRAM\n", info->node, info->fix.id, info->var.xres, info->var.yres, info->var.bits_per_pixel, size >> 10, (unsigned long)info->fix.smem_len >> 10); --- a/drivers/video/leo.c +++ b/drivers/video/leo.c @@ -613,7 +613,7 @@ static void leo_init_one(struct sbus_dev list_add(&all->list, &leo_list); - printk("leo: %s at %lx:%lx\n", + pr_info("leo: %s at %lx:%lx\n", sdev->prom_name, (long) sdev->reg_addrs[0].which_io, (long) sdev->reg_addrs[0].phys_addr); --- a/drivers/video/macfb.c +++ b/drivers/video/macfb.c @@ -639,9 +639,9 @@ static int __init macfb_init(void) Mac */ fb_info.screen_base = ioremap(mac_bi_data.videoaddr, macfb_fix.smem_len); - printk("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", + pr_info("macfb: framebuffer at 0x%08lx, mapped to 0x%p, size %dk\n", macfb_fix.smem_start, fb_info.screen_base, macfb_fix.smem_len/1024); - printk("macfb: mode is %dx%dx%d, linelength=%d\n", + pr_info("macfb: mode is %dx%dx%d, linelength=%d\n", macfb_defined.xres, macfb_defined.yres, macfb_defined.bits_per_pixel, macfb_fix.line_length); /* @@ -653,7 +653,7 @@ static int __init macfb_init(void) macfb_defined.height = PIXEL_TO_MM(macfb_defined.yres); macfb_defined.width = PIXEL_TO_MM(macfb_defined.xres); - printk("macfb: scrolling: redraw\n"); + pr_info("macfb: scrolling: redraw\n"); macfb_defined.yres_virtual = macfb_defined.yres; /* some dummy values for timing to make fbset happy */ @@ -689,7 +689,7 @@ static int __init macfb_init(void) macfb_defined.green.length = 5; macfb_defined.blue.offset = 0; macfb_defined.blue.length = 5; - printk("macfb: directcolor: " + pr_info("macfb: directcolor: " "size=1:5:5:5, shift=15:10:5:0\n"); video_cmap_len = 16; /* Should actually be FB_VISUAL_DIRECTCOLOR, but this @@ -706,14 +706,14 @@ static int __init macfb_init(void) macfb_defined.green.length = 8; macfb_defined.blue.offset = 0; macfb_defined.blue.length = 8; - printk("macfb: truecolor: " + pr_info("macfb: truecolor: " "size=0:8:8:8, shift=0:16:8:0\n"); video_cmap_len = 16; macfb_fix.visual = FB_VISUAL_TRUECOLOR; default: video_cmap_len = 0; macfb_fix.visual = FB_VISUAL_MONO01; - printk("macfb: unknown or unsupported bit depth: %d\n", macfb_defined.bits_per_pixel); + printk(KERN_WARNING "macfb: unknown or unsupported bit depth: %d\n", macfb_defined.bits_per_pixel); break; } @@ -961,8 +961,8 @@ static int __init macfb_init(void) err = register_framebuffer(&fb_info); if (!err) - printk("fb%d: %s frame buffer device\n", - fb_info.node, fb_info.fix.id); + pr_info("fb%d: %s frame buffer device\n", + fb_info.node, fb_info.fix.id); return err; } --- a/drivers/video/matrox/matroxfb_base.c +++ b/drivers/video/matrox/matroxfb_base.c @@ -1885,7 +1885,7 @@ static int initMatrox2(WPMINFO struct bo if (register_framebuffer(&ACCESS_FBINFO(fbcon)) < 0) { goto failVideoIO; } - printk("fb%d: %s frame buffer device\n", + pr_info("fb%d: %s frame buffer device\n", ACCESS_FBINFO(fbcon.node), ACCESS_FBINFO(fbcon.fix.id)); /* there is no console on this fb... but we have to initialize hardware --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c @@ -24,7 +24,7 @@ ((v).xres == (x) && (v).yres == (y)) #ifdef DEBUG -#define DPRINTK(fmt, args...) printk("modedb %s: " fmt, __FUNCTION__ , ## args) +#define DPRINTK(fmt, args...) pr_debug("modedb %s: " fmt, __FUNCTION__ , ## args) #else #define DPRINTK(fmt, args...) #endif --- a/drivers/video/neofb.c +++ b/drivers/video/neofb.c @@ -252,7 +252,7 @@ static void neoCalcVCLK(const struct fb_ par->VCLK3Denominator = d_best; #ifdef NEOFB_DEBUG - printk("neoVCLK: f:%d NumLow=%d NumHi=%d Den=%d Df=%d\n", + printk(KERN_DEBUG "neoVCLK: f:%d NumLow=%d NumHi=%d Den=%d Df=%d\n", f_target >> 12, par->VCLK3NumeratorLow, par->VCLK3NumeratorHigh, @@ -1728,13 +1728,13 @@ static int __devinit neo_map_mmio(struct if (!request_mem_region (info->fix.mmio_start, MMIO_SIZE, "memory mapped I/O")) { - printk("neofb: memory mapped IO in use\n"); + printk(KERN_ERR "neofb: memory mapped IO in use\n"); return -EBUSY; } par->mmio_vbase = ioremap(info->fix.mmio_start, MMIO_SIZE); if (!par->mmio_vbase) { - printk("neofb: unable to map memory mapped IO\n"); + printk(KERN_ERR "neofb: unable to map memory mapped IO\n"); release_mem_region(info->fix.mmio_start, info->fix.mmio_len); return -ENOMEM; @@ -1769,14 +1769,14 @@ static int __devinit neo_map_video(struc if (!request_mem_region(info->fix.smem_start, info->fix.smem_len, "frame buffer")) { - printk("neofb: frame buffer in use\n"); + printk(KERN_WARNING "neofb: frame buffer in use\n"); return -EBUSY; } info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); if (!info->screen_base) { - printk("neofb: unable to map screen memory\n"); + printk(KERN_ERR "neofb: unable to map screen memory\n"); release_mem_region(info->fix.smem_start, info->fix.smem_len); return -ENOMEM; --- a/drivers/video/p9100.c +++ b/drivers/video/p9100.c @@ -330,7 +330,7 @@ static void p9100_init_one(struct sbus_d list_add(&all->list, &p9100_list); - printk("p9100: %s at %lx:%lx\n", + pr_info("p9100: %s at %lx:%lx\n", sdev->prom_name, (long) sdev->reg_addrs[0].which_io, (long) sdev->reg_addrs[0].phys_addr); --- a/drivers/video/platinumfb.c +++ b/drivers/video/platinumfb.c @@ -146,7 +146,7 @@ static int platinumfb_set_par (struct fb FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_DIRECTCOLOR; info->fix.line_length = vmode_attrs[pinfo->vmode-1].hres * (1<cmode) + offset; - printk("line_length: %x\n", info->fix.line_length); + printk(KERN_DEBUG "line_length: %x\n", info->fix.line_length); return 0; } @@ -364,12 +364,12 @@ static int __devinit platinum_init_fb(st platinum_vram_reqd(default_vmode, default_cmode) > pinfo->total_vram) default_cmode--; - printk("platinumfb: Using video mode %d and color mode %d.\n", default_vmode, default_cmode); + pr_info("platinumfb: Using video mode %d and color mode %d.\n", default_vmode, default_cmode); /* Setup default var */ if (mac_vmode_to_var(default_vmode, default_cmode, &var) < 0) { /* This shouldn't happen! */ - printk("mac_vmode_to_var(%d, %d,) failed\n", default_vmode, default_cmode); + printk(KERN_ERR "mac_vmode_to_var(%d, %d,) failed\n", default_vmode, default_cmode); try_again: default_vmode = VMODE_640_480_60; default_cmode = CMODE_8; --- a/drivers/video/pm2fb.c +++ b/drivers/video/pm2fb.c @@ -73,8 +73,8 @@ static char *mode __devinitdata = NULL; * these flags allow the user to specify that requests for +ve sync * should be silently turned in -ve sync. */ -static int lowhsync __devinitdata = 0; -static int lowvsync __devinitdata = 0; +static int lowhsync = 0; +static int lowvsync = 0; /* * The hardware state of the graphics card that isn't part of the --- a/drivers/video/pm3fb.c +++ b/drivers/video/pm3fb.c @@ -1575,7 +1575,7 @@ static void pm3fb_common_init(struct pm3 pm3fb_write_mode(l_fb_info); - printk("fb%d: %s, using %uK of video memory (%s)\n", + pr_info("fb%d: %s, using %uK of video memory (%s)\n", l_fb_info->gen.info.node, permedia3_name, (u32) (l_fb_info->fb_size >> 10), cardbase[l_fb_info->board_type].cardname); --- a/drivers/video/pvr2fb.c +++ b/drivers/video/pvr2fb.c @@ -817,10 +817,10 @@ static int __init pvr2fb_common_init(voi rev = fb_readl(par->mmio_base + 0x04); - printk("fb%d: %s (rev %ld.%ld) frame buffer device, using %ldk/%ldk of video memory\n", + pr_info("fb%d: %s (rev %ld.%ld) frame buffer device, using %ldk/%ldk of video memory\n", fb_info->node, fb_info->fix.id, (rev >> 4) & 0x0f, rev & 0x0f, modememused >> 10, (unsigned long)(fb_info->fix.smem_len >> 10)); - printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", + pr_info("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", fb_info->node, fb_info->var.xres, fb_info->var.yres, fb_info->var.bits_per_pixel, get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel), --- a/drivers/video/retz3fb.c +++ b/drivers/video/retz3fb.c @@ -20,6 +20,8 @@ * for more details. */ +#undef DEBUG + #include #include #include @@ -44,9 +46,6 @@ #include "retz3fb.h" -/* #define DEBUG if(1) */ -#define DEBUG if(0) - /* * Reserve space for one pattern line. * @@ -125,6 +124,7 @@ static char fontname[40] __initdata = { static char retz3fb_name[16] = "RetinaZ3"; +#define DBG(fmt, args...) pr_debug("%s %s: " fmt, retz3fb_name, __FUNCTION__ , ## args) /* * A small info on how to convert XFree86 timing values into fb @@ -455,25 +455,25 @@ static int retz3_set_video(struct fb_inf #if 0 /* testing */ - printk("HBS: %i\n", data.h_bstart); - printk("HSS: %i\n", data.h_sstart); - printk("HSE: %i\n", data.h_sstop); - printk("HBE: %i\n", data.h_bstop); - printk("HT: %i\n", data.h_total); - - printk("hsync: %i\n", hsync); - printk("hfront: %i\n", hfront); - printk("hback: %i\n", hback); - - printk("VBS: %i\n", data.v_bstart); - printk("VSS: %i\n", data.v_sstart); - printk("VSE: %i\n", data.v_sstop); - printk("VBE: %i\n", data.v_bstop); - printk("VT: %i\n", data.v_total); - - printk("vsync: %i\n", vsync); - printk("vfront: %i\n", vfront); - printk("vback: %i\n", vback); + DBG("HBS: %i\n", data.h_bstart); + DBG("HSS: %i\n", data.h_sstart); + DBG("HSE: %i\n", data.h_sstop); + DBG("HBE: %i\n", data.h_bstop); + DBG("HT: %i\n", data.h_total); + + DBG("hsync: %i\n", hsync); + DBG("hfront: %i\n", hfront); + DBG("hback: %i\n", hback); + + DBG("VBS: %i\n", data.v_bstart); + DBG("VSS: %i\n", data.v_sstart); + DBG("VSE: %i\n", data.v_sstop); + DBG("VBE: %i\n", data.v_bstop); + DBG("VT: %i\n", data.v_total); + + DBG("vsync: %i\n", vsync); + DBG("vfront: %i\n", vfront); + DBG("vback: %i\n", vback); #endif if (data.v_total >= 1024) @@ -548,28 +548,28 @@ static int retz3_set_video(struct fb_inf crt_w(regs, CRT_END_VER_RETR, (data.v_sstop & 0x0f) | 0x20); /* Zuerst zu schreibende Werte nur per printk ausgeben */ - DEBUG printk("CRT_HOR_TOTAL: %ld\n", data.h_total); + DBG("CRT_HOR_TOTAL: %ld\n", data.h_total); crt_w(regs, CRT_HOR_TOTAL, data.h_total & 0xff); - DEBUG printk("CRT_HOR_DISP_ENA_END: %ld\n", data.h_dispend); + DBG("CRT_HOR_DISP_ENA_END: %ld\n", data.h_dispend); crt_w(regs, CRT_HOR_DISP_ENA_END, (data.h_dispend) & 0xff); - DEBUG printk("CRT_START_HOR_BLANK: %ld\n", data.h_bstart); + DBG("CRT_START_HOR_BLANK: %ld\n", data.h_bstart); crt_w(regs, CRT_START_HOR_BLANK, data.h_bstart & 0xff); - DEBUG printk("CRT_END_HOR_BLANK: 128+%ld\n", data.h_bstop % 32); + DBG("CRT_END_HOR_BLANK: 128+%ld\n", data.h_bstop % 32); crt_w(regs, CRT_END_HOR_BLANK, 0x80 | (data.h_bstop & 0x1f)); - DEBUG printk("CRT_START_HOR_RETR: %ld\n", data.h_sstart); + DBG("CRT_START_HOR_RETR: %ld\n", data.h_sstart); crt_w(regs, CRT_START_HOR_RETR, data.h_sstart & 0xff); tmp = (data.h_sstop & 0x1f); if (data.h_bstop & 0x20) tmp |= 0x80; - DEBUG printk("CRT_END_HOR_RETR: %d\n", tmp); + DBG("CRT_END_HOR_RETR: %d\n", tmp); crt_w(regs, CRT_END_HOR_RETR, tmp); - DEBUG printk("CRT_VER_TOTAL: %ld\n", data.v_total & 0xff); + DBG("CRT_VER_TOTAL: %ld\n", data.v_total & 0xff); crt_w(regs, CRT_VER_TOTAL, (data.v_total & 0xff)); tmp = 0x10; /* LineCompare bit #9 */ @@ -587,7 +587,7 @@ static int retz3_set_video(struct fb_inf tmp |= 0x40; if (data.v_sstart & 512) tmp |= 0x80; - DEBUG printk("CRT_OVERFLOW: %d\n", tmp); + DBG("CRT_OVERFLOW: %d\n", tmp); crt_w(regs, CRT_OVERFLOW, tmp); crt_w(regs, CRT_PRESET_ROW_SCAN, 0x00); /* not CL !!! */ @@ -597,7 +597,7 @@ static int retz3_set_video(struct fb_inf tmp |= 0x20; if (var->vmode & FB_VMODE_DOUBLE) tmp |= 0x80; - DEBUG printk("CRT_MAX_SCAN_LINE: %d\n", tmp); + DBG("CRT_MAX_SCAN_LINE: %d\n", tmp); crt_w(regs, CRT_MAX_SCAN_LINE, tmp); crt_w(regs, CRT_CURSOR_START, 0x00); @@ -609,30 +609,30 @@ static int retz3_set_video(struct fb_inf crt_w(regs, CRT_CURSOR_LOC_HIGH, 0x00); crt_w(regs, CRT_CURSOR_LOC_LOW, 0x00); - DEBUG printk("CRT_START_VER_RETR: %ld\n", data.v_sstart & 0xff); + DBG("CRT_START_VER_RETR: %ld\n", data.v_sstart & 0xff); crt_w(regs, CRT_START_VER_RETR, (data.v_sstart & 0xff)); #if 1 /* 5 refresh cycles per scanline */ - DEBUG printk("CRT_END_VER_RETR: 64+32+%ld\n", data.v_sstop % 16); + DBG("CRT_END_VER_RETR: 64+32+%ld\n", data.v_sstop % 16); crt_w(regs, CRT_END_VER_RETR, ((data.v_sstop & 0x0f) | 0x40 | 0x20)); #else - DEBUG printk("CRT_END_VER_RETR: 128+32+%ld\n", data.v_sstop % 16); + DBG("CRT_END_VER_RETR: 128+32+%ld\n", data.v_sstop % 16); crt_w(regs, CRT_END_VER_RETR, ((data.v_sstop & 0x0f) | 128 | 32)); #endif - DEBUG printk("CRT_VER_DISP_ENA_END: %ld\n", data.v_dispend & 0xff); + DBG("CRT_VER_DISP_ENA_END: %ld\n", data.v_dispend & 0xff); crt_w(regs, CRT_VER_DISP_ENA_END, (data.v_dispend & 0xff)); - DEBUG printk("CRT_START_VER_BLANK: %ld\n", data.v_bstart & 0xff); + DBG("CRT_START_VER_BLANK: %ld\n", data.v_bstart & 0xff); crt_w(regs, CRT_START_VER_BLANK, (data.v_bstart & 0xff)); - DEBUG printk("CRT_END_VER_BLANK: %ld\n", data.v_bstop & 0xff); + DBG("CRT_END_VER_BLANK: %ld\n", data.v_bstop & 0xff); crt_w(regs, CRT_END_VER_BLANK, (data.v_bstop & 0xff)); - DEBUG printk("CRT_MODE_CONTROL: 0xe3\n"); + DBG("CRT_MODE_CONTROL: 0xe3\n"); crt_w(regs, CRT_MODE_CONTROL, 0xe3); - DEBUG printk("CRT_LINE_COMPARE: 0xff\n"); + DBG("CRT_LINE_COMPARE: 0xff\n"); crt_w(regs, CRT_LINE_COMPARE, 0xff); tmp = (var->xres_virtual / 8) * (bpp / 8); @@ -651,7 +651,7 @@ static int retz3_set_video(struct fb_inf tmp |= 0x08; if (var->vmode & FB_VMODE_INTERLACED) tmp |= 0x10; - DEBUG printk("CRT_EXT_HOR_TIMING1: %d\n", tmp); + DBG("CRT_EXT_HOR_TIMING1: %d\n", tmp); crt_w(regs, CRT_EXT_HOR_TIMING1, tmp); tmp = 0x00; @@ -671,7 +671,7 @@ static int retz3_set_video(struct fb_inf tmp |= ((data.h_bstop & 0xc0) >> 2); tmp |= ((data.h_sstop & 0x60) << 1); crt_w(regs, CRT_EXT_HOR_TIMING2, tmp); - DEBUG printk("CRT_EXT_HOR_TIMING2: %d\n", tmp); + DBG("CRT_EXT_HOR_TIMING2: %d\n", tmp); tmp = 0x10; /* Line compare bit 10 */ if (data.v_total & 0x400) @@ -686,7 +686,7 @@ static int retz3_set_video(struct fb_inf if (data.v_sstop & 0x10) tmp |= 0x80; crt_w(regs, CRT_EXT_VER_TIMING, tmp); - DEBUG printk("CRT_EXT_VER_TIMING: %d\n", tmp); + DBG("CRT_EXT_VER_TIMING: %d\n", tmp); crt_w(regs, CRT_MONITOR_POWER, 0x00); --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c @@ -69,9 +69,10 @@ * * ------------------------------------------------------------------------- */ #ifdef CONFIG_FB_RIVA_DEBUG -#define NVTRACE printk +#define DEBUG +#define NVTRACE pr_debug #else -#define NVTRACE if(0) printk +#define NVTRACE if(0) pr_debug #endif #define NVTRACE_ENTER(...) NVTRACE("%s START\n", __FUNCTION__) @@ -80,7 +81,7 @@ #ifdef CONFIG_FB_RIVA_DEBUG #define assert(expr) \ if(!(expr)) { \ - printk( "Assertion failed! %s,%s,%s,line=%d\n",\ + pr_debug( "Assertion failed! %s,%s,%s,line=%d\n",\ #expr,__FILE__,__FUNCTION__,__LINE__); \ BUG(); \ } @@ -1753,7 +1754,7 @@ static int __devinit riva_get_EDID_i2c(s for (i = 0; i < par->bus; i++) { riva_probe_i2c_connector(par, i+1, &par->EDID); if (par->EDID && !fb_parse_edid(par->EDID, &var)) { - printk(PFX "Found EDID Block from BUS %i\n", i); + pr_info(PFX "Found EDID Block from BUS %i\n", i); break; } } @@ -1802,10 +1803,10 @@ static void __devinit riva_get_EDID(stru NVTRACE_ENTER(); #ifdef CONFIG_PPC_OF if (!riva_get_EDID_OF(info, pdev)) - printk(PFX "could not retrieve EDID from OF\n"); + pr_info(PFX "could not retrieve EDID from OF\n"); #elif defined(CONFIG_FB_RIVA_I2C) if (!riva_get_EDID_i2c(info)) - printk(PFX "could not retrieve EDID from DDC/I2C\n"); + pr_info(PFX "could not retrieve EDID from DDC/I2C\n"); #endif NVTRACE_LEAVE(); } --- a/drivers/video/savage/savagefb_driver.c +++ b/drivers/video/savage/savagefb_driver.c @@ -1545,7 +1545,7 @@ static int __devinit savage_map_mmio (st return 0; } -static void __devinit savage_unmap_mmio (struct fb_info *info) +static void savage_unmap_mmio (struct fb_info *info) { struct savagefb_par *par = info->par; DBG ("savage_unmap_mmio"); @@ -1597,7 +1597,7 @@ static int __devinit savage_map_video (s return 0; } -static void __devinit savage_unmap_video (struct fb_info *info) +static void savage_unmap_video (struct fb_info *info) { struct savagefb_par *par = info->par; @@ -1614,7 +1614,7 @@ static void __devinit savage_unmap_video } } -static int __devinit savage_init_hw (struct savagefb_par *par) +static int savage_init_hw (struct savagefb_par *par) { unsigned char config1, m, n, n1, n2, sr8, cr3f, cr66 = 0, tmp; --- a/drivers/video/sstfb.c +++ b/drivers/video/sstfb.c @@ -790,7 +790,7 @@ static int sstfb_ioctl(struct fb_info *i return -EFAULT; if (val > info->fix.smem_len) val = info->fix.smem_len; - printk("filling %#x \n", val); + printk(KERN_DEBUG "filling %#x \n", val); for (p=0 ; p> 6, info->screen_base + p); return 0; --- a/drivers/video/sun3fb.c +++ b/drivers/video/sun3fb.c @@ -645,7 +645,7 @@ sizechange: kfree(fb); return -EINVAL; } - printk("fb%d: %s\n", fb->info.node, p); + pr_info("fb%d: %s\n", fb->info.node, p); return 0; } @@ -667,14 +667,14 @@ int __init sun3fb_init(void) case FBTYPE_SUN3COLOR: case FBTYPE_SUN4COLOR: if(idprom->id_machtype != (SM_SUN3|SM_3_60)) { - printk("sun3fb: cgthree/four only supported on 3/60\n"); + printk(KERN_ERR "sun3fb: cgthree/four only supported on 3/60\n"); return -ENODEV; } addr = CGFOUR_OBMEM_ADDR; return sun3fb_init_fb(*(romvec->pv_fbtype), addr); default: - printk("sun3fb: unsupported framebuffer\n"); + printk(KERN_ERR "sun3fb: unsupported framebuffer\n"); return -ENODEV; } #else --- a/drivers/video/tcx.c +++ b/drivers/video/tcx.c @@ -462,7 +462,7 @@ static void tcx_init_one(struct sbus_dev list_add(&all->list, &tcx_list); - printk("tcx: %s at %lx:%lx, %s\n", + pr_info("tcx: %s at %lx:%lx, %s\n", sdev->prom_name, (long) sdev->reg_addrs[0].which_io, (long) sdev->reg_addrs[0].phys_addr, --- a/drivers/video/tdfxfb.c +++ b/drivers/video/tdfxfb.c @@ -4,7 +4,7 @@ * * Author: Hannu Mallat * - * Copyright © 1999 Hannu Mallat + * Copyright 1999 Hannu Mallat * All rights reserved * * Created : Thu Sep 23 18:17:43 1999, hmallat @@ -1201,7 +1201,7 @@ static int __devinit tdfxfb_probe(struct tdfx_fix.mmio_len = pci_resource_len(pdev, 0); default_par->regbase_virt = ioremap_nocache(tdfx_fix.mmio_start, tdfx_fix.mmio_len); if (!default_par->regbase_virt) { - printk("fb: Can't remap %s register area.\n", tdfx_fix.id); + printk(KERN_WARNING "fb: Can't remap %s register area.\n", tdfx_fix.id); goto out_err; } @@ -1213,7 +1213,7 @@ static int __devinit tdfxfb_probe(struct tdfx_fix.smem_start = pci_resource_start(pdev, 1); if (!(tdfx_fix.smem_len = do_lfb_size(default_par, pdev->device))) { - printk("fb: Can't count %s memory.\n", tdfx_fix.id); + printk(KERN_WARNING "fb: Can't count %s memory.\n", tdfx_fix.id); release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); goto out_err; @@ -1230,7 +1230,7 @@ static int __devinit tdfxfb_probe(struct info->screen_base = ioremap_nocache(tdfx_fix.smem_start, tdfx_fix.smem_len); if (!info->screen_base) { - printk("fb: Can't remap %s framebuffer.\n", tdfx_fix.id); + printk(KERN_WARNING "fb: Can't remap %s framebuffer.\n", tdfx_fix.id); release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); release_mem_region(pci_resource_start(pdev, 0), @@ -1250,7 +1250,7 @@ static int __devinit tdfxfb_probe(struct goto out_err; } - printk("fb: %s memory = %dK\n", tdfx_fix.id, tdfx_fix.smem_len >> 10); + pr_info("fb: %s memory = %dK\n", tdfx_fix.id, tdfx_fix.smem_len >> 10); tdfx_fix.ypanstep = nopan ? 0 : 1; tdfx_fix.ywrapstep = nowrap ? 0 : 1; @@ -1293,7 +1293,7 @@ static int __devinit tdfxfb_probe(struct } if (register_framebuffer(info) < 0) { - printk("tdfxfb: can't register framebuffer\n"); + printk(KERN_WARNING "tdfxfb: can't register framebuffer\n"); fb_dealloc_cmap(&info->cmap); goto out_err; } --- a/drivers/video/virgefb.c +++ b/drivers/video/virgefb.c @@ -1,7 +1,7 @@ /* * linux/drivers/video/virgefb.c -- CyberVision64/3D frame buffer device * - * Copyright (C) 1997 André Heynatz + * Copyright (C) 1997 Andr�Heynatz * * * This file is based on the CyberVision frame buffer device (cyberfb.c): @@ -2156,7 +2156,7 @@ static unsigned short virgefb_compute_cl } } if (save == ~0UL) - printk("Can't compute clock PLL values for %ld Hz clock\n", freq); + printk(KERN_NOTICE "Can't compute clock PLL values for %ld Hz clock\n", freq); DPRINTK("EXIT\n"); return(mnr); } @@ -2434,20 +2434,20 @@ static void cv64_dump(void) printk("\n"); for (i = 0; i <= 0x6f; i++) { wb_mmio(CRT_ADDRESS, i); - printk("crt idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(CRT_ADDRESS_R)); + pr_info("crt idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(CRT_ADDRESS_R)); } for (i = 0; i <= 0x1c; i++) { wb_mmio(SEQ_ADDRESS, i); - printk("seq idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(SEQ_ADDRESS_R)); + pr_info("seq idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(SEQ_ADDRESS_R)); } for (i = 0; i <= 8; i++) { wb_mmio(GCT_ADDRESS, i); - printk("gfx idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(GCT_ADDRESS_R)); + pr_info("gfx idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(GCT_ADDRESS_R)); } for (i = 0; i <= 0x14; i++) { c = rb_mmio(ACT_ADDRESS_RESET); wb_mmio(ACT_ADDRESS_W, i); - printk("atr idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(ACT_ADDRESS_R)); + pr_info("atr idx : 0x%2.2x : 0x%2.2x\n", i, rb_mmio(ACT_ADDRESS_R)); } /* re-enable video access to palette */ @@ -2460,23 +2460,23 @@ static void cv64_dump(void) /* general regs */ - printk("0x3cc(w 0x3c2) : 0x%2.2x\n", rb_mmio(0x3cc)); /* GREG_MISC_OUTPUT READ */ - printk("0x3c2(-------) : 0x%2.2x\n", rb_mmio(0x3c2)); /* GREG_INPUT_STATUS 0 READ */ - printk("0x3c3(w 0x3c3) : 0x%2.2x\n", rb_vgaio(0x3c3)); /* GREG_VIDEO_SUBS_ENABLE */ - printk("0x3ca(w 0x3da) : 0x%2.2x\n", rb_vgaio(0x3ca)); /* GREG_FEATURE_CONTROL read */ - printk("0x3da(-------) : 0x%2.2x\n", rb_mmio(0x3da)); /* GREG_INPUT_STATUS 1 READ */ + pr_info("0x3cc(w 0x3c2) : 0x%2.2x\n", rb_mmio(0x3cc)); /* GREG_MISC_OUTPUT READ */ + pr_info("0x3c2(-------) : 0x%2.2x\n", rb_mmio(0x3c2)); /* GREG_INPUT_STATUS 0 READ */ + pr_info("0x3c3(w 0x3c3) : 0x%2.2x\n", rb_vgaio(0x3c3)); /* GREG_VIDEO_SUBS_ENABLE */ + pr_info("0x3ca(w 0x3da) : 0x%2.2x\n", rb_vgaio(0x3ca)); /* GREG_FEATURE_CONTROL read */ + pr_info("0x3da(-------) : 0x%2.2x\n", rb_mmio(0x3da)); /* GREG_INPUT_STATUS 1 READ */ /* engine regs */ for (i = 0x8180; i <= 0x8200; i = i + 4) - printk("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); + pr_info("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); i = 0x8504; - printk("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); + pr_info("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); i = 0x850c; - printk("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); + pr_info("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); for (i = 0xa4d4; i <= 0xa50c; i = i + 4) - printk("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); + pr_info("0x%8.8x : 0x%8.8x\n", i, rl_mmio(i)); /* PCI regs */ @@ -2484,29 +2484,29 @@ static void cv64_dump(void) for (c = 0; c < 0x08; c = c + 2) { w = (*((u16 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000)) ^ 2))); - printk("pci 0x%2.2x : 0x%4.4x\n", c, w); + pr_info("pci 0x%2.2x : 0x%4.4x\n", c, w); } c = 8; l = (*((u32 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000))))); - printk("pci 0x%2.2x : 0x%8.8x\n", c, l); + pr_info("pci 0x%2.2x : 0x%8.8x\n", c, l); c = 0x0d; b = (*((u8 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000)) ^ 3))); - printk("pci 0x%2.2x : 0x%2.2x\n", c, b); + pr_info("pci 0x%2.2x : 0x%2.2x\n", c, b); c = 0x10; l = (*((u32 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000))))); - printk("pci 0x%2.2x : 0x%8.8x\n", c, l); + pr_info("pci 0x%2.2x : 0x%8.8x\n", c, l); c = 0x30; l = (*((u32 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000))))); - printk("pci 0x%2.2x : 0x%8.8x\n", c, l); + pr_info("pci 0x%2.2x : 0x%8.8x\n", c, l); c = 0x3c; b = (*((u8 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000)) ^ 3))); - printk("pci 0x%2.2x : 0x%2.2x\n", c, b); + pr_info("pci 0x%2.2x : 0x%2.2x\n", c, b); c = 0x3d; b = (*((u8 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000)) ^ 3))); - printk("pci 0x%2.2x : 0x%2.2x\n", c, b); + pr_info("pci 0x%2.2x : 0x%2.2x\n", c, b); c = 0x3e; w = (*((u16 *)((u32)(vgaio_regs + c + (on_zorro2 ? 0 : 0x000e0000)) ^ 2))); - printk("pci 0x%2.2x : 0x%4.4x\n", c, w); + pr_info("pci 0x%2.2x : 0x%4.4x\n", c, w); SelectMMIO; } #endif --- a/drivers/video/w100fb.c +++ b/drivers/video/w100fb.c @@ -115,7 +115,7 @@ static ssize_t w100fb_reg_read(struct de unsigned long regs, param; regs = simple_strtoul(buf, NULL, 16); param = readl(remapped_regs + regs); - printk("Read Register 0x%08lX: 0x%08lX\n", regs, param); + printk(KERN_DEBUG "Read Register 0x%08lX: 0x%08lX\n", regs, param); return count; } @@ -127,7 +127,7 @@ static ssize_t w100fb_reg_write(struct d sscanf(buf, "%lx %lx", ®s, ¶m); if (regs <= 0x2000) { - printk("Write Register 0x%08lX: 0x%08lX\n", regs, param); + printk(KERN_DEBUG "Write Register 0x%08lX: 0x%08lX\n", regs, param); writel(param, remapped_regs + regs); } @@ -152,10 +152,10 @@ static ssize_t fastpllclk_store(struct d if (simple_strtoul(buf, NULL, 10) > 0) { par->fastpll_mode=1; - printk("w100fb: Using fast system clock (if possible)\n"); + printk(KERN_INFO "w100fb: Using fast system clock (if possible)\n"); } else { par->fastpll_mode=0; - printk("w100fb: Using normal system clock\n"); + printk(KERN_INFO "w100fb: Using normal system clock\n"); } w100_init_clocks(par); --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include --- a/fs/affs/bitmap.c +++ b/fs/affs/bitmap.c @@ -289,12 +289,11 @@ int affs_init_bitmap(struct super_block sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved + sbi->s_bmap_bits - 1) / sbi->s_bmap_bits; size = sbi->s_bmap_count * sizeof(*bm); - bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL); + bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL); if (!sbi->s_bitmap) { printk(KERN_ERR "AFFS: Bitmap allocation failed\n"); return -ENOMEM; } - memset(sbi->s_bitmap, 0, size); bmap_blk = (__be32 *)sbi->s_root_bh->b_data; blk = sb->s_blocksize / 4 - 49; --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -278,11 +278,10 @@ static int affs_fill_super(struct super_ sb->s_op = &affs_sops; sb->s_flags |= MS_NODIRATIME; - sbi = kmalloc(sizeof(struct affs_sb_info), GFP_KERNEL); + sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); if (!sbi) return -ENOMEM; sb->s_fs_info = sbi; - memset(sbi, 0, sizeof(*sbi)); init_MUTEX(&sbi->s_bmlock); if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, --- a/fs/afs/vlocation.c +++ b/fs/afs/vlocation.c @@ -281,11 +281,10 @@ int afs_vlocation_lookup(struct afs_cell spin_unlock(&cell->vl_gylock); /* not in the cell's in-memory lists - create a new record */ - vlocation = kmalloc(sizeof(struct afs_vlocation), GFP_KERNEL); + vlocation = kzalloc(sizeof(struct afs_vlocation), GFP_KERNEL); if (!vlocation) return -ENOMEM; - memset(vlocation, 0, sizeof(struct afs_vlocation)); atomic_set(&vlocation->usage, 1); INIT_LIST_HEAD(&vlocation->link); rwlock_init(&vlocation->lock); --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -186,11 +186,10 @@ int afs_volume_lookup(const char *name, _debug("creating new volume record"); ret = -ENOMEM; - volume = kmalloc(sizeof(struct afs_volume), GFP_KERNEL); + volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL); if (!volume) goto error_up; - memset(volume, 0, sizeof(struct afs_volume)); atomic_set(&volume->usage, 1); volume->type = type; volume->type_force = force; --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -610,11 +610,10 @@ static int ext2_fill_super(struct super_ int i, j; __le32 features; - sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) return -ENOMEM; sb->s_fs_info = sbi; - memset(sbi, 0, sizeof(*sbi)); /* * See what the current blocksize for the device is, and --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -521,11 +521,10 @@ bad_block: ext2_error(sb, "ext2_xattr_s } } else { /* Allocate a buffer where we construct the new block. */ - header = kmalloc(sb->s_blocksize, GFP_KERNEL); + header = kzalloc(sb->s_blocksize, GFP_KERNEL); error = -ENOMEM; if (header == NULL) goto cleanup; - memset(header, 0, sb->s_blocksize); end = (char *)header + sb->s_blocksize; header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC); header->h_blocks = header->h_refcount = cpu_to_le32(1); --- a/fs/ext3/dir.c +++ b/fs/ext3/dir.c @@ -343,10 +343,9 @@ int ext3_htree_store_dirent(struct file /* Create and allocate the fname structure */ len = sizeof(struct fname) + dirent->name_len + 1; - new_fn = kmalloc(len, GFP_KERNEL); + new_fn = kzalloc(len, GFP_KERNEL); if (!new_fn) return -ENOMEM; - memset(new_fn, 0, len); new_fn->hash = hash; new_fn->minor_hash = minor_hash; new_fn->inode = le32_to_cpu(dirent->inode); --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1355,11 +1355,10 @@ static int ext3_fill_super (struct super int needs_recovery; __le32 features; - sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) return -ENOMEM; sb->s_fs_info = sbi; - memset(sbi, 0, sizeof(*sbi)); sbi->s_mount_opt = 0; sbi->s_resuid = EXT3_DEF_RESUID; sbi->s_resgid = EXT3_DEF_RESGID; --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c @@ -733,12 +733,11 @@ ext3_xattr_block_set(handle_t *handle, s } } else { /* Allocate a buffer where we construct the new block. */ - s->base = kmalloc(sb->s_blocksize, GFP_KERNEL); + s->base = kzalloc(sb->s_blocksize, GFP_KERNEL); /* assert(header == s->base) */ error = -ENOMEM; if (s->base == NULL) goto cleanup; - memset(s->base, 0, sb->s_blocksize); header(s->base)->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); header(s->base)->h_blocks = cpu_to_le32(1); header(s->base)->h_refcount = cpu_to_le32(1); --- a/fs/hfs/bnode.c +++ b/fs/hfs/bnode.c @@ -249,10 +249,9 @@ static struct hfs_bnode *__hfs_bnode_cre sb = tree->inode->i_sb; size = sizeof(struct hfs_bnode) + tree->pages_per_bnode * sizeof(struct page *); - node = kmalloc(size, GFP_KERNEL); + node = kzalloc(size, GFP_KERNEL); if (!node) return NULL; - memset(node, 0, size); node->tree = tree; node->this = cnid; set_bit(HFS_BNODE_NEW, &node->flags); --- a/fs/hfs/btree.c +++ b/fs/hfs/btree.c @@ -21,10 +21,9 @@ struct hfs_btree *hfs_btree_open(struct struct page *page; unsigned int size; - tree = kmalloc(sizeof(*tree), GFP_KERNEL); + tree = kzalloc(sizeof(*tree), GFP_KERNEL); if (!tree) return NULL; - memset(tree, 0, sizeof(*tree)); init_MUTEX(&tree->tree_lock); spin_lock_init(&tree->hash_lock); --- a/fs/hfs/super.c +++ b/fs/hfs/super.c @@ -355,11 +355,10 @@ static int hfs_fill_super(struct super_b struct inode *root_inode; int res; - sbi = kmalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); + sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); if (!sbi) return -ENOMEM; sb->s_fs_info = sbi; - memset(sbi, 0, sizeof(struct hfs_sb_info)); INIT_HLIST_HEAD(&sbi->rsrc_inodes); res = -EINVAL; --- a/fs/hfsplus/bnode.c +++ b/fs/hfsplus/bnode.c @@ -409,10 +409,9 @@ static struct hfs_bnode *__hfs_bnode_cre sb = tree->inode->i_sb; size = sizeof(struct hfs_bnode) + tree->pages_per_bnode * sizeof(struct page *); - node = kmalloc(size, GFP_KERNEL); + node = kzalloc(size, GFP_KERNEL); if (!node) return NULL; - memset(node, 0, size); node->tree = tree; node->this = cnid; set_bit(HFS_BNODE_NEW, &node->flags); --- a/fs/hfsplus/btree.c +++ b/fs/hfsplus/btree.c @@ -24,10 +24,9 @@ struct hfs_btree *hfs_btree_open(struct struct page *page; unsigned int size; - tree = kmalloc(sizeof(*tree), GFP_KERNEL); + tree = kzalloc(sizeof(*tree), GFP_KERNEL); if (!tree) return NULL; - memset(tree, 0, sizeof(*tree)); init_MUTEX(&tree->tree_lock); spin_lock_init(&tree->hash_lock); --- a/fs/jffs2/histo.h +++ b/fs/jffs2/histo.h 1970-01-01 03:00:00.000000000 +0300 @@ -1,3 +0,0 @@ -/* This file provides the bit-probabilities for the input file */ -#define BIT_DIVIDER 629 -static int bits[9] = { 179,167,183,165,159,198,178,119,}; /* ia32 .so files */ --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c @@ -204,7 +204,7 @@ static inline int read_dnode(struct jffs tn = jffs2_alloc_tmp_dnode_info(); if (!tn) { - JFFS2_ERROR("failed to allocate tn (%d bytes).\n", sizeof(*tn)); + JFFS2_ERROR("failed to allocate tn (%zu bytes).\n", sizeof(*tn)); return -ENOMEM; } @@ -434,7 +434,7 @@ static int read_more(struct jffs2_sb_inf } if (retlen < len) { - JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", + JFFS2_ERROR("short read at %#08x: %zu instead of %d.\n", offs, retlen, len); return -EIO; } @@ -542,7 +542,7 @@ static int jffs2_get_inode_nodes(struct } if (retlen < len) { - JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ref_offset(ref), retlen, len); + JFFS2_ERROR("short read at %#08x: %zu instead of %d.\n", ref_offset(ref), retlen, len); err = -EIO; goto free_out; } --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -100,9 +100,8 @@ nlm_lookup_host(int server, struct socka /* Ooops, no host found, create it */ dprintk("lockd: creating host entry\n"); - if (!(host = (struct nlm_host *) kmalloc(sizeof(*host), GFP_KERNEL))) + if (!(host = (struct nlm_host *) kzalloc(sizeof(*host), GFP_KERNEL))) goto nohost; - memset(host, 0, sizeof(*host)); addr = sin->sin_addr.s_addr; sprintf(host->h_name, "%u.%u.%u.%u", NIPQUAD(addr)); --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -284,6 +285,7 @@ EXPORT_SYMBOL(lockd_up); void lockd_down(void) { + DEFINE_WAIT(wait); static int warned; mutex_lock(&nlmsvc_mutex); @@ -306,7 +308,9 @@ lockd_down(void) * the lockd semaphore, we can't wait around forever ... */ clear_thread_flag(TIF_SIGPENDING); - interruptible_sleep_on_timeout(&lockd_exit, HZ); + prepare_to_wait(&lockd_exit, &wait, TASK_INTERRUPTIBLE); + schedule_timeout(HZ); + finish_wait(&lockd_exit, &wait); if (nlmsvc_pid) { printk(KERN_WARNING "lockd_down: lockd failed to exit, clearing pid\n"); --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -101,11 +101,10 @@ nlm_lookup_file(struct svc_rqst *rqstp, nlm_debug_print_fh("creating file for", f); nfserr = nlm_lck_denied_nolocks; - file = (struct nlm_file *) kmalloc(sizeof(*file), GFP_KERNEL); + file = (struct nlm_file *) kzalloc(sizeof(*file), GFP_KERNEL); if (!file) goto out_unlock; - memset(file, 0, sizeof(*file)); memcpy(&file->f_handle, f, sizeof(struct nfs_fh)); file->f_hash = hash; init_MUTEX(&file->f_sema); --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -338,11 +338,10 @@ void add_partition(struct gendisk *disk, { struct hd_struct *p; - p = kmalloc(sizeof(*p), GFP_KERNEL); + p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) return; - memset(p, 0, sizeof(*p)); p->start_sect = start; p->nr_sects = len; p->partno = part; --- a/fs/partitions/efi.c +++ b/fs/partitions/efi.c @@ -239,10 +239,9 @@ alloc_read_gpt_entries(struct block_devi le32_to_cpu(gpt->sizeof_partition_entry); if (!count) return NULL; - pte = kmalloc(count, GFP_KERNEL); + pte = kzalloc(count, GFP_KERNEL); if (!pte) return NULL; - memset(pte, 0, count); if (read_lba(bdev, le64_to_cpu(gpt->partition_entry_lba), (u8 *) pte, @@ -270,10 +269,9 @@ alloc_read_gpt_header(struct block_devic if (!bdev) return NULL; - gpt = kmalloc(sizeof (gpt_header), GFP_KERNEL); + gpt = kzalloc(sizeof (gpt_header), GFP_KERNEL); if (!gpt) return NULL; - memset(gpt, 0, sizeof (gpt_header)); if (read_lba(bdev, lba, (u8 *) gpt, sizeof (gpt_header)) < sizeof (gpt_header)) { @@ -527,9 +525,8 @@ find_valid_gpt(struct block_device *bdev lastlba = last_lba(bdev); if (!force_gpt) { /* This will be added to the EFI Spec. per Intel after v1.02. */ - legacymbr = kmalloc(sizeof (*legacymbr), GFP_KERNEL); + legacymbr = kzalloc(sizeof (*legacymbr), GFP_KERNEL); if (legacymbr) { - memset(legacymbr, 0, sizeof (*legacymbr)); read_lba(bdev, 0, (u8 *) legacymbr, sizeof (*legacymbr)); good_pmbr = is_pmbr_valid(legacymbr, lastlba); --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -282,12 +282,11 @@ read_kcore(struct file *file, char __use tsz = elf_buflen - *fpos; if (buflen < tsz) tsz = buflen; - elf_buf = kmalloc(elf_buflen, GFP_ATOMIC); + elf_buf = kzalloc(elf_buflen, GFP_ATOMIC); if (!elf_buf) { read_unlock(&kclist_lock); return -ENOMEM; } - memset(elf_buf, 0, elf_buflen); elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen); read_unlock(&kclist_lock); if (copy_to_user(buffer, elf_buf + *fpos, tsz)) { @@ -333,10 +332,9 @@ read_kcore(struct file *file, char __use unsigned long curstart = start; unsigned long cursize = tsz; - elf_buf = kmalloc(tsz, GFP_KERNEL); + elf_buf = kzalloc(tsz, GFP_KERNEL); if (!elf_buf) return -ENOMEM; - memset(elf_buf, 0, tsz); read_lock(&vmlist_lock); for (m=vmlist; m && cursize; m=m->next) { --- a/fs/proc/proc_tty.c +++ b/fs/proc/proc_tty.c @@ -227,13 +227,8 @@ void __init proc_tty_init(void) if (!proc_mkdir("tty", NULL)) return; 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, NULL); + + proc_tty_driver = proc_mkdir("tty/driver", NULL); create_proc_read_entry("tty/ldiscs", 0, NULL, tty_ldiscs_read_proc, NULL); entry = create_proc_entry("tty/drivers", 0, NULL); --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -179,12 +179,7 @@ const struct file_operations proc_vmcore static struct vmcore* __init get_new_element(void) { - struct vmcore *p; - - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p) - memset(p, 0, sizeof(*p)); - return p; + return kzalloc(sizeof(struct vmcore), GFP_KERNEL); } static u64 __init get_vmcore_size_elf64(char *elfptr) --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -2881,7 +2881,7 @@ static void queue_log_writer(struct supe set_current_state(TASK_UNINTERRUPTIBLE); if (test_bit(J_WRITERS_QUEUED, &journal->j_state)) schedule(); - current->state = TASK_RUNNING; + __set_current_state(TASK_RUNNING); remove_wait_queue(&journal->j_join_wait, &wait); } --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c @@ -129,14 +129,12 @@ struct inode * udf_new_inode (struct ino { UDF_I_EFE(inode) = 1; UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); - UDF_I_DATA(inode) = kmalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); - memset(UDF_I_DATA(inode), 0x00, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry)); + UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); } else { UDF_I_EFE(inode) = 0; - UDF_I_DATA(inode) = kmalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); - memset(UDF_I_DATA(inode), 0x00, inode->i_sb->s_blocksize - sizeof(struct fileEntry)); + UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); } if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -780,7 +780,6 @@ static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root) { struct buffer_head *bh = NULL; - long lastblock; uint16_t ident; if (fileset->logicalBlockNum != 0xFFFFFFFF || @@ -800,58 +799,7 @@ udf_find_fileset(struct super_block *sb, if (!bh) /* Search backwards through the partitions */ { - kernel_lb_addr newfileset; - return 1; - - for (newfileset.partitionReferenceNum=UDF_SB_NUMPARTS(sb)-1; - (newfileset.partitionReferenceNum != 0xFFFF && - fileset->logicalBlockNum == 0xFFFFFFFF && - fileset->partitionReferenceNum == 0xFFFF); - newfileset.partitionReferenceNum--) - { - lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum); - newfileset.logicalBlockNum = 0; - - do - { - bh = udf_read_ptagged(sb, newfileset, 0, &ident); - if (!bh) - { - newfileset.logicalBlockNum ++; - continue; - } - - switch (ident) - { - case TAG_IDENT_SBD: - { - struct spaceBitmapDesc *sp; - sp = (struct spaceBitmapDesc *)bh->b_data; - newfileset.logicalBlockNum += 1 + - ((le32_to_cpu(sp->numOfBytes) + sizeof(struct spaceBitmapDesc) - 1) - >> sb->s_blocksize_bits); - udf_release_data(bh); - break; - } - case TAG_IDENT_FSD: - { - *fileset = newfileset; - break; - } - default: - { - newfileset.logicalBlockNum ++; - udf_release_data(bh); - bh = NULL; - break; - } - } - } - while (newfileset.logicalBlockNum < lastblock && - fileset->logicalBlockNum == 0xFFFFFFFF && - fileset->partitionReferenceNum == 0xFFFF); - } } if ((fileset->logicalBlockNum != 0xFFFFFFFF || @@ -1505,11 +1453,10 @@ static int udf_fill_super(struct super_b uopt.gid = -1; uopt.umask = 0; - sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); + sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); if (!sbi) return -ENOMEM; sb->s_fs_info = sbi; - memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); mutex_init(&sbi->s_alloc_mutex); --- a/include/asm-arm/hardware/linkup-l1110.h +++ b/include/asm-arm/hardware/linkup-l1110.h 1970-01-01 03:00:00.000000000 +0300 @@ -1,48 +0,0 @@ -/* -* -* Definitions for H3600 Handheld Computer -* -* Copyright 2001 Compaq Computer Corporation. -* -* Use consistent with the GNU GPL is permitted, -* provided that this copyright notice is -* preserved in its entirety in all copies and derived works. -* -* COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, -* AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS -* FITNESS FOR ANY PARTICULAR PURPOSE. -* -* Author: Jamey Hicks. -* -*/ - -/* LinkUp Systems PCCard/CompactFlash Interface for SA-1100 */ - -/* PC Card Status Register */ -#define LINKUP_PRS_S1 (1 << 0) /* voltage control bits S1-S4 */ -#define LINKUP_PRS_S2 (1 << 1) -#define LINKUP_PRS_S3 (1 << 2) -#define LINKUP_PRS_S4 (1 << 3) -#define LINKUP_PRS_BVD1 (1 << 4) -#define LINKUP_PRS_BVD2 (1 << 5) -#define LINKUP_PRS_VS1 (1 << 6) -#define LINKUP_PRS_VS2 (1 << 7) -#define LINKUP_PRS_RDY (1 << 8) -#define LINKUP_PRS_CD1 (1 << 9) -#define LINKUP_PRS_CD2 (1 << 10) - -/* PC Card Command Register */ -#define LINKUP_PRC_S1 (1 << 0) -#define LINKUP_PRC_S2 (1 << 1) -#define LINKUP_PRC_S3 (1 << 2) -#define LINKUP_PRC_S4 (1 << 3) -#define LINKUP_PRC_RESET (1 << 4) -#define LINKUP_PRC_APOE (1 << 5) /* Auto Power Off Enable: clears S1-S4 when either nCD goes high */ -#define LINKUP_PRC_CFE (1 << 6) /* CompactFlash mode Enable: addresses A[10:0] only, A[25:11] high */ -#define LINKUP_PRC_SOE (1 << 7) /* signal output driver enable */ -#define LINKUP_PRC_SSP (1 << 8) /* sock select polarity: 0 for socket 0, 1 for socket 1 */ -#define LINKUP_PRC_MBZ (1 << 15) /* must be zero */ - -struct linkup_l1110 { - volatile short prc; -}; --- a/include/asm-mips/gfx.h +++ b/include/asm-mips/gfx.h 1970-01-01 03:00:00.000000000 +0300 @@ -1,55 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * This is the user-visible SGI GFX interface. - * - * This must be used verbatim into the GNU libc. It does not include - * any kernel-only bits on it. - * - * miguel@nuclecu.unam.mx - */ -#ifndef _ASM_GFX_H -#define _ASM_GFX_H - -/* The iocls, yes, they do not make sense, but such is life */ -#define GFX_BASE 100 -#define GFX_GETNUM_BOARDS (GFX_BASE + 1) -#define GFX_GETBOARD_INFO (GFX_BASE + 2) -#define GFX_ATTACH_BOARD (GFX_BASE + 3) -#define GFX_DETACH_BOARD (GFX_BASE + 4) -#define GFX_IS_MANAGED (GFX_BASE + 5) - -#define GFX_MAPALL (GFX_BASE + 10) -#define GFX_LABEL (GFX_BASE + 11) - -#define GFX_INFO_NAME_SIZE 16 -#define GFX_INFO_LABEL_SIZE 16 - -struct gfx_info { - char name [GFX_INFO_NAME_SIZE]; /* board name */ - char label [GFX_INFO_LABEL_SIZE]; /* label name */ - unsigned short int xpmax, ypmax; /* screen resolution */ - unsigned int lenght; /* size of a complete gfx_info for this board */ -}; - -struct gfx_getboardinfo_args { - unsigned int board; /* board number. starting from zero */ - void *buf; /* pointer to gfx_info */ - unsigned int len; /* buffer size of buf */ -}; - -struct gfx_attach_board_args { - unsigned int board; /* board number, starting from zero */ - void *vaddr; /* address where the board registers should be mapped */ -}; - -#ifdef __KERNEL__ -/* umap.c */ -extern void remove_mapping (struct vm_area_struct *vma, struct task_struct *, unsigned long, unsigned long); -extern void *vmalloc_uncached (unsigned long size); -extern int vmap_page_range (struct vm_area_struct *vma, unsigned long from, unsigned long size, unsigned long vaddr); -#endif - -#endif /* _ASM_GFX_H */ --- a/include/linux/amifdreg.h +++ b/include/linux/amifdreg.h @@ -15,25 +15,11 @@ */ #define DSKMOTOR (0x1<<7) /* motor on when low */ -#define DSKSEL3 (0x1<<6) /* select drive 3 when low */ -#define DSKSEL2 (0x1<<5) /* select drive 2 when low */ -#define DSKSEL1 (0x1<<4) /* select drive 1 when low */ -#define DSKSEL0 (0x1<<3) /* select drive 0 when low */ #define DSKSIDE (0x1<<2) /* side selection: 0 = upper, 1 = lower */ #define DSKDIREC (0x1<<1) /* step direction: 0=in, 1=out (to trk 0) */ #define DSKSTEP (0x1) /* pulse low to step head 1 track */ /* -** DSKBYTR bits (read only) -*/ - -#define DSKBYT (1<<15) /* register contains valid byte when set */ -#define DMAON (1<<14) /* disk DMA enabled */ -#define DISKWRITE (1<<13) /* disk write bit in DSKLEN enabled */ -#define WORDEQUAL (1<<12) /* DSKSYNC register match when true */ -/* bits 7-0 are data */ - -/* ** ADKCON/ADKCONR bits */ @@ -42,7 +28,6 @@ #endif #define ADK_PRECOMP1 (1<<14) /* precompensation selection */ #define ADK_PRECOMP0 (1<<13) /* 00=none, 01=140ns, 10=280ns, 11=500ns */ -#define ADK_MFMPREC (1<<12) /* 0=GCR precomp., 1=MFM precomp. */ #define ADK_WORDSYNC (1<<10) /* enable DSKSYNC auto DMA */ #define ADK_MSBSYNC (1<<9) /* when 1, enable sync on MSbit (for GCR) */ #define ADK_FAST (1<<8) /* bit cell: 0=2us (GCR), 1=1us (MFM) */ @@ -55,12 +40,6 @@ #define DSKLEN_WRITE (1<<14) /* -** INTENA/INTREQ bits -*/ - -#define DSKINDEX (0x1<<4) /* DSKINDEX bit */ - -/* ** Misc */ --- a/include/linux/atmdev.h +++ b/include/linux/atmdev.h @@ -29,18 +29,12 @@ #define ATM_DS3_PCR (8000*12) /* DS3: 12 cells in a 125 usec time slot */ - -#define __AAL_STAT_ITEMS \ - __HANDLE_ITEM(tx); /* TX okay */ \ - __HANDLE_ITEM(tx_err); /* TX errors */ \ - __HANDLE_ITEM(rx); /* RX okay */ \ - __HANDLE_ITEM(rx_err); /* RX errors */ \ - __HANDLE_ITEM(rx_drop); /* RX out of memory */ - struct atm_aal_stats { -#define __HANDLE_ITEM(i) int i - __AAL_STAT_ITEMS -#undef __HANDLE_ITEM + int tx; /* TX okay */ + int tx_err; /* TX errors */ + int rx; /* RX okay */ + int rx_err; /* RX errors */ + int rx_drop; /* RX out of memory */ }; @@ -226,9 +220,11 @@ extern struct proc_dir_entry *atm_proc_r struct k_atm_aal_stats { -#define __HANDLE_ITEM(i) atomic_t i - __AAL_STAT_ITEMS -#undef __HANDLE_ITEM + atomic_t tx; /* TX okay */ + atomic_t tx_err; /* TX errors */ + atomic_t rx; /* RX okay */ + atomic_t rx_err; /* RX errors */ + atomic_t rx_drop; /* RX out of memory */ }; --- a/include/linux/atm_zatm.h +++ b/include/linux/atm_zatm.h @@ -7,11 +7,6 @@ #ifndef LINUX_ATM_ZATM_H #define LINUX_ATM_ZATM_H -/* - * Note: non-kernel programs including this file must also include - * sys/types.h for struct timeval - */ - #include #include @@ -35,18 +30,8 @@ struct zatm_pool_req { struct zatm_pool_info info; /* actual information */ }; -struct zatm_t_hist { - struct timeval real; /* real (wall-clock) time */ - struct timeval expected; /* expected real time */ -}; - - -#define ZATM_OAM_POOL 0 /* free buffer pool for OAM cells */ #define ZATM_AAL0_POOL 1 /* free buffer pool for AAL0 cells */ #define ZATM_AAL5_POOL_BASE 2 /* first AAL5 free buffer pool */ #define ZATM_LAST_POOL ZATM_AAL5_POOL_BASE+10 /* max. 64 kB */ -#define ZATM_TIMER_HISTORY_SIZE 16 /* number of timer adjustments to - record; must be 2^n */ - #endif --- a/include/linux/coff.h +++ b/include/linux/coff.h @@ -1,351 +1,22 @@ -/* This file is derived from the GAS 2.1.4 assembler control file. +/* This file is what's left from the GAS 2.1.4 assembler control file after + removing the junk kernel doesn't use. The GAS product is under the GNU General Public License, version 2 or later. As such, this file is also under that license. If the file format changes in the COFF object, this file should be subsequently updated to reflect the changes. - The actual loader module only uses a few of these structures. The full - set is documented here because I received the full set. If you wish - more information about COFF, then O'Reilly has a very excellent book. + If you wish more information about COFF, then O'Reilly has a very excellent + book. */ -#define E_SYMNMLEN 8 /* Number of characters in a symbol name */ -#define E_FILNMLEN 14 /* Number of characters in a file name */ -#define E_DIMNUM 4 /* Number of array dimensions in auxiliary entry */ - -/* - * These defines are byte order independent. There is no alignment of fields - * permitted in the structures. Therefore they are declared as characters - * and the values loaded from the character positions. It also makes it - * nice to have it "endian" independent. - */ - -/* Load a short int from the following tables with little-endian formats */ -#define COFF_SHORT_L(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\ - ((unsigned short)((unsigned char)ps[0])))) - -/* Load a long int from the following tables with little-endian formats */ -#define COFF_LONG_L(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\ - ((unsigned long)((unsigned char)ps[2])<<16) |\ - ((unsigned long)((unsigned char)ps[1])<<8) |\ - ((unsigned long)((unsigned char)ps[0]))))) - -/* Load a short int from the following tables with big-endian formats */ -#define COFF_SHORT_H(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\ - ((unsigned short)((unsigned char)ps[1])))) - -/* Load a long int from the following tables with big-endian formats */ -#define COFF_LONG_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\ - ((unsigned long)((unsigned char)ps[1])<<16) |\ - ((unsigned long)((unsigned char)ps[2])<<8) |\ - ((unsigned long)((unsigned char)ps[3]))))) - -/* These may be overridden later by brain dead implementations which generate - a big-endian header with little-endian data. In that case, generate a - replacement macro which tests a flag and uses either of the two above - as appropriate. */ - -#define COFF_LONG(v) COFF_LONG_L(v) -#define COFF_SHORT(v) COFF_SHORT_L(v) - /*** coff information for Intel 386/486. */ -/********************** FILE HEADER **********************/ - -struct COFF_filehdr { - char f_magic[2]; /* magic number */ - char f_nscns[2]; /* number of sections */ - char f_timdat[4]; /* time & date stamp */ - char f_symptr[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - /* * Bits for f_flags: * - * F_RELFLG relocation info stripped from file * F_EXEC file is executable (i.e. no unresolved external * references) - * F_LNNO line numbers stripped from file - * F_LSYMS local symbols stripped from file - * F_MINMAL this is a minimal object file (".m") output of fextract - * F_UPDATE this is a fully bound update file, output of ogen - * F_SWABD this file has had its bytes swabbed (in names) - * F_AR16WR this file has the byte ordering of an AR16WR - * (e.g. 11/70) machine - * F_AR32WR this file has the byte ordering of an AR32WR machine - * (e.g. vax and iNTEL 386) - * F_AR32W this file has the byte ordering of an AR32W machine - * (e.g. 3b,maxi) - * F_PATCH file contains "patch" list in optional header - * F_NODF (minimal file only) no decision functions for - * replaced functions */ -#define COFF_F_RELFLG 0000001 #define COFF_F_EXEC 0000002 -#define COFF_F_LNNO 0000004 -#define COFF_F_LSYMS 0000010 -#define COFF_F_MINMAL 0000020 -#define COFF_F_UPDATE 0000040 -#define COFF_F_SWABD 0000100 -#define COFF_F_AR16WR 0000200 -#define COFF_F_AR32WR 0000400 -#define COFF_F_AR32W 0001000 -#define COFF_F_PATCH 0002000 -#define COFF_F_NODF 0002000 - -#define COFF_I386MAGIC 0x14c /* Linux's system */ - -#if 0 /* Perhaps, someday, these formats may be used. */ -#define COFF_I386PTXMAGIC 0x154 -#define COFF_I386AIXMAGIC 0x175 /* IBM's AIX system */ -#define COFF_I386BADMAG(x) ((COFF_SHORT((x).f_magic) != COFF_I386MAGIC) \ - && COFF_SHORT((x).f_magic) != COFF_I386PTXMAGIC \ - && COFF_SHORT((x).f_magic) != COFF_I386AIXMAGIC) -#else -#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC) -#endif - -#define COFF_FILHDR struct COFF_filehdr -#define COFF_FILHSZ sizeof(COFF_FILHDR) - -/********************** AOUT "OPTIONAL HEADER" **********************/ - -/* Linux COFF must have this "optional" header. Standard COFF has no entry - location for the "entry" point. They normally would start with the first - location of the .text section. This is not a good idea for linux. So, - the use of this "optional" header is not optional. It is required. - - Do not be tempted to assume that the size of the optional header is - a constant and simply index the next byte by the size of this structure. - Use the 'f_opthdr' field in the main coff header for the size of the - structure actually written to the file!! -*/ - -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry */ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ -} -COFF_AOUTHDR; - -#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR)) - -#define COFF_STMAGIC 0401 -#define COFF_OMAGIC 0404 -#define COFF_JMAGIC 0407 /* dirty text and data image, can't share */ -#define COFF_DMAGIC 0410 /* dirty text segment, data aligned */ -#define COFF_ZMAGIC 0413 /* The proper magic number for executables */ -#define COFF_SHMAGIC 0443 /* shared library header */ - -/********************** SECTION HEADER **********************/ - -struct COFF_scnhdr { - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries */ - char s_flags[4]; /* flags */ -}; - -#define COFF_SCNHDR struct COFF_scnhdr -#define COFF_SCNHSZ sizeof(COFF_SCNHDR) - -/* - * names of "special" sections - */ - -#define COFF_TEXT ".text" -#define COFF_DATA ".data" -#define COFF_BSS ".bss" -#define COFF_COMMENT ".comment" -#define COFF_LIB ".lib" - -#define COFF_SECT_TEXT 0 /* Section for instruction code */ -#define COFF_SECT_DATA 1 /* Section for initialized globals */ -#define COFF_SECT_BSS 2 /* Section for un-initialized globals */ -#define COFF_SECT_REQD 3 /* Minimum number of sections for good file */ - -#define COFF_STYP_REG 0x00 /* regular segment */ -#define COFF_STYP_DSECT 0x01 /* dummy segment */ -#define COFF_STYP_NOLOAD 0x02 /* no-load segment */ -#define COFF_STYP_GROUP 0x04 /* group segment */ -#define COFF_STYP_PAD 0x08 /* .pad segment */ -#define COFF_STYP_COPY 0x10 /* copy section */ -#define COFF_STYP_TEXT 0x20 /* .text segment */ -#define COFF_STYP_DATA 0x40 /* .data segment */ -#define COFF_STYP_BSS 0x80 /* .bss segment */ -#define COFF_STYP_INFO 0x200 /* .comment section */ -#define COFF_STYP_OVER 0x400 /* overlay section */ -#define COFF_STYP_LIB 0x800 /* library section */ - -/* - * Shared libraries have the following section header in the data field for - * each library. - */ - -struct COFF_slib { - char sl_entsz[4]; /* Size of this entry */ - char sl_pathndx[4]; /* size of the header field */ -}; - -#define COFF_SLIBHD struct COFF_slib -#define COFF_SLIBSZ sizeof(COFF_SLIBHD) - -/********************** LINE NUMBERS **********************/ - -/* 1 line number entry for every "breakpointable" source line in a section. - * Line numbers are grouped on a per function basis; first entry in a function - * grouping will have l_lnno = 0 and in place of physical address will be the - * symbol table index of the function name. - */ - -struct COFF_lineno { - union { - char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ - char l_paddr[4]; /* (physical) address of line number */ - } l_addr; - char l_lnno[2]; /* line number */ -}; - -#define COFF_LINENO struct COFF_lineno -#define COFF_LINESZ 6 - -/********************** SYMBOLS **********************/ - -#define COFF_E_SYMNMLEN 8 /* # characters in a short symbol name */ -#define COFF_E_FILNMLEN 14 /* # characters in a file name */ -#define COFF_E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -/* - * All symbols and sections have the following definition - */ - -struct COFF_syment -{ - union { - char e_name[E_SYMNMLEN]; /* Symbol name (first 8 characters) */ - struct { - char e_zeroes[4]; /* Leading zeros */ - char e_offset[4]; /* Offset if this is a header section */ - } e; - } e; - - char e_value[4]; /* Value (address) of the segment */ - char e_scnum[2]; /* Section number */ - char e_type[2]; /* Type of section */ - char e_sclass[1]; /* Loader class */ - char e_numaux[1]; /* Number of auxiliary entries which follow */ -}; - -#define COFF_N_BTMASK (0xf) /* Mask for important class bits */ -#define COFF_N_TMASK (0x30) /* Mask for important type bits */ -#define COFF_N_BTSHFT (4) /* # bits to shift class field */ -#define COFF_N_TSHIFT (2) /* # bits to shift type field */ - -/* - * Auxiliary entries because the main table is too limiting. - */ - -union COFF_auxent { - -/* - * Debugger information - */ - - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - union { - struct { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ - } x_misc; - - union { - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - - char x_tvndx[2]; /* tv index */ - } x_sym; - -/* - * Source file names (debugger information) - */ - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - -/* - * Section information - */ - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - -/* - * Transfer vector (branch table) - */ - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ -}; - -#define COFF_SYMENT struct COFF_syment -#define COFF_SYMESZ 18 -#define COFF_AUXENT union COFF_auxent -#define COFF_AUXESZ 18 - -#define COFF_ETEXT "etext" - -/********************** RELOCATION DIRECTIVES **********************/ - -struct COFF_reloc { - char r_vaddr[4]; /* Virtual address of item */ - char r_symndx[4]; /* Symbol index in the symtab */ - char r_type[2]; /* Relocation type */ -}; - -#define COFF_RELOC struct COFF_reloc -#define COFF_RELSZ 10 - -#define COFF_DEF_DATA_SECTION_ALIGNMENT 4 -#define COFF_DEF_BSS_SECTION_ALIGNMENT 4 -#define COFF_DEF_TEXT_SECTION_ALIGNMENT 4 - -/* For new sections we haven't heard of before */ -#define COFF_DEF_SECTION_ALIGNMENT 4 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -21,7 +21,7 @@ enum dma_data_direction { #define DMA_30BIT_MASK 0x000000003fffffffULL #define DMA_29BIT_MASK 0x000000001fffffffULL #define DMA_28BIT_MASK 0x000000000fffffffULL -#define DMA_24BIT_MASK 0x0000000000ffffffULL +#define DMA_24BIT_MASK 0x0000000000ffffffULL #include --- a/include/linux/input.h +++ b/include/linux/input.h @@ -231,7 +231,8 @@ struct input_absinfo { #define KEY_PAUSE 119 #define KEY_KPCOMMA 121 -#define KEY_HANGUEL 122 +#define KEY_HANGEUL 122 +#define KEY_HANGUEL KEY_HANGEUL #define KEY_HANJA 123 #define KEY_YEN 124 #define KEY_LEFTMETA 125 --- a/include/linux/smb_fs.h +++ b/include/linux/smb_fs.h @@ -43,17 +43,17 @@ static inline struct smb_inode_info *SMB /* macro names are short for word, double-word, long value (?) */ #define WVAL(buf,pos) \ - (le16_to_cpu(get_unaligned((u16 *)((u8 *)(buf) + (pos))))) + (le16_to_cpu(get_unaligned((__le16 *)((u8 *)(buf) + (pos))))) #define DVAL(buf,pos) \ - (le32_to_cpu(get_unaligned((u32 *)((u8 *)(buf) + (pos))))) + (le32_to_cpu(get_unaligned((__le32 *)((u8 *)(buf) + (pos))))) #define LVAL(buf,pos) \ - (le64_to_cpu(get_unaligned((u64 *)((u8 *)(buf) + (pos))))) + (le64_to_cpu(get_unaligned((__le64 *)((u8 *)(buf) + (pos))))) #define WSET(buf,pos,val) \ - put_unaligned(cpu_to_le16((u16)(val)), (u16 *)((u8 *)(buf) + (pos))) + put_unaligned(cpu_to_le16((u16)(val)), (__le16 *)((u8 *)(buf) + (pos))) #define DSET(buf,pos,val) \ - put_unaligned(cpu_to_le32((u32)(val)), (u32 *)((u8 *)(buf) + (pos))) + put_unaligned(cpu_to_le32((u32)(val)), (__le32 *)((u8 *)(buf) + (pos))) #define LSET(buf,pos,val) \ - put_unaligned(cpu_to_le64((u64)(val)), (u64 *)((u8 *)(buf) + (pos))) + put_unaligned(cpu_to_le64((u64)(val)), (__le64 *)((u8 *)(buf) + (pos))) /* where to find the base of the SMB packet proper */ #define smb_base(buf) ((u8 *)(((u8 *)(buf))+4)) --- a/ipc/sem.c +++ b/ipc/sem.c @@ -944,10 +944,9 @@ static inline int get_undo_list(struct s undo_list = current->sysvsem.undo_list; if (!undo_list) { size = sizeof(struct sem_undo_list); - undo_list = (struct sem_undo_list *) kmalloc(size, GFP_KERNEL); + undo_list = kzalloc(size, GFP_KERNEL); if (undo_list == NULL) return -ENOMEM; - memset(undo_list, 0, size); spin_lock_init(&undo_list->lock); atomic_set(&undo_list->refcnt, 1); current->sysvsem.undo_list = undo_list; --- a/kernel/audit.c +++ b/kernel/audit.c @@ -225,6 +225,8 @@ void audit_log_lost(const char *message) audit_backlog_limit); audit_panic(message); } + + return 0; } static int audit_set_rate_limit(int limit, uid_t loginuid) @@ -869,7 +871,7 @@ void audit_log_hex(struct audit_buffer * int i, avail, new_len; unsigned char *ptr; struct sk_buff *skb; - static const unsigned char *hex = "0123456789ABCDEF"; + static const unsigned char hex[] = "0123456789ABCDEF"; BUG_ON(!ab->skb); skb = ab->skb; --- a/kernel/exit.c +++ b/kernel/exit.c @@ -577,7 +577,7 @@ static void exit_mm(struct task_struct * down_read(&mm->mmap_sem); } atomic_inc(&mm->mm_count); - if (mm != tsk->active_mm) BUG(); + BUG_ON(mm != tsk->active_mm); /* more a memory barrier than a real lock */ task_lock(tsk); tsk->mm = NULL; @@ -1531,8 +1531,7 @@ check_continued: if (options & __WNOTHREAD) break; tsk = next_thread(tsk); - if (tsk->signal != current->signal) - BUG(); + BUG_ON(tsk->signal != current->signal); } while (tsk != current); read_unlock(&tasklist_lock); --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -108,11 +108,10 @@ static int do_kimage_alloc(struct kimage /* Allocate a controlling structure */ result = -ENOMEM; - image = kmalloc(sizeof(*image), GFP_KERNEL); + image = kzalloc(sizeof(*image), GFP_KERNEL); if (!image) goto out; - memset(image, 0, sizeof(*image)); image->head = 0; image->entry = &image->head; image->last_entry = &image->head; --- a/kernel/module.c +++ b/kernel/module.c @@ -583,7 +583,7 @@ static void wait_for_zero_refcount(struc break; schedule(); } - current->state = TASK_RUNNING; + __set_current_state(TASK_RUNNING); mutex_lock(&module_mutex); } --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 17 -EXTRAVERSION =-rc1 +EXTRAVERSION =-rc1-kj NAME=Sliding Snow Leopard # *DOCUMENTATION* --- a/mm/pdflush.c +++ b/mm/pdflush.c @@ -202,8 +202,7 @@ int pdflush_operation(void (*fn)(unsigne unsigned long flags; int ret = 0; - if (fn == NULL) - BUG(); /* Hard to diagnose if it's deferred */ + BUG_ON(fn == NULL); /* Hard to diagnose if it's deferred */ spin_lock_irqsave(&pdflush_lock, flags); if (list_empty(&pdflush_list)) { --- a/mm/slab.c +++ b/mm/slab.c @@ -268,11 +268,10 @@ struct array_cache { unsigned int batchcount; unsigned int touched; spinlock_t lock; - void *entry[0]; /* + void *entry[]; /* * Must have this definition in here for the proper * alignment of array_cache. Also simplifies accessing * the entries. - * [0] is for gcc 2.95. It should really be []. */ }; --- a/net/802/fc.c +++ b/net/802/fc.c @@ -87,7 +87,9 @@ static int fc_rebuild_header(struct sk_b struct fch_hdr *fch=(struct fch_hdr *)skb->data; struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr)); if(fcllc->ethertype != htons(ETH_P_IP)) { - printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(fcllc->ethertype)); + printk(KERN_WARNING "fc_rebuild_header: Don't know how to " + "resolve type %04X addresses ?\n", + ntohs(fcllc->ethertype)); return 0; } #ifdef CONFIG_INET --- a/net/802/fddi.c +++ b/net/802/fddi.c @@ -108,8 +108,9 @@ static int fddi_rebuild_header(struct sk else #endif { - printk("%s: Don't know how to resolve type %04X addresses.\n", - skb->dev->name, ntohs(fddi->hdr.llc_snap.ethertype)); + printk(KERN_WARNING "%s: Don't know how to resolve type " + "%04X addresses.\n", + skb->dev->name, ntohs(fddi->hdr.llc_snap.ethertype)); return(0); } } --- a/net/802/hippi.c +++ b/net/802/hippi.c @@ -55,7 +55,7 @@ static int hippi_header(struct sk_buff * if (!len){ len = skb->len - HIPPI_HLEN; - printk("hippi_header(): length not supplied\n"); + printk(KERN_NOTICE "hippi_header(): length not supplied\n"); } /* --- a/net/802/tr.c +++ b/net/802/tr.c @@ -165,7 +165,9 @@ static int tr_rebuild_header(struct sk_b */ if(trllc->ethertype != htons(ETH_P_IP)) { - printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n",(unsigned int)htons(trllc->ethertype)); + printk(KERN_WARNING "tr_rebuild_header: Don't know how to " + "resolve type %04X addresses ?\n", + (unsigned int)htons(trllc->ethertype)); return 0; } @@ -281,8 +283,9 @@ void tr_source_route(struct sk_buff *skb if(entry) { #if TR_SR_DEBUG -printk("source routing for %02X:%02X:%02X:%02X:%02X:%02X\n",trh->daddr[0], - trh->daddr[1],trh->daddr[2],trh->daddr[3],trh->daddr[4],trh->daddr[5]); +printk(KERN_DEBUG "source routing for %02X:%02X:%02X:%02X:%02X:%02X\n", + trh->daddr[0], trh->daddr[1], trh->daddr[2], + trh->daddr[3], trh->daddr[4], trh->daddr[5]); #endif if(!entry->local_ring && (ntohs(entry->rcf) & TR_RCF_LEN_MASK) >> 8) { @@ -293,11 +296,14 @@ printk("source routing for %02X:%02X:%02 trh->saddr[0]|=TR_RII; #if TR_SR_DEBUG - printk("entry found with rcf %04x\n", entry->rcf); + printk(KERN_DEBUG "entry found with rcf %04x\n", + entry->rcf); } else { - printk("entry found but without rcf length, local=%02x\n", entry->local_ring); + printk(KERN_DEBUG "entry found but without rcf " + "length, local=%02x\n", + entry->local_ring); #endif } entry->last_used=jiffies; @@ -313,7 +319,8 @@ printk("source routing for %02X:%02X:%02 | TR_RCF_FRAME2K | TR_RCF_LIMITED_BROADCAST); trh->saddr[0]|=TR_RII; #if TR_SR_DEBUG - printk("no entry in rif table found - broadcasting frame\n"); + printk(KERN_DEBUG "no entry in rif table found - " + "broadcasting frame\n"); #endif } } @@ -364,10 +371,9 @@ static void tr_add_rif_info(struct trh_h if(entry==NULL) { #if TR_SR_DEBUG -printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n", - trh->saddr[0],trh->saddr[1],trh->saddr[2], - trh->saddr[3],trh->saddr[4],trh->saddr[5], - ntohs(trh->rcf)); +printk(KERN_DEBUG "adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X" + " rcf:%04X\n", trh->saddr[0], trh->saddr[1], trh->saddr[2], + trh->saddr[3], trh->saddr[4], trh->saddr[5], ntohs(trh->rcf)); #endif /* * Allocate our new entry. A failure to allocate loses @@ -380,7 +386,8 @@ printk("adding rif_entry: addr:%02X:%02X if(!entry) { - printk(KERN_DEBUG "tr.c: Couldn't malloc rif cache entry !\n"); + printk(KERN_ERR "tr.c: " + "Couldn't malloc rif cache entry !\n"); spin_unlock_irqrestore(&rif_lock, flags); return; } @@ -412,10 +419,9 @@ printk("adding rif_entry: addr:%02X:%02X !(trh->rcf & htons(TR_RCF_BROADCAST_MASK))) { #if TR_SR_DEBUG -printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n", - trh->saddr[0],trh->saddr[1],trh->saddr[2], - trh->saddr[3],trh->saddr[4],trh->saddr[5], - ntohs(trh->rcf)); +printk(KERN_DEBUG "updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X " + "rcf:%04X\n", trh->saddr[0], trh->saddr[1], trh->saddr[2], + trh->saddr[3], trh->saddr[4], trh->saddr[5], ntohs(trh->rcf)); #endif entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK); memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short)); --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -671,7 +671,7 @@ int vlan_dev_set_mac_address(struct net_ memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); - printk("%s: Setting MAC address to ", dev->name); + printk(KERN_INFO "%s: Setting MAC address to ", dev->name); for (i = 0; i < 6; i++) printk(" %2.2x", dev->dev_addr[i]); printk(".\n"); @@ -687,13 +687,16 @@ int vlan_dev_set_mac_address(struct net_ /* Make PROMISC visible to the user. */ flgs |= IFF_PROMISC; - printk("VLAN (%s): Setting underlying device (%s) to promiscious mode.\n", - dev->name, VLAN_DEV_INFO(dev)->real_dev->name); - dev_change_flags(VLAN_DEV_INFO(dev)->real_dev, flgs); + printk(KERN_INFO "VLAN (%s): Setting underlying device" + " (%s) to promiscious mode.\n", + dev->name, VLAN_DEV_INFO(dev)->real_dev->name); + dev_change_flags(VLAN_DEV_INFO(dev)->real_dev, + flgs); } } else { - printk("VLAN (%s): Underlying device (%s) has same MAC, not checking promiscious mode.\n", - dev->name, VLAN_DEV_INFO(dev)->real_dev->name); + printk(KERN_INFO "VLAN (%s): Underlying device (%s) has same " + "MAC, not checking promiscious mode.\n", + dev->name, VLAN_DEV_INFO(dev)->real_dev->name); } return 0; --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -261,7 +261,7 @@ lec_start_xmit(struct sk_buff *skb, stru DPRINTK("lec_start_xmit called\n"); if (!priv->lecd) { - printk("%s:No lecd attached\n",dev->name); + printk(KERN_WARNING "%s:No lecd attached\n",dev->name); priv->stats.tx_errors++; netif_stop_queue(dev); return -EUNATCH; @@ -302,7 +302,7 @@ lec_start_xmit(struct sk_buff *skb, stru #endif #if DUMP_PACKETS > 0 - printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, + printk(KERN_DEBUG "%s: send datalen:%ld lecid:%4.4x\n", dev->name, skb->len, priv->lecid); #if DUMP_PACKETS >= 2 for(i=0;ilen && i <99;i++) { @@ -314,9 +314,9 @@ lec_start_xmit(struct sk_buff *skb, stru } #endif /* DUMP_PACKETS >= 1 */ if (i==skb->len) - printk("%s\n",buf); + printk(KERN_DEBUG "%s\n",buf); else - printk("%s...\n",buf); + printk(KERN_DEBUG "%s...\n",buf); #endif /* DUMP_PACKETS > 0 */ /* Minimum ethernet-frame size */ @@ -375,8 +375,8 @@ lec_start_xmit(struct sk_buff *skb, stru } #if DUMP_PACKETS > 0 - printk("%s:sending to vpi:%d vci:%d\n", dev->name, - vcc->vpi, vcc->vci); + printk(KERN_DEBUG "%s:sending to vpi:%d vci:%d\n", + dev->name, vcc->vpi, vcc->vci); #endif /* DUMP_PACKETS > 0 */ while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { @@ -506,8 +506,8 @@ lec_atm_send(struct atm_vcc *vcc, struct if (priv->lane_version > 1) priv->lane2_ops = &lane2_ops; if (dev->change_mtu(dev, mesg->content.config.mtu)) - printk("%s: change_mtu to %d failed\n", dev->name, - mesg->content.config.mtu); + printk(KERN_NOTICE "%s: change_mtu to %d failed\n", + dev->name, mesg->content.config.mtu); priv->is_proxy = mesg->content.config.is_proxy; break; case l_flush_tran_id: @@ -556,7 +556,8 @@ lec_atm_send(struct atm_vcc *vcc, struct } break; default: - printk("%s: Unknown message type %d\n", dev->name, mesg->type); + printk(KERN_NOTICE "%s: Unknown message type %d\n", + dev->name, mesg->type); dev_kfree_skb(skb); return -EINVAL; } @@ -578,14 +579,14 @@ lec_atm_close(struct atm_vcc *vcc) lec_arp_destroy(priv); if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) - printk("%s lec_atm_close: closing with messages pending\n", - dev->name); + printk(KERN_DEBUG "%s lec_atm_close: " + "closing with messages pending\n",dev->name); while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { atm_return(vcc, skb->truesize); dev_kfree_skb(skb); } - printk("%s: Shut down!\n", dev->name); + printk(KERN_INFO "%s: Shut down!\n", dev->name); module_put(THIS_MODULE); } @@ -677,7 +678,7 @@ lec_init(struct net_device *dev) dev->get_stats = lec_get_stats; dev->set_multicast_list = lec_set_multicast_list; dev->do_ioctl = NULL; - printk("%s: Initialized!\n",dev->name); + printk(KERN_INFO "%s: Initialized!\n",dev->name); return; } @@ -707,8 +708,8 @@ lec_push(struct atm_vcc *vcc, struct sk_ int i=0; char buf[300]; - printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, - vcc->vpi, vcc->vci); + printk(KERN_DEBUG "%s: lec_push vcc vpi:%d vci:%d\n", + dev->name, vcc->vpi, vcc->vci); #endif if (!skb) { DPRINTK("%s: null skb\n",dev->name); @@ -716,8 +717,8 @@ lec_push(struct atm_vcc *vcc, struct sk_ return; } #if DUMP_PACKETS > 0 - printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, - skb->len, priv->lecid); + printk(KERN_DEBUG "%s: rcv datalen:%ld lecid:%4.4x\n", + dev->name, skb->len, priv->lecid); #if DUMP_PACKETS >= 2 for(i=0;ilen && i <99;i++) { sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); @@ -728,9 +729,9 @@ lec_push(struct atm_vcc *vcc, struct sk_ } #endif /* DUMP_PACKETS >= 1 */ if (i==skb->len) - printk("%s\n",buf); + printk(KERN_DEBUG "%s\n",buf); else - printk("%s...\n",buf); + printk(KERN_DEBUG "%s...\n",buf); #endif /* DUMP_PACKETS > 0 */ if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/ struct sock *sk = sk_atm(vcc); @@ -808,7 +809,7 @@ lec_pop(struct atm_vcc *vcc, struct sk_b struct net_device *dev = skb->dev; if (vpriv == NULL) { - printk("lec_pop(): vpriv = NULL!?!?!?\n"); + printk(KERN_DEBUG "lec_pop(): vpriv = NULL!?!?!?\n"); return; } @@ -831,8 +832,8 @@ lec_vcc_attach(struct atm_vcc *vcc, void /* Lecd must be up in this case */ bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); if (bytes_left != 0) { - printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n", - bytes_left); + printk(KERN_WARNING "lec: lec_vcc_attach, copy from user failed" + " for %d bytes\n", bytes_left); } if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || !dev_lec[ioc_data.dev_num]) @@ -1232,7 +1233,7 @@ static int __init lane_module_init(void) #endif register_atm_ioctl(&lane_ioctl_ops); - printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); + printk(KERN_INFO "lec.c: " __DATE__ " " __TIME__ " initialized\n"); return 0; } @@ -1340,7 +1341,7 @@ static int lane2_associate_req (struct n memcpy(skb->data, tlvs, sizeoftlvs); retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); if (retval != 0) - printk("lec.c: lane2_associate_req() failed\n"); + printk(KERN_DEBUG "lec.c: lane2_associate_req() failed\n"); /* If the previous association has changed we must * somehow notify other LANE entities about the change */ @@ -1375,10 +1376,10 @@ static void lane2_associate_ind (struct memcpy(entry->tlvs, tlvs, sizeoftlvs); #endif #if 0 - printk("lec.c: lane2_associate_ind()\n"); - printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); + printk(KERN_DEBUG "lec.c: lane2_associate_ind()\n"); + printk(KERN_DEBUG "dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); while (i < sizeoftlvs) - printk("%02x ", tlvs[i++]); + printk(KERN_DEBUG "%02x ", tlvs[i++]); printk("\n"); #endif @@ -1591,7 +1592,7 @@ dump_arp_table(struct lec_priv *priv) struct lec_arp_table *mcast_fwds = priv->mcast_fwds; - printk("Dump %p:\n",priv); + printk(KERN_DEBUG "Dump %p:\n",priv); for (i=0;i%p\n",rulla->next); rulla = rulla->next; } - printk("%s",buf); + printk(KERN_DEBUG "%s",buf); } rulla = lec_no_forward; if (rulla) - printk("No forward\n"); + printk(KERN_DEBUG "No forward\n"); while(rulla) { offset=0; offset += sprintf(buf+offset,"Mac:"); @@ -1655,11 +1656,11 @@ dump_arp_table(struct lec_priv *priv) get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); rulla = rulla->next; - printk("%s",buf); + printk(KERN_DEBUG "%s",buf); } rulla = lec_arp_empty_ones; if (rulla) - printk("Empty ones\n"); + printk(KERN_DEBUG "Empty ones\n"); while(rulla) { offset=0; offset += sprintf(buf+offset,"Mac:"); @@ -1686,12 +1687,12 @@ dump_arp_table(struct lec_priv *priv) get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); rulla = rulla->next; - printk("%s",buf); + printk(KERN_DEBUG "%s",buf); } rulla = mcast_fwds; if (rulla) - printk("Multicast Forward VCCs\n"); + printk(KERN_DEBUG "Multicast Forward VCCs\n"); while(rulla) { offset=0; offset += sprintf(buf+offset,"Mac:"); @@ -1718,7 +1719,7 @@ dump_arp_table(struct lec_priv *priv) get_status_string(rulla->status)); offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); rulla = rulla->next; - printk("%s",buf); + printk(KERN_DEBUG "%s",buf); } #endif @@ -1814,7 +1815,7 @@ make_entry(struct lec_priv *priv, unsign to_return = kmalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); if (!to_return) { - printk("LEC: Arp entry kmalloc failed\n"); + printk(KERN_ERR "LEC: Arp entry kmalloc failed\n"); return NULL; } memset(to_return, 0, sizeof(struct lec_arp_table)); @@ -2234,7 +2235,8 @@ lec_vcc_added(struct lec_priv *priv, str #if 0 entry = lec_arp_find(priv, bus_mac); if (!entry) { - printk("LEC_ARP: Multicast entry not found!\n"); + printk(KERN_WARNING "LEC_ARP: Multicast entry " + "not found!\n"); goto out; } memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); --- a/net/atm/mpc.c +++ b/net/atm/mpc.c @@ -170,7 +170,7 @@ struct atm_mpoa_qos *atm_mpoa_add_qos(ui entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL); if (entry == NULL) { - printk("mpoa: atm_mpoa_add_qos: out of memory\n"); + printk(KERN_ERR "mpoa: atm_mpoa_add_qos: out of memory\n"); return entry; } @@ -297,8 +297,9 @@ static void start_mpc(struct mpoa_client dprintk("mpoa: (%s) start_mpc:\n", mpc->dev->name); if (dev->hard_start_xmit == NULL) { - printk("mpoa: (%s) start_mpc: dev->hard_start_xmit == NULL, not starting\n", - dev->name); + printk(KERN_WARNING "mpoa: (%s) start_mpc: " + "dev->hard_start_xmit == NULL, not starting\n", + dev->name); return; } mpc->old_hard_start_xmit = dev->hard_start_xmit; @@ -376,7 +377,8 @@ static void lane2_assoc_ind(struct net_d dprintk("total length of all TLVs %d\n", sizeoftlvs); mpc = find_mpc_by_lec(dev); /* Sampo-Fix: moved here from below */ if (mpc == NULL) { - printk("mpoa: (%s) lane2_assoc_ind: no mpc\n", dev->name); + printk(KERN_WARNING "mpoa: (%s) lane2_assoc_ind: no mpc\n", + dev->name); return; } end_of_tlvs = tlvs + sizeoftlvs; @@ -386,12 +388,14 @@ static void lane2_assoc_ind(struct net_d tlvs += 5; dprintk(" type 0x%x length %02x\n", type, length); if (tlvs + length > end_of_tlvs) { - printk("TLV value extends past its buffer, aborting parse\n"); + printk(KERN_NOTICE "TLV value extends past its buffer," + " aborting parse\n"); return; } if (type == 0) { - printk("mpoa: (%s) lane2_assoc_ind: TLV type was 0, returning\n", dev->name); + printk(KERN_NOTICE "mpoa: (%s) lane2_assoc_ind: " + "TLV type was 0, returning\n", dev->name); return; } @@ -404,14 +408,14 @@ static void lane2_assoc_ind(struct net_d dprintk("mpoa: (%s) MPOA device type '%s', ", dev->name, mpoa_device_type_string(mpoa_device_type)); if (mpoa_device_type == MPS_AND_MPC && length < (42 + number_of_mps_macs*ETH_ALEN)) { /* :) */ - printk("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n", - dev->name); + printk(KERN_INFO "\nmpoa: (%s) lane2_assoc_ind: " + "short MPOA Device Type TLV\n", dev->name); continue; } if ((mpoa_device_type == MPS || mpoa_device_type == MPC) && length < 22 + number_of_mps_macs*ETH_ALEN) { - printk("\nmpoa: (%s) lane2_assoc_ind: short MPOA Device Type TLV\n", - dev->name); + printk(KERN_INFO "\nmpoa: (%s) lane2_assoc_ind: " + "short MPOA Device Type TLV\n", dev->name); continue; } if (mpoa_device_type != MPS && mpoa_device_type != MPS_AND_MPC) { @@ -420,7 +424,8 @@ static void lane2_assoc_ind(struct net_d continue; /* we are only interested in MPSs */ } if (number_of_mps_macs == 0 && mpoa_device_type == MPS_AND_MPC) { - printk("\nmpoa: (%s) lane2_assoc_ind: MPS_AND_MPC has zero MACs\n", dev->name); + printk(KERN_INFO "\nmpoa: (%s) lane2_assoc_ind:" + " MPS_AND_MPC has zero MACs\n", dev->name); continue; /* someone should read the spec */ } dprintk("this MPS has %d MAC addresses\n", number_of_mps_macs); @@ -432,8 +437,9 @@ static void lane2_assoc_ind(struct net_d if (tlvs == NULL) return; } if (end_of_tlvs - tlvs != 0) - printk("mpoa: (%s) lane2_assoc_ind: ignoring %Zd bytes of trailing TLV carbage\n", - dev->name, end_of_tlvs - tlvs); + printk(KERN_NOTICE "mpoa: (%s) lane2_assoc_ind: " + "ignoring %Zd bytes of trailing TLV garbage\n", + dev->name, end_of_tlvs - tlvs); return; } @@ -453,7 +459,8 @@ static uint8_t *copy_macs(struct mpoa_cl mpc->number_of_mps_macs = 0; mpc->mps_macs = kmalloc(num_macs*ETH_ALEN, GFP_KERNEL); if (mpc->mps_macs == NULL) { - printk("mpoa: (%s) copy_macs: out of mem\n", mpc->dev->name); + printk(KERN_ERR "mpoa: (%s) copy_macs: out of mem\n", + mpc->dev->name); return NULL; } } @@ -544,7 +551,8 @@ static int mpc_send_packet(struct sk_buf mpc = find_mpc_by_lec(dev); /* this should NEVER fail */ if(mpc == NULL) { - printk("mpoa: (%s) mpc_send_packet: no MPC found\n", dev->name); + printk(KERN_WARNING "mpoa: (%s) mpc_send_packet: " + "no MPC found\n", dev->name); goto non_ip; } @@ -576,7 +584,9 @@ static int atm_mpoa_vcc_attach(struct at bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); if (bytes_left != 0) { - printk("mpoa: mpc_vcc_attach: Short read (missed %d bytes) from userland\n", bytes_left); + printk(KERN_ERR "mpoa: mpc_vcc_attach: " + "Short read (missed %d bytes) from userland\n", + bytes_left); return -EFAULT; } ipaddr = ioc_data.ipaddr; @@ -590,18 +600,21 @@ static int atm_mpoa_vcc_attach(struct at if (ioc_data.type == MPC_SOCKET_INGRESS) { in_entry = mpc->in_ops->get(ipaddr, mpc); if (in_entry == NULL || in_entry->entry_state < INGRESS_RESOLVED) { - printk("mpoa: (%s) mpc_vcc_attach: did not find RESOLVED entry from ingress cache\n", - mpc->dev->name); + printk(KERN_ERR "mpoa: (%s) mpc_vcc_attach: " + "did not find RESOLVED entry from ingress cache\n", + mpc->dev->name); if (in_entry != NULL) mpc->in_ops->put(in_entry); return -EINVAL; } ip = (unsigned char*)&in_entry->ctrl_info.in_dst_ip; - printk("mpoa: (%s) mpc_vcc_attach: attaching ingress SVC, entry = %u.%u.%u.%u\n", - mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); + printk(KERN_INFO "mpoa: (%s) mpc_vcc_attach: " + "attaching ingress SVC, entry = %u.%u.%u.%u\n", + mpc->dev->name, ip[0], ip[1], ip[2], ip[3]); in_entry->shortcut = vcc; mpc->in_ops->put(in_entry); } else { - printk("mpoa: (%s) mpc_vcc_attach: attaching egress SVC\n", mpc->dev->name); + printk(KERN_INFO "mpoa: (%s) mpc_vcc_attach: " + "attaching egress SVC\n", mpc->dev->name); } vcc->proto_data = mpc->dev; @@ -621,7 +634,8 @@ static void mpc_vcc_close(struct atm_vcc mpc = find_mpc_by_lec(dev); if (mpc == NULL) { - printk("mpoa: (%s) mpc_vcc_close: close for unknown MPC\n", dev->name); + printk(KERN_WARNING "mpoa: (%s) mpc_vcc_close: " + "close for unknown MPC\n", dev->name); return; } @@ -680,7 +694,8 @@ static void mpc_push(struct atm_vcc *vcc mpc = find_mpc_by_lec(dev); if (mpc == NULL) { - printk("mpoa: (%s) mpc_push: unknown MPC\n", dev->name); + printk(KERN_WARNING "mpoa: (%s) mpc_push: unknown MPC\n", + dev->name); return; } @@ -688,12 +703,15 @@ static void mpc_push(struct atm_vcc *vcc ddprintk("mpoa: (%s) mpc_push: tagged data packet arrived\n", dev->name); } else if (memcmp(skb->data, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA data */ - printk("mpoa: (%s) mpc_push: non-tagged data packet arrived\n", dev->name); - printk(" mpc_push: non-tagged data unsupported, purging\n"); + printk(KERN_NOTICE "mpoa: (%s) mpc_push: " + "non-tagged data packet arrived\n", dev->name); + printk(KERN_NOTICE " mpc_push: " + "non-tagged data unsupported, purging\n"); dev_kfree_skb_any(skb); return; } else { - printk("mpoa: (%s) mpc_push: garbage arrived, purging\n", dev->name); + printk(KERN_NOTICE "mpoa: (%s) mpc_push: " + "garbage arrived, purging\n", dev->name); dev_kfree_skb_any(skb); return; } @@ -703,8 +721,9 @@ static void mpc_push(struct atm_vcc *vcc eg = mpc->eg_ops->get_by_tag(tag, mpc); if (eg == NULL) { - printk("mpoa: (%s) mpc_push: Didn't find egress cache entry, tag = %u\n", - dev->name,tag); + printk(KERN_NOTICE "mpoa: (%s) mpc_push: " + "Didn't find egress cache entry, tag = %u\n", + dev->name,tag); purge_egress_shortcut(vcc, NULL); dev_kfree_skb_any(skb); return; @@ -716,7 +735,8 @@ static void mpc_push(struct atm_vcc *vcc */ if (eg->shortcut == NULL) { eg->shortcut = vcc; - printk("mpoa: (%s) mpc_push: egress SVC in use\n", dev->name); + printk(KERN_NOTICE "mpoa: (%s) mpc_push: egress SVC in use\n", + dev->name); } skb_pull(skb, sizeof(struct llc_snap_hdr) + sizeof(tag)); /* get rid of LLC/SNAP header */ @@ -782,7 +802,8 @@ static int atm_mpoa_mpoad_attach (struct mpc->dev = find_lec_by_itfnum(arg); /* NULL if there was no lec */ } if (mpc->mpoad_vcc) { - printk("mpoa: mpoad_attach: mpoad is already present for itf %d\n", arg); + printk(KERN_ERR "mpoa: mpoad_attach: " + "mpoad is already present for itf %d\n", arg); return -EADDRINUSE; } @@ -837,11 +858,12 @@ static void mpoad_close(struct atm_vcc * mpc = find_mpc_by_vcc(vcc); if (mpc == NULL) { - printk("mpoa: mpoad_close: did not find MPC\n"); + printk(KERN_ERR "mpoa: mpoad_close: did not find MPC\n"); return; } if (!mpc->mpoad_vcc) { - printk("mpoa: mpoad_close: close for non-present mpoad\n"); + printk(KERN_ERR "mpoa: mpoad_close: " + "close for non-present mpoad\n"); return; } @@ -861,7 +883,7 @@ static void mpoad_close(struct atm_vcc * kfree_skb(skb); } - printk("mpoa: (%s) going down\n", + printk(KERN_INFO "mpoa: (%s) going down\n", (mpc->dev) ? mpc->dev->name : ""); module_put(THIS_MODULE); @@ -879,7 +901,7 @@ static int msg_from_mpoad(struct atm_vcc atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); if (mpc == NULL) { - printk("mpoa: msg_from_mpoad: no mpc found\n"); + printk(KERN_WARNING "mpoa: msg_from_mpoad: no mpc found\n"); return 0; } dprintk("mpoa: (%s) msg_from_mpoad:", (mpc->dev) ? mpc->dev->name : ""); @@ -944,7 +966,8 @@ int msg_to_mpoad(struct k_message *mesg, struct sock *sk; if (mpc == NULL || !mpc->mpoad_vcc) { - printk("mpoa: msg_to_mpoad: mesg %d to a non-existent mpoad\n", mesg->type); + printk(KERN_ERR "mpoa: msg_to_mpoad: mesg %d to " + "a non-existent mpoad\n", mesg->type); return -ENXIO; } @@ -984,7 +1007,8 @@ static int mpoa_event_listener(struct no dev->name); mpc = alloc_mpc(); if (mpc == NULL) { - printk("mpoa: mpoa_event_listener: no new mpc"); + printk(KERN_ERR "mpoa: mpoa_event_listener: " + "no new mpc\n"); break; } } @@ -1070,8 +1094,9 @@ static void MPOA_trigger_rcvd(struct k_m return; } - printk("mpoa: (%s) MPOA_trigger_rcvd: entry already in resolving state\n", - (mpc->dev) ? mpc->dev->name : ""); + printk(KERN_INFO "mpoa: (%s) MPOA_trigger_rcvd: entry already " + "in resolving state\n", + (mpc->dev) ? mpc->dev->name : ""); mpc->in_ops->put(entry); return; } @@ -1110,7 +1135,8 @@ static void check_qos_and_open_shortcut( if (qos && (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) { msg->qos = qos->qos; - printk("mpoa: (%s) trying to get a CBR shortcut\n",client->dev->name); + printk(KERN_INFO "mpoa: (%s) trying to get a CBR shortcut\n", + client->dev->name); } else memset(&msg->qos,0,sizeof(struct atm_qos)); msg_to_mpoad(msg, client); @@ -1127,13 +1153,16 @@ static void MPOA_res_reply_rcvd(struct k dprintk("mpoa: (%s) MPOA_res_reply_rcvd: ip %u.%u.%u.%u\n", mpc->dev->name, NIPQUAD(ip)); ddprintk("mpoa: (%s) MPOA_res_reply_rcvd() entry = %p", mpc->dev->name, entry); if(entry == NULL){ - printk("\nmpoa: (%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name); + printk(KERN_WARNING "\nmpoa: (%s) ARGH, received res. " + "reply for an entry that doesn't exist.\n", + mpc->dev->name); return; } ddprintk(" entry_state = %d ", entry->entry_state); if (entry->entry_state == INGRESS_RESOLVED) { - printk("\nmpoa: (%s) MPOA_res_reply_rcvd for RESOLVED entry!\n", mpc->dev->name); + printk(KERN_WARNING "\nmpoa: (%s) MPOA_res_reply_rcvd " + "for RESOLVED entry!\n", mpc->dev->name); mpc->in_ops->put(entry); return; } @@ -1151,8 +1180,9 @@ static void MPOA_res_reply_rcvd(struct k } if (entry->shortcut != NULL) { - printk("mpoa: (%s) MPOA_res_reply_rcvd: entry->shortcut != NULL, impossible!\n", - mpc->dev->name); + printk(KERN_WARNING "mpoa: (%s) MPOA_res_reply_rcvd:" + " entry->shortcut != NULL, impossible!\n", + mpc->dev->name); mpc->in_ops->put(entry); return; } @@ -1173,7 +1203,8 @@ static void ingress_purge_rcvd(struct k_ in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); if(entry == NULL){ - printk("mpoa: (%s) ingress_purge_rcvd: purge for a non-existing entry, ", mpc->dev->name); + printk(KERN_ERR "mpoa: (%s) ingress_purge_rcvd: purge for" + " a non-existing entry, ", mpc->dev->name); printk("ip = %u.%u.%u.%u\n", ip[0], ip[1], ip[2], ip[3]); return; } @@ -1218,13 +1249,14 @@ static void purge_egress_shortcut(struct dprintk("mpoa: purge_egress_shortcut: entering\n"); if (vcc == NULL) { - printk("mpoa: purge_egress_shortcut: vcc == NULL\n"); + printk(KERN_ERR "mpoa: purge_egress_shortcut: vcc == NULL\n"); return; } skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); if (skb == NULL) { - printk("mpoa: purge_egress_shortcut: out of memory\n"); + printk(KERN_ERR "mpoa: purge_egress_shortcut: " + "out of memory\n"); return; } @@ -1256,7 +1288,8 @@ static void mps_death( struct k_message dprintk("mpoa: (%s) mps_death:\n", mpc->dev->name); if(memcmp(msg->MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN)){ - printk("mpoa: (%s) mps_death: wrong MPS\n", mpc->dev->name); + printk(KERN_ERR "mpoa: (%s) mps_death: wrong MPS\n", + mpc->dev->name); return; } @@ -1327,10 +1360,12 @@ static void set_mpc_ctrl_addr_rcvd(struc priv = (struct lec_priv *)mpc->dev->priv; retval = priv->lane2_ops->associate_req(mpc->dev, mpc->dev->dev_addr, tlv, sizeof(tlv)); if (retval == 0) - printk("mpoa: (%s) MPOA device type TLV association failed\n", mpc->dev->name); + printk(KERN_WARNING "mpoa: (%s) MPOA device type TLV" + " association failed\n", mpc->dev->name); retval = priv->lane2_ops->resolve(mpc->dev, NULL, 1, NULL, NULL); if (retval < 0) - printk("mpoa: (%s) targetless LE_ARP request failed\n", mpc->dev->name); + printk(KERN_WARNING "mpoa: (%s) targetless LE_ARP" + " request failed\n", mpc->dev->name); } return; @@ -1344,7 +1379,7 @@ static void set_mps_mac_addr_rcvd(struct client->number_of_mps_macs = 0; client->mps_macs = kmalloc(ETH_ALEN,GFP_KERNEL); if (client->mps_macs == NULL) { - printk("mpoa: set_mps_mac_addr_rcvd: out of memory\n"); + printk(KERN_ERR "mpoa: set_mps_mac_addr_rcvd: out of memory\n"); return; } client->number_of_mps_macs = 1; @@ -1456,7 +1491,7 @@ static __init int atm_mpoa_init(void) printk(KERN_INFO "mpoa: /proc/mpoa initialized\n"); #endif - printk("mpc.c: " __DATE__ " " __TIME__ " initialized\n"); + printk(KERN_INFO "mpc.c: " __DATE__ " " __TIME__ " initialized\n"); return 0; } --- a/net/atm/mpoa_caches.c +++ b/net/atm/mpoa_caches.c @@ -91,7 +91,8 @@ static in_cache_entry *in_cache_add_entr in_cache_entry* entry = kmalloc(sizeof(in_cache_entry), GFP_KERNEL); if (entry == NULL) { - printk("mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n"); + printk(KERN_ERR "mpoa: mpoa_caches.c: new_in_cache_entry: " + "out of memory\n"); return NULL; } @@ -459,7 +460,8 @@ static eg_cache_entry *eg_cache_add_entr eg_cache_entry *entry = kmalloc(sizeof(eg_cache_entry), GFP_KERNEL); if (entry == NULL) { - printk("mpoa: mpoa_caches.c: new_eg_cache_entry: out of memory\n"); + printk(KERN_ERR "mpoa: mpoa_caches.c: new_eg_cache_entry: " + "out of memory\n"); return NULL; } --- a/net/atm/mpoa_proc.c +++ b/net/atm/mpoa_proc.c @@ -218,7 +218,8 @@ static ssize_t proc_mpc_write(struct fil *p = '\0'; if (!parse_qos(page)) - printk("mpoa: proc_mpc_write: could not parse '%s'\n", page); + printk(KERN_WARNING "mpoa: proc_mpc_write: " + "could not parse '%s'\n", page); free_page((unsigned long)page); --- a/net/atm/resources.c +++ b/net/atm/resources.c @@ -149,18 +149,22 @@ void atm_dev_deregister(struct atm_dev * static void copy_aal_stats(struct k_atm_aal_stats *from, struct atm_aal_stats *to) { -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i) - __AAL_STAT_ITEMS -#undef __HANDLE_ITEM + to->tx = atomic_read(&from->tx); + to->tx_err = atomic_read(&from->tx_err); + to->rx = atomic_read(&from->rx); + to->rx_err = atomic_read(&from->rx_err); + to->rx_drop = atomic_read(&from->rx_drop); } static void subtract_aal_stats(struct k_atm_aal_stats *from, struct atm_aal_stats *to) { -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i) - __AAL_STAT_ITEMS -#undef __HANDLE_ITEM + atomic_sub(to->tx, &from->tx); + atomic_sub(to->tx_err, &from->tx_err); + atomic_sub(to->rx, &from->rx); + atomic_sub(to->rx_err, &from->rx_err); + atomic_sub(to->rx_drop, &from->rx_drop); } --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c @@ -831,7 +831,7 @@ static unsigned int br_nf_post_routing(u #ifdef CONFIG_NETFILTER_DEBUG print_error: if (skb->dev != NULL) { - printk("[%s]", skb->dev->name); + printk(KERN_DEBUG "[%s]", skb->dev->name); if (realoutdev) printk("[%s]", realoutdev->name); } --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -57,11 +57,11 @@ static void print_string(char *str) #define BUGPRINT(args) print_string(args); #else -#define BUGPRINT(format, args...) printk("kernel msg: ebtables bug: please "\ - "report to author: "format, ## args) +#define BUGPRINT(format, args...) printk(KERN_ERR "kernel msg: ebtables bug:" \ + " please report to author: "format, ## args) /* #define BUGPRINT(format, args...) */ #endif -#define MEMPRINT(format, args...) printk("kernel msg: ebtables "\ +#define MEMPRINT(format, args...) printk(KERN_ERR "kernel msg: ebtables "\ ": out of memory: "format, ## args) /* #define MEMPRINT(format, args...) */ --- a/net/bridge/netfilter/ebt_limit.c +++ b/net/bridge/netfilter/ebt_limit.c @@ -77,8 +77,8 @@ static int ebt_limit_check(const char *t /* Check for overflow. */ if (info->burst == 0 || user2credits(info->avg * info->burst) < user2credits(info->avg)) { - printk("Overflow in ebt_limit, try lower: %u/%u\n", - info->avg, info->burst); + printk(KERN_ERR "Overflow in ebt_limit, try lower: %u/%u\n", + info->avg, info->burst); return -EINVAL; } --- a/net/bridge/netfilter/ebt_log.c +++ b/net/bridge/netfilter/ebt_log.c @@ -68,8 +68,9 @@ ebt_log_packet(unsigned int pf, unsigned unsigned int bitmask; spin_lock_bh(&ebt_log_lock); - printk("<%c>%s IN=%s OUT=%s MAC source = ", '0' + loginfo->u.log.level, - prefix, in ? in->name : "", out ? out->name : ""); + printk(KERN_INFO "<%c>%s IN=%s OUT=%s MAC source = ", + '0' + loginfo->u.log.level, prefix, + in ? in->name : "", out ? out->name : ""); print_MAC(eth_hdr(skb)->h_source); printk("MAC dest = "); --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -3142,8 +3142,7 @@ static int pktgen_add_device(struct pktg /* We don't allow a device to be on several threads */ - pkt_dev = __pktgen_NN_threads(ifname, FIND); - if (pkt_dev) { + if (__pktgen_NN_threads(ifname, FIND)) { printk("pktgen: ERROR: interface already used.\n"); return -EBUSY; } --- a/net/ipv4/netfilter/ip_nat_standalone.c +++ b/net/ipv4/netfilter/ip_nat_standalone.c @@ -354,14 +354,46 @@ static struct nf_hook_ops ip_nat_adjust_ }; -static int init_or_cleanup(int init) +/* +** Note: This is used to clean up on unload +** but is also used in the init() error path +** to relinquish resources before exiting +*/ +static void cleanup(int clean_level) +{ + + switch (clean_level) { + + case 0: + nf_unregister_hook(&ip_nat_local_in_ops); + case 1: + nf_unregister_hook(&ip_nat_local_out_ops); + case 2: + nf_unregister_hook(&ip_nat_adjust_out_ops); + case 3: + nf_unregister_hook(&ip_nat_adjust_in_ops); + case 4: + nf_unregister_hook(&ip_nat_out_ops); + case 5: + nf_unregister_hook(&ip_nat_in_ops); + case 6: + ip_nat_rule_cleanup(); + case 7: +#ifdef CONFIG_XFRM + ip_nat_decode_session = NULL; + synchronize_net(); +#endif + break; + } +} + + +static int __init ip_nat_standalone_init(void) { int ret = 0; need_conntrack(); - if (!init) goto cleanup; - #ifdef CONFIG_XFRM BUG_ON(ip_nat_decode_session != NULL); ip_nat_decode_session = nat_decode_session; @@ -369,70 +401,50 @@ static int init_or_cleanup(int init) ret = ip_nat_rule_init(); if (ret < 0) { printk("ip_nat_init: can't setup rules.\n"); - goto cleanup_decode_session; + cleanup(7); + return ret; } ret = nf_register_hook(&ip_nat_in_ops); if (ret < 0) { printk("ip_nat_init: can't register in hook.\n"); - goto cleanup_rule_init; + cleanup(6); + return ret; } ret = nf_register_hook(&ip_nat_out_ops); if (ret < 0) { printk("ip_nat_init: can't register out hook.\n"); - goto cleanup_inops; + cleanup(5); + return ret; } ret = nf_register_hook(&ip_nat_adjust_in_ops); if (ret < 0) { printk("ip_nat_init: can't register adjust in hook.\n"); - goto cleanup_outops; + cleanup(4); + return ret; } ret = nf_register_hook(&ip_nat_adjust_out_ops); if (ret < 0) { printk("ip_nat_init: can't register adjust out hook.\n"); - goto cleanup_adjustin_ops; + cleanup(3); + return ret; } ret = nf_register_hook(&ip_nat_local_out_ops); if (ret < 0) { printk("ip_nat_init: can't register local out hook.\n"); - goto cleanup_adjustout_ops; + cleanup(2); + return ret; } ret = nf_register_hook(&ip_nat_local_in_ops); if (ret < 0) { printk("ip_nat_init: can't register local in hook.\n"); - goto cleanup_localoutops; + cleanup(1); } return ret; - - cleanup: - nf_unregister_hook(&ip_nat_local_in_ops); - cleanup_localoutops: - nf_unregister_hook(&ip_nat_local_out_ops); - cleanup_adjustout_ops: - nf_unregister_hook(&ip_nat_adjust_out_ops); - cleanup_adjustin_ops: - nf_unregister_hook(&ip_nat_adjust_in_ops); - cleanup_outops: - nf_unregister_hook(&ip_nat_out_ops); - cleanup_inops: - nf_unregister_hook(&ip_nat_in_ops); - cleanup_rule_init: - ip_nat_rule_cleanup(); - cleanup_decode_session: -#ifdef CONFIG_XFRM - ip_nat_decode_session = NULL; - synchronize_net(); -#endif - return ret; -} - -static int __init ip_nat_standalone_init(void) -{ - return init_or_cleanup(1); } static void __exit ip_nat_standalone_fini(void) { - init_or_cleanup(0); + cleanup(0); } module_init(ip_nat_standalone_init); --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -1265,27 +1265,29 @@ static int ircomm_tty_line_info(struct i ret += sprintf(buf+ret, "Port name: %s\n", self->settings.port_name); - ret += sprintf(buf+ret, "DTE status: "); - if (self->settings.dte & IRCOMM_RTS) - ret += sprintf(buf+ret, "RTS|"); - if (self->settings.dte & IRCOMM_DTR) - ret += sprintf(buf+ret, "DTR|"); - if (self->settings.dte) - ret--; /* remove the last | */ - ret += sprintf(buf+ret, "\n"); - - ret += sprintf(buf+ret, "DCE status: "); - if (self->settings.dce & IRCOMM_CTS) - ret += sprintf(buf+ret, "CTS|"); - if (self->settings.dce & IRCOMM_DSR) - ret += sprintf(buf+ret, "DSR|"); - if (self->settings.dce & IRCOMM_CD) - ret += sprintf(buf+ret, "CD|"); - if (self->settings.dce & IRCOMM_RI) - ret += sprintf(buf+ret, "RI|"); - if (self->settings.dce) - ret--; /* remove the last | */ - ret += sprintf(buf+ret, "\n"); + if (capable(CAP_SYS_RAWIO)) { + ret += sprintf(buf+ret, "DTE status: "); + if (self->settings.dte & IRCOMM_RTS) + ret += sprintf(buf+ret, "RTS|"); + if (self->settings.dte & IRCOMM_DTR) + ret += sprintf(buf+ret, "DTR|"); + if (self->settings.dte) + ret--; /* remove the last | */ + ret += sprintf(buf+ret, "\n"); + + ret += sprintf(buf+ret, "DCE status: "); + if (self->settings.dce & IRCOMM_CTS) + ret += sprintf(buf+ret, "CTS|"); + if (self->settings.dce & IRCOMM_DSR) + ret += sprintf(buf+ret, "DSR|"); + if (self->settings.dce & IRCOMM_CD) + ret += sprintf(buf+ret, "CD|"); + if (self->settings.dce & IRCOMM_RI) + ret += sprintf(buf+ret, "RI|"); + if (self->settings.dce) + ret--; /* remove the last | */ + ret += sprintf(buf+ret, "\n"); + } ret += sprintf(buf+ret, "Configuration: "); if (!self->settings.null_modem) @@ -1336,11 +1338,13 @@ static int ircomm_tty_line_info(struct i ret += sprintf(buf+ret, "Role: %s\n", self->client ? "client" : "server"); - ret += sprintf(buf+ret, "Open count: %d\n", self->open_count); + if (capable(CAP_SYS_RAWIO)) { + ret += sprintf(buf+ret, "Open count: %d\n", self->open_count); + } ret += sprintf(buf+ret, "Max data size: %d\n", self->max_data_size); ret += sprintf(buf+ret, "Max header size: %d\n", self->max_header_size); - if (self->tty) + if (self->tty && capable(CAP_SYS_RAWIO)) ret += sprintf(buf+ret, "Hardware: %s\n", self->tty->hw_stopped ? "Stopped" : "Running"); --- a/net/rxrpc/transport.c +++ b/net/rxrpc/transport.c @@ -559,9 +559,6 @@ void rxrpc_trans_receive_packet(struct r } kfree_skb(pkt); } - - _leave(""); - } /* end rxrpc_trans_receive_packet() */ /*****************************************************************************/ @@ -845,7 +842,4 @@ static void rxrpc_trans_receive_error_re rxrpc_put_peer(peer); } } - - _leave(""); - return; } /* end rxrpc_trans_receive_error_report() */ --- a/security/selinux/xfrm.c +++ b/security/selinux/xfrm.c @@ -281,7 +281,7 @@ u32 selinux_socket_getpeer_dgram(struct int i; for (i = sp->len-1; i >= 0; i--) { - struct xfrm_state *x = sp->x[i].xvec; + struct xfrm_state *x = sp->xvec[i]; if (selinux_authorizable_xfrm(x)) { struct xfrm_sec_ctx *ctx = x->security; return ctx->ctx_sid; @@ -314,7 +314,7 @@ int selinux_xfrm_sock_rcv_skb(u32 isec_s * Only need to verify the existence of an authorizable sp. */ for (i = 0; i < sp->len; i++) { - struct xfrm_state *x = sp->x[i].xvec; + struct xfrm_state *x = sp->xvec[i]; if (x && selinux_authorizable_xfrm(x)) goto accept; --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -372,10 +372,9 @@ static struct ops_list * create_driver(c { struct ops_list *ops; - ops = kmalloc(sizeof(*ops), GFP_KERNEL); + ops = kzalloc(sizeof(*ops), GFP_KERNEL); if (ops == NULL) return ops; - memset(ops, 0, sizeof(*ops)); /* set up driver entry */ strlcpy(ops->id, id, sizeof(ops->id)); --- a/sound/core/sgbuf.c +++ b/sound/core/sgbuf.c @@ -69,21 +69,18 @@ void *snd_malloc_sgbuf_pages(struct devi dmab->area = NULL; dmab->addr = 0; - dmab->private_data = sgbuf = kmalloc(sizeof(*sgbuf), GFP_KERNEL); + dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL); if (! sgbuf) return NULL; - memset(sgbuf, 0, sizeof(*sgbuf)); sgbuf->dev = device; pages = snd_sgbuf_aligned_pages(size); sgbuf->tblsize = sgbuf_align_table(pages); - sgbuf->table = kmalloc(sizeof(*sgbuf->table) * sgbuf->tblsize, GFP_KERNEL); + sgbuf->table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->table), GFP_KERNEL); if (! sgbuf->table) goto _failed; - memset(sgbuf->table, 0, sizeof(*sgbuf->table) * sgbuf->tblsize); - sgbuf->page_table = kmalloc(sizeof(*sgbuf->page_table) * sgbuf->tblsize, GFP_KERNEL); + sgbuf->page_table = kcalloc(sgbuf->tblsize, sizeof(*sgbuf->page_table), GFP_KERNEL); if (! sgbuf->page_table) goto _failed; - memset(sgbuf->page_table, 0, sizeof(*sgbuf->page_table) * sgbuf->tblsize); /* allocate each page */ for (i = 0; i < pages; i++) { --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include --- a/sound/oss/emu10k1/main.c +++ b/sound/oss/emu10k1/main.c @@ -119,7 +119,7 @@ /* the emu10k1 _seems_ to only supports 29 bit (512MiB) bit bus master */ -#define EMU10K1_DMA_MASK 0x1fffffff /* DMA buffer mask for pci_alloc_consist */ +#define EMU10K1_DMA_MASK DMA_29BIT_MASK /* DMA buffer mask for pci_alloc_consist */ #ifndef PCI_VENDOR_ID_CREATIVE #define PCI_VENDOR_ID_CREATIVE 0x1102 --- a/sound/oss/gus_wave.c +++ b/sound/oss/gus_wave.c @@ -1085,7 +1085,7 @@ static int guswave_set_instr(int dev, in { int sample_no; - if (instr_no < 0 || instr_no > MAX_PATCH) + if (instr_no < 0 || instr_no >= MAX_PATCH) instr_no = 0; /* Default to acoustic piano */ if (voice < 0 || voice > 31) @@ -1676,7 +1676,7 @@ static int guswave_load_patch(int dev, i instr = patch.instr_no; - if (instr < 0 || instr > MAX_PATCH) + if (instr < 0 || instr >= MAX_PATCH) { /* printk(KERN_ERR "GUS: Invalid patch number %d\n", instr);*/ return -EINVAL; --- a/sound/oss/msnd_pinnacle.c +++ b/sound/oss/msnd_pinnacle.c @@ -1397,36 +1397,34 @@ static int __init attach_multisound(void printk(KERN_ERR LOGNAME ": Couldn't grab IRQ %d\n", dev.irq); return err; } - request_region(dev.io, dev.numio, dev.name); + + if (!request_region(dev.io, dev.numio, dev.name)) { + printk(KERN_ERR LOGNAME ": Couldn't request_region\n"); + err = -EBUSY; + goto rr_fail; + } if ((err = dsp_full_reset()) < 0) { - release_region(dev.io, dev.numio); - free_irq(dev.irq, &dev); - return err; + goto dsp_fail; } if ((err = msnd_register(&dev)) < 0) { printk(KERN_ERR LOGNAME ": Unable to register MultiSound\n"); - release_region(dev.io, dev.numio); - free_irq(dev.irq, &dev); - return err; + goto dsp_fail; } if ((dev.dsp_minor = register_sound_dsp(&dev_fileops, -1)) < 0) { - printk(KERN_ERR LOGNAME ": Unable to register DSP operations\n"); - msnd_unregister(&dev); - release_region(dev.io, dev.numio); - free_irq(dev.irq, &dev); - return dev.dsp_minor; + printk(KERN_ERR LOGNAME ": Unable to register DSP" + " operations\n"); + err = dev.dsp_minor; + goto rs_fail; } if ((dev.mixer_minor = register_sound_mixer(&dev_fileops, -1)) < 0) { - printk(KERN_ERR LOGNAME ": Unable to register mixer operations\n"); - unregister_sound_mixer(dev.mixer_minor); - msnd_unregister(&dev); - release_region(dev.io, dev.numio); - free_irq(dev.irq, &dev); - return dev.mixer_minor; + printk(KERN_ERR LOGNAME ": Unable to register mixer" + " operations\n"); + err = dev.mixer_minor; + goto rsm_fail; } dev.ext_midi_dev = dev.hdr_midi_dev = -1; @@ -1438,6 +1436,16 @@ static int __init attach_multisound(void #endif return 0; + +rsm_fail: + unregister_sound_mixer(dev.mixer_minor); +rs_fail: + msnd_unregister(&dev); +dsp_fail: + release_region(dev.io, dev.numio); +rr_fail: + free_irq(dev.irq, &dev); + return err; } static void __exit unload_multisound(void) --- a/sound/pci/als300.c +++ b/sound/pci/als300.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -691,8 +692,8 @@ static int __devinit snd_als300_create(s if ((err = pci_enable_device(pci)) < 0) return err; - if (pci_set_dma_mask(pci, 0x0fffffff) < 0 || - pci_set_consistent_dma_mask(pci, 0x0fffffff) < 0) { + if (pci_set_dma_mask(pci, DMA_28BIT_MASK) < 0 || + pci_set_consistent_dma_mask(pci, DMA_28BIT_MASK) < 0) { printk(KERN_ERR "error setting 28bit DMA mask\n"); pci_disable_device(pci); return -ENXIO; --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c @@ -2658,7 +2658,7 @@ static void vortex_spdif_init(vortex_t * /* Initialization */ -static int vortex_core_init(vortex_t * vortex) +static int __devinit vortex_core_init(vortex_t * vortex) { printk(KERN_INFO "Vortex: init.... "); --- a/sound/pci/au88x0/au88x0_eq.c +++ b/sound/pci/au88x0/au88x0_eq.c @@ -885,7 +885,7 @@ static char *EqBandLabels[10] __devinitd }; /* ALSA driver entry points. Init and exit. */ -static int vortex_eq_init(vortex_t * vortex) +static int __devinit vortex_eq_init(vortex_t * vortex) { struct snd_kcontrol *kcontrol; int err, i; --- a/sound/pci/au88x0/au88x0.h +++ b/sound/pci/au88x0/au88x0.h @@ -19,7 +19,6 @@ #ifdef __KERNEL__ #include -#include #include #include #include @@ -277,14 +276,14 @@ static void vortex_Vort3D_InitializeSour #endif /* Driver stuff. */ -static int __devinit vortex_gameport_register(vortex_t * card); +static int vortex_gameport_register(vortex_t * card); static void vortex_gameport_unregister(vortex_t * card); #ifndef CHIP_AU8820 -static int __devinit vortex_eq_init(vortex_t * vortex); -static int __devexit vortex_eq_free(vortex_t * vortex); +static int vortex_eq_init(vortex_t * vortex); +static int vortex_eq_free(vortex_t * vortex); #endif /* ALSA stuff. */ -static int __devinit snd_vortex_new_pcm(vortex_t * vortex, int idx, int nr); -static int __devinit snd_vortex_mixer(vortex_t * vortex); -static int __devinit snd_vortex_midi(vortex_t * vortex); +static int snd_vortex_new_pcm(vortex_t * vortex, int idx, int nr); +static int snd_vortex_mixer(vortex_t * vortex); +static int snd_vortex_midi(vortex_t * vortex); #endif --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -1481,7 +1481,7 @@ void cs46xx_dsp_destroy_pcm_channel (str if (!pcm_channel->src_scb->ref_count) { cs46xx_dsp_remove_scb(chip,pcm_channel->src_scb); - snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot <= DSP_MAX_SRC_NR, + snd_assert (pcm_channel->src_slot >= 0 && pcm_channel->src_slot < DSP_MAX_SRC_NR, return ); ins->src_scb_slots[pcm_channel->src_slot] = 0; --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c @@ -801,11 +801,10 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; #ifdef PMAC_AMP_AVAIL if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { - struct awacs_amp *amp = kmalloc(sizeof(*amp), GFP_KERNEL); + struct awacs_amp *amp = kzalloc(sizeof(*amp), GFP_KERNEL); if (! amp) return -ENOMEM; chip->mixer_data = amp; - memset(amp, 0, sizeof(*amp)); chip->mixer_free = awacs_amp_free; awacs_amp_set_vol(amp, 0, 63, 63, 0); /* mute and zero vol */ awacs_amp_set_vol(amp, 1, 63, 63, 0); --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c @@ -258,10 +258,9 @@ int __init snd_pmac_daca_init(struct snd request_module("i2c-keywest"); #endif /* CONFIG_KMOD */ - mix = kmalloc(sizeof(*mix), GFP_KERNEL); + mix = kzalloc(sizeof(*mix), GFP_KERNEL); if (! mix) return -ENOMEM; - memset(mix, 0, sizeof(*mix)); chip->mixer_data = mix; chip->mixer_free = daca_cleanup; mix->amp_on = 1; /* default on */ --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -64,11 +64,10 @@ static int keywest_attach_adapter(struct if (strncmp(i2c_device_name(adapter), "mac-io", 6)) return 0; /* ignored */ - new_client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); + new_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); if (! new_client) return -ENOMEM; - memset(new_client, 0, sizeof(*new_client)); new_client->addr = keywest_ctx->addr; i2c_set_clientdata(new_client, keywest_ctx); new_client->adapter = adapter; --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -1316,10 +1316,9 @@ int __init snd_pmac_tumbler_init(struct request_module("i2c-keywest"); #endif /* CONFIG_KMOD */ - mix = kmalloc(sizeof(*mix), GFP_KERNEL); + mix = kzalloc(sizeof(*mix), GFP_KERNEL); if (! mix) return -ENOMEM; - memset(mix, 0, sizeof(*mix)); mix->headphone_irq = -1; chip->mixer_data = mix; --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -2260,10 +2260,9 @@ static int add_audio_endpoint(struct snd } /* create a new pcm */ - as = kmalloc(sizeof(*as), GFP_KERNEL); + as = kzalloc(sizeof(*as), GFP_KERNEL); if (! as) return -ENOMEM; - memset(as, 0, sizeof(*as)); as->pcm_index = chip->pcm_devs; as->chip = chip; as->fmt_type = fp->fmt_type;